Title: LEAST SQUARES UNIT CELL REFINEMENT with INDEXING on the
PERSONAL COMPUTER LSUCRIPC
KeyWords: Powder Diffraction, Unit Cell Refinement
Computer: PC, XY, AT
Operating System: MS(PC)-DOS
Programming Language: TURBO Pascal
Hardware: 192K memory, 1 diskette drive, math coproc.(recommended)
Author: Roy Garvey
Correspondence Address: Department of Chemistry
North Dakota State University
Fargo, ND 58105-5516
Abstract:
L S U C R I P C
A computer program implementing the procedure of
Appleman and Evans (1973) is now available for the
IBM-PC. Output of refinement data has been condensed
for economy of presentation. For a discussion of
methodology, see the USGS-GD-73-003 report number 20 by
Appleman and Evans (1973).
---------------------------------------------------------------------------
Title: LEAST SQUARES UNIT CELL REFINEMENT with INDEXING on the
PERSONAL COMPUTER LSUCRIPC
KeyWords: Powder Diffraction, Unit Cell Refinement
Computer: PC, XY, AT
Operating System: MS(PC)-DOS
Programming Language: TURBO Pascal
Hardware: 192K memory, 1 diskette drive, math coproc.(recommended)
Author: Roy Garvey
Correspondence Address: Department of Chemistry
North Dakota State University
Fargo, ND 58105-5516
Documentation:
---------------------------------------------------------------------------
INSTRUCTIONS for using LSUCRIPC
D A T A I N P U T Definitions and Specifications
Parameters are input with spaces separating numeric fields as
follows:
FIRST LINE
Title describing the data being processed.
SECOND LINE
Unit Cell Parameters as A B C Alpha Beta Gamma
Control Parameters Itht = 0 for defraction data in 2-theta
= 1 for defraction data in 1-theta
thtmx Maximum diffraction angle (in Itht
units) to be considered in indexing.
Set at 20 if 0 is coded.
Ncyc Number cycles during which non-indexed
diffraction with angles exceeding ThtMx
are not accepted in least squares.
A zero value is reset to 2 by program.
TolMn Minimum tolerance allowed (in units of
Itht). If 0 entered, value reset to
0.02o by program.
TolMx Maximum tolerance allowed (in units of
Itht). If no greater than TolMn, reset
to five times TolMn. If given as 0, a
value of 0.1o set by program.
THIRD LINE Code for Crystallographic System
CUBIC for cubic crystal systems.
TETRA for tetragonal systems.
ORTHO for orthorhombic systems.
MONOC for monoclinic systems.
RHOMB for rhombohedral or trigonal systems.
TRICL for triclinic systems.
HEXAG for hexagonal systems.
HEXAR for hexagonal-rhombohedral systems.
TheMx Value comensurate with Itht to be used in determining the
minimum interplanar spacing for generated diffraction.
This value may be superceded by given diffraction having
greater Bragg angles. If 0 and there are no observed
diffraction given, TheMx is set to 90o theta.
Pwl Primary wave length used in computing minimum distance for
generater diffraction. If given as 0, value of 1.5405 A
is assumed.
The next 27 entries indicate conditions for non-extinction for
certain diffraction classes. To be effective, the integer n entered
must be 2,3 4 or 6 in the appropriate location; x, y, and z are any
integers. If the crystal type is HEXAR, entry 6 will be considered
to be 3 whether it is entered or not by the user. Each of the
following 27 items must be repre sented by a numeric value as
described above or by 0 as a place holder. Each entry must be
separated form those preceding and following by at least one space.
Class of Condition for
Entry Diffraction non-extinction
1 hkl h + k = x.n
2 hkl h + l = x.n
3 hkl k + l = x.n
4 hkl h+k = x.n, h+l = x.n, k+l = x.n
5 hkl h + k + l = x.n
6 hkl -h + k + l = x.n
7 hhl h = x.n
8 hhl l = x.n
9 hhl h + l = x.n
10 hhl 2h + l = x.n
11 0kl k = x.n
12 0kl l = x.n
13 0kl k + l = x.n
14 h0l h = x.n
15 h0l l = x.n
16 h0l h + l = x.n
17 hk0 h = x.n
18 hk0 k = x.n
19 hk0 h + k = x.n
20 hh0 h = x.n
21 h00 h = x.n
22 0k0 k = x.n
23 00l l = x.n
24 hll h = x.n
25 hll l = x.n
26 hll h + l = x.n
27 hll h + 2l = x.n
SEmult Multiple of the standard error of an observation of
unit weight to be used in setting tolerances.
FOURTH LINES
Diffraction data. For diffraction that are to be indexed by
the program by comparing corresponding distances and angles with
those of theoretical diffraction, h, k, and l must be given as zero.
If one or more of the diffraction indices is non-zero, the
indices read from the diffraction entry will be maintained
throughout the run. Diffraction entries must be arranged in order
of increasing Bragg angle (or decreasing d-spacing). If no observed
diffraction data are given, the output will consist of theoretical
lines only. As before, numeric entries are separated by spaces. 0
is entered as a place holder where no data is input. Each diffraction
is represented by the following entries:
h k l D Wlc Obs Wt
where h, k, l are the corresponding Miller indices. D is the
interplanar spacing as computed from the Bragg relationship. D need not
be given if OBS is given. Wlc is the wavelength (in A) associated
with the current diffraction. If given as 0, it is assumed to be the
same as the wavelength for the previous diffraction line. (If a
wavelength for the first diffraction line of a data set is not given,
the value given or implied by Pwl is used). Obs is the Bragg angle
concomitant with Itht and given as degrees and fraction thereof. The
angle need not be given if D is given. If both theta and D are given,
D will be recomputed as the observed d- spacing from theta and the
given or implied wavelength. WT is the weight to be associated with the
value of theta for the current diffraction. If WT is given as 0, it is
set to 1.0 by the program. All entries are set to 0 for the last data
line.
A sample data set is included illustrating the use of 0 as a
place holder.
Cell Refinement of A - ZrPO4 SNOWMASS WORKSHOP test data file.
9.06 5.295 15.414 90 101.75 90 0 0 0 0 0
MONOC 73 0.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
0 0 2 0.0 1.5405981 11.7087 0.0
-1 1 1 0 0 19.8162 0
2 0 0 0 0 20.0178 0
0 1 2 0 0 20.4939 0
2 0 1 0 0 22.072 0
-1 1 3 0 0 24.9746 0
2 0 2 0 0 25.2411 0
-2 1 2 0 0 27.0218 0
1 1 3 0 0 27.7465 0
0 1 4 0 0 29.0032 0
-3 0 1 0 0 29.5801 0
-1 1 5 0 0 33.8194 0
0 2 0 0 0 33.8903 0
-3 1 1 0 0 34.1718 0
-3 1 2 0 0 34.655 0
0 2 2 0 0 35.9646 0
-3 1 3 0 0 36.1483 0
3 1 1 0 0 36.301 0
-2 0 6 0 0 37.2433 0
1 1 5 0 0 37.3402 0
0 2 3 0 0 38.4033 0
-3 1 4 0 0 38.572 0
3 1 2 0 0 38.7756 0
-2 2 2 0 0 40.2341 0
4 0 0 0 0 40.6483 0
-2 1 6 0 0 41.0746 0
0 2 4 0 0 41.6506 0
3 1 3 0 0 42.0089 0
2 2 2 0 0 42.6968 0
-4 0 4 0 0 42.8435 0
-4 1 1 0 0 43.5333 0
-1 1 7 0 0 44.4877 0
4 0 2 0 0 44.8181 0
-2 0 8 0 0 48.2941 0
1 1 7 0 0 48.4369 0
-1 3 1 0 0 53.0391 0
-4 2 2 0 0 53.3706 0
-5 1 3 0 0 54.0075 0
-1 2 7 0 0 54.1143 0
-1 3 3 0 0 55.4481 0
-4 2 4 0 0 55.7147 0
1 2 7 0 0 57.5746 0
-3 2 7 0 0 58.9394 0
2 1 8 0 0 59.4316 0
-2 2 8 0 0 60.2872 0
3 1 7 0 0 60.4909 0
-5 1 7 0 0 63.1216 0
1 2 9 0 0 68.7137 0
-4 1 10 0 0 70.0417 0
0 4 0 0 0 71.2907 0
-6 2 2 0 0 71.9717 0
0 0 0 0 0 0.0 0
Specific parameters are identified in the following lines of input
data. Note that spaces are used as "field Delimiters".
TITLE LINE
Cell Refinement of A - ZrPO4 SNOWMASS WORKSHOP test data file.
UNIT CELL PARAMETERS Tolerance
A B C aLpha beta gamma Itht thtmx ncyc mn mx
9.06 5.295 15.414 90 101.75 90 0 0 0 0 0
T
h
e Conditions for non-extinction for certain classes
m 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2
Sysext x Pwl 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 Semult
MONOC 73 0.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0
DIFFRACTION DATA
h k l D Wlc Angle Weight
0 0 2 0.0 1.5405981 11.7087 0.0
-1 1 1 0 0 19.8162 0
* * * * * * *
TERMINATOR of H K L DATA INPUT
0 0 0 0 0 0 0
ERROR MESSAGES
Run Time Error Messages that are Fatal with Program Aborted:
01 Floating point overflow.
02 Division by zero attempted.
03 SQRT argument error.
04 LN argument error.
10 String length error.
11 Invalid string index.
90 Index out of range.
91 Scalar or subrange out of range.
92 Out of integer range.
F0 Overlay file not found.
FF Heap / stack collision.
I / O Error Messages when I/O checking is active:
01 File does not exist.
02 File not opened for input.
03 File not opened for output.
04 File not opened.
10 Error in numeric format.
20 Operation not allowed on a logical devise.
21 Not allowed in direct mode.
22 Assign to STANDARD files not allowed.
90 Record length mismatch.
91 Seek beyond end-of-file.
99 Unexpected end-of-file.
F0 Disk write error.
F1 Directory is full.
F2 File sixe overflow.
F3 Too many open files.
FF File disappeared.
Special Version of LSUCRIPC includes the following new features:
Ability to pass < InFile.dat > and/or < OutFile.lst >
file names on the command line.
< InFile.dat > is the file of data and control codes
used in earlier versions of the program (and described
in the LSUCRIPC.doc file).
< OutFile.lst > is an optional text file to which all
printed information can be directed. No longer is it
necessary to wait for your printer to catch up to the
compution.
If the < OutFile.lst > is to be used, you must also
include the < InFile.dat > name on the command line as
the first entry. If no < OutFile.lst > name is given,
the program defaults to the system LST: (PRN: or LPT:)
device.
To read the data file TEST.dat from drive B: and
write the printed listing to a file TEST.out on a
RAM disk C: you would type
LSUCRIPC B:TEST.dat C:TEST.out
Printer initialization.
In the past we have been limiting users to those
printers using control codes compatible with either
those of OKIDATA Microline or those of the IBM-
EPSON series of printers. For this "Conference"
version we have included a third option. By providing
a PRINTER.$pr "Printer Profile" with the decimal
integer equivalent for the character codes of your
printer needed to initialize
COMPRESSED EXPANDED NORMAL
printing modes, the program will accomodate any
of a variety of additional printers. These codes
are written to the corresponding < OutFile.lst >
so these files may be printed as desired at a later
time and retain the text formating of the original.
The PRINTER.$pr must have three lines of FIVE
integer numbers (separated by spaces) in a format
as illustrated below.
27 48 15 0 0 Compressed Print Epson Codes
14 0 0 0 0 Expanded Print
18 0 0 0 0 Compressed off
-------------------------------------------------------------------------
End of File
Title: LEAST SQUARES UNIT CELL REFINEMENT with INDEXING on the
PERSONAL COMPUTER LSUCRIPC
KeyWords: Powder Diffraction, Unit Cell Refinement
Computer: PC, XY, AT
Operating System: MS(PC)-DOS
Programming Language: TURBO Pascal
Hardware: 192K memory, 1 diskette drive, math coproc.(recommended)
Author: Roy Garvey
Correspondence Address: Department of Chemistry
North Dakota State University
Fargo, ND 58105-5516
Source Code:
---------------------------------------------------------------------------
PROGRAM Least_Square_Unit_Cell_Refinement_and_Indexing;
{ Based upon algorithm of Appleman and Evans (1973), USGS-GD-73-003 }
{ "COMMON" Global variables and file definitions }
TYPE
AbcInt = ARRAY[1..3] of INTEGER;
AbcXyz = ARRAY[1..3] of REAL;
String14 = STRING[14];
DateStr = string[10];
TimeStr = STRING[5];
regpack = record
ax,bx,cx,dx,bp,si,ds,es,flags: integer;
END;
CONST
Version : STRING[14] = 'Fargo 87.08.01';
Ialf : ARRAY[1..11] of STRING[5] = ('CUBIC','TETRA','ORTHO','MONOC',
'RHOMB','TRICL','HEXAG','HEXAR',' 2- ',' ',' R ');
Iclass : ARRAY[1..10] of STRING[3] = ('hkl','hhl','0kl','h0l','hk0',
'hh0','h00','0k0','00l','hll');
Icond : ARRAY[1..10] of STRING[6] = (' h+k',' h+l',' k+l',' h+k+l',
'-h+k+l',' h',' k',' l',' 2h+l',' h+2l');
Jclass : ARRAY[1..27] of INTEGER = (1,1,1,1,1,1,2,2,2,2,3,3,3,4,4,4,5,
5,5,6,7,8,9,10,10,10,10);
Jcond : ARRAY[1..27] of INTEGER = (1,2,3,0,4,5,6,8,2,9,7,8,3,6,8,2,6,
7,1,6,6,7,8,6,8,2,10);
Ihkl : ARRAY[1..6,1..3] of INTEGER = (( 1,-1, 0),( 0, 1,-1),
( 1, 0,-1),( 1, 0, 0),( 0, 1, 0),( 0, 0, 1));
Jhkl : ARRAY[1..10,1..3] of INTEGER = (( 1, 1, 0),( 1, 0, 1),
( 0, 1, 1),( 1, 1, 1),(-1, 1, 1),( 1, 0, 0),( 0, 1, 0),
( 0, 0, 1),( 2, 0, 1),( 1, 0, 2));
Ifi : ARRAY[1..2,1..27] of INTEGER
= ((0,0,0,0,0,0,1,1,1,1,4,4,4,5,5,5,6,6,6,1,5,4,4,2,2,2,2),
(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,6,5,0,0,0,0));
Ifj : ARRAY[1..3,1..27] of INTEGER
= ((1,2,3,1,4,5,6,8,2,9,7,8,3,6,8,2,6,7,1,6,6,7,8,6,8,2,10),
(0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
(0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
Test : ARRAY[1..6,1..7] of INTEGER = ((8,3,1,1,3,1,8),
(0,7,2,2,10,2,9),(0,0,3,3,0,3,0),(0,0,0,6,0,4,0),
(0,0,0,0,0,5,0), (0,0,0,0,0,6,0));
HklC : ARRAY[1..6,1..10] of INTEGER = ((1,2,3,1,2,3,1,1,1,1),
(1,2,3,2,3,1,1,1,2,1),(0,0,0,0,0,0,1,2,2,2),
(0,0,0,0,0,0,2,2,3,2),(0,0,0,0,0,0,2,3,3,0),
(0,0,0,0,0,0,2,3,1,0));
VAR
Crystal, { Describes the Crystal System }
Ialf12, Ja : STRING[5];
FileName, FileOut : String14;
N, { Number of diffraction lines observed }
Ityp, Jtyp,
Itht, { Indicator of Theta angle type }
Nopt, { Number of Extinction Parameters }
Icycle, { Refinement Cycle Counter }
Imn,
Ncyc, { Number of cycles for refinement }
dx, cx, M, Irsd, MMn, Nr, Mm,
Prnt, { Defines printer Type for Initiation }
Err, { Global Error code }
ScreenX, ScreenY { Cursor position for Active Screen }
: INTEGER;
Vr, Vro, { Reciprocal Cell Volumes }
Vc, Vco, { Direct Cell Volumes }
Q, { 1 / d**2 }
Fac, Thcmp, D, Consx, Swt, Diff,
Dobs, { Observed d spacing value }
Pwl, { Pattern wavelength }
Thtse, { Standard Error for Theta }
Thobs, { Observed theta value }
RsdMax, Sum,
Dmin, { Minimum value of d for data }
Tolmn, { Tolerances for assigning given line }
Tol, { to correspond to a given theoretical }
Tolmx, { line calculated in refinement. }
Thtmx,
Themx,
Semult,
Vrd, Vcd : REAL;
Title : STRING[80];
HKL : ABCINT;
Ao, { Original Unit Cell Distances }
Ad, { Direct Cell edge Distances }
Angles, { Direct cell Angles in Degrees }
Alo, { Direct Cell Angles in minutes }
Als, { Saved Values of Direct Cell Angles }
Csa, { Cosine of Direct Cell Angles }
Sna, { Sines of Direct Cell Angles }
X, { Reciprocal Cell edge Distances }
Xo, { Saved Values of Reciprocal Cell Edges }
Ar, { Angles of the Reciprocal Cell }
U, { Cosines of Reciprocal Cell Angles }
W, { Sines of the Reciprocal Cell Angles }
Uo, { Saved values of Reciprocal Cell Cosines }
Dd : ABCXYZ;
LSUCR, LSTR : TEXT;
Printer : BOOLEAN;
Answr : CHAR;
Ifle, Iop, Jop : ARRAY[1..27] of INTEGER;
Ofle, A : ARRAY[1..27] of REAL;
B, Cr,
Sedce, { Standard Errors for Direct Cell }
Serce, { Standard Errors for Reciprocal Cell }
Z : ARRAY[1..6] of REAL;
Aa, E : ARRAY[1..7] of REAL;
TT, St, Vcme : ARRAY[1..6,1..6] of REAL;
Ss : ARRAY[1..21] of REAL;
Dcm : ARRAY[1..700] of REAL;
HKLh { Indices for generated lines }
: ARRAY[1..700,1..3] of INTEGER;
Obsth, { Observed Experimental theta values }
Sw, { Observed Statistical Weight for lines }
Wl, { Wavelength of radiation for line }
Dsp, { d Spacing for observed line }
Dlst : ARRAY[1..200] of REAL;
HKLg { Indices for Observed lines }
: ARRAY[1..200,1..3] of INTEGER;
IoCalcD : ARRAY[1..200] of INTEGER;
ChrWdt : ARRAY[1..3,1..3] of STRING[5];
{ $$$$$ ******* Utility Procedures and Functions ******* $$$$$$ }
PROCEDURE InitializePrinter;
VAR
PrnFile : TEXT;
PROCEDURE NoPRINTERfile;
BEGIN
SOUND( 525 ); DELAY( 750 ); NOSOUND;
WRITELN('Initialization File PRINTER.$pr not Found.');
ChrWdt[1,1] := Chr(29); ChrWdt[2,1] := Chr(15); {compress}
ChrWdt[1,2] := Chr(31); ChrWdt[2,2] := Chr(14); {Expanded}
WRITELN;
Write('Select Printer as : 1 = Okidata, 2 = Epson ');
READLN(Prnt);
CASE Prnt OF
1 : Writeln(LSTR,#24,#27,#56,#31);
2 : Writeln(LSTR,#24,#27,#48,#14); END
END; { No PRINTER Profile on Default Drive }
PROCEDURE PRINTERfile;
VAR
I, J, Num : INTEGER;
BEGIN
FOR I := 1 to 3 DO BEGIN { Compressed }
ChrWdt[3,i] := ''; { Expanded }
FOR J := 1 to 5 DO BEGIN { Normal }
READ(PrnFile, Num );
ChrWdt[3,i] := ChrWdt[3,i] + CHR( Num ); END;
READLN( PrnFile ); END;
CLOSE( PrnFile ); Prnt := 3;
END; { PRINTER file found on Default Diskette }
BEGIN { Initialize Printer }
ASSIGN( PrnFile,'PRINTER.$pr' ); {$I-} RESET( PrnFile ); {$I+}
Err := IOResult;
IF Err <> 0 THEN NoPRINTERfile ELSE PRINTERfile;
Writeln(LSTR, ChrWdt[prnt,2], 'Least Squares Unit Cell Refinement');
Write(LSTR, ChrWdt[prnt,1], ' ':4,'N D S U version ', Version);
Writeln(LSTR,' ':6,'after Appleman and Evans (1973).');
Writeln(LSTR,' ':5,'implementation by',' ':11,'Roy G Garvey');
Writeln(LSTR,' ':27,'Department of CHEMISTRY');
Writeln(LSTR,' ':23,'NORTH DAKOTA STATE UNIVERSITY');
Writeln(LSTR,' ':27,'Fargo 58105 - 5516');
Writeln(LSTR); WRITELN;
Write( 'Print Intermediate Reflection Tables ? Y / N ');
REPEAT
Read(Kbd,Answr); Answr := UpCase( Answr );
UNTIL Answr in ['Y','N'];
IF Answr = 'Y' THEN Printer:= True; WRITELN;
END; { Initialize Printer }
FUNCTION Date: DateStr;
VAR
recpack : regpack; { record for MsDos call }
month,day : string[2];
year : string[4];
BEGIN
with recpack do ax := $2a shl 8;
MsDos(recpack);
with recpack do BEGIN
str(cx,year); str(dx mod 256,day); str(dx shr 8,month); END;
IF Length(Month) = 1 THEN Month := ' ' + Month;
IF Length(Day) = 1 THEN Day := ' ' + Day;
date := Year + '/' + month + '/' + day;
END; { D a t e }
FUNCTION Time: TimeStr;
VAR
recpack : regpack;
Hours, Minutes: string[2];
BEGIN
with recpack do ax := $2c shl 8;
MsDos(recpack);
with recpack do BEGIN
str(cx MOD 256, Minutes); str(cx shr 8, Hours); END;
Time := Hours + ':' + Minutes;
END; { T i m e }
PROCEDURE NameOfSystem;
BEGIN
ClrScr; GotoXY(20,1);
Writeln('Least Squares Unit Cell Refinement');
GotoXY(29,3); Writeln('N D S U version ', Version);
GoToXY(65,4); Writeln('Time = ', Time);
END; { Name of System }
PROCEDURE ActiveScreen( ValueToPrint : INTEGER);
BEGIN
GotoXY( ScreenX, ScreenY );
Write( ValueToPrint );
END;
FUNCTION Theta( C, D : REAL) : REAL;
VAR
Factor : REAL;
BEGIN
Factor := d * d - c * c;
IF (Factor >= 0) AND (d*d+c*c > 0) THEN
Theta := 57.29578 * ArcTan( c / sqrt( Factor ))
ELSE Theta := 90;
END; { Theta }
PROCEDURE CommandTail;
BEGIN
FileName := ParamStr( 1 ); FileOut := ParamStr( 2 );
IF FileOut = '' THEN FileOut := 'LST:';
WRITELN(' The following information was obtained from the ',
'"Command Line".');
WRITELN(' ':8,'LSUCRIPC