Wave Propagation
WHAT IS IT?
This project explores the propogation of a wave along a rope that is being moved at one end. In this model, the rope is made up of red turtles except for the end points of the rope. The left end is a green turtle that moves and the right end is a fixed point with x = screen-half-width and y = 0.
The left end / green turtle drives the wave propogation. Its y position is determined by the formula:
yposition = amplitude X ( sin(frequency) X time )
The red turtles velocity is computed using the following formula:
yvelocity = (yvelocity + (k X ((difference in ypos between prev turtle and me + difference in ypos between next turtle and me)))) X ((1000 - friction) / 1000)
HOW TO USE IT
Click the setup button to setup the rope made of red turtles. Click the go button to start the simulation. The friction slider controls the amount of friction. The freq slider sets the frequency of the wave. (number of waves per time interval or cycles per second) The amplitude slider controls the amplitude or height of the wave.
EXPLORATIONS
How does the friction setting affect the shape of the wave? How are these two quantities frequency and amplitude related?
Turtle procedures
turtles-own [
yvel ; velocity in y direction
ypos ; position in y direction
k ; constant
time ; time
]
;; setup procedure
;; called by the observer setup procedure
;; Sets the color of the turtles to red, sets the x position of the turtle based on
;; its who number, and initializes the turtle variables. Then the turtle at the
;; left end of the rope gets colored green and the turtle at the right end of the
;; rope gets colored blue.
;;
to setup
setc red
setx who - 1 - screen-half-width
setyvel 0
setypos 0
setk 1
settime 0
if xcor = screen-half-width [setc blue]
if xcor = (-1 * screen-half-width) [setc green]
end
;; go procedure
;; called by the go button
;; Moves the left end of the rope based on the user-specified amplitude and frequency
;; then positions the red turtles according to the velocity and friction.
;;
;; new yvelocity = ((1000 - friction) / 1000)
;; X (current yvelocity
;; + (k X
;; ((difference in ypos between prev turtle and me)
;; + (difference in ypos between next turtle and me))
;; )
;; )
;;
;;
;; If a turtle has moved off the top or bottom and is wrapping around to the other edge
;; hide it.
;;
to go
if color = green [drive-force]
if color = red [
setyvel yvel + (k * (((ypos-of (who - 1)) - ypos)
+ ((ypos-of (who + 1)) - ypos)))
setyvel ((1000 - friction) / 1000) * yvel
setypos ypos + yvel
sety ypos
ifelse (abs ypos) <= screen-half-height
[st]
[ht]
]
end
;; drive-force procedure
;; called by the go procedure
;; Increments the time then sets the y position of the left end of the rope
;; based on the formula:
;;
;; new yposition = amplitude X ( sin(frequency) X time )
;;
to drive-force
settime time + 1
setypos amplitude * (sin freq * time)
sety ypos
end
Observer procedures
;; setup procedure
;; called by the setup button
;; Clears all and creates turtles to cover the entire screen width.
;; Then the turtles run their setup procedure.
;;
to setup
ca
crt screen-width
ask-turtles [setup]
end
