globals [ clock ] turtles-own [ yvel ;; velocity along the y axis ypos ;; y position (separate from ycor since we might exceed the boundaries of ;; the graphics window, which ycor can never do) ] to setup ca set clock 0 set-default-shape turtles "circle" cct screen-size-x ;; create enough turtles to span screen [ set xcor (who - screen-edge-x) ;; place them along the x-axis set color red if xcor = screen-edge-x [ set color blue ] ;; rightmost turtle is blue if xcor = (- screen-edge-x) [ set color green ] ;; leftmost turtle is green ] end to go set clock clock + 1 ask turtles with [color = green] ;; the green turtle is the driving force [ ifelse (clock > 100) ;; ramp the force up gradually to avoid spikes in the wave [ set ypos amplitude * sin (frequency * clock) ] [ set ypos (clock / 100) * amplitude * sin (frequency * clock) ] set ycor ypos ] ask turtles with [color = red] ;;the red turtles respond to their neighbors' positions [ ;; make your new y velocity equal to your old one + the average pos of your two neighbors set yvel yvel + (((ypos-of (turtle (who - 1))) - ypos) + ((ypos-of (turtle (who + 1))) - ypos)) set yvel ((1000 - friction) / 1000) * yvel ;; apply friction ] ;; we need two separate ask blocks here so all the turtles calculate their ;; new velocities before any turtles move ask turtles with [color = red] [ ;; calculate new y position set ypos ypos + yvel ;; calculate new y position set ycor ypos ifelse (abs ypos) <= screen-edge-y ;; make sure turtles do not wrap the screen [ show-turtle ] [ hide-turtle ] ] end ; *** NetLogo Model Copyright Notice *** ; ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML). The project gratefully acknowledges the support of the ; National Science Foundation (Applications of Advanced Technologies ; Program) -- grant numbers RED #9552950 and REC #9632612. ; ; Copyright 1997 by Uri Wilensky. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. Updated 2003. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1997). NetLogo Rope model. ; http://ccl.northwestern.edu/netlogo/models/Rope. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/Rope ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 266 10 680 445 50 50 4.0 1 10 1 1 1 CC-WINDOW 4 311 260 445 Command Center BUTTON 140 47 214 80 go go T 1 T OBSERVER T SLIDER 9 103 249 136 friction friction 0.0 99.0 10.0 1.0 1 NIL SLIDER 9 138 249 171 frequency frequency 0.0 99.0 10.0 1.0 1 NIL BUTTON 58 47 125 80 NIL setup NIL 1 T OBSERVER T SLIDER 9 173 249 206 amplitude amplitude 0.0 99.0 20.0 1.0 1 NIL @#$#@#$#@ WHAT IS IT? ----------- This project simulates a wave moving along a rope. The right end of the rope (shown in blue) is fixed to a wall. The left end of the rope (shown in green) provides an input, moving up and down in a sinusoidal motion. This creates a wave that travels along the rope. HOW IT WORKS ------------ The rope is made up of a line of turtles. The turtle are fixed horizontally, but can move up and down. Each turtle acts as it were connected to its two neighboring turtles with springs. When a neighboring turtle is farther away, it exerts a stronger force. When the left end of the rope (the green turtle) moves up, it "pulls up" the turtle to its right, which in turn pulls up the turtle to its right, and so on. In that way, a wave moves down the rope. When the wave reaches the right end of the rope (the blue turtle), the wave is reflected back to the left. HOW TO USE IT ------------- Click the SETUP button to set up the rope. Click GO to make the left end of the rope (the green turtle) begin moving up and down. The FRICTION slider controls the amount of friction in the rope. The FREQUENCY slider controls the speed with with the left end of the rope moves up and down. The AMPLITUDE slider controls the maximum height of the left end of the rope. THINGS TO NOTICE ---------------- There's a connection between the frequency with which the left end of the rope goes up and down and the number of peaks that emerge. THINGS TO TRY ------------ Change the values on the sliders and observe what happens to the waves on the rope. Try to create a "standing wave", in which some points on the rope do not move at all. Change the blue turtle to green, so that there are two driving forces. Then change one of the red turtles in the middle of the rope to blue, so that there is a fixed point in the middle. What happens to the waves? EXTENDING THE MODEL ------------------- Change the right end of the rope so that it moves freely, rather than being fixed. How does that change the behavior of waves in the rope? NETLOGO FEATURES ----------------- For this project, it does not make sense for the turtles to "wrap" when they get to the top or bottom of the screen. So the real y-position of the turtles is kept in a new variable (YPOS), and the turtle is hidden if YCOR, its on-screen position, ever wraps around the top or bottom edge. CREDITS AND REFERENCES ---------------------- To refer to this model in academic publications, please use: Wilensky, U. (1997). NetLogo Rope model. http://ccl.northwestern.edu/netlogo/models/Rope. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 1997 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Rope for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 circle false 0 Circle -7566196 true true 35 35 230 @#$#@#$#@ NetLogo 2.0beta4 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@