Ticket #5455: Test.mo

File Test.mo, 17.4 KB (added by massimo ceraolo, 7 years ago)
Line 
1package Test "PM SMA package"
2 //package Propulsion
3 extends Modelica.Icons.Package;
4 //end Propulsion;
5
6 package Support "Useful addtional models"
7 extends Modelica.Icons.Package;
8 // extends EHPowerTrain.Icons.SupportIcon;
9
10 model MTPAiLim "MTPA logic for a generic (anisotropic) machine"
11 // Non-Ascii Symbol to cause UTF-8 saving by Dymola: €
12 parameter Modelica.SIunits.Current Ipm = 1.5 "Permanent magnet current";
13 parameter Integer pp = 1 "Pole pairs";
14 parameter Modelica.SIunits.Resistance Rs = 0.02 "Stator resistance";
15 parameter Modelica.SIunits.Inductance Ld = 1 "Basic direct-axis inductance";
16 parameter Modelica.SIunits.Voltage Umax = 100 "Max rms voltage per phase to the motor";
17 parameter Modelica.SIunits.Current Ilim = 100 "max current (rms)";
18 Modelica.SIunits.Voltage Ulim = min(uDC / sqrt(3), UmaxPk) "tensione limite (fase-picco) fa attivare il deflussaggio;";
19 Modelica.SIunits.Angle gammaStar(start = 0);
20 // Real Is "corrente rapportata al valore nominale (es. rms/rms)";
21 Modelica.SIunits.Voltage Vd, Vq;
22 Modelica.SIunits.Current IdFF "Id FullFlux (i.e. before flux weaking evalation)";
23 Modelica.SIunits.Current IqFF "Iq FullFlux (i.e. before flux weaking evalation)";
24 Modelica.SIunits.Voltage VdFF "Vd FullFlux (i.e. before flux weaking evalation)";
25 Modelica.SIunits.Voltage VqFF "Vq FullFlux (i.e. before flux weaking evalation)";
26 Modelica.SIunits.Current IparkFF(start = 0) "Ipark amplitude FullFlux (i.e. before flux weaking evalation)";
27 Modelica.SIunits.Voltage VparkFF "Vpark amplitude FullFlux (i.e. before flux weaking evalation)";
28 // Real Ipark(start = 70) "Ipark amplitude (=sqrt(Id^2+Iq^2))";
29 Modelica.SIunits.Voltage Vpark "Vpark amplitude (=sqrt(Vd^2+Vq^2))";
30 Modelica.SIunits.AngularVelocity w = pp * wMech;
31 Modelica.SIunits.Current Id0, Iq0;
32 Real weakening, limiting;
33 Real overLoad;
34 Modelica.Blocks.Interfaces.RealInput torqueReq annotation(
35 Placement(transformation(extent = {{-140, 40}, {-100, 80}}), iconTransformation(extent = {{-140, 40}, {-100, 80}})));
36 Modelica.Blocks.Interfaces.RealInput wMech annotation(
37 Placement(transformation(extent = {{-140, -80}, {-100, -40}}), iconTransformation(extent = {{-140, -80}, {-100, -40}})));
38 Modelica.Blocks.Interfaces.RealOutput Id "direct-axix park current" annotation(
39 Placement(transformation(extent = {{100, 50}, {120, 70}}), iconTransformation(extent = {{100, 50}, {120, 70}})));
40 Modelica.Blocks.Interfaces.RealOutput Iq "quadrature-axis park current" annotation(
41 Placement(transformation(extent = {{100, -70}, {120, -50}}), iconTransformation(extent = {{100, -70}, {120, -50}})));
42 Modelica.Blocks.Interfaces.RealInput uDC "DC voltage" annotation(
43 Placement(transformation(extent = {{-140, -20}, {-100, 20}}), iconTransformation(extent = {{-140, -20}, {-100, 20}})));
44 Modelica.Blocks.Interfaces.RealOutput Ipark annotation(
45 Placement(visible = true, transformation(origin = {0, 110}, extent = {{-10, -10}, {10, 10}}, rotation = 90), iconTransformation(origin = {0, 110}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
46 protected
47 parameter Modelica.SIunits.Voltage UmaxPk = sqrt(2) * Umax "nominal voltage (peak per phase)";
48 parameter Real IsqLim = Ilim ^ 2 * 2;
49 protected
50 parameter Real Psi = Ipm * Ld "psi=Ipm*Ld";
51 equation
52 torqueReq = 1.5 * pp * Psi * IparkFF;
53 IdFF = 0;
54 IqFF = IparkFF;
55 VdFF = Rs * IdFF - w * Ld * IqFF;
56 VqFF = Rs * IqFF + w * (Psi + Ld * IdFF);
57 VparkFF = sqrt(VdFF ^ 2 + VqFF ^ 2);
58 if VparkFF < Ulim then
59 weakening = 0;
60 gammaStar = 0;
61 Id0 = IdFF;
62 Iq0 = IqFF;
63 Vd = VdFF;
64 Vq = VqFF;
65 Vpark = VparkFF;
66 else
67 weakening = 1;
68 Id0 = -Ipark * sin(gammaStar);
69 Iq0 = Ipark * cos(gammaStar);
70 Vd = Rs * Id - w * Ld * Iq;
71 Vq = Rs * Iq + w * (Psi + Ld * Id);
72 Vpark = sqrt(Vd ^ 2 + Vq ^ 2);
73 Vpark = Ulim;
74 end if;
75 if Id0 ^ 2 + Iq0 ^ 2 < IsqLim then
76 limiting = 0;
77 Id = Id0;
78 Iq = Iq0;
79 else
80 limiting = 1;
81 if IsqLim - Id0 ^ 2 > 0 then
82 overLoad = 0;
83 Id = Id0;
84 Iq = sqrt(IsqLim - Id0 ^ 2);
85 else
86 overLoad = 1;
87 Id = Id0;
88 Iq = Iq0;
89 end if;
90 end if;
91 torqueReq = 1.5 * pp * Psi * Ipark * cos(gammaStar);
92 annotation(
93 Icon(coordinateSystem(preserveAspectRatio = false, initialScale = 0.1), graphics = {Text(lineColor = {0, 0, 127}, extent = {{-98, -110}, {102, -146}}, textString = "%name"), Rectangle(lineColor = {0, 0, 127}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(lineColor = {0, 0, 127}, extent = {{-100, 26}, {100, -26}}, textString = "MTPAiL")}),
94 Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2})),
95 experiment(StartTime = 0, StopTime = 8, Tolerance = 0.0001, Interval = 0.0016),
96 Documentation(info = "<html>
97 <p>Performs a sychronous drive Maximum Torque Per Ampere (MTPA) control for isotropic and anisotropic machines</p>
98 </html>"));
99 end MTPAiLim;
100
101 model FromPark "Semplice PMM con modello funzionale inverter"
102 parameter Integer p "Number or pole pairs";
103 Modelica.Electrical.Machines.SpacePhasors.Blocks.FromSpacePhasor fromSpacePhasor annotation(
104 Placement(transformation(extent = {{60, 0}, {80, 20}})));
105 Modelica.Electrical.Machines.SpacePhasors.Blocks.Rotator rotator annotation(
106 Placement(transformation(extent = {{0, 6}, {20, 26}})));
107 Modelica.Blocks.Routing.Multiplex2 multiplex2_1 annotation(
108 Placement(transformation(extent = {{-40, 0}, {-20, 20}})));
109 Modelica.Blocks.Interfaces.RealOutput y[3] annotation(
110 Placement(transformation(extent = {{100, -10}, {120, 10}}), iconTransformation(extent = {{100, -10}, {120, 10}})));
111 Modelica.Blocks.Interfaces.RealInput Xd annotation(
112 Placement(transformation(extent = {{-140, 40}, {-100, 80}}), iconTransformation(extent = {{-140, 40}, {-100, 80}})));
113 Modelica.Blocks.Interfaces.RealInput Xq annotation(
114 Placement(transformation(extent = {{-140, -80}, {-100, -40}}), iconTransformation(extent = {{-140, -80}, {-100, -40}})));
115 Modelica.Blocks.Interfaces.RealInput phi annotation(
116 Placement(transformation(extent = {{-20, -20}, {20, 20}}, rotation = 90, origin = {0, -120}), iconTransformation(extent = {{-20, -20}, {20, 20}}, rotation = 90, origin = {0, -120})));
117 Modelica.Blocks.Math.Gain gain(k = -p) annotation(
118 Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {10, -50})));
119 Modelica.Blocks.Sources.Constant const annotation(
120 Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {50, -30})));
121 equation
122 connect(multiplex2_1.y, rotator.u) annotation(
123 Line(points = {{-19, 10}, {-10, 10}, {-10, 16}, {-2, 16}}, color = {0, 0, 127}, smooth = Smooth.None));
124 connect(fromSpacePhasor.u, rotator.y) annotation(
125 Line(points = {{58, 10}, {40, 10}, {40, 16}, {21, 16}}, color = {0, 0, 127}, smooth = Smooth.None));
126 connect(fromSpacePhasor.y, y) annotation(
127 Line(points = {{81, 10}, {94, 10}, {94, 0}, {110, 0}}, color = {0, 0, 127}, smooth = Smooth.None));
128 connect(multiplex2_1.u1[1], Xd) annotation(
129 Line(points = {{-42, 16}, {-60, 16}, {-60, 60}, {-120, 60}}, color = {0, 0, 127}, smooth = Smooth.None));
130 connect(multiplex2_1.u2[1], Xq) annotation(
131 Line(points = {{-42, 4}, {-60, 4}, {-60, -60}, {-120, -60}}, color = {0, 0, 127}, smooth = Smooth.None));
132 connect(rotator.angle, gain.y) annotation(
133 Line(points = {{10, 4}, {10, -39}}, color = {0, 0, 127}, smooth = Smooth.None));
134 connect(gain.u, phi) annotation(
135 Line(points = {{10, -62}, {10, -120}, {0, -120}}, color = {0, 0, 127}, smooth = Smooth.None));
136 connect(fromSpacePhasor.zero, const.y) annotation(
137 Line(points = {{58, 2}, {50, 2}, {50, -19}}, color = {0, 0, 127}, smooth = Smooth.None));
138 annotation(
139 Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}})),
140 experiment(StopTime = 5, Interval = 0.001),
141 Documentation(info = "<html>
142<p>Converts variables form Park into phase quantities</p>
143</html>"),
144 __Dymola_experimentSetupOutput,
145 Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(lineColor = {0, 0, 127}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(lineColor = {0, 0, 127}, extent = {{-96, 28}, {96, -26}}, textString = "P=>"), Text(lineColor = {0, 0, 255}, extent = {{-108, 150}, {102, 110}}, textString = "%name")}));
146 end FromPark;
147 annotation(
148 Icon(graphics = {Ellipse(extent = {{-36, 40}, {40, -36}}, lineColor = {0, 0, 0}), Line(points = {{4, 82}, {-6, 82}, {-10, 72}, {-24, 68}, {-34, 78}, {-46, 70}, {-42, 58}, {-54, 46}, {-66, 50}, {-74, 36}, {-66, 30}, {-68, 16}, {-78, 12}, {-78, 2}}, color = {0, 0, 0}, smooth = Smooth.None), Line(points = {{4, -78}, {-6, -78}, {-10, -68}, {-24, -64}, {-34, -74}, {-46, -66}, {-42, -54}, {-54, -42}, {-66, -46}, {-74, -32}, {-66, -26}, {-68, -12}, {-78, -8}, {-78, 2}}, color = {0, 0, 0}, smooth = Smooth.None), Line(points = {{2, -78}, {12, -78}, {16, -68}, {30, -64}, {40, -74}, {52, -66}, {48, -54}, {60, -42}, {72, -46}, {80, -32}, {72, -26}, {74, -12}, {84, -8}, {84, 2}}, color = {0, 0, 0}, smooth = Smooth.None), Line(points = {{2, 82}, {12, 82}, {16, 72}, {30, 68}, {40, 78}, {52, 70}, {48, 58}, {60, 46}, {72, 50}, {80, 36}, {72, 30}, {74, 16}, {84, 12}, {84, 2}}, color = {0, 0, 0}, smooth = Smooth.None)}));
149 end Support;
150
151 model iDriveiLim2
152 // extends Modelica.Icons.Example;
153 Modelica.Mechanics.Rotational.Components.Inertia inertia(J = 0.29, phi(fixed = true, start = 0), w(fixed = true, start = 0)) annotation(
154 Placement(visible = true, transformation(extent = {{72, -36}, {92, -16}}, rotation = 0)));
155 Modelica.Electrical.Analog.Basic.Ground ground annotation(
156 Placement(visible = true, transformation(extent = {{88, 12}, {108, 32}}, rotation = 0)));
157 Modelica.Electrical.Machines.BasicMachines.SynchronousInductionMachines.SM_PermanentMagnet smpm1(useDamperCage = false, Lmd = 1.91e-3, Lmq = 1.91e-3) annotation(
158 Placement(visible = true, transformation(extent = {{30, -36}, {50, -16}}, rotation = 0)));
159 Modelica.Electrical.Machines.Utilities.TerminalBox terminalBox1(terminalConnection = "Y") annotation(
160 Placement(visible = true, transformation(extent = {{30, -8}, {50, 12}}, rotation = 0)));
161 Modelica.Electrical.MultiPhase.Sources.SignalCurrent signalCurr1(final m = 3) annotation(
162 Placement(visible = true, transformation(origin = {40, 26}, extent = {{-10, 10}, {10, -10}}, rotation = 270)));
163 Modelica.Electrical.MultiPhase.Basic.Star star1(final m = 3) annotation(
164 Placement(visible = true, transformation(origin = {72, 36}, extent = {{10, -10}, {-10, 10}}, rotation = 180)));
165 Modelica.Blocks.Sources.Constant uDC(k = 200) annotation(
166 Placement(visible = true, transformation(extent = {{-96, 16}, {-76, 36}}, rotation = 0)));
167 Support.FromPark fromPark(p = smpm1.p) annotation(
168 Placement(visible = true, transformation(extent = {{-20, 16}, {0, 36}}, rotation = 0)));
169 Modelica.Electrical.Analog.Basic.Ground groundM1 annotation(
170 Placement(visible = true, transformation(origin = {14, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 270)));
171 Support.MTPAiLim myMTPA(Umax = 100, Ipm = smpm1.permanentMagnet.Ie, pp = smpm1.p, Rs = smpm1.Rs, Ld = smpm1.Lmd) annotation(
172 Placement(visible = true, transformation(extent = {{-48, 16}, {-28, 36}}, rotation = 0)));
173 Modelica.Blocks.Continuous.FirstOrder firstOrder1[3](T = 0.2e-4 * {1, 1, 1}) annotation(
174 Placement(visible = true, transformation(origin = {18, 26}, extent = {{-8, -8}, {8, 8}}, rotation = 0)));
175 Modelica.Blocks.Sources.Trapezoid tqRef(rising = 2, width = 2, period = 1e6, amplitude = 180, falling = 2, startTime = 1) annotation(
176 Placement(visible = true, transformation(extent = {{-96, -20}, {-76, 0}}, rotation = 0)));
177 Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque tRes(tau_nominal = -150, w_nominal(displayUnit = "rpm") = 157.07963267949) annotation(
178 Placement(visible = true, transformation(extent = {{118, -36}, {98, -16}}, rotation = 0)));
179 Modelica.Blocks.Continuous.Der der1 annotation(
180 Placement(visible = true, transformation(origin = {-38, -6}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
181 Modelica.Mechanics.Rotational.Sensors.AngleSensor angleS annotation(
182 Placement(visible = true, transformation(origin = {62, -42}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
183 equation
184 connect(angleS.flange, smpm1.flange) annotation(
185 Line(points = {{62, -32}, {62, -32}, {62, -32}, {62, -32}, {62, -26}, {50, -26}, {50, -26}}));
186 connect(angleS.phi, fromPark.phi) annotation(
187 Line(points = {{62, -53}, {26, -53}, {26, -53}, {-10, -53}, {-10, 14}, {-10, 14}, {-10, 14}, {-10, 14}}, color = {0, 0, 127}));
188 connect(der1.u, fromPark.phi) annotation(
189 Line(points = {{-26, -6}, {-10, -6}, {-10, 14}}, color = {0, 0, 127}));
190 connect(myMTPA.wMech, der1.y) annotation(
191 Line(points = {{-50, 20}, {-58, 20}, {-58, -6}, {-49, -6}}, color = {0, 0, 127}));
192 connect(inertia.flange_b, tRes.flange) annotation(
193 Line(points = {{92, -26}, {98, -26}}));
194 connect(tqRef.y, myMTPA.torqueReq) annotation(
195 Line(points = {{-75, -10}, {-66, -10}, {-66, 32}, {-50, 32}}, color = {0, 0, 127}));
196 connect(firstOrder1.y, signalCurr1.i) annotation(
197 Line(points = {{26.8, 26}, {33, 26}}, color = {0, 0, 127}));
198 connect(firstOrder1.u, fromPark.y) annotation(
199 Line(points = {{8.4, 26}, {1, 26}}, color = {0, 0, 127}));
200 connect(myMTPA.uDC, uDC.y) annotation(
201 Line(points = {{-50, 26}, {-75, 26}}, color = {0, 0, 127}));
202 connect(fromPark.Xd, myMTPA.Id) annotation(
203 Line(points = {{-22, 32}, {-27, 32}}, color = {0, 0, 127}));
204 connect(fromPark.Xq, myMTPA.Iq) annotation(
205 Line(points = {{-22, 20}, {-27, 20}}, color = {0, 0, 127}));
206 connect(groundM1.p, terminalBox1.starpoint) annotation(
207 Line(points = {{24, -2}, {31, -2}}, color = {0, 0, 255}));
208 connect(star1.pin_n, ground.p) annotation(
209 Line(points = {{82, 36}, {90, 36}, {90, 36}, {98, 36}, {98, 32}}, color = {0, 0, 255}));
210 connect(star1.plug_p, signalCurr1.plug_p) annotation(
211 Line(points = {{62, 36}, {40, 36}}, color = {0, 0, 255}));
212 connect(signalCurr1.plug_n, terminalBox1.plugSupply) annotation(
213 Line(points = {{40, 16}, {40, -2}}, color = {0, 0, 255}));
214 connect(terminalBox1.plug_sp, smpm1.plug_sp) annotation(
215 Line(points = {{46, -4}, {46, -16}}, color = {0, 0, 255}));
216 connect(terminalBox1.plug_sn, smpm1.plug_sn) annotation(
217 Line(points = {{34, -4}, {34, -16}}, color = {0, 0, 255}));
218 connect(inertia.flange_a, smpm1.flange) annotation(
219 Line(points = {{72, -26}, {50, -26}}));
220 annotation(
221 Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -60}, {120, 60}}), graphics = {Rectangle(origin = {2, -120}, lineColor = {238, 46, 47}, pattern = LinePattern.Dash, extent = {{2, 166}, {52, 130}}), Text(origin = {2, -120}, lineColor = {238, 46, 47}, pattern = LinePattern.Dash, extent = {{50, 172}, {6, 168}}, textString = "simulates inverter")}),
222 __Dymola_experimentSetupOutput,
223 Documentation(info = "<html><head></head><body><p>Az. brushless con controllo automatico per macchine ANISOTROPE&nbsp;</p><p>Il transitorio ha una prima fase a pieno flusso, poi interviene duna limiazione della tensione per effetto della uDC. Se portiamo la uDC a 400 V interviene la limitazione della tensione per limite di macchina.</p><p>Con Udc=200V non si può soddisfare tutta la richiesta di coppia per raggiunto limite di corrente</p><p>Con Udc=400V e limite di tensione dovuto alla macchina ci si avvicina di più alla possibilità di erogare tutta la coppia richiesta, ma si sbatte comunque nel limite di corrente.</p><ul>
224 </ul>
225 </body></html>"),
226 Icon(coordinateSystem(extent = {{-100, -60}, {120, 60}}, preserveAspectRatio = false)),
227 experiment(StartTime = 0, StopTime = 8, Tolerance = 0.0001, Interval = 0.001),
228 __OpenModelica_commandLineOptions = "");
229 end iDriveiLim2;
230 annotation(
231 uses(Modelica(version = "3.2.2")),
232 Icon(coordinateSystem(preserveAspectRatio = false, initialScale = 0.1)),
233 Documentation(info = "<html>
234<p>Library containing models of components, subsystems and full vehicle examples for simulation of electric and Hybrid vehicular power trains.</p>
235<p>A general description of the library composition and on how to use it effectively is in the compaion paper:</p>
236<p>M. Ceraolo &QUOT;Modelica Electric and hybrid power trains library&QUOT; submitted for publication at the 11th International Modelica Conference, 2015, September 21-23, Palais des congr&egrave;s de Versailles, 23-23 September, France</p>
237</html>"));
238end Test;