Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Free Body in space

Free Body in space

I managed to modify the FreeBody example from the mechanics multibody example, setting the two spring constants to 0 and the initial velocity to 1 m/s in e.g x-Direction.
But making the model simpler, no body appears in the animation and in the simulation the body seems not to move as expected.

Free Body with modified spring constants

Code:


within Modelica.Mechanics.MultiBody.Examples.Elementary;
model FreeBody "Free flying body attached by two springs to environment"
  extends Modelica.Icons.Example;
  parameter Boolean animation=true "= true, if animation shall be enabled";
  inner Modelica.Mechanics.MultiBody.World world(animateGravity = true, gravityType = Modelica.Mechanics.MultiBody.Types.GravityTypes.NoGravity)  annotation (Placement(
        transformation(extent={{-60,20},{-40,40}})));
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation bar2(r={0.8,0,0}, animation=false)
    annotation (Placement(transformation(extent={{0,20},{20,40}})));
  Modelica.Mechanics.MultiBody.Forces.Spring spring1(
    width=0.1,
    coilWidth=0.005,
    numberOfWindings=5,
    c=0,
    s_unstretched=0) annotation (Placement(transformation(
        origin={-20,6},
        extent={{-10,-10},{10,10}},
        rotation=270)));
  Modelica.Mechanics.MultiBody.Parts.BodyShape body(
    m=1,
    I_11=1,
    I_22=1,
    I_33=1,
    r={0.4,0,0},
    r_CM={0.2,0,0},
    width=0.05,
    r_0(start={0.2,-0.5,0.1}, each fixed=true),
    v_0(each fixed=true),
    angles_fixed=true,
    w_0_fixed=true,
    angles_start={0.174532925199433,0.174532925199433,0.174532925199433})
    annotation (Placement(transformation(extent={{0,-40},{20,-20}})));
  Modelica.Mechanics.MultiBody.Forces.Spring spring2(
    c=0,
    s_unstretched=0,
    width=0.1,
    coilWidth=0.005,
    numberOfWindings=5) annotation (Placement(transformation(
        origin={40,6},
        extent={{-10,-10},{10,10}},
        rotation=270)));
equation
  connect(bar2.frame_a, world.frame_b)
    annotation (Line(
      points={{0,30},{-40,30}},
      color={95,95,95},
      thickness=0.5));
  connect(spring1.frame_b, body.frame_a) annotation (Line(
      points={{-20,-4},{-20,-30},{0,-30}},
      color={95,95,95},
      thickness=0.5));
  connect(bar2.frame_b, spring2.frame_a)
    annotation (Line(
      points={{20,30},{40,30},{40,16}},
      color={95,95,95},
      thickness=0.5));
  connect(spring1.frame_a, world.frame_b) annotation (Line(
      points={{-20,16},{-20,30},{-40,30}},
      color={95,95,95},
      thickness=0.5));
  connect(body.frame_b, spring2.frame_b) annotation (Line(
      points={{20,-30},{40,-30},{40,-4}},
      color={95,95,95},
      thickness=0.5));
  annotation (
    experiment(StopTime=10),
    Documentation(info="<html>
<p>
This example demonstrates:
</p>
<ul>
<li>The animation of spring and damper components</li>
<li>A body can be freely moving without any connection to a joint.
    In this case body coordinates are used automatically as
    states (whenever joints are present, it is first tried to
    use the generalized coordinates of the joints as states).</li>
<li>If a body is freely moving, the initial position and velocity of the body
    can be defined with the \"Initialization\" menu as shown with the
    body \"body1\" in the left part (click on \"Initialization\").</li>
</ul>

<IMG src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Examples/Elementary/FreeBody.png\"
ALT=\"model Examples.Elementary.FreeBody\">
</html>"));
end FreeBody;

Free Body simplified, not working

Code:


model Attitude_manover_body
  model MyBodyShape
    extends Modelica.Mechanics.MultiBody.Parts.BodyShape;
    /*    parameter Real down_To_Reach(unit = "m") = 1000, max_Velocity_Abs(min = 0, unit = "m/s") = 100,     acc_Abs(min = 0, unit = "m/s^2") = 9.81;
        Real velocity_Down(start = 0.0, unit = "m/s");
        Real acceleration_Down(unit = "m/s^2");
        Real abs_Down_To_Reach = abs(down_To_Reach);
        Real time_Start_Decelaration(unit = "s") = if max_Velocity_Abs * max_Velocity_Abs / acc_Abs >   abs_Down_To_Reach then sqrt(abs_Down_To_Reach / acc_Abs) else abs_Down_To_Reach / max_Velocity_Abs;
      equation
        v_0[3] = velocity_Down;
        a_0[3] = acceleration_Down; 
        acceleration_Down = acc_Abs * sign(down_To_Reach);
        when abs(velocity_Down) >= max_Velocity_Abs then
          reinit(acceleration_Down, 0);
        end when;
        when time > time_Start_Decelaration then
          reinit(acceleration_Down, -acc_Abs * sign(down_To_Reach));
        end when;
        when velocity_Down * sign(down_To_Reach) < 0 then
          reinit(acceleration_Down, 0);
        end when;*/
  end MyBodyShape;

  inner Modelica.Mechanics.MultiBody.World world(animateGravity = true, driveTrainMechanics3D = true, gravityType = Modelica.Mechanics.MultiBody.Types.GravityTypes.NoGravity) annotation(
    Placement(visible = true, transformation(extent = {{-70, 26}, {-50, 46}}, rotation = 0)));
  MyBodyShape body(I_11 = 1, I_22 = 1, I_33 = 1, angles_fixed = true, angles_start = {0.174532925199433, 0.174532925199433, 0.174532925199433}, m = 1, r = {0, 0, 0}, r_0(fixed = true, start = {0.0, 0.0, 0.0}), r_CM = {0.2, 0, 0}, v_0(fixed = true, start = {1.0,0.0,0.0}), w_0_fixed = true, width = 0.05) annotation(
    Placement(visible = true, transformation(extent = {{-16, 26}, {4, 46}}, rotation = 0)));
equation
  connect(world.frame_b, body.frame_a) annotation(
    Line(points = {{-50, 36}, {-16, 36}, {-16, 36}, {-16, 36}}, color = {95, 95, 95}));
end Attitude_manover_body;

Thanks in advance

There are 0 guests and 0 other users also viewing this topic