1 | within ; |
---|
2 | package OOInertia |
---|
3 | "Package without if inside the battery, and without explicit loss" |
---|
4 | //La ragione di questo package sta nel fatto che il conteggio dell'efficienza attraverso l'if crea difficoltà che appiono insormontabili |
---|
5 | //all'algoritmo di ottimizzazione. Con questa modifica si pensa di superare l'ostacolo. |
---|
6 | //Rispetto a bat2 qui non si calcolano le perdite durante la simulazione ma esse vencono implicitamente |
---|
7 | //conteggiate con il fatto che a fine simulazione si impne che esa meno energia di quanta ne è entrata. |
---|
8 | //Per semplicità il loe iniziale è posto pari a 0 |
---|
9 | |
---|
10 | package Components |
---|
11 | model AddPcLosses |
---|
12 | Modelica.Blocks.Interfaces.RealOutput y annotation(Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
13 | Modelica.Blocks.Interfaces.RealInput u "input fuel power" annotation(Placement(visible = true, transformation(extent = {{-138, -20}, {-98, 20}}, rotation = 0), iconTransformation(extent = {{-140, -20}, {-100, 20}}, rotation = 0))); |
---|
14 | // Modelica.SIunits.Power losses annotation(Placement(visible = true, transformation(origin = {120, -26}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
15 | Modelica.Blocks.Interfaces.RealOutput losses annotation(Placement(visible = true, transformation(origin = {0, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
16 | Modelica.Blocks.Math.Add add annotation(Placement(transformation(extent = {{48, -10}, {68, 10}}))); |
---|
17 | Modelica.Blocks.Tables.CombiTable1D consTable(table = [0, 5000; 9990, 19500; 10000, 19520; 40000, 75000], smoothness = Modelica.Blocks.Types.Smoothness.LinearSegments) annotation(Placement(transformation(extent = {{-52, -30}, {-32, -10}}))); |
---|
18 | equation |
---|
19 | connect(y, add.y) annotation(Line(points = {{110, 0}, {90, 0}, {69, 0}}, color = {0, 0, 127})); |
---|
20 | connect(add.u1, u) annotation(Line(points = {{46, 6}, {0, 6}, {0, 40}, {-80, 40}, {-80, 0}, {-118, 0}}, color = {0, 0, 127})); |
---|
21 | connect(add.u2, losses) annotation(Line(points = {{46, -6}, {0, -6}, {0, -110}}, color = {0, 0, 127})); |
---|
22 | connect(consTable.y[1], add.u2) annotation(Line(points = {{-31, -20}, {-16, -20}, {0, -20}, {0, -6}, {46, -6}}, color = {0, 0, 127})); |
---|
23 | connect(consTable.u[1], u) annotation(Line(points = {{-54, -20}, {-68, -20}, {-80, -20}, {-80, 0}, {-118, 0}}, color = {0, 0, 127})); |
---|
24 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(lineColor= {0, 0, 255}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -100}}), Text(lineColor= {0, 0, 255}, fillColor= {0, 0, 127}, fillPattern= FillPattern.Solid, extent= {{-100, 145}, {98, 105}}, textString= "%name"), Polygon(origin= {-0.9, 2.05}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, points= {{-23.1, 53.95}, {22.9, 53.95}, {20.9045, -22.0499}, {56.9, -24.05}, {0.9, -58.05}, {-55.1, -26.05}, {-21.0955, -24.0499}, {-23.1, 53.95}}, lineColor= {0, 0, 0}), Text(extent= {{-100, 44}, {100, -40}}, lineColor= {0, 0, 0}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, textString= "PC")})); |
---|
25 | end AddPcLosses; |
---|
26 | |
---|
27 | model AddPcLossesOld |
---|
28 | "Simplified losses of a generalised ICE. First release: two straight line segments" |
---|
29 | // Le perdite sono calcolate come dall'analisi della mappa della Prius che porta a mostrare |
---|
30 | // come sia possibile rappresentarle come una spezzata. Il primo segmento deriva |
---|
31 | // dal tratto verticale dei punti di lavoro ottimale e può ragionevolmente |
---|
32 | // essere rappresentata dalla relazione: |
---|
33 | // L(W)=5000+1.45Pu(W)= loss0+slope*u |
---|
34 | // Il secondo segmento è una retta che passa per l'origine e mostra perdite |
---|
35 | // proporzionali alla potenza erogata |
---|
36 | // il che corrisponde ad avere una curva dei punti di funzionamento ottimali |
---|
37 | // orizzontale (a coppia costante). |
---|
38 | // Nel caso della Prius questo è ragionevole e la coppia vale 79.6 Nm. |
---|
39 | // |
---|
40 | // La potenza di uscita è pari a quella di ingresso a cui si sono aggiunte le perdite calcolate. |
---|
41 | // Le perdite sono anche fornite in uscita. |
---|
42 | parameter Real loss0 = 5000 "watts when the delivered power is zero"; |
---|
43 | parameter Real slope = 1.45 |
---|
44 | "watts of losses per delivered watt avobe the corner point"; |
---|
45 | Modelica.Blocks.Interfaces.RealOutput y annotation(Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
46 | Modelica.Blocks.Interfaces.RealInput u "input fuel power" annotation(Placement(visible = true, transformation(extent = {{-138, -20}, {-98, 20}}, rotation = 0), iconTransformation(extent = {{-140, -20}, {-100, 20}}, rotation = 0))); |
---|
47 | // Modelica.SIunits.Power losses annotation(Placement(visible = true, transformation(origin = {120, -26}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
48 | Modelica.Blocks.Interfaces.RealOutput losses annotation(Placement(visible = true, transformation(origin = {0, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
49 | equation |
---|
50 | losses = loss0 + slope * u; |
---|
51 | y = u + losses; |
---|
52 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(lineColor= {0, 0, 255}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -100}}), Text(lineColor= {0, 0, 255}, fillColor= {0, 0, 127}, fillPattern= FillPattern.Solid, extent= {{-100, 145}, {98, 105}}, textString= "%name"), Polygon(origin= {-0.9, 2.05}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, points= {{-23.1, 53.95}, {22.9, 53.95}, {20.9045, -22.0499}, {56.9, -24.05}, {0.9, -58.05}, {-55.1, -26.05}, {-21.0955, -24.0499}, {-23.1, 53.95}}, lineColor= {0, 0, 0}), Text(extent= {{-100, 44}, {100, -40}}, lineColor= {0, 0, 0}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, textString= "PC")})); |
---|
53 | end AddPcLossesOld; |
---|
54 | |
---|
55 | model AddLosses |
---|
56 | "Simplified losses of a generalised ICE. First release: two straight line segments" |
---|
57 | // Le perdite sono calcolate come dall'analisi della mappa della Prius che porta a mostrare |
---|
58 | // come sia possibile rappresentarle come una spezzata. Il primo segmento deriva dal tratto verticale |
---|
59 | // dei punti di lavoro ottimale e può ragionevolmente essere rappresentata dalla relazione: |
---|
60 | // L(W)=5000+1.45Pu(W)= loss0+slope*u |
---|
61 | // Il secondo segmento è una retta che passa per l'rogine e mostra perdite proporzionali alla potenza erogata |
---|
62 | // il che corrisponde ad avere una curva dei punti di funzionamento ottimali orizzontale (a coppia costante). |
---|
63 | // Nel caso della Prius questo è ragionevole e la coppia vale 79.6 Nm. |
---|
64 | // |
---|
65 | // La potenza di uscita è pari a quella di ingresso a cui si csono agigunte le perdite calcolate. |
---|
66 | // Le perdite sono anche fornite in uscita. |
---|
67 | parameter Real loss0 = 5000 "watts when the delivered power is zero"; |
---|
68 | parameter Real slope = 1.45 |
---|
69 | "watts of losses per delivered watt avobe the corner point"; |
---|
70 | Modelica.Blocks.Interfaces.RealOutput y annotation(Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
71 | Modelica.Blocks.Interfaces.RealInput u "input fuel power" annotation(Placement(visible = true, transformation(extent = {{-138, -20}, {-98, 20}}, rotation = 0), iconTransformation(extent = {{-140, -20}, {-100, 20}}, rotation = 0))); |
---|
72 | // Modelica.SIunits.Power losses annotation(Placement(visible = true, transformation(origin = {120, -26}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
73 | Modelica.Blocks.Interfaces.RealOutput losses annotation(Placement(visible = true, transformation(origin = {0, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
74 | equation |
---|
75 | losses = loss0 + slope * u; |
---|
76 | y = u + losses; |
---|
77 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(lineColor= {0, 0, 255}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -100}}), Text(lineColor= {0, 0, 255}, fillColor= {0, 0, 127}, fillPattern= FillPattern.Solid, extent= {{-100, 145}, {98, 105}}, textString= "%name"), Polygon(origin= {-0.9, 2.05}, fillColor= {255, 0, 0}, fillPattern= FillPattern.Solid, points= {{-29.0955, 59.9501}, {26.9045, 59.9501}, {20.9045, -22.0499}, {60.9045, -30.0499}, {-1.09552, -60.0499}, {-61.0955, -28.0499}, {-21.0955, -24.0499}, {-29.0955, 59.9501}})})); |
---|
78 | end AddLosses; |
---|
79 | |
---|
80 | model AddRessLosses "Simplified RESS loss computation" |
---|
81 | //le perdite hanno un termine lineare |
---|
82 | parameter Real fLin = 0.03 "lossPower=flin*|P|+fQuad*P/nomPower^2"; |
---|
83 | parameter Real fQuad = 0.04 "lossPower=flin*|P|+fQuad*P/nomPower^2"; |
---|
84 | parameter Real nomPower = 1e4; |
---|
85 | Modelica.Blocks.Interfaces.RealOutput y annotation(Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -2}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
86 | Modelica.Blocks.Interfaces.RealInput inFlow "input fuel power" annotation(Placement(visible = true, transformation(extent = {{-138, -20}, {-98, 20}}, rotation = 0), iconTransformation(extent = {{-140, -20}, {-100, 20}}, rotation = 0))); |
---|
87 | Modelica.Blocks.Interfaces.RealOutput losses annotation(Placement(visible = true, transformation(origin = {0, -110}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
88 | Real losses1, losses2; |
---|
89 | protected |
---|
90 | Real absInFlow; |
---|
91 | parameter Real smallPow = nomPower / 10; |
---|
92 | equation |
---|
93 | absInFlow = noEvent(abs(inFlow)); |
---|
94 | losses1 = fLin * (absInFlow + smallPow * exp(-absInFlow / smallPow) - smallPow); |
---|
95 | losses2 = fQuad * inFlow * inFlow / nomPower; |
---|
96 | losses = losses1 + losses2; |
---|
97 | y = inFlow - losses; |
---|
98 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(lineColor= {0, 0, 255}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -100}}), Text(lineColor= {0, 0, 255}, fillColor= {0, 0, 127}, fillPattern= FillPattern.Solid, extent= {{-100, 145}, {98, 105}}, textString= "%name"), Polygon(origin= {-0.9, -3.95}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, points= {{-23.1, 53.95}, {22.9, 53.95}, {20.9045, -22.0499}, {56.9, -24.05}, {0.9, -58.05}, {-55.1, -26.05}, {-21.0955, -24.0499}, {-23.1, 53.95}}, lineColor= {0, 0, 0}), Text(extent= {{-100, 36}, {98, -38}}, lineColor= {0, 0, 0}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, textString= "RESS")})); |
---|
99 | end AddRessLosses; |
---|
100 | |
---|
101 | model Driver |
---|
102 | parameter Real gain = 100; |
---|
103 | Modelica.Blocks.Interfaces.RealInput u annotation(Placement(transformation(extent = {{-20, -20}, {20, 20}}, rotation = -90, origin = {60, 120}))); |
---|
104 | Modelica.Blocks.Interfaces.RealOutput y annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {-60, 110}))); |
---|
105 | Modelica.Blocks.Math.Gain gain1(k = gain) annotation(Placement(visible = true, transformation(origin = {-60, 74}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); |
---|
106 | Modelica.Blocks.Math.Feedback feedback annotation(Placement(transformation(extent = {{42, 50}, {22, 30}}))); |
---|
107 | Modelica.Blocks.Sources.Trapezoid trapezoid(amplitude = 10, rising = 5, width = 5, falling = 5, period = 20) annotation(Placement(transformation(extent = {{70, 30}, {50, 50}}))); |
---|
108 | equation |
---|
109 | connect(gain1.y, y) annotation(Line(points = {{-60, 85}, {-60, 110}, {-60, 110}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
110 | connect(gain1.u, feedback.y) annotation(Line(points = {{-60, 62}, {-60, 40}, {23, 40}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
111 | connect(u, feedback.u2) annotation(Line(points = {{60, 120}, {58, 120}, {58, 70}, {32, 70}, {32, 48}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
112 | connect(trapezoid.y, feedback.u1) annotation(Line(points = {{49, 40}, {40, 40}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
113 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, 0}, {100, 100}}), graphics), Icon(coordinateSystem(extent = {{-100, -20}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(lineColor= {0, 0, 127}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -20}}), Text(fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 64}, {100, 26}}, textString= "Driver")})); |
---|
114 | end Driver; |
---|
115 | |
---|
116 | model MechInterface "Ideal Drive" |
---|
117 | parameter Modelica.SIunits.MomentOfInertia J = 1; |
---|
118 | Modelica.Mechanics.Rotational.Interfaces.Flange_a flange annotation(Placement(transformation(extent = {{90, -10}, {110, 10}}))); |
---|
119 | Modelica.Blocks.Interfaces.RealInput genTau annotation(Placement(transformation(extent = {{-20, -20}, {20, 20}}, rotation = 90, origin = {0, -102}), iconTransformation(extent = {{-20, -20}, {20, 20}}, rotation = 90, origin = {0, -102}))); |
---|
120 | Modelica.Mechanics.Rotational.Components.Inertia inertia(J = J) annotation(Placement(transformation(extent = {{60, -10}, {80, 10}}))); |
---|
121 | Modelica.Mechanics.Rotational.Sources.Torque torque annotation(Placement(transformation(extent = {{30, -10}, {50, 10}}))); |
---|
122 | Modelica.Blocks.Interfaces.RealOutput pow annotation(Placement(transformation(extent = {{-100, -10}, {-120, 10}}))); |
---|
123 | equation |
---|
124 | pow = torque.tau * der(flange.phi); |
---|
125 | connect(flange, inertia.flange_b) annotation(Line(points = {{100, 0}, {80, 0}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
126 | connect(inertia.flange_a, torque.flange) annotation(Line(points = {{60, 0}, {50, 0}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
127 | connect(torque.tau, genTau) annotation(Line(points = {{28, 0}, {0, 0}, {0, -102}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
128 | annotation(Diagram(coordinateSystem(extent = {{-100, -80}, {100, 80}}, preserveAspectRatio = false), graphics), Documentation(info = "<html> |
---|
129 | <p>This is a very simplified ideal electric drive. It is composed by a simple inertia and an ideal conversion between electrical and mechanical quantities</p> |
---|
130 | <p>It is useful for usage in simplified models for dynamic optiimisation for electricd and hybrid vehicles.</p> |
---|
131 | </html>"), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Text(origin= {0, 102}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 30}, {98, -1}}, textString= "%name"), Rectangle(origin= {1, 1}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-101, 99}, {99, -101}}), Rectangle(origin= {56, 1}, fillColor= {204, 204, 204}, fillPattern= FillPattern.Solid, extent= {{-42, 6}, {42, -7}}), Ellipse(origin= {11, 0}, fillColor= {156, 156, 156}, fillPattern= FillPattern.Solid, extent= {{-26, 26}, {26, -26}}, endAngle= 360)})); |
---|
132 | end MechInterface; |
---|
133 | |
---|
134 | model DragForce "Vehicle rolling and aerodinamical drag force" |
---|
135 | import Modelica.Constants.g_n; |
---|
136 | extends |
---|
137 | Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2; |
---|
138 | extends Modelica.Mechanics.Translational.Interfaces.PartialFriction; |
---|
139 | Modelica.SIunits.Force f "Total drag force"; |
---|
140 | Modelica.SIunits.Velocity v "vehicle velocity"; |
---|
141 | Modelica.SIunits.Acceleration a "Absolute acceleration of flange"; |
---|
142 | Real Sign; |
---|
143 | parameter Modelica.SIunits.Mass m "vehicle mass"; |
---|
144 | parameter Modelica.SIunits.Density rho(start = 1.226) "air density"; |
---|
145 | parameter Modelica.SIunits.Area S "vehicle cross area"; |
---|
146 | parameter Real fc(start = 0.01) "rolling friction coefficient"; |
---|
147 | parameter Real Cx "aerodinamic drag coefficient"; |
---|
148 | protected |
---|
149 | parameter Real A = fc * m * g_n; |
---|
150 | parameter Real B = 1 / 2 * rho * S * Cx; |
---|
151 | // Constant auxiliary variable |
---|
152 | equation |
---|
153 | // s = flange.s; |
---|
154 | v = der(s); |
---|
155 | a = der(v); |
---|
156 | // Le seguenti definizioni seguono l'ordine e le ridchieste del modello "PartialFriction" di |
---|
157 | // Modelica.Mechanics.Translational.Interfaces" |
---|
158 | v_relfric = v; |
---|
159 | a_relfric = a; |
---|
160 | f0 = A "forza a velocit? 0 ma con scorrimento"; |
---|
161 | f0_max = A "massima forza velocit? 0 e senza scorrimento "; |
---|
162 | free = false "sarebbe true quando la ruota si stacca dalla strada"; |
---|
163 | // Ora il calcolo di f, e la sua attribuzione alla flangia: |
---|
164 | flange.f - f = 0; |
---|
165 | // friction force |
---|
166 | if v > 0 then |
---|
167 | Sign = 1; |
---|
168 | else |
---|
169 | Sign = -1; |
---|
170 | end if; |
---|
171 | f - B * v ^ 2 * Sign = if locked then sa * unitForce else f0 * (if startForward then Modelica.Math.tempInterpol1(v, [0, 1], 2) else if startBackward then -Modelica.Math.tempInterpol1(-v, [0, 1], 2) else if pre(mode) == Forward then Modelica.Math.tempInterpol1(v, [0, 1], 2) else -Modelica.Math.tempInterpol1(-v, [0, 1], 2)); |
---|
172 | annotation(Documentation(info = "<html> |
---|
173 | <p>This component modesl the total (rolling è+ aerrodynamic vehicle drag resistance: </p> |
---|
174 | <p>f=mgh+(1/2)*rho*Cx*S*v^2</p> |
---|
175 | <p>It models reliably the stuck phase. based on Modelica-Intrerfaces.PartialFriction model</p> |
---|
176 | </html>"), Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Polygon(points= {{-98, 10}, {22, 10}, {22, 41}, {92, 0}, {22, -41}, {22, -10}, {-98, -10}, {-98, 10}}, lineColor= {0, 127, 0}, fillColor= {215, 215, 215}, fillPattern= FillPattern.Solid), Line(points= {{-42, -50}, {87, -50}}, color= {0, 0, 0}), Polygon(points= {{-72, -50}, {-41, -40}, {-41, -60}, {-72, -50}}, lineColor= {0, 0, 0}, fillColor= {128, 128, 128}, fillPattern= FillPattern.Solid), Line(points= {{-90, -90}, {-70, -88}, {-50, -82}, {-30, -72}, {-10, -58}, {10, -40}, {30, -18}, {50, 8}, {70, 38}, {90, 72}, {110, 110}}, color= {0, 0, 255}, thickness= 0.5), Text(extent= {{-82, 90}, {80, 50}}, lineColor= {0, 0, 255}, textString= "%name")}), Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics)); |
---|
177 | end DragForce; |
---|
178 | |
---|
179 | model LossMechInterface "Ideal Drive" |
---|
180 | parameter Modelica.SIunits.MomentOfInertia J = 1; |
---|
181 | parameter Modelica.SIunits.Voltage uBase "base voltage (rms per phase)"; |
---|
182 | parameter Modelica.SIunits.AngularVelocity wBase "base angular speed"; |
---|
183 | parameter Modelica.SIunits.Power constLoss; |
---|
184 | //perdite di cummutazione (assunte costanti) |
---|
185 | parameter Modelica.SIunits.Voltage lossFact = 4; |
---|
186 | //perdite di on-state (W/A) |
---|
187 | Modelica.SIunits.Current current "estimated AC current"; |
---|
188 | // Modelica.SIunits.Power loss "lost power"; |
---|
189 | Modelica.SIunits.AngularVelocity wMecc "base angular speed"; |
---|
190 | Modelica.SIunits.Power mechPow "mechanical power"; |
---|
191 | Modelica.Mechanics.Rotational.Interfaces.Flange_a flange annotation(Placement(transformation(extent = {{90, -10}, {110, 10}}))); |
---|
192 | Modelica.Blocks.Interfaces.RealInput genTau annotation(Placement(transformation(extent = {{-20, -20}, {20, 20}}, rotation = 90, origin = {0, -102}), iconTransformation(extent = {{-20, -20}, {20, 20}}, rotation = 90, origin = {0, -102}))); |
---|
193 | Modelica.Mechanics.Rotational.Components.Inertia inertia(J = J) annotation(Placement(transformation(extent = {{60, -10}, {80, 10}}))); |
---|
194 | Modelica.Mechanics.Rotational.Sources.Torque torque annotation(Placement(transformation(extent = {{30, -10}, {50, 10}}))); |
---|
195 | Modelica.Blocks.Interfaces.RealOutput pow annotation(Placement(transformation(extent = {{-100, -10}, {-120, 10}}))); |
---|
196 | Modelica.Blocks.Interfaces.RealOutput losses annotation(Placement(visible = true, transformation(origin = {0, 110}, extent = {{-10, -10}, {10, 10}}, rotation = 90), iconTransformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {0, 110}))); |
---|
197 | equation |
---|
198 | wMecc = der(flange.phi); |
---|
199 | mechPow = torque.tau * wMecc; |
---|
200 | current = noEvent(abs(mechPow * abs(wBase / (abs(wMecc) + 0.01) / uBase / 3))); |
---|
201 | losses = constLoss + lossFact * current; |
---|
202 | pow = losses + mechPow; |
---|
203 | connect(flange, inertia.flange_b) annotation(Line(points = {{100, 0}, {80, 0}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
204 | connect(inertia.flange_a, torque.flange) annotation(Line(points = {{60, 0}, {50, 0}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
205 | connect(torque.tau, genTau) annotation(Line(points = {{28, 0}, {0, 0}, {0, -102}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
206 | annotation(Diagram(coordinateSystem(extent = {{-100, -80}, {100, 80}}, preserveAspectRatio = false), graphics), Documentation(info = "<html> |
---|
207 | <p>This is a very simplified ideal electric drive. It is composed by a simple inertia and an ideal conversion between electrical and mechanical quantities</p> |
---|
208 | <p>It is useful for usage in simplified models for dynamic optiimisation for electricd and hybrid vehicles.</p> |
---|
209 | </html>"), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -100}}), Polygon(origin= {-0.9, 36.05}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, points= {{-19.1, -0.05}, {20.9, -0.05}, {20.9, 25.95}, {56.9, 24.05}, {0.9, 58.05}, {-55.1, 26.05}, {-19.1, 27.95}, {-19.1, -0.05}}), Text(fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, -32}, {98, -70}}, textString= "%name"), Rectangle(origin= {60, 1}, fillColor= {204, 204, 204}, fillPattern= FillPattern.Solid, extent= {{-42, 6}, {42, -7}}), Ellipse(origin= {15, 0}, fillColor= {156, 156, 156}, fillPattern= FillPattern.Solid, extent= {{-26, 26}, {26, -26}}, endAngle= 360)})); |
---|
210 | end LossMechInterface; |
---|
211 | |
---|
212 | model PropDriver "Simple Proportional controller driver" |
---|
213 | parameter String CycleFileName = "MyCycleName.txt" |
---|
214 | "Drive Cycle Name ex: \"sort1.txt\""; |
---|
215 | parameter Real k "Controller gain"; |
---|
216 | Modelica.Blocks.Interfaces.RealOutput tauRef(unit = "N.m") annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {0, 70}), iconTransformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {0, 110}))); |
---|
217 | Modelica.Blocks.Sources.CombiTimeTable driveCyc(tableOnFile = true, tableName = "Cycle", extrapolation = Modelica.Blocks.Types.Extrapolation.Periodic, fileName = CycleFileName, columns = {2}) annotation(Placement(transformation(extent = {{-86, -30}, {-66, -10}}))); |
---|
218 | Modelica.Blocks.Math.UnitConversions.From_kmh from_kmh annotation(Placement(transformation(extent = {{-48, -30}, {-28, -10}}))); |
---|
219 | Modelica.Blocks.Math.Feedback feedback annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {0, 0}))); |
---|
220 | Modelica.Blocks.Math.Gain gain(k = k) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {0, 40}))); |
---|
221 | Modelica.Blocks.Interfaces.RealInput V annotation(Placement(visible = true, transformation(origin = {114, 2}, extent = {{-14, -14}, {14, 14}}, rotation = 180), iconTransformation(origin = {112, 0}, extent = {{-12, -12}, {12, 12}}, rotation = 180))); |
---|
222 | equation |
---|
223 | connect(feedback.u2, V) annotation(Line(points = {{8, -8.88178e-016}, {8, 2}, {114, 2}}, color = {0, 0, 127})); |
---|
224 | connect(from_kmh.u, driveCyc.y[1]) annotation(Line(points = {{-50, -20}, {-65, -20}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
225 | connect(from_kmh.y, feedback.u1) annotation(Line(points = {{-27, -20}, {-14, -20}, {-14, -20}, {0, -20}, {0, -8}, {-8.88178e-016, -8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
226 | connect(feedback.y, gain.u) annotation(Line(points = {{0, 9}, {0, 10}, {0, 10}, {0, 8}, {0, 28}, {-8.88178e-016, 28}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
227 | connect(gain.y, tauRef) annotation(Line(points = {{6.66134e-016, 51}, {0, 51}, {0, 70}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
228 | annotation(Documentation(info = "<html> |
---|
229 | <p>Modello semplice di pilota.</p> |
---|
230 | <p>Esso contiene al suo interno il ciclo di riferimento, che insegue attraverso un regolatore solo proporzionale.</p> |
---|
231 | </html>"), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -100}}), Ellipse(fillColor= {255, 213, 170}, fillPattern= FillPattern.Solid, extent= {{-23, 46}, {-12, 20}}, endAngle= 360), Text(origin= {2, -250.189}, lineColor= {0, 0, 255}, extent= {{-104, 142.189}, {98, 104}}, textString= "%name"), Polygon(fillColor= {215, 215, 215}, pattern= LinePattern.None, fillPattern= FillPattern.Solid, points= {{-22, -36}, {-42, -64}, {-16, -64}, {16, -64}, {-22, -36}}), Polygon(fillColor= {135, 135, 135}, pattern= LinePattern.None, fillPattern= FillPattern.Solid, points= {{-32, 64}, {-62, -28}, {-30, -28}, {-30, -28}, {-32, 64}}, smooth= Smooth.Bezier), Polygon(fillColor= {135, 135, 135}, pattern= LinePattern.None, fillPattern= FillPattern.Solid, points= {{-68, -12}, {-14, -66}, {10, -26}, {0, -26}, {-68, -12}}, smooth= Smooth.Bezier), Polygon(fillColor= {175, 175, 175}, fillPattern= FillPattern.Solid, points= {{-22, 34}, {-30, 30}, {-40, -24}, {2, -22}, {2, -10}, {0, 26}, {-22, 34}}, smooth= Smooth.Bezier), Ellipse(fillColor= {255, 213, 170}, fillPattern= FillPattern.Solid, extent= {{-30, 68}, {-3, 34}}, endAngle= 360), Polygon(pattern= LinePattern.None, fillPattern= FillPattern.Solid, points= {{-38, 58}, {-16, 74}, {-2, 60}, {4, 60}, {6, 60}, {-38, 58}}, smooth= Smooth.Bezier), Polygon(fillColor= {95, 95, 95}, fillPattern= FillPattern.Solid, points= {{30, -20}, {-32, -4}, {-36, -20}, {-24, -34}, {30, -20}}, smooth= Smooth.Bezier), Polygon(fillPattern= FillPattern.Solid, points= {{42, -46}, {36, -60}, {48, -54}, {52, -48}, {50, -44}, {42, -46}}, smooth= Smooth.Bezier), Line(points= {{48, 10}, {26, 24}, {26, 24}}, thickness= 0.5), Line(points= {{20, 14}, {34, 34}, {34, 34}}, thickness= 0.5), Polygon(fillColor= {255, 213, 170}, fillPattern= FillPattern.Solid, points= {{28, 28}, {32, 32}, {28, 26}, {34, 30}, {30, 26}, {34, 28}, {30, 24}, {26, 26}, {34, 24}, {26, 24}, {26, 26}, {28, 28}, {28, 28}, {26, 26}, {26, 26}, {26, 26}, {28, 32}, {28, 30}, {28, 28}}, smooth= Smooth.Bezier), Polygon(fillColor= {175, 175, 175}, fillPattern= FillPattern.Solid, points= {{-18, 24}, {28, 30}, {26, 22}, {-16, 8}, {-20, 8}, {-24, 18}, {-18, 24}}, smooth= Smooth.Bezier), Polygon(fillColor= {215, 215, 215}, fillPattern= FillPattern.Solid, points= {{72, 18}, {48, 18}, {36, -2}, {58, -62}, {72, -62}, {72, 18}}), Polygon(fillColor= {95, 95, 95}, fillPattern= FillPattern.Solid, points= {{49, -70}, {17, -16}, {7, -20}, {-1, -26}, {49, -70}}, smooth= Smooth.Bezier), Line(points= {{-7, 55}, {-3, 53}}), Line(points= {{-9, 42}, {-5, 42}}), Line(points= {{-7, 55}, {-3, 55}})}), Diagram(coordinateSystem(extent = {{-100, -60}, {100, 60}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics)); |
---|
232 | end PropDriver; |
---|
233 | |
---|
234 | model Storage |
---|
235 | Real energy(min = 0, max = nomEnergy, start = energyIni, fixed = true); |
---|
236 | parameter Real nomEnergy = 500 "Nominal Energy (Wh)"; |
---|
237 | parameter Real nomPower = 500 "Nominal Power (W)"; |
---|
238 | parameter Real energyIni = 100 "Initial Energy (Wh)"; |
---|
239 | protected |
---|
240 | Real energyJoule = 3600 * energy "Energy in joules"; |
---|
241 | public |
---|
242 | Modelica.Blocks.Interfaces.RealInput inFlow annotation(Placement(transformation(extent = {{-140, -20}, {-100, 20}}))); |
---|
243 | Modelica.Blocks.Interfaces.RealOutput loe annotation(Placement(transformation(extent = {{100, -10}, {120, 10}}))); |
---|
244 | equation |
---|
245 | der(energyJoule) = inFlow; |
---|
246 | loe = energy / nomEnergy; |
---|
247 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Rectangle(fillColor= {85, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-68, 28}, {72, -70}}), Rectangle(extent= {{-100, 100}, {100, -100}}), Line(points= {{-68, 64}, {-68, -70}, {72, -70}, {72, 64}}), Line(points= {{-68, 28}, {72, 28}}), Line(points= {{-28, 20}, {34, 20}}), Line(points= {{-10, 14}, {12, 14}}), Text(origin= {5, 72.6667}, extent= {{-105, 17.3334}, {93, -10.6667}}, textString= "Pn=%nomPower"), Text(origin= {7, -45.3333}, extent= {{-105, 19.3334}, {93, -8.66668}}, textString= "En=%nomEnergy"), Text(origin= {1, 125}, lineColor= {0, 0, 255}, extent= {{-100, 20}, {100, -20}}, textString= "%name")})); |
---|
248 | end Storage; |
---|
249 | |
---|
250 | model AddPcLossesOO |
---|
251 | "Adds Primary Converter Losses, considering On/Off input signal" |
---|
252 | Modelica.Blocks.Interfaces.BooleanInput n "On Signal" annotation(Placement(transformation(extent = {{-140, -80}, {-100, -40}}))); |
---|
253 | Modelica.Blocks.Interfaces.RealInput u "mechanical outpu PC power" annotation(Placement(transformation(extent = {{-140, 40}, {-100, 80}}))); |
---|
254 | Modelica.Blocks.Logical.Switch switch2 annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 0, origin = {38, 0}))); |
---|
255 | AddPcLosses addPcLosses annotation(Placement(transformation(extent = {{-60, 50}, {-40, 70}}))); |
---|
256 | Modelica.Blocks.Interfaces.RealOutput y annotation(Placement(transformation(extent = {{100, -10}, {120, 10}}))); |
---|
257 | Modelica.Blocks.Interfaces.RealOutput losses annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = -90, origin = {0, -110}), iconTransformation(extent = {{-10, -10}, {10, 10}}, rotation = -90, origin = {-4, -110}))); |
---|
258 | Modelica.Blocks.Sources.Constant const annotation(Placement(transformation(extent = {{-10, -38}, {10, -18}}))); |
---|
259 | equation |
---|
260 | connect(addPcLosses.losses, losses) annotation(Line(points = {{-50, 49}, {-50, -78}, {0, -78}, {0, -110}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
261 | connect(addPcLosses.u, u) annotation(Line(points = {{-62, 60}, {-120, 60}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
262 | connect(const.y, switch2.u3) annotation(Line(points = {{11, -28}, {16, -28}, {16, -8}, {26, -8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
263 | connect(n, switch2.u2) annotation(Line(points = {{-120, -60}, {-72, -60}, {-72, 0}, {26, 0}}, color = {255, 0, 255}, smooth = Smooth.None)); |
---|
264 | connect(switch2.u1, addPcLosses.y) annotation(Line(points = {{26, 8}, {0, 8}, {0, 59.8}, {-39, 59.8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
265 | connect(switch2.y, y) annotation(Line(points = {{49, 0}, {110, 0}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
266 | annotation(Diagram(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics), Icon(coordinateSystem(preserveAspectRatio = false, extent = {{-100, -100}, {100, 100}}), graphics = {Rectangle(lineColor= {0, 0, 255}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-100, 100}, {100, -100}}), Polygon(origin= {-0.9, 2.05}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, points= {{-23.1, 53.95}, {22.9, 53.95}, {20.9045, -22.0499}, {56.9, -24.05}, {0.9, -58.05}, {-55.1, -26.05}, {-21.0955, -24.0499}, {-23.1, 53.95}}, lineColor= {0, 0, 0}), Text(extent= {{-100, 28}, {100, -44}}, lineColor= {0, 0, 0}, fillColor= {255, 85, 85}, fillPattern= FillPattern.Solid, textString= "PC |
---|
267 | OO")})); |
---|
268 | end AddPcLossesOO; |
---|
269 | |
---|
270 | model AVG "Sensor to measure the average value of input" |
---|
271 | Modelica.Blocks.Interfaces.RealInput u annotation(Placement(transformation(extent = {{-138, -12}, {-98, 28}}), iconTransformation(extent = {{-140, -20}, {-100, 20}}))); |
---|
272 | Modelica.Blocks.Interfaces.RealOutput y annotation(Placement(transformation(extent = {{100, 0}, {120, 20}}), iconTransformation(extent = {{100, -10}, {120, 10}}))); |
---|
273 | Modelica.Blocks.Continuous.Integrator integrator annotation(Placement(transformation(extent = {{-60, -2}, {-40, 18}}))); |
---|
274 | Modelica.Blocks.Math.Add add(k2 = -1) annotation(Placement(transformation(extent = {{12, 0}, {32, 20}}))); |
---|
275 | Modelica.Blocks.Nonlinear.FixedDelay fixedDelay1(delayTime = 1 / Frequency) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 0, origin = {-14, -22}))); |
---|
276 | Modelica.Blocks.Math.Gain gain(k = Frequency) annotation(Placement(transformation(extent = {{52, 0}, {72, 20}}))); |
---|
277 | parameter Modelica.SIunits.Frequency Frequency = 50. |
---|
278 | "Frequency of signals"; |
---|
279 | equation |
---|
280 | connect(integrator.u, u) annotation(Line(points = {{-62, 8}, {-118, 8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
281 | connect(add.u1, integrator.y) annotation(Line(points = {{10, 16}, {-14, 16}, {-14, 8}, {-39, 8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
282 | connect(fixedDelay1.y, add.u2) annotation(Line(points = {{-3, -22}, {4, -22}, {4, 4}, {10, 4}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
283 | connect(fixedDelay1.u, integrator.y) annotation(Line(points = {{-26, -22}, {-28, -22}, {-28, 8}, {-39, 8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
284 | connect(gain.u, add.y) annotation(Line(points = {{50, 10}, {33, 10}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
285 | connect(gain.y, y) annotation(Line(points = {{73, 10}, {110, 10}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
286 | annotation(Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}, grid = {2, 2}), graphics = {Text(extent= {{150, 80}, {-150, 120}}, textString= "%name", lineColor= {0, 0, 255}), Rectangle(extent= {{-100, 60}, {100, -60}}, lineColor= {0, 0, 127}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid), Text(extent= {{-100, 32}, {98, -24}}, lineColor= {0, 0, 127}, textString= "AVG")}), Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}, grid = {2, 2}), graphics), Documentation(info = "<html><p> |
---|
287 | This power sensor measures instantaneous electrical power of a singlephase system and has a separated voltage and current path. The pins of the voltage path are <code>pv</code> and <code>nv</code>, the pins of the current path are <code>pc</code> and <code>nc</code>. The internal resistance of the current path is zero, the internal resistance of the voltage path is infinite. |
---|
288 | </p> |
---|
289 | </html>", revisions = "<html> |
---|
290 | <ul> |
---|
291 | <li><i> January 12, 2006 </i> |
---|
292 | by Anton Haumer<br> implemented<br> |
---|
293 | </li> |
---|
294 | </ul> |
---|
295 | </html>")); |
---|
296 | end AVG; |
---|
297 | end Components; |
---|
298 | |
---|
299 | package DO "Dynamic Optimization models" |
---|
300 | model DOHev1 |
---|
301 | //Sequenza righe: parametri, input, obiettivo, vincoli. |
---|
302 | parameter Real p = 1 "required for optimization"; |
---|
303 | parameter Real loeInit = 0.5; |
---|
304 | input Real pcPower(min = 0, nominal = 1e4, max = 1e4); |
---|
305 | Real pcEnergy(nominal = 1000) = toPcEnergy.y "minimize pcEnergy(tf)" annotation(isLagrange = true); |
---|
306 | Real finalLOE(min = loeInit, max = loeInit) = p * storage.loe annotation(isFinalConstraint = true); |
---|
307 | // |
---|
308 | Modelica.Blocks.Math.Add add(k2 = -1) annotation(Placement(visible = true, transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {-58, 22}))); |
---|
309 | Modelica.Blocks.Continuous.Integrator toEnFlow annotation(Placement(visible = true, transformation(extent = {{-84, 26}, {-104, 46}}, rotation = 0))); |
---|
310 | Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque tauRes(w_nominal(displayUnit = "rpm") = 104.71975511966, tau_nominal = -100, phi(nominal = 1e3)) annotation(Placement(transformation(extent = {{64, 18}, {44, 38}}))); |
---|
311 | Modelica.Blocks.Sources.Trapezoid trapezoid(amplitude = 100, rising = 50, width = 50, falling = 50, period = 200) annotation(Placement(transformation(extent = {{62, -40}, {42, -20}}))); |
---|
312 | Modelica.Blocks.Math.Feedback feedback annotation(Placement(transformation(extent = {{30, -20}, {10, -40}}))); |
---|
313 | Modelica.Mechanics.Rotational.Sensors.SpeedSensor wLoad annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = -90, origin = {20, 8}))); |
---|
314 | Modelica.Blocks.Math.Gain gain1(k = 50) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {0, -12}))); |
---|
315 | Components.MechInterface idealDrive annotation(Placement(transformation(extent = {{-16, 18}, {4, 38}}))); |
---|
316 | Components.Storage storage(nomPower = 1000, energyIni = 500, nomEnergy = 1000) annotation(Placement(visible = true, transformation(origin = {-94, -4}, extent = {{10, -10}, {-10, 10}}, rotation = 0))); |
---|
317 | Modelica.Blocks.Sources.RealExpression pcPower_(y = pcPower) annotation(Placement(visible = true, transformation(origin = {-62, -38}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); |
---|
318 | Modelica.Blocks.Continuous.Integrator toPcEnergy annotation(Placement(visible = true, transformation(origin = {60, -58}, extent = {{-104, 26}, {-84, 46}}, rotation = 0))); |
---|
319 | equation |
---|
320 | connect(pcPower_.y, add.u1) annotation(Line(points = {{-62, -27}, {-62, -1.5}, {-38, -1.5}, {-38, 15.25}, {-46, 15.25}, {-46, 16}}, color = {0, 0, 127})); |
---|
321 | connect(toPcEnergy.u, pcPower_.y) annotation(Line(points = {{-46, -22}, {-62, -22}, {-62, -27}}, color = {0, 0, 127})); |
---|
322 | connect(toEnFlow.u, storage.inFlow) annotation(Line(points = {{-82, 36}, {-76, 36}, {-76, 22}, {-78, 22}, {-78, -4}, {-82, -4}}, color = {0, 0, 127})); |
---|
323 | connect(add.y, storage.inFlow) annotation(Line(points = {{-69, 22}, {-78, 22}, {-78, -4}, {-82, -4}}, color = {0, 0, 127})); |
---|
324 | connect(trapezoid.y, feedback.u1) annotation(Line(points = {{41, -30}, {28, -30}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
325 | connect(wLoad.w, feedback.u2) annotation(Line(points = {{20, -3}, {20, -22}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
326 | connect(gain1.u, feedback.y) annotation(Line(points = {{-6.66134e-016, -24}, {-6.66134e-016, -30}, {11, -30}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
327 | connect(idealDrive.flange, tauRes.flange) annotation(Line(points = {{4, 28}, {44, 28}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
328 | connect(wLoad.flange, tauRes.flange) annotation(Line(points = {{20, 18}, {20, 28}, {44, 28}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
329 | connect(gain1.y, idealDrive.genTau) annotation(Line(points = {{8.88178e-016, -1}, {8.88178e-016, 8}, {-6, 8}, {-6, 17.8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
330 | connect(idealDrive.pow, add.u2) annotation(Line(points = {{-17, 28}, {-46, 28}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
331 | annotation(Icon(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), __Dymola_experimentSetupOutput, Documentation(info = "<html> |
---|
332 | <p>Modello di sistema con rete-carico-accumulo per trovare la legge di ottimizzazione dinamica.</p> |
---|
333 | <p>Le potenze sono in kW, le energie in kWh, i costi in €/kh, il tempo in h.</p> |
---|
334 | <p>Una simulazione di 24 h dà quindi conto di un andamento giornaliero.</p> |
---|
335 | <p>La versione da usare effettivamente per l'ttimizzazione è la SystemDO, che non ha l'inflow come input assegnato, ma lasciato in gestione all'ottimizzatore. </p> |
---|
336 | </html>"), Diagram(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Text(origin= {-30, 10}, lineColor= {0, 0, 255}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-82, -30}, {-38, -40}}, textString= "battery: |
---|
337 | 1000W- 1000Wh")}), experiment(StartTime = 0, StopTime = 120, Tolerance = 0.0001, Interval = 0.5)); |
---|
338 | end DOHev1; |
---|
339 | |
---|
340 | model OOInertia |
---|
341 | //Sequenza righe: parametri, input, obiettivo, vincoli. |
---|
342 | parameter Real p = 1 "required for optimization"; |
---|
343 | parameter Real loeInit = 0.5; |
---|
344 | input Real pcPower(min = 0, nominal = 1e4, max = 1e4); |
---|
345 | Real pcEnergy(nominal = 1000) = toPcEnergy.y "minimize pcEnergy(tf)" annotation(isLagrange = true); |
---|
346 | Real finalLOE(min = loeInit, max = loeInit) = p * storage.loe annotation(isFinalConstraint = true); |
---|
347 | // |
---|
348 | Modelica.Blocks.Math.Add add(k2 = -1) annotation(Placement(visible = true, transformation(extent = {{-10, -10}, {10, 10}}, rotation = 180, origin = {-58, 22}))); |
---|
349 | Modelica.Blocks.Continuous.Integrator toEnFlow annotation(Placement(visible = true, transformation(extent = {{-84, 26}, {-104, 46}}, rotation = 0))); |
---|
350 | Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque tauRes(w_nominal(displayUnit = "rpm") = 104.71975511966, tau_nominal = -100, phi(nominal = 1e3)) annotation(Placement(transformation(extent = {{64, 18}, {44, 38}}))); |
---|
351 | Modelica.Blocks.Sources.Trapezoid trapezoid(amplitude = 100, rising = 50, width = 50, falling = 50, period = 200) annotation(Placement(transformation(extent = {{62, -40}, {42, -20}}))); |
---|
352 | Modelica.Blocks.Math.Feedback feedback annotation(Placement(transformation(extent = {{30, -20}, {10, -40}}))); |
---|
353 | Modelica.Mechanics.Rotational.Sensors.SpeedSensor wLoad annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = -90, origin = {20, 8}))); |
---|
354 | Modelica.Blocks.Math.Gain gain1(k = 50) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 90, origin = {0, -12}))); |
---|
355 | Components.MechInterface idealDrive annotation(Placement(transformation(extent = {{-16, 18}, {4, 38}}))); |
---|
356 | Components.Storage storage(nomPower = 1000, energyIni = 500, nomEnergy = 1000) annotation(Placement(visible = true, transformation(origin = {-94, -4}, extent = {{10, -10}, {-10, 10}}, rotation = 0))); |
---|
357 | Modelica.Blocks.Sources.RealExpression pcPower_(y = pcPower) annotation(Placement(visible = true, transformation(origin = {-62, -38}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); |
---|
358 | Modelica.Blocks.Continuous.Integrator toPcEnergy annotation(Placement(visible = true, transformation(origin = {60, -58}, extent = {{-104, 26}, {-84, 46}}, rotation = 0))); |
---|
359 | equation |
---|
360 | connect(pcPower_.y, add.u1) annotation(Line(points = {{-62, -27}, {-62, -1.5}, {-38, -1.5}, {-38, 15.25}, {-46, 15.25}, {-46, 16}}, color = {0, 0, 127})); |
---|
361 | connect(toPcEnergy.u, pcPower_.y) annotation(Line(points = {{-46, -22}, {-62, -22}, {-62, -27}}, color = {0, 0, 127})); |
---|
362 | connect(toEnFlow.u, storage.inFlow) annotation(Line(points = {{-82, 36}, {-76, 36}, {-76, 22}, {-78, 22}, {-78, -4}, {-82, -4}}, color = {0, 0, 127})); |
---|
363 | connect(add.y, storage.inFlow) annotation(Line(points = {{-69, 22}, {-78, 22}, {-78, -4}, {-82, -4}}, color = {0, 0, 127})); |
---|
364 | connect(trapezoid.y, feedback.u1) annotation(Line(points = {{41, -30}, {28, -30}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
365 | connect(wLoad.w, feedback.u2) annotation(Line(points = {{20, -3}, {20, -22}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
366 | connect(gain1.u, feedback.y) annotation(Line(points = {{-6.66134e-016, -24}, {-6.66134e-016, -30}, {11, -30}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
367 | connect(idealDrive.flange, tauRes.flange) annotation(Line(points = {{4, 28}, {44, 28}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
368 | connect(wLoad.flange, tauRes.flange) annotation(Line(points = {{20, 18}, {20, 28}, {44, 28}}, color = {0, 0, 0}, smooth = Smooth.None)); |
---|
369 | connect(gain1.y, idealDrive.genTau) annotation(Line(points = {{8.88178e-016, -1}, {8.88178e-016, 8}, {-6, 8}, {-6, 17.8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
370 | connect(idealDrive.pow, add.u2) annotation(Line(points = {{-17, 28}, {-46, 28}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
371 | annotation(Icon(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), __Dymola_experimentSetupOutput, Documentation(info = "<html> |
---|
372 | <p>Modello di sistema con rete-carico-accumulo per trovare la legge di ottimizzazione dinamica.</p> |
---|
373 | <p>Le potenze sono in kW, le energie in kWh, i costi in €/kh, il tempo in h.</p> |
---|
374 | <p>Una simulazione di 24 h dà quindi conto di un andamento giornaliero.</p> |
---|
375 | <p>La versione da usare effettivamente per l'ttimizzazione è la SystemDO, che non ha l'inflow come input assegnato, ma lasciato in gestione all'ottimizzatore. </p> |
---|
376 | </html>"), Diagram(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics = {Text(origin= {-30, 10}, lineColor= {0, 0, 255}, fillColor= {255, 255, 255}, fillPattern= FillPattern.Solid, extent= {{-82, -30}, {-38, -40}}, textString= "battery: |
---|
377 | 1000W- 1000Wh")}), experiment(StartTime = 0, StopTime = 120, Tolerance = 0.0001, Interval = 0.5)); |
---|
378 | end OOInertia; |
---|
379 | |
---|
380 | model ThreeLosses |
---|
381 | //Sequenza righe: parametri, input, obiettivo, vincoli. |
---|
382 | parameter Real p = 1 "required for optimization"; |
---|
383 | parameter Real loeInit = 0.5; |
---|
384 | input Real pcPower(min = 0, nominal = 1e4, max = 1e4); |
---|
385 | // Real totEnergy(nominal = 1000) = to_kWh.y "minimize totEnergy(tf)" annotation(isLagrange = true); |
---|
386 | Real pcEnergy(nominal = 1000) = to_kWh.y "minimize pcEnergy(tf)" annotation(isLagrange = true); |
---|
387 | Real finalLOE(min = loeInit, max = loeInit) = p * storage.loe annotation(isFinalConstraint = true); |
---|
388 | Real pcLosses10 = addPcL.losses / 10 "PC losses divided by 10"; |
---|
389 | // Real enPC, enRESS, enEleDrive; |
---|
390 | // |
---|
391 | OOInertia.Components.PropDriver propdriver1(CycleFileName = "SimplifEce15.txt", k = 1000) annotation(Placement(visible = true, transformation(origin = {-14, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
392 | Modelica.Mechanics.Translational.Sensors.SpeedSensor speedSensor annotation(Placement(visible = true, transformation(origin = {18, 8}, extent = {{10, -10}, {-10, 10}}, rotation = 0))); |
---|
393 | Modelica.Blocks.Sources.RealExpression pcPower_(y = pcPower) annotation(Placement(visible = true, transformation(origin = {-92, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
394 | Components.AddPcLosses addPcL annotation(Placement(visible = true, transformation(origin = {-88, 20}, extent = {{10, -10}, {-10, 10}}, rotation = 90))); |
---|
395 | Components.LossMechInterface mechInterface(J = 4, uBase = 230, wBase = 157, constLoss = 50) annotation(Placement(visible = true, transformation(extent = {{-32, 32}, {-12, 52}}, rotation = 0))); |
---|
396 | Modelica.Blocks.Math.Add add(k2 = -1) annotation(Placement(visible = true, transformation(origin = {-52, 24}, extent = {{-10, 10}, {10, -10}}, rotation = 270))); |
---|
397 | Modelica.Mechanics.Rotational.Components.IdealRollingWheel wheel(radius = 0.31) annotation(Placement(visible = true, transformation(origin = {24, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
398 | Modelica.Mechanics.Translational.Components.Mass mass1(m = 1400) annotation(Placement(visible = true, transformation(origin = {54, 32}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
399 | Modelica.Blocks.Continuous.Integrator to_kWh(k = 1 / 3.6e6) annotation(Placement(visible = true, transformation(origin = {-88, -22}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); |
---|
400 | Components.DragForce dragForce(m = 1400, rho = 1.226, S = 2.2, fc = 0.014, Cx = 0.26) annotation(Placement(visible = true, transformation(origin = {54, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); |
---|
401 | Components.Storage storage(nomPower = 1000, energyIni = 500, nomEnergy = 1000) annotation(Placement(visible = true, transformation(origin = {-48, -38}, extent = {{10, -10}, {-10, 10}}, rotation = 90))); |
---|
402 | Components.AddRessLosses addRessL annotation(Placement(visible = true, transformation(origin = {-48, -8}, extent = {{-10, 10}, {10, -10}}, rotation = -90))); |
---|
403 | equation |
---|
404 | // der(enPC) = addPcL.losses; |
---|
405 | // der(enRESS) = addRessL.losses; |
---|
406 | // der(enEleDrive) = mechInterface.losses; |
---|
407 | connect(addRessL.inFlow, add.y) annotation(Line(points = {{-48, 4}, {-52, 4}, {-52, 14}, {-52, 13}}, color = {0, 0, 127})); |
---|
408 | connect(addRessL.y, storage.inFlow) annotation(Line(points = {{-47.8, -19}, {-47.8, -22}, {-48, -22}, {-48, -26}}, color = {0, 0, 127})); |
---|
409 | connect(addPcL.u, add.u1) annotation(Line(points = {{-88, 32}, {-88, 32}, {-88, 44}, {-58, 44}, {-58, 36}}, color = {0, 0, 127})); |
---|
410 | connect(mass1.flange_b, dragForce.flange) annotation(Line(points = {{54, 22}, {54, 4}}, color = {0, 127, 0})); |
---|
411 | connect(mass1.flange_a, wheel.flangeT) annotation(Line(points = {{54, 42}, {34, 42}}, color = {0, 127, 0})); |
---|
412 | connect(speedSensor.flange, mass1.flange_b) annotation(Line(points = {{28, 8}, {54, 8}, {54, 22}, {54, 22}}, color = {0, 127, 0})); |
---|
413 | connect(wheel.flangeR, mechInterface.flange) annotation(Line(points = {{14, 42}, {-12, 42}})); |
---|
414 | connect(mechInterface.pow, add.u2) annotation(Line(points = {{-33, 42}, {-46, 42}, {-46, 36}}, color = {0, 0, 127})); |
---|
415 | connect(pcPower_.y, add.u1) annotation(Line(points = {{-81, 50}, {-58, 50}, {-58, 36}}, color = {0, 0, 127})); |
---|
416 | connect(propdriver1.tauRef, mechInterface.genTau) annotation(Line(points = {{-14, 19}, {-14, 25.5}, {-22, 25.5}, {-22, 31.8}}, color = {0, 0, 127})); |
---|
417 | connect(speedSensor.v, propdriver1.V) annotation(Line(points = {{7, 8}, {-2.8, 8}}, color = {0, 0, 127})); |
---|
418 | connect(addPcL.y, to_kWh.u) annotation(Line(points = {{-87.8, 9}, {-88, 9}, {-88, -10}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
419 | annotation(__Dymola_experimentSetupOutput, Documentation(info = "<html> |
---|
420 | <p>Modello di sistema con rete-carico-accumulo per trovare la legge di ottimizzazione dinamica.</p> |
---|
421 | <p>Le potenze sono in kW, le energie in kWh, i costi in €/kh, il tempo in h.</p> |
---|
422 | <p>Una simulazione di 24 h dà quindi conto di un andamento giornaliero.</p> |
---|
423 | <p>La versione da usare effettivamente per l'ttimizzazione è la SystemDO, che non ha l'inflow come input assegnato, ma lasciato in gestione all'ottimizzatore. </p> |
---|
424 | </html>"), Icon(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics), experiment(StartTime = 0, StopTime = 195, Tolerance = 1e-07, Interval = 0.65)); |
---|
425 | end ThreeLosses; |
---|
426 | |
---|
427 | model OneLoss |
---|
428 | //Sequenza righe: parametri, input, obiettivo, vincoli. |
---|
429 | parameter Real p = 1 "required for optimization"; |
---|
430 | parameter Real loeInit = 0.5; |
---|
431 | input Real pcPower(min = 0, nominal = 1e4, max = 1e4); |
---|
432 | Real pcEnergy(nominal = 1000) = toPcEn.y "minimize pcEnergy(tf)" annotation(isLagrange = true); |
---|
433 | Real finalLOE(min = loeInit, max = loeInit) = p * storage.loe annotation(isFinalConstraint = true); |
---|
434 | // |
---|
435 | Modelica.Mechanics.Rotational.Sensors.SpeedSensor wLoad annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = -90, origin = {28, 20}))); |
---|
436 | Modelica.Blocks.Math.Add add(k2 = -1) annotation(Placement(visible = true, transformation(origin = {-34, 20}, extent = {{-10, 10}, {10, -10}}, rotation = 270))); |
---|
437 | Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque tauRes(w_nominal(displayUnit = "rpm") = 104.71975511966, tau_nominal = -100, phi(nominal = 1e3)) annotation(Placement(visible = true, transformation(extent = {{64, 28}, {44, 48}}, rotation = 0))); |
---|
438 | Components.Storage storage(nomPower = 1000, energyIni = 500, nomEnergy = 1000, fQuad = 0) annotation(Placement(visible = true, transformation(origin = {-34, -14}, extent = {{10, -10}, {-10, 10}}, rotation = 90))); |
---|
439 | Components.MechInterface mechInterface(J = 4) annotation(Placement(visible = true, transformation(extent = {{-14, 28}, {6, 48}}, rotation = 0))); |
---|
440 | Modelica.Blocks.Sources.RealExpression pcPower_(y = pcPower) annotation(Placement(visible = true, transformation(origin = {-102, 38}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); |
---|
441 | Components.AddPcLosses addPcL annotation(Placement(visible = true, transformation(origin = {-78, 16}, extent = {{10, -10}, {-10, 10}}, rotation = 90))); |
---|
442 | Components.Driver driver annotation(Placement(transformation(extent = {{-4, -22}, {26, -8}}))); |
---|
443 | Modelica.Blocks.Continuous.Integrator toPcEn(k = 1 / 3.6e6) "unit: kWh" annotation(Placement(visible = true, transformation(extent = {{10, -10}, {-10, 10}}, rotation = 90, origin = {-78, -28}))); |
---|
444 | equation |
---|
445 | connect(mechInterface.flange, tauRes.flange) annotation(Line(points = {{6, 38}, {44, 38}})); |
---|
446 | connect(wLoad.flange, tauRes.flange) annotation(Line(points = {{28, 30}, {28, 38}, {44, 38}})); |
---|
447 | connect(mechInterface.pow, add.u2) annotation(Line(points = {{-15, 38}, {-28, 38}, {-28, 32}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
448 | connect(pcPower_.y, add.u1) annotation(Line(points = {{-91, 38}, {-40, 38}, {-40, 32}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
449 | connect(addPcL.u, add.u1) annotation(Line(points = {{-78, 28}, {-78, 38}, {-40, 38}, {-40, 32}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
450 | connect(driver.y, mechInterface.genTau) annotation(Line(points = {{2, -6.83333}, {2, 8}, {-4, 8}, {-4, 27.8}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
451 | connect(driver.u, wLoad.w) annotation(Line(points = {{20, -5.66667}, {20, 4}, {28, 4}, {28, 9}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
452 | connect(addPcL.y, toPcEn.u) annotation(Line(points = {{-77.8, 5}, {-78, 5}, {-78, -16}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
453 | connect(add.y, storage.inFlow) annotation(Line(points = {{-34, 9}, {-34, -2}}, color = {0, 0, 127}, smooth = Smooth.None)); |
---|
454 | annotation(__Dymola_experimentSetupOutput, Documentation(info = "<html> |
---|
455 | <p>Modello di sistema con rete-carico-accumulo per trovare la legge di ottimizzazione dinamica.</p> |
---|
456 | <p>Le potenze sono in kW, le energie in kWh, i costi in €/kh, il tempo in h.</p> |
---|
457 | <p>Una simulazione di 24 h dà quindi conto di un andamento giornaliero.</p> |
---|
458 | <p>La versione da usare effettivamente per l'ttimizzazione è la SystemDO, che non ha l'inflow come input assegnato, ma lasciato in gestione all'ottimizzatore. </p> |
---|
459 | </html>"), Icon(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-120, -60}, {80, 60}}, preserveAspectRatio = false, initialScale = 0.1, grid = {2, 2}), graphics), experiment(StartTime = 0, StopTime = 60, Tolerance = 1e-3, Interval = 0.5)); |
---|
460 | end OneLoss; |
---|
461 | end DO; |
---|
462 | |
---|
463 | annotation(uses(Modelica(version = "3.2.1"))); |
---|
464 | end OOInertia; |
---|