Ticket #2162: STBug.mo

File STBug.mo, 83.3 KB (added by ceraolo, 11 years ago)
Line 
1within ;
2encapsulated package simpleTrain
3  import Modelica;
4  import prova;
5  import Tesi;
6  import simpleTrain1;
7  import simpleTrain_11;
8
9  model VhDragForce "Vehicle rolling and aerodinamical drag force"
10    import Modelica.Constants.g_n "standard earth acceleration";
11
12    extends
13      Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2;
14    extends Modelica.Mechanics.Translational.Interfaces.PartialFriction;
15
16    Modelica.SIunits.Force f "Total drag force";
17    Modelica.SIunits.Velocity v "vehicle velocity";
18    Modelica.SIunits.Acceleration a "Absolute acceleration of flange";
19    Real Sign;
20    parameter Modelica.SIunits.Mass m "vehicle mass";
21    parameter Modelica.SIunits.Density rho(start=1.226) "air density";
22    parameter Modelica.SIunits.Area S "vehicle cross area";
23    parameter Real fc(start=0.01) "rolling friction coefficient";
24    parameter Real Cx "aerodinamic drag coefficient";
25
26  protected
27    parameter Real A=fc*m*g_n;
28    parameter Real B=(1/2)*rho*S*Cx;
29
30    // Constant auxiliary variable
31  equation
32    //  s = flange.s;
33    v = der(s);
34    a = der(v);
35
36    // Le seguenti definizioni seguono l'ordine e le ridchieste del modello "PartialFriction" di
37    // Modelica.Mechanics.Translational.Interfaces"
38    v_relfric = v;
39    a_relfric = a;
40    f0 = A "forza a velocità 0 ma con scorrimento";
41    f0_max = A "massima forza  velocità 0 e senza scorrimento ";
42    free = false "sarebbe true quando la ruota si stacca dalla strada";
43
44    // Ora il calcolo di f, e la sua attribuzione alla flangia:
45    flange.f - f = 0;
46    // friction force
47    if v > 0 then
48      Sign = 1;
49    else
50      Sign = -1;
51    end if;
52    f - B*v^2*Sign = if locked then sa*unitForce else f0*(if startForward then
53      Modelica.Math.tempInterpol1(
54        v,
55        [0, 1],
56        2) else if startBackward then -Modelica.Math.tempInterpol1(
57        -v,
58        [0, 1],
59        2) else if pre(mode) == Forward then Modelica.Math.tempInterpol1(
60        v,
61        [0, 1],
62        2) else -Modelica.Math.tempInterpol1(
63        -v,
64        [0, 1],
65        2));
66    annotation (
67      Documentation(info="<html>
68<p>This component modesl the total (rolling &egrave;+ aerrodynamic vehicle drag resistance: </p>
69<p>f=mgh+(1/2)*rho*Cx*S*v^2</p>
70<p>It models reliably the stuck phase. based on Modelica-Intrerfaces.PartialFriction model</p>
71</html>"),
72      Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
73              100}}), graphics={
74          Polygon(
75            points={{-98,10},{22,10},{22,41},{92,0},{22,-41},{22,-10},{-98,-10},
76                {-98,10}},
77            lineColor={0,127,0},
78            fillColor={215,215,215},
79            fillPattern=FillPattern.Solid),
80          Line(points={{-42,-50},{87,-50}}, color={0,0,0}),
81          Polygon(
82            points={{-72,-50},{-41,-40},{-41,-60},{-72,-50}},
83            lineColor={0,0,0},
84            fillColor={128,128,128},
85            fillPattern=FillPattern.Solid),
86          Line(
87            points={{-90,-90},{-70,-88},{-50,-82},{-30,-72},{-10,-58},{10,-40},
88                {30,-18},{50,8},{70,38},{90,72},{110,110}},
89            color={0,0,255},
90            thickness=0.5),
91          Text(
92            extent={{-82,90},{80,50}},
93            lineColor={0,0,255},
94            textString="%name")}),
95      Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
96              100,100}}), graphics));
97  end VhDragForce;
98
99
100  block Inverse "Outputs the inverse of (input multiplied by k)"
101    import Modelica.Constants.inf;
102    import Modelica.Constants.eps;
103    Modelica.Blocks.Interfaces.RealInput u annotation (Placement(transformation(
104            extent={{-128,-20},{-88,20}}), iconTransformation(extent={{-128,-18},
105              {-92,18}})));
106    Modelica.Blocks.Interfaces.RealOutput y annotation (Placement(
107          transformation(extent={{98,-10},{118,10}}), iconTransformation(extent
108            ={{96,-10},{116,10}})));
109    parameter Real k;
110  equation
111    if abs(u) < (eps) then
112      y = inf;
113    else
114      y = 1./(k*u);
115    end if;
116    annotation (Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,
117              -100},{100,100}}), graphics), Icon(coordinateSystem(
118            preserveAspectRatio=true, extent={{-100,-100},{100,100}}), graphics
119          ={
120          Rectangle(
121            extent={{-100,100},{100,-100}},
122            lineColor={0,0,127},
123            fillPattern=FillPattern.Solid,
124            fillColor={255,255,255}),
125          Text(
126            extent={{-10,-4},{60,52}},
127            lineColor={0,0,127},
128            textString="1"),
129          Text(
130            extent={{-32,0},{76,-46}},
131            lineColor={0,0,127},
132            textString="k u"),
133          Line(
134            points={{-14,0},{66,0}},
135            color={0,0,127},
136            smooth=Smooth.None),
137          Text(
138            extent={{-86,-30},{-16,26}},
139            lineColor={0,0,127},
140            textString="y=")}));
141  end Inverse;
142
143  model DCLConstP "Constant Power DC Load"
144
145    parameter Real k "inner PI follower proportional gain";
146    parameter Modelica.SIunits.Time T
147      "inner PI follower integral time constant";
148    Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor
149      annotation (Placement(transformation(extent={{-74,52},{-54,72}})));
150    Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation (
151        Placement(transformation(extent={{-110,70},{-90,90}}),
152          iconTransformation(extent={{-20,82},{0,102}})));
153    Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation (
154        Placement(transformation(extent={{-110,-90},{-90,-70}}),
155          iconTransformation(extent={{-20,-100},{0,-80}})));
156    Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent annotation (
157        Placement(transformation(
158          extent={{-10,-10},{10,10}},
159          rotation=270,
160          origin={-4,48})));
161    Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor annotation (
162        Placement(transformation(
163          extent={{-9,-9},{9,9}},
164          rotation=270,
165          origin={-35,45})));
166    Inverse inverse(k=1) annotation (Placement(transformation(
167          extent={{-10,-10},{10,10}},
168          rotation=0,
169          origin={18,74})));
170    Modelica.Blocks.Interfaces.RealInput Pref "Reference power" annotation (
171        Placement(transformation(
172          extent={{-18,-18},{18,18}},
173          rotation=180,
174          origin={118,-20}), iconTransformation(
175          extent={{-18,-18},{18,18}},
176          rotation=0,
177          origin={-94,0})));
178    Modelica.Blocks.Continuous.PI PI(k=k, T=T) annotation (Placement(
179          transformation(
180          extent={{-8,-8},{8,8}},
181          rotation=180,
182          origin={28,-20})));
183    Modelica.Blocks.Math.Feedback feedback1 annotation (Placement(
184          transformation(
185          extent={{-10,-10},{10,10}},
186          rotation=180,
187          origin={64,-20})));
188    Modelica.Blocks.Math.Product product annotation (Placement(transformation(
189          extent={{-8,-8},{8,8}},
190          rotation=180,
191          origin={24,48})));
192    Modelica.SIunits.Voltage v;
193  equation
194    v = pin_p.v - pin_n.v;
195    connect(powerSensor.pc, pin_p) annotation (Line(
196        points={{-74,62},{-18,62},{-18,80},{-100,80}},
197        color={0,0,255},
198        smooth=Smooth.None));
199    connect(powerSensor.pv, powerSensor.pc) annotation (Line(
200        points={{-64,72},{-74,72},{-74,62}},
201        color={0,0,255},
202        smooth=Smooth.None));
203    connect(powerSensor.nc, signalCurrent.p) annotation (Line(
204        points={{-54,62},{-4,62},{-4,58}},
205        color={0,0,255},
206        smooth=Smooth.None));
207    connect(signalCurrent.n, pin_n) annotation (Line(
208        points={{-4,38},{-4,-80},{-100,-80}},
209        color={0,0,255},
210        smooth=Smooth.None));
211    connect(voltageSensor.p, powerSensor.nc) annotation (Line(
212        points={{-35,54},{-35,62},{-54,62}},
213        color={0,0,255},
214        smooth=Smooth.None));
215    connect(voltageSensor.n, signalCurrent.n) annotation (Line(
216        points={{-35,36},{-35,2},{-4,2},{-4,38}},
217        color={0,0,255},
218        smooth=Smooth.None));
219    connect(powerSensor.nv, pin_n) annotation (Line(
220        points={{-64,52},{-64,-80},{-100,-80}},
221        color={0,0,255},
222        smooth=Smooth.None));
223    connect(feedback1.u1, Pref) annotation (Line(
224        points={{72,-20},{118,-20}},
225        color={0,0,127},
226        smooth=Smooth.None));
227    connect(feedback1.u2, powerSensor.power) annotation (Line(
228        points={{64,-12},{64,16},{-72,16},{-72,51}},
229        color={0,0,127},
230        smooth=Smooth.None));
231    connect(feedback1.y, PI.u) annotation (Line(
232        points={{55,-20},{37.6,-20}},
233        color={0,0,127},
234        smooth=Smooth.None));
235    connect(voltageSensor.v, inverse.u) annotation (Line(
236        points={{-44,45},{-46,45},{-46,74},{7,74}},
237        color={0,0,127},
238        smooth=Smooth.None));
239    connect(inverse.y, product.u2) annotation (Line(
240        points={{28.6,74},{48,74},{48,52.8},{33.6,52.8}},
241        color={0,0,127},
242        smooth=Smooth.None));
243    connect(PI.y, product.u1) annotation (Line(
244        points={{19.2,-20},{10,-20},{10,24},{46,24},{46,43.2},{33.6,43.2}},
245        color={0,0,127},
246        smooth=Smooth.None));
247    connect(product.y, signalCurrent.i) annotation (Line(
248        points={{15.2,48},{3,48}},
249        color={0,0,127},
250        smooth=Smooth.None));
251    annotation (
252      Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
253              100,100}}), graphics),
254      Icon(coordinateSystem(preserveAspectRatio=false,extent={{-100,-100},{100,
255              100}}), graphics={
256          Line(
257            points={{-10,86},{-10,-88},{-12,-90}},
258            color={0,0,0},
259            smooth=Smooth.None),
260          Rectangle(
261            extent={{-30,54},{10,-56}},
262            lineColor={0,0,0},
263            fillColor={255,255,255},
264            fillPattern=FillPattern.Solid),
265          Text(
266            extent={{-100,10},{100,-10}},
267            lineColor={0,0,255},
268            textString="%name",
269            origin={24,2},
270            rotation=90),
271          Line(
272            points={{-80,0},{-30,0},{-30,0}},
273            color={0,0,255},
274            smooth=Smooth.None),
275          Text(
276            extent={{-74,14},{-34,2}},
277            lineColor={0,0,255},
278            textString="Potenza")}),
279      Documentation(info="<html>
280<p>Questo componente simula, mediante inseguimento di un riferimento esterno, un carico a potenza costante.</p>
281<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>
282</html>"));
283  end DCLConstP;
284
285  model Sfioratore_di_Tensione
286    "Sfioratore di Tensione: Taglia la potenza di frenatura per mantenere la tensione sulla linea di alimentazione al di sotto del valore massimo Vmax"
287
288    Modelica.Blocks.Interfaces.RealInput Tensione
289      "Tensione della linea di alimentazione DC" annotation (Placement(
290          transformation(
291          extent={{-20,-20},{20,20}},
292          rotation=90,
293          origin={0,100}), iconTransformation(
294          extent={{-20,-20},{20,20}},
295          rotation=90,
296          origin={8,100})));
297    Modelica.Blocks.Interfaces.RealInput Potenza
298      "Potenza da tagliare (eventualmente)" annotation (Placement(
299          transformation(
300          extent={{-20,-20},{20,20}},
301          rotation=270,
302          origin={0,-100}), iconTransformation(
303          extent={{-20,-20},{20,20}},
304          rotation=270,
305          origin={8,-100})));
306    Modelica.Blocks.Interfaces.RealOutput y
307      annotation (Placement(transformation(extent={{100,-10},{120,10}})));
308    parameter Real Vmax=900
309      "Tensione massima sulla linea di alimentazione (+20%Vnom per linee DC) [V]";
310    parameter Real Kcontr=300000
311      "Costante del controllore di tensione puramente proporzionale ";
312    Modelica.Blocks.Continuous.FirstOrder Ritardo(T=0.01)
313      "Ritardo utile per evitare errori della simulazione"
314      annotation (Placement(transformation(extent={{60,-10},{80,10}})));
315  equation
316    if Tensione >= Vmax then
317      Ritardo.u = Potenza - Kcontr*(Vmax - Tensione);
318    else
319      Ritardo.u = Potenza;
320    end if;
321    connect(Ritardo.y, y) annotation (Line(
322        points={{81,0},{110,0}},
323        color={0,0,127},
324        smooth=Smooth.None));
325    annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
326              -100},{100,100}}), graphics={Line(
327              points={{56,0},{40,0},{40,0}},
328              color={0,0,0},
329              smooth=Smooth.None),Rectangle(extent={{-12,6},{40,-6}}, lineColor
330            ={0,0,127}),Text(
331              extent={{-8,4},{36,-4}},
332              lineColor={0,0,127},
333              fillPattern=FillPattern.Solid,
334              textString="Codice Interno")}), Icon(coordinateSystem(
335            preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
336          graphics={
337          Rectangle(extent={{-78,80},{100,-80}}, lineColor={0,0,0}),
338          Line(
339            points={{66,66},{26,10},{26,10}},
340            color={0,0,0},
341            smooth=Smooth.None),
342          Line(
343            points={{66,66},{20,14},{20,14}},
344            color={0,0,0},
345            smooth=Smooth.None),
346          Line(
347            points={{20,14},{44,74},{44,74}},
348            color={0,0,0},
349            smooth=Smooth.None),
350          Line(
351            points={{44,74},{12,16},{12,16}},
352            color={0,0,0},
353            smooth=Smooth.None),
354          Ellipse(extent={{-24,2},{-8,-8}}, lineColor={0,0,0}),
355          Ellipse(extent={{8,-16},{24,-26}}, lineColor={0,0,0}),
356          Line(
357            points={{12,16},{8,-22},{8,-22}},
358            color={0,0,0},
359            smooth=Smooth.None),
360          Line(
361            points={{26,10},{-12,-8},{-12,-8}},
362            color={0,0,0},
363            smooth=Smooth.None),
364          Text(
365            extent={{-70,-36},{98,-78}},
366            lineColor={0,0,0},
367            fillPattern=FillPattern.Solid,
368            textString="Sfioratore"),
369          Text(
370            extent={{30,96},{66,96}},
371            lineColor={0,0,0},
372            fillPattern=FillPattern.Solid,
373            textString="V"),
374          Text(
375            extent={{26,-98},{70,-102}},
376            lineColor={0,0,0},
377            fillPattern=FillPattern.Solid,
378            textString="P")}));
379  end Sfioratore_di_Tensione;
380
381
382
383
384
385
386  model DriverAB_Mod
387    "Controlla la forza di trazione con obiettivi di velocita' e spazio. (Accelerazione-Frenatura)"
388
389    Modelica.StateGraph.InitialStep Accelerazione "Fase di Accelerazione"
390      annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
391    Modelica.StateGraph.TransitionWithSignal Trans_Acc_Fren
392      "Transizione tra Accelerazione e Coasting"
393      annotation (Placement(transformation(extent={{-50,60},{-30,80}})));
394    Modelica.Blocks.Interfaces.RealInput v "Velocità [m/s]" annotation (
395        Placement(transformation(extent={{-140,-60},{-100,-20}}),
396          iconTransformation(extent={{-140,-60},{-100,-20}})));
397    Modelica.Blocks.Interfaces.RealOutput f "Forza di Trazione [N]"
398      annotation (Placement(transformation(extent={{100,-10},{120,10}})));
399    Modelica.Blocks.Interfaces.RealInput s "Spazio [m]" annotation (Placement(
400          transformation(extent={{-140,20},{-100,60}}), iconTransformation(
401            extent={{-140,20},{-100,60}})));
402    parameter Real Stot[:]={797,1464,2023,2375,2815,3237,3750,5173,6268,7251,
403        6268,5173,3750,3237,2815,2375,2023,1464,797,30}
404      "STAZIONI: Array delle ascisse di posizione (Assolute) in cui sono posizionate le varie stazioni [m]";
405    parameter Real Vmax0[:]={70,50,70,70,50,70,30,70,70,70,70,70,70,30,70,50,70,
406        70,50,70}
407      "VELOCITA' MASSIMA: Array delle velocità massime del convoglio nei vari tratti [Km/h]";
408    parameter Real Sfren[:]={697,1364,1923,2275,2715,3137,3650,5073,6168,7151,
409        6368,5273,3850,3337,2915,2475,2123,1564,897,130}
410      "ASCISSE DI FRENATURA: Array delle varie ascisse di frenatura del convoglio nei vari tratti che deve percorrere [m]";
411    parameter Real Pmax=628000 "Potenza massima del Convoglio [W]";
412    parameter Real Fmax=72100
413      "Forza massima di trazione (limite di aderenza) [N]";
414    parameter Real Kcontr=1000000
415      "Costante del controllore puramente proporzionale per la fase di frenatura ";
416    Real Vrif0 "Velocità di riferimento da seguire [m/s]";
417    Real Vrif
418      "Correzione di Vrif0 in modo che Vrif0 sia sempre maggiore o uguale a zero [m/s]";
419    Real f0 "Forza di trazione fornita dal controllore [N]";
420    Real f1
421      "Forza di trazione corretta per tenere di conto della limitazione di forza di trazione [N]";
422    Integer i "Indice per aggiornare Stot e Sfren via via che il treno avanza";
423    Modelica.Blocks.Logical.GreaterEqual Mag_Ug
424      annotation (Placement(transformation(extent={{-60,6},{-50,16}})));
425    Modelica.Blocks.Sources.RealExpression Ascissa_Frenatura(y=Sfren[i])
426      annotation (Placement(transformation(
427          extent={{-9,-8},{9,8}},
428          rotation=90,
429          origin={-83,-16})));
430
431    Modelica.StateGraph.TransitionWithSignal Trans_Ferm_Acc
432      "Transizione tra Accelerazione e Coasting"
433      annotation (Placement(transformation(extent={{70,60},{90,80}})));
434    Modelica.StateGraph.StepWithSignal Fermata
435      annotation (Placement(transformation(extent={{40,60},{60,80}})));
436    parameter Integer Seme_Partenza=50000
437      "Seme di partenza per la creazione di una sequenza di numeri random con il metodo del generatore random lineare congruenziale LCG";
438    parameter Real Gain=120
439      "Costante moltiplicativa (legata al tempo di fermata massimo) in quanto il numero random generato (x) è compreso tra 0 e 1";
440
441    Modelica.Blocks.Logical.LessEqual Min_Ug
442      annotation (Placement(transformation(extent={{-58,-16},{-48,-6}})));
443    Modelica.Blocks.Logical.LogicalSwitch Switch annotation (Placement(
444          transformation(
445          extent={{-6,-8},{6,8}},
446          rotation=90,
447          origin={-40,44})));
448    Modelica.Blocks.Sources.BooleanExpression Cond_Frenatura(y=vel) annotation
449      (Placement(transformation(
450          extent={{-5,-8},{5,8}},
451          rotation=90,
452          origin={-40,23})));
453    Boolean vel
454      "Parametro boolean per capire se la velocità durante la marcia è positiva (il conv. procede da sx. a dx.) o negativa (il conv. procede da dx. a sx.)";
455
456    Modelica.Blocks.Logical.LessEqualThreshold lessEqualThreshold
457      annotation (Placement(transformation(extent={{-58,-44},{-48,-34}})));
458    Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqualThreshold(
459        threshold=0)
460      annotation (Placement(transformation(extent={{-58,-70},{-48,-60}})));
461    Modelica.StateGraph.Step Frenatura
462      annotation (Placement(transformation(extent={{-20,60},{0,80}})));
463    Modelica.StateGraph.TransitionWithSignal Trans_Fren_Ferm
464      annotation (Placement(transformation(extent={{10,60},{30,80}})));
465    Modelica.Blocks.Logical.LogicalSwitch Switch1 annotation (Placement(
466          transformation(
467          extent={{-5,-6},{5,6}},
468          rotation=0,
469          origin={1,-54})));
470    Modelica.Blocks.Sources.BooleanExpression Condiz_Fermata(y=vel)
471      annotation (Placement(transformation(extent={{-36,-64},{-18,-44}})));
472    Real Vf_neg
473      "Campionamento della velocità nell'istante di frenatura nel caso di velocità negative [m/s]";
474    Real Vf_pos
475      "Campionamento della velocità nell'istante di frenatura nel caso di velocità positive [m/s]";
476    Real Sf_neg
477      "Campionamento della posizione nell'istante di frenatura nel caso di velocità negative [m]";
478    Real Sf_pos
479      "Campionamento della posizione nell'istante di frenatura nel caso di velocità positive [m]";
480    Real Tempof_neg
481      "Campionamento del tempo trascorso nell'istante di frenatura nel caso di velocità negative [s]";
482    Real Tempof_pos
483      "Campionamento del tempo trascorso nell'istante di frenatura nel caso di velocità positive [s]";
484    Real Vmax[size(Vmax0, 1)]
485      "Array delle velocità massima del convoglio in m/s";
486  initial equation
487    i = 1;
488    vel = true;
489  equation
490    //Trasformazione di Vmax da km/h in m/s:
491    for i in 1:size(Vmax0, 1) loop
492      Vmax[i] = Vmax0[i]/3.6;
493    end for;
494    if vel then
495      // SIAMO NEL CASO DI VELOCITA' POSITIVE (OSSIA IL CONVOGLIO VA DA SX A DX):
496      //Fase di Accelerazione:
497      if Accelerazione.active then
498        //f0 deriva dal controllo della velocità di tipo solo proporzionale:
499        f0 = Kcontr*(Vmax[i] - v);
500        //f1 altera f0 per considerare le limitazioni di forza:
501        f1 = if f0 > Fmax then Fmax else f0;
502        //f altera f0 per considerare le limitazioni di potenza:
503        f = if f1*v > Pmax then Pmax/v else f1;
504        Vrif0 = 0;
505        Vrif = 0;
506        //Fase di Frenatura:
507      elseif Frenatura.active then
508        Vrif0 = Vf_pos - Vf_pos^2/(2*(Stot[i] - Sf_pos))*(time - Tempof_pos);
509        Vrif = if Vrif0 > 0 then Vrif0 else 0;
510        f0 = Kcontr*(Vrif - v);
511        // f1 altera f0 per considerare le limitazioni di forza:
512        f1 = if f0 < -Fmax then -Fmax else f0;
513        //f altera f0 per considerare le limitazioni di potenza:
514        f = if f1*v < -Pmax then -Pmax/v else f1;
515        //Fase di Fermata in stazione:
516      else
517        f = 0;
518        Vrif0 = 0;
519        Vrif = 0;
520        f1 = 0;
521        f0 = 0;
522      end if;
523
524    else
525      // SIAMO NEL CASO DI VELOCITA' NEGATIVE (OSSIA IL CONVOGLIO VA DA DX A SX):
526      //Fase di Accelerazione:
527      if Accelerazione.active then
528        //f0 deriva dal controllo della velocità di tipo solo proporzionale:
529        f0 = Kcontr*(-Vmax[i] - v);
530        //f1 altera f0 per considerare le limitazioni di forza:
531        f1 = if f0 < -Fmax then -Fmax else f0;
532        //f altera f0 per considerare le limitazioni di potenza:
533        f = if f1*v > Pmax then Pmax/v else f1;
534        Vrif0 = 0;
535        Vrif = 0;
536        //Fase di Frenatura:
537      elseif Frenatura.active then
538        Vrif0 = Vf_neg - Vf_neg^2/(2*(Stot[i] - Sf_neg))*(time - Tempof_neg);
539        Vrif = if Vrif0 < 0 then Vrif0 else 0;
540        f0 = Kcontr*(Vrif - v);
541        // f1 altera f0 per considerare le limitazioni di forza:
542        f1 = if f0 > Fmax then Fmax else f0;
543        //f altera f0 per considerare le limitazioni di potenza:
544        f = if f1*v < -Pmax then -Pmax/v else f1;
545        //Fase di Fermata in stazione:
546      else
547        f = 0;
548        Vrif0 = 0;
549        Vrif = 0;
550        f1 = 0;
551        f0 = 0;
552      end if;
553    end if;
554    //PER VELOCITA' POSITIVE: Campionamento dei parametri per il calcolo della retta di frenatura (il campionamento avviene quando s>=Sfren "attuale"):
555    when Mag_Ug.y then
556      Sf_pos = s;
557      Vf_pos = v;
558      Tempof_pos = time;
559    end when;
560    //PER VELOCITA' NEGATIVE: Campionamento dei parametri per il calcolo della retta di frenatura (il campionamento avviene quando s<=Sfren "attuale"):
561    when Min_Ug.y then
562      Sf_neg = s;
563      Vf_neg = v;
564      Tempof_neg = time;
565    end when;
566    //Incrementazione del contatore e variazione della variabile che considera se la prossima tratta sarà a velocità positiva o negativa (Per variare in modo opportuno la condizione di transizione Trans_Acc_Fren):
567    when Fermata.active then
568      i = pre(i) + 1;
569      vel = if Stot[i] >= s then true else false;
570    end when;
571
572    connect(Accelerazione.outPort[1], Trans_Acc_Fren.inPort) annotation (Line(
573        points={{-59.5,70},{-44,70}},
574        color={0,0,0},
575        smooth=Smooth.None));
576    connect(Fermata.outPort[1], Trans_Ferm_Acc.inPort) annotation (Line(
577        points={{60.5,70},{76,70}},
578        color={0,0,0},
579        smooth=Smooth.None));
580    connect(Trans_Ferm_Acc.outPort, Accelerazione.inPort[1]) annotation (Line(
581        points={{81.5,70},{96,70},{96,94},{-92,94},{-92,70},{-81,70}},
582        color={0,0,0},
583        smooth=Smooth.None));
584    connect(f, f) annotation (Line(
585        points={{110,0},{110,0}},
586        color={0,0,127},
587        smooth=Smooth.None));
588    connect(Trans_Acc_Fren.outPort, Frenatura.inPort[1]) annotation (Line(
589        points={{-38.5,70},{-21,70}},
590        color={0,0,0},
591        smooth=Smooth.None));
592    connect(Frenatura.outPort[1], Trans_Fren_Ferm.inPort) annotation (Line(
593        points={{0.5,70},{16,70}},
594        color={0,0,0},
595        smooth=Smooth.None));
596    connect(Trans_Fren_Ferm.outPort, Fermata.inPort[1]) annotation (Line(
597        points={{21.5,70},{39,70}},
598        color={0,0,0},
599        smooth=Smooth.None));
600    connect(s, Mag_Ug.u1) annotation (Line(
601        points={{-120,40},{-68,40},{-68,11},{-61,11}},
602        color={0,0,127},
603        smooth=Smooth.None));
604    connect(Min_Ug.u1, Mag_Ug.u1) annotation (Line(
605        points={{-59,-11},{-68,-11},{-68,11},{-61,11}},
606        color={0,0,127},
607        smooth=Smooth.None));
608    connect(Mag_Ug.u2, Ascissa_Frenatura.y) annotation (Line(
609        points={{-61,7},{-83,7},{-83,-6.1}},
610        color={0,0,127},
611        smooth=Smooth.None));
612    connect(Min_Ug.u2, Ascissa_Frenatura.y) annotation (Line(
613        points={{-59,-15},{-74,-15},{-74,-2},{-83,-2},{-83,-6.1}},
614        color={0,0,127},
615        smooth=Smooth.None));
616    connect(Switch.y, Trans_Acc_Fren.condition) annotation (Line(
617        points={{-40,50.6},{-40,58}},
618        color={255,0,255},
619        smooth=Smooth.None));
620    connect(Switch.u2, Cond_Frenatura.y) annotation (Line(
621        points={{-40,36.8},{-40,28.5}},
622        color={255,0,255},
623        smooth=Smooth.None));
624    connect(Mag_Ug.y, Switch.u1) annotation (Line(
625        points={{-49.5,11},{-46.4,11},{-46.4,36.8}},
626        color={255,0,255},
627        smooth=Smooth.None));
628    connect(Min_Ug.y, Switch.u3) annotation (Line(
629        points={{-47.5,-11},{-33.6,-11},{-33.6,36.8}},
630        color={255,0,255},
631        smooth=Smooth.None));
632    connect(Condiz_Fermata.y, Switch1.u2) annotation (Line(
633        points={{-17.1,-54},{-5,-54}},
634        color={255,0,255},
635        smooth=Smooth.None));
636    connect(Switch1.u1, lessEqualThreshold.y) annotation (Line(
637        points={{-5,-49.2},{-12,-49.2},{-12,-39},{-47.5,-39}},
638        color={255,0,255},
639        smooth=Smooth.None));
640    connect(Switch1.u3, greaterEqualThreshold.y) annotation (Line(
641        points={{-5,-58.8},{-12,-58.8},{-12,-65},{-47.5,-65}},
642        color={255,0,255},
643        smooth=Smooth.None));
644    connect(Switch1.y, Trans_Fren_Ferm.condition) annotation (Line(
645        points={{6.5,-54},{20,-54},{20,58}},
646        color={255,0,255},
647        smooth=Smooth.None));
648    connect(lessEqualThreshold.u, v) annotation (Line(
649        points={{-59,-39},{-82.5,-39},{-82.5,-40},{-120,-40}},
650        color={0,0,127},
651        smooth=Smooth.None));
652    connect(greaterEqualThreshold.u, v) annotation (Line(
653        points={{-59,-65},{-82,-65},{-82,-40},{-120,-40}},
654        color={0,0,127},
655        smooth=Smooth.None));
656    connect(Fermata.active, Trans_Ferm_Acc.condition) annotation (Line(
657        points={{50,59},{50,44},{80,44},{80,58}},
658        color={255,0,255},
659        smooth=Smooth.None));
660    annotation (
661      Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{
662              100,100}}), graphics={
663          Line(
664            points={{88,0},{100,0},{100,-2}},
665            color={0,0,0},
666            smooth=Smooth.None),
667          Rectangle(extent={{88,6},{52,-6}}, lineColor={0,0,0}),
668          Text(
669            extent={{54,6},{88,-6}},
670            lineColor={0,0,0},
671            textString="Codice Interno")}),
672      Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
673              100}}), graphics={
674          Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}),
675          Text(
676            extent={{-60,-52},{56,-102}},
677            lineColor={0,0,0},
678            fillColor={0,0,0},
679            fillPattern=FillPattern.Solid,
680            textString="A-F"),
681          Text(
682            extent={{-188,84},{-126,70}},
683            lineColor={0,0,0},
684            fillColor={0,127,0},
685            fillPattern=FillPattern.Solid,
686            textString="Pos."),
687          Text(
688            extent={{-182,-70},{-128,-86}},
689            lineColor={0,0,0},
690            fillColor={0,127,0},
691            fillPattern=FillPattern.Solid,
692            textString="Vel."),
693          Text(
694            extent={{94,36},{134,10}},
695            lineColor={0,0,0},
696            fillColor={0,0,0},
697            fillPattern=FillPattern.Solid,
698            textString="F"),
699          Polygon(
700            points={{-28,-20},{-48,-48},{-22,-48},{10,-48},{-28,-20}},
701            smooth=Smooth.None,
702            fillColor={215,215,215},
703            fillPattern=FillPattern.Solid,
704            pattern=LinePattern.None,
705            lineColor={0,0,0}),
706          Polygon(
707            points={{-38,80},{-68,-12},{-36,-12},{-36,-12},{-38,80}},
708            smooth=Smooth.Bezier,
709            fillColor={135,135,135},
710            fillPattern=FillPattern.Solid,
711            pattern=LinePattern.None,
712            lineColor={0,0,0}),
713          Polygon(
714            points={{-74,4},{-20,-50},{4,-10},{-6,-10},{-74,4}},
715            smooth=Smooth.Bezier,
716            fillColor={135,135,135},
717            fillPattern=FillPattern.Solid,
718            pattern=LinePattern.None,
719            lineColor={0,0,0}),
720          Polygon(
721            points={{-28,74},{-46,-8},{-4,-6},{0,4},{2,10},{-28,74}},
722            smooth=Smooth.Bezier,
723            fillColor={0,171,0},
724            fillPattern=FillPattern.Solid,
725            pattern=LinePattern.None,
726            lineColor={0,0,0}),
727          Ellipse(
728            extent={{-38,80},{-8,52}},
729            fillColor={255,213,170},
730            fillPattern=FillPattern.Solid,
731            startAngle=0,
732            endAngle=360,
733            pattern=LinePattern.None),
734          Ellipse(
735            extent={{-16,70},{-14,72}},
736            lineColor={0,0,0},
737            fillColor={0,0,0},
738            fillPattern=FillPattern.Solid),
739          Polygon(
740            points={{-14,60},{-20,60},{-20,58},{-14,60}},
741            smooth=Smooth.Bezier,
742            fillColor={255,0,0},
743            fillPattern=FillPattern.Solid,
744            pattern=LinePattern.None),
745          Polygon(
746            points={{-46,76},{-24,92},{-10,78},{-4,78},{-2,78},{-46,76}},
747            smooth=Smooth.Bezier,
748            fillColor={0,0,127},
749            fillPattern=FillPattern.Solid,
750            pattern=LinePattern.None,
751            lineColor={0,0,0}),
752          Polygon(
753            points={{44,-54},{12,0},{2,-4},{-6,-10},{44,-54}},
754            smooth=Smooth.Bezier,
755            fillColor={0,0,127},
756            fillPattern=FillPattern.Solid,
757            pattern=LinePattern.None,
758            lineColor={0,0,0}),
759          Polygon(
760            points={{24,-4},{-38,12},{-42,-4},{-30,-18},{24,-4}},
761            smooth=Smooth.Bezier,
762            fillColor={0,0,127},
763            fillPattern=FillPattern.Solid,
764            pattern=LinePattern.None,
765            lineColor={0,0,0}),
766          Polygon(
767            points={{36,-30},{30,-44},{42,-38},{46,-32},{44,-28},{36,-30}},
768            lineColor={0,0,0},
769            smooth=Smooth.Bezier,
770            fillColor={0,0,0},
771            fillPattern=FillPattern.Solid),
772          Rectangle(
773            extent={{68,-50},{66,36}},
774            lineColor={0,0,0},
775            fillColor={0,0,0},
776            fillPattern=FillPattern.Solid,
777            radius=20),
778          Line(
779            points={{42,26},{20,40},{20,40}},
780            color={0,0,0},
781            thickness=0.5,
782            smooth=Smooth.None),
783          Line(
784            points={{14,30},{28,50},{28,50}},
785            color={0,0,0},
786            thickness=0.5,
787            smooth=Smooth.None),
788          Polygon(
789            points={{22,44},{26,48},{22,42},{28,46},{24,42},{28,44},{24,40},{20,
790                42},{28,40},{20,40},{20,42},{22,44},{22,44},{20,42},{20,42},{20,
791                42},{22,48},{22,46},{22,44}},
792            smooth=Smooth.Bezier,
793            fillColor={255,213,170},
794            fillPattern=FillPattern.Solid,
795            pattern=LinePattern.None),
796          Polygon(
797            points={{-24,40},{22,46},{20,38},{-22,24},{-26,24},{-30,34},{-24,40}},
798
799            smooth=Smooth.Bezier,
800            fillColor={0,171,0},
801            fillPattern=FillPattern.Solid,
802            pattern=LinePattern.None,
803            lineColor={0,0,0}),
804          Polygon(
805            points={{66,34},{42,34},{30,14},{66,-50},{66,-50},{66,34}},
806            lineColor={0,0,0},
807            smooth=Smooth.None,
808            fillColor={215,215,215},
809            fillPattern=FillPattern.Solid),
810          Rectangle(
811            extent={{50,-28},{48,-50}},
812            lineColor={0,0,0},
813            fillColor={0,0,0},
814            fillPattern=FillPattern.Solid,
815            radius=30),
816          Polygon(
817            points={{-10,70},{-4,68},{-10,66},{-10,66},{-10,70}},
818            smooth=Smooth.Bezier,
819            fillColor={255,213,170},
820            fillPattern=FillPattern.Solid,
821            pattern=LinePattern.None),
822          Rectangle(
823            extent={{-70,-50},{68,-48}},
824            lineColor={0,0,0},
825            fillColor={0,0,0},
826            fillPattern=FillPattern.Solid,
827            radius=20)}),
828      experiment(StopTime=500, __Dymola_NumberOfIntervals=2000),
829      __Dymola_experimentSetupOutput);
830  end DriverAB_Mod;
831
832
833
834
835
836
837  model Sottostazione_SSE "Modello della Sottostazione Elettrica (SSE)"
838
839    Modelica.Electrical.Analog.Basic.Resistor Res_Fittizia(R=R_Fitt)
840      "Resistenza fittizia che tiene conto dell'abbassamento del valore medio di tensione a causa delle induttanze a monte [Ohm]"
841      annotation (Placement(transformation(
842          extent={{-10,-10},{10,10}},
843          rotation=270,
844          origin={40,-44})));
845    Modelica.Electrical.Analog.Ideal.IdealDiode D_SSE
846      "Diodo per garantire la non inversione della corrente" annotation (
847        Placement(transformation(
848          extent={{-10,-10},{10,10}},
849          rotation=270,
850          origin={40,-74})));
851    Modelica.Electrical.Analog.Sources.ConstantVoltage Vn_SSE(V=V_Nom)
852      "Tensione nominale della SSE [V]" annotation (Placement(transformation(
853          extent={{-10,-10},{10,10}},
854          rotation=90,
855          origin={40,-16})));
856    parameter Real V_Nom=750
857      "Tensione Nominale della Sottostazione Elettrica [V]";
858    parameter Real R_Fitt=0.01267
859      "Resistenza fittizia che modellizza l'abbassamento del valore medio di tensione a causa delle induttanze a monte [Ohm]";
860    Modelica.Electrical.Analog.Interfaces.PositivePin pin_p
861      annotation (Placement(transformation(extent={{-30,-110},{-10,-90}})));
862    Modelica.Electrical.Analog.Interfaces.NegativePin pin_n
863      annotation (Placement(transformation(extent={{90,-110},{110,-90}})));
864  equation
865    connect(D_SSE.p, Res_Fittizia.n) annotation (Line(
866        points={{40,-64},{40,-54}},
867        color={0,0,255},
868        smooth=Smooth.None));
869    connect(Res_Fittizia.p, Vn_SSE.p) annotation (Line(
870        points={{40,-34},{40,-26}},
871        color={0,0,255},
872        smooth=Smooth.None));
873    connect(Vn_SSE.n, pin_n) annotation (Line(
874        points={{40,-6},{40,0},{100,0},{100,-100}},
875        color={0,0,255},
876        smooth=Smooth.None));
877    connect(D_SSE.n, pin_p) annotation (Line(
878        points={{40,-84},{-20,-84},{-20,-100}},
879        color={0,0,255},
880        smooth=Smooth.None));
881    annotation (Diagram(coordinateSystem(extent={{-60,-100},{140,100}},
882            preserveAspectRatio=false), graphics), Icon(coordinateSystem(extent
883            ={{-60,-100},{140,100}},preserveAspectRatio=false), graphics={
884          Rectangle(extent={{-60,100},{140,-100}}, lineColor={0,0,0}),
885          Rectangle(extent={{-14,38},{88,-62}}, lineColor={0,0,0}),
886          Line(
887            points={{40,16},{12,-42},{68,-42},{40,16},{40,16}},
888            color={0,0,0},
889            smooth=Smooth.None),
890          Line(
891            points={{40,16},{40,22},{40,24}},
892            color={0,0,0},
893            smooth=Smooth.None),
894          Line(
895            points={{40,-42},{40,-48},{40,-50}},
896            color={0,0,0},
897            smooth=Smooth.None),
898          Line(
899            points={{0,48},{0,38},{0,38}},
900            color={0,0,0},
901            smooth=Smooth.None),
902          Line(
903            points={{20,-62},{20,-80},{-20,-80},{-20,-92},{-20,-92}},
904            color={0,0,0},
905            smooth=Smooth.None),
906          Line(
907            points={{60,-62},{60,-80},{100,-80},{100,-90},{102,-96},{102,-96}},
908
909            color={0,0,0},
910            smooth=Smooth.None),
911          Ellipse(extent={{-4,56},{4,48}}, lineColor={0,0,0}),
912          Line(
913            points={{40,48},{40,38},{40,38}},
914            color={0,0,0},
915            smooth=Smooth.None),
916          Ellipse(extent={{36,56},{44,48}}, lineColor={0,0,0}),
917          Line(
918            points={{80,48},{80,38},{80,38}},
919            color={0,0,0},
920            smooth=Smooth.None),
921          Ellipse(extent={{76,56},{84,48}}, lineColor={0,0,0}),
922          Text(
923            extent={{-52,106},{134,56}},
924            lineColor={0,0,0},
925            fillPattern=FillPattern.Solid,
926            textString="%name"),
927          Line(
928            points={{16,16},{62,16},{64,16}},
929            color={0,0,0},
930            smooth=Smooth.None),
931          Ellipse(
932            extent={{-44,-78},{-38,-84}},
933            lineColor={0,0,0},
934            fillPattern=FillPattern.Solid)}));
935  end Sottostazione_SSE;
936
937  model Convoglio "Modello del convoglio tramviario"
938
939    Modelica.Mechanics.Translational.Components.Mass mass(m=vMass)
940      annotation (Placement(transformation(extent={{-2,-16},{18,4}})));
941    Modelica.Mechanics.Translational.Sensors.PowerSensor mP2
942      "Misuratore della Potenza resistente" annotation (Placement(
943          transformation(
944          extent={{-10,-10},{10,10}},
945          rotation=0,
946          origin={60,-6})));
947    VhDragForce dragF(
948      m=vMass,
949      Cx=0.65,
950      rho=1.226,
951      S=6.0,
952      fc=0.013) annotation (Placement(transformation(
953          extent={{-10,-10},{10,10}},
954          rotation=90,
955          origin={82,-16})));
956    Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor
957      annotation (Placement(transformation(
958          extent={{-10,-10},{10,10}},
959          rotation=270,
960          origin={28,32})));
961    Modelica.Mechanics.Translational.Sources.Force Force annotation (Placement(
962          transformation(
963          extent={{-10,-10},{10,10}},
964          rotation=0,
965          origin={-70,-6})));
966    Modelica.Mechanics.Translational.Sensors.PowerSensor mP1
967      "Misuratore della potenza trasmessa/erogata al/dal treno" annotation (
968        Placement(transformation(
969          extent={{-10,-10},{10,10}},
970          rotation=0,
971          origin={-20,-6})));
972    Modelica.Mechanics.Translational.Sensors.SpeedSensor speedSensor
973      annotation (Placement(transformation(
974          extent={{-10,-10},{10,10}},
975          rotation=90,
976          origin={28,-36})));
977    Modelica.Electrical.Analog.Sensors.PotentialSensor Vmis annotation (
978        Placement(transformation(
979          extent={{-9,-9},{9,9}},
980          rotation=270,
981          origin={-45,43})));
982    Sfioratore_di_Tensione sfioratore_di_Tensione
983      annotation (Placement(transformation(extent={{-56,6},{-36,28}})));
984    DCLConstP dCLConstP(k=100, T=0.01)
985      annotation (Placement(transformation(extent={{-10,18},{12,42}})));
986    Modelica.Electrical.Analog.Interfaces.PositivePin pin_p
987      annotation (Placement(transformation(extent={{-10,90},{10,110}})));
988    Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation (
989        Placement(transformation(extent={{94,0},{114,20}}), iconTransformation(
990            extent={{94,-6},{114,14}})));
991    Modelica.Blocks.Interfaces.RealInput Forza
992      "Forza di trazione \"regolata\" dal Driver"
993      annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
994    Modelica.Blocks.Interfaces.RealOutput Posizione
995      "Posizione del convoglio [m]" annotation (Placement(transformation(
996          extent={{-10,-10},{10,10}},
997          rotation=180,
998          origin={-110,60})));
999    Modelica.Blocks.Interfaces.RealOutput Velocita
1000      "Velocità del convoglio [m/s]" annotation (Placement(transformation(
1001          extent={{-10,-10},{10,10}},
1002          rotation=180,
1003          origin={-110,-62})));
1004    parameter Real vMass=60000 "Massa del convoglio tramviario [Kg]";
1005
1006  equation
1007    connect(mP2.flange_a, mass.flange_b) annotation (Line(
1008        points={{50,-6},{18,-6}},
1009        color={0,127,0},
1010        smooth=Smooth.None));
1011    connect(dragF.flange, mP2.flange_b) annotation (Line(
1012        points={{82,-6},{70,-6}},
1013        color={0,127,0},
1014        smooth=Smooth.None));
1015    connect(mP1.flange_b, mass.flange_a) annotation (Line(
1016        points={{-10,-6},{-2,-6}},
1017        color={0,127,0},
1018        smooth=Smooth.None));
1019    connect(speedSensor.flange, mass.flange_b) annotation (Line(
1020        points={{28,-46},{28,-6},{18,-6}},
1021        color={0,127,0},
1022        smooth=Smooth.None));
1023    connect(Vmis.phi, sfioratore_di_Tensione.Tensione) annotation (Line(
1024        points={{-45,33.1},{-45,28},{-45.2,28}},
1025        color={0,0,127},
1026        smooth=Smooth.None));
1027    connect(sfioratore_di_Tensione.Potenza, mP1.power) annotation (Line(
1028        points={{-45.2,6},{-45.2,0},{-28,0},{-28,-17}},
1029        color={0,0,127},
1030        smooth=Smooth.None));
1031    connect(dCLConstP.Pref, sfioratore_di_Tensione.y) annotation (Line(
1032        points={{-9.34,30},{-16,30},{-16,17},{-35,17}},
1033        color={0,0,127},
1034        smooth=Smooth.None));
1035    connect(Force.flange, mP1.flange_a) annotation (Line(
1036        points={{-60,-6},{-30,-6}},
1037        color={0,127,0},
1038        smooth=Smooth.None));
1039    connect(dCLConstP.pin_p, pin_p) annotation (Line(
1040        points={{-0.1,41.04},{-0.1,73.52},{0,73.52},{0,100}},
1041        color={0,0,255},
1042        smooth=Smooth.None));
1043    connect(Vmis.p, dCLConstP.pin_p) annotation (Line(
1044        points={{-45,52},{-0.1,52},{-0.1,41.04}},
1045        color={0,0,255},
1046        smooth=Smooth.None));
1047    connect(dCLConstP.pin_n, pin_n) annotation (Line(
1048        points={{-0.1,19.2},{-0.1,10},{90,10},{90,10},{104,10}},
1049        color={0,0,255},
1050        smooth=Smooth.None));
1051    connect(Forza, Force.f) annotation (Line(
1052        points={{-120,0},{-92,0},{-92,-6},{-82,-6}},
1053        color={0,0,127},
1054        smooth=Smooth.None));
1055    connect(positionSensor.flange, mass.flange_b) annotation (Line(
1056        points={{28,42},{28,-6},{18,-6}},
1057        color={0,127,0},
1058        smooth=Smooth.None));
1059    connect(positionSensor.s, Posizione) annotation (Line(
1060        points={{28,21},{28,60},{-110,60}},
1061        color={0,0,127},
1062        smooth=Smooth.None));
1063    connect(speedSensor.v, Velocita) annotation (Line(
1064        points={{28,-25},{28,-62},{-110,-62}},
1065        color={0,0,127},
1066        smooth=Smooth.None));
1067    annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
1068              -100},{100,100}}), graphics), Icon(coordinateSystem(
1069            preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
1070          graphics={
1071          Text(
1072            extent={{-152,-74},{-100,-94}},
1073            lineColor={0,0,0},
1074            fillPattern=FillPattern.Solid,
1075            textString="Vel."),
1076          Text(
1077            extent={{-132,-16},{-104,-40}},
1078            lineColor={0,0,0},
1079            fillPattern=FillPattern.Solid,
1080            textString="F"),
1081          Polygon(
1082            points={{30,70},{106,28},{34,24},{30,34},{30,70}},
1083            smooth=Smooth.Bezier,
1084            fillPattern=FillPattern.Solid,
1085            fillColor={0,158,0},
1086            pattern=LinePattern.None,
1087            lineColor={0,0,0}),
1088          Rectangle(
1089            extent={{-82,60},{38,26}},
1090            fillPattern=FillPattern.Solid,
1091            fillColor={0,158,0},
1092            pattern=LinePattern.None,
1093            lineColor={0,0,0}),
1094          Polygon(
1095            points={{-80,60},{-78,26},{-86,28},{-86,56},{-82,60},{-80,60}},
1096            smooth=Smooth.Bezier,
1097            fillColor={0,158,0},
1098            fillPattern=FillPattern.Solid,
1099            pattern=LinePattern.None,
1100            lineColor={0,0,0}),
1101          Ellipse(
1102            extent={{-74,28},{-58,14}},
1103            lineColor={0,0,0},
1104            fillColor={127,0,0},
1105            fillPattern=FillPattern.Solid),
1106          Ellipse(
1107            extent={{-20,28},{-4,14}},
1108            lineColor={0,0,0},
1109            fillColor={127,0,0},
1110            fillPattern=FillPattern.Solid),
1111          Ellipse(
1112            extent={{36,28},{52,14}},
1113            lineColor={0,0,0},
1114            fillColor={127,0,0},
1115            fillPattern=FillPattern.Solid),
1116          Rectangle(
1117            extent={{-76,36},{42,34}},
1118            lineColor={0,0,0},
1119            fillColor={255,255,170},
1120            fillPattern=FillPattern.Solid),
1121          Rectangle(
1122            extent={{-72,54},{-62,48}},
1123            lineColor={0,0,0},
1124            fillColor={170,213,255},
1125            fillPattern=FillPattern.Solid),
1126          Rectangle(
1127            extent={{-48,54},{-38,48}},
1128            lineColor={0,0,0},
1129            fillColor={170,213,255},
1130            fillPattern=FillPattern.Solid),
1131          Rectangle(
1132            extent={{-24,54},{-14,48}},
1133            lineColor={0,0,0},
1134            fillColor={170,213,255},
1135            fillPattern=FillPattern.Solid),
1136          Rectangle(
1137            extent={{0,54},{10,48}},
1138            lineColor={0,0,0},
1139            fillColor={170,213,255},
1140            fillPattern=FillPattern.Solid),
1141          Rectangle(
1142            extent={{24,54},{34,48}},
1143            lineColor={0,0,0},
1144            fillColor={170,213,255},
1145            fillPattern=FillPattern.Solid),
1146          Line(
1147            points={{88,32},{94,32},{94,32}},
1148            color={0,0,0},
1149            smooth=Smooth.None,
1150            thickness=0.5),
1151          Line(
1152            points={{94,32},{94,36},{94,28},{94,28}},
1153            color={0,0,0},
1154            smooth=Smooth.None,
1155            thickness=0.5),
1156          Line(
1157            points={{-88,14},{76,14},{78,14}},
1158            color={0,0,0},
1159            smooth=Smooth.None),
1160          Line(
1161            points={{20,60},{0,80},{0,94},{0,94}},
1162            color={0,0,0},
1163            smooth=Smooth.None),
1164          Line(
1165            points={{78,14},{78,4},{94,4},{94,4}},
1166            color={0,0,0},
1167            smooth=Smooth.None),
1168          Text(
1169            extent={{-66,-20},{56,-72}},
1170            lineColor={0,0,0},
1171            lineThickness=1,
1172            fillColor={0,0,255},
1173            fillPattern=FillPattern.Solid,
1174            textString="Tram"),
1175          Text(
1176            extent={{-156,90},{-92,70}},
1177            lineColor={0,0,0},
1178            fillPattern=FillPattern.Solid,
1179            textString="Pos."),
1180          Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0})}));
1181  end Convoglio;
1182
1183
1184
1185
1186
1187  model Rete_di_Alimentazione_Mono
1188    "Modello della rete di alimentazione DC - ALIM. BILATERA E MONOLATERA"
1189
1190    Modelica.Blocks.Interfaces.RealInput Posizione
1191      "Posizione del treno durante la marcia [m]" annotation (Placement(
1192          transformation(extent={{-280,-20},{-240,20}}), iconTransformation(
1193            extent={{-240,-10},{-200,30}})));
1194    Modelica.Electrical.Analog.Interfaces.PositivePin pin_p
1195      annotation (Placement(transformation(extent={{130,-90},{150,-70}})));
1196    Modelica.Electrical.Analog.Interfaces.Pin pin
1197      annotation (Placement(transformation(extent={{-170,90},{-150,110}})));
1198    Modelica.Electrical.Analog.Interfaces.Pin pin1
1199      annotation (Placement(transformation(extent={{-50,90},{-30,110}})));
1200    Modelica.Electrical.Analog.Interfaces.Pin pin2
1201      annotation (Placement(transformation(extent={{70,90},{90,110}})));
1202    Modelica.Electrical.Analog.Interfaces.Pin pin3
1203      annotation (Placement(transformation(extent={{190,90},{210,110}})));
1204    parameter Real Posizione_SSE[6]={580,1744,3141,4488,5555,7521}
1205      "Posizione assoluta delle SSE lungo l'intera tratta del convoglio ferroviario [m]";
1206
1207    Real R_spec[5] "Resistenza specifica della linea di alimentazione [Ohm/m]";
1208
1209    Real R_SSE[5, 6]
1210      "Matrice di gestione delle resistenze destra e sinistra tra le varie sottostazioni [Ohm]";
1211    Real R_Comm[6]
1212      "Vettore delle resistenze \"fittizie\" di commutazione tra le sottostazioni [Ohm] NOTA: L'INDICE 6 E' USATO PER LA GESTIONE DELLA RESISTENZA PER ALIM. MONOLATERA";
1213    parameter Real Val_R_Comm_Non_Att=10000000
1214      "Valore delle Resistenze di Commutazione non attive [Ohm] (VALORE ALTO)";
1215    parameter Real Val_R_Comm_Att=0.0001
1216      "Valore della Resistenza di Commutazione attiva [Ohm] (VALORE BASSO)";
1217    Real alfa[6]
1218      "Variabile utilizzata per il calcolo della resistenza destra e sinistra tra le due sottostazioni attuali [Rxy_s=Rtot*alfa e Rxy_d=Rtot*(1-alfa)] NOTA: L'INDICE 6 E' USATO PER LA GESTIONE DELLA RESISTENZA PER ALIM. MONOLATERA";
1219    Real Ltot[6]
1220      "Distanza totale tra le coppie di SSE contigue (es.SS1-SSE2 SS2-SSE3 etc...) [m] NOTA: L'INDICE 6 E' USATO PER LA GESTIONE DELLA RESISTENZA PER ALIM. MONOLATERA";
1221    Real Rtot[6]
1222      "Resistenza totale tra le coppie di SSE contigue (es.SS1-SSE2 SS2-SSE3 etc...)[Ohm]. NOTA: L'INDICE 6 E' USATO PER LA GESTIONE DELLA RESISTENZA PER ALIM. MONOLATERA";
1223
1224    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor
1225      annotation (Placement(transformation(extent={{-142,30},{-122,50}})));
1226    Modelica.Blocks.Sources.RealExpression realExpression(y=R_SSE[1, 1])
1227      annotation (Placement(transformation(
1228          extent={{-10,-10},{10,10}},
1229          rotation=270,
1230          origin={-132,70})));
1231    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor1
1232      annotation (Placement(transformation(extent={{-80,30},{-60,50}})));
1233    Modelica.Blocks.Sources.RealExpression realExpression1(y=R_SSE[1, 2])
1234      annotation (Placement(transformation(
1235          extent={{-10,-10},{10,10}},
1236          rotation=270,
1237          origin={-70,70})));
1238    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor2
1239      annotation (Placement(transformation(extent={{-20,30},{0,50}})));
1240    Modelica.Blocks.Sources.RealExpression realExpression2(y=R_SSE[2, 2])
1241      annotation (Placement(transformation(
1242          extent={{-10,-10},{10,10}},
1243          rotation=270,
1244          origin={-10,70})));
1245    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor3
1246      annotation (Placement(transformation(extent={{40,30},{60,50}})));
1247    Modelica.Blocks.Sources.RealExpression realExpression3(y=R_SSE[2, 3])
1248      annotation (Placement(transformation(
1249          extent={{-10,-10},{10,10}},
1250          rotation=270,
1251          origin={50,70})));
1252    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor4
1253      annotation (Placement(transformation(extent={{100,30},{120,50}})));
1254    Modelica.Blocks.Sources.RealExpression realExpression4(y=R_SSE[3, 3])
1255      annotation (Placement(transformation(
1256          extent={{-10,-10},{10,10}},
1257          rotation=270,
1258          origin={110,70})));
1259    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor5
1260      annotation (Placement(transformation(extent={{158,30},{178,50}})));
1261    Modelica.Blocks.Sources.RealExpression realExpression5(y=R_SSE[3, 4])
1262      annotation (Placement(transformation(
1263          extent={{-10,-10},{10,10}},
1264          rotation=270,
1265          origin={168,70})));
1266    Modelica.Blocks.Sources.RealExpression realExpression6(y=R_Comm[1])
1267      annotation (Placement(transformation(
1268          extent={{-20,-12},{20,12}},
1269          rotation=180,
1270          origin={-60,-1.77636e-015})));
1271    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor6
1272      annotation (Placement(transformation(
1273          extent={{-10,-10},{10,10}},
1274          rotation=270,
1275          origin={-100,0})));
1276    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor7
1277      annotation (Placement(transformation(
1278          extent={{-10,-10},{10,10}},
1279          rotation=270,
1280          origin={20,0})));
1281    Modelica.Blocks.Sources.RealExpression realExpression7(y=R_Comm[2])
1282      annotation (Placement(transformation(
1283          extent={{-21,-12},{21,12}},
1284          rotation=180,
1285          origin={61,-1.77636e-015})));
1286    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor8
1287      annotation (Placement(transformation(
1288          extent={{-10,-10},{10,10}},
1289          rotation=270,
1290          origin={140,0})));
1291    Modelica.Blocks.Sources.RealExpression realExpression8(y=R_Comm[3])
1292      annotation (Placement(transformation(
1293          extent={{-21,-12},{21,12}},
1294          rotation=180,
1295          origin={181,-1.77636e-015})));
1296    Real R[5, 6]
1297      "Matrice che da i valori delle resistenze destra e sinistra delle SSE attualmente attive (nel caso la velocità sia positiva o negativa) [Ohm]";
1298    Modelica.Electrical.Analog.Sensors.CurrentSensor Amp_R_Comm_1 annotation (
1299        Placement(transformation(
1300          extent={{-10,-10},{10,10}},
1301          rotation=270,
1302          origin={-100,-32})));
1303    Modelica.Electrical.Analog.Sensors.CurrentSensor Amp_R_Comm_2 annotation (
1304        Placement(transformation(
1305          extent={{-10,-10},{10,10}},
1306          rotation=270,
1307          origin={20,-32})));
1308    Modelica.Electrical.Analog.Sensors.CurrentSensor Amp_R_Comm_3 annotation (
1309        Placement(transformation(
1310          extent={{-10,-10},{10,10}},
1311          rotation=270,
1312          origin={140,-32})));
1313    Modelica.Electrical.Analog.Interfaces.Pin pin4
1314      annotation (Placement(transformation(extent={{310,90},{330,110}})));
1315    Modelica.Electrical.Analog.Interfaces.Pin pin5
1316      annotation (Placement(transformation(extent={{430,90},{450,110}})));
1317    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor9
1318      annotation (Placement(transformation(extent={{220,30},{240,50}})));
1319    Modelica.Blocks.Sources.RealExpression realExpression9(y=R_SSE[4, 4])
1320      annotation (Placement(transformation(
1321          extent={{-10,-10},{10,10}},
1322          rotation=270,
1323          origin={230,72})));
1324    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor10
1325      annotation (Placement(transformation(extent={{280,30},{300,50}})));
1326    Modelica.Blocks.Sources.RealExpression realExpression10(y=R_SSE[4, 5])
1327      annotation (Placement(transformation(
1328          extent={{-10,-10},{10,10}},
1329          rotation=270,
1330          origin={290,72})));
1331    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor11
1332      annotation (Placement(transformation(extent={{340,30},{360,50}})));
1333    Modelica.Blocks.Sources.RealExpression realExpression11(y=R_SSE[5, 5])
1334      annotation (Placement(transformation(
1335          extent={{-10,-10},{10,10}},
1336          rotation=270,
1337          origin={350,72})));
1338    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor12
1339      annotation (Placement(transformation(extent={{400,30},{420,50}})));
1340    Modelica.Blocks.Sources.RealExpression realExpression12(y=R_SSE[5, 6])
1341      annotation (Placement(transformation(
1342          extent={{-10,-10},{10,10}},
1343          rotation=270,
1344          origin={410,70})));
1345    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor13
1346      annotation (Placement(transformation(
1347          extent={{-10,-10},{10,10}},
1348          rotation=270,
1349          origin={260,0})));
1350    Modelica.Electrical.Analog.Sensors.CurrentSensor Amp_R_Comm_4 annotation (
1351        Placement(transformation(
1352          extent={{-10,-10},{10,10}},
1353          rotation=270,
1354          origin={260,-32})));
1355    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor14
1356      annotation (Placement(transformation(
1357          extent={{-10,-10},{10,10}},
1358          rotation=270,
1359          origin={380,0})));
1360    Modelica.Electrical.Analog.Sensors.CurrentSensor Amp_R_Comm_5 annotation (
1361        Placement(transformation(
1362          extent={{-10,-10},{10,10}},
1363          rotation=270,
1364          origin={380,-32})));
1365    Modelica.Blocks.Sources.RealExpression realExpression13(y=R_Comm[4])
1366      annotation (Placement(transformation(
1367          extent={{-20,-12},{20,12}},
1368          rotation=180,
1369          origin={300,0})));
1370    Modelica.Blocks.Sources.RealExpression realExpression14(y=R_Comm[5])
1371      annotation (Placement(transformation(
1372          extent={{-20,-12},{20,12}},
1373          rotation=180,
1374          origin={420,0})));
1375
1376    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor15
1377      annotation (Placement(transformation(extent={{-200,30},{-180,50}})));
1378    Modelica.Blocks.Sources.RealExpression realExpression15(y=R_SSE_sx)
1379      annotation (Placement(transformation(
1380          extent={{-10,-10},{10,10}},
1381          rotation=270,
1382          origin={-190,70})));
1383    Modelica.Electrical.Analog.Basic.VariableResistor variableResistor16
1384      annotation (Placement(transformation(
1385          extent={{-10,-10},{10,10}},
1386          rotation=270,
1387          origin={-220,0})));
1388    Modelica.Blocks.Sources.RealExpression realExpression16(y=R_Comm[6])
1389      annotation (Placement(transformation(
1390          extent={{-20,-12},{20,12}},
1391          rotation=180,
1392          origin={-180,0})));
1393    Modelica.Electrical.Analog.Sensors.CurrentSensor Amp_R_Comm_6 annotation (
1394        Placement(transformation(
1395          extent={{-10,-10},{10,10}},
1396          rotation=270,
1397          origin={-220,-32})));
1398
1399    Real R_SSE_sx
1400      "Resistenza longitudinale sinistra per alimentazione monolatera sinistra";
1401
1402  equation
1403    //NOTA:GESTIONE DI TUTTE LE RESISTENZE LONGITUDINALI E TRASVERSALI TRANNE QUELLE ESTREME ATTIVE SOLO PER ALIMENTAZIONE MONOLATERA:
1404    for i in 1:5 loop
1405      //Calcolo della distanza totale tra le due SSE (Ltot) contigue necessaria per calcolare la resistenza totale (Rtot) tra le due SSE
1406      Ltot[i] = Posizione_SSE[i + 1] - Posizione_SSE[i];
1407      //Calcolo della resistenza totale tra due SSE contigue (Rtot):
1408      Rtot[i] = R_spec[i]*Ltot[i];
1409      //Impostazione dei coefficienti della matrice di gestione delle resistenze longitudinali tra le sottostazioni (SSE):
1410      R_SSE[i, i] = if Posizione >= Posizione_SSE[i] and Posizione <=
1411        Posizione_SSE[i + 1] then R[i, i] else Rtot[i];
1412      R_SSE[i, i + 1] = if Posizione >= Posizione_SSE[i] and Posizione <=
1413        Posizione_SSE[i + 1] then R[i, i + 1] else 0;
1414      //logica di gestione della R di destra e della R di sinistra se il tratto tra le due sottostazioni è quello percorso attualmente:
1415      R[i, i] = if der(Posizione) >= 0 then (1 - alfa[i])*Rtot[i] else alfa[i]*
1416        Rtot[i];
1417      R[i, i + 1] = if der(Posizione) >= 0 then alfa[i]*Rtot[i] else (1 - alfa[
1418        i])*Rtot[i];
1419      //Gestione dell'alfa tra le varie sottostazioni e nel caso di velocità positive e negative:
1420      if Posizione >= Posizione_SSE[i] and Posizione <= Posizione_SSE[i + 1]
1421           then
1422        alfa[i] = if der(Posizione) >= 0 then (Posizione_SSE[i + 1] - Posizione)
1423          /Ltot[i] else (Posizione - Posizione_SSE[i])/Ltot[i];
1424      else
1425        alfa[i] = alfa[i];
1426      end if;
1427
1428      //GESTIONE DELLA RESISTENZA SPECIFICA (da 0 a 1744 è 0.0000867 ohm/m e da 1744 in poi di 0.0001215):
1429      if i <= 2 then
1430        R_spec[i] = 0.0000867;
1431      else
1432        R_spec[i] = 0.0001215;
1433      end if;
1434
1435      //GESTIONE DELLE RESISTENZE TRASVERSALI DI COMMUTAZIONE:
1436      if i <> 5 then
1437        R_Comm[i] = if (Posizione >= Posizione_SSE[i] and Posizione <
1438          Posizione_SSE[i + 1]) then Val_R_Comm_Att else Val_R_Comm_Non_Att;
1439      else
1440        R_Comm[i] = if Posizione >= Posizione_SSE[i] then Val_R_Comm_Att else
1441          Val_R_Comm_Non_Att;
1442      end if;
1443      //Qui sopra ho scritto un if per essere sicuro che se la posizione del convoglio va oltre la posizione dell'ultima SSE comunque ci sia la R_Comm[5] pressochè nulla perchè altrimenti sarebbero tutte a valore altissimo.
1444    end for;
1445
1446    //NOTA: GESTIONE DELLE RESISTENZE ESTREME PER ALIMENTAZIONE MONOLATERA:
1447
1448    //GESTIONE RESISTENZE PARTE SINISTRA (indice 6):
1449    Ltot[6] = Posizione_SSE[1] - 0;
1450    Rtot[6] = R_spec[1]*Ltot[6];
1451    R_SSE_sx = if Posizione <= Posizione_SSE[1] and Posizione >= 0 then (alfa[6])
1452      *Rtot[6] else Rtot[6];
1453    alfa[6] = (Posizione_SSE[1] - Posizione)/Ltot[6];
1454    R_Comm[6] = if Posizione <= Posizione_SSE[1] then Val_R_Comm_Att else
1455      Val_R_Comm_Non_Att;
1456    //IMPORTANTE: Sopra IMPLICITAMENTE ho imposto anche che se Posizione diventa minore di zero (fine simulazione) è sempre attiva la R_Comm_[6] (sennò le R_Comm sarebbero tutte attive a valore altissimo).
1457
1458    //Riempimento con zeri della matrice delle Resistenze longitudinali delle SSE [R_SSE] negli elementi non utilizzati (e anche della matrice R):
1459    R_SSE[1, 3] = 0;
1460    R_SSE[1, 4] = 0;
1461    R_SSE[1, 5] = 0;
1462    R_SSE[1, 6] = 0;
1463    R_SSE[2, 1] = 0;
1464    R_SSE[2, 4] = 0;
1465    R_SSE[2, 5] = 0;
1466    R_SSE[2, 6] = 0;
1467    R_SSE[3, 1] = 0;
1468    R_SSE[3, 2] = 0;
1469    R_SSE[3, 5] = 0;
1470    R_SSE[3, 6] = 0;
1471    R_SSE[4, 1] = 0;
1472    R_SSE[4, 2] = 0;
1473    R_SSE[4, 3] = 0;
1474    R_SSE[4, 6] = 0;
1475    R_SSE[5, 1] = 0;
1476    R_SSE[5, 2] = 0;
1477    R_SSE[5, 3] = 0;
1478    R_SSE[5, 4] = 0;
1479    R[1, 3] = 0;
1480    R[1, 4] = 0;
1481    R[1, 5] = 0;
1482    R[1, 6] = 0;
1483    R[2, 1] = 0;
1484    R[2, 4] = 0;
1485    R[2, 5] = 0;
1486    R[2, 6] = 0;
1487    R[3, 1] = 0;
1488    R[3, 2] = 0;
1489    R[3, 5] = 0;
1490    R[3, 6] = 0;
1491    R[4, 1] = 0;
1492    R[4, 2] = 0;
1493    R[4, 3] = 0;
1494    R[4, 6] = 0;
1495    R[5, 1] = 0;
1496    R[5, 2] = 0;
1497    R[5, 3] = 0;
1498    R[5, 4] = 0;
1499
1500    connect(variableResistor.p, pin) annotation (Line(
1501        points={{-142,40},{-160,40},{-160,100}},
1502        color={0,0,255},
1503        smooth=Smooth.None));
1504    connect(realExpression.y, variableResistor.R) annotation (Line(
1505        points={{-132,59},{-132,51}},
1506        color={0,0,127},
1507        smooth=Smooth.None));
1508    connect(variableResistor1.p, variableResistor.n) annotation (Line(
1509        points={{-80,40},{-122,40}},
1510        color={0,0,255},
1511        smooth=Smooth.None));
1512    connect(realExpression1.y, variableResistor1.R) annotation (Line(
1513        points={{-70,59},{-70,51}},
1514        color={0,0,127},
1515        smooth=Smooth.None));
1516    connect(variableResistor5.n, pin3) annotation (Line(
1517        points={{178,40},{200,40},{200,100}},
1518        color={0,0,255},
1519        smooth=Smooth.None));
1520    connect(variableResistor5.p, variableResistor4.n) annotation (Line(
1521        points={{158,40},{120,40}},
1522        color={0,0,255},
1523        smooth=Smooth.None));
1524    connect(variableResistor4.p, variableResistor3.n) annotation (Line(
1525        points={{100,40},{60,40}},
1526        color={0,0,255},
1527        smooth=Smooth.None));
1528    connect(variableResistor3.p, variableResistor2.n) annotation (Line(
1529        points={{40,40},{0,40}},
1530        color={0,0,255},
1531        smooth=Smooth.None));
1532    connect(variableResistor2.p, variableResistor1.n) annotation (Line(
1533        points={{-20,40},{-60,40}},
1534        color={0,0,255},
1535        smooth=Smooth.None));
1536    connect(realExpression2.y, variableResistor2.R) annotation (Line(
1537        points={{-10,59},{-10,51}},
1538        color={0,0,127},
1539        smooth=Smooth.None));
1540    connect(realExpression3.y, variableResistor3.R) annotation (Line(
1541        points={{50,59},{50,51}},
1542        color={0,0,127},
1543        smooth=Smooth.None));
1544    connect(realExpression4.y, variableResistor4.R) annotation (Line(
1545        points={{110,59},{110,51}},
1546        color={0,0,127},
1547        smooth=Smooth.None));
1548    connect(realExpression5.y, variableResistor5.R) annotation (Line(
1549        points={{168,59},{168,51}},
1550        color={0,0,127},
1551        smooth=Smooth.None));
1552    connect(pin1, variableResistor1.n) annotation (Line(
1553        points={{-40,100},{-40,40},{-60,40}},
1554        color={0,0,255},
1555        smooth=Smooth.None));
1556    connect(pin2, variableResistor3.n) annotation (Line(
1557        points={{80,100},{80,40},{60,40}},
1558        color={0,0,255},
1559        smooth=Smooth.None));
1560    connect(variableResistor6.p, variableResistor1.p) annotation (Line(
1561        points={{-100,10},{-100,40},{-80,40}},
1562        color={0,0,255},
1563        smooth=Smooth.None));
1564    connect(realExpression7.y, variableResistor7.R) annotation (Line(
1565        points={{37.9,9.99201e-016},{37.9,1},{36,0},{36,-2.22045e-015},{31,-2.22045e-015}},
1566
1567        color={0,0,127},
1568        smooth=Smooth.None));
1569    connect(variableResistor7.p, variableResistor3.p) annotation (Line(
1570        points={{20,10},{20,40},{40,40}},
1571        color={0,0,255},
1572        smooth=Smooth.None));
1573    connect(realExpression6.y, variableResistor6.R) annotation (Line(
1574        points={{-82,8.88178e-016},{-84,8.88178e-016},{-84,-2.22045e-015},{-89,
1575            -2.22045e-015}},
1576        color={0,0,127},
1577        smooth=Smooth.None));
1578    connect(variableResistor8.p, variableResistor4.n) annotation (Line(
1579        points={{140,10},{140,40},{120,40}},
1580        color={0,0,255},
1581        smooth=Smooth.None));
1582
1583    connect(variableResistor8.n, Amp_R_Comm_3.p) annotation (Line(
1584        points={{140,-10},{140,-22}},
1585        color={0,0,255},
1586        smooth=Smooth.None));
1587    connect(variableResistor7.n, Amp_R_Comm_2.p) annotation (Line(
1588        points={{20,-10},{20,-22}},
1589        color={0,0,255},
1590        smooth=Smooth.None));
1591    connect(variableResistor6.n, Amp_R_Comm_1.p) annotation (Line(
1592        points={{-100,-10},{-100,-22}},
1593        color={0,0,255},
1594        smooth=Smooth.None));
1595    connect(Amp_R_Comm_1.n, pin_p) annotation (Line(
1596        points={{-100,-42},{-100,-60},{140,-60},{140,-80}},
1597        color={0,0,255},
1598        smooth=Smooth.None));
1599    connect(Amp_R_Comm_2.n, pin_p) annotation (Line(
1600        points={{20,-42},{20,-60},{140,-60},{140,-80}},
1601        color={0,0,255},
1602        smooth=Smooth.None));
1603    connect(Amp_R_Comm_3.n, pin_p) annotation (Line(
1604        points={{140,-42},{140,-80}},
1605        color={0,0,255},
1606        smooth=Smooth.None));
1607    connect(variableResistor8.R, realExpression8.y) annotation (Line(
1608        points={{151,-2.22045e-015},{154,-2.22045e-015},{154,1.11022e-015},{
1609            157.9,1.11022e-015}},
1610        color={0,0,127},
1611        smooth=Smooth.None));
1612
1613    connect(variableResistor9.p, variableResistor5.n) annotation (Line(
1614        points={{220,40},{178,40}},
1615        color={0,0,255},
1616        smooth=Smooth.None));
1617    connect(variableResistor10.p, variableResistor9.n) annotation (Line(
1618        points={{280,40},{240,40}},
1619        color={0,0,255},
1620        smooth=Smooth.None));
1621    connect(variableResistor11.p, variableResistor10.n) annotation (Line(
1622        points={{340,40},{300,40}},
1623        color={0,0,255},
1624        smooth=Smooth.None));
1625    connect(variableResistor12.p, variableResistor11.n) annotation (Line(
1626        points={{400,40},{360,40}},
1627        color={0,0,255},
1628        smooth=Smooth.None));
1629    connect(pin5, variableResistor12.n) annotation (Line(
1630        points={{440,100},{440,40},{420,40}},
1631        color={0,0,255},
1632        smooth=Smooth.None));
1633    connect(variableResistor13.R, realExpression13.y) annotation (Line(
1634        points={{271,0},{274,0},{274,2.66454e-015},{278,2.66454e-015}},
1635        color={0,0,127},
1636        smooth=Smooth.None));
1637    connect(realExpression14.y, variableResistor14.R) annotation (Line(
1638        points={{398,2.66454e-015},{396,2.66454e-015},{396,-1.9984e-015},{391,-1.9984e-015}},
1639
1640        color={0,0,127},
1641        smooth=Smooth.None));
1642
1643    connect(variableResistor13.p, variableResistor9.n) annotation (Line(
1644        points={{260,10},{260,40},{240,40}},
1645        color={0,0,255},
1646        smooth=Smooth.None));
1647    connect(realExpression9.y, variableResistor9.R) annotation (Line(
1648        points={{230,61},{230,51}},
1649        color={0,0,127},
1650        smooth=Smooth.None));
1651    connect(realExpression10.y, variableResistor10.R) annotation (Line(
1652        points={{290,61},{290,51}},
1653        color={0,0,127},
1654        smooth=Smooth.None));
1655    connect(realExpression11.y, variableResistor11.R) annotation (Line(
1656        points={{350,61},{350,51}},
1657        color={0,0,127},
1658        smooth=Smooth.None));
1659    connect(realExpression12.y, variableResistor12.R) annotation (Line(
1660        points={{410,59},{410,51}},
1661        color={0,0,127},
1662        smooth=Smooth.None));
1663    connect(Amp_R_Comm_4.n, pin_p) annotation (Line(
1664        points={{260,-42},{260,-60},{140,-60},{140,-80}},
1665        color={0,0,255},
1666        smooth=Smooth.None));
1667    connect(Amp_R_Comm_5.n, pin_p) annotation (Line(
1668        points={{380,-42},{380,-60},{140,-60},{140,-80}},
1669        color={0,0,255},
1670        smooth=Smooth.None));
1671    connect(variableResistor14.n, Amp_R_Comm_5.p) annotation (Line(
1672        points={{380,-10},{380,-22}},
1673        color={0,0,255},
1674        smooth=Smooth.None));
1675    connect(variableResistor14.p, variableResistor11.n) annotation (Line(
1676        points={{380,10},{380,40},{360,40}},
1677        color={0,0,255},
1678        smooth=Smooth.None));
1679    connect(variableResistor13.n, Amp_R_Comm_4.p) annotation (Line(
1680        points={{260,-10},{260,-22}},
1681        color={0,0,255},
1682        smooth=Smooth.None));
1683    connect(pin4, variableResistor10.n) annotation (Line(
1684        points={{320,100},{320,40},{300,40}},
1685        color={0,0,255},
1686        smooth=Smooth.None));
1687    connect(variableResistor15.n, variableResistor.p) annotation (Line(
1688        points={{-180,40},{-142,40}},
1689        color={0,0,255},
1690        smooth=Smooth.None));
1691    connect(realExpression15.y, variableResistor15.R) annotation (Line(
1692        points={{-190,59},{-190,51}},
1693        color={0,0,127},
1694        smooth=Smooth.None));
1695    connect(variableResistor15.p, variableResistor16.p) annotation (Line(
1696        points={{-200,40},{-220,40},{-220,10}},
1697        color={0,0,255},
1698        smooth=Smooth.None));
1699    connect(variableResistor16.n, Amp_R_Comm_6.p) annotation (Line(
1700        points={{-220,-10},{-220,-22}},
1701        color={0,0,255},
1702        smooth=Smooth.None));
1703    connect(Amp_R_Comm_6.n, pin_p) annotation (Line(
1704        points={{-220,-42},{-220,-60},{140,-60},{140,-80}},
1705        color={0,0,255},
1706        smooth=Smooth.None));
1707    connect(realExpression16.y, variableResistor16.R) annotation (Line(
1708        points={{-202,0},{-209,0}},
1709        color={0,0,127},
1710        smooth=Smooth.None));
1711
1712    annotation (Diagram(coordinateSystem(extent={{-240,-80},{480,100}},
1713            preserveAspectRatio=false), graphics), Icon(coordinateSystem(extent
1714            ={{-240,-80},{480,100}}, preserveAspectRatio=false), graphics={
1715          Rectangle(extent={{-200,100},{480,-80}}, lineColor={0,0,0}),
1716          Text(
1717            extent={{-274,50},{-174,32}},
1718            lineColor={0,0,0},
1719            textString="Pos."),
1720          Line(
1721            points={{-160,90},{-160,60},{-140,60},{-140,60}},
1722            color={215,215,215},
1723            smooth=Smooth.None),
1724          Rectangle(extent={{-140,66},{-120,56}}, lineColor={215,215,215}),
1725          Rectangle(extent={{-80,64},{-60,54}}, lineColor={215,215,215}),
1726          Line(
1727            points={{-40,92},{-40,60},{-60,60},{-60,60}},
1728            color={215,215,215},
1729            smooth=Smooth.None),
1730          Line(
1731            points={{-120,62},{-120,64}},
1732            color={215,215,215},
1733            smooth=Smooth.None),
1734          Line(
1735            points={{-120,60},{-80,60}},
1736            color={215,215,215},
1737            smooth=Smooth.None),
1738          Line(
1739            points={{-100,60},{-100,40},{-100,30},{-100,30}},
1740            color={215,215,215},
1741            smooth=Smooth.None),
1742          Rectangle(
1743            extent={{-10,5},{10,-5}},
1744            lineColor={215,215,215},
1745            origin={-100,21},
1746            rotation=90),
1747          Line(
1748            points={{-100,10},{-100,-12},{-100,-20}},
1749            color={215,215,215},
1750            smooth=Smooth.None),
1751          Line(
1752            points={{-40,90},{-40,60},{-20,60},{-20,60}},
1753            color={215,215,215},
1754            smooth=Smooth.None),
1755          Rectangle(extent={{-20,66},{0,56}}, lineColor={215,215,215}),
1756          Rectangle(extent={{40,64},{60,54}}, lineColor={215,215,215}),
1757          Line(
1758            points={{80,92},{80,60},{60,60},{60,60}},
1759            color={215,215,215},
1760            smooth=Smooth.None),
1761          Line(
1762            points={{0,62},{0,64}},
1763            color={215,215,215},
1764            smooth=Smooth.None),
1765          Line(
1766            points={{0,60},{40,60}},
1767            color={215,215,215},
1768            smooth=Smooth.None),
1769          Line(
1770            points={{20,60},{20,40},{20,30},{20,30}},
1771            color={215,215,215},
1772            smooth=Smooth.None),
1773          Rectangle(
1774            extent={{-10,5},{10,-5}},
1775            lineColor={215,215,215},
1776            origin={20,21},
1777            rotation=90),
1778          Line(
1779            points={{20,10},{20,-12},{20,-20}},
1780            color={215,215,215},
1781            smooth=Smooth.None),
1782          Line(
1783            points={{80,90},{80,60},{100,60},{100,60}},
1784            color={215,215,215},
1785            smooth=Smooth.None),
1786          Rectangle(extent={{100,66},{120,56}}, lineColor={215,215,215}),
1787          Rectangle(extent={{160,64},{180,54}}, lineColor={215,215,215}),
1788          Line(
1789            points={{200,92},{200,60},{180,60},{180,60}},
1790            color={215,215,215},
1791            smooth=Smooth.None),
1792          Line(
1793            points={{120,62},{120,64}},
1794            color={215,215,215},
1795            smooth=Smooth.None),
1796          Line(
1797            points={{120,60},{160,60}},
1798            color={215,215,215},
1799            smooth=Smooth.None),
1800          Line(
1801            points={{140,60},{140,40},{140,30},{140,30}},
1802            color={215,215,215},
1803            smooth=Smooth.None),
1804          Rectangle(
1805            extent={{-10,5},{10,-5}},
1806            lineColor={215,215,215},
1807            origin={140,21},
1808            rotation=90),
1809          Line(
1810            points={{140,10},{140,-12},{140,-20}},
1811            color={215,215,215},
1812            smooth=Smooth.None),
1813          Line(
1814            points={{200,90},{200,60},{220,60},{220,60}},
1815            color={215,215,215},
1816            smooth=Smooth.None),
1817          Rectangle(extent={{220,66},{240,56}}, lineColor={215,215,215}),
1818          Rectangle(extent={{280,64},{300,54}}, lineColor={215,215,215}),
1819          Line(
1820            points={{320,92},{320,60},{300,60},{300,60}},
1821            color={215,215,215},
1822            smooth=Smooth.None),
1823          Line(
1824            points={{240,62},{240,64}},
1825            color={215,215,215},
1826            smooth=Smooth.None),
1827          Line(
1828            points={{240,60},{280,60}},
1829            color={215,215,215},
1830            smooth=Smooth.None),
1831          Line(
1832            points={{260,60},{260,40},{260,30},{260,30}},
1833            color={215,215,215},
1834            smooth=Smooth.None),
1835          Rectangle(
1836            extent={{-10,5},{10,-5}},
1837            lineColor={215,215,215},
1838            origin={260,21},
1839            rotation=90),
1840          Line(
1841            points={{260,10},{260,-12},{260,-20}},
1842            color={215,215,215},
1843            smooth=Smooth.None),
1844          Line(
1845            points={{320,90},{320,60},{340,60},{340,60}},
1846            color={215,215,215},
1847            smooth=Smooth.None),
1848          Rectangle(extent={{340,66},{360,56}}, lineColor={215,215,215}),
1849          Rectangle(extent={{400,64},{420,54}}, lineColor={215,215,215}),
1850          Line(
1851            points={{440,92},{440,60},{420,60},{420,60}},
1852            color={215,215,215},
1853            smooth=Smooth.None),
1854          Line(
1855            points={{360,62},{360,64}},
1856            color={215,215,215},
1857            smooth=Smooth.None),
1858          Line(
1859            points={{360,60},{400,60}},
1860            color={215,215,215},
1861            smooth=Smooth.None),
1862          Line(
1863            points={{380,60},{380,40},{380,30},{380,30}},
1864            color={215,215,215},
1865            smooth=Smooth.None),
1866          Rectangle(
1867            extent={{-10,5},{10,-5}},
1868            lineColor={215,215,215},
1869            origin={380,21},
1870            rotation=90),
1871          Line(
1872            points={{380,10},{380,-12},{380,-20}},
1873            color={215,215,215},
1874            smooth=Smooth.None),
1875          Line(
1876            points={{-100,-20},{380,-20},{380,-20}},
1877            color={215,215,215},
1878            smooth=Smooth.None),
1879          Line(
1880            points={{140,-20},{140,-96},{140,-96}},
1881            color={215,215,215},
1882            smooth=Smooth.None),
1883          Text(
1884            extent={{-154,164},{438,-154}},
1885            lineColor={0,0,0},
1886            textString="Rete di Alimentazione DC")}));
1887  end Rete_di_Alimentazione_Mono;
1888
1889  model ExaAB_Blocchi_Mono
1890    "Esempio con blocchi A-F e alimentazione bilatera e monolatera"
1891    //   import SimpleDriver;
1892    import Modelica.Constants.pi;
1893    parameter Modelica.SIunits.Mass vMass=60000 "Vehicle mass";
1894
1895    DriverAB_Mod Pilota_A_F
1896      annotation (Placement(transformation(extent={{-86,-42},{-56,-12}})));
1897
1898    Convoglio convoglio
1899      annotation (Placement(transformation(extent={{-26,-48},{16,-6}})));
1900    Modelica.Electrical.Analog.Basic.Ground ground2 annotation (Placement(
1901          transformation(
1902          extent={{-9,-9},{9,9}},
1903          rotation=0,
1904          origin={35,-35})));
1905    Sottostazione_SSE SSE1
1906      annotation (Placement(transformation(extent={{-176,94},{-150,120}})));
1907    Sottostazione_SSE SSE2
1908      annotation (Placement(transformation(extent={{-116,94},{-90,120}})));
1909    Sottostazione_SSE SSE3
1910      annotation (Placement(transformation(extent={{-56,94},{-30,120}})));
1911    Sottostazione_SSE SSE4
1912      annotation (Placement(transformation(extent={{4,94},{30,120}})));
1913    Modelica.Electrical.Analog.Basic.Ground ground
1914      annotation (Placement(transformation(extent={{-166,70},{-146,90}})));
1915    Modelica.Electrical.Analog.Basic.Ground ground1
1916      annotation (Placement(transformation(extent={{-106,70},{-86,90}})));
1917    Modelica.Electrical.Analog.Basic.Ground ground3
1918      annotation (Placement(transformation(extent={{-46,70},{-26,90}})));
1919    Modelica.Electrical.Analog.Basic.Ground ground4
1920      annotation (Placement(transformation(extent={{14,70},{34,90}})));
1921    Sottostazione_SSE SSE5
1922      annotation (Placement(transformation(extent={{64,94},{90,120}})));
1923    Sottostazione_SSE SSE6
1924      annotation (Placement(transformation(extent={{124,94},{150,120}})));
1925    Modelica.Electrical.Analog.Basic.Ground ground5
1926      annotation (Placement(transformation(extent={{74,70},{94,90}})));
1927    Modelica.Electrical.Analog.Basic.Ground ground6
1928      annotation (Placement(transformation(extent={{134,70},{154,90}})));
1929    Rete_di_Alimentazione_Mono rete_di_Alimentazione
1930      annotation (Placement(transformation(extent={{-92,20},{74,40}})));
1931  equation
1932    connect(ground.p, SSE1.pin_n) annotation (Line(
1933        points={{-156,90},{-155.2,90},{-155.2,94}},
1934        color={0,0,255},
1935        smooth=Smooth.None));
1936    connect(ground1.p, SSE2.pin_n) annotation (Line(
1937        points={{-96,90},{-95.2,90},{-95.2,94}},
1938        color={0,0,255},
1939        smooth=Smooth.None));
1940    connect(ground3.p, SSE3.pin_n) annotation (Line(
1941        points={{-36,90},{-35.2,90},{-35.2,94}},
1942        color={0,0,255},
1943        smooth=Smooth.None));
1944    connect(ground4.p, SSE4.pin_n) annotation (Line(
1945        points={{24,90},{24.8,90},{24.8,94}},
1946        color={0,0,255},
1947        smooth=Smooth.None));
1948    connect(convoglio.pin_n, ground2.p) annotation (Line(
1949        points={{16.84,-26.16},{34.42,-26.16},{34.42,-26},{35,-26}},
1950        color={0,0,255},
1951        smooth=Smooth.None));
1952    connect(convoglio.Posizione, Pilota_A_F.s) annotation (Line(
1953        points={{-28.1,-14.4},{-42,-14.4},{-42,-6},{-106,-6},{-106,-21},{-89,-21}},
1954
1955        color={0,0,127},
1956        smooth=Smooth.None));
1957    connect(convoglio.Velocita, Pilota_A_F.v) annotation (Line(
1958        points={{-28.1,-40.02},{-44,-40.02},{-44,-48},{-106,-48},{-106,-33},{-89,
1959            -33}},
1960        color={0,0,127},
1961        smooth=Smooth.None));
1962    connect(SSE5.pin_n, ground5.p) annotation (Line(
1963        points={{84.8,94},{84.8,91},{84,91},{84,90}},
1964        color={0,0,255},
1965        smooth=Smooth.None));
1966    connect(SSE6.pin_n, ground6.p) annotation (Line(
1967        points={{144.8,94},{144,94},{144,90}},
1968        color={0,0,255},
1969        smooth=Smooth.None));
1970    connect(rete_di_Alimentazione.pin, SSE1.pin_p) annotation (Line(
1971        points={{-73.5556,40},{-74,40},{-74,56},{-170.8,56},{-170.8,94}},
1972        color={0,0,255},
1973        smooth=Smooth.None));
1974    connect(rete_di_Alimentazione.pin1, SSE2.pin_p) annotation (Line(
1975        points={{-45.8889,40},{-46,40},{-46,60},{-110.8,60},{-110.8,94}},
1976        color={0,0,255},
1977        smooth=Smooth.None));
1978    connect(SSE3.pin_p, rete_di_Alimentazione.pin2) annotation (Line(
1979        points={{-50.8,94},{-52,94},{-52,64},{-18.2222,64},{-18.2222,40}},
1980        color={0,0,255},
1981        smooth=Smooth.None));
1982    connect(SSE5.pin_p, rete_di_Alimentazione.pin4) annotation (Line(
1983        points={{69.2,94},{69.2,60},{37.1111,60},{37.1111,40}},
1984        color={0,0,255},
1985        smooth=Smooth.None));
1986    connect(SSE6.pin_p, rete_di_Alimentazione.pin5) annotation (Line(
1987        points={{129.2,94},{130,94},{130,56},{64.7778,56},{64.7778,40}},
1988        color={0,0,255},
1989        smooth=Smooth.None));
1990
1991    connect(SSE4.pin_p, rete_di_Alimentazione.pin3) annotation (Line(
1992        points={{9.2,94},{9.44444,94},{9.44444,40}},
1993        color={0,0,255},
1994        smooth=Smooth.None));
1995    connect(rete_di_Alimentazione.Posizione, Pilota_A_F.s) annotation (Line(
1996        points={{-87.3889,30},{-106,30},{-106,-21},{-89,-21}},
1997        color={0,0,127},
1998        smooth=Smooth.None));
1999    connect(Pilota_A_F.f, convoglio.Forza) annotation (Line(
2000        points={{-54.5,-27},{-30.2,-27}},
2001        color={0,0,127},
2002        smooth=Smooth.None));
2003    connect(rete_di_Alimentazione.pin_p, convoglio.pin_p) annotation (Line(
2004        points={{-4.38889,20},{-4,20},{-4,-6},{-5,-6}},
2005        color={0,0,255},
2006        smooth=Smooth.None));
2007    annotation (
2008      Diagram(coordinateSystem(preserveAspectRatio=false,extent={{-160,-80},{
2009              180,140}}),graphics),
2010      Icon(coordinateSystem(preserveAspectRatio=true, extent={{-160,-80},{180,
2011              140}}),graphics={Ellipse(
2012            extent={{-102,100},{98,-100}},
2013            lineColor={95,95,95},
2014            fillColor={255,255,255},
2015            fillPattern=FillPattern.Solid), Polygon(
2016            points={{-34,62},{66,2},{-34,-58},{-34,62}},
2017            lineColor={0,0,255},
2018            pattern=LinePattern.None,
2019            fillColor={95,95,95},
2020            fillPattern=FillPattern.Solid)}),
2021      experiment(StopTime=2400, __Dymola_NumberOfIntervals=2000),
2022      experimentSetupOutput(derivatives=false),
2023      Documentation(info="<html>
2024<p>Il problema &egrave; che nomanca la frenata asservita allo spazio.</p>
2025<p>Il problema della fermata asservita allo spazio &egrave; che si ha un&apos;oscillazione di s con andata e ritorno che non &egrave; realistica.</p>
2026<p>Occorre fare un frenatore che quando la velocit&agrave; &egrave; moloto bassa abbandona la coppia e lascia cle la coppia resistente del veiocolo finla finisca.</p>
2027</html>"),
2028      Commands(file="Plot.mos" "plot"));
2029  end ExaAB_Blocchi_Mono;
2030
2031
2032
2033
2034
2035
2036  annotation (uses(Modelica(version="3.2")));
2037end simpleTrain;