Dymola provides a number of methods for modifying parameters for multiple simulations, such as using the Sweep Parameters tool, using the simulateExtendedModel() function and using translateModel() and simulate() in a batch file. However, the methods as described above cannot be used to modify evaluated parameters. This blog looks at how evaluated parameters can be modified in a batch file so that multiple simulations can be run.
What is the difference between evaluated and non-evaluated parameters?
Typically parameters can be modified after the model is translated without having to re-translate the model for the new values to take effect. A simple way to determine if a parameter is not evaluated is to translate the model and check if it can be modified in the variable browser as in Figure 1.
When parameters are evaluated during translation then the parameter is replaced with the literal value and this value can no longer be modified without re-translating the model.
Why are parameters evaluated?
Parameters are evaluated if the annotation Evaluate=true is used, or if the Evaluate flag is set to true, or if they are top level parameters and Advanced.EvaluateAlsoTop is true. This is as long as the annotation Evaluate=false is not used. Also strings are evaluated if Advanced.AllowStringParameters is set to false; this flag is false by default.
If a parameter affects the structure of the translated model then it is also evaluated, that is if the parameter can change the number of equations in the model. Figure 2 contains a few examples of structural parameters.
How can evaluated parameter be modified?
Evaluated parameters can be modified by using the following syntax:
For example the following can be written in the Dymola command line:
Note that the problem input to simulateModel is a string.
An example of evaluated parameters being modified in a batch process
This method also works with the simulateExtendedModel() function and can be used in a batch file as in Figure 3.
The model was created by extending the model in Figure 2 and adding a real parameter a. The a parameter is set using simulateMultiExtendedModel() so that the model does not have to be re-translated between calls when modifying a. The n, twoNotThree and filename evaluated parameters are modified using modelName(component=value) type setting. The model will be re-translated when the evaluated parameters are modified.
This post shows how evaluated parameters can be modified in a way that can be supported by multiple runs.
Written by: Garron Fish – Chief Engineer
Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion