patches-own [ old-temperature ;; the temperature of the patch the last time thru go temperature ;; the current temperature of the patch ] globals [ plate-size ;; the size of the plate on which heat is diffusing time ;; the number of times thru the go procedure ;; Used for scaling the color of the patches min-temp ;; the minimum temperature at setup time max-temp ;; the maximum temperature at setup time ] ;;;;;;;;;;;;;;;;;;;;;;;; ;;; Setup Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;; to setup ca ;; initialize variables set plate-size round (0.8 * screen-edge-x) ;; use 0.8 to make a nice sized plate set time 0 ;; set up the plate ask patches [ set-initial-temperatures set-edge-temperatures set old-temperature temperature ] set min-temp min values-from patches [old-temperature] set max-temp max values-from patches [old-temperature] draw-legend ask patches [ draw-plate ] end ;; Sets the temperature for inside of the plate to set-initial-temperatures ;; Patch Procedure if ((abs pycor) < plate-size) and ((abs pxcor) < plate-size) [set temperature in-plate-temp] end ;; Draws the Color Scale Legend to draw-legend ;; Patch Procedure locals [ x y ] set x (1 - screen-edge-x) repeat 3 [ set y 0 repeat 11 [ set pcolor-of patch-at x (y * 2 - 11) (hsb (y / 11) 1 1) set pcolor-of patch-at x (y * 2 - 10) (hsb (y / 11) 1 1) set y y + 1 ] set x x + 1 ] end ;; Sets the temperatures of the plate edges and corners to set-edge-temperatures ;; patch procedure ;; set the temperatures of the edges if (pxcor >= plate-size) and ((abs pycor) < plate-size) [set temperature right-temp] if (pxcor <= (- plate-size)) and ((abs pycor) < plate-size) [set temperature left-temp] if (pycor >= plate-size) and ((abs pxcor) < plate-size) [set temperature top-temp] if (pycor <= (- plate-size)) and ((abs pxcor) < plate-size ) [set temperature bottom-temp] ;; set the temperatures of the corners if (pxcor >= plate-size) and (pycor >= plate-size) [set temperature 0.5 * (right-temp + top-temp)] if (pxcor >= plate-size) and (pycor <= (- plate-size)) [set temperature 0.5 * (right-temp + bottom-temp)] if (pxcor <= (- plate-size)) and (pycor >= plate-size) [set temperature 0.5 * (left-temp + top-temp)] if (pxcor <= (- plate-size)) and (pycor <= (- plate-size)) [set temperature 0.5 * (left-temp + bottom-temp)] end ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Runtime Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Runs the simulation through a loop to go ask patches [ ;; diffuse the heat of a patch with its neighbors set temperature (heat-diffusivity * (nsum4 old-temperature)) + ((1 - ( 4 * heat-diffusivity )) * old-temperature) ;; set the edges back to their constant heat set-edge-temperatures set old-temperature temperature draw-plate ] set time time + 1 end ;; Draws the patches that are within the plate to draw-plate ;; Patch Procedure if ((abs pycor) <= plate-size) and ((abs pxcor) <= plate-size) [color-patch] end ;; color the patch based on its temperature to color-patch ;; Patch Procedure set pcolor hsb ((temperature - min-temp) / (1.1 * (max-temp - min-temp))) 1 1 end ;; report the heat diffusivity constant that we use for the calculations to-report heat-diffusivity ;; a few notes on the constants used here: ;; --we use .25 as a time step that causes the heat to diffuse at a reasonable pace ;; --we use alpha + .3 instead of just alpha here since alpha would be too ;; small to view any changes between some of the preset materials ;; --these constants are necessary since this model uses an Euler approximation to ;; calculate the temperature. the approximation is only valid within a certain range ;; of time-steps and this range changes depending upon the value of alpha. report .25 * e ^ (-1 / (alpha + .3)) end ;; Sets the material to update-alpha ifelse (material-type = "wood") ;; wood [ set alpha 0.00128 ] [ ifelse (material-type = "stone") ;; stone [ set alpha 0.012 ] [ ifelse (material-type = "iron") ;; iron [ set alpha 0.2034 ] [ ifelse (material-type = "aluminum") ;; aluminum [ set alpha 0.8418 ] [ ifelse (material-type = "silver") ;; silver [ set alpha 1.7004 ] [ user-message "Choose your own value for alpha!" ] ] ] ] ] 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 1998 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 2002. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1998). NetLogo Heat Diffusion model. ; http://ccl.northwestern.edu/netlogo/models/HeatDiffusion. ; 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/HeatDiffusion ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 312 10 577 296 25 25 5.0 1 10 1 1 1 CC-WINDOW 9 331 307 470 Command Center BUTTON 8 41 63 74 NIL setup NIL 1 T OBSERVER T SLIDER 8 79 302 112 alpha alpha 0.0010 10.0 0.0013 1.0E-4 1 NIL SLIDER 312 305 567 338 top-temp top-temp 1.0 100.0 9.0 1.0 1 NIL SLIDER 100 154 302 187 right-temp right-temp 1.0 100.0 99.0 1.0 1 NIL SLIDER 312 375 567 408 bottom-temp bottom-temp 1.0 100.0 33.0 1.0 1 NIL SLIDER 312 340 567 373 in-plate-temp in-plate-temp 1.0 100.0 50.0 1.0 1 NIL BUTTON 247 41 302 74 Go go T 1 T OBSERVER NIL MONITOR 8 122 81 171 time time 0 1 SLIDER 100 118 302 151 left-temp left-temp 0.0 100.0 9.0 1.0 1 NIL BUTTON 8 41 63 74 Setup setup NIL 1 T OBSERVER T BUTTON 108 41 195 74 Go Once go NIL 1 T OBSERVER T BUTTON 89 257 206 290 Update Alpha update-alpha NIL 1 T OBSERVER T CHOICE 89 211 206 256 material-type material-type "wood" "stone" "iron" "aluminum" "silver" "other" 0 @#$#@#$#@ WHAT IS IT? ----------- This model simulates transient and steady-state temperature distribution of a thin plate. The Graphics Window in the Interface tab shows a square thin plate as viewed from above. The plate is thermally isolated on the two faces parallel to the screen such that heat can flow only in and out from the perimeter of the plate and not into or out of the screen. Heat is kept constant at the edges. As the simulation runs, heat is transmitted from warmer parts of the plate to cooler parts of the plate as shown by the varying color of the plate. Therefore, the temperature of the plate begins to change immediately and possibly differently at different locations, gradually converging to a stable state. Overall, the temperature distribution over the plate is a function of time and location. In addition to this simple use of the model, you are encouraged to control various paramaters, such as the temperature of each edge edge of the plate and of the center of the plate before--and even while--the model is running. Heat diffuses ("spreads") at different rates through different media. These rates can be determined and are called the Thermal Diffusivity of the material. The Greek letter alpha is often associated with this value. The diffusivity of a material does not change based on how much of the material there is. It is always the same. Below is a table containing several different materials with different diffusitivity rates. See that wood (bottom row) has a lower heat diffusivity than, say, iron. This means that it takes a longer for heat to spread through a wooden object than an iron one. That is one reason why the handles of iron saucepans are wooden, and not the other way round. Also, think of a marble table with iron legs that has just been put out in the sun in a street-side cafe. Which material part of the table do you expect will warm up faster? The model allows you to change thermal diffusivity of the plate in two ways. You can directly change the value of ALPHA to any value you like, or you can indirectly change ALPHA by selecting a material. | THERMAL DIFFUSIVITY OF SELECTED MATERIALS | | Material Thermal diffusivity | (alpha cm*cm/s) | | Wood (Maple) 0.00128 | Stone (Marble) 0.0120 | Iron 0.2034 | Aluminum 0.8418 | Silver 1.7004 HOW IT WORKS ------------ Initialize the plate and edges to have temperatures that equal their respective slider values. Each time through the GO procedure, diffuse the heat on each patch in the following way. Have each patch set its current temperature to the sum of the 4 neighbors' old temperature times a constant based on alpha plus a weighted version of the patch's old temperature. (For those interested, the updated temperature is calculated by using a Forward Euler Method.) Then the edges are set back to the specified values and the old temperature is updated to the current temperature. Then the plate is redrawn. HOW TO USE IT ------------- There are five temperature sliders which enable users to set four fixed edge temperatures and one initial plate temperature: -- TOP-TEMP - Top edge temperature -- BOTTOM-TEMP - Bottom edge temperature -- IN-PLATE-TEMP - Initial plate temperature -- LEFT-TEMP - Left edge temperature -- RIGHT-TEMP - Right edge temperature There are two sliders that govern the thermal diffusivity of the plate: -- MATERIAL-TYPE - The value of the choice is that of the above chart. You must press UPDATE ALPHA for this to change the value of ALPHA. -- ALPHA - The alpha constant of thermal diffusivity There are four buttons with the following functions: -- SETUP - Initializes the model -- GO - Runs the simulation indefinately -- GO ONCE - Runs the simulation for 1 time step -- UPDATE ALPHA - press this if you want to set ALPHA to a preset value based on a material selected by the MATERIAL-TYPE choice The TIME monitor shows how many time steps the model has gone through. RUNNING THE MODEL ----------------- Set the paramters on the temperature sliders. Pick a value for ALPHA (or pick MATERIAL-TYPE and press UPDATE ALPHA). After you have changed all the sliders to values you like, press Setup followed by GO or GO ONCE. THINGS TO NOTICE ---------------- How does the equilibrium temperature distribution vary for different edge temperature settings? Notice how an equilibrium (the steady-state condition) is reached. Keep track of the units: | Variables Units | --------- ----- | time 0.1 second | temperature degrees Celsius | length centimeters | diffusivity square centimeters per second THINGS TO TRY ------------- Try different materials to observe the heat transfer speed. How does this compare to physical experiments? Try the following sample settings... | - Top:100, Bottom:0, Left:0, Right:0. | - Top:0, Bottom:100, Left:100, Right:100. | - Top:0, Bottom:66, Left:99, Right:33. | - Top:25, Bottom:25, Left:100, Right:0. EXTENDING THE MODEL ------------------- This model simulates a classic partial differential equation problem (that of heat diffusion). The thin square plate is a typical example, and the simplest model of the behavior. Try changing the shape or thickness of the plate (e.g. a circular or elliptical plate), or adding a hole in the center (the plate would then be a slice of a torus, a doughnut-shaped geometric object). Add a slider to alter this thickness. Try modeling derivative or combined boundary conditions. CREDITS AND REFERENCES ---------------------- To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Heat Diffusion model. http://ccl.northwestern.edu/netlogo/models/HeatDiffusion. 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/HeatDiffusion for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 arrow true 0 Polygon -7566196 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box true 0 Polygon -7566196 true true 45 255 255 255 255 45 45 45 circle true 0 Circle -7566196 true true 35 35 230 person false 0 Circle -7566196 true true 155 20 63 Rectangle -7566196 true true 158 79 217 164 Polygon -7566196 true true 158 81 110 129 131 143 158 109 165 110 Polygon -7566196 true true 216 83 267 123 248 143 215 107 Polygon -7566196 true true 167 163 145 234 183 234 183 163 Polygon -7566196 true true 195 163 195 233 227 233 206 159 spacecraft true 0 Polygon -7566196 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 thin-arrow true 0 Polygon -7566196 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 truck-down false 0 Polygon -7566196 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 Polygon -8716033 true false 195 75 195 120 240 120 240 75 Polygon -8716033 true false 195 225 195 180 240 180 240 225 truck-left false 0 Polygon -7566196 true true 120 135 225 135 225 210 75 210 75 165 105 165 Polygon -8716033 true false 90 210 105 225 120 210 Polygon -8716033 true false 180 210 195 225 210 210 truck-right false 0 Polygon -7566196 true true 180 135 75 135 75 210 225 210 225 165 195 165 Polygon -8716033 true false 210 210 195 225 180 210 Polygon -8716033 true false 120 210 105 225 90 210 turtle true 0 Polygon -7566196 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 @#$#@#$#@ NetLogo 2.0alpha2 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@