Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Nonlinear Inductor

Nonlinear Inductor

I have modeled a nonlinear inductor as a piece wise linear inductor, but when i simulate it by trapezoidal solver, it stops but using the DASSL, it is OK. I wonder if someone can help me to remove the problem.  the code for inductor and example is as below:

model NonlinearInductor
  import Modelica.SIunits.MagneticFlux;
//  extends Modelica.Electrical.Analog.Interfaces.OnePort;

  parameter Real T[:,2]=[-1.0015,-1200;-0.0015,-200;0,0;0.0015,200;1.0015,1200]
                                                                               "piecewiselinear current versus flux relation";
  parameter Integer nbPoints = size(T,1) "Number of interpolation points";
  Real m;  //Slop of line flux-Current; inductance
  MagneticFlux flux( start=0);
  Modelica.Electrical.Analog.Interfaces.PositivePin p annotation(
    Placement(visible = true, transformation(origin = {-94, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-94, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Interfaces.NegativePin n annotation(
    Placement(visible = true, transformation(origin = {94, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {94, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  p.i=-n.i;
  p.v-n.v =  noEvent(der(flux));     // Faraday's Low


algorithm
// Definition of Piecewise nonlinear inductance

if  p.i < T[2,1] then
   m     := ((T[1,2]-T[2,2])/(T[1,1]-T[2,1]));
   flux  :=  m  *  (p.i-T[1,1]) +  T[1,2];

  elseif p.i >= T[nbPoints-1,1] then
   m     := (( T[nbPoints-1,2]-T[nbPoints,2]) /(T[nbPoints-1,1]-T[nbPoints,1]));
   flux  := m*(p.i-T[nbPoints-1,1]) +  T[nbPoints-1,2];

  else
      for iter in 2:(nbPoints-2) loop
         if p.i >= T[iter,1] and p.i <T[iter+1,1] then
            m      := (( T[iter,2]-T[iter+1,2]) /(T[iter,1]-T[iter+1,1]));
            flux   := m*(p.i-T[iter,1]) +  T[iter,2];
         end if;
      end for;
end if;
annotation (
    Documentation(info = "<html>
<p>The linear inductor connects the branch voltage <em>v</em> with the branch current <em>i</em> by <em>v = L * di/dt</em>. The Inductance <em>L</em> is allowed to be positive, or zero.</p>

</html>", revisions = "<html>
<ul>
<li><em> 1998   </em>
     by Christoph Clauss<br> initially implemented<br>
     </li>
</ul>
</html>"),
    Icon(coordinateSystem(initialScale = 0.1), graphics={  Line(points = {{60, 0}, {90, 0}}, color = {0, 0, 255}), Line(points = {{-90, 0}, {-60, 0}}, color = {0, 0, 255}), Text(extent = {{-150, -40}, {150, -80}}, textString = "L=%L"), Line(points = {{-60, 0}, {-59, 6}, {-52, 14}, {-38, 14}, {-31, 6}, {-30, 0}}, color = {0, 0, 255}, smooth = Smooth.Bezier), Line(points = {{-30, 0}, {-29, 6}, {-22, 14}, {-8, 14}, {-1, 6}, {0, 0}}, color = {0, 0, 255}, smooth = Smooth.Bezier), Line(points = {{0, 0}, {1, 6}, {8, 14}, {22, 14}, {29, 6}, {30, 0}}, color = {0, 0, 255}, smooth = Smooth.Bezier), Line(points = {{30, 0}, {31, 6}, {38, 14}, {52, 14}, {59, 6}, {60, 0}}, color = {0, 0, 255}, smooth = Smooth.Bezier), Text(lineColor = {0, 0, 255}, extent = {{-150, 90}, {150, 50}}, textString = "%name"), Line(origin = {-0.1, -2.9}, points = {{-59.8995, 16.8995}, {60.1005, -11.1005}, {60.1005, -17.1005}, {60.1005, -17.1005}, {60.1005, -17.1005}}, color = {0, 0, 255}), Line(origin = {-60, 17}, points = {{0, 3}, {0, -3}}, color = {0, 0, 255})}),
    uses(Modelica(version="3.2.3")),
  experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.002));
end NonlinearInductor;




model NonlinearInductorTest
  Modelica.Electrical.Analog.Sources.CosineVoltage cosineVoltage1(V = 25e3 * sqrt(2), freqHz = 50, phase = 1.5707963267949) annotation(
    Placement(visible = true, transformation(origin = {-80, 20}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 1000e6) annotation(
    Placement(visible = true, transformation(origin = {-14, 20}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
    Placement(visible = true, transformation(origin = {-80, -12}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  NonlinearInductor nonlinearInductor1 annotation(
    Placement(visible = true, transformation(origin = {32, 18}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Analog.Basic.Capacitor capacitor1(C = 0.4e-9) annotation(
    Placement(visible = true, transformation(origin = {-50, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(nonlinearInductor1.n, ground1.p) annotation(
    Line(points = {{32, 8}, {32, 8}, {32, -2}, {-80, -2}, {-80, -2}}, color = {0, 0, 255}));
  connect(nonlinearInductor1.p, capacitor1.n) annotation(
    Line(points = {{32, 28}, {32, 28}, {32, 42}, {-40, 42}, {-40, 42}}, color = {0, 0, 255}));
  connect(ground1.p, resistor1.n) annotation(
    Line(points = {{-80, -2}, {-14, -2}, {-14, 10}, {-14, 10}, {-14, 10}}, color = {0, 0, 255}));
  connect(capacitor1.n, resistor1.p) annotation(
    Line(points = {{-40, 42}, {-14, 42}, {-14, 30}, {-14, 30}, {-14, 30}}, color = {0, 0, 255}));
  connect(capacitor1.p, cosineVoltage1.p) annotation(
    Line(points = {{-60, 42}, {-80, 42}, {-80, 30}, {-80, 30}}, color = {0, 0, 255}));
  connect(ground1.p, cosineVoltage1.n) annotation(
    Line(points = {{-80, -2}, {-80, 10}}, color = {0, 0, 255}));
  annotation(
    uses(Modelica(version = "3.2.2")),
    experiment(StartTime = 0, StopTime = 0.1, Tolerance = 1e-06, Interval = 1e-07));
end NonlinearInductorTest;

There are 0 guests and 0 other users also viewing this topic