This program is written in 'Fortran ASA' language and has ... LSD: a Fortran software for mini-computers to control a four-circle neutron diffractometer for single.
COMPUTER PROGRAMS (6) Restriction conditions on the Miller indices (if desired) expressed in terms of relationships between the h, k, l values. If the unit cell is specified as primitive and no exclusion conditions are imposed upon the hkl's, the program will generate all theoretically possible combinations of Miller indices and also calculate the 0 and 20 values for each Bragg reflection. The results are printed out in order of increasing 20 angles. The appropriate title and other information are printed out at the top ofeach page. However, if the type of unit cell is specified as A, B, C, I or F centred or rhombohedral, the program excludes the non-compatible Bragg reflections from the list. Moreover, within each independent run the user may select up to seven different, above-mentioned, configurations to be output separately. The program can also take into account any systematic absences present in any type of the specified unit cell. That is, TYPE
U V W Z Y,
where TYPE is one of the form hOl, Okl, hO0, OkO, 001, hkO. The values U, V, W, Z and Y should be chosen so as to have the desired selection rule according to the following formula: Uh + Vk + W I = Z n -
Y.
101
n is an integer which is incremented by the program. For example, the user can ask for the print-out of all theoretically possible reflections of a face-centred unit cell with the following selection conditions: for for for
Okl k + l = 4 n ; hOl h + l =4n ; hkO h + k =4n ;
or a primitive unit cell with the following selection conditions: for for
Okl hOl
k = 2n; h + l= 2n ;
and so on. Within each specified unit cell, the user may apply up to five such relationships between Miller indices. This program is written in 'Fortran ASA' language and has been tested with both the ICL 1900 and the C D C 6600/7600 computers. It should also be compatible with IBM computers although it has not been fully tested with them as yet.
Reference AZ~,ROI:F, L. V. (1968). Elements o f X-ray Crystallography. New York: McGraw-Hill.
J. Appl. Cryst. (1980). 13, 101-104
LSD: a Fortran software for mini-computers to control a four-circle neutron diffractometer for single
crystals.
By A. BARTHfELEMYand A. FILHOL,* ]nstitut Laue Langevin, 156 X, 38042 Grenoble C E D E X , France (Received 2 March 1979; accepted 25 July 1979)
Abstract The paper describes a program system, written in Fortran, designed to control an automatic four-circle diffractometer for neutrons, either with or without an analyser. A simplified version can be used to control a powder diffractometer. This system, initially developed on the Tel6m6canique T2000 computer for three diffractometers at the Institut LaueLangevin at Grenoble, has been rewritten for the Digital Equipment Corporation (DEC) PDPI1 computer in such a way as to make the best possible use of the supervisor and the facilities available on this system.
1. Introduction Several years of practice in neutron scattering at the Institut Laue-Langevin (ILL) at Grenoble - a service institute where the experimentalists are visiting physicists, biologists or chemists from laboratories all over the world .......have shown that automatic four-circle neutron diffractometers for single crystals are subjected to frequent modifications at all levels. Under these conditions, the control software of the instrument, whatever efforts the writers have made, is never complete and it therefore becomes vital that modifications should be easily possible, even by a non-computing specialist. In addition, the recent price reduction of mini-computers, particularly of the central memory, and the increase in the capacity of magnetic disks (cartridges) have resulted in the * Also: Laboratoire de Cristallographie, A144, Universit6 de Bordeaux I, 33405 Talence, France. 0021-8898/80/010101-04501.00
greatest priority being no longer as before to economise on the hardware at the cost of great programming effort (particularly use of assembler language). The use of a sophisticated programming language is therefore necessary. It should also be added that the existence of 'multi-user' monitors supplied by certain manufacturers even for the smallest configurations, makes it possible to design a particularly flexible software organisation for the control of the diffractometer and to attach to it other programs designed to facilitate the task of the experimenter. The LSD ('Large Software for Diffractometer') program system presented here is written in Fortran except for the handler and the library of subroutines controlling the electronics. LSD was initially developed on the T616m6canique T2000 computer (ILL 'CARINE' computer system) and was used successfully for several years to control the neutron diffractometers D8, D9 and D10. The DEC P D P / I 1 version of LSD which we describe here has been used in self-service operation for two years on the instrument D8 and is now available on D9 and D10. The program and the results occupy respectively 20 and 1 K words of the central memory. The disk space reserved is 116 K words. We will not discuss here the problem of the addition, alongside LSD, of a group of programs for the determination and refinement of crystallographic structures (see for example Sparks, 1975).
II. Hardware The normal equipment of a four-circle diffractometer at the ILL is as follows. © 1980 International Union of Crystallography
102
COMPUTER PROGRAMS
The control electronics consists of'CAMAC' modules. The computer hardware incorporates: a DEC P D P l l / 3 4 (or P D P l l / 4 0 ) processor with real time clock and bootstrap memory management unit; a central memory of 64 K words with an access time of 750 ns; a controller and a disk unit (a fixed and a cartridge disk of 1.25 M word each); and four serial interfaces DL11 pcrmitting the connection of three terminals, viz a DEC LA36 teleprinter (300 bauds), a LSI20 teleprinter (300 bauds input, 1200 bauds output), and a Tektronix T4010 display unit. The last D L l l connects the P D P l l with the central computer (a DEC-system 10) of ILL.
III. Operating system The operating system is the multi-user, multi-task assembly ' R S X l l M ' developed by DEC which greatly aids programming. Several programs can thus run simultaneously with a hierarchy of priorities defined by the user; they use the memory and processor in time sharing. The programs are swapped onto disks if this is necessitated by the level of the occupation of the memory. In the present case, RSX 11 M occupies a system partition of 11 K words and is generated in such a way that the user cannot destroy the files necessary to the supervisor system, i.e. access to certain parts of the disk requires the knowledge of 'passwords'. LSD uses the various possibilities offered by RSX 11 M to define the disk files (sequential files, direct access files) for the transfer of parameters between tasks and for the synchronisation between tasks by the real time processing of the results by 'event flags'.
IV. Organisation of LSD LSD consists of a main program, which calls up the subroutines associated with a 'first level' command. These subroutines are organized in overlay at five levels and some of them are able to carry out a choice of elementary functions, each associated with a 'second level' command. All the crystallographic parameters and all the command event-flags of the various functions of LSD are stored on disk. To carry out a certain number of functions, LSD has access to disk files which the user can create and edit at will. In particular, a file makes it possible to store a first and second level command chain, which may be executed sequentially as often as necessary by means of an LSD command. The automatic restart of an interrupted measuring sequence is effected by a single command. The results of the measurements are stored on disk. These data, either raw or reduced, are transferred, either later or in real time, to a central scientific computer with the aid of programs independent of LSD. 1. Subroutines There are, at present, 50 LSD subroutines which either are responsible for a series of'second level' commmands, making it possible to effect a choice of elementary functions, or are associated with complex procedures directly initiated by a 'first level' command, or are simple 'utilities'. These include, in particular: (a) A subroutine for decoding all first and second level commands, according to a fixed plan for an 80 character line: three alphabetic characters indicating the command, one control character specifying the option selected, possibly a list of numerical parameters, in free format, ended with a carriage return ( C R ) . For example:
LAT ( C R )
reads the value of the lattice parameters, a, b, c, ~,/3, y, kept on disk;
LAT: 6.356 10-4 9.61 90 109.5 90 ( C R ) writes new values on disk. The list of parameters may be abbreviated or contain "joker" characters, as shown below, to avoid repeating parameters already stored on disk. LAT: = = 9-71 ( C R ) corrects the value of lattice parameter c on disk without changing those of a, b, a,/3, 7. This method of reading commands limits considerably the risks of error. (b) A subroutine for all the error messages. These are given, as desired, in German, English or French. (c) A subroutine for all scans. (d) A subroutine for checking the coherence of the parameters associated with measurement sequences. It should also be stated that the functions using the command library of the electronics are arranged in such a way that a change of system would cause few changes.
2. Control parameters In the present version of LSD there are approximately 300 parameters for a four-circle diffractometer with analyser and motorised rotations co and 20 of the monochromator. The disk space reserved for LSD permits this number to be increased to 450. These parameters include: (a) static parameters: these are the crystallographic data, the parameters defining the measurement strategy, the parameters defining the characteristics of the instrument; (b) the dynamic parameters: these are the parameters describing the state of LSD at any time. If the program is intentionally or accidentally interrupted, these permit the restart of the current procedure by means of a single command. All these parameters are present both on disk and in a common area in the core memory. This duplication makes it possible to reduce the number of disk accesses, which is the bottle-neck of the system. The tests are carried out on the parameters in the memory, but the parameters necessary for the automatic restart of the long sequences are rewritten on the disk when they are modified. The last values of the other dynamic parameters would thus be lost ifLSD had to be interrupted by the user as a result of a command error. To avoid this, a special sequence has been introduced which allows the user to interrupt the measurement sequences without interrupting LSD, which returns to the command input state. To increase further the operating reliability, the files of parameters are defined as being directaccess files with fixed length recording. As a result, the contents of these files cannot be modified by the utility programs supplied by the manufacturer, but only by means of special LSD commands. 3. Data and command files These files (eight at present), are primarily used for storing lists of reflexions to be measured (Miller indices and possibly corresponding Eulerian angles or other parameters), lists of parameters defining a new area of reciprocal space to be measured as soon as the data collection in progress is finished. or a list of first and second level commands to be sequentially executed by LSD.
COMPUTER PROGRAMS Two of these files are only accessible by LSD commands, so that users who are less familiar with the text editors can limit themselves for their measurements to the LSD commands. The six other files can be created and modified independently of LSD; they are then either accessible for all LSD measuring sequences, or associated with a specific LSD command.
4. Storage and transfer of results Datafiles: For safety reasons the measurement data files are of direct-access, fixed-length-recording type. As the length of each spectrum may be different, two files are necessary to record one spectrum. A first one mainly describes the content of a second one which stores the data. A real-time automatic a posteriori compacting procedure exists, but is scarcely used in view of the limited number of data produced in 24 h ( < 500 spectra a day for D8, which has the highest neutron flux at the ILL). Transfer. The transfer of raw or reduced data to the main computer has been done, up to now, using a direct line from the P D P l l to the main computer, the disk cartridges themselves, or magtapes. Storage. The measurement data are stored up to the limit of the disk cartridge. A set of about ten disks is enough for storage of several weeks' results. This procedure is safe and avoids losses of measurement time as data reduction, plot profiles, transfer of data etc. are carried out in real time or independently of LSD by programs of lesser priority.
5. Principal LSD options The positioning of a point on the reciprocal network on the Ewald sphere can be effected with any azimuth rotation angle ~, (except for mechanical limitations). Non-integer Miller indices are accepted at all levels of LSD. The calculations are carried out according to Busing & Levy (1967) conventions. The scans are always carried out point by point. The preselection may be either in constant time, or in constant monitor or detector counts. The scan range is either fixed or a function of angle 0. The preselection value and the steps of the first and last n scan points may be different from those of the other points, in order to improve the background counting statistics. LSD offers a wide choice of scans: (a) scan of all encoded movement (Euler angles and possibly rotation and translation of monochromator and analyser); (b) scan of the azimuth rotation angle ff (Renninger scan) with, for each step in if, either the acquisition of a single point or an w scan; (c) scan along any scattering vector q of reciprocal space. Scan results are printed on the console in more or less detail as selected by the experimenter, and a simplified data reduction is done (integration, Lorentz correction, calculation of the width at half-height of the peak, etc.). The true data reduction of the raw data is generally carried out by a program independent of LSD (cf § VI). The systematic exploration of the reciprocal space and the automatic reduction of the lattice are currently used procedures on X-ray diffractometers for single crystals. In neutron diffraction, on the other hand, they are rarely useful (preorientated or well-known samples) or useable (counting time too long). LSD at present has only a simplified scan procedure of a portion of reciprocal space and does not yet have a lattice-reduction sequence. The automatic centring procedure for Bragg reflexions used by LSD was designed to accept weak intensities and wide or somewhat deformed profile lines. It either uses successive
103
scans of the angles w, 20 and Z, or combines the use of scans and of four beam splitters (right, left, up, down) placed in front of the detector. The orientation matrix UB of the crystal can be calculated, whatever the measurement geometry, either by a single linear least-squares method included in LSD, or independently of LSD with the aid of the R A F I N program (§ VI) which makes it possible to refine the wavelength, the lattice parameters and the offsets of angles 20, w and Z. The intensity collection procedure gives a wide choice of options, in particular the possibility of effecting a fast preliminary scan of three or four points permitting the rejection of the weakest reflexions. The list of reflexions to be measured can be either generated by LSD or read from a disk file. The equivalent-reflexion measurement can be automatically selected ifa blind zone of the instrument is encountered. The possibility of measuring reflexions in such a way that the standard intensity variation divided by the intensity is constant has not been requested by the users of the diffractometers D8, D9 and D10, but could easily be introduced. The current use of cryogenic devices, furnaces, pressure cells etc., mounted inside or in the place of the Eulerian cradle of the diffractometer, has necessitated the introduction of sequences to allow for the associated additional constraints. As examples may be cited the possibility of reading a digital voltmeter, the choice between several methods of displacement of the movement ~0towards the desired value, permitting an optimization of displacement times, the taking into consideration of a possible mechanical backlash, and the avoidance of the rolling of cables or tubes around the sample holder. In the case of D10 which has an analyser, this instrument may also be used in a two-axis geometry, i.e. the Eulerian cradle is replaced by a simple rotating table and the movements are then Wcry,,,~= 0)4......~ + qO, 204-c,rc)~, Og~n~,b.~,r, 20...~>,er. V. Use of LSD It is, of course, possible to use the whole system of programs on the basis of a single console, but to make the best use ofthe possibilities of the multi-user R S X I l M monitor, we have opted for a configuration of three interchangeable terminals. The usc which can be made of these terminals is not fixed and varies, in particular, as a function of the user, and of the measurements to be made. For example, when the collection of intensities is in progress, the distribution of tasks is often as follows: (a) Alpha-numerical terminal no. 1; dialogue with LSD priority program. (b) Alpha-numerical terminal no. 2; automatic data reduction (program COLL5N) in real time, with print-out of profile and all the characteristics of each reflexion. (c) Graph display : it is used either for display of the scan in progress (i.e. not yet treated by COLL5N), or to create or edit data files intended for subsequent measurements, or for the analysis or measurements already carried out (see attached programs), or for any programming or calculation without direct connection with the measurements in progress. (d) Finally, the programs for compacting and for automatic transfer of data, once they have been started from one of the terminals, leave it free for other uses. In the same way, one of the alpha-numerical terminals acts as system console, while still being used for one of the tasks mentioned above.
VI. Associated programs and procedures The calculating capacity and the speed of the mini-computer
104
COMPUTER PROGRAMS
terminals on the experiment is such that it is tempting to install on it an increasing number of programs. Owing to lack of time and because of the limited disk space available in the present configuration, we have not yet undertaken the implementation of the programs necessary for determining and refining crystallographic structures. Concerning the experiment itself, several independent programs or procedures have been implemented. In fact, LSD operates sequentially and sophisticated calculations will slow down measurements while separate low priority programs, running in parallel with LSD, will not. Five such programs are mentioned here. H K L G E N : generates lists of Miller indices and Eulerian angles within sets of limits and allows for a certain optimization of the displacement of the diffractometer movements. R A F I N : [a modified version ofCODR UB program (Ellis & Pryor, 1968)] refinement program by a least-squares method of the crystal orientation matrix and of the wavelength, offset of the angles 20, co and X and the crystal lattice parameter. CENAUT: procedure permitting the automatic linking of automatic centring series of reflexions, alternating with the increase in the precise calculation of the UB matrix with the aid of the program R A F I N . COLL5N: data reduction program using the a(l)/1 criterion [I being the intensity of a point of the scan and o'(I) its standard deviation] proposed by Lehmann & Larsen (1974). It traces the profile of all or some peaks on the console and prints out the results of the integration and all the parameters associated with the measurement. The reduced data are then stored on disk. COLL5I: interactive version on Tektronix screen of the program COLL5N. The user then has the choice of the limits of integration and position of the background; this proves particularly appropriate for the treatment of data relating to a 'difficult' sample. VII. Documentation This consists essentially of two ILL internal reports (Barth~lemy, Rice & Turfat, 1978; Barth61emy & Filhol, 1978) written in French. An English edition is available.
diffractometer (I000 to 2000 reflexions/d compared with less that 500 reflexions/d with neutrons) could necessitate the rewriting of some too "neutron oriented' sequences and make essential the systematic use of the automatic data compacting procedure on disk. IX. LSD for powder diffractometer A simplified version of LSD has been developed for the control of a powder diffractometer and has recently been implemented on the ILL instrument DIA. This instrument has motorised and encoded movements co and 20 and has a detector consisting of ten counters side by side. The computer is a PDP11/03 with 28 K words of central memory, and equipped with a disk unit including a fixed and a cartridge disk, both of 2.5 M words. The operating system is the DEC model R T l l . This permits the simultaneous implementation of only two programs (foreground/ background) and the simplified version of LSD takes account of this limitation. In particular, it permits the acquisition of powder diagrams and their display on a Tektronix T4010 graph display console and, in the case of single-crystal samples, the calculation of the diffraction angles and the execution of appropriate scans. X. Development of L SD LSD started in 1976 and since that date several versions have been provided for self-sevice operation on the instruments DS, D9 and D10 at the ILL. The construction of new versions is in progress. The cost in manpower to date has been as follows: one full-time system engineer, six months system programmer (electronic control and CAMAC handler subroutines), twelve months programmer's time. The physicists responsible and co-responsible for the diffractometers D8, D9 and D10 have repeatedly helped in defining needs, proposing algorithms, testing and criticizing the successive versions of LSD. The authors wish to thank J. Allibon, D. Grosset, M. S. Lehmann, S. A. Mason, P. Rice, O. Tillier, M. Thomas, C. Turfat and C. Zeyen for their contribution to the design of LSD.
VIII. Adaptation of LSD to another type of computer and/or to another type of diffractometer
References
LSD can be adapted for a different type of computer and electronics interface, provided that the computer has a Fortran compiler and a disk for storage of programs, branches of overlay and data. This would necessitate rewriting the handler and the modules controlling the electronics and replacing the PDP11 functions used for direct access to disk files by those of the manufacturer. It should also be mentioned that it may be useful to change the structure of the result files to allow for constraints inherent in the type of scientific computer available. The adaptation of LSD to the case of an X-ray
BARTHI~LEMY,A. & FILHOL, A. (1978). 78BA51T Tech. Rep., Institut Laue-Langevin, Grenoble, France. BARTHI~LEMY, A., RICE, P. & TURFAT, C. (1978). 78BA72T Tech. Rep., Institut Laue-Langevin, Grenoble, France. BUSING, W. R. & LEVY, H. (1967). Acta Co'st. 22, 457. ELLlS, P. J. & PRYOR, A. W. (1968). Aus. A. E. C. A A E C /ERep. 191. LEHMANN, M. S. & LARSEN, F. K. (1974). Acta Co'st. A30, 580-584. SPARKS, A. (1975). In Crystallographic Computing Techniques, edited by F. R. AHMED. Copenhagen: Munksgaard.