Message Boards Message Boards

Initial position issues when updating to SystemModeler from 5.0 to 5.1

GROUPS:

I have recently updated SystemModeler from version 5.0 to 5.1 and now I have some issues with my model.

The first thing I noticed were new messages in the "Build log", the one that stands out the most being:

Notification: The initialization problem is underdetermined, the following variables where chosen to be initialized from their start values: ...

The model I have developed has many closed loops, that are correctly modelled in 5.0 with the appropriate selection of the state variables (using StateSelect). With the update to 5.1 the initial position is no longer correctly calculated, but it still works fine with 5.0.

Simulation works fine in 5.1 and 5.0, but 5.0 calculates correctly the initial position while 5.1 does not.

Can someone provide any insight for this?

POSTED BY: JOSE OLIVER
Answer
1 month ago

Jose,

WSM has to choose initial conditions. If you under constrain the problem, the selection is left to WSM. In 5.0 WSM chose different variables to constrain. I suggest you look at the list of variables that WSM reports that it reports were “initialized” to the start values and fix some or all of those by selecting “true” next to the initial value in the tab. This will force WSM to use that value. Usually fixing one variable does the trick.

Regards

Neil

POSTED BY: Neil Singer
Answer
1 month ago

Hi Neil,

I have been trying to fix the initialization values, it still finds the wrong initial solution. I have also tried to change the state variable selection, but it makes the simulation fail. I have tried different combinations of state variables and fixed initializations with no success.

POSTED BY: JOSE OLIVER
Answer
1 month ago

Jose,

I found the best way to track this down is to run your 5.0 simulation and note some initial values in simulation center. (Especially the variables cited by 5.1). Keep all the stateselect settings the same. Fix the start values one by one to the values recoded in WSM 5.0.

Is it a mechanical or electrical system? I found that electrical systems often have issues with initial currents in inductors. These almost always have to be set to zero and fixed (assuming that is your initial state).

In mechanical systems I found that initial positions can sometimes be incompatible. Also initial velocities may have to be pinned down for a loop.

If you are using the WSM 3D mechanics library there are some other settings that might help.

Can you post the model or at least describe what domain it’s in?

Regards

Neil

POSTED BY: Neil Singer
Answer
1 month ago

It is a mechanical system defined using the MulitBody mechanics library. I can't set any more initial position values to fixed otherwise the simulation fails.

Build log:

Warning: The initialization problem is structurally singular, error found sorting equations

Simulation Log:

[ERROR]: In initialization. System of initial equations is not consistent.

I am trying to pin down the initial velocities of loops to see if this might solve the problem.

POSTED BY: JOSE OLIVER
Answer
27 days ago

Neil,

5.0

[:0:0-0:0] Notification: Forcing static selection of states. If this leads to problems during simulation turn on dynamic state selection.

[:0:0-0:0] Notification: The following variables are selected as states: model.prismatic12.s, model.prismatic12.v, model.revolute23.phi, model.revolute23.w, model.revolute34.phi, model.revolute34.w, model.revolute45.phi, model.revolute45.w, position.phi, position.w, position1.s, position1.v

[:0:0-0:0] Warning: Start value is assigned for variable: model.prismatic12.s, but not used since it is solved from an equation or from a linear system..

...

5.1

[:0:0-0:0] Notification: Forcing static selection of states. If this leads to problems during simulation turn on dynamic state selection.

[:0:0-0:0] Notification: The following variables are selected as states: model.prismatic12.s, model.prismatic12.v, model.revolute23.phi, model.revolute23.w, model.revolute34.phi, model.revolute34.w, model.revolute45.phi, model.revolute45.w, position.phi, position.w, position1.s, position1.v

[:0:0-0:0] Notification: The initialization problem is underdetermined, the following variables where chosen to be initialized from their start values: model.revolute45.w, model.revolute34.w, model.revolute23.w, model.prismatic12.v, position1.v, position.w.

[:0:0-0:0] Warning: Start value is assigned for variable: model.prismatic12.s, but not used since it is solved from an equation or from a linear system..

...

Something changed in the algorithms behind the numerical integration from 5.0 to 5.1.

The good news is that I managed to fix it. It was not possible to fix initial values, but changing the initial guess value solved it.

The configuration of some closed loops in the model allow for two possible solutions, one in the upper half-plane and the other in the lower half-plane. I had an initial relative angle value for a revolute joint that was obtained from the Mathematica model, this value is the exact solution and it is double checked, it corresponded to the solution for the upper half-plane. This value was set as the initial guess for the revolute joint in the SystemModeler model, but it made the solver find the solution for the lower half-plane (which is really far away). Changing slightly the value made it find the upper half-plane solution again. Weird.

Regards,

Jose

POSTED BY: JOSE OLIVER
Answer
27 days ago

Hi Jose, good that you got it working.

Guess values can be a bit tricky. That a variable's start value is used as a guess value indicates that it is solved in a nonlinear system, typically together with other variables. Hence it is typically not only one variable's start value that matters, but several.

This is complicated further by the fact that the initialization is underdetermined, if WSM chooses different values to initialize exactly from their start values this might change which variables and equations are in the nonlinear system. This is one of the reason why we decided to add the "The initialization problem is underdetermined" notification in WSM 5.1.

You should be able to add fixed = true to the variables in the list shown in the "The initialization problem is underdetermined" notification. Your model's initialization should then be exactly determined (with the exception of nonlinear systems that might have more than one solution).

If you would like to fix other variables (whose initial values might be more relevant to change after build) you can try setting fixed = true to those instead (they don't need to be states). WSM will then try to set it up the way you requested, but if it can't you will get some kind of error or warning, like the ones you already saw or a warning that tells you that the initialization problem is overdetermined (which is typically undesirable). For complicated models I would suggest adding fixed = true one variable at a time, checking that you don't get any warnings or errors in the Build Log, then continue until it no longer says the initialization is underdetermined.

POSTED BY: Carl Jönsson
Answer
26 days ago

Thank you for your answer, Carl.

I will set all the variables from the initialization to fixed in order to completely determine the system.

In the past I had to fix the value of some variables in order to start at the desired location, but there is a limit to how many variables you can set before the problem becomes overdetermined.

The model is quite large and complicated, and it was kind of hard to make it all work together in version 5.0. I had a small panic attack when it failed to work in 5.1, it was a relief when it found the correct initial conditions again.

I would like to mention that I really appreciate the excellent job you are doing at Wolfram with SystemModeler.

Best regards,

Jose

POSTED BY: JOSE OLIVER
Answer
25 days ago

Group Abstract Group Abstract