Development of a Real-Time Dynamic Graphing Web Page

Development of the Theory

The theory involved relates to rates of chemical reactions. In the case illustrated here:

Always save your ChemDraw as a CDX file as well as a GIF. You'll probably want to use it again.

This really now stands for two standard differential equations:

This graphic was created in Microsoft Word as an equation object. Saving the file as HTML then generated the GIF image.
All of the equations used in this discussio are from the same Word document.

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:

If you put your equations in a Word table with one column and several rows, they will be saved in order.

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:

This was a real pain to produce. It's a matrix with even spacing and equal-sign alignment.

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.

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.