Understanding State Selection in Multibody Simulation

Written by: Theodor Ensbury – Project Engineer

Unique to Modelica based tools, such as Dymola, state selection is a topic which affects every model produced which can manifest itself in several possible ways; a brief introduction and overview to the topic of state selection can be found here. Ever seen a multibody simulation initialise in an apparently illogical way, such as Figure 1? The most likely cause is incorrect state selection within the model. Ever seen a simulation fail to compile, generating an error message like Figure 2? Again, this is the topic of state selection at play. Ever seen a model translate with dynamic states and wonder what causes these to occur in some models? Once more state selection is the culprit. State selection affects the structure of the model to be solved so has a profound effect upon simulation performance.

Figure 1

Figure 1: Half car suspension rig experiment with poor state selection on the left, a comparable example with correct state selection on the right. An extreme case, the model on the left has initialised incorrectly and unsurprisingly, Dymola cannot compute a solution to the model as it tries to simulate it. The simulation subsequently fails.

Most of the time state selection should not concern the user as Dymola automatically undertakes the process. However, in some cases when building models, the user may encounter the incorrect or improper state selection or want to adjust it to improve simulation performance; this blog post serves to give a brief explanation regarding the topic so users have more of an understanding of what is happening when tweaking the state selection with their model.

Figure 2

Figure 2: Too many states have been selected by the user, making it impossible for Dymola to translate the model.

What is a state?

In Dymola, a state refers to what would be termed as a state variable in general parlance. This means a state is a variable within a system of equations which can describe the state of the system in enough detail to depict the behaviour of the system during the next time step. Dymola specifically defines when solving a model, automatically going through a process to determine what should be considered a state from its own determination and the state selection of the user. However, not all differential equations are selected as states by Dymola.

Therefore, in effect, a state can be considered a constraint equation on a model. However, it is more important to understand how Dymola uses these states within the process of symbolic manipulation, where a whole model is compiled in Modelica code from all the constituent models.

What are states used for within symbolic manipulation?

Dymola utilises states in two processes during symbolic manipulation, the balancing of equations within the model and a process known as “tearing”. When balancing equations, states can be used as ‘dummy derivatives’ to balance the ODE. The selection of which state is to be used as a dummy derivative depends on the variable declaration classification and the user controlled state selection parameter.

During tearing, Dymola will look to use states to assign to loops within a system to create a non-linear system of equations within a model. Therefore, state selection has a direct impact upon non-linear system formulation within a model.

What is dynamic state selection/what are dynamic states?

Dynamic state selection occurs when Dymola cannot compile a model with a single static set of states, having instead to switch between which equations are designated as states during simulation to solve the model. The states Dymola switches between are termed ‘dynamic states’, with those states which are continuously selected throughout the simulation known as ‘static states’. Consequently, simulation time suffers because of Dymola switching between states on the fly during simulation.  It is easy to identify if a model has dynamic states; simply interrogate the translation statistics, such as Figure 3.

Figure 3

Figure 3: Dynamic states present within a successfully translated model.

How can we use this information to our advantage?

If we apply this knowledge, common state selection related issues can be explained and understood better.

  • Simulation accuracy can be increased by manipulating states, as poor state selection can lead to numerically unstable and unsuitable models.
  • The typical error message in Figure 2, detailing “Too many variables are required to be states”, is caused when Dymola tried to conduct the symbolic manipulation during model compilation whilst containing too many states manually enforced by the user in the model.
  • Models initialising incorrectly and subsequently failing during simulation are often caused by state selection leading to the compilation of a non-valid model which Dymola is unable to find a solution to at a point in time. This will manifest itself with a “repeated error test failure” message such as the one shown in Figure 4.

Figure 4

Figure 4: Typical error message depicting a model failing a consequence of poor state selection. Dymola has reached a point where it is unable to compute a solution to the model.

  • User state selection settings directly affect the construction of the model. Therefore, it can be manually manipulated to remove formation and non-linear systems within a model to decrease the simulation time. Furthermore, overall simulation time will be increased if a model has initialised poorly, even if the simulation is successfully completed.

For more information about state selection, please see the Dymola User Manual Vol. 2, specifically section 8.4.






Log in with your credentials

Forgot your details?