Conduction in solids intro

Conduction in solids intro preview image

1 collaborator

Default-person Michael Novak (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.0 • Viewed 707 times • Downloaded 18 times • Run 0 times
Download the 'Conduction in solids intro' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model supports a drawing style interface for "sketching" up representations of new systems to explore related to gas behavior and gas particles. This model is part of the "Connected Chemistry" curriculum http://ccl.northwestern.edu/curriculum/ConnectedChemistry/ which explores the behavior of gases.

Most of the models in the Connected Chemistry curriculum use the same basic rules for simulating the behavior of gases. Each model highlights different features of how gas behavior is related to gas particle behavior.

In all of the models, gas particles are assumed to move and to collide, both with each other and with objects such as walls.

In this model, particles can be added, color coded, and sped up or slowed down, by drawing with the mouse cursor in the WORLD & VIEW. Also, additional types of removable and replaceable walls can be added to the WORLD.

This model enables students to draw a model of a real world system and then test that model. A wide range of real world systems can be modeled with this simple interface (e.g. diffusion of perfume from an uncapped container, hot gas mixed with a cold gas, mixtures of gases).

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. Collisions with the wall are not.

The exact way two particles collide is as follows:

  1. A particle moves in a straight line without changing its speed, unless it collides with another particle or bounces off the wall.
  2. Two particles "collide" if they find themselves on the same patch. In this model, two turtles are aimed so that they will collide at the origin.
  3. An angle of collision for the particles is chosen, as if they were two solid balls that hit, and this angle describes the direction of the line connecting their centers.
  4. The particles exchange momentum and energy only along this line, conforming to the conservation of momentum and energy for elastic collisions.
  5. Each particle is assigned its new speed, heading and energy.

As the walls of the box are heated, the sides of the walls will change color from a deep red (cool) to a bright red, to pink to a pale pink white (hot). The walls contain a constant heat value throughout the simulation.

The exact way particles gain energy from the walls of the box is as follows:

  1. Particles check their state of energy (kinetic).
  2. They hit or bounce off the wall.
  3. They find wall energy and set their new energy to be the average of their old kinetic energy and the wall energy.
  4. They change their speed and direction after the wall hit.

HOW TO USE IT

Buttons: SETUP - sets up the initial conditions set on the sliders. GO/STOP - runs and stops the model. MOUSE INTERACTION - when this is set to "none - let the particles interact" the particles will move and interact with each other and the surroundings. When set to any other value you can then click in the WORLD & VIEW to paint, erase, color, or add various objects and properties.

Sliders: INITIAL-#-PARTICLES - sets the number of gas particles in the box when the simulation starts. INITIAL-GAS-TEMPERATURE sets the initial temperature of the gas.

Switches: SHOW-WALL-HITS? turn visualization of when particles hits the walls (as flashes) on or off

Choosers: VISUALIZE-SPEED? allows you to visualize particle speeds. For example, selecting "arrows", creates a representation of each particle velocity using a scalar arrow. Selecting "shades" creates representation of each particle speed using a brighter (faster) or darker (slower) shade of the particle's color.

MOUSE-INTERACTION sets the type interaction the user can do with the mouse in the WORLD & VIEW. Possible settings include: "none - let the particles interact" - particles move about "draw basic wall" - adds a gray wall under the mouse cursor "draw red removable wall" - adds a red wall under the mouse cursor which can be alternatively removed and replaced (like a valve) using the REMOVE/REPLACE RED WALL. "draw green removable wall" - adds a green wall under the mouse cursor which can be alternatively removed and replaced (like a valve) using the REMOVE/REPLACE GREEN WALL. "big eraser" - erases all objects (except the yellow box boundary walls) under the mouse cursor. "slow down particles" - increase the current speed of the particles by 10%. "speed up particles" - reduces the current speed of the particles by 10%. "paint particles green" - recolors the particles under the mouse cursor green (other settings include orange and purple) "add green particles" - adds a couple of new particles under the mouse cursor (other settings include orange and purple)

Plots:

  • 1: TEMPERATURE OF GASES VS. TIME: plots the temperature of the different gases in the model, as indicated by their color (orange particles, green particles, and purple particles)

THINGS TO NOTICE

The mouse interaction can be used while the model is running as well as when it is stopped.

THINGS TO TRY

Create a model of how odors move throughout a room. Why do some people smell the odor before others? Does the layout of furniture, large objects, and walls in the room effect the movement of the odor? How about the temperature of the air in the room?

Create a model of diffusion of a perfume from a closed container. How would you represent the different gases (the perfume and the surrounding air)? What shape will the container be? How will you model a removable cap or lid?

Create a model of room filled with cold air and a different room filled with warm air. How will represent these different rooms of air? What could you add to show what happens when they mix?

Create a model of heat transfer that shows what happens to the energy of one very fast moving gas particle when it hits a bunch of very slow moving gas particles. What does this show happening to the energy of the initial gas particles?

RELATED MODELS

See GasLab Models See other Connected Chemistry models.

CREDITS AND REFERENCES

This model is part of the Connected Chemistry curriculum. See http://ccl.northwestern.edu/curriculum/chemistry/.

We would like to thank Sharona Levy and Michael Novak for their substantial contributions to this model.

HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

To cite the Connected Chemistry curriculum as a whole, please use:

COPYRIGHT AND LICENSE

Copyright 2006 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://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.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
  tick-advance-amount               ; how much we advance the tick counter this time through
  max-tick-advance-amount           ; the largest tick-advance-amount is allowed to be
  init-avg-speed init-avg-energy    ; initial averages
  avg-speed avg-energy              ; current average
  avg-temp-type-1
   avg-temp-type-2
   avg-temp-type-3

  avg-energy-gray
  particle-size
  toggle-red-state
  toggle-green-state
  min-particle-energy
  max-particle-energy
  gas-particles-to-add
  initial-gas-temperature

  #-3-wall-particles
  #-2-wall-particles
  #-1-wall-particles

  #-3-wall-total-te
  #-2-wall-total-te
  #-1-wall-total-te

  init-temp#1
  init-temp#2
  init-temp#3

  left-piece-label
  middle-piece-label
  right-piece-label
  mouse-interaction
  kelvin-celcius-offset
  a
  b

  left-solid-length
  left-solid-width
  middle-solid-length
  middle-solid-width
  right-solid-length
  right-solid-width
]

breed [ gas-particles particle ]
breed [ walls wall ]
breed [ flashes flash ]
breed [ erasers eraser ]
breed [ arrowheads arrowhead ]
breed [ boundaries boundary ]

erasers-own [ pressure? ]
flashes-own [ birthday ]

gas-particles-own [
  speed mass energy          ; gas-particles info
  last-collision
  color-type
]

walls-own [
  energy
  valve-1?
  valve-2?
  pressure?
  my-pxcor
  my-pycor
  my-heading
  distance-advance
  color-type
  particle-type
  init-yoffset
]

to setup
  clear-all
  reset-ticks
  set particle-size 1.0
  set max-tick-advance-amount 0.02

  set #-3-wall-particles 0
  set #-2-wall-particles 0
  set #-1-wall-particles 0
  set kelvin-celcius-offset 273
  set gas-particles-to-add 2
  set mouse-interaction "none"
  set a 200
  set b .75
 ; set initial-gas-temperature 500
  set   left-solid-length 8
  set   left-solid-width 8
  set   middle-solid-length 2
  set   middle-solid-width 8
  set   right-solid-length 8
  set   right-solid-width 8

  set init-temp#1 left.start.temp ;+ kelvin-celcius-offset
  set init-temp#2 middle.start.temp ;+ kelvin-celcius-offset
  set init-temp#3 right.start.temp; + kelvin-celcius-offset

  set-default-shape flashes "square2"
  set-default-shape walls "circle"
  set-default-shape erasers "eraser"
  set-default-shape arrowheads "default"

  set min-particle-energy 100
  set max-particle-energy 500  ;(.5 ) * ( max-dist-in-tick-advance-amount  / max-tick-advance-amount ) ^ 2

  create-erasers 1 [ set hidden? true set size 1.2 set color [255 255 255 100] ]

  make-box

  ask walls [transfer-energy-mytype]

  ask walls [recolorshade-walls]

  ask gas-particles [ apply-speed-visualization ]

  set init-avg-speed avg-speed
  set init-avg-energy avg-energy

  update-variables
  do-plots
end 

to go
   if end-simulation? [ stop ]
  ask walls [transfer-energy]
  ask walls [calculate-distance-advance-amount]

  ask walls [apply-vibration-motion-visualization]
  ask gas-particles [ apply-speed-visualization ]
  ask walls [recolorshade-walls]

  update-variables
  do-plots

  calculate-tick-advance-amount
  tick-advance tick-advance-amount

  display
end 

to calculate-distance-advance-amount
   set distance-advance (distance-advance + (tick-advance-amount * (energy) * 9 ))
end 

to-report end-simulation?
  let value-to-report false
  let auto-stop-simulation? ""
  if auto-stop-simulation? = "at time = 5" and ticks >= 5    [set value-to-report true]
  if auto-stop-simulation? = "at time = 10" and ticks >= 10  [set value-to-report true]
  if auto-stop-simulation? = "at time = 15" and ticks >= 15  [set value-to-report true]
  if auto-stop-simulation? = "at time = 20" and ticks >= 20  [set value-to-report true]
 ; set value-to-report true
  report value-to-report
end 

to update-variables

  if any? gas-particles [
    set avg-speed  mean [ speed ] of gas-particles
    set avg-energy( mean [ energy ] of gas-particles - kelvin-celcius-offset)
  ]
  let wall-particles-type-1 walls with [particle-type = 1]
  let wall-particles-type-2 walls with [particle-type = 2]
  let wall-particles-type-3 walls with [particle-type = 3]



  ;show count gas-particles-type-1
  ifelse any? wall-particles-type-1 [
     set #-1-wall-particles count wall-particles-type-1
     set avg-temp-type-1 ( (mean [ energy ] of wall-particles-type-1)  - kelvin-celcius-offset)
     set #-1-wall-total-te ((mean [ energy ] of wall-particles-type-1)  * #-1-wall-particles )
     set left-piece-label avg-temp-type-1
   ; show "yes"
  ]
  [set left-piece-label "N/A"]
  ifelse any? wall-particles-type-2 [
     set #-2-wall-particles count wall-particles-type-2
     set avg-temp-type-2 ( (mean [ energy ] of wall-particles-type-2)  - kelvin-celcius-offset)
     set #-2-wall-total-te ((mean [ energy ] of wall-particles-type-2)  * #-2-wall-particles )
     set middle-piece-label avg-temp-type-2
   ; show "yes"
  ]
  [set right-piece-label "N/A"]
    ifelse any? wall-particles-type-3 [
     set #-3-wall-particles count wall-particles-type-3
     set avg-temp-type-3 ( (mean [ energy ] of wall-particles-type-3)  - kelvin-celcius-offset)
     set #-3-wall-total-te ((mean [ energy ] of wall-particles-type-3) * #-3-wall-particles )
     set right-piece-label avg-temp-type-3
   ; show "yes"
  ]
  [set right-piece-label "N/A"]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS MOLECULES MOVEMENT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to bounce  ; gas-particles procedure
  ; get the coordinates of the patch we'll be on if we go forward 1
  let bounce-patch nobody
  let bounce-patches nobody
  let hit-angle 0
  let this-patch patch-here
  let new-px 0
  let new-py 0
  let visible-wall nobody
  let particle-energy energy

  set bounce-patch  min-one-of walls in-cone ((sqrt (2)) / 2) 180 with [ myself != this-patch ] [ distance myself ]

  if bounce-patch != nobody [
    let wall-energy [energy] of bounce-patch
    let energy-difference (particle-energy - wall-energy)
    set new-px [ pxcor ] of bounce-patch
    set new-py [ pycor ] of bounce-patch
    set visible-wall walls-on bounce-patch

    if any? visible-wall with [ not hidden? ]  [
      set hit-angle towards bounce-patch
      ifelse (hit-angle <= 135 and hit-angle >= 45) or (hit-angle <= 315 and hit-angle >= 225) [
        set heading (- heading)
      ][
        set heading (180 - heading)
      ]
      set energy (energy - (energy-difference / 4))
      set speed speed-from-energy
      ask bounce-patch [set energy (energy + (energy-difference / 4)) ]
      if true [; show-wall-hits? [
        ask patch new-px new-py [
          sprout 1 [
            set breed flashes
            set color gray - 2
            set birthday ticks
          ]
        ]
      ]
    ]
  ]
end 

to rewind-to-bounce  ; gas-particles procedure
  ; attempts to deal with particle penetration by rewinding the particle path back to a point
  ; where it is about to hit a wall
  ; the particle path is reversed 49% of the previous tick-advance-amount it made,
  ; then particle collision with the wall is detected again.
  ; and the particle bounces off the wall using the remaining 51% of the tick-advance-amount.
  ; this use of slightly more of the tick-advance-amount for forward motion off the wall, helps
  ; insure the particle doesn't get stuck inside the wall on the bounce.

  let bounce-patch nobody
  let bounce-patches nobody
  let hit-angle 0
  let this-patch nobody
  let new-px 0
  let new-py 0
  let visible-wall nobody

  bk (speed) * tick-advance-amount * .49
  set this-patch  patch-here

  set bounce-patch  min-one-of walls in-cone ((sqrt (2)) / 2) 180 with [ self != this-patch ] [ distance myself ]

  if bounce-patch != nobody [

    set new-px [pxcor] of bounce-patch
    set new-py [pycor] of bounce-patch
    set visible-wall walls-on bounce-patch

    if any? visible-wall with [not hidden?] [
      set hit-angle towards bounce-patch

      ifelse (hit-angle <= 135 and hit-angle >= 45) or (hit-angle <= 315 and hit-angle >= 225) [
        set heading (- heading)
      ][
        set heading (180 - heading)
      ]

      if true [;[show-wall-hits? [
        ask patch new-px new-py [
          sprout 1 [
            set breed flashes
            set color gray - 2
            set birthday ticks
          ]
        ]
      ]
    ]
  ]
  fd (speed) * tick-advance-amount * .51
end 

to move  ; gas-particles procedure
  if patch-ahead (speed * tick-advance-amount) != patch-here [ set last-collision nobody ]
  jump (speed * tick-advance-amount)
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS MOLECULES COLLISIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;from GasLab

to calculate-tick-advance-amount
  set tick-advance-amount max-tick-advance-amount
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  mouse interaction procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to mouse-action
 let snap-xcor 0
 let snap-ycor 0
 let orig-xcor 0
 let orig-ycor 0
 let eraser-window-walls nobody
 let eraser-window-gas-particles nobody

  ifelse mouse-down? [
    set orig-xcor mouse-xcor
    set orig-ycor mouse-ycor
    set snap-xcor round orig-xcor
    set snap-ycor round orig-ycor

    ask patches with [ pxcor = snap-xcor and pycor = snap-ycor ] [
      set eraser-window-walls  walls-here
     ; show eraser-window-walls
      set eraser-window-gas-particles gas-particles-here



      if mouse-interaction = "speed up gas-particles"  [

        ask erasers [
          set hidden? false
          set shape "spray paint"
          setxy orig-xcor orig-ycor
        ]
        ask eraser-window-gas-particles [
          set energy (energy * 1.1)
          set energy limited-particle-energy
          set speed speed-from-energy
        ;  apply-vibration-color-visualization
        ]
        ask eraser-window-walls [
          set energy (energy * 1.1)
          set energy limited-particle-energy
         ; apply-vibration-color-visualization
        ]



      ]

      if mouse-interaction = "slow down gas-particles" [
        ask erasers [
          set hidden? false
          set shape "spray paint"
          setxy orig-xcor orig-ycor
        ]
        ask eraser-window-gas-particles [
          set energy (energy / 1.1)
          set energy limited-particle-energy
          set speed speed-from-energy
          apply-speed-visualization
        ]
        ask eraser-window-walls [
          set energy (energy / 1.1)
          set energy limited-particle-energy
        ;  apply-vibration-color-visualization
        ]
      ]
    ]
    ask gas-particles with [ any? walls-here ] [ remove-from-walls ] ; deal with any walls drawn on top of gas-particles
  ][
    ask erasers [ set hidden? true ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; thermal energy transfer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to transfer-energy
  let neighboring-walls walls-on neighbors4
  let my-energy energy
  let total-energy-from-neighbors 0

  if any? neighboring-walls [

  ask neighboring-walls [
    let energy-from-me (((energy) * (0.25)))
    set energy (energy - energy-from-me)
    set total-energy-from-neighbors total-energy-from-neighbors + energy-from-me
  ]

  set energy energy + total-energy-from-neighbors
  ]
end 

to transfer-energy-mytype
  let my-type particle-type
  let neighboring-walls-all walls-on neighbors4
  let neighboring-walls neighboring-walls-all with [particle-type = my-type]
  let my-energy energy
  let total-energy-from-neighbors 0

  if any? neighboring-walls [

  ask neighboring-walls [
    let energy-from-me (((energy) * (0.25)))
    set energy (energy - energy-from-me)
    set total-energy-from-neighbors total-energy-from-neighbors + energy-from-me
  ]

  set energy energy + total-energy-from-neighbors
  ]
end 

to check-slide-up
  if particle-type = 1 [set ycor slide-left-solid-up + init-yoffset]
  if particle-type = 2 [set ycor slide-middle-solid-up + init-yoffset]
  if particle-type = 3 [set ycor slide-right-solid-up + init-yoffset]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; particle speed and flash visualization procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to apply-vibration-motion-visualization
  set xcor my-pxcor
  check-slide-up
 ; set my-heading my-heading + (energy / 100) * (random-float 5  - random-float 5) ; (energy / 100)  - random-float (energy / 100)
;  set heading my-heading
  let displacement (0.05 * ((energy / a) ^ b) *  sin (distance-advance) )
  fd displacement
end 

to apply-speed-visualization
  recolorshade-gas-particles
 ; if visualize-speed? = "arrows" [ scale-arrowheads ]
 ; if visualize-speed? = "different shades" [ recolorshade-gas-particles ]
 ; if visualize-speed? = "none" [ recolornone ]
end 

to color-particle-and-link
  let this-link my-out-links
  let this-color-type color-type
  set color this-color-type
  ask this-link [ set color this-color-type ]
end 

to scale-arrowheads
  let this-xcor xcor
  let this-ycor ycor
  let this-speed speed
  let this-heading heading
  let this-arrowhead out-link-neighbors
  let this-link my-out-links
  ask this-link [ set hidden? false ]
  ask this-arrowhead [
    set xcor this-xcor
    set ycor this-ycor
    set heading this-heading
    fd .5 + this-speed / 3
  ]
end 

to-report my-color-type
  let this-color-type color-type
  report this-color-type
end 

to recolorshade-gas-particles
  let this-link my-out-links
  let this-arrowhead out-link-neighbors

  let local-color-type my-color-type
  let energy-difference (energy)
  let r-value ((4.9) * (1 - 0.999 ^ (energy)))


  let this-color ((my-color-type + 4.99) - r-value)

  set color this-color
  ask this-link [ set color this-color ]
  ask this-arrowhead [ set color this-color ]
end 

to recolornone
  let this-link my-out-links
  let this-arrowhead out-link-neighbors
  let this-color color-type
  set color color-type
  ask this-link [set color this-color]
  ask this-arrowhead [ set color this-color ]
end 

to recolorshade-walls
  let this-link my-out-links
  let this-arrowhead out-link-neighbors

  let local-color-type my-color-type
  let energy-difference (energy)
  let r-value ((8.9) * (1 - 0.999 ^ (energy)))

  let this-color ((my-color-type + 4.99) - r-value)

  set color this-color
  ask this-link [ set color this-color ]
  ask this-arrowhead [ set color this-color ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  initialization procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to make-box
  let vertical-line min-pycor
  let vertical-line-xcor 0.5
  let vertical-line-offset 8

  create-boundaries 1 [
    set xcor (vertical-line-xcor)  set shape "new-line" set color [255 255 255 120] set size 17
  ]
  create-boundaries 1 [
    set xcor (vertical-line-xcor + left-solid-width) set shape "new-line" set color [255 255 255 120] set size 17
  ]
 create-boundaries 1 [
    set xcor (vertical-line-xcor + left-solid-width + middle-solid-width) set shape "new-line" set color [255 255 255 120] set size 17
  ]

 create-boundaries 1 [
    set xcor (vertical-line-xcor + left-solid-width + middle-solid-width + right-solid-width) set shape "new-line" set color [255 255 255 120] set size 17
  ]


  ask patches with [ ((pycor >= (min-pycor + slide-left-solid-up)) and (pycor < (min-pycor + slide-left-solid-up + left-solid-length )) )
      and (pxcor > min-pxcor ) and (pxcor <= (left-solid-width)) ] [
      sprout 1 [set breed walls set color-type red set size 1.0 set particle-type 1 set shape "rounded-square" initialize-this-wall set init-yoffset( pycor - slide-left-solid-up)]
  ]

  ask patches with [ ((pycor >= (min-pycor + slide-middle-solid-up )) and (pycor < (min-pycor + slide-middle-solid-up + middle-solid-length )) )
      and (pxcor > (min-pxcor + left-solid-width )  and (pxcor <=  (min-pxcor + left-solid-width  + middle-solid-width))) ] [
      sprout 1 [set breed walls set color-type red set particle-type 2 set size 1.0 set shape "rounded-square" initialize-this-wall set init-yoffset( pycor - slide-middle-solid-up) ]
  ]

  ask patches with [ ((pycor >= (min-pycor + slide-right-solid-up )) and (pycor < (min-pycor + slide-right-solid-up + right-solid-length )) )
      and (pxcor > (min-pxcor + left-solid-width + middle-solid-width))  and (pxcor <= (min-pxcor  + middle-solid-width + left-solid-width + right-solid-width)) ] [
      sprout 1 [set breed walls set color-type red set size 1.0  set particle-type 3 set shape "rounded-square" initialize-this-wall set init-yoffset( pycor - slide-right-solid-up)]
  ]
end 

to initialize-this-wall
  set valve-1? false
  set valve-2? false
  set pressure? false
  if particle-type =  1 [set energy left.start.temp + kelvin-celcius-offset]
  if particle-type =  2 [set energy middle.start.temp  + kelvin-celcius-offset]
  if particle-type =  3 [set energy right.start.temp  + kelvin-celcius-offset]
  set my-pxcor pxcor
  set my-pycor pycor
  set my-heading random 360
  set distance-advance 0
end 

to setup-gas-particles  ; gas-particles procedure
  set shape "circle"
  ;set size particle-size
  set energy initial-gas-temperature
  set color-type 5
  set color color-type
  set mass (10)  ; atomic mass
  hatch 1 [
    set breed arrowheads
    set hidden? true
    create-link-from myself [ tie ]
  ]
  set speed speed-from-energy
  set last-collision nobody
end 


; Place gas-particles at random, but they must not be placed on top of wall atoms.
; This procedure takes into account the fact that wall molecules could have two possible arrangements,
; i.e. high-surface area ot low-surface area.

to random-position ;; gas-particles procedure
  let open-patches nobody
  let open-patch nobody
  set open-patches patches with [not any? turtles-here and pxcor != max-pxcor and pxcor != min-pxcor and pycor != min-pycor and pycor != max-pycor]
  set open-patch one-of open-patches

  ; Reuven added the following "if" so that we can get through setup without a runtime error.
  if open-patch = nobody [
    user-message "No open patches found.  Exiting."
    stop
  ]

  setxy ([ pxcor ] of open-patch) ([ pycor ] of open-patch)
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; wall penetration error handling procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; if gas-particles actually end up within the wall

to remove-from-walls
  let this-wall walls-here with [ not hidden? ]

  if count this-wall != 0 [
    let available-patches patches with [ not any? walls-here ]
    let closest-patch nobody
    if (any? available-patches) [
      set closest-patch min-one-of available-patches [ distance myself ]
      set heading towards closest-patch
      setxy ([ pxcor ] of closest-patch)  ([ pycor ] of closest-patch)
    ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GRAPHS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;REPORTERS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to-report speed-from-energy
  report sqrt (2 * energy / mass)
end 

to-report energy-from-speed
  report (mass * speed * speed / 2)
end 

to-report limited-particle-energy
  let limited-energy energy
  if limited-energy > max-particle-energy [ set limited-energy max-particle-energy ]
  if limited-energy < min-particle-energy [ set limited-energy min-particle-energy ]
  report limited-energy
end 

to-report vibration-displacement
end 

to do-plots
  set-current-plot "Temperature of solids"
  if #-1-wall-particles > 0 [
    set-current-plot-pen "left"
    plotxy ticks avg-temp-type-1
  ]
    if #-2-wall-particles > 0 [
    set-current-plot-pen "middle"
    plotxy ticks avg-temp-type-2
  ]
    if #-3-wall-particles > 0 [
    set-current-plot-pen "right"
    plotxy ticks avg-temp-type-3
  ]
end 



; Copyright 2006 Uri Wilensky.
; See Info tab for full copyright and license.

There are 2 versions of this model.

Uploaded by When Description Download
Michael Novak over 4 years ago temp change initial Download this version
Michael Novak over 4 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Conduction in solids intro.png preview Preview for 'Conduction in solids intro' over 4 years ago, by Michael Novak Download

This model does not have any ancestors.

This model does not have any descendants.