13
Chapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling to build a simulation of a simple pendulum. The basic ideas can be extended to other types of pendulums, such as physical, spherical or torsional pendulums. 12.1 The Physics of a Pendulum Figure 12.1: A simple pendulum A simple pendulum consists of a point mass m swinging at the end of a massless string of length L, as shown in Figure 12.1. The angle that the string makes with vertical at any instant is , and the motion is confined to a single vertical plane. It is straightforward to find the equations of motion using the rotational form of Newton’s second law, 105

A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

  • Upload
    hahuong

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

Chapter 12

A Simple Pendulum

by Brian Patterson

In this module you will use DIYModeling to build a simulation of a simplependulum. The basic ideas can be extended to other types of pendulums, suchas physical, spherical or torsional pendulums.

12.1 The Physics of a Pendulum

Figure 12.1: A simple pendulum

A simple pendulum consists of a point mass m swinging at the end of a massless stringof length L, as shown in Figure 12.1. The angle that the string makes with vertical at anyinstant is ✓, and the motion is confined to a single vertical plane. It is straightforward tofind the equations of motion using the rotational form of Newton’s second law,

105

Page 2: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 106

X⌧ = I↵.

The only torque (⌧) acting on the pendulum is caused by gravity (we ignore any fric-tional losses) and can be written as

⌧ = �mgL sin ✓,

and the rotational inertia (I) for the point mass is

I = mL

2

.

Putting these two equations together and writing the angular acceleration (↵) as thesecond time derivative of the angular position (✓) gives

�mgL sin ✓ = mL

2

d

2

dt

2

or

d

2

dt

2

= � g

L

sin ✓.

In DIYModeling we express this second order di↵erential equation as a system of twofirst order di↵erential equations

d✓

dt

= !

d!

dt

= � g

L

sin ✓

where ! is the angular velocity of the pendulum in radians per second (and should not beconfused with the angular frequency of oscillation). We will also use initial conditions

✓(0) = ✓

0

!(0) = !

0

Page 3: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 107

Figure 12.2: The Project tab

Note that because we are using DIYModeling, which solves these di↵erential equationsnumerically, students can study the motion of a simple pendulum without recourse to thesmall angle approximation, as is typically done in standard textbooks.

12.2 Building the Model and Simulation in DIYModeling

Launch DIYModeling and open the QuickStart skeleton filependulumTemplate.xml. See Section 1.2 on page 6. This skeleton file does not yet imple-ment a working simulation – you will need to modify it a bit to get it to work, as outlinedbelow. (Note: if you want to examine a fully functional pendulum simulation, open theexample file pendulum.xml and run it in the usual way.)

In the Project tab (See Figure 12.2), you will see some basic information: a descrip-tive Model Name (“Simple Pendulum Template”), the World Time Units (“seconds”) andWorld Length Units (“meters”) used in the model, and Time Scale and Visual Scale factors(both set to “1” because no scaling is needed for this model). If you were creating thismodel completely from scratch, you would need to provide this information yourself.

Page 4: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 108

Figure 12.3: The finished simulation

12.2.1 Adding Components

Looking ahead a bit, Figure 12.3 shows the final rendering of the pendulum model inDIYModeling. It includes a support structure to which the pendulum is attached, alength of string, and the pendulum mass (or “bob”). Not explicitly shown, but also includedas components are the camera and light source. To create these components in your model,click on the Components tab in the Model Editor window. In the large area on the right ofthe screen (see Figure 12.4) you will see that the camera and light source have already beenprovided in your model components, but you will need to add the other three componentsyourself.

• From the Component Libraries pane to the left of the screen, scroll down until youfind the standard component Cube. Click and drag this component to the right sideof the screen, where it will show up as a component named Cube1. You will use thiscomponent for the pendulum support. Note that, by double-clicking on Cube1, youcan rename it as something a little more descriptive (e.g, “Support”). Next, click on

Page 5: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 109

Figure 12.4: The Components tab

the standard component Sphere in the Component Libraries pane and drag it to theright side of the screen, where it will show up as a component named Sphere1. Youwill use this component for the pendulum bob, so double-click on it and rename itas “PendulumBob.” Finally, click and drag the standard component Arrow from theComponent Libraries to the right side of the screen. You will use this component asthe pendulum string, so rename it as String. At this point your component set shouldresemble Figure 12.5.

• Although you have now created all the required visual components for your model,they are neither correctly sized nor positioned (go ahead and run your model to seethis for yourself). To fix this, click on the small button to the right of the Supportcomponent. A new region will open in the center of the screen labeled ComponentAttributes and Parameters, where you can specify both the size and position of theSupport component. In the Size field (see Figure 12.6), enter

[5, 1, 5]

which changes the size of the Support component to 5 units in the x and z (horizontal)directions and 1 unit in the y (vertical) direction. Then change the Position field (seeFigure 12.7) to

[0, 0.5, 0]

Page 6: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 110

Figure 12.5: The Components tab with the new components

which shifts the Support component vertically by 0.5 unit, so that its base is in thexz�plane.

• In the same way, click on the small button to the right of the PendulumBob compo-nent, and change the Diameter field to

[1, 1, 1]

This sets the PendulumBob diameter to 1 unit. In the Position field, enter thevariable name

bobPosition

• Finally, you will need to change the end points of the String so that it starts at theorigin (i.e., at the pivot point) and ends at the center of the bob. Click on the smallbutton to the right of the String component, and enter

[0,0,0]

in the ArrowTail field and enter the variable name

Page 7: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 111

Figure 12.6: The Support size parameter

Page 8: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 112

Figure 12.7: The Support position parameter

Page 9: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 113

Figure 12.8: Linking the PendulumBob position to the variable bobPosition

bobPosition

in the ArrowHead field. This variable name has not yet been defined, but we will useit later on to specify the three-dimensional position of the pendulum bob. You havenow finished creating your model components. See Figure 12.8.

12.2.2 Specifying the Model

Now that you’ve selected your components, you will need to enter the mathematical modelthat controls their behavior. Click on the Model tab in the Model Editor. The first twolines of the model table have already been created for you (see Figure 12.9) and define theconstants appearing in the problem: the acceleration due to gravity (g = 9.81 meters persecond2) and the pendulum length (which is set to length = 10 meters). Later we will adda slider control that will allow you to easily adjust the value of length, but for now we’lljust keep length constant at 10 meters.

In the next three lines of the model table, you will create the dynamical variables for

Page 10: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 114

Figure 12.9: The first two lines in the model

the angle (✓), the angular velocity (!), and the position of the pendulum, as describedbelow.

• To create a variable for the pendulum angle, click on the Add New button at thetop of the table, and, in the new line that appears, enter theta in the Name column.Because ✓ is governed by a di↵erential equation, select “di↵ eq” from the drop downmenu in the How column. The pendulum angle is a simple scalar function, so youshould leave the What column unchanged (“decimal”). Click in the Units columnand select “radians” for the angular units, and enter a reasonable initial value for✓ in the Initial Value column, say 0.5 radians (about 30 degrees). Finally, in theExpression column, enter the time derivative for ✓, given by

d✓

dt

= !

That is, you should simply enter omega (the variable name you will use for angularvelocity) in this cell. Check your inputs for theta against line 3 of of Figure 12.10.

• To create a variable for the angular velocity, click the Add New button and, in thenew line that appears, enter omega in the Name column. The values you enter in thisrow should parallel those for ✓ (or theta) – “di↵ eq,” “decimal” and “radians/s,” inthe columns How, What, and Units, respectively. We’ll release the pendulum fromrest, so enter 0 as the Initial Value. Finally, in the Expression column, enter the timederivative for !, given by

d!

dt

= � g

L

sin ✓

That is, you should enter

Page 11: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 115

Figure 12.10: The model

-(g/length) * sin(theta)

Check your inputs for omega against line 4 of Figure 12.10.

• To create a variable for the position of the pendulum bob, click the Add Newbutton and, in the new line that appears, enter bobPosition in the Name column.You will calculate the bob position as a simple function of the angle and length of thependulum, so select “function” in the How column. The variable bobPosition willbe a three-dimensional vector, as it must specify the x, y and z components of thebob position, so select “vector” in the What column and enter 3 in the Dim column.Select “meter” for units. Finally, in the Expression column, enter the vector positionof the bob,

[sin(theta), -cos(theta), 0] * length

Check your inputs for bobPosition against line 5 of Figure 12.10.

Run your simulation in the usual way by selecting Simulate and Run from the Runpull-down menu in the Model Editor. If you’ve made no mistakes, you should see yourpendulum swinging back and forth beneath the support structure (see Figure 12.3). If yoursimulation doesn’t run, check the Error tab in the Model Editor, fix any errors, and re-runthe simulation. If you have problems troubleshooting your model, compare your work tofully implemented model pendulum.xml provided in the QuickStart Collection.

Page 12: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 116

12.3 Adding Some Bells and Whistles

To make the simulation more useful, try adding a couple of slider controls (see Chapter 9)for the pendulum length and initial angle, so that you can easily vary these parametersduring the simulation. Briefly,

• To create a slider control for the pendulum length, go to the Components tab ofthe Model Editor. Select a sliderControl standard component from the ComponentLibraries on the left side of the screen and drag it into your collection of pendulumcomponents on the right side of the screen. Then double-click on the slider icon andrename it as length so that it will control the pendulum length during the simulation.You will also need to go to the Model tab in the Model Editor and remove the variablenamed length from the model table, since this table entry is no longer needed nowthat the slider control has been created. (To remove the variable “length”, simpleselect this entry in the table and click the Remove Selected button just above thetable.) Sliders have four parameters that you will want to set.

� Label – this descriptive label appears next to the slider control during the sim-ulation.

� Value – this parameter specifies the initial value, or setting, of the slider.� Minimum – this parameter specifies the minimum value of the slider.� Maximum – this parameter specifies the maximum value of the slider.

• To create a slider control for the initial pendulum angle, click and drag a secondsliderControl from the Component Libraries into your collection of pendulum com-ponents and rename it as initialAngle. You will also need to go to the Model tabin the Model Editor and modify the Initial Value of the variable theta. Replace thevalue of 0.5 radians that you entered earlier with either

degreesToRadians(initialAngle)

or

initialAngle

With the first version the slider will specify the initial angle in degrees and with thesecond version the slider will specify the initial angle in radians. The simulation willnow reference the slider control initialAngle to determine the starting position ofthe pendulum. Remember to set the values of the four slider parameters.

Page 13: A Simple Pendulum - diymodeling.appstate.edudiymodeling.appstate.edu/.../files/chapter-12.pdfChapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling

CHAPTER 12. A SIMPLE PENDULUM 117

12.4 Suggestions for Further Exploration

Once your pendulum simulation is working, here are a few avenues for exploration.

• Explore the e↵ect of changing the initial angle or the pendulum length on the periodof oscillation. Unlike the usual textbook example where small angles are assumed,the period will depend on both of these parameters. To determine the period ofoscillation, go to the Model tab and ensure that the box in the Rec column is checkedfor the variable theta. Run the simulation by selecting Simulate, Record, andRun from the Run pulldown menu. Upon quitting the simulation, you will find thatthe numerical values generated for ✓ (or theta) are available in the Recorded Datatab at the bottom of the Model Editor and can be used to determine the period.

• Add components to create a second pendulum, using the small angle approximation,that runs simultaneously with the first one. Compare its simple harmonic motion tothe motion of the actual pendulum.

• Explore the e↵ect of changing the initial velocity of the pendulum. To do this, simplychange the value specified in the Initial Value column for the variable ! (or omega)in the Model tab.

• Modify the model to model a spherical pendulum. A spherical pendulum is similarto the simple pendulum, but without the constraint of a single plane of oscillation.The pendulum position is therefore determined by two angles: ✓ as defined above,and an azimuthal angle �. The equations of motion for ✓ and � are

d

2

dt

2

= � g

L

sin ✓

d

2

dt

2

= 0