Ticket #3624: test.mo

File test.mo, 3.2 KB (added by ceraolo, 9 years ago)
Line 
1within ;
2package Test
3  model FullRecovery "Minimize mechanical energy in a simple path"
4    parameter Real m=1000 "1000 kg of vehicle mass";
5    parameter Real p=1 "needed for final constraints";
6    parameter Real fGrip=0.02;
7    parameter Real S=2 "superficie frontale in m^2";
8    parameter Real Cx=0.4;
9    constant Real rho=1.226 "air density kg/m^3";
10    constant Real g=9.81;
11    Real a(
12      min=-1,
13      max=1,
14      nominal=0) annotation (isConstraint=true);
15    Real v(start=0);
16    Real pos(start=0);
17    Real pow=f*v "Mechanical power";
18    Real fResis "Motion resistance";
19    Real Energy "Energy to minimize";
20    input Real f(min=-1e9, max=1e9);
21    Real constEn(nominal=1) = Energy "minimize Energy(tf)"
22      annotation (isMayer=true);
23    Real constSpeed(
24      min=0,
25      max=0) = p*v " 0<= p*v(tf) <=0 " annotation (isFinalConstraint=true);
26    Real constSpace(
27      min=1000,
28      max=1000) = p*pos " 0<= p*v(tf) <=0 " annotation (isFinalConstraint=true);
29  equation
30    der(Energy) = pow;
31    der(pos) = v;
32    der(v) = a;
33    fResis = fGrip*m*g + 0.5*Cx*rho*S*v^2;
34    f - fResis = m*a;
35    annotation (Documentation(info="<html>
36<p>train movement optimization.</p>
37</html>"), experiment(
38        StartTime=0,
39        StopTime=100,
40        Tolerance=1e-08,
41        Interval=0.333333));
42  end FullRecovery;
43
44  model DOminEnPant "Minimize mechanical Pantograph energy in a simple path"
45    parameter Real m=1000 "1000 kg of vehicle mass";
46    parameter Real p=1 "needed for final constraints";
47    parameter Real fGrip=0.02;
48    parameter Real S=2 "superficie frontale in m^2";
49    parameter Real Cx=0.4;
50    constant Real rho=1.226 "densità aria kg/m^3";
51    constant Real g=9.81;
52    Real a(
53      min=-1,
54      max=1,
55      nominal=0) annotation (isConstraint=true);
56    Real v(start=0);
57    Real pos(start=0);
58    Real mechPow=f*v "Mechanical power";
59    Real fResis "Motion resistance";
60    Real mechEnergy;
61    Real energy "Energy to minimize";
62    input Real f(min=-1e9, max=1e9);
63    Real constEn(nominal=1) = energy "minimize energy(tf)"
64      annotation (isMayer=true);
65    Real constSpeed(
66      min=0,
67      max=0) = p*v " 0<= p*v(tf) <=0 " annotation (isFinalConstraint=true);
68    Real constSpace(
69      min=1000,
70      max=1000) = p*pos " 0<= p*v(tf) <=0 " annotation (isFinalConstraint=true);
71  equation
72    der(mechEnergy) = mechPow;
73    der(pos) = v;
74    der(v) = a;
75    energy = mechEnergy;
76    fResis = fGrip*m*g + 0.5*Cx*rho*S*v^2;
77    f - fResis = m*a;
78    annotation (Documentation(info="<html>
79<p>train movement optimization.</p>
80</html>"), experiment(
81        StartTime=0,
82        StopTime=100,
83        Tolerance=1e-08,
84        Interval=0.333333));
85  end DOminEnPant;
86
87  annotation (
88    Icon(graphics, coordinateSystem(
89        extent={{-100,-80},{100,80}},
90        preserveAspectRatio=true,
91        initialScale=0.1,
92        grid={2,2})),
93    Diagram(graphics, coordinateSystem(
94        extent={{-100,-100},{100,100}},
95        preserveAspectRatio=true,
96        initialScale=0.1,
97        grid={2,2})),
98    uses(Modelica(version="3.2.1")),
99    version="1",
100    conversion(from(version="", script="ConvertFromDOtrainPkg_.mos")));
101end Test;