| ECCC-3 Contents Page | THEOCHEM Home Page | Elsevier Chemistry Home Page |
|
Laboratoire de Chimie Théorique AppliquéeE-mail:
David.Mosley@fundp.ac.be
|
A significant amount of educational material can also be found on the WWW. This may be presented in the form of virtual textbooks, as support for regular lecture and practical courses, or as standalone remote learning material [7]. Aspects of applied quantum and computational chemistry play an increasingly important role in undergraduate and graduate chemistry courses as molecular modelling tools are used more and more widely used in several domains of chemical research. Our aim here is to investigate the potential of JavaScript scripts embedded within HTML pages for model, interactive, quantum chemical calculations. The two examples we give are:
In the next section we give a brief introduction to the JavaScript language, its functionality, and its embedding within HTML documents. This is followed by a more detailed discussion of the examples, before closing the paper with comments on the performance of the scripts and on scope for further development of this type of teaching material on the WWW.
JavaScript supports run-time operations on a small number of data types (numeric, Boolean and string values), objects and methods. Functions are also supported within JavaScript, which enhances both the power of the language and the simplicity of the relevant scripts. Indeed, the appeal of JavaScript lies in its relative simplicity as a tool for developing client and server internet applications.
A simple example of a JavaScript script to find the distance between two points, given by their respective x,y, and z co-ordinates introduced by the user via a HTML form is given below in Figure 1. The resulting screen output is then given in Figure 2, which the reader may then try.
<SCRIPT Language="JavaScript">
function dist(form) {
xx=Math.pow((form.x1.value-form.x2.value),2)
yy=Math.pow((form.y1.value-form.y2.value),2)
zz=Math.pow((form.z1.value-form.z2.value),2)
form.distance.value=Math.sqrt(xx+yy+zz)
}
</SCRIPT>
<FORM>
x1: <INPUT TYPE="TEXT" NAME="x1" SIZE=10>
y1: <INPUT TYPE="TEXT" NAME="y1" SIZE=10>
z1: <INPUT TYPE="TEXT" NAME="z1" SIZE=10><BR>
x2: <INPUT TYPE="TEXT" NAME="x2" SIZE=10>
y2: <INPUT TYPE="TEXT" NAME="y2" SIZE=10>
z2: <INPUT TYPE="TEXT" NAME="z2" SIZE=10><BR>
<INPUT TYPE="button" VALUE="Calculate distance"
OnClick="dist(this.form)">
<INPUT TYPE="RESET" VALUE="Clear input">
<BR>
Result: <INPUT TYPE="TEXT" NAME="distance" SIZE=25> <BR>
</FORM>
|
Figure 1: |
JavaScript script and HTML source for a simple example JavaScript script to find the distance between two points, given by their respective x, y, and z co-ordinates introduced by the user via a HTML form. |
Figure 2: |
Screen output for the JavaScript script and HTML source listed in Figure 1. |
dist, defined between
the <SCRIPT> .... </SCRIPT> tags, using the
OnClick event handler, which, as its name suggests, responds
to a mouse click on the Calculate distance button.
Values of individual elements of the form (x1, y1, ...), identified
by the NAME attribute in the form, are referred to in the function
dist as form.name.value.
In the example, the result of the calculation is written
to the empty Result box in the form, via the
NAME attribute of the input data field. It is also possible, using
the JavaScript write method, to write directly to a HTML
document, to a separate frame in the browser window, or to a different browser window, this giving the possibility to create HTML pages
on the fly.
JavaScript scripts can be included at any point
in a HTML document, as is the case with the example in Figure1.
It is common practice to place the scripts in the
<HEAD> ... </HEAD> section of an HTML document.
The JavaScript itself can be hidden from old browsers which are unable to
run scripts through enclosing the commands between
comment tags, <!-- ... -->, which must be included
immediately after (and immediately before) the <SCRIPT>
(</SCRIPT>) tags.
In the applications presented here, we are particularly interested in
exploiting the numerical
capabilities of JavaScript in illustrative quantum chemical calculations.
It is perhaps worth noting that several methods for simple
mathematical functions are built in
to the Math object which make
JavaScript attractive for these applications and for scientific usage.
These methods include basic trigonometric functions
(sin, cos, tan, asin, acos, atan), square root and power
functions (sqrt, pow)
(as used in Figures 1 and 2), a random number generator (random), logarithmic and exponential functions (log, exp),
and miscellaneous numerical functions (floor, ceil, max, min,
round).
Another important issue for the development of client/server internet applications is that of portability. Unfortunately, such has been the rapid pace of development of JavaScript that compatibility across platforms and versions is not assured. Examples of bugs and differences in behaviour on different platforms do exist. Scripts written in JavaScript, which originated at Netscape [5], should work with versions of Netscape 2.0x and higher, and also Microsoft Internet Explorer 3.0. However full and equivalent functionality of JavaScript cannot be assumed across platforms and versions. Support for JavaScript across future versions of all browsers is not assured. This is an important question to be faced by the Internet community. It would be a great pity if moves away from platform-dependency of codes and applications was only to be replaced by equivalent problems with browser-dependency. The scripts presented here have been developed and tested with Netscape Versions 2.02 and 3.0 on a Macintosh Quadra 610 and under AIX on IBM RS6000 machines. They do not make use of any of the more particular version and platform sensitive aspects of JavaScript, and so stand a good chance of being portable.
This calculation, despite its simplicity, does illustrate the full conceptual complexity of an SCF calculation. In the form given in Figure 3, the reader is able to select orbital exponents, the convergence threshold, and the maximum number of iterations. Good values to choose for the exponents are in the region of 1.45 and 2.90. These values are close to the values for the "best" double-zeta results for the helium atom, exponents of 1.45363 and 2.91093, obtained by Roetti and Clementi [10], which give an SCF total energy of -2.861672598 a.u.. On running the calculation, a new HTML document is created in a second window which contains the results of the calculation, together with hypertext links to pages giving the formulae used to calculate the one- and two-electron integrals, and the total energy. In an educational environment, the student may use the program to find the optimum orbital exponents and to investigate the variation of the the total energy as a function of the orbital exponents in region of the minimum, or to carry out some integral evaluations and SCF iterations by hand using the formulae available at the click of a mouse button.
The trial solution (or initial guess) of the SCF equations is c1s=1 and c1s'=0. This is an arbitrary choice, and superior choices for the initial guess do exist. In most cases, 20 iterations is more than sufficient for the change in the value of the coefficients between successive iterations to be less than 10-8. An error is flagged if the convergence conditions are not met within the number of iterations specified.
Figure 3: |
Input Form for SCF-LCAO calculation of the 1s2 ground state of the helium atom in a double-zeta basis of Slater-type orbitals |
In this example, the user is able to study the H2 molecule using a single FSGO. As in the previous example, input to the script is via a HTML form, and the user is able to specify the internuclear distance, an initial guess for the orbital exponent, and the displacement of the orbital from the centre of the H-H bond. In the course of the calculation, the orbital exponent is optimized according to a simple optimization scheme.
The utility of this calculation is to enable the student to explore the symmetric and asymmetric FSGO solutions for the hydrogen molecule [13]. Using symmetry arguments, the location of the FSGO at the centre of the H-H bond leads to a physically nonsensical situation at the dissociation limit, i.e., two protons (2H+) and an isolated pair of electrons (2e-). At distances greater than a certain critical distance, the optimal (lowest energy) solution will no longer be the situation in which the orbital is located at the centre of the H-H bond, but in which the orbital has "jumped" towards one of the atoms. Thus, dissociation in the FSGO scheme corresponds to
Plotting the total energy as a function of the displacement of the centre of the FSGO from the centre of the H-H bond (RH-H > 5.5 bohr) in small steps will give access to these symmetry broken solutions, and provide an insight into the symmetry dilema in the conventional Hartree-Fock LCAO-SCF scheme and the question of Hartree-Fock instability.
Figure 4: |
Input Form for the calculation on the H2 molecule using a subminimal FSGO basis set. |
As a choice of language, JavaScript seems to be well suited for the cases chosen. However, a more complete language, such as Java, would be necessary for more complex examples, able to execute across different platforms on the WWW. For the simple applications given, computational effeciency and performance is not an issue. Work is in progress on the extension and enhancement in the form of a Java applet of the FSGO application illustrated here, which will include a graphical representation of the results and the possibility to optimize the position of the orbital. The double-zeta LCAO-SCF calculation on the helium atom could be easily be extended to, for example, a configuration interaction calculation. On a wider scale, the possibility now exists and is being investigated for the development of object-oriented computational chemistry codes across the WWW using Java.
| [1] | Several comprehensive lists of chemistry resources on the internet are available. Three good examples are the Sheffield ChemDex at http://www.shef.ac.uk/uni/academic/A-C/chem/chemdex/; UCLA ChemPointers at http://www.chem.ucla.edu/chempointers.html; Chemistry Information via the Internet, US FDA/CFSAN at http://www.cfsan.fda.gov/~dms/chemist.html |
| [2] | H. S. Rzepa, B. Whitaker and M. J. Winter, Chemical Applications of the World-Wide-Web System , J. Chem. Soc. Chem. Comm., 1907 (1994) ( also see http://chem.leeds.ac.uk/papers/html/chem-com/chem-com.html); O. Casher, G. K. Chandramohan, M. J. Hargreaves, C. J. Leach, P. Murray-Rust, H. S. Rzepa, R. Sayle and B. J. Whitaker, Hyperactive Molecules and the World-Wide-Web Information System, J. Chem. Soc. Perkin Trans. 2, 7 (1995) (also see http://chem.leeds.ac.uk/papers/html/Perkin2/tartrazine.html). |
| [3] | NIST Chemistry WebBook, http://webbook.nist.gov/chemistry/; WWW Chemical Structures Database, http://schiele.organik.uni-erlangen.de/services/webmol.html; WebElements, http://www.shef.ac.uk/~chem/web-elements/; Gaussian Basis Set Order Form, http://www.emsl.pnl.gov:2080/forms/basisform.html; Molecule of the Month, http://www.bris.ac.uk/Depts/Chemistry/MOTM/motm.htm. |
| [4] | Java, Sun Microsystems, Inc, 2550 Garcia Ave., Mountain View, CA 94043-1100, USA, 1996. See http://java.sun.com/index.html. |
| [5] | JavaScript. See http://home.netscape.com/eng/mozilla/3.0/handbook/javascript/index.html. |
| [6] | Molecule Editor 1.0, D. M. Bayada, http://www.chem.leeds.ac.uk/ICAMS/people/denis/moledit.html; Sketch and Fetch, TRIPOS, Inc., http://www.webcom.com/~tripos2/SandF.html; JavaTM-powered Quantum Chemistry, F. Friedman-Hill, http://herzberg.ca.sandia.gov/MolEdit/; JavaScript Pocket Computer for Physics, J. P. Vigneron, http://www.physique.fundp.ac.be/Comp/PhysComp.html |
| [7] | For Example: Global Instructional Chemistry at Imperial College, U.K. (http://www.ch.ic.ac.uk/GIC/); Practical Exercises in Quantum Chemistry at ETH, Switzerland (http://www.scsc.ethz.ch/chem/qcii.html), also see H. P. Lüthi, G. Vacek, A. Hilger and W. Klopper, Practical Exercises in Ab Initio Quantum Chemistry - the World Wide Web as a Teaching Environment, to appear in Computational Chemistry: Reviews of Current Trends, Vol. 2 , J. Leszczynski World Scientific (Singapore), to be published in 1997; Frank Potter's Science Gems - Physical Science I and II, at University of California, Irvine (http://www-sci.lib.uci.edu/SEP/physical.html and http://www-sci.lib.uci.edu/SEP/physical2.html); Theory of Atoms in Molecules, R. F. W. Bader, at McMaster University, Canada (http://www.chemistry.mcmaster.ca/faculty/bader/aim/). |
| [8] | J. M. André, D. H. Mosley, M. C. André, B. Champagne, E. Clementi, J. G. Fripiat, L. Leherte, L. Pisani, D. Vercauteren and M. Vracko, Exploring Aspects of Computational Chemistry: Concepts and Exercises, (Presses Universitaires de Namur, Namur), to be published in 1997. |
| [9] | This example can be found permanently at http://www.chimie.fundp.ac.be/javas/he_dz_calc.html. |
| [10] | C. Roetti and E. Clementi, J. Chem. Phys., 60, 4725 (1974) |
| [11] | This example can be found permanently at http://www.chimie.fundp.ac.be/javas/fsgo_calc.html. |
| [12] | A. A. Frost, J. Chem. Phys., 47, 3707 (1967) |
| [13] | J. M. André, G. Hardy, D. H. Mosley and L. Piela, FSGO Hartree-Fock Instabilities of Hydrogen in External Electric Fields, in Strategies and Applications in Quantum Chemistry, Y. Ellinger and M. Defranceschi (Eds.), Kluwer (Dordrecht) (1996). |