Obtain the initial value of inductance or capacitance set in Systemmodeler

How to obtain the initial value of inductance or capacitance set in Systemmodeler in Mathematica?

  1. initial value of inductance

2)initial value of capacitance

Then attach my circuit in the attachments.

Model2.mo (5.55 KB)

model = SystemModel[“Model2”];
model[{“InitialValues”, {“inductor1.i”, “capacitor1.v”}}]
You can load the model in Mathematica as a System Model, and use the “InitialValues” property.

Thank you very much! Your answer gave me inspiration. Now I have another small problem, the questions are as follows:

I use initvalueil and initvaluevc in the code to obtain the values of inductor1.i and capacitor1.v, but the initvalueil value contains a dot, which causes me to be unable to operate correctly in the subsequent code. Could you tell me how this dot comes from and how can I eliminate this dot?

My code:

model = SystemModel["Model2"];
init = model[{"InitialValues", {"inductor1.i", "capacitor1.v"}}]
initvalueil = init[[1, 2]]
initvaluevc = init[[2, 2]]

Model2.mo (5.55 KB)

You can use the following function to get the integer value:

IntegerPart[(*variable*)]

Thank you!!!

Sir, I tested it today and found that “the solution error was not caused by the dot in the initial value mentioned yesterday”, but that after I set the initial values of capacitance and inductance, the state space equation could not be obtained normally using the SystemModelLinearize command. How can we solve it?

My code:

spacemodel = SystemModelLinearize["Model2", 
   Method -> {"SymbolicDerivative", 
       "SymbolicParameters" -> {"r", "l", "c", "k1", "k2"}}]

Then attach my circuit in the attachments.

Model2.mo (5.54 KB)