Message Boards Message Boards

0
|
9057 Views
|
15 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How does the initialization process in WSM work?

Dear users of SystemModeler

I am trying to build a steady-state analysis module in Mathematica that will take a model from WSM to simulate a base cycle and extrapolate the final conditions to reach the steady-state fastly. I do not have any trouble in nonsingular systems where the number of differential equations matches the number of energy-storing elements. But I am having some problems extending my algorithm to singular systems like the one I have attached here.

In Mathematica, I have checked that the selected state variables are: {L1.i,c2.v} so I guested that it will suffice to give initial conditions for L1, but this is not the case. Instead, I got the following error:

"SystemModelSimulate::eva: The variables {L1.i} are computed from other variables,"

which is corroborated with the equation browser at the simulation center. The following equation may be found: L1.i = L3.i. Shouldn't it be the inverse assignation?

What is the right way to programmatically initialize this kind of system?

Also, can someone direct me to verify the circuit system approach that WSM used in the automated generation of equations.? Is it Modified Nodal Analysis? I cannot find this kind of documentation.

As always, I will appreciate any help you can give me.

Jesus

15 Replies

Dear members, I case some of you found these discussions related to your work. I found this link to the Mathematica documentation that helped me better understand the difficulties of directly initializing dynamical systems. https://reference.wolfram.com/language/tutorial/NDSolveDAE.html Very instructive!! Cheers Jesús

Hi Jesus,

Sorry, I wrote the wrong the name for the model, but I have edited the comment now. The steps are then:

1) Find the Modelica.Electrical.Machines.Examples.SynchronousInductionMachines.SMEE_Rectifier model in the class browser in Model Center.

2) Duplicate the model, by clicking it with the right button and selecting Duplicate. A window will open where you can give a name to this new model.

3) Go to the text view of this new model.

4) You'll find the declaration of the component

Modelica.Electrical.Machines.BasicMachines.SynchronousInductionMachines.SM_ElectricalExcited smee(...)

with a lot of modifications, here represented with ... .

5) Add the modification

idq_dr(each fixed = true)

to it, so you should end up with something like

Modelica.Electrical.Machines.BasicMachines.SynchronousInductionMachines.SM_ElectricalExcited smee(... ,  idq_dr(each fixed = true))

6) Simulate, with either Simulation Center or Mathematica, and you'll be able to set initial values for both smee.idq_dr[1] and smee.idq_dr[2].

POSTED BY: Sergio Vargas

Dear Sergio,

I am afraid I do not know where/how to add such modification. Looking at the element smee, I see that I can set phiMechanical or wMechanical, but not idq_dr.

can you be more explicit?

Jesus

Dear Jesus,

In this case, if you duplicate the Modelica.Electrical.Machines.Examples.SynchronousInductionMachines.SMEE_Rectifier model and add the modification

idq_dr(each fixed = true)

to the component

    Modelica.Electrical.Machines.BasicMachines.SynchronousInductionMachines.SM_ElectricalExcited smee

then you can provide initial values to both smee.idq_dr[1] and smee.idq_dr[2].

Sergio

POSTED BY: Sergio Vargas

Actually, there is technically not even a guarantee that there will be a choice at all; one can imagine using integration methods that don't perform reduction to ODE (state-space) form, or ODE forms where the equations used don't have a closed-form relation to the original equations of the model.

This is very clear thank you.

However, I still do not understand why SystemModeler cannot accept the initial values I am declaring in my example.

Thanks again.

Jesus

No, that is not possible, and there is no guarantee that two different Modelica tools (or two different versions of the same tool) will make the same choice of equations. Actually, there is technically not even a guarantee that there will be a choice at all; one can imagine using integration methods that don't perform reduction to ODE (state-space) form, or ODE forms where the equations used don't have a closed-form relation to the original equations of the model.

POSTED BY: Henrik Tidefelt

Is it possible at all, to always know which are the independent differential equations that systemmodeler is simulating?

Regards,

Jesus

Posted 3 years ago

Dear Sergio and Henrik, Looking into more complex systems but in the same subject, I have tried this with a SystemModeler example and I am again having trouble at initializing. I thought I understood before, but I did not. Please help.

Ex1 = SystemModel[
  "Modelica.Electrical.Machines.Examples.SynchronousInductionMachines.\
SMEE_Rectifier"]
Ex1["StateVariables", 
 Method -> {"Elimination" -> All, "ReduceIndex" -> True}]
Ex1["StateVariables"]
Ex1["Balanced"]
SystemModelSimulate[Ex1, {0, 1/50}, <|
  "InitialValues" -> {"capacitor1.v" -> 1, "smee.idq_dr[1]" -> 1}|>]

SystemModelSimulate::eva: The variables {smee.idq_dr[1]} are computed from other variables.

POSTED BY: Updating Name

Dear Jesus,

I'm glad to hear it's working out for you, although I must admit that I found it difficult to see through the computations in the notebook.

It is true that System Modeler doesn't include methods for finding periodic steady-state, so this is a nice examples of building functionality on top of System Modeler using Wolfram Language.

POSTED BY: Henrik Tidefelt

Dear Sergio and Henrik,

With the above help, I have written a simple routine to find the steady-state in a "singular" circuit. Note the option "To Steady State" (SimulationCenter) will not work for periodic responses (I think). The routine will be extended to the case of nonlinear circuits without much effort. My notebook and model are attached.

So my idea is that transient analysis tools such as SystemModeler may be the basis for the fast computation of the periodic steady-state in complex systems. Thus, taking advantage of the great detail with which SystemModeler and other transient analysis programs may represent dynamical systems.

Thanks again!

Jesus

Posted 3 years ago

Dear Henrik and Sergio

Thank you for your generous explanations. I think the setting "fixed" as true reduces my initialization problems. Yes, I think there is a bug in the report yielded by system["StateVariables"] However, to be honest, I still have to process all the information you gave me. I let you know more about it later on.

Best regards to you two.

Jesus

POSTED BY: Updating Name

Hi Jesus,

In the Mathematica side of your question, I believe you are using the SystemModel property "StateVariables" to find the states. To get a picture consistent with the full kernel action in System Modeler, you can use the Method option

SystemModel[model, "StateVariables", Method -> {"Elimination" -> All, "ReduceIndex" -> True}] 

which returns, for your model, L3.i and c2.v. We created a bug report to clarify the process of state classification further in the Mathematica side. Thanks for your input.

Sergio

POSTED BY: Sergio Vargas

Also, can someone direct me to verify the circuit system approach that WSM used in the automated generation of equations.? Is it Modified Nodal Analysis? I cannot find this kind of documentation.

There is no "circuit system approach" applied inside WSM. Instead, WSM – similar to other Modelica tools – relies on generic index reduction and state selection methods. The index reduction used in WSM is based on Pantelides' algorithm for consistent initialization, enhanced in various ways to avoid some of the pitfalls that the purely structural analysis of the basic algorithm would fall into.

POSTED BY: Henrik Tidefelt

In Mathematica, I have checked that the selected state variables are: {L1.i,c2.v} so I guested that it will suffice to give initial conditions for L1, but this is not the case. Instead, I got the following error:

"SystemModelSimulate::eva: The variables {L1.i} are computed from other variables,"

which is corroborated with the equation browser at the simulation center. The following equation may be found: L1.i = L3.i. Shouldn't it be the inverse assignation?

I'm surprised that you find this equation. The behavior I see is that when I right-click L1.i in the Experiment Browser and jump to one of the offered places in the Equation Browser, I get to the place where L3.i or der(L3.i) is solved, with a brief hint in the "Variables Solved in Block" area explaining that the two are related by an alias relation.

Anyway, I don't think one should read any causality ("assignation") into an equation presented like L1.i = L3.i, unless presented in a context where right-to-left can be taken for granted.

POSTED BY: Henrik Tidefelt

Dear Jesus,

I am part of the System Modeler development team, and will try to answer even though I don't consider myself one of the real "users of System Modeler".

To make sure we're on the same page, this is what I get when building the attached example:

Building "SteadyStateComputations.MartiExample" as experiment "temporary-experiment" started at 11:35:13 
Notification: interactive The following variables are selected as states: L3.i, c2.v
Notification: interactive The initialization problem is underdetermined, the following variables were chosen to be initialized from their start values: c2.v, L3.i
Notification: interactive C/C++ compiler output:
…

For some reason, I'm getting L3.i instead of L1.i as a state, and will return to this difference below.

In Model Center, I then set fixed = true for both L3.i and c2.v, and the result is a balanced initialization problem:

Building "SteadyStateComputations.MartiExample" as experiment "temporary-experiment" started at 11:39:28 
Notification: interactive The following variables are selected as states: L3.i, c2.v
Notification: interactive C/C++ compiler output:
…

That we don't get the same selection of states is in the nature of automatic state selection, and means that one generally have to find the right balance between fiddling with stateSelect in the models (not unlikely to end up getting in the way of the automatic state selection) and finding ways to cope with uncertainty about where the states are. The latter requires good tool support, and although there are situations where System Modeler could act more intelligently, an example of it working well is that I can set the fixed = true on L1.i instead, and the selection of states changes to make it straight-forward to respect this choice of initialization constraints instead:

Building "SteadyStateComputations.MartiExample" as experiment "temporary-experiment" started at 11:46:53 
Notification: interactive The following variables are selected as states: L1.i, c2.v

Note, that the fixed attribute is a so-called structural property of a model, meaning that it must be known at the time of translating the model, so if L3.i and c2.v were reported to be selected as states when the model was built, is is precisely where you find the two degrees of freedom in the initialization when looking at the Initial Values column of the Variables tab in Simulation Center.

POSTED BY: Henrik Tidefelt
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract