Content area
Microsoft Corp's Visual Basic provides an easy operating framework for the design of Windows programs. The programming language should be used by those interested in dynamic data exchange or OLE control of scientific programs for instructional use.
Visual Basic and Dynamic Data Exchange: Controlling Windows Applications
Timothy L. Porter
Department of Physics
Northern Arizona University
Flagstaff, AZ 86011
Jim Maxka end John Abes
Department of Chemistry
Northern Arizona University
Flagstaff, AZ 86011
Commercially available molecular modeling programs have become increasingly popular as classroom tools in graduate and undergraduate chemistry courses. Many of these programs are Windows based, (1) and thus share a common application programming interface (API). Many also are DDE (dynamic data exchange) or OLE (object linking and embedding) enabled. This allows these programs to communicate and share data or objects with each other through the operating environment. One such program, HyperChem, (2) has become popular due to its research quality power as well as its ease of use. In this paper we describe general methods of controlling HyperChem through Visual Basic and DDE, thus extending the capability of this program for demonstration and classroom use.
While some of the DDE commands for Visual Basic control of HyperChem have been documented, (2) most of the work in this area has been performed using Microsoft Excel (10). Visual Basic, however, provides a much easier operating framework for the design of Windows programs and should be considered by anyone interested in the DDE or OLE control of scientific programs for instructional use. As with most Visual Basic programs, the starting point is the main "form". In the main form, the design of controls, text boxes, labels, and graphs is laid out using simple drag-and-drop procedures. The actual code to be performed by the program then is attached to the various controls on the form. In this paper, we will describe only the program operation. The actual code will be made available upon request.
The program "torsion" can vary systematically one, two, or three torsion angles of a chosen molecule. The molecule and torsion angles must be named previously in HyperChem. At each angle(s), the molecular geometry may be optimized using any of the available molecular mechanics or semiempirical methods in HyperChem. During the optimization, the torsion angle may be held fixed by applying a user specified force. After optimization, a single-point molecular mechanics or semiempirical quantum mechanical energy calculation is performed. The user also may specify gradient and cycle limits to these calculations in order to minimize computer time. The resulting molecular energy as a function of torsion angle(s) is then plotted on the Visual Basic form. If two or three torsion angles are varied, the resulting data is written to a file to be plotted using any scientific plotting package.
In the figure, a plot of the total energy versus dihedral angle is shown for the molecule bithiophene. In this plot, each of the two torsion angles was varied from zero to 180 degrees in five-degree increments, and the total energy calculated using the semiempirical method AM1. Four distinct energy minima are identified, with the lowest energy occurring at 35deg for both dihedral angles. The DDE commands used in this program cover many of the basic commands necessary to control HyperChem through Visual Basic. Other DDE commands are available that can control the translational or rotational motion of atoms or molecules, their display, and so on. For example, using simple DDE commands from Visual Basic, we have created a program for classroom demonstration that begins with two atoms separated far enough to be noninteracting. As they are then slowly brought together, quantum mechanical calculations at selected increments graphically show onscreen the evolution of the molecular wavefunction and system energy as the atoms come together. These are only two of the many possibilities for demonstration or research available if we know how to use the powerful DDE capabilities built into Visual Basic.
1 Microsoft Corporation, Redmond, WA.
2 Hypercurbe Inc., Waterloo, Ontario, Canada.
Copyright American Chemical Society Dec 1995