Ticket #6389: temp.mo

File temp.mo, 5.5 KB (added by jean-philippe.tavella@…, 4 years ago)
Line 
1package PowerSysPro
2 //Copyright 2020 EDF
3 import CM = PowerSysPro.Functions;
4
5 package Functions "Functions and constants"
6 //final constant Real pi= 2 * Functions.asin(1.0) "Pi number";
7
8 function abs "Absolute value of complex number"
9 input Complex c "Complex number";
10 output Real result "= abs(c)";
11
12 algorithm
13 result := (c.re ^ 2 + c.im ^ 2) ^ 0.5;
14
15 end abs;
16
17 function fromPolar "Complex from polar representation"
18 input Real len "abs of complex";
19 input Types.myAngle phi "arg of complex";
20 output Complex c "= len * cos(phi) + j * len * sin(phi)";
21 algorithm
22 c :=Complex(len*cos(phi), len*sin(phi));
23
24 end fromPolar;
25
26 function conj "Conjugate of complex number"
27 input Complex c1 "Complex number";
28 output Complex c2 "= c1.re - j*c1.im";
29 algorithm
30 c2 := Complex(c1.re, -c1.im);
31
32 end conj;
33
34 function cos "Cosine"
35 input Types.myAngle u "Independent variable";
36 output Real y "Dependent variable y=cos(u)";
37
38 external "builtin" y = cos(u);
39
40 end cos;
41
42 function sin "Sine"
43 input Types.myAngle u "Independent variable";
44 output Real y "Dependent variable y=sin(u)";
45
46 external "builtin" y = sin(u);
47
48 end sin;
49
50 function asin "Inverse sine (-1 <= u <= 1)"
51 input Real u "Independent variable";
52 output Types.myAngle y "Dependent variable y=asin(u)";
53
54 external "builtin" y = asin(u);
55
56 end asin;
57 annotation (
58 Icon(graphics={ Text(extent = {{-72, 58.9}, {78, -53.1}}, lineColor = {28, 108, 200}, fontName = "Segoe Print", textString = "F")}),
59 Documentation(info = "<html>
60 <p>Rewrite MSL functions for portability needs.</p>
61</body></html>"));
62 end Functions;
63
64 package Types "Domain-specific type definitions"
65 type myVoltage = Real(nominal = 1e3, unit = "V", displayUnit = "kV");
66 type myCurrent = Real(nominal = 1e-3, unit = "A", displayUnit = "A");
67 type myActivePower = Real(unit = "W", displayUnit = "kW");
68 type myReactivePower = Real(unit = "var", displayUnit = "kvar");
69 type myApparentPower = Real(unit = "VA", displayUnit = "kVA");
70 type myApparentPowerMVA = Real(unit = "kVA", displayUnit = "MVA");
71 type myResistance = Real(unit = "Ohm", displayUnit = "Ohm");
72 type myReactance = Real(unit = "Ohm", displayUnit = "Ohm");
73 type myConductance = Real(unit = "S", displayUnit = "S");
74 type mySusceptance = Real(unit = "S", displayUnit = "S");
75 type myAngle = Real(unit = "rad", displayUnit = "deg");
76 type myPerUnit = Real(unit = "1");
77 type myTime = Real(unit = "s", displayUnit = "s");
78 operator record myComplexVoltage =
79 Complex(redeclare myVoltage re "Imaginary part of complex voltage",
80 redeclare myVoltage im "Real part of complex voltage")
81 "Complex voltage";
82 operator record myComplexCurrent =
83 Complex(redeclare myCurrent re "Real part of complex current",
84 redeclare myCurrent im "Imaginary part of complex current")
85 "Complex current";
86 operator record myComplexAdmittance =
87 Complex(redeclare myConductance re "Real part of complex admittance (conductance)",
88 redeclare mySusceptance im "Imaginary part of complex admittance (susceptance)")
89 "Complex admittance";
90 operator record myComplexImpedance =
91 Complex(redeclare myResistance re "Real part of complex impedance (resistance)",
92 redeclare myReactance im "Imaginary part of complex impedance (reactance)")
93 "Complex impedance";
94 operator record myComplexPerUnit =
95 Complex(re(unit = "1"),
96 im(unit = "1"))
97 "Complexe per unit";
98 annotation (
99 Documentation(info = "<html>
100 <p>This package gathers dedicated icons for all models in this library.</p>
101</body></html>"));
102 end Types;
103
104 annotation (
105 version = "Version 2.1.2 February 18th, 2021",
106 Documentation(info = "<html><head></head><body>
107 <p>Copyright © 2020-2021, EDF.</p>
108 <p>The use of the PowerSysPro library is granted by EDF under the provisions of the Modelica License 2. A copy of this license can be obtained&nbsp;<a href=\"http://www.modelica.org/licenses/ModelicaLicense2\">here</a>.</p>
109 <p></p><p>-------------------------------------------------------------------------------------------------------------</p>
110<p>For further technical information, see the <a href=\"modelica://PowerSysPro.Information\">Information</a>.</p>
111</body></html>"),
112 Diagram(graphics={ Text(lineColor = {28, 108, 200}, extent = {{-174, 28}, {180, -28}}, fontSize = 14, textStyle = {TextStyle.Bold}, textString = "Open electrical library
113developed at EDF Lab. Paris-Saclay")}),
114 Icon(graphics={ Text(extent={{
115 -208,70},{214,-60}}, lineColor=
116 {28,108,200}, fontName=
117 "Segoe Print",
118 textString="PSP")}),
119 uses(Modelica(version="4.0.0")));
120end PowerSysPro;