forked from modelica/ModelicaStandardLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provided by @maximo-privato
- Loading branch information
Showing
13 changed files
with
884 additions
and
0 deletions.
There are no files selected for viewing
184 changes: 184 additions & 0 deletions
184
Modelica/Electrical/Analog/Examples/Lines/CompareLineTrunks.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
within Modelica.Electrical.Analog.Examples.Lines; | ||
model CompareLineTrunks "Compares oLine and tLine splitting lines into trunks" | ||
extends Modelica.Icons.Example; | ||
import Modelica.Units.SI; | ||
import Modelica.Constants.small; | ||
parameter SI.Resistance Rload=1000 "Load resistance"; | ||
parameter Real r1(final min=small, unit="Ohm/m")=1e-6 "Resistance per meter"; | ||
parameter Real g1(final min=small, unit="S/m")=1e-12 "Conductance per meter"; | ||
parameter Real l1(final min=small, unit="H/m")=1e-6 "Inductance per meter"; | ||
parameter Real c1(final min=small, unit="F/m")=1e-11 "Capacitance per meter"; | ||
parameter SI.Length len=100e3 "Length of line"; | ||
parameter Integer segsPerTrunk=7 "Segments per trunk"; | ||
parameter SI.Velocity c=1/sqrt(l1*c1) "Speed of EM wave"; | ||
parameter SI.Time td=len/c/4 "Transmission delay"; | ||
parameter SI.Impedance z0=sqrt(l1/c1) "Characteristic impedance for very high frequency"; | ||
Modelica.Blocks.Sources.Ramp ramp(startTime=400e-6, duration=50e-6) | ||
annotation (Placement(transformation(extent={{-88,-10},{-68,10}}))); | ||
Modelica.Electrical.Analog.Sources.SignalVoltage srcLump annotation ( | ||
Placement(transformation( | ||
origin={-40,30}, | ||
extent={{-10,10},{10,-10}}, | ||
rotation=-90))); | ||
Modelica.Electrical.Analog.Basic.Ground ground1 annotation (Placement(transformation(extent={{-50,-10},{-30,10}}))); | ||
Modelica.Electrical.Analog.Lines.OLine oLine1( | ||
N=segsPerTrunk, | ||
r=r1, | ||
l=l1, | ||
g=g1, | ||
c=c1, | ||
length=len/4) annotation (Placement(transformation(extent={{-30,30},{-10,50}}))); | ||
Modelica.Electrical.Analog.Lines.OLine oLine2( | ||
N=segsPerTrunk, | ||
r=r1, | ||
l=l1, | ||
g=g1, | ||
c=c1, | ||
length=len/4) annotation (Placement(transformation(extent={{0,30},{20,50}}))); | ||
Modelica.Electrical.Analog.Lines.OLine oLine3( | ||
N=segsPerTrunk, | ||
r=r1, | ||
l=l1, | ||
g=g1, | ||
c=c1, | ||
length=len/4) annotation (Placement(transformation(extent={{30,30},{50,50}}))); | ||
Modelica.Electrical.Analog.Lines.OLine oLine4( | ||
N=segsPerTrunk, | ||
r=r1, | ||
l=l1, | ||
g=g1, | ||
c=c1, | ||
length=len/4) annotation (Placement(transformation(extent={{60,30},{80,50}}))); | ||
Modelica.Electrical.Analog.Basic.Resistor R1(R=Rload) annotation (Placement( | ||
transformation( | ||
origin={90,30}, | ||
extent={{-10,-10},{10,10}}, | ||
rotation=-90))); | ||
Modelica.Electrical.Analog.Sources.SignalVoltage srcDistr annotation ( | ||
Placement(transformation( | ||
origin={-40,-30}, | ||
extent={{-10,10},{10,-10}}, | ||
rotation=-90))); | ||
Basic.Ground ground2 annotation (Placement(transformation(extent={{-50,-70},{-30,-50}}))); | ||
Modelica.Electrical.Analog.Lines.TLine tLine1(Z0=z0, TD=td, | ||
er(start=0), | ||
v2(start=0)) annotation ( | ||
Placement(transformation(extent={{-30,-40},{-10,-20}}))); | ||
Modelica.Electrical.Analog.Lines.TLine tline2(Z0=z0, TD=td, | ||
er(start=0), | ||
v2(start=0)) annotation ( | ||
Placement(transformation( | ||
origin={32,4}, | ||
extent={{-32,-44},{-12,-24}}))); | ||
Modelica.Electrical.Analog.Lines.TLine tline3(Z0=z0, TD=td, | ||
er(start=0), | ||
v2(start=0)) annotation ( | ||
Placement(transformation( | ||
origin={62,4}, | ||
extent={{-32,-44},{-12,-24}}))); | ||
Modelica.Electrical.Analog.Lines.TLine tline4(Z0=z0, TD=td, | ||
er(start=0), | ||
v2(start=0)) annotation ( | ||
Placement(transformation( | ||
origin={92,4}, | ||
extent={{-32,-44},{-12,-24}}))); | ||
Modelica.Electrical.Analog.Basic.Resistor R2(R=Rload) annotation (Placement( | ||
transformation( | ||
origin={90,-30}, | ||
extent={{-10,-10},{10,10}}, | ||
rotation=-90))); | ||
initial equation | ||
oLine1.C.v=zeros(segsPerTrunk); | ||
oLine1.L.i=zeros(segsPerTrunk + 1); | ||
oLine2.C.v=zeros(segsPerTrunk); | ||
oLine2.L.i=zeros(segsPerTrunk + 1); | ||
oLine3.C.v=zeros(segsPerTrunk); | ||
oLine3.L.i=zeros(segsPerTrunk + 1); | ||
oLine4.C.v=zeros(segsPerTrunk); | ||
oLine4.L.i=zeros(segsPerTrunk + 1); | ||
equation | ||
connect(srcLump.v, ramp.y) | ||
annotation (Line(points={{-52,30},{-60,30},{-60,0},{-67,0}}, | ||
color={0,0,127})); | ||
connect(oLine1.p1, srcLump.p) annotation (Line(points={{-30,40},{-40,40}}, | ||
color={0,0,255})); | ||
connect(tLine1.p1, srcDistr.p) annotation ( | ||
Line(points={{-30,-20},{-40,-20}}, color={0,0,255})); | ||
connect(srcDistr.n, tLine1.n1) annotation ( | ||
Line(points={{-40,-40},{-30,-40}}, color={0,0,255})); | ||
connect(oLine1.p2, oLine2.p1) | ||
annotation (Line(points={{-10,40},{0,40}}, color={0,0,255})); | ||
connect(oLine2.p2, oLine3.p1) | ||
annotation (Line(points={{20,40},{30,40}},color={0,0,255})); | ||
connect(oLine3.p2, oLine4.p1) | ||
annotation (Line(points={{50,40},{60,40}}, color={0,0,255})); | ||
connect(oLine4.p2, R1.p) | ||
annotation (Line(points={{80,40},{90,40}}, color={0,0,255})); | ||
connect(srcDistr.v, ramp.y) annotation (Line(points={{-52,-30},{-60,-30},{-60, | ||
0},{-67,0}}, color={0,0,127})); | ||
connect(tline2.n1, tLine1.n2) annotation ( | ||
Line(points={{0,-40},{-10,-40}}, color={0,0,255})); | ||
connect(tline2.p1, tLine1.p2) annotation ( | ||
Line(points={{0,-20},{-10,-20}}, color={0,0,255})); | ||
connect(tline3.n1, tline2.n2) annotation ( | ||
Line(points={{30,-40},{20,-40}}, color={0,0,255})); | ||
connect(tline3.p1, tline2.p2) annotation ( | ||
Line(points={{30,-20},{20,-20}}, color={0,0,255})); | ||
connect(tline4.n1, tline3.n2) annotation ( | ||
Line(points={{60,-40},{50,-40}}, color={0,0,255})); | ||
connect(tline4.p1, tline3.p2) annotation ( | ||
Line(points={{60,-20},{50,-20}}, color={0,0,255})); | ||
connect(srcLump.n, ground1.p) | ||
annotation (Line(points={{-40,20},{-40,10}}, color={0,0,255})); | ||
connect(ground1.p, oLine1.p3) | ||
annotation (Line(points={{-40,10},{-20,10},{-20,30}}, color={0,0,255})); | ||
connect(ground1.p, oLine2.p3) | ||
annotation (Line(points={{-40,10},{10,10},{10,30}}, color={0,0,255})); | ||
connect(ground1.p, oLine3.p3) | ||
annotation (Line(points={{-40,10},{40,10},{40,30}}, color={0,0,255})); | ||
connect(ground1.p, oLine4.p3) | ||
annotation (Line(points={{-40,10},{70,10},{70,30}}, color={0,0,255})); | ||
connect(ground1.p, R1.n) | ||
annotation (Line(points={{-40,10},{90,10},{90,20}}, color={0,0,255})); | ||
connect(tline4.p2, R2.p) | ||
annotation (Line(points={{80,-20},{90,-20}}, color={0,0,255})); | ||
connect(tline4.n2, R2.n) | ||
annotation (Line(points={{80,-40},{90,-40}}, color={0,0,255})); | ||
connect(srcDistr.n, ground2.p) | ||
annotation (Line(points={{-40,-40},{-40,-50}}, color={0,0,255})); | ||
connect(ground2.p, tline2.n2) | ||
annotation (Line(points={{-40,-50},{20,-50},{20,-40}}, color={0,0,255})); | ||
connect(ground2.p, tline3.n2) | ||
annotation (Line(points={{-40,-50},{50,-50},{50,-40}}, color={0,0,255})); | ||
connect(ground2.p, tline4.n2) | ||
annotation (Line(points={{-40,-50},{80,-50},{80,-40}}, color={0,0,255})); | ||
connect(ground2.p, tLine1.n2) | ||
annotation (Line(points={{-40,-50},{-10,-50},{-10,-40}}, color={0,0,255})); | ||
annotation ( | ||
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{ | ||
100,100}})), | ||
Icon(coordinateSystem(extent={{-100,-100},{100,100}})), | ||
experiment(StopTime=0.004, Interval=4e-006, Tolerance=1e-06), | ||
Documentation(info="<html> | ||
<p>This example shows a way to look at the traveling wave moving along a power line.</p> | ||
<p>This wave can be seen looking at intermediate points of the line, looking at both OLine (several segments per line trunk) and TLine models.</p> | ||
<p>OLine in the lossless case is less accurate, since shows oscillations that are not present in a distributed parameter line but, | ||
since it allows the addition of resistances and conductances, allows evaluation of losses.</p> | ||
<p>Suggested tests:</p> | ||
<h4>7 segments per trunk, lossless</h4> | ||
<p>Run the model as it is. Since resistances and conductances are very small in OLine, the simulation is substantially lossless.</p> | ||
<p>Show in the same plot <code>ramp.y</code>, <code>oLine1.p2.v</code>, <code>oLine2.p2.v</code>, <code>oLine3.p2.v</code>, <code>oLine4.p2.v</code>.</p> | ||
<p>Show in another plot, simultaneously, <code>ramp.y</code>, <code>tLine1.p2.v</code>, <code>tLine2.p2.v</code>, <code>tLine3.p2.v</code>, <code>tLine4.p2.v</code>. Here oLine shows unreal oscillations, which, however, reduce if the number of segments per trunk increases.</p> | ||
<h4>50 segments per trunk, lossless</h4> | ||
<p>Try increasing this number from 7 to 50 using parameter <code>segsPerTrunk</code>, and look at the same plots as per test 1</p> | ||
<h4>50 segments per trunk, losses</h4> | ||
<p>Leave segsPerTrunk=50, change rl to 1e-3 ohms, re-simulate: the effect of losses is visible only on the oLine plot.</p> | ||
</html>", | ||
revisions="<html> | ||
<ul> | ||
<li><em>May, 2021</em> | ||
implemented by Massimo Ceraolo, University of Pisa | ||
</li> | ||
</ul> | ||
</html>")); | ||
end CompareLineTrunks; |
172 changes: 172 additions & 0 deletions
172
Modelica/Electrical/Analog/Examples/Lines/CompareLosslessLines.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
within Modelica.Electrical.Analog.Examples.Lines; | ||
model CompareLosslessLines | ||
"Compare lossless lines with different load" | ||
extends Modelica.Icons.Example; | ||
import Modelica.Units.SI; | ||
import Modelica.Constants.small; | ||
parameter Real l(final min=small, unit="H/m")=250e-9 "Inductance per meter"; | ||
parameter Real c(final min=small, unit="F/m")=100e-12 "Capacitance per meter"; | ||
parameter SI.Length len=1 "Length of line"; | ||
parameter SI.Velocity c0=1/sqrt(l*c) "Speed of EM wave"; | ||
parameter SI.Time td=len/c0 "Transmission delay"; | ||
parameter SI.Impedance z0=sqrt(l/c) "Characteristic impedance"; | ||
Sources.SignalVoltage source1 annotation (Placement(transformation( | ||
extent={{-10,10},{10,-10}}, | ||
rotation=270, | ||
origin={-30,60}))); | ||
Basic.Resistor ri1(R=z0) | ||
annotation (Placement(transformation(extent={{-20,60},{0,80}}))); | ||
Basic.Ground ground1 | ||
annotation (Placement(transformation(extent={{10,20},{30,40}}))); | ||
Modelica.Electrical.Analog.Lines.TLine line1(Z0=z0, TD=td, | ||
er(start=0), | ||
v2(start=0)) | ||
annotation (Placement(transformation(extent={{10,50},{30,70}}))); | ||
Ideal.Idle load1 annotation (Placement(transformation( | ||
extent={{-10,-10},{10,10}}, | ||
rotation=270, | ||
origin={48,60}))); | ||
Sources.SignalVoltage source2 annotation (Placement(transformation( | ||
extent={{-10,10},{10,-10}}, | ||
rotation=270, | ||
origin={-30,0}))); | ||
Basic.Resistor ri2(R=z0) | ||
annotation (Placement(transformation(extent={{-20,0},{0,20}}))); | ||
Basic.Ground ground2 | ||
annotation (Placement(transformation(extent={{10,-40},{30,-20}}))); | ||
Modelica.Electrical.Analog.Lines.TLine line2( | ||
Z0=z0, | ||
TD=td, | ||
er(start=0), | ||
v2(start=0)) | ||
annotation (Placement(transformation(extent={{10,-10},{30,10}}))); | ||
Basic.Resistor load2(R=z0) annotation (Placement(transformation( | ||
extent={{-10,-10},{10,10}}, | ||
rotation=270, | ||
origin={50,0}))); | ||
Sources.SignalVoltage source3 annotation (Placement(transformation( | ||
extent={{-10,10},{10,-10}}, | ||
rotation=270, | ||
origin={-30,-60}))); | ||
Basic.Ground ground3 | ||
annotation (Placement(transformation(extent={{10,-100},{30,-80}}))); | ||
Modelica.Electrical.Analog.Lines.TLine line3( | ||
Z0=z0, | ||
TD=td, | ||
er(start=0), | ||
v2(start=0)) | ||
annotation (Placement(transformation(extent={{10,-70},{30,-50}}))); | ||
Basic.Resistor ri3(R=z0) | ||
annotation (Placement(transformation(extent={{-20,-60},{0,-40}}))); | ||
Ideal.Short load3 annotation (Placement(transformation( | ||
extent={{-10,-10},{10,10}}, | ||
rotation=270, | ||
origin={50,-60}))); | ||
Blocks.Sources.Pulse pulse( | ||
amplitude=10, | ||
width=50, | ||
period=td, | ||
nperiod=1, | ||
startTime=td/2) | ||
annotation (Placement(transformation(extent={{-90,-10},{-70,10}}))); | ||
equation | ||
connect(source1.n, ground1.p) | ||
annotation (Line(points={{-30,50},{-30,40},{20,40}}, color={0,0,255})); | ||
connect(source1.n, line1.n1) | ||
annotation (Line(points={{-30,50},{10,50}}, color={0,0,255})); | ||
connect(line1.p2, load1.p) | ||
annotation (Line(points={{30,70},{48,70}}, color={0,0,255})); | ||
connect(line1.n2, load1.n) | ||
annotation (Line(points={{30,50},{48,50}}, color={0,0,255})); | ||
connect(source2.n, ground2.p) | ||
annotation (Line(points={{-30,-10},{-30,-20},{20,-20}}, color={0,0,255})); | ||
connect(source2.n, line2.n1) | ||
annotation (Line(points={{-30,-10},{10,-10}}, color={0,0,255})); | ||
connect(line2.p2, load2.p) | ||
annotation (Line(points={{30,10},{50,10}}, color={0,0,255})); | ||
connect(line2.n2, load2.n) | ||
annotation (Line(points={{30,-10},{50,-10}}, color={0,0,255})); | ||
connect(source3.n, ground3.p) | ||
annotation (Line(points={{-30,-70},{-30,-80},{20,-80}}, color={0,0,255})); | ||
connect(source3.n, line3.n1) | ||
annotation (Line(points={{-30,-70},{10,-70}}, color={0,0,255})); | ||
connect(line3.p2, load3.p) | ||
annotation (Line(points={{30,-50},{50,-50}}, color={0,0,255})); | ||
connect(line3.n2, load3.n) | ||
annotation (Line(points={{30,-70},{50,-70}}, color={0,0,255})); | ||
connect(pulse.y, source2.v) | ||
annotation (Line(points={{-69,0},{-42,0}}, color={0,0,127})); | ||
connect(pulse.y, source1.v) annotation (Line(points={{-69,0},{-60,0},{-60,60}, | ||
{-42,60}}, color={0,0,127})); | ||
connect(pulse.y, source3.v) annotation (Line(points={{-69,0},{-60,0},{-60,-60}, | ||
{-42,-60}}, color={0,0,127})); | ||
connect(load1.n, ground1.p) | ||
annotation (Line(points={{48,50},{48,40},{20,40}}, color={0,0,255})); | ||
connect(load2.n, ground2.p) | ||
annotation (Line(points={{50,-10},{50,-20},{20,-20}}, color={0,0,255})); | ||
connect(load3.n, ground3.p) | ||
annotation (Line(points={{50,-70},{50,-80},{20,-80}}, color={0,0,255})); | ||
connect(source1.p, ri1.p) | ||
annotation (Line(points={{-30,70},{-20,70}}, color={0,0,255})); | ||
connect(ri1.n, line1.p1) | ||
annotation (Line(points={{0,70},{10,70}}, color={0,0,255})); | ||
connect(source2.p, ri2.p) | ||
annotation (Line(points={{-30,10},{-20,10}}, color={0,0,255})); | ||
connect(ri2.n, line2.p1) | ||
annotation (Line(points={{0,10},{6,10},{6,10},{10,10}}, color={0,0,255})); | ||
connect(source3.p, ri3.p) | ||
annotation (Line(points={{-30,-50},{-20,-50}}, color={0,0,255})); | ||
connect(ri3.n, line3.p1) | ||
annotation (Line(points={{0,-50},{10,-50}}, color={0,0,255})); | ||
annotation ( | ||
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{ | ||
100,100}})), | ||
Icon(coordinateSystem(extent={{-100,-100},{100,100}})), | ||
experiment( | ||
StopTime=2e-08, | ||
Interval=1e-10, | ||
Tolerance=1e-06), | ||
Documentation(info="<html> | ||
<p> | ||
This example compares three lossless lines with different loads. | ||
Inductance per meter (l=250 nH/m) and capacitance per meter (c=100 pF/m) are estimated for an average coaxial cable with characteristic impedance z0=√(l/c)=50 Ω. | ||
The speed of the electromagnetic wave is given by c0=1/√(l*c)=2*10<sup>8</sup> m/s. Using a cable with a length of len=1 m, we obtain a delay td=len/c0=5 ns. | ||
The sources impress a single voltage pulse with height=10 V and lenght=td/2, starting at td/2. | ||
Due to the inner resistances of the sources ri=z0 the pulse at the input of the line (v1) has a height of 5 V. | ||
Simulate for 20 ns and compare for each of the lines: <code>v1, v2</code> and <code>i1, i2</code>. | ||
</p> | ||
<h4>1. load = idle</h4> | ||
<p> | ||
The voltage pulse at the beginning of the line (v1) starts at 2.5 ns and lasts for 2.5 ns. It arrives at 7.5 ns at the end of the line (v2), | ||
and is reflected giving a pulse of 10 V (superposition of arriving and reflected pulse). | ||
At 12.5 ns the reflected pulse arrives at the beginning of the line, with a height of 5 V (voltage divider of z0 and ri). | ||
Bear in mind that the source voltage is zero at that time, i.e. a short. | ||
The current at the end of the line (i2) is zero since the load is implemented as an idle. | ||
The current at the beginning of the line i1 is 5 V/z0=100 mA at 2.5 mA and 12.5 ns. | ||
</p> | ||
<h4>2. load = z0</h4> | ||
<p> | ||
The voltage pulse at the beginning of the line (v1) starts at 2.5 ns and lasts for 2.5 ns. It arrives at 7.5 ns at the end of the line (v2). | ||
Due to load resistance=z0 no reflection occurs. | ||
The current at the beginning of the line i1 is 5 V/z0=100 mA at 2.5 ns. | ||
The current at the end of the line i2 is -5 V/z0=100 mA at 7.5 ns. | ||
</p> | ||
<h4>3. load = short</h4> | ||
<p> | ||
The voltage pulse at the beginning of the line (v1) starts at 2.5 ns and lasts for 2.5 ns. | ||
Since the load is implemented as a short, the voltage at the end of the line (v2) is zero. | ||
This is possible due to a reflection with negative sign, i.e. the superposition of arriving and reflected pulse gives zero. | ||
The reflected voltage pulse arrives at 12.5 ns at the beginning of the line. | ||
The current pulse at the beginning of the line (i1) is 5 V/z0=100 mA at 2.5 ns. | ||
At the end of the line (i2) a reflection occurs at 7.5 ns giving a current pulse of 200 mA (superposition of arriving and reflected pulse). | ||
The reflected pulse (100 mA) arrives at 12.5 ns at the beginning of the line (i1). | ||
</p> | ||
</html>", | ||
revisions="<html> | ||
<ul> | ||
<li><em>May, 2021</em> | ||
implemented by Anton Haumer, Technical University of Applied Sciences Regensburg | ||
</li> | ||
</ul> | ||
</html>")); | ||
end CompareLosslessLines; |
Oops, something went wrong.