Visual Basic and Dynamic Data Exchange: Controlling Windows

Visual Basic and Dynamic Data Exchange: Controlling Windows Applications. Timothy L. Porter, Jim Maxka, and John Abes. Northern Arizona University, Fl...
0 downloads 10 Views 1MB Size
the computer bulletin board

edited by

RUSSELLH. BATT Kenyon College Garnbier. OH 43022

work in this area has been performed using MicrosoR Excel (10). Visual Basic, however, provides a much easier operating framework for the design of Windows programs and should be considered bv "anvone . interested in the DDE Timothv ~~~~~-~~~ ,L. Porter ~ ~ ~ or OLE control of scientific programs for instructional use. Department of Physics As with most Visual Basic Dromams. the startine ~ o i nis t Northern Arizona University the main "form". In the m a k krm, the design oflebutrols, Flagstaff, AZ86011 text boxes, labels, and graphs is laid out using simple dragand-drop procedures. The actual code to be performed by Jim Maxka and John Abes the program then is attached to the various controls on the DepaRmenl of Chem stry form. In this paper, we will describe only the program ophonhern Ar'zona Un versity eration. The actual code will be made available upon reFlagstaff, AZ 86011 quest. The program "torsionncan vary systematically one, two, Commercially available molecular modeling programs or three torsion angles of a chosen molecule. The molecule have become increasingly popular as classroom tools in and torsion angles must be named previously in Hypergraduate and undergraduate chemistry courses. Many of Chem. At each angle(s), the molecular geometry may be these Droerams are Windows based.' and thus share a optimized using any of the available molecular mechanics common application programming interface (API). Many or semiempirical methods in HyperChem. During the optialso are DDE (dvnamic data exchanee) or OLE (obiect linkmization, the torsion angle may be held fured by applying ing and embedkng) enabled. This allows these &ograms a user specified force. After optimization, a single-point to communicate and share data or objects with each other molecular mechanics or semiempirical quantum mechanithrough the operating environment. One such program, cal energy calculation is performed. The user also may HyperChem,' has become popular due to its research qualspecify gradient and cycle limits to these calculations in ity power as well as its ease of use. In this paper we deorder to minimize computer time. The resulting molecular scribe general methods of controlling HyperChem through energy as a function of torsion angle(s) is then plotted on Visual Basic and DDE, thus extending the capability of the Visual Basic form. If two or three torsion angles are this program for demonstration and classroom use. varied, the resulting data is written to a file to be plotted using any scientific plotting package. While some of the DDE commands for Visual Basic control of HyperChem have been documented,' most of the In the figure, a plot of the total energy versus dihedral angle is shown for the molecule bithiophene. In this plot, 'Micmsofl Corporation. Redmond, WA. each of the two torsion angles was varied from zero to 180 'Hypercube lnc., Waterloo. Ontario, Canada. 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 35" 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 a t 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 Total AM1 semlemp~rlcalenergy as a funmonof two lorslona angles for oilhiophene. The powerful DDE capabilities built into Visual lowest energy r n i n ~ m ~ roccurs n at 35" for both tonlon ang es. Basic.

Visual Basic and Dynamic Data Exchange: Controlling Windows Applications

.

-

Angle (Deg)

~

A236

Journal of Chemical Education

~~

~

~~

~~~~