An important use for modeling and simulation is to improve a system design, usually before it is physically realized and manufactured. In this process it is customary to perform a number of simulations for different values of the design parameters, until a design has been obtained that best fulfills a given set of design criteria. To automate this process it is very useful if the simulation environment has programmable scripting facilities that provide the glue between optimization algorithms, executing simulations and various computational functions.
The following example demonstrates the solution of a small but non-trivial design optimization problem containing dynamic system simulations. First we define a Modelica model of a linear actuator with a spring damped stopping, as well as a first order system that will be used to generate a kind of "reference" response. The goal is to find a damping for the translational spring-damper that minimizes the deviation between the step response of the linear actuator system and the step response from our "reference" first order system.
See Section 15.7 in the Modelica Book
In this example we use the MathModelica environment with Mathematica as the scripting language providing the built-in optimization function FindMinimum. //??Change to OpenModelica
A LinearActuator model containing a spring damped connection to an anchoring point.
Consider the following model of a linear actuator, depicted in Figure 1, with a spring-damped connection to an anchoring point:
We first make a simulation of the step response for the above linear actuator with damping d=2 and store the result in the scripting language variable called resLinActFirst. Then we plot the simulated position of the sliding mass as a function of time to take a closer look at the response.
Plot of step response from the linear actuator.