2aED6 - ICA 2013 Montreal

advertisement
D. Russell
Proceedings of Meetings on Acoustics
Volume 19, 2013
http://acousticalsociety.org/
ICA 2013 Montreal
Montreal, Canada
2 - 7 June 2013
Education in Acoustics
Session 2aED: Tools for Teaching Advanced Acoustics
2aED6. Creating interactive acoustics animations using Mathematica's Computable
Document Format
Daniel A. Russell*​
​ *Corresponding author's address: Graduate Program in Acoustics, Pennsylvania State University, University Park, PA 16802,
drussell@engr.psu.edu
The computational and graphical prowess of Mathematica has long made it a powerful educational tool for creating effective animations of
acoustic and vibration phenomena [D. Russell, J. Acoust. Soc. Am., 106, 2197 (1999) and V.W. Sparrow and D.A. Russell, J. Acoust. Soc.
Am., 103, 2987 (1998)]. Once an animation has been created within Mathematica it is relatively easy to convert the animation to an animated
GIF file for display on a webpage [D. Russell, J. Acoust. Soc. Am., 114, 2308 (2003)]. However, such animations, while effective at
communicating or illustrating complicated acoustic phenomena, are "static" in the sense that they are not interactive and a person viewing the
animation cannot change parameters. Recently Wolfram Research implemented a new Computable Document Format that allows interactive
plots and animations to be inserted into webpages and electronic documents. A free CDF player from Wolfram allows viewers to interact with
plots and animations by moving sliders to change values of parameters. This talk will demonstrate the process of creating a CDF animation for
embedding in a webpage. Other, more complex, demonstrations will also be showcased to illustrate the potential capabilities of CDF as an
educational tool.
Published by the Acoustical Society of America through the American Institute of Physics
© 2013 Acoustical Society of America [DOI: 10.1121/1.4801411]
Received 23 Jan 2013; published 2 Jun 2013
Proceedings of Meetings on Acoustics, Vol. 19, 025006 (2013)
Page 1
D. Russell
I NTRODUCTION : W EB A NIMATIONS AND I NTERACTIVE A PPLETS
The use of static graphic images, plots and drawings as educational tools is frequently championed by
stating "A picture is worth a thousand words."[1] There are, however, many times when a single static image
is not enough to convey understanding of a difficult concept. Movies or animated images, such as the
animated GIF format utilized on many HTML webpages, are especially helpful for explaining concepts
involving acoustic phenomena involving waves and vibration, concepts that involve motion, oscillation, and
propagation which beg for animation. This author has created a rather popular website containing roughly
45 web articles containing animations of various acoustic, vibration, and wave phenomena.[2, 3] Computer
generated movies, presented as animated GIF files automatically load and run when each webpage is
accessed; accompanying text provides some context or background explanation for the concepts illustrated in
each animation. This web site has been favorably reviewed in a number of publications[4, 5, 6, 7, 8] and has
amassed nearly 2.2 million unique visits since 2000. Animations on this website were created to be
mathematically and physically correct, and were generated using the computational and graphical prowess of
Mathematica[9] with its built in animation tools. Post processing of the Mathematica animations involves
conversion of animation frames into an animated GIF file for insertion as an image into the HTML code for a
webpage.[10, 11]
However, while such animations have proven to be quite useful for teaching and explaining acoustic
phenomena, there are times when it would be preferable for the viewer to be able to interact with the
animation, to change values of one or more parameters, and to see the result of such changes in realtime. For
example, a webpage showing an animation of two sinusoidal wave signals interacting with each other
through constructive and destructive interference[12] is a useful education tool for explaining the concepts of
superposition and interference to a classroom of students, or for having students view and read on their own
as an assignment. However, the same webpage would be potentially more useful if the animation had a
slider, as illustrated in Fig. 1, allowing the viewer to adjust the relative phase of the two sinusoidal
waveforms, allowing the viewer to pause the pattern to observe the conditions of constructive and destructive
interference or some point between the two extremes.
F IGURE 1: Two screen captures of an interactive Mathematica animation[12] showing constructive and destructive interference between
two identical sinusoidal signals with differing phases, with a slider that allows the viewer to adjust the relative phase between the two
signals.
T HE M ATHEMATICA C OMPUTABLE D OCUMENT F ORMAT (CDF)
Websites with interactive Java applets have been around for several years; one outstanding example is
the excellent collection of interactive Java applets created by Paul Falstad.[13] However, until Wolfram
Research recently introduced of the Computable Document Format,[14] with Mathematica version 8.0, it was
not previously possible to interact with a Mathematica animation without having access to both the
Mathematica software package and the source code used to produce the animation. The Computable
Document Format (CDF) allows a user to save a Mathematica notebook file in a special format that may be
Proceedings of Meetings on Acoustics, Vol. 19, 025006 (2013)
Page 2
D. Russell
read and manipulated with a special free CDF Player application, without requiring access to the
Mathematica program itself. CDF files may be saved as standalone documents, allowing an electronic version
of a technical report to contain calculations and animations, with which the reader may interact by changing
parameters, altering variables and calculations, rotating a 3D graphical object, etc. Alternately, the resulting
output of a Mathematica calculation – say a plot or similar graphical output – may be saved as a CDF file and
embedded into an HTML document for display and interaction on a webpage.
C REATING CDF F ILES
In order to create a CDF file, one must create the content with a licensed copy of Mathematica. However,
to view and interact with the content of a CDF file, one only needs to install the CDF Player application
which is provided free of charge.[15] The person interacting with the content of the CDF file may interact
with the content using the controls (sliders or input options) used to create the Mathematica CDF file.
However, the user may not alter the content itself.
While running Mathematica a new file is created, but instead of opening a new Mathematica Notebook
(*.nb) file, a FreeCDF file is opened instead. To create the content of the CDF file, Mathematica commands
and functions are written and executed in exactly the same way as they are when creating a Notebook file.
From the content creation point of view, there is no difference between creating the content for a Notebook
file and the same content for a CDF file. When the content is complete, the file is saved as a Computable
Document (*.cdf) as a standalone CDF file to be accessed and interacted with using the CDF Player.
Alternately, one may use a menu option to "Deploy" the content and a CDF Deployment Wizard will
assist in the creation of the CDF file. This approach is useful if one wishes to save a selection of the document
output - say a plot with slider controls - as a CDF file to be embedded in the HTML code for a webpage .
A N E XAMPLE OF A S IMPLE I NTERACTIVE CDF F ILE
The steady state displacement amplitude response of a single-degree-of-freedom oscillator to a sinusoidal
driving force may be written as
F/m
.
(1)
x= 2
ω2 − (s/m) + (2β)2
When discussing the physical meaning of this equation and the resulting resonance curve it produces,
especially with respect to a discussion of vibration isolation problems, one often discusses the regions of the
plot where changing the mass, stiffness, or damping individually have the greatest affect on the shape of the
response curve. Figure 2 shows the typical shape of the displacement response of a driven 1-dof oscillator.
When the system is driven below resonance, the system is said to be "stiffness controlled" and changing the
Displacement Amplitude
1000
100
10
1
damping controlled
stiffness controlled
0.1
0.0
mass controlled
0.5
1.0
1.5
2.0
Normalized Frequency
F IGURE 2: Typical response curve for the displacement response of a driven oscillator, showing the regions where the oscillator is stiffness
controlled, damping controlled, and mass controlled.
Proceedings of Meetings on Acoustics, Vol. 19, 025006 (2013)
Page 3
D. Russell
stiffness causes the shape and amplitude of the response in this region to change significantly, while leaving
the response at the higher frequency mass-controlled region relatively unchanged. Similarly, when the
system is driven above resonance, the system is said to be "mass controlled" and varying the mass results in
large changes in the amplitude of the response in this region while the amplitude at very low frequencies is
relatively constant. Near resonance, the system is "damping controlled" and increasing the damping causes
the amplitude near resonance to be lowered dramatically. However, large changes in damping produce no
changes in the response amplitude in the lower frequency stiffness controlled region, nor in the higher
frequency mass controlled region.
All of this discussion is fine, but it would be very helpful if we had the ability to change the values of the
stiffness, mass, and damping independently or together in order to see exactly how the response curve
changes shape. The Mathematica code to define the displacement response in Eq.(1) could be entered as
shown in Fig. 3.
F IGURE 3: Mathematica code to calculate the displacement amplitude response in Eq.(1).
We can use the Manipulate[ ] command, to produce a plot of the displacement amplitude response from
Eq.(1) with interactive sliders allowing the numerical values of the mass m, stiffness s, and damping β to be
changed while the plot updates in realtime while the slider is moving and the values change. Figure 4 shows
the code used to produce the interactive plot, which is shown in Fig. 5 for three slider positions emphasizing
the stiffness, mass, and damping controlled regions.
F IGURE 4: The Manipulate[ ] command is used to produce a plot with interactive sliders.
F IGURE 5: Example of a manipulatable plot showing the steady state response of a driven 1-dof oscillator, created with the Mathematica
Manipulate[ ] command. Moving the sliders allows the viewer to explore the effects of changing the stiffness (left), mass (center), and
damping (right).
We could either save the entire Mathematica notebook as a standalone CDF file for later interaction
through the CDF Player application. Or we could just use the "File"→"Deploy"→"Embed in HTML" menu
option to save just the plot with the sliders into a CDF file that can be embedded into the HTML code for a
webpage. An example of the script that the CDF Deployment Wizard provides for embedding a CDF
Proceedings of Meetings on Acoustics, Vol. 19, 025006 (2013)
Page 4
D. Russell
document in the HTML code for a webpage is shown in Fig. 6. This script automatically checks to see that the
CDF Player is installed and that JavaScript is enabled. When the webpage containing this CDF file is opened,
the CDF Player automatically loads and the plot is ready for interaction by the person reading the page.
F IGURE 6: JavaScript code for embedding a CDF file into the HTML code for a webpage.
C ONCLUSIONS
The Computable Document Format provides a very easy way to create interactive Mathematica plots,
graphics, calculations, and animations that may be saved as standalone files or embedded into webpages for
viewers to interact with. CDF files should provide acoustics educators with a powerful tool for developing
interactive content for students studying acoustics and vibration topics. If a picture is indeed worth a
thousand words, then an effective interactive animation must be worth many thousands of pictures!
R EFERENCES
[1] “A picture is worth a thousand words”, (last viewed 22 Jan. 2013), URL
http://en.wikipedia.org/wiki/A picture is worth a thousand words, The phrase ‘Use a
picture. It’s worth a thousand words.’ appeared in an article in the March 28, 1911 issue of the Syracuse
Post Standard which quoted newspaper editor Arthur Brisbane discussing journalism and publicity.
Russian author Ivan Turgenev penned the phrase ‘A picture shows me at a glance what it takes dozens
of pages of a book to expound.’ in Fathers and Sons, published in 1862.
[2] D. Russell, “Acoustics and Vibration Animations”, (last viewed 22 Jan. 2013), URL
http://www.acs.psu.edu/drussell/demos.html.
[3] D. Russell, “Acoustics and vibration animations: A surprisingly successful website”, J. Acoust. Soc. Am..
114, 2308 (2003).
[4] Ear & Hearing 31, 585–586 (2010).
[5] Phys. Teach. 43, 57 (2005).
[6] Physics Today 56, 29 (2003).
[7] Science 293, 1563 (August 21, 2001).
[8] Sound & Communication 21, 18 (2000).
[9] Wolfram Research, Inc., Mathematica, 9.0 edition (Wolfram Research., Champaign, IL) (2012).
[10] V. Sparrow and D. Russell, “Animations created in mathematica for acoustics education”, J. Acoust. Soc.
Am.. 103, 2987 (1998).
[11] D. Russell, “Animations for teaching more advanced acoustics topics”, J. Acoust. Soc. Am.. 106, 2197
(1999).
[12] D. Russell, “Superposition of Waves”, (last viewed 22 Jan. 2013), URL
http://www.acs.psu.edu/drussell/Demos/superposition/superposition.html.
Proceedings of Meetings on Acoustics, Vol. 19, 025006 (2013)
Page 5
D. Russell
[13] P. Falstad, “Math, Physics, and Engineering Applets”, (last viewed 22 Jan. 2013), URL
http://www.falstad.com/mathphysics.html.
[14] “Computable document format (cdf) for interactive content”, (last viewed 22 Jan. 2013), URL
http://www.wolfram.com/cdf/.
[15] “Wolfram cdf player for interactive computable document format”, (last viewed 22 Jan. 2013), URL
http://www.wolfram.com/cdf-player/.
Proceedings of Meetings on Acoustics, Vol. 19, 025006 (2013)
Page 6
Download