package 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( Placement(transformation(origin = {0, 100}, extent = {{-10, -10}, {10, 10}}))); BondGraph.I moi(I = momentOfInertia, state(fixed = false)) annotation( Placement(transformation(origin = {40, 100}, extent = {{-10, -10}, {10, 10}}))); mTFrot2lin mTFrot2lin1(r_body = {-0.5*length, 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}}))); rTF rTF1 annotation( Placement(transformation(origin = {40, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); Modelica.Blocks.Continuous.Integrator w2phi(y_start=startAngle) annotation( Placement(transformation(origin = {30, 70}, extent = {{-10, -10}, {10, 10}}))); BondGraph._2D.I m(I = [mass, 0; 0, mass]) annotation( Placement(transformation(origin = {80, -20}, extent = {{-10, -10}, {10, 10}}))); BondGraph._2D.Se g(e0 = {0, -9.81*mass}) annotation( Placement(transformation(origin = {0, -20}, extent = {{-10, -10}, {10, 10}}))); Modelica.Blocks.Continuous.Integrator vx2x(y_start=-0.5*length*cos(startAngle)) annotation( Placement(transformation(origin = {70, -50}, extent = {{-10, -10}, {10, 10}}))); Modelica.Blocks.Continuous.Integrator vy2y(y_start=-0.5*length*sin(startAngle)) annotation( Placement(transformation(origin = {70, -80}, extent = {{-10, -10}, {10, 10}}))); vis2d vis2d1 annotation( Placement(transformation(origin = {118, -64}, extent = {{-10, -10}, {10, 10}}))); rTF rTF2 annotation( Placement(transformation(origin = {-40, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); BondGraph._2D.J1 v_P_i(N = 2, s = {1, 1}) annotation( Placement(transformation(origin = {-40, -20}, extent = {{-10, -10}, {10, 10}}))); BondGraph.BondPort rotIn annotation( Placement(transformation(origin = {-30, 100}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {0, 198}, extent = {{-10, -10}, {10, 10}}))); BondGraph._2D.BondPort trans_i annotation( 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 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(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 = {{42, 70}, {100, 70}, {100, -58}, {108, -58}}, color = {0, 0, 127})); connect(w2phi.y, rTF2.phi) annotation( Line(points = {{42, 70}, {100, 70}, {100, 26}, {-20, 26}, {-20, 10}, {-32, 10}}, color = {0, 0, 127})); connect(v_P_bff.P[2], rTF2.p2) annotation( Line(points = {{-40, 40}, {-40, 18}}, color = {0, 85, 0}, thickness = 0.75, arrow = {Arrow.None, Arrow.Half}, arrowSize = 6)); connect(rTF2.p1, v_P_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(rotIn, w_com.P[3]) annotation( 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( uses(Modelica(version = "4.1.0")), Diagram(coordinateSystem(extent = {{-100, 120}, {140, -100}})), 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 = "", experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.002)); end pendulum; 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; 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( uses(Modelica(version = "4.1.0"))); end test2d;