Student Density Lab

No preview image

1 collaborator

Default-person Rhazes Spell (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.2.2 • Viewed 13 times • Downloaded 0 times • Run 0 times
Download the 'Student Density Lab' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

;; DO NOT TOUCH
;; ------------------------
globals [object random-mode-set? oLiquid1 oLiquid2 oLiquid3 oLiquid4 liquids]

turtles-own [dense]
;; ------------------------


;; ------------------------
;; YOUR LAB ANSWERS
;; ------------------------

to-report kg-to-dg [kilograms]
report kilograms * 10000
end 

to-report m3-to-ml [meters-cubed]
  report meters-cubed * 100000
end 

to-report kg-per-m3-to-dg-per-ml [density]
  report round (density / 100)
end 

to draw-background [a-color]
  ask patches [set pcolor a-color]
end 

to draw-flask [a-color]
  ask patches [if pycor > 10 [set pcolor a-color]]
  ask patches [if pxcor > -14 and pxcor < 14 and pycor > -16[set pcolor a-color]]
end 

to pour-liquid [liquid density a-color]
  ask patches [if pycor <= (density * -1) and pxcor > -14 and pxcor < 14 and pycor > -15 [set pcolor a-color]]
  ask patch -5 (density * -1) [set plabel (word liquid " (" density " dg/mL)")]
end 

to create-object
  set-default-shape turtles "circle"
  crt 1 
  [
 set xcor one-of (range -12 12)
    set ycor one-of (range 11 16)
  set size 3
    set color random 255
    set heading 180
    
    ifelse is-random?
    [set dense 4 + random 9]
    [set dense object-density]
    
    set label (word dense " dg/ml")
  ]
end 


;; -----------------------
;; -- END OF LAB ANSWERS --
;; ------------------------


;; ------------------------
;; DO NOT TOUCH
;; ------------------------

to setup
  ; initialize the liquid "objects"
  set oLiquid1 new-oLiquid liquid1 (read-from-string density1) color1
  set oLiquid2 new-oLiquid liquid2 (read-from-string density2) color2
  set oLiquid3 new-oLiquid liquid3 (read-from-string density3) color3
    set oLiquid4 new-oLiquid liquid4 (read-from-string density4) color4
  set liquids (list oLiquid1 oLiquid2 oLiquid3 oLiquid4)

  
  draw-background pink + 3
  ; set the mode based on the UI toggle
  set random-mode-set? false
  
  draw-flask cyan
  

  ; sort liquids by density
  set liquids sort-by [ 
    [l1 l2] -> oLiquid-density l1 < oLiquid-density l2 
  ] liquids
  
  ; pour liquids from top to bottom (least dense to most dense
  foreach liquids [
    [l] -> pour-liquid (oLiquid-name l) (oLiquid-density l) (oLiquid-color l)
  ]
  ;draw-flask cyan
  create-object
  reset-ticks
end 

to run-experiment
  ask turtles [
    if pycor != (-1) * dense [
      fd 1
    ]
  ]
  
;  if not random-mode-set?  [
;    if is-random? [
;  		ask turtle 0 [
;        show "got here once"
;        set dense 4 + random 11
;        set ycor 16
;        set color random 155
;      ]
;    ]  
;  ]

;  set random-mode-set? true
  tick
end 

to bye-bye
  clear-turtles
end 

;; Class oLiquid

to-report new-oLiquid [name density col]
  let converted-density kg-per-m3-to-dg-per-ml density
  ;let converted-density density
  report (list name converted-density col)
end 

to-report oLiquid-name [aLiquid]
  report item 0 aLiquid
end 

to-report oLiquid-density [aLiquid]
  report item 1 aLiquid
end 

to-report oLiquid-color [aLiquid]
  report item 2 aLiquid
end 

to reset
  set liquid1 ""
  set liquid2 ""
  set liquid3 ""
  set liquid4 ""
  set density1 ""
  set density2 ""
  set density3 ""
  set density4 ""
  set color1 white
  set color2 white
  set color3 white
  set color4 white
  
  ask patches [ set pcolor gray + 2 set plabel ""]
  ;draw-flask
  bye-bye
end 

There is only one version of this model, created 4 months ago by Rhazes Spell.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.