Modifying evaluated parameters in multiple simulations

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.

Figure 1.  Variable Browser with parameters that can be modified without re-translation
Figure 1. Variable Browser with parameters that can be modified without re-translation

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.

Figure 2.  All the parameters are structural parameters and will be evaluated
Figure 2. All the parameters are structural parameters and will be evaluated

How can evaluated parameter be modified?

Evaluated parameters can be modified by using the following syntax:
modelName(component=value)

For example the following can be written in the Dymola command line:
simulateModel(problem=”StructuralParametersExample(n=2,twoNotThree=false,filename=\”data2.mat\”)”, resultFile=”StructuralParametersExample”);

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.

Figure 3.  Example of multiple simulations with evaluated parameters
Figure 3. Example of multiple simulations with evaluated parameters

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.

Conclusion

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

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2020 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?