Using the X window system in chemical education

Arizona State University. Tempe, AZ 85281. Using the X Window System in Chemical Education. Robert G. Ford. Department of Computer Science. State Univ...
1 downloads 3 Views 3MB Size
edited by

computer series, 143 Using the X Window System in Chemical Education Robert G. Ford Department of Computer Science State University of New York at Plansburgh Plattsburgh, NY 12901

Understanding chemistry, in general and in particular, is helped through the use of graphical diagrams. Many excellent examples can be found in Tufte's outstanding book, The Visual Display of Quantitative Information ( I ) . The figure below, reproduced from Tulle, illustrates the advantage incumbent office hoiders in the U. S. House of Reoresentatives make of their free mailing privilege a s elections a ~ ~ r o a cAauiek h. look a t the diaeram helps one to unders&d the sitiation better than reading hundreds of words on the topic. Similarly, graphs of various physical quantities versus atomic number can illustrate the periodic nature of the elements much more effectively than a page of text. Over the years, chemistry textbooks have changed dramaticalb to include many more illustrative diamams. Of course, j i s t having the diagrams available does not ensure that they will be understood, or even looked at. In fact, it appears that learning can be enhanced in any manner that gets students to spend time learning. Reading supplementary materials, working problems in the textbook, and drills using computer-aided instruction programs can all be effective, provided they are used by the student. Interactive Computer Graphics Through the use of interactive computer graphics, i t is possible to allow students to work with diagrams that respond to their own input, and thereby increase student interest and participation in the process. This approach may be attractive to some students who would not choose the other methods, and may increase the time spent studying. This is particularly true if the interface to the programs is easy to use, and the student is able to derive benefits rap-

Ftgure 1. Tne volme of franked mad (ml tons of mts per month) sent oy memDers of me U S Home of Representatfvesas a functton of tlme The reaaer may speculate on wnen elect on aay occurs

888

Journal of Chemical Education

JAMES P. BIRK Arizona State University Tempe, AZ 85281

idly without added learning overhead. Several years ago, I developed a promam (2) that had this interactivitv and also w k e a s i t o use. However, the state ofthe art was such that specialized hardware was required, and the . promams were not portable. An early contribution to this series of articles in this Journol surveyed the state of Computer graphic^ for Chemical Education in 1979. The three most noteworthv changes that have occurred in the decade of the 80's were t h e dramatic price decrease of computer hardware the introduction of the micrommputer the development of graphics standards Software for Three Standard Systems Organizations such a s CONDUIT (41,and the Journal of Chemical Education: Software, generally distribute programs written for threestandard systems, the ~ ~ 11, ~ the IBM PC, and the Apple Macintosh. There are a number of benefits to this standardization. First. the ~ortabilitvof Droerams eives a larger clientele for any pm&ims t h i t are d&elopei. At least a s important is the issue of "promammer ~ortabilitv".Writine the first - program for a system involves a steep learning curve. If the proerammer can continue to write Droerams for the sam; &m, productivity will be enhan/ed.r'he most useful atandards wdl be those that work on a number of different systems, over a long period of time, without requiring a lot of specific system knowledge.

-

First Computer for Educational Graphics The first de facto standard computer for educational graphics was the Apple 11.Although widely used, it is now obsolete and has been replaced largely by IBM PC compatibles running the MS/DOS operating system. Both the Apple 11and the IBM PC offer low performance graphics, except in the 386 and 486 versions of the PC's with graphics accelerators. An additional problem with the PC is the large number of graphics adapters that are used. To be generally available to all of these systems, programs could use one of the low end PC graphics standards, or be written to adapt to the graphics capability that is available on a specific machine (Hercules, MDA, EGA, VGA, extended VGA, PGA, ete.). The adaptive technique is more desirable because it can give a muih better appearing diagram when the appropriate hardware is available. However, this complicates the writing of the programs. In addition, new PC graphics standards (TIGA and 851UA) to allow higher resolution and higher performance through the use of graphics coprocessors are becoming available. One also can use PC's and the Microsoft Windows environment along with any of the new compilers that are capable of generating k~aphics for Windows. Another possibility, in to write programs for the Apple Macintosh computer. The Macintosh was des i p e d From the b e ~ m i n gto work graphically, so it docs not have the problem of numerous graphics adapters. There are some exccllcnt proerams available fbr the Macintosh, such a s the F V O G N M RSpectrum Simulator (5).

1

;

1""1 rn

Proprietary Operating Systems Generally useful graphical programs also can be written for larger computers with graphics termiManager nals, or for the increasingly popular workstations. Proprietary operating systems have been the norm with large computers, and this has made it difficult to transfer programs between them. The UNM operating system has provided a common basis for programming on a wide variety of systems, but unKeyboard XSew fortunately, it does not provide a common method for graphics. There have been several graphics standard defmitious to allow these computers to be programmed in a standard way. The first of these was the SIGGRAPH Core standard (6)of 1977 and 1979.Although Core was never a complete graphics Local Area Network standard, there were many packages built that were "Core like", and many of the ideas from Core survived and were incorporated into the current standards. The Graphic Kernel System (71,GKS, (Remote) was the first complete graphics standard of this tvoe that included bindings to several cornouter la&uages. It was adopted by the ~nternat'ional Standards O~anizationin 1984 and i~ a standard that could be-used for our educational graphics. GKS is available on a large number of computer Figure 2. The clienffserver relationship in the X Window System. The server and systems, and it includes device drivers to support Clients 1 and 2 are running on alocal workstation. Client 3 is on a remotecomputer. many graphics terminal types. It has the disadvantage of not being in the standard set of software supplied on most large computers, and it is generally exclient has registered for input, and whether the input is pensive. Another similar graphics standard that is readily relative to a window that the client owns. available on larger computers is the Programmers HierarVersion 10 of the X Window System was released in chical Interactive Graphics Standard (8)(PHIGS). It is 1986. It was then largely rewritten in response to more modem than GKS, but it is also expensive. ments, and later released as version 11 which was intended to be stable for several years. Virtually all workstaX Window System tion manufacturers (including SUN, DEC, HPIApollo, IBM, and Data General) have adopted X as their windowThe last alternative to be discussed is the X Window Sysing standard, so the capability of displaying the output (9),also known as X, has become available on a very from an X client exists on nearly all current workstations. large of computers and thus provides an alternaIn addition, there are numerous manufacturers of X Wintive to microcomputers for graphical programs to be used dow terminals that can be used as display servers, and on which Xis used chemical education, The also much greater than most microcom. there are X Window terminal emulation programs available for IBM PC compatibles, and for the Macintosh. The put-. X was developed at the Massachusetts Institute of compatible should be based on an 80286 or Technology by Project Athena beginning in 1984 (10).This preferably a 386 or 486, and the Macintosh should have a is a project that is intended to link as many as 10,000 68020,30 or 40 processor. At least 2 megabytes of memory workstations of various types on the MIT campus. There would be desirable. Thus, there is a wide range of possibilare over 1000 workstations in the current network. Beities for devices that can display the results of graphical cause these workstations are from different manufaeturprograms, provided the programs are written to be X Winers and run different operating systems, a common protodow clients. col was develooed for graohical communicatiou amonn them. Hardware and Software Required This protocol can be used as the basis for writing proNow for the hardware and software required for the cligrams that run and display graphics on a workstation. It ent programs. These programs can be run on workstations, also can be used by programs that need to display graphminicomputers, mainframes or supercomputers, using any ics, but that are runnine on comouters (such as mini-comoperating system. The X Window System library routines, puters, mainframes or supercomputers) that do not themknown as Xlib, and a reliable byte stream connectionto the selves have rrauhics dlsolav ca~ab~lities. The underlvmn server computer (which may be the same workstation that model is one of progra&, -known as clients, that are i;; the clients are on) are required. If the client and server are need of display services. These services are provided by on separate computers, the connection is normally other programs, known as servers, which run on devices Ethernet, although some terminals from GraphOn and with display capability. The nature of the clientlserver reNCD may use a 9600 baud serial connection. The Xlib roulationship is shown in Figure 2. Here, the X server is ruutines are available a t no cost from MIT. Currently, there ning on a workstation that has one display screen for outare language bindings for Xlib in C and Ada with addiput, and a mouse and keyboard for input. There are two tional language bindings expected. Because the routines of programs (Client 1and Client 2) running on this workstaXlib provide only low level graphics, various tool kits have tion. and in need of disolav services. In additiou. there is been made available that provide higher level objects like another program (ClieLt 37 running on another computer scrolling lists and push buttons. connected to the d i s ~ l a vworkstation bv a Local Area Network. Each client h a s its own windbw on the display As an example of using X to write an interactive graphics program useful in chemical education, the van der Wads screen. The server distributes input from the keyboard and curve generating program (2) has been rewritten using the mouse to the appropriate client, depending on whether the

1

\I/L

LMDuSe

/

+

- .

-

Volume 69 Number 11 November 1992

889

Approximately what is the critical temperature, or the Boyle temperature of a particular gas according to the van der Wads equation? How would a gas behave if it had finite molecular volume, but no attractive forces between molecules. or vice versa? Which bemmes more important at high temperatures in the van der Waals model, the molecular volume, or the attractive forces?

-

Because a single run of the . Droeram can involve as manv gases, temperakres, and values of the constants as dcsired, these questions and others can be investigated thoroughly with a minimum of effort. The standard objects (scrolling lists, push buttons, and radio boxes) can be used in other programs to give a consistent interface as has been done so effectively with Macintosh programs.

Figure 3. The output of the sample X program consists of van der Waals and Ideal Gas curves displayed in a window.

The Two-Part VDW Program First, the part that describes the objects to be displayed for the user interface is written in User Interface Language. This was coded directly, although a graphical editing tool like Digital Equipment's W I T (Visual User Interface Tool) could be used to make this easier. With VUIT, the push buttons, scrolling lists, etc. of the user interface are selected from menus, and then moved into position. W I T automatically builds the UIL file that corres~ondsto the selected

is written in t h e C language. I t contains code to: instantiate the user interface objects, calculate the curves to be displayed, call Xlib functions to build and display the graphs, and respond to user inputs. a U*l*atm/mole*mol~l b (Ilter/molel The X Window System is avail0.0305 able a s standard equipment on nearly all workstations. X clients can run on any of these, or on most large computers provided there is access to the subroutine library, Xlib. The graphical results can be displayed on workFigure 4. The input to the sample X program is by mouse selection in the control window stations, X terminals, or microcomputers running X terminal Digital Equipment Corporation DEC windows toolkit and emulation programs. Thus, X is largely independent of DEC User Interface Language (UIL). The van der Waals both hardware and operating system. From the point of program uses two windows, one for input and one for outview of chemical educatori, there are some disadvintages put, as shownin Figures 3 and 4. Figure 3 shows the graph in usinax. Xlib IS cum?ntly available only in C and Ada. In of the van der Waals curve (solid line) addition. X is n rather comolcx svstenl. Nonetheless. the advantages of X are so great t h a t i t should be c&sideikd P = R T l ( V - b ) - a /v2 for any chemical instructional systems that make heavy and the corresponding Ideal Gas m e (dashed line) use of interactive graphics. Step size for a

step

rim forb

Step size for T

P=RTN

for the same temperature. Figure 4 is the control panel used by the student to select parameters to compute the curves. Initially, the curves correspond to water a t 550 K., using van der Waals constants selected from a list for various gases that are stored in the program. A different gas may he chosen from the scrolling list on the right side of the control panel. The a and h constants, and the temperature may be changed by clicking the mouse on the appropriate upldown push button. Each time a change is made, the curves are automatically updated, as are the displayed values of the constants. Each update requires a small fraction of a second on a DECstation 3100. Changes in step size may be made by using the set of radio buttons next to each upldown arrow. Anumber of questions can be posed for students to answer using this program.

890

Journal of Chemical Education

7. ANSI (Amdean National Standarb Jnstitutel, h e t i e a n National Standard fm Information Roceasing Systems--ComputerGraphics-Graphical Kernel System (GKSI Functional Dertiption. ANSI X3.1241985.ANSLNew York. 1985.

9. Schelfier R W;Cettys, J.: Newman, R. X Wndou System, E&al Ress: Bedford, MA, 1988.

lo. Champine, G. A ; Gear, D. E. Jr.: Rah, W N. Computer 1990,23(91,m1.