new 2d lib and test
This commit is contained in:
216
test2d.mo
216
test2d.mo
@@ -1,99 +1,127 @@
|
||||
model test2d
|
||||
import _1D = BondGraph._1D;
|
||||
import _2D = BondGraph._2D;
|
||||
_1D.J1 w_com(N = 4, s = {1, -1, -1, -1}) annotation(
|
||||
Placement(transformation(origin = {0, 120}, extent = {{-10, -10}, {10, 10}})));
|
||||
_2D.TransRotUtils.mTFrot2lin mTFrot2lin(r_body = {0.5, 0}) annotation(
|
||||
Placement(transformation(origin = {0, 80}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
||||
_2D.J0 j0(N = 3, s = {1, 1, -1}) annotation(
|
||||
Placement(transformation(origin = {0, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||
_2D.J1 v_p_bff(N = 2, s = {1, 1}) annotation(
|
||||
Placement(transformation(origin = {-40, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||
_2D.J1 v_com_bff(N = 2, s = {-1, -1}) annotation(
|
||||
Placement(transformation(origin = {40, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||
_2D.TransRotUtils.rTF rTF annotation(
|
||||
Placement(transformation(origin = {40, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
|
||||
_1D.fsensor wsensor annotation(
|
||||
Placement(transformation(origin = {50, 90}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Continuous.Integrator w2phi(k = 1) annotation(
|
||||
Placement(transformation(origin = {90, 90}, extent = {{-10, -10}, {10, 10}})));
|
||||
_2D.J1 v_com_in(N = 4, s = {1, -1, 1, 1}) annotation(
|
||||
Placement(transformation(origin = {40, -40}, extent = {{-10, -10}, {10, 10}})));
|
||||
_2D.I mass(I = [1, 0; 0, 1]) annotation(
|
||||
Placement(transformation(origin = {80, -40}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.Sf ground(f0 = {0, 0}) annotation(
|
||||
Placement(transformation(origin = {-80, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._1D.I m_inertial(I = 0.001) annotation(
|
||||
Placement(transformation(origin = {40, 120}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._1D.Sf ground2(f0 = 0) annotation(
|
||||
Placement(transformation(origin = {-80, 120}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._1D.J0 j1(N = 3, s = {1, -1, -1}) annotation(
|
||||
Placement(transformation(origin = {-40, 120}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._1D.J1 w_hinge(N = 2, s = {1, -1}) annotation(
|
||||
Placement(transformation(origin = {-40, 90}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._1D.R hinge_r(R = 0.08) annotation(
|
||||
Placement(transformation(origin = {-80, 90}, extent = {{-10, -10}, {10, 10}})));
|
||||
package test2d
|
||||
model test2d
|
||||
BondGraph.J1 w_com(N = 3, s = {-1, -1, 1}) annotation(
|
||||
Placement(transformation(origin = {0, 100}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph.I moi(I = 0.01) annotation(
|
||||
Placement(transformation(origin = {40, 100}, extent = {{-10, -10}, {10, 10}})));
|
||||
mTFrot2lin mTFrot2lin1(r_body = {-0.5, 0}) annotation(
|
||||
Placement(transformation(origin = {0, 70}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
||||
BondGraph._2D.J0 j0(N = 3, s = {1, 1, -1}) annotation(
|
||||
Placement(transformation(origin = {0, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.J1 v_com_i(N = 3, s = {1, -1, 1}) annotation(
|
||||
Placement(transformation(origin = {40, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.J1 v_P_bff(N = 2, s = {1, 1}) annotation(
|
||||
Placement(transformation(origin = {-40, 40}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.J1 v_com_bff(N = 2, s = {-1, -1}) annotation(
|
||||
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(
|
||||
Placement(transformation(origin = {40, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
|
||||
Modelica.Blocks.Continuous.Integrator w2phi(k = 1) annotation(
|
||||
Placement(transformation(origin = {30, 70}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.I m(I = [1, 0; 0, 1]) annotation(
|
||||
Placement(transformation(origin = {80, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.Se g(e0 = {0, -9.81}) annotation(
|
||||
Placement(transformation(origin = {2, -40}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.fsensor2d v_inertial annotation(
|
||||
Placement(transformation(origin = {40, -60}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
||||
Modelica.Blocks.Continuous.Integrator vx_to_x(k = 1, y_start = -0.5) annotation(
|
||||
Placement(transformation(origin = {70, -70}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Continuous.Integrator vy_to_y(k = 1) annotation(
|
||||
Placement(transformation(origin = {70, -100}, 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(
|
||||
Placement(transformation(origin = {70, -50}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Continuous.Integrator vy2y(y_start = 0) annotation(
|
||||
Placement(transformation(origin = {70, -80}, extent = {{-10, -10}, {10, 10}})));
|
||||
vis2d vis2d1 annotation(
|
||||
Placement(transformation(origin = {150, -6}, extent = {{-10, -10}, {10, 10}})));
|
||||
equation
|
||||
connect(w_com.P[2], mTFrot2lin.pR) annotation(
|
||||
Line(points = {{0, 120}, {0, 88}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(mTFrot2lin.pT, j0.P[1]) annotation(
|
||||
Line(points = {{0, 72}, {0, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(v_com_bff.P[1], j0.P[2]) annotation(
|
||||
Line(points = {{40, 40}, {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(
|
||||
Line(origin = {-1, 0}, points = {{0, 40}, {-40, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(wsensor.f, w2phi.u) annotation(
|
||||
Line(points = {{58, 90}, {78, 90}}, color = {0, 0, 127}));
|
||||
connect(w2phi.y, rTF.phi) annotation(
|
||||
Line(points = {{102, 90}, {110, 90}, {110, 0}, {48, 0}}, color = {0, 0, 127}, arrow = {Arrow.None, Arrow.Filled}));
|
||||
connect(v_com_in.P[2], mass.p) annotation(
|
||||
Line(points = {{40, -40}, {80, -40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(w_com.P[3], wsensor.p) annotation(
|
||||
Line(points = {{0, 120}, {44, 90}}, color = {0, 0, 127}, pattern = LinePattern.Dash, thickness = 0.75, arrow = {Arrow.None, Arrow.Open}, arrowSize = 6));
|
||||
connect(w_com.P[1], m_inertial.p) annotation(
|
||||
Line(points = {{0, 120}, {40, 120}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(ground2.p, j1.P[1]) annotation(
|
||||
Line(points = {{-72, 120}, {-40, 120}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(j1.P[2], w_com.P[4]) annotation(
|
||||
Line(points = {{-40, 120}, {0, 120}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.Half, Arrow.None}, arrowSize = 6));
|
||||
connect(ground.p, v_p_bff.P[2]) annotation(
|
||||
Line(points = {{-72, 40}, {-40, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(j1.P[3], w_hinge.P[1]) annotation(
|
||||
Line(points = {{-40, 120}, {-40, 90}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(w_hinge.P[2], hinge_r.p) annotation(
|
||||
Line(points = {{-40, 90}, {-80, 90}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(g.p, v_com_in.P[3]) annotation(
|
||||
Line(points = {{10, -40}, {40, -40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(v_com_bff.P[2], rTF.p2) annotation(
|
||||
Line(points = {{40, 40}, {40, 8}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(rTF.p1, v_com_in.P[1]) annotation(
|
||||
Line(points = {{40, -8}, {40, -40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(v_com_in.P[4], v_inertial.p) annotation(
|
||||
Line(points = {{40, -40}, {40, -54}}, color = {0, 85, 0}, pattern = LinePattern.Dash, thickness = 0.75, arrow = {Arrow.None, Arrow.Open}, arrowSize = 6));
|
||||
connect(v_inertial.f0, vx_to_x.u) annotation(
|
||||
Line(points = {{42, -66}, {42, -70}, {58, -70}}, color = {0, 0, 127}));
|
||||
connect(v_inertial.f1, vy_to_y.u) annotation(
|
||||
Line(points = {{38, -66}, {38, -100}, {58, -100}}, color = {0, 0, 127}));
|
||||
Placement(transformation(origin = {118, -64}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph.J0 j1(N = 3, s = {1, -1, 1}) annotation(
|
||||
Placement(transformation(origin = {-40, 100}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph.Sf sf(f0 = 0) annotation(
|
||||
Placement(transformation(origin = {-80, 100}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph.J1 hinge2(N = 2, s = {-1, -1}) annotation(
|
||||
Placement(transformation(origin = {-40, 70}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph.R r(R = 0.2) annotation(
|
||||
Placement(transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}})));
|
||||
equation
|
||||
connect(w_com.f, w2phi.u) annotation(
|
||||
Line(points = {{6, 94}, {18, 70}}, color = {0, 0, 127}));
|
||||
connect(w2phi.y, rTF1.phi) annotation(
|
||||
Line(points = {{41, 70}, {100, 70}, {100, 10}, {48, 10}}, color = {0, 0, 127}));
|
||||
connect(w_com.P[1], moi.p) annotation(
|
||||
Line(points = {{0, 100}, {40, 100}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(w_com.P[2], mTFrot2lin1.pR) annotation(
|
||||
Line(points = {{0, 100}, {0, 78}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(v_com_bff.P[1], j0.P[1]) annotation(
|
||||
Line(points = {{40, 40}, {0, 40}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(mTFrot2lin1.pT, j0.P[2]) annotation(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
Line(points = {{40, 2}, {40, -20}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(g.p, v_com_i.P[3]) annotation(
|
||||
Line(points = {{8, -20}, {40, -20}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(v_com_i.P[2], m.p) annotation(
|
||||
Line(points = {{40, -20}, {80, -20}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(v_com_i.f[1], vx2x.u) annotation(
|
||||
Line(points = {{46, -26}, {50, -50}, {58, -50}}, color = {0, 0, 127}));
|
||||
connect(v_com_i.f[2], vy2y.u) annotation(
|
||||
Line(points = {{46, -26}, {50, -80}, {58, -80}}, color = {0, 0, 127}));
|
||||
connect(vy2y.y, vis2d1.y) annotation(
|
||||
Line(points = {{82, -80}, {94, -80}, {94, -70}, {108, -70}}, color = {0, 0, 127}));
|
||||
connect(vx2x.y, vis2d1.x) annotation(
|
||||
Line(points = {{82, -50}, {94, -50}, {94, -64}, {108, -64}}, color = {0, 0, 127}));
|
||||
connect(w2phi.y, vis2d1.phi) annotation(
|
||||
Line(points = {{102, 90}, {110, 90}, {110, 0}, {141, 0}}, color = {0, 0, 127}));
|
||||
connect(vx_to_x.y, vis2d1.x) annotation(
|
||||
Line(points = {{82, -70}, {110, -70}, {110, -6}, {141, -6}}, color = {0, 0, 127}));
|
||||
connect(vy_to_y.y, vis2d1.y) annotation(
|
||||
Line(points = {{82, -100}, {118, -100}, {118, -12}, {141, -12}}, 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(
|
||||
Line(points = {{-40, 100}, {0, 100}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(sf.p, j1.P[1]) annotation(
|
||||
Line(points = {{-72, 100}, {-40, 100}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(hinge2.P[1], j1.P[2]) annotation(
|
||||
Line(points = {{-40, 70}, {-40, 100}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
connect(r.p, hinge2.P[2]) annotation(
|
||||
Line(points = {{-70, 70}, {-40, 70}}, color = {0, 0, 127}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6));
|
||||
annotation(
|
||||
uses(Modelica(version = "4.1.0")),
|
||||
experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.02),
|
||||
Diagram(coordinateSystem(extent = {{-100, 140}, {160, -120}})),
|
||||
Icon(coordinateSystem(extent = {{-200, -200}, {200, 200}})),
|
||||
version = "");
|
||||
uses(Modelica(version = "4.1.0")),
|
||||
experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.02),
|
||||
Diagram(coordinateSystem(extent = {{-100, 120}, {140, -100}})),
|
||||
Icon(coordinateSystem(extent = {{-200, -200}, {200, 200}})),
|
||||
version = "");
|
||||
end test2d;
|
||||
|
||||
model mTFrot2lin
|
||||
BondGraph.BondPort pR annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.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
|
||||
BondGraph._2D.BondPort p1 "Port 1" annotation(
|
||||
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
|
||||
BondGraph._2D.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;
|
||||
annotation(
|
||||
uses(Modelica(version = "4.1.0")));
|
||||
end test2d;
|
||||
Reference in New Issue
Block a user