Software control of simulation parameters
Working with models
Getting simulation settings
Before editing a model, open it using the open method. After editing, don’t forget to save the results with save.
To get the simulation settings use the public method get_param
engee.get_param(model)
engee.get_param("path")
engee.get_param("path", param)
-
If a model name is specified but no parameter name is specified, returns simulation settings for the selected model as a
ModelParameters
structure. -
If a parameter name is specified, it returns the parameter value.
All values of the model simulation settings can be passed to a variable:
m = "example_model"
Via engee.get_param("path", param)
you can output the value of a specific model parameter:
engee.get_param(m, :start_time) #выведет значение start_time
Changing model simulation settings
The public method set_param! is used
engee.set_param!(model_name, param...)
engee.set_param!(model_name, param)
engee.set_param!(model, param...)
engee.set_param!(model, param)
-
Updates the selected parameters of model
Model
withmodel_name
. -
Returns
nothing
. -
If a simulation settings structure is passed to
param
, the settings will be copied from it. -
If the parameters are invalid, it terminates with an appropriate error.
-
The structure of simulation settings is bound to a specific model - you can change the settings of the model directly by specifying the fields of the structure.
Output
engee.set_param!("model_1", "SolverName"=>"ode45", "StopTime"=>15)
param_1 = engee.get_param("model_1")::ModelParameters
engee.set_param!("model_2", param_1)
Updating block parameters
The public method set_param! is also used
engee.set_param!(block_path, params...)
engee.set_param!(block, params...)
engee.set_param!(block, block_params)
engee.set_param!(block_path, block_params)
-
Updates the selected block parameters.
-
If a parameter is changed that entails changes in the number of ports, or state, the number of ports and state are changed according to the passed parameter values.
-
Returns
nothing
. -
If a block settings structure is passed as the second parameter, parameters will be copied from it. If the parameters are incorrect, it is terminated with an error.
Changing model simulation settings using a structure
-
The simulation settings structure is linked to a specific model - you can change the model settings directly by specifying the structure fields.
Output
params = engee.get_param("newmodel_1")
# структура params привязана к конкретной model
params.FixedStep = 0.05
0.05
# аналогично `engee.set_param!(model, "FixedStep" => 0.05)
All public methods of programme management available in Engee are presented in the article Public methods of programme management. |