Skip to content

Commit

Permalink
cures modelica#3064 for 3.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
AHaumer committed Jul 20, 2019
1 parent faedcbe commit 8e55eea
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Modelica/Electrical/Analog/Basic.mo
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ package Basic "Basic electrical components"

model SaturatingInductor "Simple model of an inductor with saturation"
extends Modelica.Electrical.Analog.Interfaces.OnePort(i(start=0));
import Modelica.Constants.pi;
import Modelica.Constants.eps;
import Modelica.Constants.small;
parameter SI.Current Inom(start=1) "Nominal current";
parameter SI.Inductance Lnom(start=1)
"Nominal inductance at Nominal current";
Expand All @@ -311,15 +314,14 @@ package Basic "Basic electrical components"
protected
parameter SI.Current Ipar(start=Inom/10, fixed=false);
initial equation
(Lnom - Linf) = (Lzer - Linf)*Ipar/Inom*(Modelica.Constants.pi/2 -
Modelica.Math.atan(Ipar/Inom));
(Lnom - Linf)/(Lzer - Linf)=Ipar/Inom*(pi/2 - atan(Ipar/Inom));
equation
assert(Lzer > Lnom + Modelica.Constants.eps, "Lzer (= " + String(Lzer) +
") has to be > Lnom (= " + String(Lnom) + ")");
assert(Linf < Lnom - Modelica.Constants.eps, "Linf (= " + String(Linf) +
") has to be < Lnom (= " + String(Lnom) + ")");
(Lact - Linf)*i/Ipar = (Lzer - Linf)*noEvent(Modelica.Math.atan(i/Ipar));
Psi = Lact*i;
Lact = Linf + (Lzer - Linf)*(if noEvent(abs(i)/Ipar<small) then 1 else atan(i/Ipar)/(i/Ipar));
Psi = Linf*i + (Lzer - Linf)*Ipar*atan(i/Ipar);
v = der(Psi);
annotation (defaultComponentName="inductor",
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
Expand Down
49 changes: 49 additions & 0 deletions ModelicaTest/Electrical/Analog.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
within ModelicaTest.Electrical;
package Analog
extends Modelica.Icons.ExamplesPackage;
model TestSaturatingInductor
"Simple demo to show behaviour of SaturatingInductor component"
extends Modelica.Icons.Example;
import Modelica.Constants.pi;
parameter Modelica.SIunits.Inductance Lzer=10 "Inductance near current=0";
parameter Modelica.SIunits.Inductance Lnom=1 "Nominal inductance at Nominal current";
parameter Modelica.SIunits.Current Inom=1 "Nominal current";
parameter Modelica.SIunits.Inductance Linf=0.1 "Inductance at large currents";
parameter Modelica.SIunits.Current I=sqrt(2) "Source current (peak)";
Modelica.Electrical.Analog.Sources.RampCurrent rampCurrent(
I=2*I,
duration=1,
offset=-I)
annotation (Placement(transformation(
origin={-20,50},
extent={{10,-10},{-10,10}},
rotation=270)));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-30,10},{-10,30}})));
Modelica.Electrical.Analog.Basic.SaturatingInductor saturatingInductor(
Inom=Inom,
Lnom=Lnom/(2*pi),
Lzer=Lzer/(2*pi),
Linf=Linf/(2*pi),
i(fixed=false)) annotation (Placement(transformation(
origin={20,50},
extent={{-10,-10},{10,10}},
rotation=270)));
equation
connect(rampCurrent.p, ground.p)
annotation (Line(points={{-20,40},{-20,30}},
color={0,0,255}));
connect(ground.p, saturatingInductor.n)
annotation (Line(points={{-20,30},{20,30},{20,40}},color={0,0,255}));
connect(rampCurrent.n, saturatingInductor.p) annotation (Line(points={{-20,60},
{-20,70},{20,70},{20,60}}, color={0,0,255}));
annotation (
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}})),
experiment(Interval=0.001, Tolerance=1e-05),
Documentation(info="<html>
<p>This simple circuit uses the saturating inductor which has an inductance dependent on current.</p>
<p>Plot <code>saturatingInductor.Psi</code> versus <code>saturatingInductor.i</code></p>
</html>"));
end TestSaturatingInductor;
end Analog;
1 change: 1 addition & 0 deletions ModelicaTest/Electrical/package.order
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Analog
Machines
PowerConverters
QuasiStatic
Expand Down

0 comments on commit 8e55eea

Please sign in to comment.