Contents Prev Manual

PROGRAM MAG3D

To draw magnetic structures in 3D

Description:

MAG3D is a program to draw magnetic structures, described in a standard crystal data file, on a terminal screen. The picture can be rotated to obtain a satisfactory viewing angle and a high quality representation of the structure can finally be written in postscript format.

Input:

The crystal data file must contain all the information that would be required for magnetic structure factor calculations viz:
Symmetry (S) cards
Cell (C) card
Atom (A) cards
Form factor (F) cards
Magnetic structure (Q) cards
in addition special "X" cards are required to describe the graphical output these are:
X ARRO <Data> to define the proportions of arrows representing
the magnetic moments.
The <Data> are 5 real numbers: the head length, the head radius, the tail radius and the linewidth, all given as fractions of the total length of the arrow. The final number is the scale relating the length of an arrow in Angstroms to its moment in Bohr magnetons.

X CM/A <Scale>
<Scale> gives the scale of the picture in cms/Angstrom unit.

X PERS <Data> to define the perspective
The <Data> are 3 real numbers: the cosine and sine of the angle that the direction perpendicular to the plane of the projection makes, in projection, with the negative x axis of the picture; and a factor giving the contraction in projection of vector components perpendicular to the plane of projection.

X <Atom Name> SYMB <Data> indicating how to draw each type of
atom.
There should be one SYM B card with a matching <Atom Name> for each A card .
The <Data> are 2 real numbers: the radius of the atom in Angstrom units and the grey level to be used to paint it. Grey levels are in the range 0 to 1 with 0 being jet black and 1 pure white.

X TRAN <Data> The transformation matrix
The <Data> are 9 real numbers describing the transformation from orthogonal crystallographic axes to the projection axes for which x is perpendicular to the projection plane, z is vertical and y horizontal in the projection plane. The data are the direction cosines of the projection axes x,y,z on the crystal axes.

Example X cards for Fe2Ti
X PERS .5 .7660 .6428
X ARRO .333 0.1667 .0833 .02 1.2
X TRAN 1 0 0 0 1 0 0 0 1
X SYMB Fe1 .25 0.25
X SYMB Fe2 .25 0.25
X SYMB Ti .4 .8
X CM/A 1

Output:

The usual listing file MAG3D.LIS reporting what was read from the crystal data file and how it was interpreted.
An optional screen dump of the graphic terminal can be obtained after each picture is drawn if the plotter driver supports "hard copy".
At the end of the program a "postscript" output file can be written which gives a high quality rendering of the final picture. This file will have the same name as the crystal data file and the extension .PS.

Notes:

The program can be run in conjunction with any graphical output device for which a CCSL graphical driver(PIGLET) is available. It is most conveniently run from an X-terminal or one which emulates a
Tektronix 4010.

Running the program:

Once running, the program the user will be asked in the usual way for the name of the crystal data file. Next the numbers of unit cells to be drawn in the directions of the a,b and c crystallographic axes, are required. They should be given in that order.
The screen will then switch to graphic mode and the magnetic structure will be drawn. When the drawing is complete the user is asked whether a hard copy of the graphic screen is required. There is then an option to rotate the picture about any of the the projection axes; if this is selected the rotated structure is drawn. When no further rotation is requested the user may, if he wishes, record a new crystal data file containing the latest rotation matrix. Finally the user is given the option of making a "PostScript" output file. If this is chosen a file with a name of the form 'CDF'.ps (where 'CDF' is name of the crystal data file) is written before the program ends.

Calls:

AROW3D ARTILT ASK ATLABS CIRCLE DEGREE EQPOS ERRCHK ERRMES FILNOM FINDCD FRAME GMADD GMEQ GMPRD GMSCA GMSUB GMUNI GMZER INDFIX INDFLO INPUTN JGMEQ JGMZER KANGA1 KANGA2 LABAXE LATGEN MAG3DX MAGCNC MESS NFIND ORTHO PERSPC PIGLET PLTRIN POSOUT PREFIN RADIAN RDNUMS ROTSYM SAYS SCALPR SETFCM SPCSET SPHPOL UNIVEC

Common blocks used:

/ARRAYS/ to use all members
/ATMLAB/ to use all members
/ATNAM/ to use ATNAME
/CONSTA/ to use TWOPI
/IOUNIT/ to use LPT ITO IPLO
/MAGDAT/ to use NMAG MAGAT ANGM SMOD PHIH LPHI SPIND
/NTITL/ to use NTITLE
/PICDAT/ to use all members
/PICDEF/ to use CMPERA APERMB PWIDTH PHGHT X0 Y0
/PLODAT/ to use ASPECT CHUNIT
/POSTSC/ to use all members
/POSNS/ to use NATOM
/NSYM/ to use NCENT NOPC NLAT
/SATELL/ to use PROP KSTAB NKC
/SYMDA/ to use TRANS ALAT
/SYMMAG/ to use OTRSYM MTYP MODUL
/TITLE/ to use all members

*** MAG3D Postscript arrows included C110 ***

Classification:

Magnetic Structure Factors . . . . . . . Main Program

SUBROUTINE AROW3D(XP,YP,AL,ARDAT)

To draw 3D arrows

Arguments:

XP,YP is the position for the arrow in space 4
AL is the length in Angstoms(space 4)
Arrow drawing data in ARDAT(4): can be filled in by subroutine ARTILT
PHI1 (ARDAT(1)) is the angle of rotation of the projected
arrow from the x axis of the picture (in radians)

PHI2 (ARDAT(2)) is the angle of rotation of the minor axis of
projected ellipses from the projected arrow direction.

FR (ARDAT(3)) is the perspective foreshortening factor in the
direction parallel to the projection of the arrow

EX (ARDAT(4)) is the ratio of the minor to major axes of
projected ellipses

Prerequisite calls:

MAG3DX to put the arrow definition in COMMON PICDEF

Notes:

Uses plotter space 5 to keep the transformation for the arrow rotation

Calls:

KANGA1 PLTRIN SPCSET

Called by:

MAG3D LABAXE

Common blocks used:

/CONSTA/ to use PI TWOPI
/PICDAT/ to use all members

*** AROW3D improved by PJB March 1992 ***



SUBROUTINE ARTILT(R,ARDAT)

To define the tilt parameters for 3d arrows

Arguments:

On entry: R is a unit vector parallel to the spin, on the orthogonal
coordinate system of the picture.

On exit: Arrow drawing data in ARDAT(4)
PHI1 (ARDAT(1)) is the angle of rotation of the projected
arrow from the x axis of the picture (in radians)

PHI2 (ARDAT(2)) is the angle of rotation of the minor axis of
projected ellipses from the projected arrow direction.

FR (ARDAT(3)) is the perspective foreshortening factor in the
direction parallel to the projection of the arrow

FT (ARDAT(4)) is the ratio of the minor to major axes of
projected ellipses

Prerequisite calls:

MAG3DX to set the perspective transformation in COMMON PICDAT and the arrow definition in PICDEF

Calls:

PERSPC TESTOV UNIVEC

Called by:

MAG3D

Common blocks used:

/PICDAT/ to use all members

*** ARTILT NEW BY PJB MARCH 1992 ***



SUBROUTINE ARROW(P,S,N)

Writes postscript output to plot an arrow in MAG3D

Calls:

DEGREE GMSCA

Called by:

ATLABS POSORT

Common blocks used:

/VFRMTS/ to use all members
/IOUNIT/ to use IPLO
/LAYOUT/ to use all members
/PICDEF/ to use CMPERA APERMB

*** ARROW NEW BY PJB DECEMBER 1991 ***

Classification:

Graphical Output . . . . . . . Utility

SUBROUTINE ATLAB(P,NAME)

Writes an atom name on the postscript output file

Arguments:

P gives the position and NAME the name

Calls:

GMSCA

Called by:

ATLABS

Common blocks used:

/IOUNIT/ to use IPLO
/PICDAT/ to use all members
/PICDEF/ to use CMPERA

*** ATLAB new by PJB March 1992 ***



SUBROUTINE ATLABS(MODE)

Makes a key for the atom symbols in MAG3D

Arguments:

A multiple entry subprogram driven by MODE
MODE = 1 Identify the inequivalent atoms
MODE = 2 Arrange the space needed for the key
MODE = 3 Write the key

Calls:

ARROW ATLAB ATOM LENGT

Called by:

MAG3D POSOUT

Common blocks used:

/ARRAYS/ to use all members
/ATMLAB/ to use all members
/ATNAM/ to use ATNAME
/PICDAT/ to use all members
/PICDEF/ to use CMPERA PWIDTH PHGHT X0 Y0
/POSNS/ to use NATOM

*** ATLABS new by PJB April 92 ***



SUBROUTINE ATOM(R,N)

Writes postscript output to plot an atom in MAG3D

Calls:

GMSCA

Called by:

ATLABS POSORT

Common blocks used:

/VFRMTS/ to use all members
/IOUNIT/ to use IPLO
/LAYOUT/ to use all members
/PICDEF/ to use CMPERA

*** ATOM new by PJB Dec 91 ***



SUBROUTINE ELIPSE(X,Y,R,EX,ANG,ANG1,ANG2)

To draw an arc of an ellipse

Arguments:

X,Y are the coordinates of the centre.
R is the length of the major axis
EX is the ratio of the minor to the major axis
ANG is the angle by which the major axis is inclined to the x-axis
The arc is drawn from ANG1 to ANG2 measured counter clockwise from the x-axis.

Calls:

KANGA1 PLCONV

Common blocks used:

/CONSTA/ to use TWOPI
/PLTRAN/ to use NSPCE

*** ELIPSE new by PJB Mar 92 ***



SUBROUTINE INVPRS(P,Q)

Inverse perspective transformation

Description:

Given the x,y components of the 2D representation in P and the x(out of plane) component of the 3D vector in Q, fills in the other two components.

Called by:

OVERLA

Common blocks used:

/PICDAT/ to use all members

*** INVPRS new by PJB March 1992 ***



SUBROUTINE LABAXE(P1,P2,AL,S,ID)

Labels the axes of a diagram

Calls:

AROW3D KANGA2 PLCONV SPCSET

Called by:

MAG3D

Common blocks used:

/GRAYS/ to use all members
/PICDAT/ to use all members
/PLODAT/ to use CHUNIT

*** LABAXE revised by PJB Apr 92 ***



SUBROUTINE LAXIS(P1,P2,S,ID)

Puts arrows and labels to identify the axes of a postscript
picture

Calls:

DEGREE GMSCA

Called by:

POSORT

Common blocks used:

/GRAYS/ to use all members
/IOUNIT/ to use IPLO
/PICDAT/ to use all members
/PICDEF/ to use CMPERA FRLINE

*** LAXIS new by PJB Apr 92 ***



SUBROUTINE LINE(P1,P2)

Writes postscript output to plot a line in MAG3D

Calls:

GMSCA

Called by:

POSORT PSPOUT

Common blocks used:

/IOUNIT/ to use IPLO
/PICDAT/ to use all members
/PICDEF/ to use CMPERA

*** LINE new by PJB Dec 91 ***



SUBROUTINE MAG3DX

To read the "X" cards for MAG3D

Calls:

ERRCHK ERRMES FINDCD IATOM RDNUMS RDREAL RDWORD

Called by:

MAG3D

Common blocks used:

/ATNAM/ to use ATNAME
/IOUNIT/ to use ITO
/PICDAT/ to use all members
/PICDEF/ to use CMPERA FRLINE APERMB
/POSNS/ to use NATOM

*** MAG3DX new by PJB Mar 92 ***



FUNCTION MINZ(IQ,IP)

Determines what next to plot in MAG3D

Arguments:

IQ and IP mark the current positions in the arrays of atoms,lines and labels. IQ directly and IP with respect to the sorted arrays.
IQ is given on entry and Ip is set in the subprogram.

Notes:

The function returns 1,2,or 3 to indicate that an atom, a line or an axis label should be plotted next. The return value 4 indicates the end.

Calls:

MINZ

Called by:

MINZ POSORT

Common blocks used:

/ARRAYS/ to use all members

*** MINZ new by PJB Mar 92 ***



LOGICAL FUNCTION OVERLA(II,JJ,RAD,P)

Determines whether a line goes through an atom

Arguments:

II labels the atom in the arrays ARRAT, ARRAZ etc.
JJ labesl a line in the arrays ALINE, BLINE etc.
RAD is the radius of the atom.
If OVERLA is TRUE ie line and atom intersect P is returned containing the perspective coordinates of the intersection point nearest to the viewer

Calls:

FACT GMADD GMSCA GMSUB INVPRS OVERLA PERSPC SCALPR UNIVEC VECPRD

Called by:

OVERLA POSORT

Common blocks used:

/ARRAYS/ to use all members

*** OVERLA new by PJB Mar 92 ***



SUBROUTINE PERSPC(R,S,IS)

Perspective transformation

Arguments:

IS Indicates the space in which R is given
IS=0 Orthogonal and no transformation
IS=1 or 2 for real or reciprocal respectively, both with transformation

Prerequisite calls:

The common PICDAT must be set up to contain the perspective factors and any required transformation

Calls:

GMEQ GMPRD ORTHO

Called by:

MAG3D ARTILT OVERLA

Common blocks used:

/PICDAT/ to use all members

*** PERSPC new by PJB Jan 91 ***



SUBROUTINE POSORT(NARRAS,NLINES)

Sorts the arrows and atoms for postscript output of MAG3D

Arguments:

NARRAS is the number of atom/arrows to be plotted
NLINES is the number of lines to be plotted

Calls:

ARROW ATOM GMEQ JGMEQ LAXIS LINE MINZ OVERLA SORTX

Called by:

POSOUT

Common blocks used:

/ARRAYS/ to use all members
/PICDAT/ to use all members



SUBROUTINE POSOUT(NARS,NLINES)

Drives the postscript output for MAG3D

Arguments:

NARRAS is the number of atom/arrows to be plotted
NLINES is the number of lines to be plotted

Calls:

ATLABS FILNOM LENGT NOPFIL POSORT PSPROC UPONE

Called by:

MAG3D

Common blocks used:

/CARDRC/ to use ICRYDA
/IOUNIT/ to use LPT ITO IPLO LUNI
/NTITL/ to use NTITLE
/PICDAT/ to use all members
/PICDEF/ to use CMPERA FRLINE PWIDTH PHGHT X0 Y0
/TITLE/ to use all members
/SCRACH/ to use MESSAG
/WHEN/ to use all members

*** POSOUT new by PJB Apr 92 ***



SUBROUTINE PSPOUT(LUNO,CHARS,N)

Formats and prints CHARS on LUNO in lines only breaking at spaces

Calls:

LINE

Called by:

PSPROC



SUBROUTINE PSPROC(LUN)

Print postscript arrow procedures on unit LUN

Calls:

PSPOUT

Called by:

POSOUT

Common blocks used:




Contents Manual

P. Jane Brown e-mail: brown@ill.fr
Institut Laue Langevin,
Grenoble, FRANCE