![]() |
Development of a Real-Time Dynamic Graphing Web Page | ![]() |
The theory involved relates to rates of chemical reactions. In the case illustrated here:
This really now stands for two standard differential equations:
Thus, we can relate the change in concentration of A (d[A]/dt) at any time to the concentrations of A and B in solution at that time. The same goes for B. These equations can be rewritten:
"Time" in a simulation can be adjusted to fit the circumstances. In our case, we will just consider "dt" to be "1 unit of time" (however long we allow for the JavaScript to go through its loop. Then, technically, we have D[A] and D[B] rather than d[A] and d[B], and we can write:
Furthermore, no one is interested really in k1 or k2 per se. So we can arbitrarily assign them in relation to an equilibrium constant, K, as follows:
Notice that there really isn't any assumption here. This is just a definition. The quotient of any two constants is a constant. What will be interesting to see is whether that constant ultimately, at equilibrium, is related to the concentrations of A and B:
That ratio, [B]/[A], is a meaningful quantity called the reaction quotient, Q. It can be measured anytime, but at equilibrium, it's value should be K.
Furthermore, the exact values of k1 and k2 do not matter. Only their ratio matters. So we will simplify things by adding one more relationship, where r is some constant that we will set and will determine how fast equilibrium is reached.
Now, we can put all these equations together and write:
So we now have k1 and k2 in terms of K. That's important, because it is K that will be input by the user.
This is all the theory we need. Time to implement the theory as code.
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.