-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElectricPackage.mo
102 lines (88 loc) · 8.65 KB
/
ElectricPackage.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
within ;
package ElectricPackage
extends Modelica.Icons.Package;
package Interfaces
connector Pin "Electrical Pin"
Modelica.SIunits.Voltage v;
flow Modelica.SIunits.Current i;
annotation(Icon(corrdinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, -100},{100, 100}}, lineColor = {0, 0, 0}, fillColor = {0, 255, 0},
fillPattern = FillPattern.Solid)}), Diagram(corrdinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, 100},{100, -100}}, lineColor = {0, 0, 0}, fillColor = {0, 255, 0},
fillPattern = FillPattern.Solid), Text(extent={{-160, 110}, {40, 50}}, lineColor = {0, 0, 255}, textString
= "Pin")}), Documentation(info="<html> The model of the Electric Pin: the model provides interface between lumped components in the circuit </html> "));
end Pin;
connector PositivePin "Positive Electrical Pin"
Modelica.SIunits.Voltage v;
flow Modelica.SIunits.Current i;
annotation(Icon(corrdinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, -100},{100, 100}}, lineColor = {0, 0, 0}, fillColor = {0, 0, 255},
fillPattern = FillPattern.Solid)}), Diagram(corrdinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, 100},{100, -100}}, lineColor = {0, 0, 0}, fillColor = {0, 0, 255},
fillPattern = FillPattern.Solid), Text(extent={{-160, 110}, {40, 50}}, lineColor = {0, 0, 255}, textString
= "Pin")}), Documentation(info="<html> The model of the Electric Pin: the model provides interface between lumped components in the circuit </html> "));
end PositivePin;
connector NegativePin "Negative Electrical Pin"
Modelica.SIunits.Voltage v;
flow Modelica.SIunits.Current i;
annotation(Icon(corrdinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, -100},{100, 100}}, lineColor = {0, 0, 0}, fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid)}), Diagram(corrdinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, 100},{100, -100}}, lineColor = {0, 0, 0}, fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid), Text(extent={{-160, 110}, {40, 50}}, lineColor = {0, 0, 255}, textString
= "Pin")}), Documentation(info="<html> The model of the Negative Electric Pin: the model provides interface between lumped components in the circuit </html> "));
end NegativePin;
model OnePort
Modelica.SIunits.Voltage v "Voltage drop inside the component";
flow Modelica.SIunits.Current i "Current inside the component";
PositivePin p annotation(Placement(transformation(extent={{-110, -10},{-90, 10}})));
NegativePin n annotation(Placement(transformation(extent={{90, -10},{110, 10}})));
equation
v = p.v - n.v;
i = p.i;
i = -n.i;
annotation(Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, -100},{100, 100}}, lineColor = {0, 0, 0}, fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid)}), Diagram(coordinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-100, 60},{100, -60}}, lineColor = {0, 0, 0}, fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid), Text(extent={{-160, 110}, {40, 50}}, lineColor = {0, 0, 255}, textString
= "Pin")}), Documentation(info="<html> The model of the General Lumped Element </html> "));
end OnePort;
end Interfaces;
model Experiment
Components.Capacitor capacitor( v(start = 1, fixed=true), C=1)
annotation (Placement(transformation(extent={{-12,20},{8,40}})));
Components.Resistor resistor1(R=1)
annotation (Placement(transformation(extent={{-82,20},{-62,40}})));
equation
connect(resistor1.n, capacitor.p)
annotation (Line(points={{-62,30},{-12,30}}, color={0,0,0}));
connect(ground.p, capacitor.n)
annotation (Line(points={{18,-16},{18,30},{8,30}}, color={0,0,0}));
connect(resistor1.p, ground.p) annotation (Line(points={{-82,30},{-90,30},{
-90,-16},{18,-16}}, color={0,0,0}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end Experiment;
package Components
model Resistor
extends Interfaces.OnePort;
parameter Modelica.SIunits.Resistance R;
equation
v=i*R;
annotation(Icon(corrdinateSystem(extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-70, 20},{70, -20}}, lineColor = {0, 0, 0}, fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid)}), Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100, -100},{100, 100}}), graphics={Rectangle(extent={{-70, -20},{70, 20}}, lineColor = {0, 0, 0}, fillColor = {255, 255, 255},
fillPattern = FillPattern.Solid), Text(extent={{-160, 110}, {40, 50}}, lineColor = {0, 0, 255}, textString
= "Pin")}), Documentation(info="<html> The model of the General Lumped Element </html> "));
end Resistor;
model Capacitor
extends Interfaces.OnePort;
parameter Modelica.SIunits.Capacitance C;
equation
C*der(v) = i;
annotation(Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Line(points={{-10,40},{-10,-40}}, color={0,0,0}),
Line(points={{10,40},{10,-40}}, color={0,0,0})}),
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={
Line(points={{-10,40},{-10,-40}}, color={0,0,0}),
Line(points={{10,40},{10,-40}}, color={0,0,0})}),
Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end Capacitor;
end Components;
annotation (uses(Modelica(version="3.2.2")));
end ElectricPackage;