Skip to content

Instantly share code, notes, and snippets.

@dietmarw
Last active August 5, 2016 19:07
Show Gist options
  • Save dietmarw/1460972583c1d82458cbb80a185197fb to your computer and use it in GitHub Desktop.
Save dietmarw/1460972583c1d82458cbb80a185197fb to your computer and use it in GitHub Desktop.
within ;
model Planar4Bar "Planar4Bar.mo"
inner Modelica.Mechanics.MultiBody.World world(
animateWorld=false,
animateGravity=false) annotation(Placement(transformation(extent={{-105,-45},{-85,-25}})));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(
phi(fixed=true),
w(start=5,fixed=true)) annotation(Placement(transformation(extent={{-55,-30},{-35,-10}})));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute2 annotation(Placement(transformation(extent={{25,-30},{45,-10}})));
Modelica.Mechanics.MultiBody.Joints.Revolute revolute3 annotation(Placement(transformation(extent={{-55,20},{-35,40}})));
Modelica.Mechanics.MultiBody.Joints.RevolutePlanarLoopConstraint revolute4 annotation(Placement(transformation(extent={{25,20},{45,40}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder1(
r={0,2,0},
diameter=0.05) annotation(Placement(transformation(
origin={-80,10},
extent={{-10,-10},{10,10}},
rotation=90)));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder2(
r={-5,0,0},
diameter=0.05,
r_0(each fixed=true)) annotation(Placement(transformation(extent={{-15,-30},{5,-10}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder3(
r={4,1,0},
diameter=0.05) annotation(Placement(transformation(extent={{-15,20},{5,40}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder4(
r={1,-3,0},
diameter=0.05) annotation(Placement(transformation(
origin={60,10},
extent={{-10,-10},{10,10}},
rotation=-90)));
equation
connect(bodyCylinder1.frame_b,revolute3.frame_a) annotation(Line(
points={{-80,20},{-80,25},{-80,30},{-60,30},{-55,30}},
color={95,95,95}));
connect(revolute3.frame_b,bodyCylinder3.frame_a) annotation(Line(
points={{-35,30},{-30,30},{-20,30},{-15,30}},
color={95,95,95}));
connect(bodyCylinder2.frame_b,revolute2.frame_a) annotation(Line(
points={{5,-20},{10,-20},{20,-20},{25,-20}},
color={95,95,95}));
connect(bodyCylinder4.frame_b,revolute2.frame_b) annotation(Line(
points={{60,0},{60,-5},{60,-20},{50,-20},{45,-20}},
color={95,95,95}));
connect(bodyCylinder3.frame_b,revolute4.frame_a) annotation(Line(
points={{5,30},{10,30},{20,30},{25,30}},
color={95,95,95}));
connect(revolute4.frame_b,bodyCylinder4.frame_a) annotation(Line(
points={{45,30},{50,30},{60,30},{60,25},{60,20}},
color={95,95,95}));
connect(bodyCylinder1.frame_a,revolute1.frame_b) annotation(Line(
points={{-80,0},{-80,-5},{-30,-5},{-30,-20},{-35,-20}},
color={95,95,95}));
connect(revolute1.frame_a,world.frame_b) annotation(Line(
points={{-55,-20},{-60,-20},{-80,-20},{-80,-35},{-85,-35}},
color={95,95,95}));
connect(world.frame_b,bodyCylinder2.frame_a) annotation(Line(
points={{-85,-35},{-80,-35},{-20,-35},{-20,-20},{-15,-20}},
color={95,95,95}));
annotation(uses(Modelica(version="3.2.1")));
end Planar4Bar;
@johanrhodin
Copy link

I suggest adding:

  • experiment(StopTime = 8) to annotation()
  • extends Modelica.Icons.Example;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment