pre-big change
This commit is contained in:
269
_2D/package.mo
Normal file
269
_2D/package.mo
Normal file
@@ -0,0 +1,269 @@
|
||||
within BondGraph;
|
||||
package _2D
|
||||
|
||||
connector BondPort "Bond graph 2D multibond power port"
|
||||
Real e[2] "Effort vector";
|
||||
flow Real f[2] "Flow vector";annotation(
|
||||
Icon(graphics = {Rectangle(lineColor = {0, 85, 0}, fillColor = {0, 85, 0},fillPattern = FillPattern.Solid, extent = {{-60, 60}, {60, -60}})}));
|
||||
end BondPort;
|
||||
|
||||
model J1 "Bond graph 2D 1-junction (common flow, efforts sum to zero)"
|
||||
parameter Integer N(min=1) = 2 "# of power ports";
|
||||
parameter Real s[N] = fill(1.0, N)
|
||||
"Bond orientation signs used in the effort balance";
|
||||
BondPort P[N] "Power ports" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(extent = {{-10, -10}, {10, 10}})));
|
||||
Real f[2];
|
||||
equation
|
||||
// Efforts sum to zero, with signs from bond directions
|
||||
for j in 1:2 loop
|
||||
sum(s[i] * P[i].e[j] for i in 1:N) = 0;
|
||||
end for;
|
||||
|
||||
// Flows are all equal
|
||||
for i in 2:N loop
|
||||
P[i].f = P[i-1].f;
|
||||
end for;
|
||||
f = P[1].f;
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "1", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}));
|
||||
end J1;
|
||||
|
||||
model J0 "Bond graph 2D 0-junction (common effort, flows sum to zero)"
|
||||
parameter Integer N(min=1) = 2 "# of power ports";
|
||||
parameter Real s[N] = fill(1.0, N)
|
||||
"Bond orientation signs used in the effort balance";
|
||||
BondPort P[N] "Power ports" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(extent = {{-10, -10}, {10, 10}})));
|
||||
Real e[2];
|
||||
equation
|
||||
// Flows sum to zero, with signs from bond directions
|
||||
for j in 1:2 loop
|
||||
sum(s[i] * P[i].f[j] for i in 1:N) = 0;
|
||||
end for;
|
||||
|
||||
// Efforts are all equal
|
||||
for i in 2:N loop
|
||||
P[i].e = P[1].e;
|
||||
end for;
|
||||
e = P[1].e;
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "0", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end J0;
|
||||
|
||||
partial model OnePortPassive "One-port passive 2D multibond element"
|
||||
BondPort p "Generic power port" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(extent = {{-10, -10}, {10, 10}})));
|
||||
end OnePortPassive;
|
||||
|
||||
partial model OnePortEnergetic "One-port 2D multibond storage element"
|
||||
extends OnePortPassive annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {0, 80}, extent = {{-10, -10}, {10, 10}})));
|
||||
Real state[2] "Conserved quantity";
|
||||
end OnePortEnergetic;
|
||||
|
||||
model C "Bond graph 2D C element"
|
||||
extends OnePortEnergetic(state(start=q0, each fixed=true));
|
||||
parameter Real c[2,2] = [1, 0; 0, 1] "Capacitance matrix inverse denominator form";
|
||||
parameter Real q0[2] = {0, 0} "Initial stored quantity (charge)";
|
||||
equation
|
||||
der(state) = p.f;
|
||||
c * p.e = state;
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "C", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end C;
|
||||
|
||||
model I "Bond graph 2D I element"
|
||||
extends OnePortEnergetic(state(start=p0, each fixed=true));
|
||||
parameter Real I[2,2] = [1, 0; 0, 1] "Inertance / inductance / mass matrix";
|
||||
parameter Real p0[2] = {0, 0} "Initial stored quantity (momentum / flux)";
|
||||
equation
|
||||
der(state) = p.e;
|
||||
I * p.f = state;
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "I", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end I;
|
||||
|
||||
model R "Bond graph 2D resistor"
|
||||
extends OnePortPassive;
|
||||
parameter Real R[2,2] = [1, 0; 0, 1] "Resistance matrix";
|
||||
equation
|
||||
p.e = R * p.f;
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-100, 100}, {100, -100}}, textString = "R", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end R;
|
||||
|
||||
model Se "Effort source"
|
||||
BondPort p annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
parameter Real e0[2] "Imposed effort";
|
||||
equation
|
||||
p.e = e0;
|
||||
annotation(
|
||||
Icon(graphics = {Text(origin = {-20, 0}, extent = {{-80, 100}, {80, -100}}, textString = "Se", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end Se;
|
||||
|
||||
model Sf "Flow source"
|
||||
BondPort p annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
parameter Real f0[2] "Imposed flow";
|
||||
equation
|
||||
p.f = f0;
|
||||
annotation(
|
||||
Icon(graphics = {Text(origin = {-20, 0}, extent = {{-80, 100}, {80, -100}}, textString = "Sf", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end Sf;
|
||||
|
||||
model TF "Bond graph 2D transformer"
|
||||
BondPort p1 "Port 1" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondPort p2 "Port 2" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
|
||||
parameter Real n[2,2] = [1, 0; 0, 1] "Transformer ratio matrix";
|
||||
equation
|
||||
p1.e = n * p2.e;
|
||||
transpose(n) * p1.f = p2.f;
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-80, 100}, {80, -100}}, textString = "TF", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end TF;
|
||||
|
||||
model GY "Bond graph 2D gyrator"
|
||||
BondPort p1 "Port 1" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondPort p2 "Port 2" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
parameter Real r[2,2] = [1, 0; 0, 1] "Gyrator modulus matrix";
|
||||
equation
|
||||
p1.e = r * p2.f;
|
||||
p2.e = transpose(r) * p1.f;
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-80, 100}, {80, -100}}, textString = "GY", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end GY;
|
||||
|
||||
model mSe "Bond graph modulated effort source"
|
||||
BondPort p annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput e0 "Imposed effort" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-20, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
|
||||
Modelica.Blocks.Interfaces.RealInput e1 "Imposed effort" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {20, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
|
||||
equation
|
||||
p.e = {e0,e1};
|
||||
annotation(
|
||||
Icon(graphics = {Text(origin = {-20, 0}, extent = {{-80, 100}, {80, -100}}, textString = "mSe", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end mSe;
|
||||
|
||||
model mSf "Bond graph modulated flow source"
|
||||
BondPort p annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput f0 "Imposed flow" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-20, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
|
||||
Modelica.Blocks.Interfaces.RealInput f1 "Imposed flow" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {20, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
|
||||
equation
|
||||
p.f = {f0,f1};
|
||||
annotation(
|
||||
Icon(graphics = {Text(origin = {-20, 0}, extent = {{-80, 100}, {80, -100}}, textString = "mSf", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||
Diagram(graphics));
|
||||
end mSf;
|
||||
|
||||
model mTF "Bond graph modulated transformer"
|
||||
BondPort p1 "Port 1" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondPort p2 "Port 2" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput m[2,2] "Modulation" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {0, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
|
||||
equation
|
||||
p1.e = m * p2.e;
|
||||
transpose(m) * p1.f = p2.f;
|
||||
annotation(
|
||||
Diagram(graphics),
|
||||
Icon(graphics = {Text(extent = {{-60, 100}, {60, -100}}, textString = "mTF", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}));
|
||||
end mTF;
|
||||
|
||||
model mGY "Bond graph modulated gyrator"
|
||||
BondPort p1 "Port 1" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondPort p2 "Port 2" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput m[2,2] "Modulation" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {0, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
|
||||
equation
|
||||
p1.e = m * p2.f;
|
||||
p2.e = transpose(m) * p1.f;
|
||||
annotation(
|
||||
Diagram(graphics),
|
||||
Icon(graphics = {Text(extent = {{-60, 100}, {60, -100}}, textString = "mGY", textStyle = {TextStyle.Bold, TextStyle.UnderLine}), Text(origin = {50, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}));
|
||||
end mGY;
|
||||
|
||||
package TransRotUtils
|
||||
|
||||
model mTFrot2lin
|
||||
_1D.BondPort pR annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondPort pT annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
parameter Real r_body[2] = {1,0};
|
||||
protected
|
||||
Real B[2];
|
||||
equation
|
||||
B = {-r_body[2], r_body[1]};
|
||||
pT.f = B * pR.f;
|
||||
pR.e = B[1]*pT.e[1] + B[2]*pT.e[2];
|
||||
annotation(
|
||||
Icon(graphics = {Text(extent = {{-70, 100}, {70, -100}}, textString = "rlTF", textStyle = {TextStyle.Bold, TextStyle.UnderLine})}));
|
||||
end mTFrot2lin;
|
||||
|
||||
model rTF
|
||||
BondPort p1 "Port 1" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondPort p2 "Port 2" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput phi "angle" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {0, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
|
||||
protected
|
||||
Real R[2,2];
|
||||
equation
|
||||
R = [cos(phi), -sin(phi);
|
||||
sin(phi), cos(phi)];
|
||||
p1.e = R * p2.e;
|
||||
transpose(R) * p1.f = p2.f;
|
||||
annotation(
|
||||
Diagram(graphics),
|
||||
Icon(graphics = {Text(extent = {{-60, 100}, {60, -100}}, textString = "rTF", textStyle = {TextStyle.Bold, TextStyle.UnderLine}) }));
|
||||
end rTF;
|
||||
|
||||
end TransRotUtils;
|
||||
|
||||
model fsensor2d
|
||||
BondPort p annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-52, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealOutput f0 "Flow output" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {54, 20}, extent = {{-8, -8}, {8, 8}})));
|
||||
Modelica.Blocks.Interfaces.RealOutput f1 "Flow output" annotation(
|
||||
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {54, -20}, extent = {{-8, -8}, {8, 8}})));
|
||||
equation
|
||||
// Ideal flow sensor in bond-graph form: zero effort loading.
|
||||
p.e = {0,0};
|
||||
f0 = p.f[1];
|
||||
f1 = p.f[2];
|
||||
annotation(
|
||||
Icon(graphics = {Text(origin = {-10, 0}, extent = {{-50, 60}, {50, -60}}, textString = "f", textStyle = {TextStyle.Italic}), Ellipse(origin = {-2, 0}, lineThickness = 5, extent = {{-50, 50}, {50, -50}})}));
|
||||
end fsensor2d;
|
||||
|
||||
|
||||
annotation(
|
||||
Icon(graphics = {Text(origin = {50, 0}, extent = {{-50, 100}, {50, -100}}, textString = "R", textStyle = {TextStyle.Bold}), Line(origin = {-45.22, 20.19}, points = {{-58.7774, -20.1934}, {21.2226, -20.1934}, {-38.7774, 19.8066}}, thickness = 5), Line(origin = {-9.81, -8.19}, points = {{-10.1934, 48.1934}, {-10.1934, -31.8066}}, thickness = 5), Line(origin = {-78, 16}, points = {{-26, 0}, {30, 0}}, thickness = 5)}),
|
||||
uses(Modelica(version = "4.1.0")),
|
||||
Diagram(graphics));
|
||||
end _2D;
|
||||
18
_2D/package.order
Normal file
18
_2D/package.order
Normal file
@@ -0,0 +1,18 @@
|
||||
BondPort
|
||||
J1
|
||||
J0
|
||||
OnePortPassive
|
||||
OnePortEnergetic
|
||||
C
|
||||
I
|
||||
R
|
||||
Se
|
||||
Sf
|
||||
TF
|
||||
GY
|
||||
mSe
|
||||
mSf
|
||||
mTF
|
||||
mGY
|
||||
TransRotUtils
|
||||
fsensor2d
|
||||
Reference in New Issue
Block a user