# Class ReactionPendulumApp

Displays the reaction forces pendulum simulation ReactionPendulumSim and compares it to the classic pendulum simulation PendulumSim which is shown alongside. The simultaneous simulations show that the two pendulums are equivalent in their motion. This also confirms that the calculation for equivalent arm length (see below) is correct.

Something to notice is that the reaction force diverges more from the stick vector as the size of disk increases. This is because a smaller disk is closer to the ideal of a point mass in the classic pendulum simulation.

## Keep Parameters Synchronized

We keep the parameters for gravity, mass and length of pendulum synchronized between the two simulations (though length is slightly different, see below).

The damping model is different for the two simulations so we don't try to synchronize the damping; we just leave both simulations with zero damping.

## Length of Equivalent Classic Pendulum

To match the motion of the two simulations, the lengths are slightly different. The ReactionPendulumSim simulation models the pendulum as a rigid disc with mass distributed evenly. The classic ideal PendulumSim models the pendulum as a point mass at the end of a massless rod.

We want to find the length of the simple ideal pendulum that is equivalent to the rigid body disk pendulum.

Rotation of a solid cylinder of radius r about its cylinder axis has rotational inertia

I = m r^2 / 2


Use parallel axis theorem, where the CM (center of mass) is at distance h from the pivot point, to get rotational inertia of:

I = m r^2 / 2 + m h^2


Use rotational analog of Newton's second law of motion about a fixed axis which is

I \theta'' = sum of torques


Here the only torque is from gravity at the CM:

I \theta'' = -h m g sin(\theta)


expand this using the value for I found above

\theta'' =  -h m g sin(\theta) / (m r^2 / 2 + m h^2)
= -h g sin(\theta) / (r^2/2 + h^2)


what would be the equivalent length of a simple point mass pendulum? Let

R = the length of that equivalent simple pendulum
I = m R^2


then we have

I \theta'' = - m g R sin (\theta)
\theta'' = - g sin (\theta) / R


equating the two we get

h / (r^2/2 + h^2) = 1 / R
R = (r^2/2 + h^2) / h
= h + r^2 / (2 h)


So the equivalent ideal pendulum is longer: R > h

## Another Way to Calculate Equivalent Length

Here's another way to calculate equivalent classic ideal pendulum length. Suppose we have rotational inertia about the pivot point (not about the CM) is I, and length to the CM is h.

I \theta'' = -h m g sin(\theta)
\theta'' = -h m g sin(\theta) / I


What would be the equivalent length R of an ideal (point mass) pendulum? For ideal pendulum, as above:

\theta'' = - g sin (\theta) / R


Equating these gives:

1 / R = h m / I
R = I / (m h)


If we put in the value for I above:

R = (m r^2 / 2 + m h^2) / (m h)
= h + r^2 / (2 h)


which is the same as the previous answer.

## App Setup

Creates instance objects such as the simulation and display objects; defines regular expressions for easy Terminal scripting of these objects using short names instead of fully qualified property names.

The constructor takes an argument that specifies the names of the HTML elementId's to look for in the HTML document; these elements are where the user interface of the simulation is created. This allows for having two separate simulation apps running concurrently on a single page.

A global variable is created for this application instance outside of this file in the HTML where the constructor is called. The name of that global variable holding the application is passed to defineNames() method so that short-names in scripts can be properly expanded.

## Properties

pendulumLength: number = 1.5

length of ReactionPendulumSim

radius of rigid body pendulum disk

separation: number = 0.5

distance between the pendulum anchor points

## Methods

• Add the control to the set of simulation controls.

#### Returns void

• 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.

#### Returns void

• Adds the Parameter to the list of this Subject's available Parameters.

#### Throws

if a Parameter with the same name already exists.

• Notifies all Observers that the Parameter with the given name has changed by calling observe on each Observer.

#### Parameters

• ##### name: string

the language-independent or English name of the Parameter that has changed

#### Throws

if there is no Parameter with the given name

• Returns equivalent length for classic pendulum when ReactionPendulumSim has given length, depends on the length and radius of ReactionPendulumSim.

#### Returns number

equivalent length for classic pendulum

• Define short-cut name replacement rules. For example 'sim2' is replaced by 'app.sim2' when myName is 'app'.

#### Parameters

• ##### myName: string

the name of this object, valid in global Javascript context.

• #### Parameters

• ##### output: boolean = true

whether to print the result to the output text area and add the script to session history; default is true

#### Returns any

the result of evaluating the string

• Returns the Parameter with the given name.

#### Parameters

• ##### name: string

the language-independent or English name of the Parameter

#### Returns Parameter

the Parameter with the given name

#### Throws

if there is no Parameter with the given name

• Returns the ParameterNumber with the given name.

#### Parameters

• ##### name: string

the language-independent or English name of the ParameterNumber

#### Returns ParameterNumber

the ParameterNumber with the given name

#### Throws

if there is no ParameterNumber with the given name

• Returns the ParameterString with the given name.

#### Parameters

• ##### name: string

the language-independent or English name of the ParameterString

#### Returns ParameterString

the ParameterString with the given name

#### Throws

if there is no ParameterString with the given name

• Returns the distance between the fixed pivot points of the two pendulums.

#### Returns number

distance between the fixed pivot points

• Notifies this Observer that a change has occurred in the Subject.

#### Parameters

• ##### event: SubjectEvent

contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter

#### Returns void

• Removes the Observer from this Subject's list of Observers. An Observer may call removeObserver during its observe method.

#### Parameters

• ##### observer: Observer

the Observer to detach from list of Observers

#### Returns void

• Removes the Parameter from the list of this Subject's available Parameters.

#### Parameters

• ##### parameter: Parameter

the Parameter to remove

#### 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 length of ReactionPendulumSim rod, and set length of classic pendulum to equivalent length. See classicLength.

#### Parameters

• ##### value: number

length of ReactionPendulumSim rod

#### Returns void

• Set radius of ReactionPendulumSim bob, and set length of classic pendulum to according equivalent length. See classicLength.

#### Returns void

• Sets the distance between the fixed pivot points of the two pendulums.

#### Parameters

• ##### value: number

distance between the fixed pivot points

#### Returns void

• 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