Skip to content

Instantly share code, notes, and snippets.

@Foadsf
Created February 14, 2017 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Foadsf/3022d4abf1b273cadd4cc0ecdb4a749b to your computer and use it in GitHub Desktop.
Save Foadsf/3022d4abf1b273cadd4cc0ecdb4a749b to your computer and use it in GitHub Desktop.
model SimpleCarModel
extends Modelica.Icons.Example;
inner Modelica.Mechanics.MultiBody.World world(animateGravity = false) annotation(Placement(transformation(extent = {{-40, 40}, {-20, 60}}, rotation = 0, origin = {-40, -70}), visible = true));
Modelica.Mechanics.MultiBody.Joints.Prismatic prismatic(animation = false) annotation(Placement(visible = true, transformation(origin = {-20, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Forces.WorldForce force(animation = false) annotation(Placement(visible = true, transformation(origin = {-30, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Constant const annotation(Placement(visible = true, transformation(origin = {-70, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Constant const1 annotation(Placement(visible = true, transformation(origin = {-70, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Ramp ramp(duration = 2, startTime = 1) annotation(Placement(visible = true, transformation(origin = {-70, 71.62000000000001}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Parts.Body body(animation = false) annotation(Placement(visible = true, transformation(origin = {30, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.MultiBody.Visualizers.FixedShape fixedShape(shapeType = "Citroen2CV.obj", length = 1, width = 0.1, height = 0.1, specularCoefficient = 1, widthDirection = {-1, 0, 0}, lengthDirection = {0, 0, -1}) annotation(Placement(visible = true, transformation(origin = {30, 13.229}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(fixedShape.frame_a, prismatic.frame_b) annotation(Line(visible = true, origin = {-0.887, -3.386}, points = {{20.887, 16.614}, {-5.887, 16.614}, {-5.887, -16.614}, {-9.113, -16.614}}));
connect(prismatic.frame_b, body.frame_a) annotation(Line(visible = true, origin = {5, -20}, points = {{-15, 0}, {15, 0}}));
connect(ramp.y, force.force[1]) annotation(Line(visible = true, origin = {-47.75, 55.81}, points = {{-11.25, 15.81}, {2.75, 15.81}, {2.75, -15.81}, {5.75, -15.81}}, color = {0, 0, 127}));
connect(const1.y, force.force[3]) annotation(Line(visible = true, origin = {-47.75, 25}, points = {{-11.25, -15}, {2.75, -15}, {2.75, 15}, {5.75, 15}}, color = {0, 0, 127}));
connect(const.y, force.force[2]) annotation(Line(visible = true, origin = {-50.5, 40}, points = {{-8.5, 0}, {8.5, 0}}, color = {0, 0, 127}));
connect(force.frame_b, prismatic.frame_b) annotation(Line(visible = true, origin = {-10.887, 10}, points = {{-9.112, 30}, {4.113, 30}, {4.113, -30}, {0.887, -30}}));
connect(world.frame_b, prismatic.frame_a) annotation(Line(visible = true, origin = {-45, -20}, points = {{-15, 0}, {15, 0}}));
annotation(experiment(StopTime = 3), Documentation(info = "<html>
<p>
This example shows that a force component may have a mass.
The 3-dimensional spring as used in this example, has an optional
point mass between the two points where the spring is attached.
In the animation, this point mass is represented by a small,
light blue, sphere.
</p>
<IMG src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Examples/Elementary/SpringWithMass.png\"
ALT=\"model Examples.Elementary.SpringWithMass\">
</html>"));
end SimpleCarModel;
@Foadsf
Copy link
Author

Foadsf commented Feb 14, 2017

for some reason the original Wolfram community post is gone, so I upload it hear again.

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