GasLab Single Collision
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is one in a series of GasLab models that use the same basic rules for what happens when particles run into each other. Each one has different features in order to show different aspects of the behavior of gases.
This model is simplified to show the collision of only two particles, since this event is so hard to watch when there are many particles in the world: given the initial motions of two colliding particles, what can we learn about their final motions from the principles of conservation of momentum and energy?
HOW IT WORKS
The particles are modeled as hard balls with no internal energy except that which is due to their motion. Collisions between particles are elastic. Particles are colored according to speed --wel- blue for slow, green for medium, and red for high speeds.
Coloring of the particles is with respect to one speed (10). Particles with a speed less than 5 are blue, ones that are more than 15 are red, while all in those in-between are green.
Particles behave according to the following rules:
- A particle moves in a straight line without changing its speed, unless it collides with another particle or bounces off the wall. The particles are aimed to hit each other at the origin.
- Two particles "collide" if they find themselves on the same patch (the world is composed of a grid of small squares called patches).
- A random axis is chosen, as if they are two balls that hit each other and this axis is the line connecting their centers.
- They exchange momentum and energy along that axis, according to the conservation of momentum and energy. This calculation is done in the center of mass system.
- Each turtle is assigned its new velocity, energy, and heading.
- If a turtle finds itself on or very close to a wall of the container, it "bounces" -- that is, reflects its direction and keeps its same speed.
HOW TO USE IT
Initial settings:
- COLLISION-ANGLE: Sets the angle that separates the pink and blue particles before the collision.
- REFLECTION-ANGLE: Sets the angle of the axis connecting the particles' centers when they collide with respect to the vertical axis. To calculate the outcome of the collision, the speeds of the two particles are projected onto this new axis and the new speeds and headings are computed. Other GasLab models use random values for "REFLECTION-ANGLE", but this model allows you to experiment with them one by one. This angle is called THETA in the code of the model.
- INIT-PINK-SPEED (or BLUE): Sets the initial speed of the pink (or blue) particle.
- PINK-MASS (or BLUE): Sets the mass of the pink (or blue) particle.
Other settings:
- SHOW-CENTER-OF-MASS?: If ON, the center of mass of the system will be shown in gray.
Buttons for running the model:
- SETUP
- RUN-MODE: Chooses between ONE COLLISION (just one run), ALL-COLLISION-ANGLES (loops through all the collision angles with 15-degrees steps) and ALL-REFLECTION-ANGLES(loops through all the reflection angles with 15-degrees steps).
- GO
Monitors:
- ENERGY OF PINK (or -BLUE): Shows the current energy of the pink (or blue) particle.
- SPEED OF PINK (or -BLUE): Shows the current speed of the pink (or blue) particle.
- AVERAGE SPEED: Shows the average of the speeds of the two particles.
- TOTAL ENERGY: Shows the sum of the energies of the two particles.
Plots:
- SPEEDS: speed of each of the particles over time.
THINGS TO TRY
Set the reflection-angle to zero. Draw a picture representing the two balls as they collide, with their two faces touching. Make the line connecting their centers be the same as theta. Draw vectors representing their motion.
While running the following situations note the paths of the two particles. Can you make sense of what they do? Is it what you expected?
Choose a COLLISION-ANGLE and a REFLECTION-ANGLE and choose ONE-COLLISION to see one particular collision.
Choose a COLLISION-ANGLE and choose ALL-REFLECTION-ANGLES to cycle through all of the angles of reflection.
Choose a REFLECTION-ANGLE and choose ALL-COLLISION-ANGLES to cycle through all of the angles of collision.
THINGS TO NOTICE
With COLLISION-ANGLE = 180 (directly across from each other) and REFLECTION-ANGLE = 90, it looks as if the two particles miss each other. What is happening?
With REFLECTION-ANGLE = 45 degrees, the particles go off at right angles. Why? Draw a picture of what is happening at the moment of collision.
With REFLECTION-ANGLE = 0 degrees, the two particles reverse direction. Why?
What is the motion of the center of mass? What would you expect it to be?
THINGS TO TRY
Have the masses of the two particles be different.
Have the initial speeds of the two particles be different.
Change the initial positions and headings of the two particles. As a simple case, set one on the y-axis and the other on the x-axis, (COLLISION-ANGLE = 90) each one heading toward the origin. The center of mass is no longer stationary. Note its path. Is it what you would expect?
If the center of mass is not stationary, the two particles often have different speeds after they collide, even when they have identical initial speeds and masses! Why does this happen? How can this satisfy the conservation of both energy and momentum?
The fact that the velocities are not always the same after every kind of collision is essential to getting a distribution of velocities among identical particles after many collisions, which is what we observe with particles in a gas.
Does this seem like a reasonable model for colliding particles? When is it reasonably valid, and when is it decidedly NOT valid?
When two particles collide, should theta be picked randomly -- each theta has an equal probability --- or in some other way? Would this change the eventual velocity distribution among many particles?
After you have gotten used to observing and understanding these simple collisions, go to the "Free Gas" or "Gas in a Box" model. Especially watch the particle whose path is traced in gray. Does it make sense? Can you picture each collision?
Record the velocities of each particle after each collision. After you have several sets of velocities, look at the entire velocity distribution. What do you notice? Is it the Maxwell-Boltzmann distribution?
CREDITS AND REFERENCES
This model was developed as part of the GasLab curriculum (http://ccl.northwestern.edu/curriculum/gaslab/) and has also been incorporated into the Connected Chemistry curriculum (http://ccl.northwestern.edu/curriculum/ConnectedChemistry/)
HOW TO CITE
If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:
- Wilensky, U. (1997). NetLogo GasLab Single Collision model. http://ccl.northwestern.edu/netlogo/models/GasLabSingleCollision. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
COPYRIGHT AND LICENSE
Copyright 1997 Uri Wilensky.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
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.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2002.
Comments and Questions
globals [ tick-delta ;; how much we advance the tick counter this time through max-tick-delta ;; the largest tick-delta is allowed to be plot-clock ;; keeps track of the x-axis for the plot avg-speed ;; average speed of the two particles total-energy ;; total energy of the two particles x-center y-center ;; coordinates of center of mass done? ;; becomes true when one particles is about to 'leave' the world after-collision? ;; for graphing purposes ] breed [ particles particle ] breed [ centers-of-mass center-of-mass ] particles-own [ speed mass energy ;; particle variables last-collision ] to setup clear-all set-default-shape particles "circle" set-default-shape centers-of-mass "x" set done? false set max-tick-delta 0.1073 set after-collision? false make-particles create-centers-of-mass 1 [ set size 3 ] update-variables clear-drawing ;; erase the line made by initially moving the center of mass reset-ticks end to update-variables let total-mass sum [mass] of particles set x-center (sum [ xcor * mass ] of particles) / total-mass set y-center (sum [ ycor * mass ] of particles) / total-mass set avg-speed mean [speed] of particles set total-energy sum [energy] of particles ask centers-of-mass [ ifelse show-center-of-mass? ;; marks a gray path along the particles' center of mass [ show-turtle pen-down ] [ hide-turtle pen-up ] setxy x-center y-center ] end to go ask particles [ move ] ask particles ;; each particle checks if it's on the same patch as the other [ check-for-collision ] update-variables calculate-tick-delta tick-advance tick-delta display update-plots end to go-mode if run-mode = "one-collision" [go-once stop] if run-mode = "all-collision-angles" [all-collision-angles] if run-mode = "all-reflection-angles" [all-reflection-angles] end to go-once ;; a single collision setup while [ not done? ] [ go ask particles [ if not can-move? 1 [ set done? true ] ] ] end to all-collision-angles ;; activated when the reflection angle is constant and the collision angle is varied go-once ifelse collision-angle >= 345 [ set collision-angle 15 ] [ set collision-angle collision-angle + 15 ] end to all-reflection-angles ;; activated when the collision angle is constant and the reflection angle is varied go-once set reflection-angle reflection-angle + 15 if reflection-angle = 360 [ set reflection-angle 0 ] end to calculate-tick-delta ;; tick-delta is calculated in such way that even the fastest ;; particle will jump at most 1 patch length in a tick. As ;; particles jump (speed * tick-delta) at every tick, making ;; tick length the inverse of the speed of the fastest particle ;; (1/max speed) assures that. Having each particle advance at most ;; one patch-length is necessary for them not to "jump over" each ;; other without colliding. ifelse any? particles with [speed > 0] [ set tick-delta min list (1 / (ceiling max [speed] of particles)) max-tick-delta ] [ set tick-delta max-tick-delta ] end to move ;; particle procedure jump (speed * tick-delta) end to check-for-collision ;; particle procedure if count other particles-here = 1 [ ;; the following conditions are imposed on collision candidates: ;; 1. they must have a lower who number than my own, because collision ;; code is asymmetrical: it must always happen from the point of view ;; of just one particle. ;; 2. they must not be the same particle that we last collided with on ;; this patch, so that we have a chance to leave the patch after we've ;; collided with someone. let candidate one-of other particles-here with [who < [who] of myself and myself != last-collision] ;; we also only collide if one of us has non-zero speed. It's useless ;; (and incorrect, actually) for two particles with zero speed to collide. if (candidate != nobody) and (speed > 0 or [speed] of candidate > 0) [ collide-with candidate set last-collision candidate ask candidate [ set last-collision myself ] set after-collision? true ] ] end ;; implements a collision with another particle. ;; ;; THIS IS THE HEART OF THE PARTICLE SIMULATION, AND YOU ARE STRONGLY ADVISED ;; NOT TO CHANGE IT UNLESS YOU REALLY UNDERSTAND WHAT YOU'RE DOING! ;; ;; The two particles colliding are self and other-particle, and while the ;; collision is performed from the point of view of self, both particles are ;; modified to reflect its effects. This is somewhat complicated, so I'll ;; give a general outline here: ;; 1. Do initial setup, and determine the heading between the reflected particles ;; (call it theta). ;; 2. Convert the representation of the velocity of each particle from ;; speed/heading to a theta-based vector whose first component is the ;; particle's speed along theta, and whose second component is the speed ;; perpendicular to theta. ;; 3. Modify the velocity vectors to reflect the effects of the collision. ;; This involves: ;; a. computing the velocity of the center of mass of the whole system ;; along direction theta ;; b. updating the along-theta components of the two velocity vectors. ;; 4. Convert from the theta-based vector representation of velocity back to ;; the usual speed/heading representation for each particle. ;; 5. Perform final cleanup and update derived quantities. to collide-with [ other-particle ] ;; particle procedure ;;; PHASE 1: initial setup ;; for convenience, grab some quantities from other-particle let mass2 [mass] of other-particle let speed2 [speed] of other-particle let heading2 [heading] of other-particle ;; since particles are modeled as zero-size points, theta isn't meaningfully ;; defined. we can assign it randomly without affecting the model's outcome. let theta reflection-angle ;;; PHASE 2: convert velocities to theta-based vector representation ;; now convert my velocity from speed/heading representation to components ;; along theta and perpendicular to theta let v1t (speed * cos (theta - heading)) let v1l (speed * sin (theta - heading)) ;; do the same for other-particle let v2t (speed2 * cos (theta - heading2)) let v2l (speed2 * sin (theta - heading2)) ;;; PHASE 3: manipulate vectors to implement collision ;; compute the velocity of the system's center of mass along theta let vcm (((mass * v1t) + (mass2 * v2t)) / (mass + mass2) ) ;; now compute the new velocity for each particle along direction theta. ;; velocity perpendicular to theta is unaffected by a collision along theta, ;; so the next two lines actually implement the collision itself, in the ;; sense that the effects of the collision are exactly the following changes ;; in particle velocity. set v1t (2 * vcm - v1t) set v2t (2 * vcm - v2t) ;;; PHASE 4: convert back to normal speed/heading ;; now convert my velocity vector into my new speed and heading set speed sqrt ((v1t ^ 2) + (v1l ^ 2)) set energy (0.5 * mass * speed ^ 2) ;; if the magnitude of the velocity vector is 0, atan is undefined. but ;; speed will be 0, so heading is irrelevant anyway. therefore, in that ;; case we'll just leave it unmodified. if v1l != 0 or v1t != 0 [ set heading (theta - (atan v1l v1t)) ] ;; and do the same for other-particle ask other-particle [ set speed sqrt ((v2t ^ 2) + (v2l ^ 2)) set energy (0.5 * mass * (speed ^ 2)) if v2l != 0 or v2t != 0 [ set heading (theta - (atan v2l v2t)) ] ] end to recolor ;; particle procedure ifelse speed < (0.5 * 10) [ set color blue + 2 ] [ ifelse speed > (1.5 * 10) [ set color red ] [ set color green ] ] end ;; creates initial particles to make-particles create-particles 1 [ set color pink set speed init-pink-speed set mass pink-mass set heading 180 bk 2 * speed ] create-particles 1 [ set color blue set speed init-blue-speed set mass blue-mass set heading 180 + collision-angle bk 2 * speed ] ask particles [ setup-particle ] calculate-tick-delta end to setup-particle ;; particle procedure pen-down set size 2 set energy (0.5 * mass * speed ^ 2 ) set last-collision nobody end ; Copyright 1997 Uri Wilensky. ; See Info tab for full copyright and license.
There are 15 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
GasLab Single Collision.png | preview | Preview for 'GasLab Single Collision' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.