Message Boards Message Boards

0
|
8406 Views
|
9 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Modeling a brick subjected to gravity with SystemModeler?

Posted 8 years ago

Most of the questions on this forum are of way higher level than those I need to ask, but I haven't found any other place, so here they come.

As my first (and only so far) achievement with SystemModeler, I was able to design a brick and have it subjected to gravity.

But when the simulation starts, it goes straight through the ground.

1) Why doesn't my brick simply lie on the ground ?

2) How do I apply a constant force on my brick in a chosen direction ? I found a relatively close example but it involves several models I don't understand and can't adapt to what I intend to do.

3) I saw several animations in which it was possible to change the value of a parameter (say, the brick's mass, the force applied,...) with a slider, but all had been designed exclusively with Mathematica. Is it available in SM also ? (and where ?)

Thank you for helping a free-lance amateur.

POSTED BY: Ch' Prof
9 Replies
Posted 8 years ago

Also, I'm struggling over how to set values in an array using Mathematica sliders.

enter image description here

POSTED BY: Ch' Prof
Posted 8 years ago

Thank you Patrik,

As you can see, my first model is soon finished :

enter image description here

But nevertheless, here comes a new question.

I would like to add a checkerboard ground to my simulation, like in this model.

enter image description here

I haven't been able to see how it's been done. Could you explain it ?

POSTED BY: Ch' Prof

That picture looks like nice! Glad that you are on your way!

  1. What does "Frame in which input force is resolved" mean ?

When you specify a force you specify x,y,z coordinates. Since bodies can be rotated it is often ambiguous which coordinate system (or frame) to use.

Resolved force

In the above picture (from attached model, ResolveForce.mo) I rotated a rod 180 degrees around the y-axis. You can see the result from comparing the two animated frames/axes. I then applied a force of a certain magnitude along the x-axis. This force was resolved in frameb which meant it used the rotated coordinate system. If it had been resolved in the world frame, the arrow would be pointing to the left (along the original x-axis). You can also choose where in the system to resolve your frame by choosing frameresolve and connecting the dotted frame to a part of your system. In the attached model, I chose that, so if you want, you can try different frames to connect it to. (Though in that small model, there will only be two outcomes, one that is the same as the world frame, and one that is the same as frame_b).

I think most of the time you will want to resolve your forces in the world frame, it is more intuitive to think along the lines of x,y,z coordinates. Its for integrated engineering tasks you mostly have to think about how you resolve things.

  1. Also, is there an option somewhere to have forces vectors "nose out" ?

There does not seem to be one. You can however use the Modelica.Mechanics.MultiBody.Visualizers.SignalArrow visualizer. It will define an arrow that starts at the position given by framea and extends along a vector given by the 3-dimensional signal. This will always be resolved in framea however. See ForceArrow.mo.

Force arrow

  1. Can I setup the initial position of the camera ?

No sorry, I do not think so!

  1. I would like to have sliders to easily setup my simulation, just like in this demonstration. Are they available in SM as in Mathematica ?

There are no sliders in SystemModeler but as you mentioned, there are sliders in Mathematica, and that makes them kind of in SystemModeler too, through WSMLink.

For example, the following Mathematica code will create a slider that sets amplitude of the applied force in the ResolveForce model.

Needs["WSMLink`"]

mod = "ResolveForce";
Manipulate[
 WSMSetValues[mod, {"pulse.amplitude" -> amp}],
 {amp, 0, 1000},
 ContinuousAction -> False]

You can for example generate a palette to use only the control part.

force slider

palette

What is it that you want to set up with sliders and controls?

Attachments:
POSTED BY: Patrik Ekenberg
Posted 8 years ago

I need some other information though :

  1. What does "Frame in which input force is resolved" mean ? enter image description here

  2. Also, is there an option somewhere to have forces vectors "nose out" ?

  3. Can I setup the initial position of the camera ?

  4. I would like to have sliders to easily setup my simulation, just like in this demonstration. Are they available in SM as in Mathematica ?

enter image description here

POSTED BY: Ch' Prof
Posted 8 years ago

I resumed practicing with SM this afternoon and thanks to your explanations, got it now. I made huge progress.

Here is what I'm trying to design : a very simple simulation that allows me to explain Newton's 1st and 2nd laws, and show why we use integration to go from acceleration to speed then to position :

enter image description here

You setup masses, velocities and forces on 2 different mobiles, and compare their evolutions.

Thanks again Patrik !

POSTED BY: Ch' Prof

I missed that you had replied to this thread, sorry!

I am glad that you found my tutorial helpful!

You can think of framea and frameb as two points in a coordinate system. The vector r[3] will describe their relative displacement from one another. If framea is in at {0,0,0}, and r[3]={1,1,0} then frameb will be located one unit along the x-axis and up one unit along the y-axis.

The BodyBox component will draw a rectangular parallelpiped between the origin and frameb. The location of the origin is determined by rshape[3] which is the vector from the point defined by framea to the box origin. The length of the body will be determined by the length of the vector r[3]-rshape[3], in Modelica written as:

Modelica.Math.Vectors.length(r - r_shape)

So if we use the previous example where framea is at point {0,0,0} and r[3]={1,1,0} then, as mentioned previously, frameb will be at point {1,1,0}. If r_shape[3]={0,1,0} then a body will be drawn between {1,0,0} since

r-r_shape={1,1,0}-{0,1,0}={1,0,0}

i.e one unit distance along the x-axis and it will have length 1. The width and height of the box is set by the width and height parameters respectively.

I have, however, never seen anyone use anything beside rshape[3]={0,0,0} which then means a body will be drawn between framea and frame_b. (As long as you haven't changed the length or lengthDirection parameters).

What is it you are trying to accomplish? Maybe I can be of better use if I know more.

POSTED BY: Patrik Ekenberg
Posted 8 years ago

Anyone ?

POSTED BY: Ch' Prof
Posted 8 years ago

Thank you very much Patrik, for your time and efforts.

I learned a lot more studying your tutorial this morning than during last few days.

A couple of things should be clarified though, regarding coordinates :

I understood r[3] and r_shape[3] decide of the position of a point of the BodyBox (Which point ?) and its orientation, but I can't figure out what frames are : on a Multibody/Parts/BodyBox, it looks like frame_a and frame_b aren't specific points on the box itself, like center of faces, what are they exactly ?

POSTED BY: Ch' Prof

Hi and welcome to the SystemModeler community!

I am assuming you used the Modelica MultiBody library for modelling your brick. I was looking for good introductory examples that explained the basic concepts of the MultiBody but did not find anything that I was satisfied with so I decided to write a tutorial.

I tried to make it general so that it could be useful for others also so I did not answer your questions directly there. I separated the instructions into 5 steps, and in the file that I attached you will find a model for each of the steps. Your first question (“Why doesn't my brick simply lie on the ground?”) will be answered in step/model 2 (BouncingSurface2). Your second question I will try and answer in step/model 3 (BouncingSurface3). Some of these things you might be familiar with already, so you can possibly skip ahead to step 2 and 3, or read it from the beginning.

Or if you just prefer the short answers: 1) Because you haven't yet added any equations or components that keep it up from falling through the ground and by there is be default a gravitational pull in the negative y-direction. You can remove the gravitational pull by changing the g parameter in the world component to 0. 2) You can for example use the Modelica.Mechanics.MultiBody.Forces.WorldForce block. To see how you can connect it up to your object, see model 3 (BouncingSurface3).

I attached the tutorial and the model to this post. I am thinking about refining it and making it a post here in the community, so if you decide to read it, and there is anything that you find that is unclear please let me know so I can polish it!

Cheers, Patrik!

Attachments:
POSTED BY: Patrik Ekenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract