WSMLink`
WSMLink`

WSMInitialValues

WSMInitialValues is being phased out in favor of the association key "InitialValues" in functions introduced experimentally in Version 11.3.

WSMInitialValues

is an option for functions such as WSMSimulate that specifies initial values for variables.

Details

  • Setting WSMInitialValues->{v1->a1,} sets initial values vi to ai in the simulation or model.
  • WSMInitialValues corresponds to the start property in the model.
  • Using WSMInitialValues for a simulation does not recompile the model.
  • WSMInitialValues takes the following values:
  • {v1a1,}set initial values for vi to ai
    {v1{a1,a2,},}run simulations in parallel, with initial values aj for vi
  • Each vi can be either a string or DotName.

Examples

open allclose all

Basic Examples  (4)

Load Wolfram SystemModeler Link:

Simulate with default initial values:

Modify x to have initial value 3:

Simulate with a range of initial values:

Vary the initial angles of the balls in the cradle:

The angles of the first and last ball in the cradle for different initial angles:

Create a model with a start value for a variable:

Scope  (8)

Simulate  (5)

WSMInitialValues is used to set initial values for variables in simulation:

WSMInitialValues can be used together with WSMParameterValues:

If a list is given for WSMInitialValues, multiple simulations are run in parallel:

Sweeps with multiple initial values changing can be done with lists of equal length:

Simulate all combinations of a parameter and an initial value:

Create Models  (3)

Create a model with a start value for a parameter:

With both a start value and an initial equation, the initial equation has higher priority:

Create a Modelica string representing a model with start values:

Applications  (2)

Find initial values to satisfy a condition on a final value:

Simulate a bouncing ball with a range of initial heights:

Pick out the simulations where the ball bounced 18 times:

Find initial heights of successful simulations:

Show drops in a plot:

Do a parallel sweep to fit a variable to experimental data for a rolling wheel:

Import and interpolate experimental data:

Simulate with initial values in the interval 1.9 to 2.3:

Find the total norm differences from simulations and experiment:

The plot shows that the second simulation, with a mass of 2, is closest to the experimental data:

Properties & Relations  (1)

Parameters can be set with the option WSMParameterValues:

Possible Issues  (2)

Some initial values are calculated and cannot be changed by WSMSimulate:

No message is generated when setting a parameter with WSMInitialValues:

Use WSMParameterValues to set parameters:

Neat Examples  (1)

Show height plots of balls dropped from different heights: