Pendulum on a cart
This commit is contained in:
@@ -130,6 +130,23 @@ package _2D
|
|||||||
Diagram(graphics));
|
Diagram(graphics));
|
||||||
end Sf;
|
end Sf;
|
||||||
|
|
||||||
|
model MuxDemux "Combine/split two 1D bond ports and one 2D multibond port"
|
||||||
|
BondGraph.BondPort p1 "1D input channel 1" annotation(
|
||||||
|
Placement(transformation(extent = {{-110, 30}, {-90, 50}}), iconTransformation(extent = {{-110, 30}, {-90, 50}})));
|
||||||
|
BondGraph.BondPort p2 "1D input channel 2" annotation(
|
||||||
|
Placement(transformation(extent = {{-110, -50}, {-90, -30}}), iconTransformation(extent = {{-110, -50}, {-90, -30}})));
|
||||||
|
BondPort p "2D multibond output" annotation(
|
||||||
|
Placement(transformation(extent = {{90, -10}, {110, 10}}), iconTransformation(extent = {{90, -10}, {110, 10}})));
|
||||||
|
equation
|
||||||
|
// Power-preserving grouping of effort/flow pairs
|
||||||
|
p.e = {p1.e, p2.e};
|
||||||
|
p1.f = p.f[1];
|
||||||
|
p2.f = p.f[2];
|
||||||
|
annotation(
|
||||||
|
Icon(graphics = {Line(points = {{-70, 40}, {-30, 40}, {-10, 0}, {70, 0}}, thickness = 2), Line(points = {{-70, -40}, {-30, -40}, {-10, 0}}, thickness = 2), Line(points = {{0, 30}, {0, -30}}, thickness = 8), Text(origin = {0, 80}, textColor = {0, 0, 255}, extent = {{-50, 20}, {50, -20}}, textString = "%name")}),
|
||||||
|
Diagram(graphics));
|
||||||
|
end MuxDemux;
|
||||||
|
|
||||||
model TF "Bond graph 2D transformer"
|
model TF "Bond graph 2D transformer"
|
||||||
BondPort p1 "Port 1" annotation(
|
BondPort p1 "Port 1" annotation(
|
||||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
|||||||
117
test2d.mo
117
test2d.mo
@@ -1,43 +1,48 @@
|
|||||||
package test2d
|
package test2d
|
||||||
model test2d
|
model pendulum
|
||||||
|
parameter Modelica.Units.SI.Mass mass;
|
||||||
|
parameter Modelica.Units.SI.Length length;
|
||||||
|
parameter Modelica.Units.SI.MomentOfInertia momentOfInertia;
|
||||||
|
parameter Modelica.Units.SI.Angle startAngle;
|
||||||
|
|
||||||
BondGraph.J1 w_com(N = 3, s = {-1, -1, 1}) annotation(
|
BondGraph.J1 w_com(N = 3, s = {-1, -1, 1}) annotation(
|
||||||
Placement(transformation(origin = {0, 100}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {0, 100}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph.I moi(I = 0.01) annotation(
|
BondGraph.I moi(I = momentOfInertia, state(fixed = false)) annotation(
|
||||||
Placement(transformation(origin = {40, 100}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {40, 100}, extent = {{-10, -10}, {10, 10}})));
|
||||||
mTFrot2lin mTFrot2lin1(r_body = {-0.5, 0}) annotation(
|
mTFrot2lin mTFrot2lin1(r_body = {-0.5*length, 0}) annotation(
|
||||||
Placement(transformation(origin = {0, 70}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
Placement(transformation(origin = {0, 70}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
||||||
BondGraph._2D.J0 j0(N = 3, s = {1, 1, -1}) annotation(
|
BondGraph._2D.J0 j0(N = 3, s = {1, 1, -1}) annotation(
|
||||||
Placement(transformation(origin = {0, 40}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {0, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph._2D.J1 v_com_i(N = 3, s = {1, -1, 1}) annotation(
|
BondGraph._2D.J1 v_com_i(N = 3, s = {1, -1, 1}) annotation(
|
||||||
Placement(transformation(origin = {40, -20}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {40, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph._2D.J1 v_P_bff(N = 2, s = {1, 1}) annotation(
|
BondGraph._2D.J1 v_P_bff(N = 2, s = {1, -1}) annotation(
|
||||||
Placement(transformation(origin = {-40, 40}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {-40, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph._2D.J1 v_com_bff(N = 2, s = {-1, -1}) annotation(
|
BondGraph._2D.J1 v_com_bff(N = 2, s = {-1, -1}) annotation(
|
||||||
Placement(transformation(origin = {40, 40}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {40, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph._2D.Sf hinge(f0 = {0, 0}) annotation(
|
|
||||||
Placement(transformation(origin = {-78, 40}, extent = {{-10, -10}, {10, 10}})));
|
|
||||||
rTF rTF1 annotation(
|
rTF rTF1 annotation(
|
||||||
Placement(transformation(origin = {40, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
|
Placement(transformation(origin = {40, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
|
||||||
Modelica.Blocks.Continuous.Integrator w2phi(k = 1) annotation(
|
Modelica.Blocks.Continuous.Integrator w2phi(y_start=startAngle) annotation(
|
||||||
Placement(transformation(origin = {30, 70}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {30, 70}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph._2D.I m(I = [1, 0; 0, 1]) annotation(
|
BondGraph._2D.I m(I = [mass, 0; 0, mass]) annotation(
|
||||||
Placement(transformation(origin = {80, -20}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {80, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph._2D.Se g(e0 = {0, -9.81}) annotation(
|
BondGraph._2D.Se g(e0 = {0, -9.81*mass}) annotation(
|
||||||
Placement(transformation(origin = {0, -20}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {0, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||||
Modelica.Blocks.Continuous.Integrator vx2x(y_start = -0.5) annotation(
|
Modelica.Blocks.Continuous.Integrator vx2x(y_start=-0.5*length*cos(startAngle)) annotation(
|
||||||
Placement(transformation(origin = {70, -50}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {70, -50}, extent = {{-10, -10}, {10, 10}})));
|
||||||
Modelica.Blocks.Continuous.Integrator vy2y(y_start = 0) annotation(
|
Modelica.Blocks.Continuous.Integrator vy2y(y_start=-0.5*length*sin(startAngle)) annotation(
|
||||||
Placement(transformation(origin = {70, -80}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {70, -80}, extent = {{-10, -10}, {10, 10}})));
|
||||||
vis2d vis2d1 annotation(
|
vis2d vis2d1 annotation(
|
||||||
Placement(transformation(origin = {118, -64}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {118, -64}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph.J0 j1(N = 3, s = {1, -1, 1}) annotation(
|
rTF rTF2 annotation(
|
||||||
Placement(transformation(origin = {-40, 100}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {-40, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
|
||||||
BondGraph.Sf sf(f0 = 0) annotation(
|
BondGraph._2D.J1 v_P_i(N = 2, s = {1, 1}) annotation(
|
||||||
Placement(transformation(origin = {-80, 100}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {-40, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph.J1 hinge2(N = 2, s = {-1, -1}) annotation(
|
BondGraph.BondPort rotIn annotation(
|
||||||
Placement(transformation(origin = {-40, 70}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {-30, 100}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {0, 198}, extent = {{-10, -10}, {10, 10}})));
|
||||||
BondGraph.R r(R = 0.2) annotation(
|
BondGraph._2D.BondPort trans_i annotation(
|
||||||
Placement(transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}})));
|
Placement(transformation(origin = {-80, -20}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {0, -198}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
Modelica.Blocks.Interfaces.RealOutput phi annotation(
|
||||||
|
Placement(transformation(origin = {120, 70}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {202, 80}, extent = {{-10, -10}, {10, 10}})));
|
||||||
equation
|
equation
|
||||||
connect(w_com.f, w2phi.u) annotation(
|
connect(w_com.f, w2phi.u) annotation(
|
||||||
Line(points = {{6, 94}, {18, 70}}, color = {0, 0, 127}));
|
Line(points = {{6, 94}, {18, 70}}, color = {0, 0, 127}));
|
||||||
@@ -53,8 +58,6 @@ package test2d
|
|||||||
Line(points = {{0, 62}, {0, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
Line(points = {{0, 62}, {0, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
connect(j0.P[3], v_P_bff.P[1]) annotation(
|
connect(j0.P[3], v_P_bff.P[1]) annotation(
|
||||||
Line(points = {{0, 40}, {-40, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
Line(points = {{0, 40}, {-40, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
connect(hinge.p, v_P_bff.P[2]) annotation(
|
|
||||||
Line(points = {{-70, 40}, {-40, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
|
||||||
connect(v_com_bff.P[2], rTF1.p2) annotation(
|
connect(v_com_bff.P[2], rTF1.p2) annotation(
|
||||||
Line(points = {{40, 40}, {40, 18}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
Line(points = {{40, 40}, {40, 18}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
connect(rTF1.p1, v_com_i.P[1]) annotation(
|
connect(rTF1.p1, v_com_i.P[1]) annotation(
|
||||||
@@ -73,21 +76,25 @@ package test2d
|
|||||||
Line(points = {{82, -50}, {94, -50}, {94, -64}, {108, -64}}, color = {0, 0, 127}));
|
Line(points = {{82, -50}, {94, -50}, {94, -64}, {108, -64}}, color = {0, 0, 127}));
|
||||||
connect(w2phi.y, vis2d1.phi) annotation(
|
connect(w2phi.y, vis2d1.phi) annotation(
|
||||||
Line(points = {{42, 70}, {100, 70}, {100, -58}, {108, -58}}, color = {0, 0, 127}));
|
Line(points = {{42, 70}, {100, 70}, {100, -58}, {108, -58}}, color = {0, 0, 127}));
|
||||||
connect(j1.P[2], w_com.P[3]) annotation(
|
connect(w2phi.y, rTF2.phi) annotation(
|
||||||
Line(points = {{-40, 100}, {0, 100}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
Line(points = {{42, 70}, {100, 70}, {100, 26}, {-20, 26}, {-20, 10}, {-32, 10}}, color = {0, 0, 127}));
|
||||||
connect(sf.p, j1.P[1]) annotation(
|
connect(v_P_bff.P[2], rTF2.p2) annotation(
|
||||||
Line(points = {{-72, 100}, {-40, 100}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
Line(points = {{-40, 40}, {-40, 18}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
connect(hinge2.P[1], j1.P[2]) annotation(
|
connect(rTF2.p1, v_P_i.P[1]) annotation(
|
||||||
Line(points = {{-40, 70}, {-40, 100}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
Line(points = {{-40, 2}, {-40, -20}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
connect(r.p, hinge2.P[2]) annotation(
|
connect(rotIn, w_com.P[3]) annotation(
|
||||||
Line(points = {{-70, 70}, {-40, 70}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
Line(points = {{-30, 100}, {0, 100}}, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
|
connect(trans_i, v_P_i.P[2]) annotation(
|
||||||
|
Line(points = {{-80, -20}, {-40, -20}}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
|
connect(w2phi.y, phi) annotation(
|
||||||
|
Line(points = {{42, 70}, {120, 70}}, color = {0, 0, 127}));
|
||||||
annotation(
|
annotation(
|
||||||
uses(Modelica(version = "4.1.0")),
|
uses(Modelica(version = "4.1.0")),
|
||||||
experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.02),
|
|
||||||
Diagram(coordinateSystem(extent = {{-100, 120}, {140, -100}})),
|
Diagram(coordinateSystem(extent = {{-100, 120}, {140, -100}})),
|
||||||
Icon(coordinateSystem(extent = {{-200, -200}, {200, 200}})),
|
Icon(coordinateSystem(extent = {{-200, -200}, {200, 200}}), graphics = {Rectangle(lineColor = {204, 204, 204}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Sphere, lineThickness = 2, extent = {{-200, 200}, {200, -200}}, radius = 50), Ellipse(origin = {0, -60},lineColor = {255, 0, 0}, fillColor = {255, 0, 0}, fillPattern = FillPattern.Solid, extent = {{-15, 15}, {15, -15}}), Line(origin = {29, 19}, points = {{-29, -79}, {29, 79}}, color = {255, 0, 0}, thickness = 5), Line(origin = {0, -76}, points = {{-130, 0}, {130, 0}}, thickness = 1.25)}),
|
||||||
version = "");
|
version = "",
|
||||||
end test2d;
|
experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.002));
|
||||||
|
end pendulum;
|
||||||
|
|
||||||
model mTFrot2lin
|
model mTFrot2lin
|
||||||
BondGraph.BondPort pR annotation(
|
BondGraph.BondPort pR annotation(
|
||||||
@@ -122,6 +129,50 @@ package test2d
|
|||||||
Diagram(graphics),
|
Diagram(graphics),
|
||||||
Icon(graphics = {Text(extent = {{-60, 100}, {60, -100}}, textString = "rTF", textStyle = {TextStyle.Bold, TextStyle.UnderLine})}));
|
Icon(graphics = {Text(extent = {{-60, 100}, {60, -100}}, textString = "rTF", textStyle = {TextStyle.Bold, TextStyle.UnderLine})}));
|
||||||
end rTF;
|
end rTF;
|
||||||
|
|
||||||
|
model test
|
||||||
|
pendulum pendulum1(mass = 1, length = 1, momentOfInertia = 0.001, startAngle = 0) annotation(
|
||||||
|
Placement(transformation(origin = {60, 0}, extent = {{-20, -20}, {20, 20}})));
|
||||||
|
BondGraph.J0 j1(N = 2, s = {1, -1}) annotation(
|
||||||
|
Placement(transformation(origin = {60, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
BondGraph.J1 w_hinge(N = 2, s = {-1, -1}) annotation(
|
||||||
|
Placement(transformation(origin = {20, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
BondGraph.R r(R = 0.02) annotation(
|
||||||
|
Placement(transformation(origin = {-18, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
//BondGraph._2D.Sf sf(f0 = {0, 0}) annotation(
|
||||||
|
// Placement(transformation(origin = {60, -58}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
|
||||||
|
BondGraph._2D.J1 j2(N = 2, s = {-1, 1}) annotation(
|
||||||
|
Placement(transformation(origin = {60, -40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
BondGraph._2D.MuxDemux muxDemux annotation(
|
||||||
|
Placement(transformation(origin = {30, -40}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
BondGraph.J1 j3(N = 2, s = {1, -1}) annotation(
|
||||||
|
Placement(transformation(origin = {-20, -60}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
BondGraph.J1 j4(N = 1, s = {-1}) annotation(
|
||||||
|
Placement(transformation(origin = {-20, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
BondGraph.Sf sf(f0 = 0) annotation(
|
||||||
|
Placement(transformation(origin = {-58, -60}, extent = {{-10, -10}, {10, 10}})));
|
||||||
|
equation
|
||||||
|
connect(w_hinge.P[1], j1.P[1]) annotation(
|
||||||
|
Line(points = {{20, 40}, {60, 40}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
|
connect(r.p, w_hinge.P[2]) annotation(
|
||||||
|
Line(points = {{-18, 40}, {20, 40}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
|
connect(j1.P[2], pendulum1.rotIn) annotation(
|
||||||
|
Line(points = {{60, 40}, {60, 20}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
|
//connect(sf.p, pendulum1.trans_i) annotation(
|
||||||
|
// Line(points = {{60, -50}, {60, -20}}, color = {0, 85, 0}, thickness = 0.75, arrow = //{Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||||
|
connect(j2.P[1], pendulum1.trans_i) annotation(
|
||||||
|
Line(points = {{60, -40}, {60, -20}}, color = {0, 85, 0}));
|
||||||
|
connect(muxDemux.p, j2.P[2]) annotation(
|
||||||
|
Line(points = {{40, -40}, {60, -40}}, color = {0, 85, 0}));
|
||||||
|
connect(j3.P[2], muxDemux.p2) annotation(
|
||||||
|
Line(points = {{-20, -60}, {8, -60}, {8, -44}, {20, -44}}, color = {0, 0, 127}));
|
||||||
|
connect(j4.P[1], muxDemux.p1) annotation(
|
||||||
|
Line(points = {{-20, -20}, {8, -20}, {8, -36}, {20, -36}}, color = {0, 0, 127}));
|
||||||
|
connect(sf.p, j3.P[1]) annotation(
|
||||||
|
Line(points = {{-50, -60}, {-20, -60}}, color = {0, 0, 127}));
|
||||||
|
annotation(
|
||||||
|
experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.02));
|
||||||
|
end test;
|
||||||
annotation(
|
annotation(
|
||||||
uses(Modelica(version = "4.1.0")));
|
uses(Modelica(version = "4.1.0")));
|
||||||
end test2d;
|
end test2d;
|
||||||
Reference in New Issue
Block a user