Simulation of a pendulum driven by an optional periodic torque force.

Variables and Parameters

The 'bob' (point mass) at the end of a massless rod is suspended from a fixed point. We use coordinate system with y increasing upwards. The fixed anchor point is at the origin.

Variables:

  • th = angle formed with vertical, positive is counter clockwise
  • v = velocity of angle = th'

Parameters:

  • m = mass of bob
  • g = gravity constant
  • L = length of rod
  • b = friction constant
  • A = amplitude of driving force
  • k = determines frequency of driving force

The position of the pendulum is given by U = position of center of mass

Ux = L sin(th)
Uy = -L cos(th)

We set the radius of the arc that represents the driving force to be 0.5 times the amplitude A.

Equations of Motion

The derivation of the equations of motion is shown at

Use the rotational analog of Newton's second law:

Σ torques = I a

where I = rotational inertia, and a = v' = angular acceleration.

  • Rotational inertia I = m L^2

  • Torque due to gravity is -L m g sin(th)

  • Torque due to friction is -b v

  • Torque due to driving force is A cos(w) where A is constant amplitude and w = k t is a linear function of time.

Then Σ torques = I a becomes

-L m g sin(th) - b v + A cos(w) = m L^2 v'

This can be rearranged to get the equations of motion (these are implemented in evaluate):

th' = v
v' = -(g / L) sin(th) -(b /m L^2) v + (A / m L^2) cos(k t)

Settings for Chaotic Pendulum

Compare our equations of motion to equation 3.1 in Chaotic Dynamics by Baker/Gollub (translated to equivalent variables):

v' = - sin(th) - v / q + A cos(k t)

The range of chaos according to Baker/Gollub is: q=2, 0.5<A<1.5, k=2/3. If we have m = L = g = 1, then we need:

  • L = 1.0 = rod length
  • m = 1.0 = mass
  • g = 1.0 = gravity
  • A = 1.15 = drive amplitude
  • k = 2.0/3.0 = drive frequency
  • b = 1/q = 0.5 = damping

Variables Array

The variables are stored in the VarsList as follows

vars[0] = th
vars[1] = v
vars[2] = time
vars[3] = th''  acceleration of angle
vars[4] = ke, kinetic energy
vars[5] = pe, potential energy
vars[6] = te, total energy

TO DO add ParameterBoolean specifying whether to limit angles to +/-Pi.

Hierarchy (view full)

Implements

Constructors

Properties

amplitude_: number = 1.15

amplitude of driving torque

drive_: Arc = ...

the Arc tracks the drive frequency and amplitude

frequency_: number = ...

frequency of driving torque

initialState_: null | number[] = null

Initial values.

limitAngle_: boolean = true

Whether to limit the pendulum angle to +/- Pi

pivot_: Vector = Vector.ORIGIN

location of pivot point

potentialOffset_: number = 0

potential energy offset

Methods

  • Adds the given Observer to this Subject's list of Observers, so that the Observer will be notified of changes in this Subject. An Observer may call Subject.addObserver during its observe method.

    Parameters

    Returns void

  • Defines the differential equations of this ODESim; for an input set of variables, returns the current rate of change for each variable (the first derivative of each variable with respect to time).

    The timeStep is the time since the state variables were last fully calculated, which can be and often is zero. The current time can be regarded as getTime() + timeStep. The input variables correspond to the Simulation state at that time. Note that timeStep is different from the time step used to advance the Simulation (as in AdvanceStrategy.advance). The timeStep is typically used when finding collisions in CollisionSim.findCollisions.

    Parameters

    • vars: number[]

      the current array of state variables (input), corresponding to the state at getTime() + timeStep

    • change: number[]

      array of change rates for each variable (output), all values are zero on entry.

    • _timeStep: number

      the current time step (might be zero)

    Returns null | object

    null if the evaluation succeeds, otherwise an object relating to the error that occurred. The change array contains the output results.

  • Called at the end of a mouse drag operation, performs whatever action is appropriate. Only called if startDrag returned true.

    Parameters

    • simObject: null | SimObject

      the SimObject being dragged, or null if no SimObject was found

    • _location: Vector

      the location of the mouse in simulation coordinates of the SimView where simObject was found, or in the focus view if simObject is null.

    • _offset: Vector

      distance from the initial object position to the mouse location at start of drag.

    Returns void

  • Return amplitude of the rotating driving force

    Returns number

    amplitude of the rotating driving force

  • Return frequency of the rotating driving force

    Returns number

    frequency of the rotating driving force

  • Return whether we limit the pendulum angle to +/- Pi

    Returns boolean

    whether we limit the pendulum angle to +/- Pi

  • Called when a key is pressed or released, performs whatever action is appropriate for that event.

    Parameters

    • _evt: KeyboardEvent

      the KeyboardEvent that happened

    • _pressed: boolean

      true means this is a key-down event; false means a key-up event

    • _modifiers: ModifierKeys

      the modifier keys down during event

    Returns void

  • Called at each movement during a mouse drag, performs whatever action is appropriate. Only called if startDrag returned true. The SimObject being moved is passed in, along with the current mouse position, in simulation coordinates, and an offset calculated at the start of the drag.

    Setting the SimObject position to (x - offsetX, y - offsetY) will move the SimObject smoothly along with the mouse movement.

    Parameters

    • simObject: null | SimObject

      the SimObject being dragged, or null if no SimObject was found

    • location: Vector

      the location of the mouse in simulation coordinates of the SimView where simObject was found, or in the focus view if simObject is null.

    • offset: Vector

      distance from the initial object position (from DisplayObject.getPosition) to the mouse location at start of drag.

    Returns void

  • Sets whether this Subject will broadcast events, typically used to temporarily disable broadcasting. Intended to be used in situations where a subclass overrides a method that broadcasts an event. This allows the subclass to prevent the superclass broadcasting that event, so that the subclass can broadcast the event when the method is completed.

    Parameters

    • value: boolean

      whether this Subject should broadcast events

    Returns boolean

    the previous value

  • Set amplitude of the rotating driving force

    Parameters

    • value: number

      amplitude of the rotating driving force

    Returns void

  • Set frequency of the rotating driving force

    Parameters

    • value: number

      frequency of the rotating driving force

    Returns void

  • Set whether mouse drag is in progress

    Parameters

    • value: boolean

      whether mouse drag is in progress

    Returns void

  • Set whether we limit the pendulum angle to +/- Pi

    Parameters

    • value: boolean

      whether we limit the pendulum angle to +/- Pi

    Returns void

  • Called at the start of a mouse drag. The nearest dragable SimObject is passed in, along with mouse position in simulation coordinates. If no dragable SimObject was found, null is passed for the first argument. If the EventHandler does not recognize the SimObject then it should return false.

    Parameters

    • simObject: null | SimObject

      the SimObject that is nearest to the mouse drag coordinates, or null if no SimObject was found

    • _location: Vector

      the location of the mouse in simulation coordinates of the SimView where simObject was found, or in the focus view if simObject is null.

    • _offset: Vector

      distance from the initial object position (from DisplayObject.getPosition) to the mouse location at start of drag

    • _dragBody: null | Vector

      location of 'drag point' on the SimObject in body coordinates of the SimObject; this is where for example a spring will be attached on the SimObject when dragging; or null when no SimObject was found

    • _modifiers: ModifierKeys

      the modifier keys down during event

    Returns boolean

    true if the EventHandler will handle dragging the SimObject

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc