86
2 Description of the Wolfram SystemModeler
Real y;
equation;
x=time - 1;
y=if noEvent(abs(x) > 0) then sin(x)/x else 1;
end GuardEval.
2.7 General Recommendations for Creating a Computer
Model
We formulate a few general recommendations for modeling in the WSM environment. They may come in handy to avoid some common problems.
• Debugging code based on equations, compared to debugging code based on algorithms, is very different, since it is impossible to add breakpoints, perform a stepby-step solution, etc. Therefore, try to create your model step by step, while conducting small test components of the whole model. If an error occurs, it will be
much easier to find it if the model is small.
• When creating components, use the Validate Class function described above to
test them. If the component check was successful, then it is likely that it will work
correctly with other components. A full-fledged component during verification
should always return the same number of variables and equations. Note that an
incomplete model often returns a different number of equations and variables.
• If the simulation takes a long time, this may be due to a large number of events.
The number of events can be found in the Simulation Log after it is completed.
If possible, try reducing the number of events using the noEvent operator or try
changing your model. Note that when simulating discrete systems, an event is
generated for each sample interval, which is normal.
• Try to avoid automatic adjustment of output intervals when modeling a familiar
system. Since the data is written to the file for each step of the solver, this can
significantly reduce the performance of the simulation of large systems. If you are
familiar with the model’s behavior, it is recommended to switch to a fixed number
of intervals for the output signal or use the interval duration setting instead.
References
1. Wolfram SystemModeler: https://www.wolfram.com/system-modeler/
2. Modelica: https://modelica.org/
3. OpenModelica: https://openmodelica.org/
4. M.V. Tiller, Modelica by Example: https://mbe.modelica.university/
5. S.A. Agafonov, T.V. Muratova, Obyknovennye differencialnye uravneniya: ucheb. posobie dlya
stud. vuzov. – Izdatelskij centr «Akademiya», Moscow (2008)
Précédent

- 99/274

Suivant