Ticket #2960: Test35s.mo

File Test35s.mo, 188.3 KB (added by ceraolo, 8 years ago)
Line 
1within ;
2package Test35s "Electric and Hybrid Power train library Rev May 2016"
3  //Character to force UTF usage in Dymola: €
4  extends Modelica.Icons.Package;
5
6  package MapBased
7    "Contains map-based models of Internal combustion engines and electric drives"
8    extends Modelica.Icons.Package;
9
10    class Information
11      extends Modelica.Icons.Information;
12      annotation (Documentation(info="<html>
13<p>The map-based folder contains simple model whose only dynamics is due to their mechanical inertia.</p>
14<p>The ice model, since implemnts an Internal Combustion Engine, can deliber power, but never absorbs, while the other, two (&QUOT;oneFlange&QUOT; and &QUOT;twoFlange&QUOT;) simulate electric drive trains, i.e. the assembly of an electric machine and the corresponding ACDC converter, can absorb or deliver.</p>
15<p>The input torque of the ice model is in Newton-metres, whil e in the other cases it is normalised: it is between -1 and +1, where -1 means maximum available torque to be absorbed, +1 to be delivered.</p>
16<p>All the models come in two versions:</p>
17<ul>
18<li>version without &QUOT;Conn&QUOT; in the name: they get the input signals from a Real input connector. The input signal indicates a torque request.</li>
19<li>version with &QUOT;Conn&QUOT; in the name: they exchange several quantities through an expandable connector.</li>
20</ul>
21<p><br><u>Names and meaning </u>of the pre-defined quantities circulating through the connection bus in the model versions having &QUOT;Conn&QUOT; in their names.</p>
22<p>All the names are composed by two or three parts. The first one indicates the component to which the variable refers, (for instance &QUOT;ice&QUOT;) the central one which kind of variable it is (for instance &QUOT;tau&QUOT; means torque), finally the(optional) third part indicates info about de variable for instance &QUOT;del&QUOT; means delivered, i.e.for a power a positivive value indicates that the power is delivered to the outside by the component the variable belongs to, the opposite happens when the third part of the name in &QUOT;abs&QUOT; (stands for absorbed). Another exmple is &QUOT;Norm&QUOT;: this third part of a name indicates that the correspondng quantity is normalised (see above in this info).</p>
23<p><br><u>Full list</u> of the variables defined or used in the component of the MAP-based folder (other names that are used in the bus in the FullVehicle Examples, will be discussed in the examples themselves):</p>
24<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\"><tr>
25<td valign=\"top\"><p><br><i>Nome</i> </p></td>
26<td valign=\"top\"><p>sender </p></td>
27<td valign=\"top\"><p>users </p></td>
28<td valign=\"top\"><p>comment</p></td>
29</tr>
30<tr>
31<td valign=\"top\"><p>iceTauRef </p></td>
32<td valign=\"top\"></td>
33<td valign=\"top\"><p><br>Ice</p></td>
34<td valign=\"top\"><p>torque reference sent to ice through Conn (Nm)</p></td>
35</tr>
36<tr>
37<td valign=\"top\"><p>icePowDel</p></td>
38<td valign=\"top\"><p>Ice</p></td>
39<td valign=\"top\"><p> </p></td>
40<td valign=\"top\"><p>the mechanical power the ice delivers</p></td>
41</tr>
42<tr>
43<td valign=\"top\"><p>iceW</p></td>
44<td valign=\"top\"><p>Ice</p></td>
45<td valign=\"top\"></td>
46<td valign=\"top\"><p><br>ice rotational speed (rad/s)</p></td>
47</tr>
48<tr>
49<td valign=\"top\"><p>genTauNorm</p></td>
50<td valign=\"top\"></td>
51<td valign=\"top\"><p><br>OneFlange</p></td>
52<td valign=\"top\"><p>normalised torque OneFlange  must deliver</p><p>It is used in examples in which OneFlange Instance is called &QUOT;gen&QUOT;</p></td>
53</tr>
54<tr>
55<td valign=\"top\"><p>genTauLim</p></td>
56<td valign=\"top\"><p>OneFlange</p></td>
57<td valign=\"top\"></td>
58<td valign=\"top\"><p><br>maximum (limit) torque OneFlance must deliver</p><p><br>It is used in examples in which OneFlange Instance is called &QUOT;gen&QUOT;</p></td>
59</tr>
60<tr>
61<td valign=\"top\"></td>
62<td valign=\"top\"></td>
63<td valign=\"top\"></td>
64<td valign=\"top\"></td>
65</tr>
66<tr>
67<td valign=\"top\"></td>
68<td valign=\"top\"></td>
69<td valign=\"top\"></td>
70<td valign=\"top\"></td>
71</tr>
72<tr>
73<td valign=\"top\"></td>
74<td valign=\"top\"></td>
75<td valign=\"top\"></td>
76<td valign=\"top\"></td>
77</tr>
78<tr>
79<td valign=\"top\"></td>
80<td valign=\"top\"></td>
81<td valign=\"top\"></td>
82<td valign=\"top\"></td>
83</tr>
84<tr>
85<td valign=\"top\"></td>
86<td valign=\"top\"></td>
87<td valign=\"top\"></td>
88<td valign=\"top\"></td>
89</tr>
90<tr>
91<td valign=\"top\"></td>
92<td valign=\"top\"></td>
93<td valign=\"top\"></td>
94<td valign=\"top\"></td>
95</tr>
96<tr>
97<td valign=\"top\"></td>
98<td valign=\"top\"></td>
99<td valign=\"top\"></td>
100<td valign=\"top\"></td>
101</tr>
102</table>
103</html>"), uses(Modelica(version="3.2.1")));
104    end Information;
105
106    model MBiceConnP
107      "Simple map-based ice model with connector; follows power request"
108      extends Partial.PartialMBiceP;
109      import Modelica.Constants.*;
110      parameter Real vMass=1300;
111      parameter Real wIceStart=167;
112      // rad/s
113      SupportModels.Conn conn annotation (Placement(
114          visible=true,
115          transformation(extent={{-20,-78},{20,-118}}, rotation=0),
116          iconTransformation(extent={{-20,-78},{20,-118}}, rotation=0)));
117      Modelica.Blocks.Continuous.Integrator tokgFuel(k=1/3.6e6) annotation (
118          Placement(visible=true, transformation(
119            origin={28,-70},
120            extent={{-10,-10},{10,10}},
121            rotation=-90)));
122      Modelica.Blocks.Math.Product product1 annotation (Placement(visible=true,
123            transformation(
124            origin={28,-40},
125            extent={{-10,-10},{10,10}},
126            rotation=-90)));
127    equation
128      connect(tokW.y, product1.u2) annotation (Line(points={{-18,-29},{-18,-29},
129              {-18,-36},{10,-36},{10,-20},{22,-20},{22,-28},{22,-28}}, color={0,
130              0,127}));
131      connect(feedback.u1, conn.icePowRef) annotation (Line(points={{-88,52},{-92,
132              52},{-92,-98},{0,-98}}, color={0,0,127}), Text(
133          string="%second",
134          index=1,
135          extent={{6,3},{6,3}}));
136      connect(Pice.power, conn.icePowDel) annotation (Line(points={{68,63},{68,
137              63},{68,6},{78,6},{78,-98},{0,-98}}, color={0,0,127}), Text(
138          string="%second",
139          index=1,
140          extent={{6,3},{6,3}}));
141      connect(w.w, conn.iceW) annotation (Line(points={{58,25},{58,25},{58,6},{
142              58,-98},{0,-98}}, color={0,0,127}), Text(
143          string="%second",
144          index=1,
145          extent={{6,3},{6,3}}));
146      connect(product1.u1, toGramsPerkWh.y) annotation (Line(points={{34,-28},{
147              34,-20},{42,-20},{42,-13}}, color={0,0,127}));
148      connect(tokgFuel.u, product1.y) annotation (Line(points={{28,-58},{28,-51},
149              {28,-51}}, color={0,0,127}));
150      annotation (
151        Diagram(coordinateSystem(
152            preserveAspectRatio=false,
153            initialScale=0.1,
154            extent={{-100,-100},{100,100}})),
155        experiment(
156          StopTime=200,
157          __Dymola_NumberOfIntervals=1000,
158          __Dymola_Algorithm="Lsodar"),
159        __Dymola_experimentSetupOutput,
160        Documentation(info="<html>
161<p><b><span style=\"font-family: MS Shell Dlg 2;\">Simple map-based ICE model for power-split power trains - with connector</span></b> </p>
162<p><span style=\"font-family: MS Shell Dlg 2;\">This is a &QUOT;connector&QUOT; version of MBiceP.</span></p>
163<p><span style=\"font-family: MS Shell Dlg 2;\">For a general descritiption see the info of MBiceP.</span></p>
164<p><span style=\"font-family: MS Shell Dlg 2;\">Signals connected to the connector:</span></p>
165<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowRef (input) is the power request (W). Negative values are internally converted to zero</span></p>
166<p><span style=\"font-family: MS Shell Dlg 2;\">- iceW (output) is the measured ICE speed (rad/s)</span></p>
167<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowDel (output) delivered power (W)</span></p>
168</html>"),
169        Icon(coordinateSystem(
170            extent={{-100,-100},{100,100}},
171            preserveAspectRatio=false,
172            initialScale=0.1,
173            grid={2,2})),
174        uses(Modelica(version="3.2.2")));
175    end MBiceConnP;
176
177    model MBiceConnOO
178      "Simple map-based ice model with connector; follows power request with ON-OFF"
179      extends Partial.PartialMBiceP;
180      import Modelica.Constants.*;
181      parameter Real vMass=1300;
182      parameter Real wIceStart=167;
183      // rad/s
184      SupportModels.Conn conn annotation (Placement(
185          visible=true,
186          transformation(extent={{-20,-78},{20,-118}}, rotation=0),
187          iconTransformation(extent={{-20,-78},{20,-118}}, rotation=0)));
188      Modelica.Blocks.Continuous.Integrator tokgFuel(k=1/3.6) annotation (
189          Placement(visible=true, transformation(
190            origin={38,-76},
191            extent={{-10,-10},{10,10}},
192            rotation=-90)));
193      Modelica.Blocks.Logical.Switch switch1 annotation (Placement(visible=true,
194            transformation(
195            origin={2,-46},
196            extent={{-10,-10},{10,10}},
197            rotation=0)));
198      Modelica.Blocks.Sources.Constant zero(k=0) annotation (Placement(visible=
199              true, transformation(extent={{-46,-74},{-26,-54}}, rotation=0)));
200      Modelica.Blocks.Math.Product toG_perHour annotation (Placement(visible=
201              true, transformation(
202            origin={38,-42},
203            extent={{-10,-10},{10,10}},
204            rotation=-90)));
205    equation
206      connect(toG_perHour.u1, toGramsPerkWh.y) annotation (Line(points={{44,-30},
207              {42,-30},{42,-13},{42,-13}}, color={0,0,127}));
208      connect(switch1.y, toG_perHour.u2) annotation (Line(points={{13,-46},{20,
209              -46},{20,-22},{32,-22},{32,-30},{32,-30}}, color={0,0,127}));
210      connect(toG_perHour.y, tokgFuel.u) annotation (Line(points={{38,-53},{38,
211              -53},{38,-64},{38,-64}}, color={0,0,127}));
212      connect(tokW.y, switch1.u1) annotation (Line(points={{-18,-29},{-18,-29},
213              {-18,-38},{-10,-38},{-10,-38}}, color={0,0,127}));
214      connect(switch1.u3, zero.y) annotation (Line(points={{-10,-54},{-18.5,-54},
215              {-18.5,-64},{-25,-64}}, color={0,0,127}));
216      connect(switch1.u2, conn.iceON) annotation (Line(points={{-10,-46},{-60,-46},
217              {-60,-82},{0,-82},{0,-98}}, color={255,0,255}));
218      connect(feedback.u1, conn.icePowRef) annotation (Line(points={{-88,52},{-88,
219              52},{-88,-98},{0,-98}}, color={0,0,127}), Text(
220          string="%second",
221          index=1,
222          extent={{6,3},{6,3}}));
223      connect(Pice.power, conn.icePowDel) annotation (Line(points={{68,63},{68,
224              63},{68,6},{78,6},{78,-98},{0,-98}}, color={0,0,127}), Text(
225          string="%second",
226          index=1,
227          extent={{6,3},{6,3}}));
228      connect(w.w, conn.iceW) annotation (Line(points={{58,25},{58,25},{58,6},{
229              58,-98},{0,-98}}, color={0,0,127}), Text(
230          string="%second",
231          index=1,
232          extent={{6,3},{6,3}}));
233      annotation (
234        Diagram(coordinateSystem(
235            preserveAspectRatio=false,
236            initialScale=0.1,
237            extent={{-100,-100},{100,100}})),
238        experiment(
239          StopTime=200,
240          __Dymola_NumberOfIntervals=1000,
241          __Dymola_Algorithm="Lsodar"),
242        __Dymola_experimentSetupOutput,
243        Documentation(info="<html>
244<p><b><span style=\"font-family: MS Shell Dlg 2;\">Simple map-based ICE model for power-split power trains - with connector</span></b> </p>
245<p><span style=\"font-family: MS Shell Dlg 2;\">This is a &QUOT;connector&QUOT; version of MBiceP.</span></p>
246<p><span style=\"font-family: MS Shell Dlg 2;\">For a general descritiption see the info of MBiceP.</span></p>
247<p><span style=\"font-family: MS Shell Dlg 2;\">Signals connected to the connector:</span></p>
248<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowRef (input) is the power request (W). Negative values are internally converted to zero</span></p>
249<p><span style=\"font-family: MS Shell Dlg 2;\">- iceW (output) is the measured ICE speed (rad/s)</span></p>
250<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowDel (output) delivered power (W)</span></p>
251</html>"),
252        Icon(coordinateSystem(
253            extent={{-100,-100},{100,100}},
254            preserveAspectRatio=false,
255            initialScale=0.1,
256            grid={2,2})),
257        uses(Modelica(version="3.2.2")));
258    end MBiceConnOO;
259
260    model MBOneFlangeConn "Simple map-based one-flange electric drive "
261      extends Partial.PartialMBOneFlange;
262      SupportModels.Conn conn annotation (Placement(
263          visible=true,
264          transformation(extent={{-18,-60},{22,-100}}, rotation=0),
265          iconTransformation(extent={{80,-58},{120,-98}}, rotation=0)));
266      Modelica.Blocks.Sources.RealExpression mechPow(y=powSensor.power)
267        annotation (Placement(transformation(extent={{38,-56},{18,-36}})));
268    equation
269      connect(createTau.u2, conn.genTauRef) annotation (Line(
270          points={{-28,4},{-42,4},{-42,-68},{2,-68},{2,-80}},
271          color={0,0,127},
272          smooth=Smooth.None), Text(
273          string="%second",
274          index=1,
275          extent={{6,3},{6,3}}));
276      connect(mechPow.y, conn.genPowDel) annotation (Line(
277          points={{17,-46},{2,-46},{2,-80}},
278          color={0,0,127},
279          smooth=Smooth.None), Text(
280          string="%second",
281          index=1,
282          extent={{6,3},{6,3}}));
283      connect(limTau.y, conn.genTauLim) annotation (Line(
284          points={{15,30},{-36,30},{-36,30},{-42,30},{-42,-68},{2,-68},{2,-80}},
285
286          color={0,0,127},
287          smooth=Smooth.None), Text(
288          string="%second",
289          index=1,
290          extent={{6,3},{6,3}}));
291
292      connect(wSensor.w, conn.genW) annotation (Line(
293          points={{78,35.2},{78,-68},{2,-68},{2,-80}},
294          color={0,0,127},
295          smooth=Smooth.None), Text(
296          string="%second",
297          index=1,
298          extent={{6,3},{6,3}}));
299      annotation (
300        Diagram(coordinateSystem(
301            extent={{-100,-80},{100,80}},
302            preserveAspectRatio=false,
303            initialScale=0.1,
304            grid={2,2}), graphics),
305        Icon(coordinateSystem(
306            extent={{-100,-100},{100,100}},
307            preserveAspectRatio=false,
308            initialScale=0.1,
309            grid={2,2}), graphics={
310            Line(points={{62,-7},{82,-7}}),
311            Rectangle(extent={{-70,80},{100,-80}}),
312            Line(points={{-98,40},{-70,40}}, color={0,0,255}),
313            Line(points={{-92,-40},{-70,-40}}, color={0,0,255}),
314            Text(
315              origin={0,20},
316              lineColor={0,0,255},
317              extent={{-70,98},{100,60}},
318              textString="%name")}),
319        Documentation(info="<html>
320<p>The input signal is interpreted as a <u>normalised</u> torque request (0 means null torque, 1 maximum availabile torque).</p>
321<p>The maximum available torque is internally computed considering a direct torque maximum (tauMax) and a power maximum (powMax) </p>
322<p>The requested torque is applied to a mechancal inertia. The inertia is interfaced by means ot two flanges with the exterior.</p>
323<p>The model then computes the inner losses and absorbs the total power from the DC input.</p>
324<p><br><u>Signals connected to the bus connecto</u>r (the names are chosen from the examples FullVehicles!PSecu1 and PSecu2 where the one-flange machine is called &QUOT;gen&QUOT;):</p>
325<p>- genTauRef (input) is the torque request (Nm)</p>
326<p>- genPowDel (output) is the delivered mechanical power (W)</p>
327<p>- genTauLim (output) maximum available torque at the given machine rotational speed (Nm)</p>
328</html>"));
329    end MBOneFlangeConn;
330
331    model MBTwoFlangeConn "Simple map-based two-flange electric drive model"
332      extends Partial.PartialMBTwoFlange;
333      SupportModels.Conn conn1 annotation (Placement(
334          visible=true,
335          transformation(extent={{-112,-58},{-72,-98}}, rotation=0),
336          iconTransformation(extent={{-112,-58},{-72,-98}}, rotation=0)));
337    equation
338      connect(outBPow_.power, conn1.motPowDelB) annotation (Line(
339          points={{64,39},{64,-78},{-92,-78},{-92,-78}},
340          color={0,0,127},
341          smooth=Smooth.None), Text(
342          string="%second",
343          index=1,
344          extent={{6,3},{6,3}}));
345      connect(speedRing.w, conn1.motW) annotation (Line(
346          points={{-80,29},{-86,29},{-86,28},{-92,28},{-92,-78}},
347          color={0,0,127},
348          smooth=Smooth.None), Text(
349          string="%second",
350          index=1,
351          extent={{6,3},{6,3}}));
352      connect(add.y, conn1.motPowDelAB) annotation (Line(
353          points={{28,-1},{28,-22},{78,-22},{78,-78},{-92,-78}},
354          color={0,0,127},
355          smooth=Smooth.None), Text(
356          string="%second",
357          index=1,
358          extent={{6,3},{6,3}}));
359      connect(createTau.u2, conn1.motTauRef) annotation (Line(
360          points={{-20,-10},{-92,-10},{-92,-78}},
361          color={0,0,127},
362          smooth=Smooth.None), Text(
363          string="%second",
364          index=1,
365          extent={{6,3},{6,3}}));
366      annotation (
367        Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
368                {100,100}}), graphics),
369        Icon(coordinateSystem(
370            extent={{-100,-100},{100,100}},
371            preserveAspectRatio=false,
372            initialScale=0.1,
373            grid={2,2}), graphics={
374            Rectangle(
375              fillColor={192,192,192},
376              fillPattern=FillPattern.HorizontalCylinder,
377              extent={{-100,10},{-66,-10}}),
378            Rectangle(
379              fillColor={192,192,192},
380              fillPattern=FillPattern.HorizontalCylinder,
381              extent={{66,8},{100,-12}}),
382            Rectangle(origin={-25,2}, extent={{-75,74},{125,-74}}),
383            Line(
384              origin={20,-2},
385              points={{-60,94},{-60,76}},
386              color={0,0,255}),
387            Line(
388              origin={-20,-2},
389              points={{60,94},{60,76}},
390              color={0,0,255})}),
391        Documentation(info="<html>
392<p><b><span style=\"font-family: MS Shell Dlg 2;\">Simple map-based ICE model for power-split power trains - with connector</b> </span></p>
393<p><span style=\"font-family: MS Shell Dlg 2;\">This is a &QUOT;connector&QUOT; version of MBice.</span></p>
394<p><span style=\"font-family: MS Shell Dlg 2;\">For a general descritiption see the info of MBice.</span></p>
395<p><span style=\"font-family: MS Shell Dlg 2;\">Signals connected to the connector:</span></p>
396<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowRef (input) is the power request (W). Negative values are internally converted to zero</span></p>
397<p><span style=\"font-family: MS Shell Dlg 2;\">- iceW (output) is the measured ICE speed (rad/s)</span></p>
398<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowDel (output) delivered power (W)</span></p>
399</html>"));
400    end MBTwoFlangeConn;
401
402    package MBsupport "Useful Additional Models"
403      extends Modelica.Icons.Package;
404
405      model ToConnIceTauRef "signal adaptor to send iceTauRef to a connector"
406        Modelica.Blocks.Interfaces.RealInput u annotation (Placement(
407              transformation(extent={{-94,-20},{-54,20}}), iconTransformation(
408                extent={{-94,-20},{-54,20}})));
409        SupportModels.Conn conn annotation (Placement(transformation(
410              extent={{-20,-20},{20,20}},
411              rotation=-90,
412              origin={60,0}), iconTransformation(
413              extent={{-20,-20},{20,20}},
414              rotation=-90,
415              origin={60,0})));
416      equation
417        connect(u, conn.iceTauRef) annotation (Line(
418            points={{-74,0},{60,0}},
419            color={0,0,127},
420            smooth=Smooth.None), Text(
421            string="%second",
422            index=1,
423            extent={{6,3},{6,3}}));
424        annotation (
425          Icon(coordinateSystem(preserveAspectRatio=false, extent={{-60,-60},{
426                  60,60}}), graphics={Rectangle(
427                      extent={{-60,40},{60,-40}},
428                      lineColor={0,0,0},
429                      fillColor={255,255,255},
430                      fillPattern=FillPattern.Solid),Line(
431                      points={{-38,0},{30,0}},
432                      color={0,0,0},
433                      smooth=Smooth.None),Polygon(
434                      points={{42,0},{22,8},{22,-8},{42,0}},
435                      lineColor={0,0,0},
436                      smooth=Smooth.None,
437                      fillColor={0,0,0},
438                      fillPattern=FillPattern.Solid)}),
439          Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-60,-60},
440                  {60,60}}), graphics),
441          Documentation(info="<html>
442<p><span style=\"font-family: MS Shell Dlg 2;\">Adapter for an input signal into &QUOT;iceTauRef&QUOT; signal in the library connector.</span></p>
443</html>"));
444      end ToConnIceTauRef;
445
446      model ToConnGenTauRef "signal adaptor to send genTauRef to a connector"
447        Modelica.Blocks.Interfaces.RealInput u annotation (Placement(
448              transformation(extent={{-90,-20},{-50,20}}), iconTransformation(
449                extent={{-90,-20},{-50,20}})));
450        SupportModels.Conn conn annotation (Placement(transformation(
451              extent={{-20,-20},{20,20}},
452              rotation=-90,
453              origin={58,0}), iconTransformation(
454              extent={{-20,-20},{20,20}},
455              rotation=-90,
456              origin={58,0})));
457      equation
458        connect(u, conn.genTauRef) annotation (Line(
459            points={{-70,0},{58,0}},
460            color={0,0,127},
461            smooth=Smooth.None), Text(
462            string="%second",
463            index=1,
464            extent={{6,3},{6,3}}));
465        annotation (
466          Icon(coordinateSystem(preserveAspectRatio=false, extent={{-60,-60},{
467                  60,60}}), graphics={Rectangle(
468                      extent={{-60,40},{60,-40}},
469                      lineColor={0,0,0},
470                      fillColor={255,255,255},
471                      fillPattern=FillPattern.Solid),Line(
472                      points={{-40,0},{32,0}},
473                      color={0,0,0},
474                      smooth=Smooth.None),Polygon(
475                      points={{42,0},{22,8},{22,-8},{42,0}},
476                      lineColor={0,0,0},
477                      smooth=Smooth.None,
478                      fillColor={0,0,0},
479                      fillPattern=FillPattern.Solid)}),
480          Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-60,-60},
481                  {60,60}}), graphics),
482          Documentation(info="<html>
483<p><span style=\"font-family: MS Shell Dlg 2;\">Adapter for an input signal into &QUOT;genTauRef&QUOT; signal in the library connector.</span></p>
484</html>"));
485      end ToConnGenTauRef;
486
487      package Internal
488        "Models intended to be used by other models of this package, not by the final user"
489        block LimTau "Torque limiter"
490          Modelica.Blocks.Interfaces.RealInput w annotation (Placement(
491                transformation(extent={{-140,-20},{-100,20}})));
492          Modelica.Blocks.Interfaces.RealOutput y
493            annotation (Placement(transformation(extent={{100,-10},{120,10}})));
494          parameter Real powMax(start=50000) "Maximum mechanical power (W)";
495          parameter Real tauMax(start=400) "Maximum torque (Nm)";
496          parameter Real wMax(start=1500, min=powMax/tauMax)
497            "Maximum speed (rad/s)";
498          Integer state
499            "=0 below base speed; =1 before wMax; =2 in w limit, =3 above wMax";
500          //0 or 1 if tauMax or powMax is delivered; =2 or 3 if w>wMax
501        protected
502          parameter Real alpha=0.10
503            "fraction of wMax over which the torque is to be brought to zero";
504        algorithm
505          if w < powMax/tauMax then
506            state := 0;
507            y := tauMax;
508          else
509            state := 1;
510            y := powMax/w;
511          end if;
512          //over wMax the torque max is to be rapidly brought to zero
513          if w > wMax then
514            if w < (1 + alpha)*wMax then
515              state := 2;
516              y := powMax/wMax*(1 - (w - wMax)/(alpha*wMax));
517            else
518              state := 3;
519              y := 0;
520            end if;
521          end if;
522          annotation (
523            Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
524                    {100,100}}), graphics),
525            Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
526                    {100,100}}), graphics={Rectangle(
527                          extent={{-100,60},{100,-60}},
528                          lineColor={0,0,0},
529                          fillColor={255,255,255},
530                          fillPattern=FillPattern.Solid),Polygon(
531                          points={{-4,34},{6,16},{22,2},{38,-10},{56,-16},{72,-18},
532                    {72,-38},{12,-38},{-72,-38},{-72,34},{-4,34}},
533                          lineColor={0,0,0},
534                          smooth=Smooth.None,
535                          fillColor={255,255,255},
536                          fillPattern=FillPattern.Solid),Line(
537                          points={{-72,54},{-72,-40},{-74,-40}},
538                          color={0,0,0},
539                          thickness=0.5,
540                          smooth=Smooth.None,
541                          arrow={Arrow.Filled,Arrow.None}),Line(
542                          points={{90,-38},{-74,-38}},
543                          color={0,0,0},
544                          thickness=0.5,
545                          smooth=Smooth.None,
546                          arrow={Arrow.Filled,Arrow.None}),Text(
547                          extent={{-100,80},{96,52}},
548                          lineColor={0,0,255},
549                          fillColor={255,255,255},
550                          fillPattern=FillPattern.Solid,
551                          textString="%name
552    "),Text(              extent={{70,-48},{84,-54}},
553                          lineColor={0,0,255},
554                          textString="W"),Text(
555                          extent={{-96,48},{-82,42}},
556                          lineColor={0,0,255},
557                          textString="T")}),
558            Documentation(info="<html>
559<p>Gives the maximum output torque as a function of the input speed.</p>
560<p>When w&LT;wMax the output is Tmax if Tmax*w&LT;Pnom, othersise it is Pnom/w</p>
561<p>But if w is over wMax Tmax is rapidly falling to zero (reaches zero when speed overcomes wMax by 10&percnt;).</p>
562<p>Torques and powers are in SI units</p>
563</html>"));
564        end LimTau;
565
566        block Pel
567          "Outputs a power signal computed from the given efficiency and input power"
568          Modelica.Blocks.Interfaces.RealInput eta annotation (Placement(
569                transformation(extent={{-140,-60},{-100,-20}})));
570          Modelica.Blocks.Interfaces.RealInput P annotation (Placement(
571                transformation(extent={{-140,20},{-100,60}})));
572          Modelica.Blocks.Interfaces.RealOutput Pel
573            annotation (Placement(transformation(extent={{100,-10},{120,10}})));
574        algorithm
575          if noEvent(P <= 0) then
576            Pel := P*eta;
577          else
578            Pel := P/eta;
579          end if;
580          annotation (
581            Icon(graphics={Rectangle(
582                          extent={{-92,56},{98,-48}},
583                          lineColor={0,0,255},
584                          fillColor={170,255,255},
585                          fillPattern=FillPattern.Solid),Text(
586                          extent={{-64,30},{48,-14}},
587                          lineColor={0,0,255},
588                          fillColor={170,255,255},
589                          fillPattern=FillPattern.Solid,
590                          textString="Pel")}),
591            Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
592                    {100,100}}), graphics),
593            Documentation(info="<html>
594<pre><span style=\"font-family: Courier New,courier;\">Outputs&nbsp;a power signal computed from the&nbsp;given&nbsp;efficiency&nbsp;and&nbsp;input&nbsp;power</span></pre>
595</html>"));
596        end Pel;
597
598        model InertiaTq "Inertia with added torque"
599          import SI = Modelica.SIunits;
600          Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a
601            "Left flange of shaft" annotation (Placement(transformation(extent=
602                    {{-110,-10},{-90,10}}, rotation=0)));
603          Modelica.Mechanics.Rotational.Interfaces.Flange_b flange_b
604            "Right flange of shaft" annotation (Placement(transformation(extent
605                  ={{90,-10},{110,10}}, rotation=0)));
606          parameter SI.Inertia J(min=0, start=1) "Moment of inertia";
607          parameter StateSelect stateSelect=StateSelect.default
608            "Priority to use phi and w as states"
609            annotation (HideResult=true, Dialog(tab="Advanced"));
610          SI.Angle phi(stateSelect=stateSelect)
611            "Absolute rotation angle of component" annotation (Dialog(group=
612                  "Initialization", showStartAttribute=true));
613          SI.AngularVelocity w(stateSelect=stateSelect)
614            "Absolute angular velocity of component (= der(phi))" annotation (
615              Dialog(group="Initialization", showStartAttribute=true));
616          SI.AngularAcceleration a
617            "Absolute angular acceleration of component (= der(w))" annotation
618            (Dialog(group="Initialization", showStartAttribute=true));
619          Modelica.Blocks.Interfaces.RealInput tau annotation (Placement(
620                transformation(
621                extent={{-20.5,-20},{20.5,20}},
622                rotation=90,
623                origin={-54.5,-100})));
624        equation
625          phi = flange_a.phi;
626          phi = flange_b.phi;
627          w = der(phi);
628          a = der(w);
629          J*a = flange_a.tau + flange_b.tau + tau;
630          annotation (
631            Documentation(info="<html>
632    <p>
633    Rotational component with <b>inertia</b> and two rigidly connected flanges.
634    </p>
635
636    </HTML>
637    "),
638            Icon(coordinateSystem(
639                preserveAspectRatio=true,
640                extent={{-100,-100},{100,100}},
641                grid={2,2}), graphics={Rectangle(
642                          extent={{-100,10},{-50,-10}},
643                          lineColor={0,0,0},
644                          fillPattern=FillPattern.HorizontalCylinder,
645                          fillColor={192,192,192}),Rectangle(
646                          extent={{50,10},{100,-10}},
647                          lineColor={0,0,0},
648                          fillPattern=FillPattern.HorizontalCylinder,
649                          fillColor={192,192,192}),Line(points={{-80,-25},{-60,
650                  -25}}, color={0,0,0}),Line(points={{60,-25},{80,-25}}, color=
651                  {0,0,0}),Line(points={{-70,-25},{-70,-70}}, color={0,0,0}),
652                  Line(points={{70,-25},{70,-70}}, color={0,0,0}),Line(points={
653                  {-80,25},{-60,25}}, color={0,0,0}),Line(points={{60,25},{80,
654                  25}}, color={0,0,0}),Line(points={{-70,45},{-70,25}}, color={
655                  0,0,0}),Line(points={{70,45},{70,25}}, color={0,0,0}),Line(
656                  points={{-70,-70},{70,-70}}, color={0,0,0}),Rectangle(
657                          extent={{-50,50},{50,-50}},
658                          lineColor={0,0,0},
659                          fillPattern=FillPattern.HorizontalCylinder,
660                          fillColor={192,192,192}),Text(
661                          extent={{-150,100},{150,60}},
662                          textString="%name",
663                          lineColor={0,0,255}),Text(
664                          extent={{-150,-80},{150,-120}},
665                          lineColor={0,0,0},
666                          textString="J=%J")}),
667            Diagram(coordinateSystem(
668                preserveAspectRatio=true,
669                extent={{-100,-100},{100,100}},
670                grid={2,2}), graphics));
671        end InertiaTq;
672
673        block ToElectricPower
674          "Determines the electric power from the mechanical considering efficiency map"
675          parameter Real tauMax(start=400) "Maximum machine torque(Nm)";
676          parameter Real powMax(start=22000) "Maximum drive power";
677          parameter Real wMax(start=650) "Maximum machine speed(rad/s)";
678          parameter Real effTable[:, :]=[0.00, 0.00, 0.25, 0.50, 0.75, 1.00;
679              0.00, 0.75, 0.80, 0.81, 0.82, 0.83; 0.25, 0.76, 0.81, 0.82, 0.83,
680              0.84; 0.50, 0.77, 0.82, 0.83, 0.84, 0.85; 0.75, 0.78, 0.83, 0.84,
681              0.85, 0.87; 1.00, 0.80, 0.84, 0.85, 0.86, 0.88];
682          Modelica.Blocks.Tables.CombiTable2D effTable_(
683            tableOnFile=false,
684            smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments,
685            table=effTable) "normalised efficiency" annotation (Placement(
686                transformation(
687                extent={{-14,-14},{14,14}},
688                rotation=0,
689                origin={18,-18})));
690          Modelica.Blocks.Interfaces.RealInput w annotation (Placement(
691                transformation(extent={{-140,-60},{-100,-20}}),
692                iconTransformation(extent={{-140,-60},{-100,-20}})));
693          Modelica.Blocks.Interfaces.RealInput tau annotation (Placement(
694                transformation(extent={{-140,20},{-100,60}}),
695                iconTransformation(extent={{-140,20},{-100,60}})));
696          Modelica.Blocks.Interfaces.RealOutput elePow
697            annotation (Placement(transformation(extent={{100,-10},{120,10}})));
698          Modelica.Blocks.Math.Abs abs1 annotation (Placement(transformation(
699                  extent={{-76,-50},{-56,-30}})));
700          Modelica.Blocks.Math.Abs abs2
701            annotation (Placement(transformation(extent={{-80,40},{-60,60}})));
702          Modelica.Blocks.Math.Gain normalizeTau(k=1/tauMax) annotation (
703              Placement(transformation(
704                extent={{-10,-10},{10,10}},
705                rotation=0,
706                origin={-36,50})));
707          Pel pel
708            annotation (Placement(transformation(extent={{60,-12},{84,10}})));
709          Modelica.Blocks.Math.Product PMOT
710            annotation (Placement(transformation(extent={{-72,0},{-52,20}})));
711          Modelica.Blocks.Math.Gain normalizeSpeed(k=1/wMax) annotation (
712              Placement(transformation(
713                extent={{-10,-10},{10,10}},
714                rotation=0,
715                origin={-34,-40})));
716        equation
717          connect(tau, abs2.u) annotation (Line(
718              points={{-120,40},{-94,40},{-94,50},{-82,50}},
719              color={0,0,127},
720              smooth=Smooth.None));
721          connect(w, abs1.u) annotation (Line(
722              points={{-120,-40},{-78,-40}},
723              color={0,0,127},
724              smooth=Smooth.None));
725          connect(abs2.y, normalizeTau.u) annotation (Line(
726              points={{-59,50},{-48,50}},
727              color={0,0,127},
728              smooth=Smooth.None));
729          connect(normalizeTau.y, effTable_.u1) annotation (Line(
730              points={{-25,50},{-7.7,50},{-7.7,-9.6},{1.2,-9.6}},
731              color={0,0,127},
732              smooth=Smooth.None));
733          connect(pel.Pel, elePow) annotation (Line(
734              points={{85.2,-1},{92.48,-1},{92.48,0},{110,0}},
735              color={0,0,127},
736              smooth=Smooth.None));
737          connect(effTable_.y, pel.eta) annotation (Line(
738              points={{33.4,-18},{46,-18},{46,-5.4},{57.6,-5.4}},
739              color={0,0,127},
740              smooth=Smooth.None));
741          connect(PMOT.u1, tau) annotation (Line(
742              points={{-74,16},{-84,16},{-84,40},{-120,40}},
743              color={0,0,127},
744              smooth=Smooth.None));
745          connect(PMOT.u2, w) annotation (Line(
746              points={{-74,4},{-84,4},{-84,-40},{-120,-40}},
747              color={0,0,127},
748              smooth=Smooth.None));
749          connect(PMOT.y, pel.P) annotation (Line(
750              points={{-51,10},{42,10},{42,3.4},{57.6,3.4}},
751              color={0,0,127},
752              smooth=Smooth.None));
753          connect(abs1.y, normalizeSpeed.u) annotation (Line(
754              points={{-55,-40},{-46,-40}},
755              color={0,0,127},
756              smooth=Smooth.None));
757          connect(normalizeSpeed.y, effTable_.u2) annotation (Line(
758              points={{-23,-40},{-10,-40},{-10,-26.4},{1.2,-26.4}},
759              color={0,0,127},
760              smooth=Smooth.None));
761          annotation (
762            Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},
763                    {100,80}}), graphics),
764            Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
765                    {100,100}}), graphics={Rectangle(
766                          extent={{-100,72},{100,-72}},
767                          lineColor={0,0,0},
768                          fillColor={255,255,255},
769                          fillPattern=FillPattern.Solid),Line(
770                          points={{-74,-54},{-74,58}},
771                          color={0,0,0},
772                          smooth=Smooth.None),Line(
773                          points={{-82,-48},{78,-48}},
774                          color={0,0,0},
775                          smooth=Smooth.None),Line(
776                          points={{-74,38},{-24,38},{-4,12},{28,-8},{60,-22},{
777                    62,-48}},
778                          color={0,0,0},
779                          smooth=Smooth.None),Polygon(
780                          points={{-20,14},{-40,24},{-56,-4},{-38,-36},{12,-38},
781                    {26,-28},{22,-20},{8,-6},{-8,4},{-20,14}},
782                          lineColor={0,0,0},
783                          smooth=Smooth.None,
784                          fillColor={255,255,255},
785                          fillPattern=FillPattern.Solid),Polygon(
786                          points={{-28,4},{-38,2},{-32,-20},{0,-32},{10,-28},{
787                    12,-20},{-28,4}},
788                          lineColor={0,0,0},
789                          smooth=Smooth.None,
790                          fillColor={255,255,255},
791                          fillPattern=FillPattern.Solid),Text(
792                          extent={{-102,118},{100,78}},
793                          lineColor={0,0,255},
794                          fillColor={255,255,255},
795                          fillPattern=FillPattern.Solid,
796                          textString="%name"),Text(
797                          extent={{26,46},{76,4}},
798                          lineColor={0,0,0},
799                          textString="M")}),
800            Documentation(info="<html>
801<p>This block computes the machine and inverter losses from the mechanical input quantities and determines the power to be drawn from the electric circuit. The &QUOT;drawn&QUOT; power can be also a negative numer, meaning that themachine is actually delivering electric power.</p>
802<p>The given efficiency map is intended as being built with torques being rations of actual torques to tauMax and speeds being ratios of w to wMax. In case the user uses, inthe given efficiency map,  torques in Nm and speeds in rad/s, the block can be used selecting tauTmax=1, wMax=1.</p>
803<p>The choice of having normalised efficiency computation allows simulations of machines different in sizes and similar in characteristics to be repeated without having to rebuild the efficiency maps. </p>
804</html>"));
805        end ToElectricPower;
806      end Internal;
807
808      model ToConnIcePowRef "signal adaptor to send icePowRef to a connector"
809        Modelica.Blocks.Interfaces.RealInput u annotation (Placement(
810              transformation(extent={{-94,-20},{-54,20}}), iconTransformation(
811                extent={{-94,-20},{-54,20}})));
812        SupportModels.Conn conn annotation (Placement(transformation(
813              extent={{-20,-20},{20,20}},
814              rotation=-90,
815              origin={60,0}), iconTransformation(
816              extent={{-20,-20},{20,20}},
817              rotation=-90,
818              origin={60,0})));
819      equation
820        connect(u, conn.icePowRef) annotation (Line(points={{-74,0},{60,0},{60,
821                0}}, color={0,0,127}), Text(
822            string="%second",
823            index=1,
824            extent={{6,3},{6,3}}));
825        annotation (
826          Icon(coordinateSystem(preserveAspectRatio=false, extent={{-60,-60},{
827                  60,60}}), graphics={Rectangle(
828                      extent={{-60,40},{60,-40}},
829                      lineColor={0,0,0},
830                      fillColor={255,255,255},
831                      fillPattern=FillPattern.Solid),Line(
832                      points={{-38,0},{30,0}},
833                      color={0,0,0},
834                      smooth=Smooth.None),Polygon(
835                      points={{42,0},{22,8},{22,-8},{42,0}},
836                      lineColor={0,0,0},
837                      smooth=Smooth.None,
838                      fillColor={0,0,0},
839                      fillPattern=FillPattern.Solid)}),
840          Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-60,-60},
841                  {60,60}})),
842          Documentation(info="<html>
843<p><span style=\"font-family: MS Shell Dlg 2;\">Adapter for an input signal into &QUOT;icePowRef&QUOT; signal in the library connector.</span></p>
844</html>"));
845      end ToConnIcePowRef;
846      annotation (Icon(graphics={
847            Ellipse(extent={{-38,40},{38,-36}}, lineColor={0,0,0}),
848            Line(
849              points={{2,82},{-8,82},{-12,72},{-26,68},{-36,78},{-48,70},{-44,
850                  58},{-56,46},{-68,50},{-76,36},{-68,30},{-70,16},{-80,12},{-80,
851                  2}},
852              color={0,0,0},
853              smooth=Smooth.None),
854            Line(
855              points={{2,-78},{-8,-78},{-12,-68},{-26,-64},{-36,-74},{-48,-66},
856                  {-44,-54},{-56,-42},{-68,-46},{-76,-32},{-68,-26},{-70,-12},{
857                  -80,-8},{-80,2}},
858              color={0,0,0},
859              smooth=Smooth.None),
860            Line(
861              points={{0,-78},{10,-78},{14,-68},{28,-64},{38,-74},{50,-66},{46,
862                  -54},{58,-42},{70,-46},{78,-32},{70,-26},{72,-12},{82,-8},{82,
863                  2}},
864              color={0,0,0},
865              smooth=Smooth.None),
866            Line(
867              points={{0,82},{10,82},{14,72},{28,68},{38,78},{50,70},{46,58},{
868                  58,46},{70,50},{78,36},{70,30},{72,16},{82,12},{82,2}},
869              color={0,0,0},
870              smooth=Smooth.None)}));
871    end MBsupport;
872
873    package Partial
874      model PartialMBOneFlange
875        "Partial map-based one-Flange electric drive model"
876        parameter Real powMax=22000 "Maximum drive power  (W)";
877        parameter Real tauMax=80 "Maximum drive torque (Nm)";
878        parameter Real wMax(start=3000, min=powMax/tauMax)
879          "Maximum drive speed (rad/s)";
880        parameter Real J=0.25 "Rotor's moment of inertia (kg.m^2)";
881        Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a
882          "Left flange of shaft" annotation (Placement(transformation(extent={{
883                  88,50},{108,70}}, rotation=0), iconTransformation(extent={{90,
884                  -10},{110,10}})));
885        Modelica.Mechanics.Rotational.Sensors.SpeedSensor wSensor annotation (
886            Placement(transformation(
887              extent={{8,-8},{-8,8}},
888              rotation=90,
889              origin={78,44})));
890        Modelica.Blocks.Math.Abs abs1
891          annotation (Placement(transformation(extent={{62,16},{46,32}})));
892        MBsupport.Internal.LimTau limTau(
893          tauMax=tauMax,
894          wMax=wMax,
895          powMax=powMax)
896          annotation (Placement(transformation(extent={{36,18},{16,42}})));
897        MBsupport.Internal.ToElectricPower effMap(
898          tauMax=tauMax,
899          wMax=wMax,
900          powMax=powMax)
901          annotation (Placement(transformation(extent={{-6,-28},{-26,-8}})));
902        Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation (
903            Placement(transformation(extent={{-110,30},{-90,50}}),
904              iconTransformation(extent={{-110,30},{-90,50}})));
905        Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation (
906            Placement(transformation(extent={{-110,-50},{-90,-30}}),
907              iconTransformation(extent={{-110,-50},{-90,-30}})));
908        SupportModels.Internal.ConstPDC constPDC(k=10, T=0.01) annotation (
909            Placement(transformation(
910              extent={{-10,-10},{10,10}},
911              rotation=0,
912              origin={-100,0})));
913        Modelica.Mechanics.Rotational.Components.Inertia inertia(J=J)
914          annotation (Placement(transformation(extent={{22,50},{42,70}})));
915        Modelica.Mechanics.Rotational.Sources.Torque torque
916          annotation (Placement(transformation(extent={{-16,50},{4,70}})));
917        Modelica.Blocks.Math.Gain gain(k=1)
918          annotation (Placement(transformation(extent={{-64,-10},{-84,10}})));
919        Modelica.Mechanics.Rotational.Sensors.PowerSensor powSensor
920          annotation (Placement(transformation(extent={{50,50},{70,70}})));
921        Modelica.Blocks.Math.Min createTau annotation (Placement(visible=true,
922              transformation(extent={{-26,0},{-6,20}}, rotation=0)));
923      equation
924        assert(wMax >= powMax/tauMax, "\n****\n" +
925          "PARAMETER VERIFICATION ERROR:\nwMax must be not lower than powMax/tauMax"
926           + "\n***\n");
927        connect(abs1.u, wSensor.w) annotation (Line(
928            points={{63.6,24},{78,24},{78,35.2}},
929            color={0,0,127},
930            smooth=Smooth.None));
931        connect(effMap.w, wSensor.w) annotation (Line(
932            points={{-4,-22},{78,-22},{78,35.2}},
933            color={0,0,127},
934            smooth=Smooth.None));
935        connect(pin_p, constPDC.pin_p) annotation (Line(
936            points={{-100,40},{-100,10}},
937            color={0,0,255},
938            smooth=Smooth.None));
939        connect(pin_n, constPDC.pin_n) annotation (Line(
940            points={{-100,-40},{-100,-9.8}},
941            color={0,0,255},
942            smooth=Smooth.None));
943        connect(constPDC.Pref, gain.y) annotation (Line(
944            points={{-91.8,0},{-85,0}},
945            color={0,0,127},
946            smooth=Smooth.None));
947        connect(limTau.w, abs1.y) annotation (Line(
948            points={{38,30},{42,30},{42,24},{45.2,24}},
949            color={0,0,127},
950            smooth=Smooth.None));
951        connect(powSensor.flange_b, flange_a) annotation (Line(
952            points={{70,60},{98,60}},
953            color={0,0,0},
954            smooth=Smooth.None));
955        connect(wSensor.flange, flange_a) annotation (Line(
956            points={{78,52},{78,60},{98,60}},
957            color={0,0,0},
958            smooth=Smooth.None));
959        connect(effMap.elePow, gain.u) annotation (Line(
960            points={{-27,-18},{-46,-18},{-46,0},{-62,0}},
961            color={0,0,127},
962            smooth=Smooth.None));
963        connect(inertia.flange_a, torque.flange) annotation (Line(
964            points={{22,60},{4,60}},
965            color={0,0,0},
966            smooth=Smooth.None));
967        connect(inertia.flange_b, powSensor.flange_a) annotation (Line(
968            points={{42,60},{50,60}},
969            color={0,0,0},
970            smooth=Smooth.None));
971        connect(limTau.y, createTau.u1) annotation (Line(
972            points={{15,30},{-40,30},{-40,16},{-28,16}},
973            color={0,0,127},
974            smooth=Smooth.None));
975        connect(createTau.y, torque.tau) annotation (Line(
976            points={{-5,10},{6,10},{6,40},{-40,40},{-40,60},{-18,60}},
977            color={0,0,127},
978            smooth=Smooth.None));
979        connect(createTau.y, effMap.tau) annotation (Line(
980            points={{-5,10},{6,10},{6,-14},{-4,-14}},
981            color={0,0,127},
982            smooth=Smooth.None));
983        annotation (
984          Diagram(coordinateSystem(
985              extent={{-100,-80},{100,80}},
986              preserveAspectRatio=false,
987              initialScale=0.1,
988              grid={2,2}), graphics),
989          Icon(coordinateSystem(
990              extent={{-100,-100},{100,100}},
991              preserveAspectRatio=false,
992              initialScale=0.1,
993              grid={2,2}), graphics={
994              Rectangle(
995                extent={{-70,80},{100,-80}},
996                lineColor={0,0,0},
997                fillColor={255,255,255},
998                fillPattern=FillPattern.Solid),
999              Rectangle(
1000                fillColor={192,192,192},
1001                fillPattern=FillPattern.HorizontalCylinder,
1002                extent={{-48,48},{52,-44}}),
1003              Line(points={{62,-7},{82,-7}}),
1004              Rectangle(
1005                fillColor={192,192,192},
1006                fillPattern=FillPattern.HorizontalCylinder,
1007                extent={{52,10},{100,-10}}),
1008              Text(
1009                origin={-14,-36},
1010                extent={{-140,-54},{160,-94}},
1011                textString="J=%J"),
1012              Line(points={{-98,40},{-70,40}}, color={0,0,255}),
1013              Line(points={{-92,-40},{-70,-40}}, color={0,0,255}),
1014              Text(
1015                origin={0,20},
1016                lineColor={0,0,255},
1017                extent={{-70,98},{100,60}},
1018                textString="%name",
1019                fillPattern=FillPattern.Solid,
1020                fillColor={255,255,255})}),
1021          Documentation(info="<html>
1022<p>One-flange electric drive.</p>
1023<p>The input signal is the requested normalised torque (1 means nominal torque)</p>
1024</html>"));
1025      end PartialMBOneFlange;
1026
1027      model PartialMBTwoFlange
1028        "Simple map-based two-flange electric drive model"
1029        parameter Real powMax(start=50000) "Maximum Mechanical drive power (W)";
1030        parameter Real tauMax(start=400) "Maximum drive Torque  (Nm)";
1031        parameter Real wMax(start=650) "Maximum drive speed (rad/s)";
1032        parameter Real J=0.59 "Moment of Inertia (kg.m^2)";
1033        //  Real state=limTau.state;
1034        MBsupport.Internal.LimTau limTau(
1035          tauMax=tauMax,
1036          wMax=wMax,
1037          powMax=powMax)
1038          annotation (Placement(transformation(extent={{-54,-8},{-32,14}})));
1039        MBsupport.Internal.InertiaTq inertia(w(displayUnit="rad/s", start=0), J
1040            =J) annotation (Placement(transformation(extent={{6,40},{26,60}})));
1041        Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedRing annotation
1042          (Placement(transformation(
1043              extent={{-10,-10},{10,10}},
1044              rotation=270,
1045              origin={-80,40})));
1046        Modelica.Blocks.Math.Abs abs1
1047          annotation (Placement(transformation(extent={{-76,-4},{-62,10}})));
1048        MBsupport.Internal.ToElectricPower effMap(
1049          tauMax=tauMax,
1050          wMax=wMax,
1051          powMax=powMax)
1052          annotation (Placement(transformation(extent={{20,-46},{40,-26}})));
1053        SupportModels.Internal.ConstPDC constPDC(k=10, T=0.01) annotation (
1054            Placement(transformation(
1055              extent={{-10,10},{10,-10}},
1056              rotation=-90,
1057              origin={0,100})));
1058        Modelica.Mechanics.Rotational.Sensors.PowerSensor outBPow_
1059          annotation (Placement(transformation(extent={{62,40},{82,60}})));
1060        Modelica.Mechanics.Rotational.Sensors.PowerSensor outAPow_
1061          annotation (Placement(transformation(extent={{-18,40},{-38,60}})));
1062        Modelica.Blocks.Math.Add add annotation (Placement(transformation(
1063              extent={{-10,-10},{10,10}},
1064              rotation=-90,
1065              origin={28,10})));
1066        Modelica.Mechanics.Rotational.Interfaces.Flange_b flange_b
1067          "Right flange of shaft" annotation (Placement(
1068            visible=true,
1069            transformation(extent={{90,40},{110,60}}, rotation=0),
1070            iconTransformation(extent={{90,-12},{110,8}}, rotation=0)));
1071        Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a
1072          "Left flange of shaft" annotation (Placement(
1073            visible=true,
1074            transformation(extent={{-110,40},{-90,60}}, rotation=0),
1075            iconTransformation(extent={{-110,-10},{-90,10}}, rotation=0)));
1076        Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation (
1077            Placement(
1078            visible=true,
1079            transformation(extent={{-70,90},{-50,110}}, rotation=0),
1080            iconTransformation(extent={{-50,88},{-30,108}}, rotation=0)));
1081        Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation (
1082            Placement(
1083            visible=true,
1084            transformation(extent={{30,90},{50,110}}, rotation=0),
1085            iconTransformation(extent={{30,90},{50,110}}, rotation=0)));
1086        Modelica.Blocks.Math.Min createTau annotation (Placement(visible=true,
1087              transformation(extent={{-18,-14},{2,6}}, rotation=0)));
1088      equation
1089        connect(flange_a, speedRing.flange) annotation (Line(
1090            points={{-100,50},{-80,50}},
1091            color={0,0,0},
1092            smooth=Smooth.None));
1093        connect(abs1.u, speedRing.w) annotation (Line(
1094            points={{-77.40000000000001,3},{-80,3},{-80,29}},
1095            color={0,0,127},
1096            smooth=Smooth.None));
1097        connect(limTau.w, abs1.y) annotation (Line(
1098            points={{-56.2,3},{-61.3,3}},
1099            color={0,0,127},
1100            smooth=Smooth.None));
1101        connect(effMap.w, speedRing.w) annotation (Line(
1102            points={{18,-40},{-80,-40},{-80,29}},
1103            color={0,0,127},
1104            smooth=Smooth.None));
1105        connect(pin_p, constPDC.pin_p) annotation (Line(
1106            points={{-60,100},{-10,100}},
1107            color={0,0,255},
1108            smooth=Smooth.None));
1109        connect(pin_n, constPDC.pin_n) annotation (Line(
1110            points={{40,100},{9.8,100}},
1111            color={0,0,255},
1112            smooth=Smooth.None));
1113        connect(effMap.elePow, constPDC.Pref) annotation (Line(
1114            points={{41,-36},{52,-36},{52,80},{0,80},{0,91.8}},
1115            color={0,0,127},
1116            smooth=Smooth.None));
1117        connect(flange_b, outBPow_.flange_b) annotation (Line(
1118            points={{100,50},{82,50}},
1119            color={0,0,0},
1120            smooth=Smooth.None));
1121        connect(inertia.flange_b, outBPow_.flange_a) annotation (Line(
1122            points={{26,50},{62,50}},
1123            color={0,0,0},
1124            smooth=Smooth.None));
1125        connect(inertia.flange_a, outAPow_.flange_a) annotation (Line(
1126            points={{6,50},{-18,50}},
1127            color={0,0,0},
1128            smooth=Smooth.None));
1129        connect(outAPow_.flange_b, speedRing.flange) annotation (Line(
1130            points={{-38,50},{-80,50}},
1131            color={0,0,0},
1132            smooth=Smooth.None));
1133        connect(add.u1, outBPow_.power) annotation (Line(
1134            points={{34,22},{34,28},{64,28},{64,39}},
1135            color={0,0,127},
1136            smooth=Smooth.None));
1137        connect(add.u2, outAPow_.power) annotation (Line(
1138            points={{22,22},{22,28},{-20,28},{-20,39}},
1139            color={0,0,127},
1140            smooth=Smooth.None));
1141        connect(limTau.y, createTau.u1) annotation (Line(
1142            points={{-30.9,3},{-26,3},{-26,2},{-20,2}},
1143            color={0,0,127},
1144            smooth=Smooth.None));
1145        connect(createTau.y, inertia.tau) annotation (Line(
1146            points={{3,-4},{10.55,-4},{10.55,40}},
1147            color={0,0,127},
1148            smooth=Smooth.None));
1149        connect(effMap.tau, inertia.tau) annotation (Line(
1150            points={{18,-32},{10,-32},{10,-4},{10.55,-4},{10.55,40}},
1151            color={0,0,127},
1152            smooth=Smooth.None));
1153        annotation (
1154          Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
1155                  {100,100}}), graphics),
1156          Icon(coordinateSystem(
1157              extent={{-100,-100},{100,100}},
1158              preserveAspectRatio=false,
1159              initialScale=0.1,
1160              grid={2,2}), graphics={
1161              Rectangle(
1162                origin={-25,2},
1163                extent={{-75,74},{125,-74}},
1164                lineColor={0,0,0},
1165                fillColor={255,255,255},
1166                fillPattern=FillPattern.Solid),
1167              Text(
1168                origin={4,-6},
1169                lineColor={0,0,255},
1170                extent={{-110,84},{100,44}},
1171                textString="%name"),
1172              Rectangle(
1173                fillColor={192,192,192},
1174                fillPattern=FillPattern.HorizontalCylinder,
1175                extent={{-64,38},{64,-44}}),
1176              Rectangle(
1177                fillColor={192,192,192},
1178                fillPattern=FillPattern.HorizontalCylinder,
1179                extent={{-100,10},{-64,-10}}),
1180              Rectangle(
1181                fillColor={192,192,192},
1182                fillPattern=FillPattern.HorizontalCylinder,
1183                extent={{64,8},{100,-12}}),
1184              Line(
1185                origin={20,0},
1186                points={{-60,94},{-60,76}},
1187                color={0,0,255}),
1188              Line(
1189                origin={-20,0},
1190                points={{60,94},{60,76}},
1191                color={0,0,255}),
1192              Text(
1193                origin={66,-32},
1194                extent={{-108,-46},{100,-84}},
1195                textString="J=%J")}),
1196          Documentation(info="<html>
1197<p>This model receives from the connector the torque request (variable MotTauInt) and trieds to deliver it.</p>
1198<p>Howeve,r before delivering the requested torque, the model limits it considering the maximum deliverable torque and power. In addition it computes and considers inner losses as determined by means of a map. </p>
1199</html>"));
1200      end PartialMBTwoFlange;
1201
1202      partial model PartialMBice
1203        "Simple  map-based Internal Combustion Engine model"
1204        import Modelica.Constants.*;
1205        parameter Real vMass=1300;
1206        parameter Real wIceStart=167;
1207        // rad/s
1208        parameter Real iceJ=0.5 "ICE moment of inertia (kg.m^2)";
1209        parameter Real maxIceTau[:, :]=[0, 80; 100, 80; 350, 95; 500, 95]
1210          "curve of maximum ice torque (Nm)";
1211        parameter Real specificCons[:, :]=[0.0, 100, 200, 300, 400, 500; 10,
1212            630, 580, 550, 580, 630; 20, 430, 420, 400, 400, 450; 30, 320, 325,
1213            330, 340, 350; 40, 285, 285, 288, 290, 300; 50, 270, 265, 265, 270,
1214            275; 60, 255, 248, 250, 255, 258; 70, 245, 237, 238, 243, 246; 80,
1215            245, 230, 233, 237, 240; 90, 235, 230, 228, 233, 235]
1216          "curve of ice specific consumption (g/kWh)";
1217        Modelica.Mechanics.Rotational.Sensors.SpeedSensor w annotation (
1218            Placement(visible=true, transformation(
1219              origin={52,44},
1220              extent={{-10,-10},{10,10}},
1221              rotation=270)));
1222        Modelica.Blocks.Math.Min min1 annotation (Placement(visible=true,
1223              transformation(extent={{-48,50},{-28,70}}, rotation=0)));
1224        Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a annotation (
1225            Placement(
1226            visible=true,
1227            transformation(extent={{90,10},{110,30}}, rotation=0),
1228            iconTransformation(extent={{90,10},{110,30}}, rotation=0)));
1229        Modelica.Mechanics.Rotational.Sensors.PowerSensor icePow annotation (
1230            Placement(visible=true, transformation(extent={{66,50},{86,70}},
1231                rotation=0)));
1232        Modelica.Mechanics.Rotational.Sources.Torque Tice annotation (Placement(
1233              visible=true, transformation(extent={{-12,50},{8,70}}, rotation=0)));
1234        Modelica.Mechanics.Rotational.Components.Inertia inertia(w(
1235            fixed=true,
1236            start=wIceStart,
1237            displayUnit="rpm"), J=iceJ) annotation (Placement(visible=true,
1238              transformation(extent={{16,50},{36,70}}, rotation=0)));
1239        Modelica.Blocks.Math.Product toPow0 annotation (Placement(visible=true,
1240              transformation(
1241              origin={0,12},
1242              extent={{-10,-10},{10,10}},
1243              rotation=-90)));
1244        Modelica.Blocks.Math.Product toG_perHour annotation (Placement(visible=
1245                true, transformation(
1246              origin={34,-48},
1247              extent={{-10,-10},{10,10}},
1248              rotation=-90)));
1249        //  Modelica.Blocks.Continuous.Integrator toGrams(k = 1 / 3600000.0)
1250        // annotation(Placement(visible = true, transformation(origin = {26, -44},
1251        //extent = {{-10, -10}, {10, 10}}, rotation = 270)));
1252        Modelica.Blocks.Tables.CombiTable1D toLimTau(table=maxIceTau)
1253          annotation (Placement(visible=true, transformation(
1254              origin={-72,66},
1255              extent={{10,-10},{-10,10}},
1256              rotation=180)));
1257        Modelica.Blocks.Sources.RealExpression rotorW(y=w.w) annotation (
1258            Placement(transformation(
1259              extent={{-10,-10},{10,10}},
1260              rotation=90,
1261              origin={-88,36})));
1262        Modelica.Blocks.Math.Gain tokW(k=1e-3) annotation (Placement(
1263              transformation(
1264              extent={{-10,-10},{10,10}},
1265              rotation=-90,
1266              origin={0,-18})));
1267        Modelica.Blocks.Tables.CombiTable2D toSpecCons(table=specificCons)
1268          annotation (Placement(transformation(
1269              extent={{-10,10},{10,-10}},
1270              rotation=-90,
1271              origin={40,0})));
1272      equation
1273        connect(toPow0.u1, w.w)
1274          annotation (Line(points={{6,24},{6,33},{52,33}}, color={0,0,127}));
1275        connect(toPow0.u2, min1.y) annotation (Line(points={{-6,24},{-6,32},{-22,
1276                32},{-22,60},{-27,60}}, color={0,0,127}));
1277        connect(w.flange, inertia.flange_b)
1278          annotation (Line(points={{52,54},{52,60},{36,60}}));
1279        connect(icePow.flange_a, inertia.flange_b)
1280          annotation (Line(points={{66,60},{36,60}}));
1281        connect(Tice.flange, inertia.flange_a)
1282          annotation (Line(points={{8,60},{16,60}}));
1283        connect(Tice.tau, min1.y)
1284          annotation (Line(points={{-14,60},{-27,60}}, color={0,0,127}));
1285        connect(icePow.flange_b, flange_a)
1286          annotation (Line(points={{86,60},{94,60},{94,20},{100,20}}));
1287        connect(min1.u1, toLimTau.y[1]) annotation (Line(
1288            points={{-50,66},{-61,66}},
1289            color={0,0,127},
1290            smooth=Smooth.None));
1291        connect(toLimTau.u[1], rotorW.y) annotation (Line(
1292            points={{-84,66},{-88,66},{-88,47}},
1293            color={0,0,127},
1294            smooth=Smooth.None));
1295        connect(toPow0.y, tokW.u) annotation (Line(
1296            points={{-2.22045e-015,1},{-2.22045e-015,-2},{2.22045e-015,-2},{
1297                2.22045e-015,-6}},
1298            color={0,0,127},
1299            smooth=Smooth.None));
1300        connect(toSpecCons.y, toG_perHour.u1)
1301          annotation (Line(points={{40,-11},{40,-36}}, color={0,0,127}));
1302        connect(toG_perHour.u2, tokW.y) annotation (Line(points={{28,-36},{28,-32},
1303                {0,-32},{0,-29}}, color={0,0,127}));
1304        connect(toSpecCons.u2, w.w) annotation (Line(points={{46,12},{46,28},{
1305                52,28},{52,33}}, color={0,0,127}));
1306        connect(toSpecCons.u1, min1.y) annotation (Line(points={{34,12},{34,40},
1307                {-22,40},{-22,60},{-27,60}}, color={0,0,127}));
1308        annotation (
1309          Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-80},
1310                  {100,80}})),
1311          experiment(
1312            StopTime=200,
1313            __Dymola_NumberOfIntervals=1000,
1314            __Dymola_Algorithm="Lsodar"),
1315          __Dymola_experimentSetupOutput,
1316          Documentation(info="<html>
1317<h4>Basic map-based ICE model.</h4>
1318<p>It receives as input the reference torque as a fracton of the maximum deliverable torque at a given speed. It can be approximately thought as a signal proportional to the accelerator position oF the vehicle.</p>
1319<p>The generated torque is the minimum between this signal and the maximum deliverable torque at the actual engine speed (defined by means of a table).</p>
1320<p>From the generated torque and speed the fuel consumption is computed.</p>
1321<p>The used maxTorque (toLimTau) and specific fuel consumption (toSpecCons) maps are inspired to public data related to the Toyota Prius&apos; engine </p>
1322</html>"),
1323          Icon(coordinateSystem(
1324              extent={{-100,-100},{100,100}},
1325              preserveAspectRatio=false,
1326              initialScale=0.1,
1327              grid={2,2}), graphics={
1328              Rectangle(
1329                extent={{-100,80},{100,-80}},
1330                lineColor={0,0,0},
1331                fillColor={255,255,255},
1332                fillPattern=FillPattern.Solid),
1333              Rectangle(
1334                fillColor={192,192,192},
1335                fillPattern=FillPattern.HorizontalCylinder,
1336                extent={{-24,68},{76,-24}}),
1337              Rectangle(
1338                fillColor={192,192,192},
1339                fillPattern=FillPattern.HorizontalCylinder,
1340                extent={{76,30},{100,10}}),
1341              Text(
1342                extent={{-140,-32},{140,-70}},
1343                textString="J=%inertiaJ",
1344                lineColor={0,0,0}),
1345              Text(
1346                origin={0,30},
1347                lineColor={0,0,255},
1348                extent={{-140,100},{140,60}},
1349                textString="%name"),
1350              Rectangle(extent={{-90,68},{-32,-26}}),
1351              Rectangle(
1352                fillColor={95,95,95},
1353                fillPattern=FillPattern.Solid,
1354                extent={{-90,22},{-32,0}}),
1355              Line(points={{-60,56},{-60,32}}),
1356              Polygon(points={{-60,66},{-66,56},{-54,56},{-60,66}}),
1357              Polygon(points={{-60,24},{-66,34},{-54,34},{-60,24}}),
1358              Rectangle(
1359                fillColor={135,135,135},
1360                fillPattern=FillPattern.Solid,
1361                extent={{-64,0},{-54,-20}})}));
1362      end PartialMBice;
1363
1364      model PartialMBiceP_old
1365        "Simple map-based ice model with connector and Power request"
1366        import Modelica.Constants.*;
1367        parameter Real contrGain=0.1 "Proportional controller gain (Nm/W)";
1368        parameter Real wIceStart=167;
1369        parameter Real iceJ=0.5 "ICE moment of Inertia (kg.m^2)";
1370        // rad/s
1371        Modelica.Mechanics.Rotational.Components.Inertia inertia(w(
1372            fixed=true,
1373            start=wIceStart,
1374            displayUnit="rpm"), J=iceJ)
1375          annotation (Placement(transformation(extent={{20,42},{40,62}})));
1376        Modelica.Mechanics.Rotational.Sources.Torque iceTau
1377          annotation (Placement(transformation(extent={{-12,42},{8,62}})));
1378        Modelica.Mechanics.Rotational.Sensors.PowerSensor Pice
1379          annotation (Placement(transformation(extent={{66,62},{86,42}})));
1380        Modelica.Mechanics.Rotational.Sensors.SpeedSensor w annotation (
1381            Placement(transformation(
1382              extent={{-10,-10},{10,10}},
1383              rotation=270,
1384              origin={52,36})));
1385        Modelica.Blocks.Math.Product toPow0 annotation (Placement(
1386              transformation(
1387              extent={{-10,-10},{10,10}},
1388              rotation=-90,
1389              origin={-22,10})));
1390        Modelica.Blocks.Math.Feedback feedback
1391          annotation (Placement(transformation(extent={{-90,62},{-70,42}})));
1392        Modelica.Blocks.Math.Gain gain(k=contrGain)
1393          annotation (Placement(transformation(extent={{-58,42},{-38,62}})));
1394        Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a annotation (
1395            Placement(transformation(extent={{90,-10},{110,10}}),
1396              iconTransformation(extent={{90,-10},{110,10}})));
1397        Modelica.Blocks.Tables.CombiTable2D toGramsPerkWh(table=specificCons)
1398          annotation (Placement(transformation(
1399              extent={{-10,10},{10,-10}},
1400              rotation=-90,
1401              origin={42,-2})));
1402      protected
1403        parameter Real specificCons[:, :]=[0.0, 100, 200, 300, 400, 500; 10,
1404            630, 580, 550, 580, 630; 20, 430, 420, 400, 400, 450; 30, 320, 325,
1405            330, 340, 350; 40, 285, 285, 288, 290, 300; 50, 270, 265, 265, 270,
1406            275; 60, 255, 248, 250, 255, 258; 70, 245, 237, 238, 243, 246; 80,
1407            245, 230, 233, 237, 240; 90, 235, 230, 228, 233, 235]
1408          "curve of ice specific consumption (g/kWh)";
1409      public
1410        Modelica.Blocks.Math.Gain tokW(k=0.001) annotation (Placement(
1411              transformation(
1412              extent={{-10,-10},{10,10}},
1413              rotation=-90,
1414              origin={-22,-18})));
1415        Modelica.Blocks.Math.Product toG_perHour annotation (Placement(visible=
1416                true, transformation(
1417              origin={24,-48},
1418              extent={{-10,-10},{10,10}},
1419              rotation=-90)));
1420      equation
1421        connect(iceTau.flange, inertia.flange_a) annotation (Line(
1422            points={{8,52},{20,52}},
1423            color={0,0,0},
1424            smooth=Smooth.None));
1425        connect(Pice.flange_a, inertia.flange_b) annotation (Line(
1426            points={{66,52},{40,52}},
1427            color={0,0,0},
1428            smooth=Smooth.None));
1429        connect(Pice.flange_b, flange_a) annotation (Line(
1430            points={{86,52},{94,52},{94,0},{100,0}},
1431            color={0,0,0},
1432            smooth=Smooth.None));
1433        connect(w.flange, inertia.flange_b) annotation (Line(
1434            points={{52,46},{52,52},{40,52}},
1435            color={0,0,0},
1436            smooth=Smooth.None));
1437        connect(toPow0.u1, w.w) annotation (Line(
1438            points={{-16,22},{-16,25},{52,25}},
1439            color={0,0,127},
1440            smooth=Smooth.None));
1441        connect(toPow0.u2, iceTau.tau) annotation (Line(
1442            points={{-28,22},{-28,52},{-14,52}},
1443            color={0,0,127},
1444            smooth=Smooth.None));
1445        connect(feedback.u2, Pice.power) annotation (Line(
1446            points={{-80,60},{-80,72},{68,72},{68,63}},
1447            color={0,0,127},
1448            smooth=Smooth.None));
1449        connect(gain.y, iceTau.tau) annotation (Line(
1450            points={{-37,52},{-14,52}},
1451            color={0,0,127},
1452            smooth=Smooth.None));
1453        connect(gain.u, feedback.y) annotation (Line(
1454            points={{-60,52},{-71,52}},
1455            color={0,0,127},
1456            smooth=Smooth.None));
1457        connect(toGramsPerkWh.u2, w.w) annotation (Line(points={{48,10},{48,10},
1458                {48,16},{48,20},{50,20},{52,20},{52,25}}, color={0,0,127}));
1459        connect(toGramsPerkWh.u1, iceTau.tau) annotation (Line(points={{36,10},
1460                {36,32},{-28,32},{-28,52},{-14,52}}, color={0,0,127}));
1461        connect(toPow0.y, tokW.u)
1462          annotation (Line(points={{-22,-1},{-22,-6}}, color={0,0,127}));
1463        connect(tokW.y, toG_perHour.u2) annotation (Line(points={{-22,-29},{18,
1464                -29},{18,-36}}, color={0,0,127}));
1465        connect(toG_perHour.u1, toGramsPerkWh.y) annotation (Line(points={{30,-36},
1466                {30,-26},{42,-26},{42,-13}}, color={0,0,127}));
1467        annotation (
1468          Diagram(coordinateSystem(
1469              preserveAspectRatio=false,
1470              extent={{-100,-80},{100,80}},
1471              initialScale=0.1), graphics={Text(
1472                      extent={{-86,6},{-46,-16}},
1473                      lineColor={0,0,0},
1474                      textString="follows the power
1475 reference and
1476 computes consumption")}),
1477          experiment(
1478            StopTime=200,
1479            __Dymola_NumberOfIntervals=1000,
1480            __Dymola_Algorithm="Lsodar"),
1481          __Dymola_experimentSetupOutput,
1482          Documentation(info="<html>
1483<p><b><span style=\"font-family: MS Shell Dlg 2;\">Simple map-based ICE model for power-split power trains - with connector</b> </span></p>
1484<p><span style=\"font-family: MS Shell Dlg 2;\">This is a &QUOT;connector&QUOT; version of MBice.</span></p>
1485<p><span style=\"font-family: MS Shell Dlg 2;\">For a general descritiption see the info of MBice.</span></p>
1486<p><span style=\"font-family: MS Shell Dlg 2;\">Signals connected to the connector:</span></p>
1487<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowRef (input) is the power request (W). Negative values are internally converted to zero</span></p>
1488<p><span style=\"font-family: MS Shell Dlg 2;\">- iceW (output) is the measured ICE speed (rad/s)</span></p>
1489<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowDel (output) delivered power (W)</span></p>
1490</html>"),
1491          Icon(coordinateSystem(
1492              extent={{-100,-100},{100,100}},
1493              preserveAspectRatio=false,
1494              initialScale=0.1,
1495              grid={2,2}), graphics={Rectangle(
1496                      fillColor={192,192,192},
1497                      fillPattern=FillPattern.HorizontalCylinder,
1498                      extent={{-24,48},{76,-44}}),Rectangle(
1499                      fillColor={192,192,192},
1500                      fillPattern=FillPattern.HorizontalCylinder,
1501                      extent={{76,10},{100,-10}}),Text(
1502                      origin={-2,0},
1503                      extent={{-140,-52},{140,-90}},
1504                      textString="J=%J"),Rectangle(extent={{-100,62},{100,-100}}),
1505                Text( origin={0,10},
1506                      lineColor={0,0,255},
1507                      extent={{-140,100},{140,60}},
1508                      textString="%name"),Rectangle(extent={{-90,48},{-32,-46}}),
1509                Rectangle(
1510                      fillColor={95,95,95},
1511                      fillPattern=FillPattern.Solid,
1512                      extent={{-90,2},{-32,-20}}),Line(points={{-60,36},{-60,12}}),
1513                Polygon(points={{-60,46},{-66,36},{-54,36},{-60,46}}),Polygon(
1514                points={{-60,4},{-66,14},{-54,14},{-60,4}}),Rectangle(
1515                      fillColor={135,135,135},
1516                      fillPattern=FillPattern.Solid,
1517                      extent={{-64,-20},{-54,-40}})}));
1518      end PartialMBiceP_old;
1519
1520      model PartialMBiceP
1521        "Simple map-based ice model with connector and Power request"
1522        import Modelica.Constants.*;
1523        parameter Real contrGain=0.1 "Proportional controller gain (Nm/W)";
1524        parameter Real wIceStart=167;
1525        parameter Real iceJ=0.5 "ICE moment of Inertia (kg.m^2)";
1526        // rad/s
1527        Modelica.Mechanics.Rotational.Components.Inertia inertia(w(
1528            fixed=true,
1529            start=wIceStart,
1530            displayUnit="rpm"), J=iceJ) annotation (Placement(visible=true,
1531              transformation(extent={{30,42},{50,62}}, rotation=0)));
1532        Modelica.Mechanics.Rotational.Sources.Torque iceTau annotation (
1533            Placement(visible=true, transformation(extent={{4,42},{24,62}},
1534                rotation=0)));
1535        Modelica.Mechanics.Rotational.Sensors.PowerSensor Pice
1536          annotation (Placement(transformation(extent={{66,62},{86,42}})));
1537        Modelica.Mechanics.Rotational.Sensors.SpeedSensor w annotation (
1538            Placement(visible=true, transformation(
1539              origin={58,36},
1540              extent={{-10,-10},{10,10}},
1541              rotation=270)));
1542        Modelica.Blocks.Math.Product toPow0 annotation (Placement(visible=true,
1543              transformation(
1544              origin={-18,10},
1545              extent={{-10,-10},{10,10}},
1546              rotation=-90)));
1547        Modelica.Blocks.Math.Feedback feedback
1548          annotation (Placement(transformation(extent={{-90,62},{-70,42}})));
1549        Modelica.Blocks.Math.Gain gain(k=contrGain) annotation (Placement(
1550              visible=true, transformation(extent={{-62,42},{-42,62}}, rotation
1551                =0)));
1552        Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a annotation (
1553            Placement(transformation(extent={{90,-10},{110,10}}),
1554              iconTransformation(extent={{90,-10},{110,10}})));
1555        Modelica.Blocks.Tables.CombiTable2D toGramsPerkWh(table=specificCons)
1556          annotation (Placement(transformation(
1557              extent={{-10,10},{10,-10}},
1558              rotation=-90,
1559              origin={42,-2})));
1560        Modelica.Blocks.Math.Gain tokW(k=0.001) annotation (Placement(visible=
1561                true, transformation(
1562              origin={-18,-18},
1563              extent={{-10,-10},{10,10}},
1564              rotation=-90)));
1565        Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=1e99, uMin=0)
1566          annotation (Placement(visible=true, transformation(
1567              origin={-22,52},
1568              extent={{-10,-10},{10,10}},
1569              rotation=0)));
1570      protected
1571        parameter Real specificCons[:, :]=[0.0, 100, 200, 300, 400, 500; 10,
1572            630, 580, 550, 580, 630; 20, 430, 420, 400, 400, 450; 30, 320, 325,
1573            330, 340, 350; 40, 285, 285, 288, 290, 300; 50, 270, 265, 265, 270,
1574            275; 60, 255, 248, 250, 255, 258; 70, 245, 237, 238, 243, 246; 80,
1575            245, 230, 233, 237, 240; 90, 235, 230, 228, 233, 235]
1576          "curve of ice specific consumption (g/kWh)";
1577      equation
1578        connect(toPow0.y, tokW.u)
1579          annotation (Line(points={{-18,-1},{-18,-6}}, color={0,0,127}));
1580        connect(toPow0.u2, iceTau.tau) annotation (Line(points={{-24,22},{-24,
1581                32},{-6,32},{-6,52},{2,52}}, color={0,0,127}));
1582        connect(iceTau.tau, limiter1.y) annotation (Line(points={{2,52},{-10,52},
1583                {-10,52},{-11,52}}, color={0,0,127}));
1584        connect(limiter1.u, gain.y) annotation (Line(points={{-34,52},{-42,52},
1585                {-42,52},{-41,52}}, color={0,0,127}));
1586        connect(toGramsPerkWh.u1, iceTau.tau) annotation (Line(points={{36,10},
1587                {36,32},{-6,32},{-6,52},{2,52}}, color={0,0,127}));
1588        connect(iceTau.flange, inertia.flange_a)
1589          annotation (Line(points={{24,52},{30,52}}));
1590        connect(w.flange, inertia.flange_b)
1591          annotation (Line(points={{58,46},{58,52},{50,52}}));
1592        connect(Pice.flange_a, inertia.flange_b)
1593          annotation (Line(points={{66,52},{50,52}}));
1594        connect(toGramsPerkWh.u2, w.w) annotation (Line(points={{48,10},{48,20},
1595                {58,20},{58,25}}, color={0,0,127}));
1596        connect(toPow0.u1, w.w) annotation (Line(points={{-12,22},{-12,25},{58,
1597                25}}, color={0,0,127}));
1598        connect(gain.u, feedback.y)
1599          annotation (Line(points={{-64,52},{-71,52}}, color={0,0,127}));
1600        connect(Pice.flange_b, flange_a) annotation (Line(
1601            points={{86,52},{94,52},{94,0},{100,0}},
1602            color={0,0,0},
1603            smooth=Smooth.None));
1604        connect(feedback.u2, Pice.power) annotation (Line(
1605            points={{-80,60},{-80,72},{68,72},{68,63}},
1606            color={0,0,127},
1607            smooth=Smooth.None));
1608        annotation (
1609          Diagram(coordinateSystem(
1610              preserveAspectRatio=false,
1611              extent={{-100,-80},{100,80}},
1612              initialScale=0.1), graphics={Text(
1613                      extent={{-86,6},{-46,-16}},
1614                      lineColor={0,0,0},
1615                      textString="follows the power
1616 reference and computes consumption")}),
1617          Documentation(info="<html>
1618<p><b><span style=\"font-family: MS Shell Dlg 2;\">Simple map-based ICE model for power-split power trains - with connector</b> </span></p>
1619<p><span style=\"font-family: MS Shell Dlg 2;\">This is a &QUOT;connector&QUOT; version of MBice.</span></p>
1620<p><span style=\"font-family: MS Shell Dlg 2;\">For a general descritiption see the info of MBice.</span></p>
1621<p><span style=\"font-family: MS Shell Dlg 2;\">Signals connected to the connector:</span></p>
1622<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowRef (input) is the power request (W). Negative values are internally converted to zero</span></p>
1623<p><span style=\"font-family: MS Shell Dlg 2;\">- iceW (output) is the measured ICE speed (rad/s)</span></p>
1624<p><span style=\"font-family: MS Shell Dlg 2;\">- icePowDel (output) delivered power (W)</span></p>
1625</html>"),
1626          Icon(coordinateSystem(
1627              extent={{-100,-100},{100,100}},
1628              preserveAspectRatio=false,
1629              initialScale=0.1,
1630              grid={2,2}), graphics={
1631              Rectangle(
1632                fillColor={192,192,192},
1633                fillPattern=FillPattern.HorizontalCylinder,
1634                extent={{-24,48},{76,-44}}),
1635              Rectangle(
1636                fillColor={192,192,192},
1637                fillPattern=FillPattern.HorizontalCylinder,
1638                extent={{76,10},{100,-10}}),
1639              Text(
1640                origin={-2,0},
1641                extent={{-140,-52},{140,-90}},
1642                textString="J=%J"),
1643              Rectangle(extent={{-100,62},{100,-100}}),
1644              Text(
1645                origin={0,10},
1646                lineColor={0,0,255},
1647                extent={{-140,100},{140,60}},
1648                textString="%name"),
1649              Rectangle(extent={{-90,48},{-32,-46}}),
1650              Rectangle(
1651                fillColor={95,95,95},
1652                fillPattern=FillPattern.Solid,
1653                extent={{-90,2},{-32,-20}}),
1654              Line(points={{-60,36},{-60,12}}),
1655              Polygon(points={{-60,46},{-66,36},{-54,36},{-60,46}}),
1656              Polygon(points={{-60,4},{-66,14},{-54,14},{-60,4}}),
1657              Rectangle(
1658                fillColor={135,135,135},
1659                fillPattern=FillPattern.Solid,
1660                extent={{-64,-20},{-54,-40}})}),
1661          uses(Modelica(version="3.2.2")));
1662      end PartialMBiceP;
1663    end Partial;
1664
1665    model MBecu1
1666      "Power Split hybrid power train controller, not using ON/OFF strategy"
1667      parameter Real genTorqueMax=80
1668        "maximum absolute valoe of gen torque (Nm)";
1669      parameter Real maxTorqueReq=80
1670        "Torque request (Nm) that corresponds to 1 from driver";
1671      parameter Real powFiltT=60 "Power filter time constant (s)";
1672      parameter Real genLoopGain=0.1
1673        "Control gain between ice speed error and gen torque: Nm/(rad/s)";
1674      Modelica.Blocks.Interfaces.RealInput tauReference annotation (Placement(
1675          visible=true,
1676          transformation(extent={{-140,-20},{-100,20}}, rotation=0),
1677          iconTransformation(extent={{-140,-20},{-100,20}}, rotation=0)));
1678      Modelica.Blocks.Continuous.FirstOrder powFilt(T=powFiltT) annotation (
1679          Placement(visible=true, transformation(
1680            origin={-40,40},
1681            extent={{-10,-10},{10,10}},
1682            rotation=-90)));
1683      SupportModels.Conn conn1 annotation (Placement(
1684          visible=true,
1685          transformation(extent={{-20,60},{20,100}}, rotation=0),
1686          iconTransformation(extent={{-20,78},{20,118}}, rotation=0)));
1687      Modelica.Blocks.Math.Gain gain(k=genLoopGain) annotation (Placement(
1688            visible=true, transformation(extent={{32,-30},{52,-10}}, rotation=0)));
1689      Modelica.Blocks.Math.Feedback feedback annotation (Placement(visible=true,
1690            transformation(extent={{6,-10},{26,-30}}, rotation=0)));
1691      Modelica.Blocks.Nonlinear.Limiter limiter(uMax=genTorqueMax, uMin=-
1692            genTorqueMax) annotation (Placement(visible=true, transformation(
1693            origin={60,40},
1694            extent={{-10,-10},{10,10}},
1695            rotation=90)));
1696      Modelica.Blocks.Tables.CombiTable1Ds powToW(
1697        fileName="wToTau.txt",
1698        tableOnFile=false,
1699        table=[0, 0; 1884, 126; 9800, 126; 36600, 366; 52300, 523])
1700        "optimal ice speed as a function of power" annotation (Placement(
1701            transformation(
1702            extent={{-10,-10},{10,10}},
1703            rotation=0,
1704            origin={-40,-20})));
1705      Modelica.Blocks.Math.Gain toNm(k=maxTorqueReq)
1706        "converts p.u. torque request into Nm" annotation (Placement(visible=
1707              true, transformation(
1708            extent={{-10,-10},{10,10}},
1709            rotation=90,
1710            origin={-80,32})));
1711      Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=1e6, uMin=125)
1712        annotation (Placement(visible=true, transformation(
1713            origin={-10,-20},
1714            extent={{-10,-10},{10,10}},
1715            rotation=0)));
1716      Modelica.Blocks.Continuous.FirstOrder genTauFilt(T=1) annotation (
1717          Placement(visible=true, transformation(
1718            origin={60,12},
1719            extent={{10,-10},{-10,10}},
1720            rotation=-90)));
1721    equation
1722      connect(powFilt.u, conn1.motPowDelB) annotation (Line(points={{-40,52},{-40,
1723              60},{0,60},{0,80}}, color={0,0,127}));
1724      connect(powFilt.y, conn1.icePowRef) annotation (Line(
1725          points={{-40,29},{-40,20},{0,20},{0,80}},
1726          color={0,0,127},
1727          smooth=Smooth.None), Text(
1728          string="%second",
1729          index=1,
1730          extent={{6,3},{6,3}}));
1731      connect(gain.u, feedback.y)
1732        annotation (Line(points={{30,-20},{25,-20}}, color={0,0,127}));
1733      connect(powToW.u, powFilt.y) annotation (Line(
1734          points={{-52,-20},{-60,-20},{-60,20},{-40,20},{-40,29}},
1735          color={0,0,127},
1736          smooth=Smooth.None));
1737      connect(feedback.u2, conn1.iceW) annotation (Line(
1738          points={{16,-12},{16,40},{16,40},{16,66},{0,66},{0,80}},
1739          color={0,0,127},
1740          smooth=Smooth.None), Text(
1741          string="%second",
1742          index=1,
1743          extent={{6,3},{6,3}}));
1744      connect(limiter.y, conn1.genTauRef) annotation (Line(
1745          points={{60,51},{60,74},{0,74},{0,80}},
1746          color={0,0,127},
1747          smooth=Smooth.None), Text(
1748          string="%second",
1749          index=1,
1750          extent={{6,3},{6,3}}));
1751      connect(toNm.u, tauReference) annotation (Line(
1752          points={{-80,20},{-80,0},{-120,0}},
1753          color={0,0,127},
1754          smooth=Smooth.None));
1755      connect(toNm.y, conn1.motTauRef) annotation (Line(
1756          points={{-80,43},{-80,80},{0,80}},
1757          color={0,0,127},
1758          smooth=Smooth.None), Text(
1759          string="%second",
1760          index=1,
1761          extent={{6,3},{6,3}}));
1762      connect(feedback.u1, limiter1.y) annotation (Line(
1763          points={{8,-20},{1,-20}},
1764          color={0,0,127},
1765          smooth=Smooth.None));
1766      connect(limiter1.u, powToW.y[1]) annotation (Line(
1767          points={{-22,-20},{-29,-20}},
1768          color={0,0,127},
1769          smooth=Smooth.None));
1770      connect(limiter.u, genTauFilt.y) annotation (Line(
1771          points={{60,28},{60,23}},
1772          color={0,0,127},
1773          smooth=Smooth.None));
1774      connect(genTauFilt.u, gain.y) annotation (Line(
1775          points={{60,0},{60,-20},{53,-20}},
1776          color={0,0,127},
1777          smooth=Smooth.None));
1778      annotation (
1779        Diagram(coordinateSystem(
1780            extent={{-100,-60},{100,80}},
1781            preserveAspectRatio=false,
1782            initialScale=0.1,
1783            grid={2,2}), graphics={Text(
1784                  extent={{-82,74},{-24,70}},
1785                  lineColor={0,0,0},
1786                  textString="Send requested torque to mot"),Text(
1787                  extent={{-22,16},{6,12}},
1788                  lineColor={0,0,0},
1789                  textString="send filtered
1790power to ice"),Text(
1791                  extent={{62,70},{90,66}},
1792                  lineColor={0,0,0},
1793                  textString="send
1794reference tau
1795to gen",          horizontalAlignment=TextAlignment.Left)}),
1796        Icon(coordinateSystem(
1797            extent={{-100,-100},{100,100}},
1798            preserveAspectRatio=false,
1799            initialScale=0.1,
1800            grid={2,2}), graphics={
1801            Text(
1802              lineColor={0,0,255},
1803              extent={{-100,-102},{100,-140}},
1804              textString="%name"),
1805            Rectangle(
1806              extent={{-100,100},{100,-100}},
1807              lineColor={0,0,0},
1808              fillColor={255,255,255},
1809              fillPattern=FillPattern.Solid),
1810            Polygon(
1811              points={{-4,-40},{74,16},{74,-6},{-4,-62},{-4,-40}},
1812              lineColor={95,95,95},
1813              fillColor={175,175,175},
1814              fillPattern=FillPattern.Solid),
1815            Polygon(
1816              points={{8,-38},{28,-48},{20,-54},{0,-44},{8,-38}},
1817              lineColor={0,0,255},
1818              fillColor={255,255,0},
1819              fillPattern=FillPattern.Solid),
1820            Polygon(
1821              points={{20,-54},{28,-48},{32,-56},{24,-62},{20,-54}},
1822              lineColor={0,0,255},
1823              fillColor={255,255,0},
1824              fillPattern=FillPattern.Solid),
1825            Polygon(
1826              points={{24,-62},{32,-56},{32,-78},{24,-84},{24,-62}},
1827              lineColor={0,0,255},
1828              fillColor={255,255,127},
1829              fillPattern=FillPattern.Solid),
1830            Polygon(
1831              points={{0,-44},{20,-54},{24,-62},{24,-84},{22,-84},{22,-62},{20,
1832                  -58},{0,-48},{0,-44}},
1833              lineColor={0,0,255},
1834              fillColor={191,191,0},
1835              fillPattern=FillPattern.Solid),
1836            Polygon(
1837              points={{-14,40},{-18,32},{-10,38},{-8,44},{-14,40}},
1838              lineColor={128,128,128},
1839              fillColor={128,128,128},
1840              fillPattern=FillPattern.Solid),
1841            Polygon(
1842              points={{-18,32},{-10,38},{-10,14},{-18,8},{-18,32}},
1843              lineColor={0,0,255},
1844              fillColor={255,255,127},
1845              fillPattern=FillPattern.Solid),
1846            Polygon(
1847              points={{-20,10},{-20,32},{-16,40},{4,30},{4,26},{-16,36},{-18,32},
1848                  {-18,8},{-20,10}},
1849              lineColor={0,0,255},
1850              fillColor={191,191,0},
1851              fillPattern=FillPattern.Solid),
1852            Polygon(
1853              points={{-8,46},{12,36},{4,30},{-16,40},{-8,46}},
1854              lineColor={0,0,255},
1855              fillColor={255,255,0},
1856              fillPattern=FillPattern.Solid),
1857            Polygon(
1858              points={{28,-22},{48,-32},{40,-38},{20,-28},{28,-22}},
1859              lineColor={0,0,255},
1860              fillColor={255,255,0},
1861              fillPattern=FillPattern.Solid),
1862            Polygon(
1863              points={{40,-38},{48,-32},{52,-40},{44,-46},{40,-38}},
1864              lineColor={0,0,255},
1865              fillColor={255,255,0},
1866              fillPattern=FillPattern.Solid),
1867            Polygon(
1868              points={{44,-46},{52,-40},{52,-62},{44,-68},{44,-46}},
1869              lineColor={0,0,255},
1870              fillColor={255,255,127},
1871              fillPattern=FillPattern.Solid),
1872            Polygon(
1873              points={{20,-28},{40,-38},{44,-46},{44,-68},{42,-68},{42,-46},{40,
1874                  -42},{20,-32},{20,-28}},
1875              lineColor={0,0,255},
1876              fillColor={191,191,0},
1877              fillPattern=FillPattern.Solid),
1878            Polygon(
1879              points={{48,-8},{68,-18},{60,-24},{40,-14},{48,-8}},
1880              lineColor={0,0,255},
1881              fillColor={255,255,0},
1882              fillPattern=FillPattern.Solid),
1883            Polygon(
1884              points={{60,-24},{68,-18},{72,-26},{64,-32},{60,-24}},
1885              lineColor={0,0,255},
1886              fillColor={255,255,0},
1887              fillPattern=FillPattern.Solid),
1888            Polygon(
1889              points={{64,-32},{72,-26},{72,-48},{64,-54},{64,-32}},
1890              lineColor={0,0,255},
1891              fillColor={255,255,127},
1892              fillPattern=FillPattern.Solid),
1893            Polygon(
1894              points={{40,-14},{60,-24},{64,-32},{64,-54},{62,-54},{62,-32},{60,
1895                  -28},{40,-18},{40,-14}},
1896              lineColor={0,0,255},
1897              fillColor={191,191,0},
1898              fillPattern=FillPattern.Solid),
1899            Polygon(
1900              points={{68,6},{88,-4},{80,-10},{60,0},{68,6}},
1901              lineColor={0,0,255},
1902              fillColor={255,255,0},
1903              fillPattern=FillPattern.Solid),
1904            Polygon(
1905              points={{80,-10},{88,-4},{92,-12},{84,-18},{80,-10}},
1906              lineColor={0,0,255},
1907              fillColor={255,255,0},
1908              fillPattern=FillPattern.Solid),
1909            Polygon(
1910              points={{84,-18},{92,-12},{92,-34},{84,-40},{84,-18}},
1911              lineColor={0,0,255},
1912              fillColor={255,255,127},
1913              fillPattern=FillPattern.Solid),
1914            Polygon(
1915              points={{60,0},{80,-10},{84,-18},{84,-40},{82,-40},{82,-18},{80,-14},
1916                  {60,-4},{60,0}},
1917              lineColor={0,0,255},
1918              fillColor={191,191,0},
1919              fillPattern=FillPattern.Solid),
1920            Polygon(
1921              points={{-34,26},{-38,18},{-30,24},{-28,30},{-34,26}},
1922              lineColor={128,128,128},
1923              fillColor={128,128,128},
1924              fillPattern=FillPattern.Solid),
1925            Polygon(
1926              points={{-38,18},{-30,24},{-30,0},{-38,-6},{-38,18}},
1927              lineColor={0,0,255},
1928              fillColor={255,255,127},
1929              fillPattern=FillPattern.Solid),
1930            Polygon(
1931              points={{-40,-4},{-40,18},{-36,26},{-16,16},{-16,12},{-36,22},{-38,
1932                  18},{-38,-6},{-40,-4}},
1933              lineColor={0,0,255},
1934              fillColor={191,191,0},
1935              fillPattern=FillPattern.Solid),
1936            Polygon(
1937              points={{-28,32},{-8,22},{-16,16},{-36,26},{-28,32}},
1938              lineColor={0,0,255},
1939              fillColor={255,255,0},
1940              fillPattern=FillPattern.Solid),
1941            Polygon(
1942              points={{-54,12},{-58,4},{-50,10},{-48,16},{-54,12}},
1943              lineColor={128,128,128},
1944              fillColor={128,128,128},
1945              fillPattern=FillPattern.Solid),
1946            Polygon(
1947              points={{-58,4},{-50,10},{-50,-14},{-58,-20},{-58,4}},
1948              lineColor={0,0,255},
1949              fillColor={255,255,127},
1950              fillPattern=FillPattern.Solid),
1951            Polygon(
1952              points={{-60,-18},{-60,4},{-56,12},{-36,2},{-36,-2},{-56,8},{-58,
1953                  4},{-58,-20},{-60,-18}},
1954              lineColor={0,0,255},
1955              fillColor={191,191,0},
1956              fillPattern=FillPattern.Solid),
1957            Polygon(
1958              points={{-48,18},{-28,8},{-36,2},{-56,12},{-48,18}},
1959              lineColor={0,0,255},
1960              fillColor={255,255,0},
1961              fillPattern=FillPattern.Solid),
1962            Polygon(
1963              points={{-74,-4},{-78,-12},{-70,-6},{-68,0},{-74,-4}},
1964              lineColor={128,128,128},
1965              fillColor={128,128,128},
1966              fillPattern=FillPattern.Solid),
1967            Polygon(
1968              points={{-78,-12},{-70,-6},{-70,-30},{-78,-36},{-78,-12}},
1969              lineColor={0,0,255},
1970              fillColor={255,255,127},
1971              fillPattern=FillPattern.Solid),
1972            Polygon(
1973              points={{-80,-34},{-80,-12},{-76,-4},{-56,-14},{-56,-18},{-76,-8},
1974                  {-78,-12},{-78,-36},{-80,-34}},
1975              lineColor={0,0,255},
1976              fillColor={191,191,0},
1977              fillPattern=FillPattern.Solid),
1978            Polygon(
1979              points={{-68,2},{-48,-8},{-56,-14},{-76,-4},{-68,2}},
1980              lineColor={0,0,255},
1981              fillColor={255,255,0},
1982              fillPattern=FillPattern.Solid),
1983            Polygon(
1984              points={{-64,-8},{-4,-40},{-4,-62},{-64,-30},{-64,-8}},
1985              lineColor={95,95,95},
1986              fillColor={75,75,75},
1987              fillPattern=FillPattern.Solid),
1988            Polygon(
1989              points={{-64,-8},{-4,-40},{74,16},{14,48},{-64,-8}},
1990              lineColor={95,95,95},
1991              fillColor={160,160,164},
1992              fillPattern=FillPattern.Solid),
1993            Rectangle(
1994              extent={{-98,92},{98,62}},
1995              fillColor={255,255,255},
1996              fillPattern=FillPattern.Solid,
1997              pattern=LinePattern.None),
1998            Text(
1999              extent={{-100,84},{100,54}},
2000              lineColor={0,0,0},
2001              textString="PSD-ecu1")}),
2002        Documentation(info="<html>
2003<p><b><span style=\"font-family: MS Shell Dlg 2;\">Power Split Power Train Controller without ON/OFF</span></b></p>
2004<p><span style=\"font-family: MS Shell Dlg 2;\">This controller operates as follows:</span></p>
2005<ul>
2006<li><span style=\"font-family: MS Shell Dlg 2;\">it makes the ice deliver the average power needed by the power train</span></li>
2007<li><span style=\"font-family: MS Shell Dlg 2;\">it determines the optimal ice speed at which the requested power is delivered with minimum fuel consumption and asks the &QUOT;gen&QUOT; to control so that the ice opertes at that speed</span></li>
2008<li><span style=\"font-family: MS Shell Dlg 2;\">the vehicle motion is controlled acting on the &QUOT;mot&QUOT;.</span></li>
2009</ul>
2010<p><span style=\"font-family: MS Shell Dlg 2;\"></p><p>Since this technique allows only approximatively the correct energy balance of the vehicle, the battery tends to sdischarge.This is solved with MBEcu2, in which a closed loop StateOfCharge (SOC) control is added.</span></p>
2011<p><span style=\"font-family: MS Shell Dlg 2;\">So:</span></p>
2012<ul>
2013<li><span style=\"font-family: MS Shell Dlg 2;\">powFilt Block filters the delivered power to obtained the power to ask the ICE to deliver</span></li>
2014<li><span style=\"font-family: MS Shell Dlg 2;\">toIceWref converts the power to be requested from the ICE by its maximum torque at the actual speed</span></li>
2015<li><span style=\"font-family: MS Shell Dlg 2;\">after a limiting block, this torque is the reference signal of a feedback; the corresponnding error controls the Gen torque.</span></li>
2016</ul>
2017</html>"));
2018    end MBecu1;
2019
2020    model MBecu1soc
2021      "Power Split hybrid power train controller, with SOC control, without ON/OFF"
2022      parameter Real genTorqueMax=80
2023        "maximum absolute valoe of gen torque (Nm)";
2024      parameter Real socRef=0.6 "Target value of SOC";
2025      parameter Real socLoopGain=10000 "soc loop gain (W)";
2026      parameter Real maxTorqueReq=80
2027        "Torque request (Nm) that corresponds to 1 from driver";
2028      parameter Real genLoopGain=0.1
2029        "Control gain between ice speed error and gen torque: Nm/(rad/s)";
2030      parameter Real powFiltT=60 "Power filter time constant (s)";
2031      Modelica.Blocks.Interfaces.RealInput tauReference annotation (Placement(
2032          visible=true,
2033          transformation(extent={{-140,-20},{-100,20}}, rotation=0),
2034          iconTransformation(extent={{-140,-20},{-100,20}}, rotation=0)));
2035      Modelica.Blocks.Continuous.FirstOrder powFilt(T=powFiltT) annotation (
2036          Placement(visible=true, transformation(
2037            origin={20,46},
2038            extent={{-10,-10},{10,10}},
2039            rotation=-90)));
2040      SupportModels.Conn conn1 annotation (Placement(
2041          visible=true,
2042          transformation(extent={{-20,60},{20,100}}, rotation=0),
2043          iconTransformation(extent={{-20,78},{20,118}}, rotation=0)));
2044      Modelica.Blocks.Math.Gain gain(k=genLoopGain) annotation (Placement(
2045            visible=true, transformation(
2046            extent={{-10,-10},{10,10}},
2047            rotation=90,
2048            origin={84,-4})));
2049      Modelica.Blocks.Math.Feedback feedback annotation (Placement(visible=true,
2050            transformation(extent={{36,-30},{56,-50}}, rotation=0)));
2051      Modelica.Blocks.Tables.CombiTable1Ds toIceWref(
2052        fileName="wToTau.txt",
2053        tableOnFile=false,
2054        table=[0, 0; 1884, 126; 9800, 126; 36600, 366; 52300, 523])
2055        "optimal ice speed as a function of power" annotation (Placement(
2056            transformation(
2057            extent={{-10,-10},{10,10}},
2058            rotation=0,
2059            origin={-16,-40})));
2060      Modelica.Blocks.Math.Gain toNm(k=maxTorqueReq)
2061        "converts p.u. torque request into Nm" annotation (Placement(visible=
2062              true, transformation(
2063            extent={{-10,-10},{10,10}},
2064            rotation=90,
2065            origin={-86,30})));
2066      Modelica.Blocks.Nonlinear.Limiter limiter1(uMax=1e6, uMin=125)
2067        annotation (Placement(visible=true, transformation(
2068            origin={14,-40},
2069            extent={{-10,-10},{10,10}},
2070            rotation=0)));
2071      Modelica.Blocks.Continuous.FirstOrder genTauFilt(T=1) annotation (
2072          Placement(visible=true, transformation(
2073            origin={84,38},
2074            extent={{10,-10},{-10,10}},
2075            rotation=-90)));
2076      Modelica.Blocks.Math.Add add annotation (Placement(transformation(
2077            extent={{-10,-10},{10,10}},
2078            rotation=-90,
2079            origin={18,8})));
2080      Modelica.Blocks.Math.Feedback fbSOC
2081        annotation (Placement(transformation(extent={{-50,38},{-30,18}})));
2082      Modelica.Blocks.Math.Gain socErrToPow(k=socLoopGain) annotation (
2083          Placement(transformation(
2084            extent={{-10,-10},{10,10}},
2085            rotation=0,
2086            origin={-10,28})));
2087      Modelica.Blocks.Sources.Constant socRef_(k=socRef) annotation (Placement(
2088            transformation(
2089            extent={{-10,-10},{10,10}},
2090            rotation=90,
2091            origin={-54,-2})));
2092    equation
2093      connect(powFilt.u, conn1.motPowDelB) annotation (Line(points={{20,58},{20,
2094              58},{20,64},{20,64},{0,64},{0,80}}, color={0,0,127}));
2095      connect(gain.u, feedback.y) annotation (Line(points={{84,-16},{84,-16},{
2096              84,-40},{82,-40},{56,-40},{56,-40},{55,-40}}, color={0,0,127}));
2097      connect(feedback.u2, conn1.iceW) annotation (Line(
2098          points={{46,-32},{46,4},{40,4},{40,64},{0,64},{0,80}},
2099          color={0,0,127},
2100          smooth=Smooth.None), Text(
2101          string="%second",
2102          index=1,
2103          extent={{6,3},{6,3}}));
2104      connect(toNm.u, tauReference) annotation (Line(
2105          points={{-86,18},{-86,0},{-120,0}},
2106          color={0,0,127},
2107          smooth=Smooth.None));
2108      connect(toNm.y, conn1.motTauRef) annotation (Line(
2109          points={{-86,41},{-86,80},{0,80}},
2110          color={0,0,127},
2111          smooth=Smooth.None), Text(
2112          string="%second",
2113          index=1,
2114          extent={{6,3},{6,3}}));
2115      connect(feedback.u1, limiter1.y) annotation (Line(
2116          points={{38,-40},{25,-40}},
2117          color={0,0,127},
2118          smooth=Smooth.None));
2119      connect(limiter1.u, toIceWref.y[1]) annotation (Line(
2120          points={{2,-40},{-5,-40}},
2121          color={0,0,127},
2122          smooth=Smooth.None));
2123      connect(genTauFilt.u, gain.y) annotation (Line(
2124          points={{84,26},{84,7}},
2125          color={0,0,127},
2126          smooth=Smooth.None));
2127      connect(powFilt.y, add.u1) annotation (Line(points={{20,35},{20,26},{24,
2128              26},{24,20}}, color={0,0,127}));
2129      connect(socErrToPow.y, add.u2)
2130        annotation (Line(points={{1,28},{12,28},{12,20}}, color={0,0,127}));
2131      connect(fbSOC.y, socErrToPow.u)
2132        annotation (Line(points={{-31,28},{-22,28}}, color={0,0,127}));
2133      connect(add.y, toIceWref.u) annotation (Line(points={{18,-3},{18,-3},{18,
2134              -10},{18,-12},{18,-18},{-40,-18},{-40,-40},{-28,-40}}, color={0,0,
2135              127}));
2136      connect(fbSOC.u2, conn1.batSOC) annotation (Line(points={{-40,36},{-40,36},
2137              {-40,80},{0,80}}, color={0,0,127}), Text(
2138          string="%second",
2139          index=1,
2140          extent={{6,3},{6,3}}));
2141      connect(socRef_.y, fbSOC.u1)
2142        annotation (Line(points={{-54,9},{-54,28},{-48,28}}, color={0,0,127}));
2143      connect(add.y, conn1.icePowRef) annotation (Line(points={{18,-3},{18,-3},
2144              {18,-18},{18,-12},{56,-12},{56,74},{0,74},{0,80}}, color={0,0,127}),
2145          Text(
2146          string="%second",
2147          index=1,
2148          extent={{6,3},{6,3}}));
2149      connect(genTauFilt.y, conn1.genTauRef) annotation (Line(points={{84,49},{
2150              84,49},{84,80},{0,80}}, color={0,0,127}), Text(
2151          string="%second",
2152          index=1,
2153          extent={{6,3},{6,3}}));
2154      annotation (
2155        Diagram(coordinateSystem(
2156            extent={{-100,-60},{100,80}},
2157            preserveAspectRatio=false,
2158            initialScale=0.1,
2159            grid={2,2}), graphics={Text(
2160                  extent={{-84,68},{-70,58}},
2161                  lineColor={0,0,0},
2162                  horizontalAlignment=TextAlignment.Left,
2163                  textString="Send
2164requested
2165torque
2166to mot"),Text(    extent={{54,68},{82,64}},
2167                  lineColor={0,0,0},
2168                  horizontalAlignment=TextAlignment.Right,
2169                  textString="send
2170reference tau
2171to gen"),Text(    extent={{26,58},{54,54}},
2172                  lineColor={0,0,0},
2173                  horizontalAlignment=TextAlignment.Right,
2174                  textString="send
2175ref pow
2176to ice")}),
2177        Icon(coordinateSystem(
2178            extent={{-100,-100},{100,100}},
2179            preserveAspectRatio=false,
2180            initialScale=0.1,
2181            grid={2,2}), graphics={
2182            Text(
2183              lineColor={0,0,255},
2184              extent={{-100,-102},{100,-140}},
2185              textString="%name"),
2186            Rectangle(
2187              extent={{-100,100},{100,-100}},
2188              lineColor={0,0,0},
2189              fillColor={255,255,255},
2190              fillPattern=FillPattern.Solid),
2191            Polygon(
2192              points={{-4,-40},{74,16},{74,-6},{-4,-62},{-4,-40}},
2193              lineColor={95,95,95},
2194              fillColor={175,175,175},
2195              fillPattern=FillPattern.Solid),
2196            Polygon(
2197              points={{8,-38},{28,-48},{20,-54},{0,-44},{8,-38}},
2198              lineColor={0,0,255},
2199              fillColor={255,255,0},
2200              fillPattern=FillPattern.Solid),
2201            Polygon(
2202              points={{20,-54},{28,-48},{32,-56},{24,-62},{20,-54}},
2203              lineColor={0,0,255},
2204              fillColor={255,255,0},
2205              fillPattern=FillPattern.Solid),
2206            Polygon(
2207              points={{24,-62},{32,-56},{32,-78},{24,-84},{24,-62}},
2208              lineColor={0,0,255},
2209              fillColor={255,255,127},
2210              fillPattern=FillPattern.Solid),
2211            Polygon(
2212              points={{0,-44},{20,-54},{24,-62},{24,-84},{22,-84},{22,-62},{20,
2213                  -58},{0,-48},{0,-44}},
2214              lineColor={0,0,255},
2215              fillColor={191,191,0},
2216              fillPattern=FillPattern.Solid),
2217            Polygon(
2218              points={{-14,40},{-18,32},{-10,38},{-8,44},{-14,40}},
2219              lineColor={128,128,128},
2220              fillColor={128,128,128},
2221              fillPattern=FillPattern.Solid),
2222            Polygon(
2223              points={{-18,32},{-10,38},{-10,14},{-18,8},{-18,32}},
2224              lineColor={0,0,255},
2225              fillColor={255,255,127},
2226              fillPattern=FillPattern.Solid),
2227            Polygon(
2228              points={{-20,10},{-20,32},{-16,40},{4,30},{4,26},{-16,36},{-18,32},
2229                  {-18,8},{-20,10}},
2230              lineColor={0,0,255},
2231              fillColor={191,191,0},
2232              fillPattern=FillPattern.Solid),
2233            Polygon(
2234              points={{-8,46},{12,36},{4,30},{-16,40},{-8,46}},
2235              lineColor={0,0,255},
2236              fillColor={255,255,0},
2237              fillPattern=FillPattern.Solid),
2238            Polygon(
2239              points={{28,-22},{48,-32},{40,-38},{20,-28},{28,-22}},
2240              lineColor={0,0,255},
2241              fillColor={255,255,0},
2242              fillPattern=FillPattern.Solid),
2243            Polygon(
2244              points={{40,-38},{48,-32},{52,-40},{44,-46},{40,-38}},
2245              lineColor={0,0,255},
2246              fillColor={255,255,0},
2247              fillPattern=FillPattern.Solid),
2248            Polygon(
2249              points={{44,-46},{52,-40},{52,-62},{44,-68},{44,-46}},
2250              lineColor={0,0,255},
2251              fillColor={255,255,127},
2252              fillPattern=FillPattern.Solid),
2253            Polygon(
2254              points={{20,-28},{40,-38},{44,-46},{44,-68},{42,-68},{42,-46},{40,
2255                  -42},{20,-32},{20,-28}},
2256              lineColor={0,0,255},
2257              fillColor={191,191,0},
2258              fillPattern=FillPattern.Solid),
2259            Polygon(
2260              points={{48,-8},{68,-18},{60,-24},{40,-14},{48,-8}},
2261              lineColor={0,0,255},
2262              fillColor={255,255,0},
2263              fillPattern=FillPattern.Solid),
2264            Polygon(
2265              points={{60,-24},{68,-18},{72,-26},{64,-32},{60,-24}},
2266              lineColor={0,0,255},
2267              fillColor={255,255,0},
2268              fillPattern=FillPattern.Solid),
2269            Polygon(
2270              points={{64,-32},{72,-26},{72,-48},{64,-54},{64,-32}},
2271              lineColor={0,0,255},
2272              fillColor={255,255,127},
2273              fillPattern=FillPattern.Solid),
2274            Polygon(
2275              points={{40,-14},{60,-24},{64,-32},{64,-54},{62,-54},{62,-32},{60,
2276                  -28},{40,-18},{40,-14}},
2277              lineColor={0,0,255},
2278              fillColor={191,191,0},
2279              fillPattern=FillPattern.Solid),
2280            Polygon(
2281              points={{68,6},{88,-4},{80,-10},{60,0},{68,6}},
2282              lineColor={0,0,255},
2283              fillColor={255,255,0},
2284              fillPattern=FillPattern.Solid),
2285            Polygon(
2286              points={{80,-10},{88,-4},{92,-12},{84,-18},{80,-10}},
2287              lineColor={0,0,255},
2288              fillColor={255,255,0},
2289              fillPattern=FillPattern.Solid),
2290            Polygon(
2291              points={{84,-18},{92,-12},{92,-34},{84,-40},{84,-18}},
2292              lineColor={0,0,255},
2293              fillColor={255,255,127},
2294              fillPattern=FillPattern.Solid),
2295            Polygon(
2296              points={{60,0},{80,-10},{84,-18},{84,-40},{82,-40},{82,-18},{80,-14},
2297                  {60,-4},{60,0}},
2298              lineColor={0,0,255},
2299              fillColor={191,191,0},
2300              fillPattern=FillPattern.Solid),
2301            Polygon(
2302              points={{-34,26},{-38,18},{-30,24},{-28,30},{-34,26}},
2303              lineColor={128,128,128},
2304              fillColor={128,128,128},
2305              fillPattern=FillPattern.Solid),
2306            Polygon(
2307              points={{-38,18},{-30,24},{-30,0},{-38,-6},{-38,18}},
2308              lineColor={0,0,255},
2309              fillColor={255,255,127},
2310              fillPattern=FillPattern.Solid),
2311            Polygon(
2312              points={{-40,-4},{-40,18},{-36,26},{-16,16},{-16,12},{-36,22},{-38,
2313                  18},{-38,-6},{-40,-4}},
2314              lineColor={0,0,255},
2315              fillColor={191,191,0},
2316              fillPattern=FillPattern.Solid),
2317            Polygon(
2318              points={{-28,32},{-8,22},{-16,16},{-36,26},{-28,32}},
2319              lineColor={0,0,255},
2320              fillColor={255,255,0},
2321              fillPattern=FillPattern.Solid),
2322            Polygon(
2323              points={{-54,12},{-58,4},{-50,10},{-48,16},{-54,12}},
2324              lineColor={128,128,128},
2325              fillColor={128,128,128},
2326              fillPattern=FillPattern.Solid),
2327            Polygon(
2328              points={{-58,4},{-50,10},{-50,-14},{-58,-20},{-58,4}},
2329              lineColor={0,0,255},
2330              fillColor={255,255,127},
2331              fillPattern=FillPattern.Solid),
2332            Polygon(
2333              points={{-60,-18},{-60,4},{-56,12},{-36,2},{-36,-2},{-56,8},{-58,
2334                  4},{-58,-20},{-60,-18}},
2335              lineColor={0,0,255},
2336              fillColor={191,191,0},
2337              fillPattern=FillPattern.Solid),
2338            Polygon(
2339              points={{-48,18},{-28,8},{-36,2},{-56,12},{-48,18}},
2340              lineColor={0,0,255},
2341              fillColor={255,255,0},
2342              fillPattern=FillPattern.Solid),
2343            Polygon(
2344              points={{-74,-4},{-78,-12},{-70,-6},{-68,0},{-74,-4}},
2345              lineColor={128,128,128},
2346              fillColor={128,128,128},
2347              fillPattern=FillPattern.Solid),
2348            Polygon(
2349              points={{-78,-12},{-70,-6},{-70,-30},{-78,-36},{-78,-12}},
2350              lineColor={0,0,255},
2351              fillColor={255,255,127},
2352              fillPattern=FillPattern.Solid),
2353            Polygon(
2354              points={{-80,-34},{-80,-12},{-76,-4},{-56,-14},{-56,-18},{-76,-8},
2355                  {-78,-12},{-78,-36},{-80,-34}},
2356              lineColor={0,0,255},
2357              fillColor={191,191,0},
2358              fillPattern=FillPattern.Solid),
2359            Polygon(
2360              points={{-68,2},{-48,-8},{-56,-14},{-76,-4},{-68,2}},
2361              lineColor={0,0,255},
2362              fillColor={255,255,0},
2363              fillPattern=FillPattern.Solid),
2364            Polygon(
2365              points={{-64,-8},{-4,-40},{-4,-62},{-64,-30},{-64,-8}},
2366              lineColor={95,95,95},
2367              fillColor={75,75,75},
2368              fillPattern=FillPattern.Solid),
2369            Polygon(
2370              points={{-64,-8},{-4,-40},{74,16},{14,48},{-64,-8}},
2371              lineColor={95,95,95},
2372              fillColor={160,160,164},
2373              fillPattern=FillPattern.Solid),
2374            Rectangle(
2375              extent={{-98,92},{98,62}},
2376              fillColor={255,255,255},
2377              fillPattern=FillPattern.Solid,
2378              pattern=LinePattern.None),
2379            Text(
2380              extent={{-100,82},{100,54}},
2381              lineColor={0,0,0},
2382              textString="PSD-ecu1s")}),
2383        Documentation(info="<html>
2384<p><b><span style=\"font-family: MS Shell Dlg 2;\">Power Split Power Train Controller without ON/OFF</span></b></p>
2385<p><span style=\"font-family: MS Shell Dlg 2;\">This controller is derived from MBecu1, in which the basic description can be found.</span></p>
2386<p><span style=\"font-family: MS Shell Dlg 2;\">It adds a soc control loop to avoid soc Drifts.</span></p>
2387</html>"));
2388    end MBecu1soc;
2389
2390    model MBecu2
2391      "Power Split hybrid power train controller, using ON/OFF strategy"
2392      parameter Real socRef=0.6 "Reference soc";
2393      parameter Real maxTorqueReq=80
2394        "Maximum torque that can be requested from mot";
2395      parameter Real powFiltT=60 "Power filter time constant (s)";
2396      parameter Real socLoopGain=50e3 "gain of the soc loop (w/pu)";
2397      parameter Real genLoopGain=0.02 "gain of the soc loop (Nm/(rad/s))";
2398      parameter Real onThreshold=7000
2399        "average power over which engine is switched on (W)";
2400      parameter Real offThreshold=5000
2401        "average power below which engine is switched off (W)";
2402      Modelica.Blocks.Interfaces.RealInput tauReference annotation (Placement(
2403          visible=true,
2404          transformation(extent={{-140,-20},{-100,20}}, rotation=0),
2405          iconTransformation(extent={{-140,-20},{-100,20}}, rotation=0)));
2406      Modelica.Blocks.Continuous.FirstOrder powFilt(T=powFiltT) annotation (
2407          Placement(visible=true, transformation(
2408            origin={-50,58},
2409            extent={{-10,-10},{10,10}},
2410            rotation=-90)));
2411      SupportModels.Conn conn1 annotation (Placement(
2412          visible=true,
2413          transformation(extent={{-20,78},{20,118}}, rotation=0),
2414          iconTransformation(extent={{-20,78},{20,118}}, rotation=0)));
2415      Modelica.Blocks.Math.Gain genWLGain_(k=genLoopGain) "gen speed gain"
2416        annotation (Placement(visible=true, transformation(
2417            extent={{-10,-10},{10,10}},
2418            rotation=90,
2419            origin={104,30})));
2420      Modelica.Blocks.Math.Gain toNm(k=maxTorqueReq)
2421        "converts p.u. torque request into Nm" annotation (Placement(visible=
2422              true, transformation(
2423            extent={{-10,-10},{10,10}},
2424            rotation=90,
2425            origin={-88,50})));
2426      Modelica.Blocks.Continuous.FirstOrder genTauFilt(T=1) annotation (
2427          Placement(visible=true, transformation(
2428            origin={104,76},
2429            extent={{10,-10},{-10,10}},
2430            rotation=-90)));
2431      Modelica.Blocks.Math.Add add annotation (Placement(visible=true,
2432            transformation(
2433            origin={-36,12},
2434            extent={{-10,-10},{10,10}},
2435            rotation=0)));
2436      Modelica.Blocks.Tables.CombiTable1Ds powToW(
2437        fileName="wToTau.txt",
2438        tableOnFile=false,
2439        table=[0, 0; 1884, 126; 9800, 126; 36600, 366; 52300, 523])
2440        "optimal ice speed as a function of power" annotation (Placement(
2441            visible=true, transformation(
2442            origin={64,-16},
2443            extent={{-10,-10},{10,10}},
2444            rotation=90)));
2445      Modelica.Blocks.Nonlinear.Limiter iceSpeedLimiter(uMax=1e6, uMin=125)
2446        annotation (Placement(visible=true, transformation(
2447            origin={64,16},
2448            extent={{-10,-10},{10,10}},
2449            rotation=90)));
2450      Modelica.Blocks.Math.Feedback feedback annotation (Placement(visible=true,
2451            transformation(
2452            extent={{-10,10},{10,-10}},
2453            rotation=90,
2454            origin={64,46})));
2455      Modelica.Blocks.Sources.Constant socRef_(k=socRef) annotation (Placement(
2456            visible=true, transformation(extent={{-98,-34},{-78,-14}}, rotation
2457              =0)));
2458      Modelica.Blocks.Math.Feedback fbSOC annotation (Placement(visible=true,
2459            transformation(extent={{-74,-14},{-54,-34}}, rotation=0)));
2460      Modelica.Blocks.Math.Gain socErrrToPow(k=socLoopGain) annotation (
2461          Placement(visible=true, transformation(
2462            origin={-38,-24},
2463            extent={{-10,-10},{10,10}},
2464            rotation=0)));
2465      Modelica.Blocks.Logical.Hysteresis hysteresis(uLow=offThreshold, uHigh=
2466            onThreshold) annotation (Placement(transformation(
2467            extent={{-10,-10},{10,10}},
2468            rotation=90,
2469            origin={-18,42})));
2470      Modelica.Blocks.Logical.Switch switch1 annotation (Placement(
2471            transformation(
2472            extent={{-10,-10},{10,10}},
2473            rotation=0,
2474            origin={12,12})));
2475      Modelica.Blocks.Sources.Constant constZero(k=0)
2476        annotation (Placement(transformation(extent={{20,-30},{0,-10}})));
2477    equation
2478      connect(socErrrToPow.y, add.u2) annotation (Line(points={{-27,-24},{-22,-24},
2479              {-22,-4},{-58,-4},{-58,6},{-48,6}}, color={0,0,127}));
2480      connect(socErrrToPow.u, fbSOC.y)
2481        annotation (Line(points={{-50,-24},{-55,-24}}, color={0,0,127}));
2482      connect(fbSOC.u2, conn1.batSOC) annotation (Line(points={{-64,-16},{-64,-12},
2483              {-68,-12},{-68,98},{0,98}}, color={0,0,127}));
2484      connect(fbSOC.u1, socRef_.y)
2485        annotation (Line(points={{-72,-24},{-77,-24}}, color={0,0,127}));
2486      connect(feedback.u1, iceSpeedLimiter.y) annotation (Line(points={{64,38},
2487              {64,38},{64,28},{64,27}}, color={0,0,127}));
2488      connect(feedback.u2, conn1.iceW) annotation (Line(points={{56,46},{56,72},
2489              {56,98},{0,98}}, color={0,0,127}));
2490      connect(genWLGain_.u, feedback.y) annotation (Line(points={{104,18},{104,
2491              18},{104,0},{88,0},{88,55},{64,55}}, color={0,0,127}));
2492      connect(iceSpeedLimiter.u, powToW.y[1])
2493        annotation (Line(points={{64,4},{64,-5}}, color={0,0,127}));
2494      connect(add.u1, powFilt.y) annotation (Line(points={{-48,18},{-54,18},{-58,
2495              18},{-58,42},{-50,42},{-50,47}}, color={0,0,127}));
2496      connect(powFilt.u, conn1.motPowDelB) annotation (Line(points={{-50,70},{-50,
2497              78},{0,78},{0,98}}, color={0,0,127}));
2498      connect(toNm.u, tauReference) annotation (Line(
2499          points={{-88,38},{-88,0},{-120,0}},
2500          color={0,0,127},
2501          smooth=Smooth.None));
2502      connect(toNm.y, conn1.motTauRef) annotation (Line(
2503          points={{-88,61},{-88,98},{0,98}},
2504          color={0,0,127},
2505          smooth=Smooth.None), Text(
2506          string="%second",
2507          index=1,
2508          extent={{6,3},{6,3}}));
2509      connect(genWLGain_.y, genTauFilt.u) annotation (Line(
2510          points={{104,41},{104,64}},
2511          color={0,0,127},
2512          smooth=Smooth.None));
2513      connect(genTauFilt.y, conn1.genTauRef) annotation (Line(
2514          points={{104,87},{104,98},{0,98}},
2515          color={0,0,127},
2516          smooth=Smooth.None), Text(
2517          string="%second",
2518          index=1,
2519          extent={{6,3},{6,3}}));
2520      connect(hysteresis.u, add.y) annotation (Line(
2521          points={{-18,30},{-18,12},{-25,12}},
2522          color={0,0,127},
2523          smooth=Smooth.None));
2524      connect(hysteresis.y, conn1.iceON) annotation (Line(
2525          points={{-18,53},{-18,92},{0,92},{0,98}},
2526          color={255,0,255},
2527          smooth=Smooth.None), Text(
2528          string="%second",
2529          index=1,
2530          extent={{6,3},{6,3}}));
2531      connect(powToW.u, switch1.y) annotation (Line(
2532          points={{64,-28},{30,-28},{30,12},{23,12}},
2533          color={0,0,127},
2534          smooth=Smooth.None));
2535      connect(switch1.u1, add.y) annotation (Line(
2536          points={{0,20},{-18,20},{-18,12},{-25,12}},
2537          color={0,0,127},
2538          smooth=Smooth.None));
2539      connect(switch1.u3, constZero.y) annotation (Line(
2540          points={{0,4},{-8,4},{-8,-20},{-1,-20}},
2541          color={0,0,127},
2542          smooth=Smooth.None));
2543      connect(switch1.u2, hysteresis.y) annotation (Line(
2544          points={{0,12},{-8,12},{-8,30},{0,30},{0,62},{-18,62},{-18,53}},
2545          color={255,0,255},
2546          smooth=Smooth.None));
2547      connect(powToW.u, conn1.icePowRef) annotation (Line(
2548          points={{64,-28},{30,-28},{30,72},{0,72},{0,98}},
2549          color={0,0,127},
2550          smooth=Smooth.None), Text(
2551          string="%second",
2552          index=1,
2553          extent={{6,3},{6,3}}));
2554      annotation (
2555        Documentation(info="<html>
2556<p><b><span style=\"font-family: MS Shell Dlg 2;\">Power Split Power Train Controller with ON/OFF</span></b></p>
2557<p><span style=\"font-family: MS Shell Dlg 2;\">This controller operates as follows:</span></p>
2558<ul>
2559<li><span style=\"font-family: MS Shell Dlg 2;\">it makes the ice deliver the average power needed by the power train</span></li>
2560<li><span style=\"font-family: MS Shell Dlg 2;\">it determines the optimal ice speed at which the requested power is delivered with minimum fuel consumption and asks the &QUOT;gen&QUOT; to control so that the ice opertes at that speed</span></li>
2561<li><span style=\"font-family: MS Shell Dlg 2;\">the vehicle motion is controlled acting on the &QUOT;mot&QUOT;.</span></li>
2562<li><span style=\"font-family: MS Shell Dlg 2;\">a closed-loop SOC control avoids the battery do become too charged or discharged</span></li>
2563<li><span style=\"font-family: MS Shell Dlg 2;\">an ON/OFF control determines ICe switching OFF when the looad is to loow and switching it ON again when the requested power is sifnigicntly high. this normally reduces fuel consumpton.</span></li>
2564</ul>
2565<p><span style=\"font-family: MS Shell Dlg 2;\">So:</span></p>
2566<ul>
2567<li><span style=\"font-family: MS Shell Dlg 2;\">powFilt Block filters the delivered power to obtained the power to ask the ICE to deliver</span></li>
2568<li><span style=\"font-family: MS Shell Dlg 2;\">toIceWref converts the power to be requested from the ICE by its maximum torque at the actual speed</span></li>
2569<li><span style=\"font-family: MS Shell Dlg 2;\">after a limiting block, this torque is the reference signal of a feedback; the corresponnding error controls the Gen torque.</span></li>
2570<li><span style=\"font-family: MS Shell Dlg 2;\">fbSOC sis the feedback for SOC control and socLoopGain is its gain</span></li>
2571<li><span style=\"font-family: MS Shell Dlg 2;\">hysteresis manages switching ON/OFF the ice. </span></li>
2572</ul>
2573<p><span style=\"font-family: MS Shell Dlg 2;\"></p><p>Details of ice going to off (e.g. bringing its speed to zero) and to on (i.e. first making ice speed to rise, then start sending fuel) are not implemented.</span></p>
2574</html>"),
2575        Diagram(coordinateSystem(
2576            extent={{-100,-40},{120,100}},
2577            preserveAspectRatio=false,
2578            initialScale=0.1,
2579            grid={2,2}), graphics={Text(extent={{-86,92},{-28,88}}, textString=
2580              "Send requested torque to mot"),Text(extent={{12,50},{40,46}},
2581              textString="send reterence tau
2582 to gen")}),
2583        Icon(coordinateSystem(
2584            extent={{-100,-100},{100,100}},
2585            preserveAspectRatio=false,
2586            initialScale=0.1,
2587            grid={2,2}), graphics={
2588            Text(
2589              lineColor={0,0,255},
2590              extent={{-102,-102},{98,-140}},
2591              textString="%name"),
2592            Rectangle(
2593              fillColor={255,255,255},
2594              fillPattern=FillPattern.Solid,
2595              extent={{-100,100},{100,-100}}),
2596            Polygon(
2597              lineColor={95,95,95},
2598              fillColor={175,175,175},
2599              fillPattern=FillPattern.Solid,
2600              points={{-4,-40},{74,16},{74,-6},{-4,-62},{-4,-40}}),
2601            Polygon(
2602              lineColor={0,0,255},
2603              fillColor={255,255,0},
2604              fillPattern=FillPattern.Solid,
2605              points={{8,-38},{28,-48},{20,-54},{0,-44},{8,-38}}),
2606            Polygon(
2607              lineColor={0,0,255},
2608              fillColor={255,255,0},
2609              fillPattern=FillPattern.Solid,
2610              points={{20,-54},{28,-48},{32,-56},{24,-62},{20,-54}}),
2611            Polygon(
2612              lineColor={0,0,255},
2613              fillColor={255,255,127},
2614              fillPattern=FillPattern.Solid,
2615              points={{24,-62},{32,-56},{32,-78},{24,-84},{24,-62}}),
2616            Polygon(
2617              lineColor={0,0,255},
2618              fillColor={191,191,0},
2619              fillPattern=FillPattern.Solid,
2620              points={{0,-44},{20,-54},{24,-62},{24,-84},{22,-84},{22,-62},{20,
2621                  -58},{0,-48},{0,-44}}),
2622            Polygon(
2623              lineColor={128,128,128},
2624              fillColor={128,128,128},
2625              fillPattern=FillPattern.Solid,
2626              points={{-14,40},{-18,32},{-10,38},{-8,44},{-14,40}}),
2627            Polygon(
2628              lineColor={0,0,255},
2629              fillColor={255,255,127},
2630              fillPattern=FillPattern.Solid,
2631              points={{-18,32},{-10,38},{-10,14},{-18,8},{-18,32}}),
2632            Polygon(
2633              lineColor={0,0,255},
2634              fillColor={191,191,0},
2635              fillPattern=FillPattern.Solid,
2636              points={{-20,10},{-20,32},{-16,40},{4,30},{4,26},{-16,36},{-18,32},
2637                  {-18,8},{-20,10}}),
2638            Polygon(
2639              lineColor={0,0,255},
2640              fillColor={255,255,0},
2641              fillPattern=FillPattern.Solid,
2642              points={{-8,46},{12,36},{4,30},{-16,40},{-8,46}}),
2643            Polygon(
2644              lineColor={0,0,255},
2645              fillColor={255,255,0},
2646              fillPattern=FillPattern.Solid,
2647              points={{28,-22},{48,-32},{40,-38},{20,-28},{28,-22}}),
2648            Polygon(
2649              lineColor={0,0,255},
2650              fillColor={255,255,0},
2651              fillPattern=FillPattern.Solid,
2652              points={{40,-38},{48,-32},{52,-40},{44,-46},{40,-38}}),
2653            Polygon(
2654              lineColor={0,0,255},
2655              fillColor={255,255,127},
2656              fillPattern=FillPattern.Solid,
2657              points={{44,-46},{52,-40},{52,-62},{44,-68},{44,-46}}),
2658            Polygon(
2659              lineColor={0,0,255},
2660              fillColor={191,191,0},
2661              fillPattern=FillPattern.Solid,
2662              points={{20,-28},{40,-38},{44,-46},{44,-68},{42,-68},{42,-46},{40,
2663                  -42},{20,-32},{20,-28}}),
2664            Polygon(
2665              lineColor={0,0,255},
2666              fillColor={255,255,0},
2667              fillPattern=FillPattern.Solid,
2668              points={{48,-8},{68,-18},{60,-24},{40,-14},{48,-8}}),
2669            Polygon(
2670              lineColor={0,0,255},
2671              fillColor={255,255,0},
2672              fillPattern=FillPattern.Solid,
2673              points={{60,-24},{68,-18},{72,-26},{64,-32},{60,-24}}),
2674            Polygon(
2675              lineColor={0,0,255},
2676              fillColor={255,255,127},
2677              fillPattern=FillPattern.Solid,
2678              points={{64,-32},{72,-26},{72,-48},{64,-54},{64,-32}}),
2679            Polygon(
2680              lineColor={0,0,255},
2681              fillColor={191,191,0},
2682              fillPattern=FillPattern.Solid,
2683              points={{40,-14},{60,-24},{64,-32},{64,-54},{62,-54},{62,-32},{60,
2684                  -28},{40,-18},{40,-14}}),
2685            Polygon(
2686              lineColor={0,0,255},
2687              fillColor={255,255,0},
2688              fillPattern=FillPattern.Solid,
2689              points={{68,6},{88,-4},{80,-10},{60,0},{68,6}}),
2690            Polygon(
2691              lineColor={0,0,255},
2692              fillColor={255,255,0},
2693              fillPattern=FillPattern.Solid,
2694              points={{80,-10},{88,-4},{92,-12},{84,-18},{80,-10}}),
2695            Polygon(
2696              lineColor={0,0,255},
2697              fillColor={255,255,127},
2698              fillPattern=FillPattern.Solid,
2699              points={{84,-18},{92,-12},{92,-34},{84,-40},{84,-18}}),
2700            Polygon(
2701              lineColor={0,0,255},
2702              fillColor={191,191,0},
2703              fillPattern=FillPattern.Solid,
2704              points={{60,0},{80,-10},{84,-18},{84,-40},{82,-40},{82,-18},{80,-14},
2705                  {60,-4},{60,0}}),
2706            Polygon(
2707              lineColor={128,128,128},
2708              fillColor={128,128,128},
2709              fillPattern=FillPattern.Solid,
2710              points={{-34,26},{-38,18},{-30,24},{-28,30},{-34,26}}),
2711            Polygon(
2712              lineColor={0,0,255},
2713              fillColor={255,255,127},
2714              fillPattern=FillPattern.Solid,
2715              points={{-38,18},{-30,24},{-30,0},{-38,-6},{-38,18}}),
2716            Polygon(
2717              lineColor={0,0,255},
2718              fillColor={191,191,0},
2719              fillPattern=FillPattern.Solid,
2720              points={{-40,-4},{-40,18},{-36,26},{-16,16},{-16,12},{-36,22},{-38,
2721                  18},{-38,-6},{-40,-4}}),
2722            Polygon(
2723              lineColor={0,0,255},
2724              fillColor={255,255,0},
2725              fillPattern=FillPattern.Solid,
2726              points={{-28,32},{-8,22},{-16,16},{-36,26},{-28,32}}),
2727            Polygon(
2728              lineColor={128,128,128},
2729              fillColor={128,128,128},
2730              fillPattern=FillPattern.Solid,
2731              points={{-54,12},{-58,4},{-50,10},{-48,16},{-54,12}}),
2732            Polygon(
2733              lineColor={0,0,255},
2734              fillColor={255,255,127},
2735              fillPattern=FillPattern.Solid,
2736              points={{-58,4},{-50,10},{-50,-14},{-58,-20},{-58,4}}),
2737            Polygon(
2738              lineColor={0,0,255},
2739              fillColor={191,191,0},
2740              fillPattern=FillPattern.Solid,
2741              points={{-60,-18},{-60,4},{-56,12},{-36,2},{-36,-2},{-56,8},{-58,
2742                  4},{-58,-20},{-60,-18}}),
2743            Polygon(
2744              lineColor={0,0,255},
2745              fillColor={255,255,0},
2746              fillPattern=FillPattern.Solid,
2747              points={{-48,18},{-28,8},{-36,2},{-56,12},{-48,18}}),
2748            Polygon(
2749              lineColor={128,128,128},
2750              fillColor={128,128,128},
2751              fillPattern=FillPattern.Solid,
2752              points={{-74,-4},{-78,-12},{-70,-6},{-68,0},{-74,-4}}),
2753            Polygon(
2754              lineColor={0,0,255},
2755              fillColor={255,255,127},
2756              fillPattern=FillPattern.Solid,
2757              points={{-78,-12},{-70,-6},{-70,-30},{-78,-36},{-78,-12}}),
2758            Polygon(
2759              lineColor={0,0,255},
2760              fillColor={191,191,0},
2761              fillPattern=FillPattern.Solid,
2762              points={{-80,-34},{-80,-12},{-76,-4},{-56,-14},{-56,-18},{-76,-8},
2763                  {-78,-12},{-78,-36},{-80,-34}}),
2764            Polygon(
2765              lineColor={0,0,255},
2766              fillColor={255,255,0},
2767              fillPattern=FillPattern.Solid,
2768              points={{-68,2},{-48,-8},{-56,-14},{-76,-4},{-68,2}}),
2769            Polygon(
2770              lineColor={95,95,95},
2771              fillColor={75,75,75},
2772              fillPattern=FillPattern.Solid,
2773              points={{-64,-8},{-4,-40},{-4,-62},{-64,-30},{-64,-8}}),
2774            Polygon(
2775              lineColor={95,95,95},
2776              fillColor={160,160,164},
2777              fillPattern=FillPattern.Solid,
2778              points={{-64,-8},{-4,-40},{74,16},{14,48},{-64,-8}}),
2779            Rectangle(
2780              fillColor={255,255,255},
2781              pattern=LinePattern.None,
2782              fillPattern=FillPattern.Solid,
2783              extent={{-98,92},{98,62}}),
2784            Text(
2785              extent={{-100,84},{100,54}},
2786              lineColor={0,0,0},
2787              textString="PSD-ecu2")}));
2788    end MBecu2;
2789    annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
2790              -100},{100,100}}), graphics={
2791          Line(
2792            points={{-80,-84},{-80,68}},
2793            color={0,0,0},
2794            smooth=Smooth.None),
2795          Line(
2796            points={{-88,-80},{78,-80}},
2797            color={0,0,0},
2798            smooth=Smooth.None),
2799          Polygon(
2800            points={{94,-80},{78,-74},{78,-86},{94,-80}},
2801            lineColor={0,0,0},
2802            smooth=Smooth.None),
2803          Polygon(
2804            points={{8,0},{-8,6},{-8,-6},{8,0}},
2805            lineColor={0,0,0},
2806            smooth=Smooth.None,
2807            origin={-80,76},
2808            rotation=90),
2809          Line(
2810            points={{-84,40},{-14,40}},
2811            color={0,0,0},
2812            smooth=Smooth.None),
2813          Line(
2814            points={{-14,40},{-4,2},{22,-32},{62,-44},{62,-80}},
2815            color={0,0,0},
2816            smooth=Smooth.None)}));
2817  end MapBased;
2818
2819  package SupportModels "Useful addtional models"
2820    extends Modelica.Icons.Package;
2821    // extends EHPowerTrain.Icons.SupportIcon;
2822
2823    model PropDriver "Simple Proportional controller driver"
2824      parameter String CycleFileName="MyCycleName.txt"
2825        "Drive Cycle Name ex: \"sort1.txt\"";
2826      parameter Real k "Controller gain";
2827      parameter Real yMax=1000000.0 "Max output value (absolute)";
2828      parameter Modelica.Blocks.Types.Extrapolation extrapolation=Modelica.Blocks.Types.Extrapolation.HoldLastPoint;
2829      Modelica.Blocks.Interfaces.RealInput V annotation (Placement(
2830            transformation(
2831            extent={{-14,-14},{14,14}},
2832            rotation=90,
2833            origin={0,-114}), iconTransformation(
2834            extent={{-12,-12},{12,12}},
2835            rotation=90,
2836            origin={0,-112})));
2837      Modelica.Blocks.Interfaces.RealOutput tauRef(unit="N.m") annotation (
2838          Placement(transformation(extent={{100,-10},{120,10}}),
2839            iconTransformation(extent={{100,-10},{120,10}})));
2840      Modelica.Blocks.Sources.CombiTimeTable driveCyc(
2841        columns={2},
2842        fileName=CycleFileName,
2843        tableName="Cycle",
2844        tableOnFile=true)
2845        annotation (Placement(transformation(extent={{-86,-10},{-66,10}})));
2846      Modelica.Blocks.Math.UnitConversions.From_kmh from_kmh
2847        annotation (Placement(transformation(extent={{-48,-10},{-28,10}})));
2848      Modelica.Blocks.Math.Feedback feedback
2849        annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
2850      Modelica.Blocks.Math.Gain gain(k=k)
2851        annotation (Placement(transformation(extent={{32,-10},{52,10}})));
2852      Modelica.Blocks.Nonlinear.Limiter limiter(uMax=yMax)
2853        annotation (Placement(transformation(extent={{70,-10},{90,10}})));
2854    equation
2855      connect(from_kmh.u, driveCyc.y[1]) annotation (Line(
2856          points={{-50,0},{-65,0}},
2857          color={0,0,127},
2858          smooth=Smooth.None));
2859      connect(from_kmh.y, feedback.u1) annotation (Line(
2860          points={{-27,0},{-8,0}},
2861          color={0,0,127},
2862          smooth=Smooth.None));
2863      connect(feedback.u2, V) annotation (Line(
2864          points={{0,-8},{0,-114},{1.77636e-015,-114}},
2865          color={0,0,127},
2866          smooth=Smooth.None));
2867      connect(feedback.y, gain.u) annotation (Line(
2868          points={{9,0},{30,0}},
2869          color={0,0,127},
2870          smooth=Smooth.None));
2871      connect(gain.y, limiter.u) annotation (Line(
2872          points={{53,0},{68,0}},
2873          color={0,0,127},
2874          smooth=Smooth.None));
2875      connect(tauRef, limiter.y) annotation (Line(
2876          points={{110,0},{91,0}},
2877          color={0,0,127},
2878          smooth=Smooth.None));
2879      annotation (
2880        Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
2881                {100,100}}), graphics),
2882        Documentation(info="<html>
2883            <p>Modello semplice di pilota.</p>
2884            <p>Esso contiene al suo interno il ciclo di riferimento, che insegue attraverso un regolatore solo proporzionale.</p>
2885            </html>"),
2886        Icon(coordinateSystem(
2887            extent={{-100,-100},{100,100}},
2888            preserveAspectRatio=false,
2889            initialScale=0.1,
2890            grid={2,2}), graphics={
2891            Rectangle(
2892              fillColor={255,255,255},
2893              fillPattern=FillPattern.Solid,
2894              extent={{-100,100},{100,-100}}),
2895            Ellipse(
2896              fillColor={255,213,170},
2897              fillPattern=FillPattern.Solid,
2898              extent={{-23,46},{-12,20}},
2899              endAngle=360),
2900            Text(
2901              origin={0,1.81063},
2902              lineColor={0,0,255},
2903              extent={{-104,142.189},{98,104}},
2904              textString="%name"),
2905            Polygon(
2906              fillColor={215,215,215},
2907              pattern=LinePattern.None,
2908              fillPattern=FillPattern.Solid,
2909              points={{-22,-36},{-42,-64},{-16,-64},{16,-64},{-22,-36}}),
2910            Polygon(
2911              fillColor={135,135,135},
2912              pattern=LinePattern.None,
2913              fillPattern=FillPattern.Solid,
2914              points={{-32,64},{-62,-28},{-30,-28},{-30,-28},{-32,64}},
2915              smooth=Smooth.Bezier),
2916            Polygon(
2917              fillColor={135,135,135},
2918              pattern=LinePattern.None,
2919              fillPattern=FillPattern.Solid,
2920              points={{-68,-12},{-14,-66},{10,-26},{0,-26},{-68,-12}},
2921              smooth=Smooth.Bezier),
2922            Polygon(
2923              fillColor={175,175,175},
2924              fillPattern=FillPattern.Solid,
2925              points={{-22,34},{-30,30},{-40,-24},{2,-22},{2,-10},{0,26},{-22,
2926                  34}},
2927              smooth=Smooth.Bezier),
2928            Ellipse(
2929              fillColor={255,213,170},
2930              fillPattern=FillPattern.Solid,
2931              extent={{-30,68},{-3,34}},
2932              endAngle=360),
2933            Polygon(
2934              pattern=LinePattern.None,
2935              fillPattern=FillPattern.Solid,
2936              points={{-38,58},{-16,74},{-2,60},{4,60},{6,60},{-38,58}},
2937              smooth=Smooth.Bezier),
2938            Polygon(
2939              fillColor={95,95,95},
2940              fillPattern=FillPattern.Solid,
2941              points={{30,-20},{-32,-4},{-36,-20},{-24,-34},{30,-20}},
2942              smooth=Smooth.Bezier),
2943            Polygon(
2944              fillPattern=FillPattern.Solid,
2945              points={{42,-46},{36,-60},{48,-54},{52,-48},{50,-44},{42,-46}},
2946              smooth=Smooth.Bezier),
2947            Line(points={{48,10},{26,24},{26,24}}, thickness=0.5),
2948            Line(points={{20,14},{34,34},{34,34}}, thickness=0.5),
2949            Polygon(
2950              fillColor={255,213,170},
2951              fillPattern=FillPattern.Solid,
2952              points={{28,28},{32,32},{28,26},{34,30},{30,26},{34,28},{30,24},{
2953                  26,26},{34,24},{26,24},{26,26},{28,28},{28,28},{26,26},{26,26},
2954                  {26,26},{28,32},{28,30},{28,28}},
2955              smooth=Smooth.Bezier),
2956            Polygon(
2957              fillColor={175,175,175},
2958              fillPattern=FillPattern.Solid,
2959              points={{-18,24},{28,30},{26,22},{-16,8},{-20,8},{-24,18},{-18,24}},
2960
2961              smooth=Smooth.Bezier),
2962            Polygon(
2963              fillColor={215,215,215},
2964              fillPattern=FillPattern.Solid,
2965              points={{72,18},{48,18},{36,-2},{58,-62},{72,-62},{72,18}}),
2966            Polygon(
2967              fillColor={95,95,95},
2968              fillPattern=FillPattern.Solid,
2969              points={{49,-70},{17,-16},{7,-20},{-1,-26},{49,-70}},
2970              smooth=Smooth.Bezier),
2971            Line(points={{-7,55},{-3,53}}),
2972            Line(points={{-9,42},{-5,42}}),
2973            Line(points={{-7,55},{-3,55}})}));
2974    end PropDriver;
2975
2976    model DragForce "Vehicle rolling and aerodinamical drag force"
2977      import Modelica.Constants.g_n;
2978      extends
2979        Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2;
2980      extends Modelica.Mechanics.Translational.Interfaces.PartialFriction;
2981      Modelica.SIunits.Force f "Total drag force";
2982      Modelica.SIunits.Velocity v "Vehicle velocity";
2983      Modelica.SIunits.Acceleration a "Absolute acceleration of flange";
2984      Real Sign;
2985      parameter Modelica.SIunits.Mass m "Vehicle mass";
2986      parameter Modelica.SIunits.Density rho(start=1.226) "air density";
2987      parameter Modelica.SIunits.Area S "Vehicle cross area";
2988      parameter Real fc(start=0.01) "Rolling friction coefficient";
2989      parameter Real Cx "Aerodinamic drag coefficient";
2990    protected
2991      parameter Real A=fc*m*g_n;
2992      parameter Real B=1/2*rho*S*Cx;
2993      // Constant auxiliary variable
2994    equation
2995      //  s = flange.s;
2996      v = der(s);
2997      a = der(v);
2998      // Le seguenti definizioni seguono l'ordine e le ridchieste del modello "PartialFriction" di
2999      // Modelica.Mechanics.Translational.Interfaces"
3000      v_relfric = v;
3001      a_relfric = a;
3002      f0 = A "forza a velocitC  0 ma con scorrimento";
3003      f0_max = A "massima forza  velocitC  0 e senza scorrimento ";
3004      free = false "sarebbe true quando la ruota si stacca dalla strada";
3005      // Ora il calcolo di f, e la sua attribuzione alla flangia:
3006      flange.f - f = 0;
3007      // friction force
3008      if v > 0 then
3009        Sign = 1;
3010      else
3011        Sign = -1;
3012      end if;
3013      f - B*v^2*Sign = if locked then sa*unitForce else f0*(if startForward
3014         then Modelica.Math.tempInterpol1(
3015            v,
3016            [0, 1],
3017            2) else if startBackward then -Modelica.Math.tempInterpol1(
3018            -v,
3019            [0, 1],
3020            2) else if pre(mode) == Forward then Modelica.Math.tempInterpol1(
3021            v,
3022            [0, 1],
3023            2) else -Modelica.Math.tempInterpol1(
3024            -v,
3025            [0, 1],
3026            2));
3027      annotation (
3028        Documentation(info="<html>
3029            <p>This component modesl the total (rolling &egrave;+ aerrodynamic vehicle drag resistance: </p>
3030            <p>f=mgh+(1/2)*rho*Cx*S*v^2</p>
3031            <p>It models reliably the stuck phase. based on Modelica-Intrerfaces.PartialFriction model</p>
3032            </html>"),
3033        Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
3034                100,100}}), graphics={
3035            Polygon(
3036              points={{-98,10},{22,10},{22,41},{92,0},{22,-41},{22,-10},{-98,-10},
3037                  {-98,10}},
3038              lineColor={0,127,0},
3039              fillColor={215,215,215},
3040              fillPattern=FillPattern.Solid),
3041            Line(points={{-42,-50},{87,-50}}, color={0,0,0}),
3042            Polygon(
3043              points={{-72,-50},{-41,-40},{-41,-60},{-72,-50}},
3044              lineColor={0,0,0},
3045              fillColor={128,128,128},
3046              fillPattern=FillPattern.Solid),
3047            Line(
3048              points={{-90,-90},{-70,-88},{-50,-82},{-30,-72},{-10,-58},{10,-40},
3049                  {30,-18},{50,8},{70,38},{90,72},{110,110}},
3050              color={0,0,255},
3051              thickness=0.5),
3052            Text(
3053              extent={{-82,90},{80,50}},
3054              lineColor={0,0,255},
3055              textString="%name")}),
3056        Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
3057                {100,100}}), graphics));
3058    end DragForce;
3059
3060    expandable connector Conn
3061      "Control bus that is adapted to the signals connected to it"
3062      extends Modelica.Icons.SignalBus;
3063      annotation (Diagram(graphics));
3064    end Conn;
3065
3066    model Batt1Conn
3067      "Modello di batteria basato su Batt0 con ordine elettrico pari a 1"
3068      Real powDeliv "battery power (positive when delivered)";
3069      Real SOC "State Of Charge";
3070      parameter Modelica.SIunits.ElectricCharge QCellNom(min=0) = 10*3.6e3
3071        "Nominal admissible electric charge per cell"
3072        annotation (Dialog(tab="cell data"));
3073      parameter Modelica.SIunits.Voltage ECellMin(min=0) = 3.3
3074        "Minimum open source voltage per cell"
3075        annotation (Dialog(tab="cell data"));
3076      parameter Modelica.SIunits.Voltage ECellMax(min=0.0001) = 4.15
3077        "Maximum open source voltage per cell"
3078        annotation (Dialog(tab="cell data"));
3079      parameter Real SOCMin(
3080        min=0,
3081        max=1) = 0 "Minimum state of charge"
3082        annotation (Dialog(group="SOC parameters"));
3083      parameter Real SOCMax(
3084        min=0,
3085        max=1) = 1 "Maximum state of charge"
3086        annotation (Dialog(group="SOC parameters"));
3087      parameter Real SOCInit(
3088        min=0,
3089        max=1) = 0.5 "Initial state of charge"
3090        annotation (Dialog(group="SOC parameters"));
3091      parameter Modelica.SIunits.Current ICellMax(min=0) = 10*QCellNom/3.6e3
3092        "Maximum admissible current" annotation (Dialog(tab="cell data"));
3093      parameter Modelica.SIunits.Resistance R0Cell(min=0) = 0.05*ECellMax/
3094        ICellMax "Series resistance \"R0\"" annotation (Dialog(tab="cell data",
3095            group="Electric circuit parameters"));
3096      parameter Modelica.SIunits.Resistance R1Cell(min=0) = R0Cell
3097        "Series resistance \"R1\"" annotation (Dialog(tab="cell data", group=
3098              "Electric circuit parameters"));
3099      parameter Modelica.SIunits.Capacitance C1Cell(min=0) = 60/R1Cell
3100        "Capacitance in parallel with R1" annotation (Dialog(tab="cell data",
3101            group="Electric circuit parameters"));
3102      parameter Real efficiency(
3103        min=0,
3104        max=0.9999) = 0.85 "Overall charging/discharging energy efficiency"
3105        annotation (Dialog(group="Parameters related to losses"));
3106      parameter Modelica.SIunits.Current iCellEfficiency(min=0) = 0.5*ICellMax
3107        "Cell charging/discharging current the efficiency refers to"
3108        annotation (Dialog(group="Parameters related to losses"));
3109      parameter Integer ns=1 "Number of serial connected cells"
3110        annotation (Dialog(tab="package data", group="Size of the package"));
3111      parameter Integer np=1 "Number of parallel connected cells"
3112        annotation (Dialog(tab="package data", group="Size of the package"));
3113      // determine fraction of drain current with respect to the total package current
3114      Modelica.Electrical.Analog.Basic.Capacitor cBattery(final C=CBattery)
3115        annotation (Placement(transformation(
3116            origin={-60,0},
3117            extent={{-10,-10},{10,10}},
3118            rotation=270)));
3119      Modelica.Electrical.Analog.Basic.Resistor R0(final R=R0Battery)
3120        annotation (Placement(transformation(
3121            origin={20,60},
3122            extent={{-10,-10},{10,10}},
3123            rotation=180)));
3124      Modelica.Electrical.Analog.Sources.SignalCurrent strayCurrent annotation
3125        (Placement(transformation(
3126            origin={-6,0},
3127            extent={{-10,-10},{10,10}},
3128            rotation=270)));
3129      Modelica.Electrical.Analog.Interfaces.Pin p annotation (Placement(
3130            transformation(extent={{90,50},{110,70}}), iconTransformation(
3131              extent={{90,52},{110,72}})));
3132      Modelica.Electrical.Analog.Interfaces.NegativePin n annotation (Placement(
3133            transformation(extent={{90,-70},{110,-50}}), iconTransformation(
3134              extent={{91,-70},{111,-50}})));
3135      Modelica.Electrical.Analog.Basic.Capacitor C1(C=C1Battery) annotation (
3136          Placement(transformation(
3137            extent={{-10,-10},{10,10}},
3138            rotation=180,
3139            origin={-37,50})));
3140      SupportModels.Conn conn annotation (Placement(transformation(
3141            extent={{-20,-20},{20,20}},
3142            rotation=90,
3143            origin={-100,-2})));
3144      Modelica.Blocks.Sources.RealExpression SOCs(y=SOC) annotation (Placement(
3145            transformation(
3146            extent={{-10,-10},{10,10}},
3147            rotation=-90,
3148            origin={-80,30})));
3149      Modelica.Blocks.Sources.RealExpression outPow(y=(p.v - n.v)*n.i)
3150        annotation (Placement(transformation(
3151            extent={{10,-10},{-10,10}},
3152            rotation=-90,
3153            origin={-80,-26})));
3154      Modelica.Electrical.Analog.Basic.Resistor R1(final R=R1Battery)
3155        annotation (Placement(visible=true, transformation(
3156            origin={-37,72},
3157            extent={{-10,-10},{10,10}},
3158            rotation=180)));
3159    protected
3160      parameter Real k=((1 - efficiency)*(eBattMax + eBattMin) - 2*(1 +
3161          efficiency)*Rtot*iCellEfficiency)/((1 + efficiency)*(eBattMax +
3162          eBattMin) - 2*(1 - efficiency)*Rtot*iCellEfficiency);
3163      parameter Real efficiencyMax=(eBattMin + eBattMax - 2*Rtot*
3164          iCellEfficiency)/(eBattMin + eBattMax + 2*Rtot*iCellEfficiency);
3165      final parameter Modelica.SIunits.Capacitance C=QCellNom/(ECellMax -
3166          ECellMin) "Cell capacitance";
3167      parameter Modelica.SIunits.Current IBatteryMax=ICellMax*np
3168        "Maximum battery current";
3169      parameter Modelica.SIunits.Voltage eBattMin=ECellMin*ns
3170        "Minimum battery voltage";
3171      parameter Modelica.SIunits.Voltage eBattMax=ECellMax*ns
3172        "Maximum battery voltage";
3173      parameter Modelica.SIunits.ElectricCharge QBatteryNominal=QCellNom*np
3174        "Battery admissible electric charge";
3175      parameter Modelica.SIunits.Capacitance CBattery=C*np/ns
3176        "Battery capacitance";
3177      parameter Modelica.SIunits.Resistance R0Battery=R0Cell*ns/np
3178        "Series inner resistance R0 of cell package";
3179      parameter Modelica.SIunits.Resistance R1Battery=R1Cell*ns/np
3180        "Series inner resistance R1 of cell package";
3181      parameter Modelica.SIunits.Resistance Rtot=R0Battery + R1Battery;
3182      parameter Modelica.SIunits.Capacitance C1Battery=C1Cell*np/ns
3183        "Battery series inner capacitance C1";
3184      Modelica.SIunits.Voltage ECell "Cell e.m.f.";
3185      Modelica.SIunits.Current iCellStray "Cell stray current";
3186      Modelica.SIunits.Voltage eBatt(start=eBattMin + SOCInit*(eBattMax -
3187            eBattMin), fixed=true) "Battery e.m.f.";
3188      Modelica.SIunits.Current iBatteryStray "Cell parasitic current";
3189      Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
3190        annotation (Placement(transformation(extent={{70,50},{90,70}}, rotation
3191              =0)));
3192      Modelica.Blocks.Math.Gain gain(k=k) annotation (Placement(transformation(
3193            origin={60,0},
3194            extent={{-10,-10},{10,10}},
3195            rotation=180)));
3196      Modelica.Blocks.Math.Abs absolute annotation (Placement(transformation(
3197              extent={{34,-10},{14,10}}, rotation=0)));
3198    equation
3199      connect(R1.p, R0.n) annotation (Line(points={{-27,72},{-18,72},{-18,60},{
3200              10,60}}, color={0,0,255}));
3201      connect(R1.p, C1.p) annotation (Line(points={{-27,72},{-18,72},{-18,50},{
3202              -27,50}}, color={0,0,255}));
3203      connect(R1.n, cBattery.p) annotation (Line(points={{-47,72},{-60,72},{-60,
3204              10}}, color={0,0,255}));
3205      assert(SOCMin >= 0, "SOCMin must be greater than, or equal to 0");
3206      assert(SOCMax <= 1, "SOCMax must be smaller than, or equal to 1");
3207      assert(efficiency <= efficiencyMax,
3208        "Overall charging/discharging energy efficiency is too big with respect to the actual serial resistance (EfficiencyMax ="
3209         + String(efficiencyMax) + ")");
3210      assert(SOCMin < SOCMax, "SOCMax(=" + String(SOCMax) +
3211        ") must be greater than SOCMin(=" + String(SOCMin) + ")");
3212      assert(SOCInit >= SOCMin, "SOCInit(=" + String(SOCInit) +
3213        ") must be greater than, or equal to SOCMin(=" + String(SOCMin) + ")");
3214      assert(SOCInit <= SOCMax, "SOCInit(=" + String(SOCInit) +
3215        ") must be smaller than, or equal to SOCMax(=" + String(SOCMax) + ")");
3216      iBatteryStray = strayCurrent.i;
3217      iCellStray = iBatteryStray/np;
3218      eBatt = cBattery.v;
3219      //Solo per dare maggiore chiarezza all'utente con un nome significativo
3220      ECell = eBatt/ns;
3221      powDeliv = (p.v - n.v)*n.i;
3222      assert(abs(p.i/np) < ICellMax, "Battery cell current i=" + String(abs(p.i
3223        /np)) + "\n exceeds max admissable ICellMax (=" + String(ICellMax) +
3224        "A)");
3225      SOC = (eBatt - eBattMin)/(eBattMax - eBattMin);
3226      //*(SOCMax-SOCMin)+SOCMin);
3227      assert(SOC <= SOCMax,
3228        "Battery is fully charged: State of charge reached maximum limit (=" +
3229        String(SOCMax) + ")");
3230      assert(SOCMin <= SOC,
3231        "Battery is fully discharged: State of charge reached minimum limit (="
3232         + String(SOCMin) + ")");
3233      connect(R0.p, currentSensor.p)
3234        annotation (Line(points={{30,60},{70,60}}, color={0,0,255}));
3235      connect(strayCurrent.p, R0.n)
3236        annotation (Line(points={{-6,10},{-6,60},{10,60}}, color={0,0,255}));
3237      connect(currentSensor.i, gain.u) annotation (Line(points={{80,50},{80,-1.46958e-015},
3238              {72,-1.46958e-015}}, color={0,0,127}));
3239      connect(absolute.u, gain.y) annotation (Line(points={{36,0},{39.5,0},{
3240              39.5,1.33227e-015},{49,1.33227e-015}}, color={0,0,127}));
3241      connect(absolute.y, strayCurrent.i) annotation (Line(points={{13,0},{7,0},
3242              {7,-1.28588e-015},{1,-1.28588e-015}}, color={0,0,127}));
3243      connect(currentSensor.n, p)
3244        annotation (Line(points={{90,60},{90,60},{100,60}}, color={0,0,255}));
3245      connect(strayCurrent.n, n) annotation (Line(points={{-6,-10},{-6,-60},{
3246              100,-60}}, color={0,0,255}));
3247      connect(n, cBattery.n) annotation (Line(points={{100,-60},{-60,-60},{-60,
3248              -10}}, color={0,0,255}));
3249      connect(C1.n, cBattery.p) annotation (Line(
3250          points={{-47,50},{-60,50},{-60,10}},
3251          color={0,0,255},
3252          smooth=Smooth.None));
3253      connect(conn.batSOC, SOCs.y) annotation (Line(
3254          points={{-100,-2},{-100,8.5},{-80,8.5},{-80,19}},
3255          color={255,204,51},
3256          thickness=0.5,
3257          smooth=Smooth.None), Text(
3258          string="%first",
3259          index=-1,
3260          extent={{-6,3},{-6,3}}));
3261      connect(outPow.y, conn.batPowDel) annotation (Line(
3262          points={{-80,-15},{-80,-2},{-100,-2}},
3263          color={0,0,127},
3264          smooth=Smooth.None), Text(
3265          string="%second",
3266          index=1,
3267          extent={{6,3},{6,3}}));
3268      annotation (
3269        Documentation(info="<html>
3270    <p>Modello di batteria  dotato di efficienza colombica non unitaria, secondo quanto discusso nelle dispense SEB.</p>
3271    <p>Il ramo principaledel modello di cella  presenta una f.e.m. linearmente crescente con il SOC (simulata tramite un condensatore equivalente), una resistenza R0 ed un blocco R-C.</p>
3272    <p>La batteria &egrave; composta da np filari idi celle in parallelo, ciascuno composto da ns celle in serie.</p>
3273    <p><br/>SEB a.a. 2012-2013.</p>
3274    </html>", revisions="<html><table border=\"1\" rules=\"groups\">
3275    <thead>
3276    <tr><td>Version</td>  <td>Date</td>  <td>Comment</td></tr>
3277    </thead>
3278    <tbody>
3279    <tr><td>1.0.0</td>  <td>2006-01-12</td>  <td> </td></tr>
3280    <tr><td>1.0.3</td>  <td>2006-08-31</td>  <td> Improved assert statements </td></tr>
3281    <tr><td>1.0.6</td>  <td>2007-05-14</td>  <td> The documentation changed slightly </td></tr>
3282    </tbody>
3283    </table>
3284    </html>"),
3285        Diagram(coordinateSystem(
3286            extent={{-100,-80},{100,80}},
3287            preserveAspectRatio=false,
3288            initialScale=0.1,
3289            grid={2,2}), graphics),
3290        Icon(coordinateSystem(
3291            extent={{-100,-80},{100,80}},
3292            preserveAspectRatio=false,
3293            initialScale=0.1,
3294            grid={2,2}), graphics={
3295            Rectangle(
3296              lineColor={95,95,95},
3297              fillColor={255,255,255},
3298              fillPattern=FillPattern.Solid,
3299              extent={{-100,80},{80,-82}}),
3300            Line(points={{-92,6},{-52,6}}, color={0,0,255}),
3301            Rectangle(
3302              lineColor={0,0,255},
3303              fillColor={0,0,255},
3304              fillPattern=FillPattern.Solid,
3305              extent={{-82,-3},{-65,-10}}),
3306            Line(points={{-73,63},{98,64}}, color={0,0,255}),
3307            Rectangle(
3308              lineColor={0,0,255},
3309              fillColor={255,255,255},
3310              fillPattern=FillPattern.Solid,
3311              extent={{38,69},{68,57}}),
3312            Rectangle(
3313              lineColor={0,0,255},
3314              fillColor={255,255,255},
3315              fillPattern=FillPattern.Solid,
3316              extent={{-37.5,68},{-6.5,56}}),
3317            Line(points={{-19.5,49},{-19.5,32}}, color={0,0,255}),
3318            Line(points={{-54.5,63},{-54.5,41},{-25.5,41}}, color={0,0,255}),
3319            Line(points={{9.5,62},{9.5,40},{-19.5,40}}, color={0,0,255}),
3320            Line(points={{-73,63},{-73,5}}, color={0,0,255}),
3321            Line(points={{-73,-6},{-73,-60},{96,-60}}, color={0,0,255}),
3322            Line(points={{26,63},{26,-61}}, color={0,0,255}),
3323            Line(points={{-25.5,49},{-25.5,32}}, color={0,0,255}),
3324            Polygon(
3325              lineColor={0,0,255},
3326              fillColor={255,255,255},
3327              fillPattern=FillPattern.Solid,
3328              points={{26,22},{14,4},{26,-14},{38,4},{26,22}}),
3329            Line(points={{20,4},{32,4}}, color={0,0,255}),
3330            Polygon(lineColor={0,0,255}, points={{22,-20},{30,-20},{26,-32},{22,
3331                  -20}}),
3332            Text(
3333              origin={-4,-22},
3334              lineColor={0,0,255},
3335              extent={{-100,150},{100,110}},
3336              textString="%name")}));
3337    end Batt1Conn;
3338
3339    package Internal
3340      "Models intended to be used by other models of this package, not by the final user"
3341      model ConstPDC "Constant Power DC Load"
3342        parameter Real k "inner PI follower proportional gain";
3343        parameter Modelica.SIunits.Time T
3344          "inner PI follower integral time constant";
3345        Real v "DC voltage";
3346        Modelica.Blocks.Math.Feedback feedback1 annotation (Placement(visible=
3347                true, transformation(
3348              origin={56,-44},
3349              extent={{-10,-10},{10,10}},
3350              rotation=180)));
3351        Modelica.Blocks.Continuous.PI PI(
3352          k=k,
3353          T=T,
3354          initType=Modelica.Blocks.Types.Init.InitialState) annotation (
3355            Placement(visible=true, transformation(
3356              origin={20,-44},
3357              extent={{-8,-8},{8,8}},
3358              rotation=180)));
3359        Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation (
3360            Placement(
3361            visible=true,
3362            transformation(extent={{-108,58},{-88,78}}, rotation=0),
3363            iconTransformation(extent={{-10,90},{10,110}}, rotation=0)));
3364        Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation (
3365            Placement(
3366            visible=true,
3367            transformation(extent={{-108,-74},{-88,-54}}, rotation=0),
3368            iconTransformation(extent={{-10,-108},{10,-88}}, rotation=0)));
3369        Modelica.Blocks.Interfaces.RealInput Pref "Reference power" annotation
3370          (Placement(
3371            visible=true,
3372            transformation(
3373              origin={100,-44},
3374              extent={{-18,-18},{18,18}},
3375              rotation=180),
3376            iconTransformation(
3377              origin={82,0},
3378              extent={{-18,-18},{18,18}},
3379              rotation=180)));
3380        Modelica.Electrical.Analog.Sensors.PowerSensor pSensor annotation (
3381            Placement(visible=true, transformation(extent={{-78,58},{-58,78}},
3382                rotation=0)));
3383        Modelica.Electrical.Analog.Sensors.VoltageSensor uSensor annotation (
3384            Placement(visible=true, transformation(
3385              origin={-43,15},
3386              extent={{-9,-9},{9,9}},
3387              rotation=270)));
3388        Modelica.Electrical.Analog.Sources.SignalCurrent iDrawn annotation (
3389            Placement(visible=true, transformation(
3390              origin={-12,18},
3391              extent={{-10,-10},{10,10}},
3392              rotation=270)));
3393        Modelica.Blocks.Math.Product product annotation (Placement(visible=true,
3394              transformation(
3395              origin={18,18},
3396              extent={{-8,-8},{8,8}},
3397              rotation=180)));
3398        Inverse inverse(k=1) annotation (Placement(visible=true, transformation(
3399              origin={10,50},
3400              extent={{-10,-10},{10,10}},
3401              rotation=0)));
3402      equation
3403        connect(PI.y, product.u1) annotation (Line(points={{11.2,-44},{2,-44},{
3404                2,-20},{40,-20},{40,13.2},{27.6,13.2}}, color={0,0,127}));
3405        connect(inverse.y, product.u2) annotation (Line(points={{20.6,50},{40,
3406                50},{40,22.8},{27.6,22.8}}, color={0,0,127}));
3407        connect(uSensor.v, inverse.u) annotation (Line(points={{-52,15},{-54,15},
3408                {-54,50},{-1,50}}, color={0,0,127}));
3409        connect(product.y, iDrawn.i)
3410          annotation (Line(points={{9.2,18},{-5,18}}, color={0,0,127}));
3411        connect(uSensor.n, iDrawn.n) annotation (Line(points={{-43,6},{-43,-28},
3412                {-12,-28},{-12,8}}, color={0,0,255}));
3413        connect(pSensor.nc, iDrawn.p) annotation (Line(points={{-58,68},{-12,68},
3414                {-12,28}}, color={0,0,255}));
3415        connect(iDrawn.n, pin_n) annotation (Line(points={{-12,8},{-12,-64},{-98,
3416                -64}}, color={0,0,255}));
3417        connect(uSensor.p, pSensor.nc) annotation (Line(points={{-43,24},{-43,
3418                68},{-58,68}}, color={0,0,255}));
3419        connect(feedback1.u2, pSensor.power) annotation (Line(points={{56,-36},
3420                {56,-8},{-76,-8},{-76,57}}, color={0,0,127}));
3421        connect(pSensor.nv, pin_n) annotation (Line(points={{-68,58},{-68,-64},
3422                {-98,-64}}, color={0,0,255}));
3423        connect(feedback1.u1, Pref)
3424          annotation (Line(points={{64,-44},{100,-44}}, color={0,0,127}));
3425        connect(iDrawn.n, pin_n) annotation (Line(points={{-12,8},{-12,-64},{-98,
3426                -64}}, color={0,0,255}));
3427        connect(pSensor.nv, pin_n) annotation (Line(points={{-68,58},{-68,-64},
3428                {-98,-64}}, color={0,0,255}));
3429        connect(feedback1.u2, pSensor.power) annotation (Line(points={{56,-36},
3430                {56,-8},{-76,-8},{-76,57}}, color={0,0,127}));
3431        connect(uSensor.n, iDrawn.n) annotation (Line(points={{-43,6},{-43,-28},
3432                {-12,-28},{-12,8}}, color={0,0,255}));
3433        connect(uSensor.v, inverse.u) annotation (Line(points={{-52,15},{-54,15},
3434                {-54,50},{-1,50}}, color={0,0,127}));
3435        connect(feedback1.y, PI.u)
3436          annotation (Line(points={{47,-44},{29.6,-44}}, color={0,0,127}));
3437        v = pin_p.v - pin_n.v;
3438        connect(pSensor.pc, pin_p) annotation (Line(
3439            points={{-78,68},{-98,68}},
3440            color={0,0,255},
3441            smooth=Smooth.None));
3442        connect(pSensor.pv, pSensor.pc) annotation (Line(
3443            points={{-68,78},{-78,78},{-78,68}},
3444            color={0,0,255},
3445            smooth=Smooth.None));
3446        annotation (
3447          Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
3448                  {100,100}}), graphics),
3449          Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
3450                  100,100}}), graphics={Line(
3451                      points={{-4,0},{70,0}},
3452                      color={0,0,0},
3453                      smooth=Smooth.None),Line(
3454                      points={{0,94},{0,-88},{-2,-90}},
3455                      color={0,0,255},
3456                      smooth=Smooth.None),Rectangle(
3457                      extent={{-28,68},{28,-52}},
3458                      lineColor={0,0,255},
3459                      fillColor={255,255,255},
3460                      fillPattern=FillPattern.Solid),Text(
3461                      extent={{42,58},{78,22}},
3462                      lineColor={255,0,0},
3463                      fillColor={255,255,255},
3464                      fillPattern=FillPattern.Solid,
3465                      textString="P")}),
3466          Documentation(info="<html>
3467    <p>Questo componente simula, mediante inseguimento di un riferimento esterno, un carico a potenza costante.</p>
3468    <p>I parametri k e T sono i parametri del regolatore PI che insegue l&apos;input. TIpicamente si potr&agrave; utilizzare k=1 e T di un ordine di grandezza pi&ugrave; piccolo delle costanti di tempo del segnale di ingresso di potenza</p>
3469    </html>"));
3470      end ConstPDC;
3471
3472      block Inverse "Outputs the inverse of (input multiplied by k)"
3473        import Modelica.Constants.inf;
3474        import Modelica.Constants.eps;
3475        Modelica.Blocks.Interfaces.RealInput u annotation (Placement(
3476              transformation(extent={{-128,-20},{-88,20}}), iconTransformation(
3477                extent={{-128,-18},{-92,18}})));
3478        Modelica.Blocks.Interfaces.RealOutput y annotation (Placement(
3479              transformation(extent={{98,-10},{118,10}}), iconTransformation(
3480                extent={{96,-10},{116,10}})));
3481        parameter Real k;
3482      equation
3483        if abs(u) < eps then
3484          y = inf;
3485        else
3486          y = 1.0/(k*u);
3487        end if;
3488        annotation (Diagram(coordinateSystem(preserveAspectRatio=true, extent={
3489                  {-100,-100},{100,100}}), graphics), Icon(coordinateSystem(
3490                preserveAspectRatio=true, extent={{-100,-100},{100,100}}),
3491              graphics={Rectangle(
3492                      extent={{-100,100},{100,-100}},
3493                      lineColor={0,0,127},
3494                      fillPattern=FillPattern.Solid,
3495                      fillColor={255,255,255}),Text(
3496                      extent={{-10,-4},{60,52}},
3497                      lineColor={0,0,127},
3498                      textString="1"),Text(
3499                      extent={{-32,0},{76,-46}},
3500                      lineColor={0,0,127},
3501                      textString="k u"),Line(
3502                      points={{-14,0},{66,0}},
3503                      color={0,0,127},
3504                      smooth=Smooth.None),Text(
3505                      extent={{-86,-30},{-16,26}},
3506                      lineColor={0,0,127},
3507                      textString="y=")}));
3508      end Inverse;
3509
3510      model Inverter
3511        Modelica.Blocks.Interfaces.RealInput u
3512          annotation (Placement(transformation(extent={{140,-20},{100,20}})));
3513        Modelica.Blocks.Interfaces.RealOutput y
3514          annotation (Placement(transformation(extent={{-100,-10},{-120,10}})));
3515        Modelica.Blocks.Math.Gain gain(k=LossFact)
3516          annotation (Placement(transformation(extent={{10,-10},{-10,10}})));
3517        parameter Real LossFact=4 "Loss Factor (W per AC Arms)";
3518      equation
3519        connect(gain.u, u) annotation (Line(
3520            points={{12,0},{120,0}},
3521            color={0,0,127},
3522            smooth=Smooth.None));
3523        connect(gain.y, y) annotation (Line(
3524            points={{-11,0},{-110,0}},
3525            color={0,0,127},
3526            smooth=Smooth.None));
3527        annotation (Diagram(coordinateSystem(extent={{-100,-100},{100,100}},
3528                preserveAspectRatio=false), graphics), Icon(coordinateSystem(
3529              extent={{-100,-100},{100,100}},
3530              preserveAspectRatio=false,
3531              initialScale=0.1,
3532              grid={2,2}), graphics={Rectangle(
3533                      lineColor={0,0,127},
3534                      fillColor={255,255,255},
3535                      fillPattern=FillPattern.Solid,
3536                      extent={{-100,60},{100,-60}}),Text(
3537                      origin={0,4},
3538                      lineColor={0,0,255},
3539                      fillColor={255,255,255},
3540                      fillPattern=FillPattern.Solid,
3541                      extent={{-100,102},{100,62}},
3542                      textString="%name")}));
3543      end Inverter;
3544    end Internal;
3545
3546    annotation (Icon(graphics={
3547          Ellipse(extent={{-36,40},{40,-36}}, lineColor={0,0,0}),
3548          Line(
3549            points={{4,82},{-6,82},{-10,72},{-24,68},{-34,78},{-46,70},{-42,58},
3550                {-54,46},{-66,50},{-74,36},{-66,30},{-68,16},{-78,12},{-78,2}},
3551
3552            color={0,0,0},
3553            smooth=Smooth.None),
3554          Line(
3555            points={{4,-78},{-6,-78},{-10,-68},{-24,-64},{-34,-74},{-46,-66},{-42,
3556                -54},{-54,-42},{-66,-46},{-74,-32},{-66,-26},{-68,-12},{-78,-8},
3557                {-78,2}},
3558            color={0,0,0},
3559            smooth=Smooth.None),
3560          Line(
3561            points={{2,-78},{12,-78},{16,-68},{30,-64},{40,-74},{52,-66},{48,-54},
3562                {60,-42},{72,-46},{80,-32},{72,-26},{74,-12},{84,-8},{84,2}},
3563            color={0,0,0},
3564            smooth=Smooth.None),
3565          Line(
3566            points={{2,82},{12,82},{16,72},{30,68},{40,78},{52,70},{48,58},{60,
3567                46},{72,50},{80,36},{72,30},{74,16},{84,12},{84,2}},
3568            color={0,0,0},
3569            smooth=Smooth.None)}));
3570
3571  end SupportModels;
3572
3573  package Icons
3574    model EcuIcon
3575      SupportModels.Conn conn1 annotation (Placement(
3576          visible=true,
3577          transformation(extent={{-20,78},{20,118}}, rotation=0),
3578          iconTransformation(extent={{-20,80},{20,120}}, rotation=0)));
3579      Modelica.Blocks.Interfaces.RealInput motTauInt annotation (Placement(
3580          visible=true,
3581          transformation(extent={{-140,-20},{-100,20}}, rotation=0),
3582          iconTransformation(extent={{-140,-20},{-100,20}}, rotation=0)));
3583      annotation (Icon(graphics={Rectangle(
3584                  extent={{-100,100},{100,-100}},
3585                  lineColor={0,0,0},
3586                  fillColor={255,255,255},
3587                  fillPattern=FillPattern.Solid),Polygon(
3588                  points={{-4,-40},{74,16},{74,-6},{-4,-62},{-4,-40}},
3589                  lineColor={95,95,95},
3590                  fillColor={175,175,175},
3591                  fillPattern=FillPattern.Solid),Polygon(
3592                  points={{8,-38},{28,-48},{20,-54},{0,-44},{8,-38}},
3593                  lineColor={0,0,255},
3594                  fillColor={255,255,0},
3595                  fillPattern=FillPattern.Solid),Polygon(
3596                  points={{20,-54},{28,-48},{32,-56},{24,-62},{20,-54}},
3597                  lineColor={0,0,255},
3598                  fillColor={255,255,0},
3599                  fillPattern=FillPattern.Solid),Polygon(
3600                  points={{24,-62},{32,-56},{32,-78},{24,-84},{24,-62}},
3601                  lineColor={0,0,255},
3602                  fillColor={255,255,127},
3603                  fillPattern=FillPattern.Solid),Polygon(
3604                  points={{0,-44},{20,-54},{24,-62},{24,-84},{22,-84},{22,-62},
3605                {20,-58},{0,-48},{0,-44}},
3606                  lineColor={0,0,255},
3607                  fillColor={191,191,0},
3608                  fillPattern=FillPattern.Solid),Polygon(
3609                  points={{-14,40},{-18,32},{-10,38},{-8,44},{-14,40}},
3610                  lineColor={128,128,128},
3611                  fillColor={128,128,128},
3612                  fillPattern=FillPattern.Solid),Polygon(
3613                  points={{-18,32},{-10,38},{-10,14},{-18,8},{-18,32}},
3614                  lineColor={0,0,255},
3615                  fillColor={255,255,127},
3616                  fillPattern=FillPattern.Solid),Polygon(
3617                  points={{-20,10},{-20,32},{-16,40},{4,30},{4,26},{-16,36},{-18,
3618                32},{-18,8},{-20,10}},
3619                  lineColor={0,0,255},
3620                  fillColor={191,191,0},
3621                  fillPattern=FillPattern.Solid),Polygon(
3622                  points={{-8,46},{12,36},{4,30},{-16,40},{-8,46}},
3623                  lineColor={0,0,255},
3624                  fillColor={255,255,0},
3625                  fillPattern=FillPattern.Solid),Polygon(
3626                  points={{28,-22},{48,-32},{40,-38},{20,-28},{28,-22}},
3627                  lineColor={0,0,255},
3628                  fillColor={255,255,0},
3629                  fillPattern=FillPattern.Solid),Polygon(
3630                  points={{40,-38},{48,-32},{52,-40},{44,-46},{40,-38}},
3631                  lineColor={0,0,255},
3632                  fillColor={255,255,0},
3633                  fillPattern=FillPattern.Solid),Polygon(
3634                  points={{44,-46},{52,-40},{52,-62},{44,-68},{44,-46}},
3635                  lineColor={0,0,255},
3636                  fillColor={255,255,127},
3637                  fillPattern=FillPattern.Solid),Polygon(
3638                  points={{20,-28},{40,-38},{44,-46},{44,-68},{42,-68},{42,-46},
3639                {40,-42},{20,-32},{20,-28}},
3640                  lineColor={0,0,255},
3641                  fillColor={191,191,0},
3642                  fillPattern=FillPattern.Solid),Polygon(
3643                  points={{48,-8},{68,-18},{60,-24},{40,-14},{48,-8}},
3644                  lineColor={0,0,255},
3645                  fillColor={255,255,0},
3646                  fillPattern=FillPattern.Solid),Polygon(
3647                  points={{60,-24},{68,-18},{72,-26},{64,-32},{60,-24}},
3648                  lineColor={0,0,255},
3649                  fillColor={255,255,0},
3650                  fillPattern=FillPattern.Solid),Polygon(
3651                  points={{64,-32},{72,-26},{72,-48},{64,-54},{64,-32}},
3652                  lineColor={0,0,255},
3653                  fillColor={255,255,127},
3654                  fillPattern=FillPattern.Solid),Polygon(
3655                  points={{40,-14},{60,-24},{64,-32},{64,-54},{62,-54},{62,-32},
3656                {60,-28},{40,-18},{40,-14}},
3657                  lineColor={0,0,255},
3658                  fillColor={191,191,0},
3659                  fillPattern=FillPattern.Solid),Polygon(
3660                  points={{68,6},{88,-4},{80,-10},{60,0},{68,6}},
3661                  lineColor={0,0,255},
3662                  fillColor={255,255,0},
3663                  fillPattern=FillPattern.Solid),Polygon(
3664                  points={{80,-10},{88,-4},{92,-12},{84,-18},{80,-10}},
3665                  lineColor={0,0,255},
3666                  fillColor={255,255,0},
3667                  fillPattern=FillPattern.Solid),Polygon(
3668                  points={{84,-18},{92,-12},{92,-34},{84,-40},{84,-18}},
3669                  lineColor={0,0,255},
3670                  fillColor={255,255,127},
3671                  fillPattern=FillPattern.Solid),Polygon(
3672                  points={{60,0},{80,-10},{84,-18},{84,-40},{82,-40},{82,-18},{
3673                80,-14},{60,-4},{60,0}},
3674                  lineColor={0,0,255},
3675                  fillColor={191,191,0},
3676                  fillPattern=FillPattern.Solid),Polygon(
3677                  points={{-34,26},{-38,18},{-30,24},{-28,30},{-34,26}},
3678                  lineColor={128,128,128},
3679                  fillColor={128,128,128},
3680                  fillPattern=FillPattern.Solid),Polygon(
3681                  points={{-38,18},{-30,24},{-30,0},{-38,-6},{-38,18}},
3682                  lineColor={0,0,255},
3683                  fillColor={255,255,127},
3684                  fillPattern=FillPattern.Solid),Polygon(
3685                  points={{-40,-4},{-40,18},{-36,26},{-16,16},{-16,12},{-36,22},
3686                {-38,18},{-38,-6},{-40,-4}},
3687                  lineColor={0,0,255},
3688                  fillColor={191,191,0},
3689                  fillPattern=FillPattern.Solid),Polygon(
3690                  points={{-28,32},{-8,22},{-16,16},{-36,26},{-28,32}},
3691                  lineColor={0,0,255},
3692                  fillColor={255,255,0},
3693                  fillPattern=FillPattern.Solid),Polygon(
3694                  points={{-54,12},{-58,4},{-50,10},{-48,16},{-54,12}},
3695                  lineColor={128,128,128},
3696                  fillColor={128,128,128},
3697                  fillPattern=FillPattern.Solid),Polygon(
3698                  points={{-58,4},{-50,10},{-50,-14},{-58,-20},{-58,4}},
3699                  lineColor={0,0,255},
3700                  fillColor={255,255,127},
3701                  fillPattern=FillPattern.Solid),Polygon(
3702                  points={{-60,-18},{-60,4},{-56,12},{-36,2},{-36,-2},{-56,8},{
3703                -58,4},{-58,-20},{-60,-18}},
3704                  lineColor={0,0,255},
3705                  fillColor={191,191,0},
3706                  fillPattern=FillPattern.Solid),Polygon(
3707                  points={{-48,18},{-28,8},{-36,2},{-56,12},{-48,18}},
3708                  lineColor={0,0,255},
3709                  fillColor={255,255,0},
3710                  fillPattern=FillPattern.Solid),Polygon(
3711                  points={{-74,-4},{-78,-12},{-70,-6},{-68,0},{-74,-4}},
3712                  lineColor={128,128,128},
3713                  fillColor={128,128,128},
3714                  fillPattern=FillPattern.Solid),Polygon(
3715                  points={{-78,-12},{-70,-6},{-70,-30},{-78,-36},{-78,-12}},
3716                  lineColor={0,0,255},
3717                  fillColor={255,255,127},
3718                  fillPattern=FillPattern.Solid),Polygon(
3719                  points={{-80,-34},{-80,-12},{-76,-4},{-56,-14},{-56,-18},{-76,
3720                -8},{-78,-12},{-78,-36},{-80,-34}},
3721                  lineColor={0,0,255},
3722                  fillColor={191,191,0},
3723                  fillPattern=FillPattern.Solid),Polygon(
3724                  points={{-68,2},{-48,-8},{-56,-14},{-76,-4},{-68,2}},
3725                  lineColor={0,0,255},
3726                  fillColor={255,255,0},
3727                  fillPattern=FillPattern.Solid),Polygon(
3728                  points={{-64,-8},{-4,-40},{-4,-62},{-64,-30},{-64,-8}},
3729                  lineColor={95,95,95},
3730                  fillColor={75,75,75},
3731                  fillPattern=FillPattern.Solid),Polygon(
3732                  points={{-64,-8},{-4,-40},{74,16},{14,48},{-64,-8}},
3733                  lineColor={95,95,95},
3734                  fillColor={160,160,164},
3735                  fillPattern=FillPattern.Solid),Text(
3736                  origin={-1,-42},
3737                  lineColor={0,0,255},
3738                  extent={{-119,-64},{119,-104}},
3739                  textString="%name"),Rectangle(
3740                  extent={{-98,92},{98,62}},
3741                  fillColor={255,255,255},
3742                  fillPattern=FillPattern.Solid,
3743                  pattern=LinePattern.None)}), Diagram(coordinateSystem(
3744              preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
3745            graphics));
3746    end EcuIcon;
3747
3748    model SupportIcon
3749      annotation (Icon(graphics={Ellipse(extent={{-38,38},{38,-38}}, lineColor=
3750              {0,0,0}),Line(
3751                  points={{2,80},{-8,80},{-12,70},{-26,66},{-36,76},{-48,68},{-44,
3752                56},{-56,44},{-68,48},{-76,34},{-68,28},{-70,14},{-80,10},{-80,
3753                0}},
3754                  color={0,0,0},
3755                  smooth=Smooth.None),Line(
3756                  points={{2,-80},{-8,-80},{-12,-70},{-26,-66},{-36,-76},{-48,-68},
3757                {-44,-56},{-56,-44},{-68,-48},{-76,-34},{-68,-28},{-70,-14},{-80,
3758                -10},{-80,0}},
3759                  color={0,0,0},
3760                  smooth=Smooth.None),Line(
3761                  points={{0,-80},{10,-80},{14,-70},{28,-66},{38,-76},{50,-68},
3762                {46,-56},{58,-44},{70,-48},{78,-34},{70,-28},{72,-14},{82,-10},
3763                {82,0}},
3764                  color={0,0,0},
3765                  smooth=Smooth.None),Line(
3766                  points={{0,80},{10,80},{14,70},{28,66},{38,76},{50,68},{46,56},
3767                {58,44},{70,48},{78,34},{70,28},{72,14},{82,10},{82,0}},
3768                  color={0,0,0},
3769                  smooth=Smooth.None)}));
3770    end SupportIcon;
3771  end Icons;
3772
3773  model FullModel
3774    import Modelica.Constants.*;
3775    extends Modelica.Icons.Example;
3776    parameter Real vMass=1300;
3777    parameter Real wIceStart=50;
3778    parameter Real factorDebug=100;
3779    // rad/s
3780    Modelica.SIunits.Energy EbatDel "energy delivered by the battery";
3781    Modelica.SIunits.Energy EgenDelM
3782      "energy delivered by gen trough mechanical flange";
3783    Modelica.SIunits.Energy Eroad
3784      "mechanical energy absorbed by roas (friction & air)";
3785    Modelica.SIunits.Energy EiceDel "mechanical energy delivered by ice";
3786    Modelica.SIunits.Energy Emot, Emass;
3787    Modelica.Mechanics.Rotational.Components.IdealPlanetary PSD(ratio=78/30)
3788      annotation (Placement(transformation(
3789          extent={{-10,-10},{10,10}},
3790          rotation=0,
3791          origin={-50,52})));
3792    Modelica.Mechanics.Rotational.Components.IdealGear idealGear(ratio=3.905)
3793      annotation (Placement(transformation(extent={{2,42},{22,62}})));
3794    Modelica.Mechanics.Translational.Sensors.SpeedSensor carVel annotation (
3795        Placement(transformation(
3796          extent={{-10,-10},{10,10}},
3797          rotation=270,
3798          origin={78,-12})));
3799    Modelica.Mechanics.Translational.Components.Mass mass(v(fixed=true, start=0),
3800        m=vMass)
3801      annotation (Placement(transformation(extent={{54,42},{74,62}})));
3802    SupportModels.DragForce dragForce(
3803      fc=0.014,
3804      rho=1.226,
3805      m=vMass,
3806      S=2.2,
3807      Cx=0.26) annotation (Placement(transformation(
3808          extent={{-9,-9},{9,9}},
3809          rotation=90,
3810          origin={89,29})));
3811    MapBased.MBiceConnP ice(vMass=vMass, wIceStart=wIceStart)
3812      annotation (Placement(transformation(extent={{-98,46},{-78,66}})));
3813    SupportModels.Batt1Conn bat(
3814      ECellMin=0.9,
3815      ECellMax=1.45,
3816      R0Cell=0.0003,
3817      ns=168,
3818      QCellNom=2*6.5*3600.0,
3819      SOCInit=0.6,
3820      ICellMax=1e5,
3821      iCellEfficiency=15*6.5) annotation (Placement(transformation(
3822          extent={{-10,-10},{10,10}},
3823          rotation=90,
3824          origin={-16,0})));
3825    SupportModels.PropDriver driver(
3826      CycleFileName="nedc.txt",
3827      k=1,
3828      yMax=1.8) annotation (Placement(visible=true, transformation(extent={{-58,
3829              -50},{-38,-30}}, rotation=0)));
3830    SupportModels.Conn d annotation (Placement(
3831        visible=true,
3832        transformation(extent={{2,-40},{28,-16}}, rotation=0),
3833        iconTransformation(extent={{4,-52},{30,-28}}, rotation=0)));
3834    MapBased.MBecu1soc ECU(genLoopGain=1, socLoopGain=1e5) annotation (
3835        Placement(visible=true, transformation(
3836          origin={-10,-41},
3837          extent={{-10,-9},{10,9}},
3838          rotation=0)));
3839    MapBased.MBTwoFlangeConn mot annotation (Placement(visible=true,
3840          transformation(extent={{-28,62},{-8,42}}, rotation=0)));
3841    Modelica.Mechanics.Rotational.Components.IdealRollingWheel wheel(radius=
3842          0.31) annotation (Placement(visible=true, transformation(
3843          origin={38,52},
3844          extent={{-10,-10},{10,10}},
3845          rotation=0)));
3846    Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(
3847          visible=true, transformation(
3848          origin={10,26},
3849          extent={{10,10},{-10,-10}},
3850          rotation=270)));
3851    MapBased.MBOneFlangeConn gen annotation (Placement(visible=true,
3852          transformation(extent={{-38,14},{-58,34}}, rotation=0)));
3853  equation
3854    connect(gen.pin_p, bat.p) annotation (Line(points={{-38,28},{-24,28},{-24,
3855            10},{-23.75,10}}, color={0,0,255}));
3856    connect(gen.pin_n, bat.n) annotation (Line(points={{-38,20},{-8.5,20},{-8.5,
3857            10.1}}, color={0,0,255}));
3858    connect(gen.flange_a, PSD.sun)
3859      annotation (Line(points={{-58,24},{-58,24},{-70,24},{-70,52},{-60,52}}));
3860    connect(gen.conn, ECU.conn1) annotation (Line(
3861        points={{-58,16.2},{-58,-20},{-10,-20},{-10,-32.18}},
3862        color={255,204,51},
3863        thickness=0.5));
3864    connect(ground.p, bat.n) annotation (Line(points={{0,26},{-8.5,26},{-8.5,
3865            10.1}}, color={0,0,255}));
3866    connect(wheel.flangeT, mass.flange_a)
3867      annotation (Line(points={{48,52},{54,52}}, color={0,127,0}));
3868    connect(wheel.flangeR, idealGear.flange_b)
3869      annotation (Line(points={{28,52},{22,52}}));
3870    connect(PSD.ring, mot.flange_a)
3871      annotation (Line(points={{-40,52},{-34,52},{-28,52}}));
3872    connect(idealGear.flange_a, mot.flange_b)
3873      annotation (Line(points={{2,52},{-4,52},{-4,52.2},{-8,52.2}}));
3874    connect(mot.pin_p, bat.p) annotation (Line(points={{-22,42.2},{-22,10},{-23.75,
3875            10}}, color={0,0,255}));
3876    connect(mot.pin_n, bat.n) annotation (Line(points={{-14,42},{-14,10.1},{-8.5,
3877            10.1}}, color={0,0,255}));
3878    connect(mot.conn1, ECU.conn1) annotation (Line(
3879        points={{-27.2,59.8},{-27.2,76},{50,76},{50,-20},{-10,-20},{-10,-32.18}},
3880
3881        color={255,204,51},
3882        thickness=0.5));
3883
3884    connect(bat.conn, ECU.conn1) annotation (Line(
3885        points={{-15.75,-10},{-16,-10},{-16,-20},{-10,-20},{-10,-32.18}},
3886        color={255,204,51},
3887        thickness=0.5));
3888    connect(ice.conn, ECU.conn1) annotation (Line(
3889        points={{-88,46.2},{-88,46.2},{-88,-20},{-10,-20},{-10,-32.18}},
3890        color={255,204,51},
3891        thickness=0.5));
3892    connect(ECU.conn1, d) annotation (Line(
3893        points={{-10,-32.18},{-10,-28},{15,-28}},
3894        color={255,204,51},
3895        thickness=0.5));
3896    connect(carVel.v, driver.V) annotation (Line(points={{78,-23},{78,-58},{-48,
3897            -58},{-48,-51.2}}, color={0,0,127}));
3898    der(EbatDel) = (bat.p.v - bat.n.v)*bat.n.i;
3899    der(EgenDelM) = gen.pin_p.i*(gen.pin_p.v - gen.pin_n.v) + gen.flange_a.tau*
3900      der(gen.flange_a.phi);
3901    der(Eroad) = dragForce.flange.f*der(dragForce.flange.s);
3902    der(EiceDel) = -ice.flange_a.tau*der(ice.flange_a.phi);
3903    der(Emot) = mot.flange_a.tau*der(mot.flange_a.phi) + mot.flange_b.tau*der(
3904      mot.flange_b.phi);
3905    Emass = 0.5*mass.m*der(mass.flange_a.s)^2;
3906    connect(PSD.carrier, ice.flange_a) annotation (Line(
3907        points={{-60,56},{-70,56},{-70,56},{-78,56}},
3908        color={0,0,0},
3909        smooth=Smooth.None));
3910    connect(dragForce.flange, mass.flange_b) annotation (Line(
3911        points={{89,38},{90,38},{90,52},{74,52}},
3912        color={0,127,0},
3913        smooth=Smooth.None));
3914    connect(carVel.flange, mass.flange_b) annotation (Line(
3915        points={{78,-2},{78,52},{74,52}},
3916        color={0,127,0},
3917        smooth=Smooth.None));
3918    connect(ECU.tauReference, driver.tauRef) annotation (Line(points={{-22,-41},
3919            {-29,-41},{-29,-40},{-37,-40}}, color={0,0,127}));
3920    annotation (
3921      __Dymola_experimentSetupOutput,
3922      Documentation(info="<html>
3923<p>This model tries to make the ICE to operate at the highest possible torque since this corresponds to the best fuel consumption given the delivered power. </p>
3924<p>This has two main inconveniences:</p>
3925<ul>
3926<li>the battery SOC is not controlled and tends to drift</li>
3927<li>in urban environment the power is too low to allow efficient drive without shutting off the engine.</li>
3928</ul>
3929<p>Both these inconveniencess are addressed in podel PSecu2.</p>
3930</html>"),
3931      Diagram(coordinateSystem(
3932          extent={{-100,-60},{100,80}},
3933          preserveAspectRatio=false,
3934          initialScale=0.1,
3935          grid={2,2})),
3936      Icon(coordinateSystem(
3937          extent={{-100,-100},{100,100}},
3938          preserveAspectRatio=false,
3939          initialScale=0.1,
3940          grid={2,2})),
3941      experiment(
3942        StartTime=0,
3943        StopTime=1400,
3944        Tolerance=0.0001,
3945        Interval=2.8));
3946  end FullModel;
3947  annotation (
3948    uses(Modelica(version="3.2.2"), Complex(version="3.2.2")),
3949    Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
3950            100}}), graphics={
3951        Polygon(
3952          points={{-60,16},{78,16},{94,0},{96,-16},{-98,-16},{-90,0},{-76,12},{
3953              -60,16}},
3954          lineColor={0,0,0},
3955          smooth=Smooth.None,
3956          fillColor={0,0,255},
3957          fillPattern=FillPattern.Solid),
3958        Ellipse(
3959          extent={{-70,-4},{-30,-40}},
3960          lineColor={95,95,95},
3961          fillColor={95,95,95},
3962          fillPattern=FillPattern.Solid),
3963        Ellipse(
3964          extent={{34,-6},{74,-42}},
3965          lineColor={95,95,95},
3966          fillColor={95,95,95},
3967          fillPattern=FillPattern.Solid),
3968        Polygon(
3969          points={{-54,16},{-18,46},{46,46},{74,16},{-54,16}},
3970          lineColor={0,0,0},
3971          smooth=Smooth.None,
3972          fillColor={0,0,255},
3973          fillPattern=FillPattern.Solid),
3974        Ellipse(
3975          extent={{-86,-6},{-92,4}},
3976          lineColor={0,0,0},
3977          fillColor={255,255,0},
3978          fillPattern=FillPattern.Solid),
3979        Ellipse(
3980          extent={{98,-10},{92,-4}},
3981          lineColor={0,0,0},
3982          fillColor={255,0,0},
3983          fillPattern=FillPattern.Solid),
3984        Polygon(
3985          points={{-46,20},{-20,42},{16,42},{14,20},{-46,20}},
3986          lineColor={0,0,0},
3987          smooth=Smooth.None,
3988          fillColor={255,255,255},
3989          fillPattern=FillPattern.Solid),
3990        Polygon(
3991          points={{22,42},{42,42},{60,20},{20,20},{22,42}},
3992          lineColor={0,0,0},
3993          smooth=Smooth.None,
3994          fillColor={255,255,255},
3995          fillPattern=FillPattern.Solid),
3996        Ellipse(
3997          extent={{-60,-12},{-40,-30}},
3998          lineColor={95,95,95},
3999          fillColor={215,215,215},
4000          fillPattern=FillPattern.Solid),
4001        Ellipse(
4002          extent={{44,-14},{64,-32}},
4003          lineColor={95,95,95},
4004          fillColor={215,215,215},
4005          fillPattern=FillPattern.Solid)}),
4006    Documentation(info="<html>
4007<p>Library containing models of components, subsystems and full vehicle examples for simulation of electric and Hybrid vehicular power trains.</p>
4008<p>A general description of the library composition and on how to use it effectively is in the compaion paper:</p>
4009<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>
4010</html>"));
4011end Test35s;