Program for finding aberrations of a magnetic deflector, used in conjunction with xmpl3d30.dat

This can be copied from the end of file xmpl3d30.dat, which is supplied with the CPO3D package.

Program for finding aberrations of a magnetic deflector (in Fortran, early version).

DIMENSION x(100) , y(100) , z(100) , vx(100) , vy(100) , vz(100) ,

& xf(100) , yf(100)

n = 14

C =number of results in output file

zf_gaussian = 50.0

C =final z at which image is supposed to be

dzf = 0.05

C =decrements for testing for z positions of minimum spots (in tangential

C and sagittal directions, and disc of least confusion)

zf_min = 45.0

C =lowest vale of zf for looking for minimum spots

ntest = int((zf_gaussian-zf_min)/dzf)

zf = zf_gaussian + dzf

OPEN (UNIT=1,FILE='temp30a.dat',STATUS='OLD')

C =trajectory output file

OPEN (UNIT=2,FILE='tempres.dat',STATUS='UNKNOWN')

C =results file

DO i = 1 , n

READ (1,*) x(i) , y(i) , z(i) , vx(i) , vy(i) , vz(i)

ENDDO

dxmin = 1.E10

C =spread in x direction

dymin = 1.E10

C =spread in y direction

dxymin = 1.E10

C =spread in either x or y directions -ie disc of least confusion

DO iz = 1 , ntest

zf = zf - dzf

C =test value of final z, to find minimum spots

xmax = -1.E10

xmin = 1.E10

ymax = -1.E10

ymin = 1.E10

DO i = 1 , n

xf(i) = x(i) + (zf - zf_gaussian)*vx(i)/vz(i)

yf(i) = y(i) + (zf - zf_gaussian)*vy(i)/vz(i)

C =x and y at test plane

C (put in arrays in case more sophisticated analysis is wanted later)

xmax = max(xmax,xf(i))

xmin = min(xmin,xf(i))

ymax = max(ymax,yf(i))

ymin = min(ymin,yf(i))

ENDDO

dx = xmax - xmin

C =spread in x direction

dy = 2.*(ymax - ymin)

C =spread in y direction

C (2* because of reflection in y plane)

IF (iz.EQ.1) THEN

dx_gaussian = dx

dy_gaussian = dy

C =saved values at z=zf_gaussian

ENDIF

IF (dx.LT.dxmin) THEN

C Best size of spot so far, in the x direction only

dxmin = dx

dzminx = zf_gaussian - zf

IF (iz.EQ.ntest)

& WRITE (2,'(''Range of z not large enough'')')

ENDIF

IF (dy.LT.dymin) THEN

C Best size of spot so far, in the y direction only

dymin = dy

dzminy = zf_gaussian - zf

IF (iz.EQ.ntest)

& WRITE (2,'(''Range of z not large enough'')')

ENDIF

dxy = max(dx,dy)

C =largest spread in x or y direction (for disc of least confusion)

IF (dxy.LT.dxymin) THEN

C Best size of spot of least confusion so far

dxymin = dxy

dzminlc = zf_gaussian - zf

IF (iz.EQ.ntest)

& WRITE (2,'(''Range of z not large enough'')')

ENDIF

ENDDO

WRITE (2,99001) x(1) , dx_gaussian , dy_gaussian , dxmin ,

& dzminx , dymin , dzminy , dxymin , dzminlc

99001 FORMAT (

& 'Gaussian plane: tangential: sagital: least confus

&ion:'/

& 'median_x dx dy dx dz dy dz dx,y dz

&'/

& F7.4,2F8.5,F9.5,F5.2,F9.5,F5.2,F9.5,F5.2)

STOP

END