MV-9000: Bouncing Ball Tutorial
In this tutorial, you will learn how to model a simple 1 DOF mechanism using the Msolve Python API.
If you are running this tutorial as IPython notebook, you can interactively execute each code cell by clicking SHIFT-ENTER. The output of the Python code (if any) is displayed and the execution jumps to the next cell.
Load the Msolve Module
In [2]: from msolve import*
The
above command requires the msolve module be in your computer path. Assuming the
above is successful, you have imported the msolve names into the current
namespace. This means you have access to all the classes and functions defined
in msolve and can start creating the bouncing ball case.Create a Model
To create the pendulum mechanism, you must first create a model.
In [3]: model = Model()
The above command requires the
msolve module be in your computer path. Assuming the above is successful, you
have imported the msolve names into the current namespace. This means you have
access to all the classes and functions defined in msolve and can start creating
the bouncing ball case.Add Units and Gravity
After creating a model, you can add details, units, and other entities such as gravity and ground. Most entities have default properties. For example, when you create the solver unit set without specifying arguments, you are essentially creating SI units.
Create Markers
Next, you can create markers on the ground part. A marker is defined by a geometric point in space and a set of three mutually perpendicular coordinate axes emanating from that point. It can be used as a reference frame of the part that it belongs to.
In [7]: global_ref = Marker(part=ground)
Create a Geometry Object
For animation purposes, you can create a geometry object. In this case, a box representing the ground. According to the documentation, a box requires a center marker and its x,y,z dimension.
Define the Contact Force
You can define the contact force between the ground and the sphere. First, define a marker on each part at the contacting point. These two markers are used in the force calculation and displacement monitor.
Add Joints and Requests
You can add a translational joint here to prevent the ball from flapping around (although it is not necessary). To create a joint, define the type of the joint as well as the markers that the joint is placed on. The z axis of marker j defines the direction of translational joint.
You can also create a request. Requests define output channels in MotionSolve and are written to MotionSolve output files so that they may be used for plotting and signal processing by HyperGraph. Requests can be defined using runtime expressions, built-in functions (MOTION, FORCE, FIELD, and so on), or user-written functions.
Run the Simulation
At this point you are ready to run a transient analysis. The simulate method is invoked on the MBS model. A validation process is performed on each of the entities that make up the model. This is a necessary step to ensure that only correct models are being simulated. Note that the simulate command can be invoked with an optional flag, returnResults, set to True. This stores the results of the simulation into a run container for further post-processing, as shown below.