lars111
lars111

Reputation: 1313

Modelica spring-pendulum

I want to model a simple "spring-pendulum" in modelica:

model Pendulum

  parameter Boolean animation=true "= true, if animation shall be enabled";
  inner Modelica.Mechanics.MultiBody.World world(axisLength=0.6)
          Modelica.Mechanics.MultiBody.Parts.Body body1(
    m=1,
    animation=animation,
    I_11=1,
    I_22=1,
    I_33=1,
    r_CM={0,0,0},
    cylinderDiameter=0.05,
    sphereDiameter=0.2) 
  Modelica.Mechanics.MultiBody.Forces.Spring spring1(
    coilWidth=0.01,
    numberOfWindings=5,
    c=20,
    s_unstretched=0.2) ;
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute(phi(fixed=true), w(
        fixed=true));
equation 
  connect(world.frame_b, revolute.frame_a) 
  connect(spring1.frame_a, revolute.frame_a) 
  connect(spring1.frame_b, body1.frame_a) 
  connect(revolute.frame_b, body1.frame_a
end Pendulum;

Trying to simulate the simulation fail - no error message. Do i need a revolulte for a spring-pendulum? Thank you very much for your help!

Upvotes: 1

Views: 183

Answers (1)

jrhodin
jrhodin

Reputation: 669

Not exactly sure of what you're trying to model. If you make a drawing of your system you'll see that it won't represent what you're trying to model (I think).

Here's a pendulum with a spring:

model pendulum2
  inner Modelica.Mechanics.MultiBody.World world annotation(Placement(visible = true, transformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute annotation(Placement(visible = true, transformation(origin = {-41.539, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Joints.Prismatic prismatic(s.start = .5) annotation(Placement(visible = true, transformation(origin = {-10, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.Body body annotation(Placement(visible = true, transformation(origin = {25, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Forces.Spring spring(c = 100, s_unstretched = .5) annotation(Placement(visible = true, transformation(origin = {-10, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(spring.frame_b, prismatic.frame_b) annotation(Line(visible = true, origin = {0, 10}, points = {{0, 10}, {0, -10}}));
  connect(spring.frame_a, prismatic.frame_a) annotation(Line(visible = true, origin = {-20, 10}, points = {{0, 10}, {0, -10}}));
  connect(prismatic.frame_b, body.frame_a) annotation(Line(visible = true, origin = {7.5, 0}, points = {{-7.5, -0}, {7.5, 0}}));
  connect(revolute.frame_b, prismatic.frame_a) annotation(Line(visible = true, origin = {-25.77, 0}, points = {{-5.77, 0}, {5.77, 0}}));
  connect(world.frame_b, revolute.frame_a) annotation(Line(visible = true, origin = {-60.77, 0}, points = {{-9.23, 0}, {9.23, 0}}));
  annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
end pendulum2;

Upvotes: 1

Related Questions