particles in a box Chemical Kinetics

particles in a box Chemical Kinetics preview image

1 collaborator

Default-person Luis Mayorga (Author)

Tags

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.3.0 • Viewed 30 times • Downloaded 4 times • Run 0 times
Download the 'particles in a box Chemical Kinetics' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

globals
[
  box-edge1
  box-edge2
  leftbox-edge
  rightbox
  floor1
  floor2
  entropy1
 ; entropy2
 ; temperature
  R
  yboltz
  enthalpy1
  ; enthalpy2
 ; scale
  Eafloor
 initialstate ; particles in initially in state 1
  ΔG
  ΔG0
  ΔG0e
  -ΔG0e
  ΔS
  ΔH
  Kin1
  Kin2
  K
  tracer
  a
]

breed [ particles particle ]
breed [ flashes flash ]

flashes-own [birthday]

particles-own
[
  mass energy          ;; particle info
  last-collision
  state
]

to setup
  clear-all
  set-default-shape particles "circle"
  set-default-shape flashes "plane"
  set R 1.9858775 / 1000 ;constante de gases en kcal/mol/K
 ; set entropy1 0.3
  set entropy1 1 - entropy2
  set enthalpy1 0
  ifelse enthalpy1 <= enthalpy2
   [set floor1 0
     set floor2 enthalpy2 * scale] ; scale 1kcal= scale y coordenate
   [set floor2 0
     set floor1 -1 * scale * enthalpy2] ; scale 1kcal=scale y coordinate
  set Eafloor max (list floor1 floor2) + Ea * scale
 ; set initialstate 0.1
  set box-edge2 (max-pxcor)
  set box-edge1 min-pxcor + (entropy1 * max-pxcor * 2)
  set ΔH enthalpy2 - enthalpy1
  set ΔS  R * ln (entropy2 / entropy1) ;calculo entropía
  set ΔG0 ΔH - temperature * ΔS ;calculo Δ G cero teórica
  make-box
  set initialstate 1 - avance
  make-particles
  update-variables
  reset-ticks
  set a 1
end 

to go
  ask particles [ bounce ]
    update-variables
    update-plots
    display
    set a a + 1
  if single = true [stop]
;  if a > 1 [stop]
end 

to update-variables
  set ΔG0 ΔH - temperature * ΔS ;calculo Δ G cero teórica
  set Kin1 count turtles with [state = 1]
  set Kin2 count turtles with [state = 2]
  set K count turtles with [state = 2] / (count turtles with [state = 1] + 0.0000000000000001)
  set ΔG0e (- R * temperature * ln (K + 1E-10))
  set -ΔG0e -1 * ΔG0e
  set ΔG R * temperature * ln (K + 1E-10) + ΔG0
end 

to bounce  ;; particle procedure

 ifelse state = 1
     [
     set yboltz floor1 - scale * ln (random-float 1) * R * temperature
     if yboltz >= Eafloor
     [set xcor min-pxcor + random (max-pxcor - min-pxcor)]
     ]
     [
     set yboltz floor2 - scale * ln (random-float 1) * R * temperature
     if yboltz >= Eafloor
     [set xcor min-pxcor + random (max-pxcor - min-pxcor)]
     ]

  ifelse yboltz > max-pycor
       [set ycor  max-pycor]
       [set ycor yboltz]

  ifelse (xcor >= min-pxcor and xcor < box-edge1)
   [set state 1
    set color green]
  [set state 2
    set color red]
end 

;;;
;;; drawing procedures

to make-box

     ; white the part of the  box that is inactive
     ifelse floor1 <= floor2
     [
       ask patches with [ (pxcor > box-edge1) and (pycor < floor2) ]
     [ set pcolor white ]
     ]
     [
       ask patches with [ (pxcor < box-edge1) and (pycor < floor1) ]
     [ set pcolor white ]
     ]

       ; limite superior
    ask patches with [ pycor > max-pycor - 5 ]
    [ set pcolor blue ]

    ; limite inferior
    ask patches with [ (pycor < floor1 + 5 and pycor > floor1 ) and (pxcor <= box-edge1) ]
    [ set pcolor yellow ]

    ask patches with [ (pycor < floor2 + 5 and pycor > floor2) and (pxcor >= box-edge1) ]
    [ set pcolor yellow ]
    ; limite izquierdo
    ask patches with [ (pxcor < min-pxcor + 5) and (pycor >= floor1) ]
    [ set pcolor yellow ]

    ; limite derecho
    ask patches with [ (pxcor > max-pxcor - 5) and (pycor >= floor2) ]
    [ set pcolor yellow ]

    ; limite central
    ask patches with [ (pxcor < box-edge1 + 3 and pxcor > box-edge1 - 3) and (pycor <= Eafloor) ]
    [ set pcolor yellow ]
end 
;;;


;; creates initial particles

to make-particles
  create-particles number-of-particles
  [

    set size 6
    ifelse random-float 1 < initialstate
    [
      set xcor min-pxcor + random (box-edge1 - min-pxcor)
      set yboltz floor1 - scale * ln (random-float 1) * R * temperature
      ifelse yboltz > max-pycor
       [set ycor  max-pycor]
       [set ycor yboltz]
    ]

    [
      set xcor box-edge1 + random (box-edge2 - box-edge1)
      set yboltz floor2 - scale * ln (random-float 1) * R * temperature
      ifelse yboltz > max-pycor
       [set ycor  max-pycor]
       [set ycor yboltz]
    ]


   ifelse (xcor >= min-pxcor and xcor < box-edge1)
  [set state 1
    set color green]
  [set state 2
    set color red]
    ;;random-position

  ]
   set K count turtles with [state = 2] / (count turtles with [state = 1] + 0.00000000000000000000001)
  set ΔG0e (- R * temperature * ln (K + 0.0000000000001))
  set ΔG R * temperature * ln (K + 0.0000000000001) + ΔG0
end 




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

There is only one version of this model, created 3 days ago by Luis Mayorga.

Attached files

File Type Description Last updated
particles in a box Chemical Kinetics.png preview Preview for 'particles in a box Chemical Kinetics' 3 days ago, by Luis Mayorga Download

This model does not have any ancestors.

This model does not have any descendants.