Development of a Real-Time Dynamic Graphing Web Page

Implementation of the Theory as Code

In summary, there are two key equations relating changes in concentrations of A and B to their concentrations at any given time:

In addition, there are two equations relating k1 and k2 to K:

This was made from eqnkkk.

Finally, a measure of whether or not equilibrium has been reached is determined by measuring Q and comparing that value to K.

That pretty much defines our variables.

JavaSciptTheoryMeaning
delay--the time delay between iterations
tmax--the maximum time to allow for equilibration
ttthe time
rra constant related to how fast equilibrium will be reached
A[A]the concentration of A
B[B]the concentration of B
dAD[A]the change in concentration of A
dBD[B]the change in concentration of B
k1k1the forward rate constant
k2k2the reverse rate constant
KKthe equilibrium constant
QQthe reaction quotient

Our key routine is the one that will change the concentrations of A and B. Let's call it react().

These variables are global variables, because we have not placed var in front of their definitions. That's OK, because they are variables that mean something in our theory. Let's make plotpoint() simply display on the document status bar for now:

In addition, we need to initialize these variables:

This is all we need for a perfectly fine JavaScript program that at least displays information on the status bar.

Run initialize();react()

View the code

After you click on the "Run initialize();react()" link, above, consider what might be still needed. For example, how could we stop or interrupt the process if we needed to? If you like, go ahead and change the functions in the text area, then click on the "Run" link again and see what happens. When you are ready, go on to the next page.

back to the list of examples


copyright 2001 Robert M. Hanson. All rights reserved. divgraph.js is freely distributable for noncomercial purposes, provided reference is made as "divgraph.js was developed at St. Olaf College by Robert M. Hanson (http://www.stolaf.edu/people/hansonr/divgraph)." Commercial licensing is available for specific purposes.