Weak Acid
Model was written in NetLogo 5.0.4
•
Viewed 398 times
•
Downloaded 95 times
•
Run 1 time
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
breed [waters water] ;; water molecules breed [hydroniums hydronium] ;; hydronium ions (green) breed [hydroxides hydroxide] ;; base molecules (red) breed [acids acid] ;; parent acid molecules (yellow) breed [conj-bases conj-base] ;; conjugate base molecules of parent acid (orange) globals [ pH Ka ;; variable for acid reactions base-added ;; use to keep track of how much total base has been added ] to setup clear-all set-default-shape waters "molecule2" set-default-shape hydroniums "molecule3" set-default-shape hydroxides "molecule1" set-default-shape acids "molecule2" set-default-shape conj-bases "molecule1" set Ka 1.9 create-acids vol-acid ;; adds parent acid molecules [ set color yellow ] ask acids [ if random-float 100.0 < Ka ;; creates initial dissociated acid [ hatch-hydroniums 1 [ set color green fd 3 ] set breed conj-bases ;; parent turtle turns into a conj-base set color orange ] ] create-waters (100 - count hydroniums) [ set color blue ] ask turtles ;; randomize position and heading of turtles [ setxy random-xcor random-ycor ] set base-added 0 calculate-pH reset-ticks plot-pH end to go ask hydroxides [ react-hydroxide-hydronium ] ask hydroxides [ react-hydroxide-acid ] ask acids [ react-acid ] ask hydroniums [ react-hydronium ] ;; move turtles randomly around the world ask turtles [ fd 1 rt random 10 lt random 10 ] tick calculate-pH plot-pH end ;; adds base molecules to the solution to add-base create-hydroxides vol-base [ fd 1 set color red ] set base-added base-added + vol-base end ;; hydroxide procedure to react-hydroxide-hydronium let partner one-of hydroniums-here ;; tells hydroxide to recognize hydronium if partner != nobody ;; if you are a hydroxide molecule and you encounter a hydronium [ ;; then turn yourself and the hydronium into water molecules set breed waters set color blue ask partner [ set breed waters set color blue ] ] end ;; hydroxide procedure to react-hydroxide-acid if random-float 100.0 < Ka ;; react with acid molecules according to the acid strength [ let partner one-of acids-here if partner != nobody ;; if you are a hydroxide molecule and you encounter an acid molecule ;; then turn the hydroxide into a conjugate base molecule ;; and turn yourself into a water molecule [ set breed waters set color blue ask partner [ set breed conj-bases set color orange ] ] ] end ;; acid procedure to react-acid if random-float 100.0 < Ka ;; acid molecules may dissociate to hydronium depending on their Ka [ let partner one-of waters-here if partner != nobody ;; if you are an acid molecule and you encounter a water molecule ;; then turn the water molecule into a hydronium molecule ;; and turn yourself into a conjugate base molecule [ set breed conj-bases set color orange ask partner [ set breed hydroniums set color green ] ] ] end ;; hydronium procedure to react-hydronium if random-float 100.0 < Ka ;; hydronium molecules may recombine with conjugate base to form acid [ let partner one-of conj-bases-here if partner != nobody ;; if you are a hydronium molecule and you encounter a conjugate base molecule ;; then turn the conjugate base molecule into an acid molecule ;; and turn yourself into a water molecule [ set breed waters set color blue ask partner [ set breed acids set color yellow ] ] ] end ;; calculates the pH from the amount of the various ions in solution; ;; note that for simplicity the calculations don't take the true molar ;; concentration of water into account, but instead use an arbitrarily ;; chosen factor of 1000 to produce numbers lying in a reasonable range to calculate-pH let volume count turtles let concH (count hydroniums / volume) let concOH (count hydroxides / volume) ifelse (concH = concOH) [ set pH 7 ] [ ifelse (concH > concOH) [ set pH (- log (concH / 1000) 10) ] [ let pOH (- log (concOH / 1000) 10) set pH 14 - pOH ] ] end ;; plotting procedures to plot-pH set-current-plot "pH Curve" plot pH end to record-pH set-current-plot "Titration Curve" plotxy base-added pH end ; Copyright 2001 Uri Wilensky. ; See Info tab for full copyright and license.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Weak Acid.png | preview | Preview for 'Weak Acid' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.