The following program coded in fortran computes the 4 fringe field integrals I1, I2, I3 and I4 for either a magnetic or an electrostatic quadrupole. The necessary data are read in from a corresponding data file. PROGRAM FRINGE C C PROGRAM TO COMPUTE FRINGE FIELD INTEGRALS C SEE NUCL. INST. AND METH. 103 (1972) P.117-124 C FIRST TIME COMPILED BY U. ROHRER (SIN), JULY 1986 C CHARACTER*40 TITLE REAL F(0:200), FF(0:200) C DO I = 0, 200 F(I) = 0. ENDDO C C READ IN GRADIENT ON QUAD AXIS C READ(1,1001) TITLE 1001 FORMAT(A) TYPE *,TITLE READ(1,1002) DZ,AP ! INCREMENT IN Z AND APERTURE RADIUS 1002 FORMAT(2F10.1) READ(1,1000) N1,N2 FMAX = FLOAT(N1 + N2) / 2. F(200) = 1. I = 199 C 10 READ(1,1000,END=20) N1,N2 1000 FORMAT(2I5) F(I) = FLOAT(N1 + N2) / 2. F(I) = F(I) / FMAX ! NORMALIZE I = I - 1 GO TO 10 C 20 DZ = DZ / AP ! NORMALIZE (Z IS MEASURED IN UNITS OF AP) C C FF(Z) IS INTEGRAL OF F(I) ALONG Z ( AS FUNCTION OF Z) C FF(0) = 0. DO I = 1, 200 FM = (F(I) + F(I-1)) / 2. FF(I) = FF(I-1) + FM * DZ ENDDO C ZB = FF(200) ! KIND OF AN OFFSET C C CONPUTE INTEGRAL I1 C SUM = 0. DO I = 1, 200 FFM = (FF(I) + FF(I-1)) / 2. SUM = SUM + FFM * DZ ENDDO XI1 = SUM - 0.5 * ZB**2 TYPE *, 'I1 =',XI1 C C CONPUTE INTEGRAL I2 C SUM = 0. Z = ZB - 200. * DZ + DZ/2. DO I = 1, 200 FFM = (FF(I) + FF(I-1)) / 2. SUM = SUM + Z * FFM * DZ Z = Z + DZ ENDDO XI2 = SUM - ZB**3 / 3. TYPE *, 'I2 =',XI2 C C CONPUTE INTEGRAL I3 C SUM = 0. DO I = 1, 200 FFM = (FF(I) + FF(I-1)) / 2. FFM2 = FFM**2 SUM = SUM + FFM2 * DZ ENDDO XI3 = SUM - ZB**3 / 3. TYPE *, 'I3 =',XI3 C C CONPUTE INTEGRAL I4 C SUM = 0. DO I = 1, 200 FFM = (F(I) + F(I-1)) / 2. FFM2 = FFM**2 SUM = SUM + FFM2 * DZ ENDDO XI4 = SUM - ZB TYPE *, 'I4 =',XI4 C C FINISHED C CALL EXIT ENDSample input file. Note that the enumeration of field values starts from the interior of the quad (first value is the max). 2 rows are used, because field measurements on the axis are done by taking data by moving in and out the measurement device. The average of the 2 values should be taken for our purpose. LINEAR AXIAL GRADIENT 2.,200. 1000 1000 1000 1000 1000 1000 1000 1000 990 990 980 980 970 970 960 960 .. .. .. .. 60 60 50 50 40 40 30 30 20 20 10 10 0 0 0 0 0 0 0 0 Last updated by Urs Rohrer on 8-Feb-2006 |