Simple Pendulum

Introduction

This is a tutorial for creating a simple pendulum with a point mass attached to a rigid, mass-less beam, which has a single rotational degree-of-freedom (DOF), and in a uniform gravitational field. The animation below is generated in MOMDYN at the completion of the tutorial.

Animation of the pendulum in a 2-D diagram view

A depiction of this system is shown below, which shows the inertial reference frame with unit vectors nx and ny, single angular degree-of-freedom θ, the rotated reference frame with unit vectors ex and ey , the mass m, length l, and gravitational vector g.

Schematic depiction of the pendulum

The model is generated using two variations on the kinematics interface, “Classic,” and “Joints.” The former is akin to a pencil-and-paper approach, each symbolic parameter is individually named by the user, and each frame, vector, and point is created using these parameters. The latter is closer to the approach used in modern mulitibody dynamics software, where lower-level modeling attributes are consolidated into the joint object, reducing the total number of steps.

Create the New Model

Welcome screen Create screen Create screen, bottom

To begin, from the welcome screen tap the “Create” button, which will bring up a dialog with the title “Create - Specify Settings.” Many of the settings in this dialog can remain with their defaults. The modified specifications give a model name and description, and creates gravitational force, time, and tolerance. Enter the following:

Create - Specify Settings
  • model_name: Pendulum

  • model_description: A simple pendulum with a point mass and single angular degree of freedom

  • gravity_method: Uniform

  • gravity_constant: 9.8

  • gravity_direction: -Y

  • time_duration: 5

  • tol: 0.00001

Tap the green check in the lower right, which will bring up a blank diagram. Tap the save button, as we will be returning to this stage later in the tutorial.


Classic Interface

Here we will use the classic interface, which allows for more direct control over the fundamental building blocks of the kinematics. The joints interface is more convenient for many applications, as it consolidates functionality of the building block components into common mechanical joints, and doesn’t require individually defining all of the symbols, reference frames, vectors, and points in the model. If you are interested in using the joints interface, you may proceed to the joints section.

Symbols

Length

Diagram view, prior to creating symbols Edit menu New parameter

Tap the edit button (three horizontal bars) in the upper left to bring up the edit menu. We will first create the pendulum using the classic interface. Expand the classic panel, and tap the plus sign on the parameter line, which will bring up the new parameter dialog. Create a constant for pendulum length with the following specifications

New Parameter
  • name: l

  • value: 1

  • description: length

then tap the green plus sign after entering the values for each parameter to create it.

Angular Degree-of-Freedom

Edit menu New generalized coordinate

Next create the generalized coordinate, θ, corresponding to the angular degree of freedom. With the classic panel open, tap the plus sign to the left of generalized coordinate, and enter the following specifications

New Generalized Coordinate
  • name: theta

  • initial: 1

  • description: angle

noting that when theta is entered as the name, it will be replaced by the unicode character θ.

Kinematics

Orientation

Edit menu New frame Created frame in the diagram view

Once again, with the classic panel open, tap the plus sign to the left of frame, and enter the following (noting that line items that are not listed below can retain their default values)

New Frame
  • first_angle: θ(t)

tap the green check button to create the frame. This will create the new frame rotated by the angle θ measured about the out of plane axis k.

Vector

Edit menu New vector Created vector in the diagram view

Next, tap the plus sign to the left of vector, and enter the following

New Vector
  • name: r

  • ref_frame_key: E

  • x: l

and tap the green check button to create the vector named r, aligned with the ex axis of the rotated frame, with constant length l.

Point

Edit menu New point Created point in the diagram view

Finally, tap the plus sign to the left of point, and enter the following

New Point
  • vector_key: r

and tap the green check button to create the point a at the end of the vector r. Minimize the edit menu by tapping the three horizontal lines, at which point you should see the diagram updated to include the frame, vector, and point.


Joints Interface

Angular Degree of Freedom

Joints menu New revolute Created revolute joint in the diagram view

Tap on the welcome tab on the bottom of the screen, then the import button, and select the saved user.Pendulum file, which will return the model to its state after creating the model. Open the edit menu, and expand the joints panel, then tap the plus sign to the left of revolute. Add the following specifications, leaving line items that are unlisted at their default value,

New Revolute
  • name: E

  • z: 1

  • value: 1

and then tap the green check button to create the joint. This will create a new frame rotated about the out-of-plane k axis by an angle θE , similar to the output of step (5a). Notably, the creation of the generalized coordinate is combined with the generation of a reference frame in a single joint object.

Rigid, Massless Beam

Joints menu New rigid translation Created rigid translation in the diagram view

Next, tap the plus sign to the left of rigid translation, and add the following specifications

New Rigid Translation
  • ref_frame_key: E

  • x: 1

once again tapping the green check button to create the joint. This will create a new vector ra aligned with the exaxis with length 1, and a new point a, similar to the output of step (7a). Thus, in this example, the same kinematics definition requiring 5 steps using the classic interface, is completed using two joints.


Bodies

Mass Symbol

Classic menu New parameter

Reopen the edit menu, expand the classic panel, and create a constant for pendulum mass with the following specifications

New Parameter
  • name: m

  • value: 1

  • description: mass

Point Mass

Bodies menu New particle Created particle in the diagram view

Expand the bodies panel. Tap on the plus sign to the left of particle, and enter the following.

New Particle
  • name: bob

  • ref_point_key: a

  • mass: m

which will create the pendulum bob with mass m attached to the point a, as shown below.


Analysis

Simulation

To generate equations of motion, tap the right-arrow button in the lower left corner of the diagram. Since this is a very simple model, the derivation run nearly instantaneously. Once complete, the icon will change to the outline of a play button. Tap again to run the simulation, once again this will be nearly instantaneous. Tap again to play the animation, which will show the pendulum swinging from right to left with around a 3 second period, as seen previously at the top of this page.

Model Export

Open the edit menu by tapping the three horizontal lines in the upper left corner, and then tap on the export button. Tap each of the three line items, Model, Simulation, and Python, to activate them, and then tap the check button in the lower right to export the files. The Model file (momdyn_model.py) is the format used to import to the MOMDYN app. The Simulation file (simulation.csv) are the time-series reflecting the generalized coordinates and speeds that are animated. The Python file (py_model.py) contains code that can be executed and further manipulated on a desktop Python environment.

Press the export button in the menu Select to export model, simulation, and python Exported Python code, shown in the Pyto app Plotted states

Report

Tap on the report tab in the lower right to open up the report view showing text, equations and plots. The buttons at the top specify which section of the report to view. From left to right these are symbols, frames, points, bodies, loads, equations, and plots. The images below show these sections for the Pendulum model, omitting loads as there are none (except for gravity).

Symbols in the report view Frames in the report view Points in the report view Bodies in the report view Equations in the report view Plots in the report view