Team:Dundee/Project/Netlogo

From 2013.igem.org

Revision as of 13:46, 9 August 2013 by Kyleharrison (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SECGATEcoloursprobabilities

This page was automatically generated by NetLogo 5.0.4.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.


In order for this to work, this file, your model file (SECGATEcoloursprobabilities.nlogo), and the files NetLogoLite.jar and NetLogoLite.jar.pack.gz must all be in the same directory. (You can copy NetLogoLite.jar and NetLogoLite.jar.pack.gz from the directory where you installed NetLogo.)

On some systems, you can test the applet locally on your computer before uploading it to a web server. It doesn't work on all systems, though, so if it doesn't work from your hard drive, please try uploading it to a web server.

You don't need to include everything in this file in your page. If you want, you can just take the HTML code beginning with <applet> and ending with </applet>, and paste it into any HTML file you want. It's even OK to put multiple <applet> tags on a single page.

If the NetLogoLite files and your model are in different directories, you must modify the archive= and value= lines in the HTML code to point to their actual locations. (For example, if you have multiple applets in different directories on the same web server, you may want to put a single copy of the NetLogoLite files in one central place and change the archive= lines of all the HTML files to point to that one central copy. This will save disk space for you and download time for your users.)

powered by NetLogo

view/download model file: SECGATEcoloursprobabilities.nlogo

WHAT IS IT?

This model follows on the Simple Kinetics 2 model. In Simple Kinetics 2, we saw how changes to variables such as temperature, volume, and concentration affected the rate at which a chemical reaction reached an equilibrium state. Here we model the same phenomenon based upon a physical separation.

This model investigates some laboratory methods that chemists use to purify chemicals. Most of these methods are based upon physical properties of molecular separation. The same principles that affect chemical equilibrium affect physical equilibrium as well. By changing the variables of temperature, volume, and concentration, we can affect not only the speed at which a system reaches equilibrium, but also the nature of the distribution ratio. In this model, we watch how these factors affect the physical distribution of red molecules that are considered “dissolved” in a blue solvent.

HOW TO USE IT

Setup the model by pressing either the SETUP-RANDOM or the SETUP-SIDE buttons at the top of the Interface tab. SETUP-RANDOM distributes all the molecules randomly around the world. SETUP-SIDE distributes the blue molecules evenly, while placing the red molecules on the right side of the world.

Press GO to watch the molecules move about the world as they achieve equilibrium. The plot tracks the relative concentrations of each color molecule on each side of the central divider. If the red line dips below 0, there are more red molecules on the left side of the divider than on the right. If it rises above 0, there are more red molecules on the right side of the divider than on the left. The blue line plots the same relationship for blue molecules.

You can add more red molecules to the right side of the world by pressing ADD RED.

Similarly, you can shrink or expand the right side of the box with the buttons SHRINK RIGHT and EXPAND RIGHT, respectively.

Finally, to change the size of the connection window, move the WINDOW slider to your desired size and then press the CHANGE WINDOW button.

THINGS TO NOTICE

Pay attention to the plot and compare it what you see in the world. Is there an equal number of blue and red molecules on each side of the divider according to the plot and according to what you see in the view?

THINGS TO TRY

Run the model with several different states for each variable. Do you observe similar equilibrium effects to those seen in Simple Kinetics 2? Are there significant differences?

Does the temperature affect the system in the same way it affected the chemical reaction in Simple Kinetics 2? Why or why not?

How does changing the concentration affect the rate at which the molecules achieve equilibrium? Does this make sense?

EXTENDING THE MODEL

The system we have established here always comes to an approximately identical equilibrium state, no matter how you change the variables. In the lab, this is not useful to chemists, who want to separate one type of molecule from another. Can you extend the model to separate all of the red molecules from the blue molecules?

Try adding another color of molecule to the system and randomly distributing all the molecules around the world. Can you devise a way to separate the new molecules from the red molecules?

Add a slider that allows you to alter the temperature of the system. Think about what effect cooling and heating the system would have on the molecules. Be sure to include a command in the procedures window that will execute your proposed effect.

RELATED MODELS

Simple Kinetics 1, Simple Kinetics 2

RELATED MODELS

Simple Kinetics 1
Simple Kinetics 2

CREDITS AND REFERENCES

Thanks to Mike Stieff for his work on this model.

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:

  • Stieff, M. and Wilensky, U. (2001). NetLogo Simple Kinetics 3 model. http://ccl.northwestern.edu/netlogo/models/SimpleKinetics3. 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 2001 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 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 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.

CODE

breed [PP1s PP1]           ;; red molecules
breed [degPs degP]         ;; degradation proteins
breed [mcs mc]             ;; microcystin, assuming so small that kinetic interaction is negligible
breed [complexes complex]   ;; PP1 bounded to microcystin
breed [secBs secB]


globals [
  shrink ;; how many steps right side has been shrunk
  i     
  seperation
  j
  current
  k
  l
  g
  deg-number
  PP1-transported
  init-avg-speed init-avg-energy  ;; initial averages
  avg-speed avg-energy            ;; current averages
  secBs-dead  
]


turtles-own 
[
  speed mass energy          ;; particle info
  last-collision
  bound
  linked?
]



to-report particles
  report (turtle-set PP1s degPs mcs complexes)
end

to-report lefties
  report (turtle-set degPs mcs complexes)
end





to setup-PP1  ;; particle procedure
  set speed 10
  set mass 37500
  set energy (0.5 * mass * (speed ^ 2))
  set last-collision nobody
  set color red
  set size 1.5
  set linked? false
end

to setup-degPs  ;; particle procedure
  set speed 10
  set mass 37500
  set energy (0.5 * mass * (speed ^ 2))
  set last-collision nobody
  set size 2
  set color black
end

to setup-mcs  ;; particle procedure
  set speed 10
  set mass 995
  set energy (0.5 * mass * (speed ^ 2))
  set last-collision nobody
  set bound false
  set size 1
  set color 114
end

to setup-complex  ;; particle procedure
  set speed 10
  set mass 38495
  set energy (0.5 * mass * (speed ^ 2))
  set last-collision nobody
end

to setup-secB  ;; particle procedure
  set speed 10
  set mass 17278
  set energy (0.5 * mass * (speed ^ 2))
  set last-collision nobody
  set color 55
  set size 2
  set linked? false
end


to setup [both-sides?]
  clear-all
  set-default-shape PP1s "circle"
  set-default-shape degPs "square"
  set-default-shape mcs "turtle"
  set-default-shape secBs "key"
  set shrink 0
  set i 0
  set k ( 99 )
  set l ( - 99 )
  set g 0
  set deg-number 0
  set PP1-transported 0
  set j 0
  set current 0
  set seperation 0
  set init-avg-speed avg-speed
  set init-avg-energy avg-energy
  set secBs-dead 0
 
  
  walls
  gates
  

  create-PP1s initial-PP1        ;; makes 42 red PP1s
    [setup-PP1
     randomize-right ]
    
    
  create-degPs degP-number        ;; makes xx degradation proteins
    [setup-degPs
     randomize-left ]
    
    
  create-mcs mc-number
    [ setup-mcs
     randomize-left]
  
   create-secBs initial-secB        ;; makes 42 red PP1s
    [setup-secB
    randomize-right ]
    
    
    
  reset-ticks
end



to randomize-left
  setxy (- (abs random-xcor))
        random-ycor
  if any? patches in-radius 1 with [pcolor != 87]
    [ randomize-left ] ;; try again until we don't land on or near blue
end

to randomize-right
  setxy abs random-xcor
        random-ycor
  if any? patches in-radius 1 with [pcolor != 19.9]
    [ randomize-right ] ;; try again until we don't land on or near blue
end



to go
  ask particles [
    
    if collide? [check-for-collision]
    if random-walk? [rt random-float 360]
    bounce
    fd 1
  ]
    
  ask PP1s [
      loss-PP1
      degrade
      ]
  
  if ticks mod 5 = 0 [
    create-PP1s PP1-production
    [
      setxy abs 48
      random-ycor
      setup-PP1
    ]
    
    create-mcs mc-production
      [
        setxy ( - 48 )
        random-ycor
        setup-mcs
      ]
  ]
 
 
  ask mcs [
    loss-mc 
    bind
  ]
  
  ask secBs [
    stick
    if collide? [check-for-collision]
    if random-walk? [rt random-float 360]
     bounce
    if linked? = false [fd 1]
  ]
  
  create-secBs (initial-secB - (count secBs)) [
    setup-secB
    setxy 1 (one-of [random-pxcor] of patches with [pcolor = 78])
    set secBs-dead 0
  ]
  
  tick
end



to walls
 ask patches with [pxcor > 0 and pxcor < 50][ set pcolor 19.9]
 ;; ask patches with [pxcor = 17 or pxcor = (- 17) or pycor = 17 or pycor = (- 17) or pxcor = 0] [ set pcolor blue ]
  ask patches with [ pxcor = (- 50)] [ set pcolor 3 ]
  ask patches with [ pxcor = 0] [ set pcolor 75 ]
  ask patches with [ pxcor = 50 ] [ set pcolor 8 ]
  if k != -16 [
   periplasm
   set k ( k - 1 )
   walls
   
    ]
end

to periplasm
   if l != 0 [
    ask patches with [pxcor = l  or pycor = k ] [ set pcolor 87 ]
       set l ( l + 1 )
       periplasm
   ]  
end


to gates
  set seperation ( round ( 99 / ( gate-number * 2 ) ) )

 
    if (gate-number mod 2 ) = 1 [
     set seperation ( round ( 99 / ( (gate-number + 1) * 2 ) ) )
     if j != ((gate-number + 1) / 2) [
      ask patches with [ pxcor = 0 and ( pycor = 0 + (seperation * j * 2) or pycor = 0 - (seperation * j * 2) )] [set pcolor 78
        set g 0
        gate-width]
      
      set j (j + 1) 
      gates
      ]
    ]
       if (gate-number mod 2) = 0 [
     if j != (gate-number / 2) [
      ask patches with [ pxcor = 0 and ( pycor = ( - seperation) + (seperation * (j + 1) * 2) or pycor = seperation - (seperation * (j + 1) * 2) )] [set pcolor 78
        set g 0
        gate-width
      ] 
      
       set j (j + 1) 
      gates
      ]
   ]
end

to gate-width
  if ( gate-size mod 2) = 1 [
    if g !=(( gate-size + 1 ) / 2  ) [
    ask patch-at-heading-and-distance 0 g [set pcolor 78]
    ask patch-at-heading-and-distance 180 g [set pcolor 78]
    set g ( g + 1 )
    gate-width
    ]]
  if ( gate-size mod 2) = 0 [
    if g !=(( gate-size ) / 2  ) [
    ask patch-at-heading-and-distance 0 1 [set pcolor 78]
    ask patch-at-heading-and-distance 0 (g + 1) [set pcolor 78]
    ask patch-at-heading-and-distance 180 g [set pcolor 78]
    set g ( g + 1 )
    gate-width
     
    ]    
  ]
end
    
   



to loss-PP1     ;;loss inside cell
   if [pcolor] of patch-ahead 1 = 8 [
   if linked? = false [die
;     ask secBs in-radius 2 [
;       set linked? false
;       ask links [untie die]
     ]
   ]
end

to loss-mc     ;;loss inside cell
   if [pcolor] of patch-ahead 1 = 3 [die]
   if [pcolor] of patch-ahead 2 = 3 [die]
end

to degrade
    ask degPs [ let prey one-of PP1s-here
      if prey != nobody [ 
        ask PP1s-here [ 
          if bound = false [
            if random 100 <= degprob [
        ask prey [die] ]
        set deg-number ( deg-number + 1 )
      ]]
      ]
    ]
;    ask degPs [ let prey one-of complexes-here
;      if prey != nobody [ 
;        ask complexes-here [ 
;          if bound = false [
;        ask prey [die] ]
;        set deg-number ( deg-number + 1 )
;      ]
;      ]
;    ]
end


to bind
  if count PP1s-here = 1 [
    if bound = false [
      if random 100 <= bindprob [
      ask PP1s-here [
      set bound true
      set breed complexes
        ;;set turtle-type "complex"
        set shape "x"
        set color 126
        set size 3]
      
  die]
  ]]

end
    


to bounce ;; turtle procedure
  ;; or [pcolor] of patch-ahead 1 = 87
  
 if [pcolor] of patch-ahead 1 = 75 or [pcolor] of patch-ahead 1 = 3 [
     set heading (- heading) 
 ]
 
 if [pcolor] of patch-ahead 1 = 78 and [pcolor] of patch-here = 87 [
    set heading (- heading)
 ]
  
 ask lefties [
   if [pcolor] of patch-ahead 1 != 87 [set heading (- heading)]
 ]
 
 ask secBs [
   if [pcolor] of patch-ahead 1 = 87 or [pcolor] of patch-ahead 1 = 8  [set heading (- heading)]
 ]
 
 ask PP1s [
 if [pcolor] of patch-ahead 1 = 78 and [pcolor] of patch-here = 19.9 [
   if linked? = false [
     set heading (- heading)]
   if linked? = true [
     if gateprob <= (random 100) [
       set heading (- heading)
     ]
   ]
        ]
 if [pcolor] of patch-ahead 1 = 87 and [pcolor] of patch-here = 78 [

      set linked? false
      unstick

 ]
 ]
end



to check-for-collision  ;; PP1 procedure
    if count other turtles-here = 1
  [
    let candidate one-of other turtles-here with
      [who < [who] of myself and myself != last-collision]
    
    if (candidate != nobody) and (speed > 0 or [speed] of candidate > 0)
    [
      collide-with candidate
      set last-collision candidate
      ask candidate [ set last-collision myself ]
    ]
  ]
 
 
end


to collide-with [ other-particle ] ;; PP1 colliding with other PP1 proteins
  let mass2 [mass] of other-particle
  let speed2 [speed] of other-particle
  let heading2 [heading] of other-particle
  let theta (random-float 360)
  let v1t (speed * cos (theta - heading))
  let v1l (speed * sin (theta - heading))
  let v2t (speed2 * cos (theta - heading2))
  let v2l (speed2 * sin (theta - heading2))
  let vcm (((mass * v1t) + (mass2 * v2t)) / (mass + mass2) )
  set v1t (2 * vcm - v1t)
  set v2t (2 * vcm - v2t)
  set speed sqrt ((v1t ^ 2) + (v1l ^ 2))
  set energy (0.5 * mass * speed ^ 2)
  if v1l != 0 or v1t != 0
    [ set heading (theta - (atan v1l v1t)) ]
  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 stick
  if random 100 <= secBprob [
  if (count other PP1s-here = 1 ) and (linked? = false)
  [
    let candidate one-of other PP1s-here ; with [stick-count = 1]
    if (candidate != nobody); and (speed > 0 or [speed] of candidate > 0)
    [
      ask candidate [
        if linked? = false [
        create-link-to myself[
          tie
          hide-link
        ] ask one-of other secBs-here [set linked? true]
        set linked? true
        ]
      ]
     
    ]
  ]
  ]
end


to unstick
  ask out-link-neighbors [
    ; set heading (- heading)
    ; set linked? false
    ; fd 1
     die
    ]
   ; set linked? false
  
end