State Selection: Overview and Definitions

In most cases state selection should not concern the user and should be done automatically by Dymola. There are a number of times however when it is useful for the model developer to be able to influence the state selection. Using knowledge of the system being modelled, the state selection can be used:

  1. To improve accuracy
  2. To avoid inverting non-linear functions
  3. To select a less non-linear set of states
  4. Avoiding Dynamic state selection
  5. To guarantee the correct use of the reinit operator
  6. To prevent variables in sensors being selected as state variables
  7. To enable the user to have an auxiliary variable selected as a state

State Variables

A state variable is a variable within the set of equations which describes the state of a system in enough detail that the future behaviour of that system can be determined. For example: for 1D mechanical rotational components, state variables are usually defined as the rotational velocity and the rotational position of a flange, thermodynamic examples can include Temperature, Pressure and enthalpy.

A Real state variables is one that has been differentiated at least once within the model equations.

Dynamic States

Dynamic State Selection is where Dymola creates a number of lists of possible time states to be selected. In the event of singularities during the simulation, Dymola may change the state variables by selecting an alternative set of states from the lists. This may in turn cause CPU time penalties and has to be avoided for real-time simulation. To avoid dynamic state selection the user can manually control the selection of states through the component parameter dialog boxes within the model.

Dynamic state selection within a model is not supported when exporting code to c-code or for use on HIL systems.  This is because the advanced runtime routines associated with dynamic state selection are not included in the code generation for real time simulation and the time penalty associated with this approach would need to be avoided anyway.  Normal simulation of models in Simulink can use dynamic state simulation.

Selection of States

In Dymola, any variable defined with the type Real can use the state selection attribute; more details are given in Dymola 2012 User Manual Volume 2 section 8.4.2 the state select attribute pg. 311.

The state select attribute is set using the following syntax:

stateSelect=StateSelect.never
stateSelect=StateSelect.avoid
stateSelect=StateSelect.default
stateSelect=StateSelect.prefer
stateSelect=StateSelect.always
never Do not use it as a state at all
avoid Avoid it as state in favour of the having the default value
default If the variable does not appear differentiated in the model this means no
prefer Prefer it as state over those having the default value
Always Do use it as a state

Control of States

Within normal modelling activities, the selection of states should be automatic. To report the states being selected by Dymola, check the option list continuous time states selected in the translation tab of the simulation setup. This will list the states selected in the translation window. Or in the command window, enter the flag:

LogStateSelection:=true;

States should be selected that most effectively describe the state of the system for example a McPherson strut type suspension model may define the lower wishbone angle instead of one of the ball joints. States are likely to be picked in pairs i.e. effective states of a shaft would be its angular position and angular velocity.

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-2023 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?