CLS '************************************************************************* ' Useful Conversion Numbers CONST PI = 3.141592653# ' Value of PI CONST CONV = .0254 ' Inches to Meters ' Parameters obtained from drawings (meters) CONST LMAG = 5.245989 ' Magnet Chord Length CONST SAG = .085647 ' Sagita ' Parameters measured (inches) CONST P1X = 3.87 ' Distance from NLE Pole to P1 in X-direction CONST P2X = -2.39 ' Distance from NLE Pole to P2 in X-direction CONST P3Z = 25.84 ' Distance from NLE to P1(P2) in Z-direction CONST LEext = 17.68 ' Distance of Lead End Extension CONST NLEext = 17.9375 ' Distance of Non Lead End Extension CONST offset = -1.5 ' Radial offset of measuring probes ' File names filein$ = "map5.dat" fileout$ = "5.dat" ' Calculate additional parameters rad! = ((LMAG / 2) ^ 2 + SAG ^ 2) / (2 * SAG)'Magnet Radius of curvature dc = rad! - SAG ' Distance from center of circle to chord cen = LMAG / 2 + LEext * CONV ' Distance to magnet center from Lead End radoff! = rad! + (offset * CONV) ' Offset radius scen! = (radoff! * PI / 2) ' Arc length (s) to center of magnet ' Calculate distances and angles of positioning points ' from the center of the magnet circle px1 = dc + P1X * CONV px2 = dc + P2X * CONV pz = LMAG / 2 + P3Z * CONV rp1 = SQR(pz ^ 2 + px1 ^ 2) rp2 = SQR(pz ^ 2 + px2 ^ 2) angP1 = ATN(px1 / pz) angP2 = ATN(px2 / pz) '************************************************************************* DIM spos!(200) DIM nmrhall!(200) avecur! = 0 ' Open file to read data from infile% = FREEFILE OPEN filein$ FOR INPUT AS infile% ' Open file to write corrected data to outfile% = FREEFILE OPEN fileout$ FOR OUTPUT AS outfile% ' Read data, correct positions then write to new file WHILE NOT EOF(infile%) 'Read data INPUT #infile%, n% INPUT #infile%, zpos! INPUT #infile%, cur! INPUT #infile%, hall! INPUT #infile%, nmr! INPUT #infile%, nmrh! nmrhall!(n%) = hall! 'Use the hall probe data for field uniformity measurements 'Average current avecur! = avecur! + cur! 'Set z=0 to first position z! = 250! * CONV - zpos! '250" from z=0 to probe 'Calculate angular position of each point along circle IF (zpos! / .0254) < 121 THEN num! = rp1 ^ 2 + rad! ^ 2 - z! ^ 2 den! = 2 * rp1 * rad! angP = angP1 ELSE num! = rp2 ^ 2 + rad! ^ 2 - z! ^ 2 den! = 2 * rp2 * rad! angP = angP2 END IF rat! = num! / den! thetam! = ATN(SQR(1! - rat! ^ 2) / rat!) 'Angle between Positioning point and point on Pole thetac! = PI - angP - thetam! 'Angular position along circle IF n% = 1 THEN thetainit! = thetac! 'Calculate position along pole face (arc length: s=r*theta) s! = radoff! * thetac! - scen! ' Set s=0 at magnet center 's! = radoff! * (thetac! - thetainit!) ' Set s=0 at 1st position PRINT #outfile%, USING " ##.##### ###.#### ##.#####"; s!; cur!; nmrh! 'Save positions and nmr/hall values for Int Bdl calculation spos!(n%) = s! WEND 'Calculate the Integrated Field Strength intbdl! = 0 'Sum the areas of the trapezoids to get the integral FOR i% = 2 TO n% intbdl! = intbdl! + .5 * (nmrhall!(i%) + nmrhall!(i% - 1)) * (spos!(i%) - spos!(i% - 1)) NEXT i% PRINT #outfile%, " " PRINT #outfile%, " Total number of Positions: "; n% PRINT #outfile%, " The average current = "; avecur! / n%; " Amps" PRINT #outfile%, " The Integrated Field Strength = "; intbdl!; " Tm" PRINT #outfile%, " The Transfer Function = "; 1000 * intbdl! / (avecur! / n%); " Tm/kA" CLOSE infile% CLOSE outfile% PRINT " " PRINT " Total number of Positions: "; n% PRINT " The total length = "; spos!(n%) - spos!(1) PRINT " The average current = "; avecur! / n%; " Amps" PRINT " The Integrated Field Strength = "; intbdl!; " Tm" PRINT " The Transfer Function = "; 1000 * intbdl! / (avecur! / n%); " Tm/kA"