State space equation obtained with Systemmodeler command

I use Boolean signals to control the opening and closing of the switch. The state space equation obtained by using the Systemmodeler command is inconsistent with the correct result. What is the reason? Or how did the number 100000 in the result come from?

  1. Buck circuit with Boolean switch

  1. State space equation with boolean switch

  1. Buck circuit without Boolean switch

  1. State space equation without Boolean switch (correct)

My code:

spacemodel = SystemModelLinearize["Model2", 
    Method -> {"SymbolicDerivative", 
        "SymbolicParameters" -> {"r", "l", "c", "k1", "k2"}}];
rule1 = {QuantityVariable["r", IndependentPhysicalQuantity[""]] -> r, 
   QuantityVariable["l", IndependentPhysicalQuantity[""]] -> l, 
   QuantityVariable["c", IndependentPhysicalQuantity[""]] -> c, 
   QuantityVariable["k1", IndependentPhysicalQuantity[""]] -> k1, 
   QuantityVariable["k2", IndependentPhysicalQuantity[""]] -> k2};
A = spacemodel[[1, 1]] /. rule1 // UnitSimplify // FullSimplify
B = spacemodel[[1, 2]] /. rule1 // UnitSimplify // FullSimplify

Model2.mo (4.47 KB)

The switch component that is used in this model actually has a non-zero conductance when the switch is open and a non-zero resistance when the switch is closed:

This is the origin of the odd 100000 term that you are seeing. You can use the component Modelica.Electrical.Analog.Ideal.Idle to represent a fully open circuit and a direct connection to represent 0 resistance.

Thank you, sir!