Java StarLogo
2.0
english
`turtle`
breeds [cat per oxy]
turtles-own [degrees acid-base]

to go
  wiggle
  friends-meet
end

to wiggle
  seetemp ;move based on temperature
  seepH  ;moved based on pH
  moveoxy ;oxygen moves differently than H2O2
end

to moveoxy
  ;oxygen moves toward the top of the screen
  if breed = oxy [ifelse ycor < 23 
                    [seth 0 fd 2] 
                    [fd 0]]
end

to friends-meet
 ;when catalyst and H2O2 meet, the H2O2 turns to oxygen
 ;this project does not model the creation of water, 
 ;which would also happen here if this were a lab experiment
  if breed = per [if count-cat-here > 0
                     [hatch [setbreed oxy setshape bubble-shape
                             setc white]
                      die]]
end

;this procedure takes a parameter
;more about parameters can be found in the StarLogo online documentation
to move :number
  fd :number
  lt random 360
  bk :number
  rt random 360
end

to seetemp
 ;0=0 degrees C, 1=10 degrees C, ..., 10=100 degrees C
 ;the activity doubles with each 10 degree increase
  if (breed = per) or (breed = cat)
    [if temp = 0 [move .025] 
     if temp = 1 [move .5] 
     if temp = 2 [move .1] 
     if temp = 3 [move .2] 
     if temp = 4 [move .4] 
     if temp = 5 [move .8] 
     if temp = 6 [move .3]]
  if temp > 6 
    [if breed = cat [die]] ;above 60 degrees, enzyme function rapidly drops to zero (denaturization of protein)
end                             

to seepH
 ;the reaction rate declines as the pH moves away from pH=7
 ;reaction rate is changed by a +/- 2x for one pH change between pH 3 and pH 11
 ;pH under 3 or over 11 causes the enzyme (catalyst) bonds to break
  if pH > 11 [if breed = cat [die]]
  if pH < 3 [if breed = cat [die]]   
  if (breed = per) or (breed = cat)
    [if ph = 4 [move .025] 
     if ph = 5 [move .05] 
     if pH = 6 [move .1] 
     if ph = 7 [move .2] 
     if pH = 8 [move .1] 
     if ph = 9 [move .05] 
     if pH = 10 [move .025]]
end


`observer`
to startup
  plotid 2
end

to setup
  plotid 2
  clearplot
  setplot-title ""
  ask-turtles [die]
  graph-setup
  enzyme-setup
  peroxide-setup
end

to graph-setup
  pp1 ppreset setppc gray ;oxygen
  pp2 ppreset setppc green ;catalyst
  pp3 ppreset setppc red ;hydrogen peroxide (H2O2)
  setplot-xrange 0 100
  setplot-yrange 0 500
  setplot-title "Concentrations vs Time"
end

to enzyme-setup ;enzyme = catalyst
  create-cat Cat-Num * 10
  ask-cat [setc yellow
           setxy random screen-height random screen-width
           seth random 360
           setdegrees temp
           setacid-base pH
           setshape enzyme-shape]
end

to peroxide-setup ;peroxide = hydrogen peroxide = H2O2
  create-per Per-Num * 100
  ask-per [setc red
           setxy random screen-height random screen-width
           seth random 360
           setdegrees temp 
           setacid-base pH setshape h202-shape]
end

to graph
  pp1 ppd plot count-oxy
  pp2 ppd plot count-cat
  pp3 ppd plot count-per
end

to start
  startgobutton
  startgraphbutton
end


`information`
Enzyme  

Enzymes are protiens that act as biological catalysts, greatly lowering activation energies and accelerating chemical reactions in living cells. In this project, the catalyst turtles (yellow) act as enzymes in the reaction 2 H2O2 --> 2 H2O + O2. When two hydrogen peroxide (H2O2) molecules (red) share a patch with a catalyst, they react to form 2 molecules of water (not shown) and a molecule of oxygen (white) which rises to the top of the  solution.  

Press "setup" and then "start" to run the simulation. The "Cat-Num" and "Per-Num" sliders control the initial number of catalysts and peroxide molecules, respectively. As the concentration of enzyme or catalyst increases, so does the  probability that the reaction will occur. The "temp" slider influences how fast the molecules move, effectively  controlling how often the molecules meet and are able to form  water. The monitors show the number of catalyst, peroxide, and water molecules. Note that the amount of catalyst stays constant throughout.


`interface`
SLCanvas
top-left 8 224

SLSlider
top-left 105 101
width-height 88 25
name "Init Peroxide"
variable "per-num"
min-value 1
max-value 4
current-value 4
slider-number 1
show-name? true

SLMonitor
top-left 191 16
width-height 82 36
name "peroxide count"
list-to-run "count-per"
digits 0
delay 0.5
monitor-number 2
show-name? true
whichip 18
onewhichip 19

SLMonitor
top-left 191 106
width-height 82 36
name "catalyst count"
list-to-run "count-cat"
digits 0
delay 0.5
monitor-number 3
show-name? true
whichip 20
onewhichip 21

SLMonitor
top-left 234 57
width-height 82 36
name "oxygen count"
list-to-run "count-oxy"
digits 0
delay 0.5
monitor-number 1
show-name? true
whichip 22
onewhichip 23

SLSlider
top-left 105 12
width-height 83 25
name "Init Catalyst"
variable "cat-num"
min-value 1
max-value 4
current-value 3
slider-number 0
show-name? true

SLSlider
top-left 147 12
width-height 86 25
name "temperature"
variable "temp"
min-value 0
max-value 10
current-value 5
slider-number 2
show-name? true

SLSlider
top-left 146 107
width-height 75 25
name "slider4"
variable "pH"
min-value 1
max-value 14
current-value 7
slider-number 3
show-name? false

SLLegend
top-left 422 45
width-height 81 16
name ""
shape 1
color -11418368
show-border? false
legend-number 5
toolTip-text "2H2O2 -> 2H2O + O2"

SLLegend
top-left 404 45
width-height 81 16
name ""
shape 1
color -7434610
show-border? false
legend-number 4
toolTip-text "2H2O2 -> 2H2O + O2"

SLLegend
top-left 440 45
width-height 81 16
name ""
shape 1
color -65536
show-border? false
legend-number 6
toolTip-text "2H2O2 -> 2H2O + O2"

SLLegend
top-left 440 67
width-height 136 16
name "Hydrogen Peroxide"
shape 10
color -65536
show-border? false
legend-number 3
toolTip-text "2H2O2 -> 2H2O + O2"

SLLegend
top-left 404 65
width-height 81 16
name "Oxygen"
shape 11
color -65536
show-border? false
legend-number 1
toolTip-text "2H2O2 -> 2H2O + O2"

SLLegend
top-left 422 65
width-height 81 16
name "Enzyme"
shape 9
color -65536
show-border? false
legend-number 2
toolTip-text "2H2O2 -> 2H2O + O2"

SLLineWidget
top-left 281 14
width-height 181 111
id 2
order 2
type 1
title "Concentrations vs Time"
delay-string "1.0"
xlabel ""
ylabel ""
grid false
connected true
autoscaletrue
location 0 0
wizard-on false

SLButton
turtle-or-observer? observer
top-left 11 97
width-height 54 30
name "button2"
line-to-run "start"
forever? false
button-number 3
show-name? false
whichip 14

SLButton
turtle-or-observer? turtle
top-left 48 37
width-height 54 30
name "gobutton"
line-to-run "go"
forever? true
button-number 4
show-name? false
whichip 16

SLButton
turtle-or-observer? observer
top-left 48 97
width-height 55 30
name "graphbutton"
line-to-run "graph"
forever? true
button-number 5
show-name? false
whichip 15

SLButton
turtle-or-observer? observer
top-left 11 37
width-height 54 30
name "button1"
line-to-run "setup"
forever? false
button-number 2
show-name? false
whichip 17


`turtle shapes`
[encoded data, 8385 characters]
VVVVVVVtt/8PciU8j+0OFQAAFQ7t

`template`
null

`settings`
patch-size 8
num-shapes 256
screen-half-width 25
screen-half-height 25
interface-window-xcor 160
interface-window-ycor 103
interface-window-size 653 468
output-window-xcor 691
output-window-ycor 57
output-window-width 300
output-window-height 219
info-window-xcor 422
info-window-ycor 64
info-window-width 500
info-window-height 419
control-center-xcor 13
control-center-ycor 14
control-center-width 476
control-center-height 615
turtle-command-center-height 150
observer-command-center-height 150

`string table`
H4sIAAAAAAAAAGNgYGBiYGAQc87PS07NKylKLMnMzytWKCtWCMnMTQUAUBjmSB4A
AAAAAAAe

`symbol table`
H4sIAAAAAAAAAGNgYGAAABzfRCEEAAAAAAAABA==

`double table`
H4sIAAAAAAAAAGNgYBB08G5gAAEHPQYI7Qbh23+A8pWgtAqU5oDSDFBaDULbzwSD
WfYPoPydUP5JKH0TSr+E0peNwcB+JYQPAFuImTeMAAAAAAAAjA==

`list table`
H4sIAAAAAAAAAHVRSQ4DMQgDklkyXaUeKlXq7+Yw/1cf0DiYiksjRRjiOIaIyENE
VEWsR0OsMtZJvT6hhsMei3kNePeonzrSHx/JBmxDTw913biPXck33tn5hv7hTz2d
yS3pXkm+qzoPazLnP6kz9KDR60v4NM/Xjpv8vOrR8SvxjNwW75r3Z/QcfcDnmbh2
fCGGlysx3rsFVp/bm33E/Aq3Jg+Fmo0YmnfimR6AF3oAXlO9Jf5m3m/MET1s8fec
Z/YQZ4V+S3hKZyP/Al7leOtMAgAAAAACTA==

`bytecodes`
H4sIAAAAAAAAAO1WXXLaMBBe/yrY/BiCE0gyE6aBvHGBPHX61JfeIZSolJmCKTht
0mv0Dj1Ne6dK8lpaG7ueaZ46U8+AtLv6Vt9Kn2xBeP/+OeXL5IEf7l/DT/n8AoAR
sEO62KePO2H4oB8L29kNQA882fUOPBt2WT1s5qIt/mZnALbs23IKAEf8bkR6hr78
UbZTsl1jq6ktCFf7xe7jPCcwqyDQF7+IEHCwb5diDom5pZhHYj62gtFsgP0TbFvC
d4r9ICtWEbWhzbffnjdcM50fM0WG1hQ0QyuSy+QZhmqFrgzLOALryhHjfNHaqoXY
16wze6SZm9yC/cDS7I2/RfyigvgWt4hhJQ50d3yfPK0f/v1aXPCUfKBauVIAQ1PK
uJXpqyCeoS6nGHdLcc/E1dSeODTydGUsy1NPyYGRfQXxwV4lwhea8SyruGgHxlY4
Bv7X9Wr1iStHcWy7ZHdKNuGGudgm+cKTp2fhuTa844kmb0XnuLWx8Ntm/aL85DOz
hno7xb7E7Wx7bFw/LQv09xxsbSRzAu0P+zXfPhzmG87lUt40MBobNpc+EWaM8R62
AWH1ijC5Na8DIVbFZkTeY5JZgWELXLlcwtUHTcdDirIuzVBK+4LEOmTdZGyMGQPx
Vha18o08d99ryzW2ldnRNZb22ZStz4lDloiZcpUCQkM8Ly0XtMb7FXjWgC+e02N8
0IAPCb5dge804LsE36vARw34PsEPKvCnDfghwccV+LN6fCHPOckzIlIOiAbGJP+f
5BrKLznfvRW+H6CfXFZ6GqtmGrt5mlxuOpdL3gs0l9eYy4z1S5JnNZL/L7m/llyl
1Mr4cQP+guAvK/BXzZJXMm1D981jmibbu8kk/4h6iCUXVXSasfm3voXz5hjPINQ8
vg6GBptUAFktkBDEO1KOsYA8yjl4l2zXabK/myyTx206F9crkGIpfopyKF5EpuQW
2wtK83dqcrL6XArXPcItF+kLufRqcjZxiY5w2aXjJVz6NTmbuAx+A12xydEkDQAA
AAANJA==

`observer world`
H4sIAAAAAAAAAGMQSMhPKk4tKkstUiguSSxJTXBggAMrBq6CnPyS8syU9NQSIJ+F
gS0nNS+9JAPI5mBgB8kVpOaBlXKDNSPJQgAzEDMBACLnUJBkAAAAAAAAZA==

`patch world`
[encoded data, 7276 characters]

`turtle world`
[encoded data, 5330 characters]
x/kHO5QC/x+EiHDermwAAAAAbK4=

