DECLARE SUB dlogdl (logfile$, rcoil!, nturns%, nrot%, f!, v2!, dl!) DECLARE SUB dlogdlav (logfile$, rcoil!, nturns%, nrotave%, nmeasave%, dl!, sdl!) DECLARE SUB dmeasdl (dl!) DECLARE SUB dcalcdl (nh%, fcoil!, vm!(), vp!(), v2!, dl!) DECLARE SUB dcalchar (nh%, fcoil!, vm!(), vp!(), bl!(), th!(), r!()) DECLARE SUB dcalcxy (nh%, bl!(), sbl!(), th!(), sth!(), x!, sx!, y!, sy!) DECLARE SUB dimagloop () DECLARE SUB dlogcalc (logfile$) DECLARE SUB dlogdl (logfile$, rcoil!, nturns%, nrot%, f!, v2!, dl!) DECLARE SUB dlogdlav (logfile$, rcoil!, nturns%, nrotave%, nmeasave%, dl!, sdl!) DECLARE SUB dlogdlvsi (logfile$, rcoil!, nturns%, nrot%, nmeas%, ni%, imag!(), simag!(), dl!(), sdl!(), tf!(), stf!()) DECLARE SUB dloghar (logfile$, rcoil!, nturns%, nh%, fcoil!, vm!(), vp!(), bl!(), th!(), r!()) DECLARE SUB dlogharav (logfile$, rcoil!, nturns%, nrot%, nmeas%, nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) DECLARE SUB dlogharvsi (logfile$, rcoil!, nturns%, nrot%, nmeas%, nh%, imag!, simag!, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) DECLARE SUB dlognewpage (logfile$) DECLARE SUB dlogxy (logfile$, th!(), x!, sx!, y!, sy!) DECLARE SUB dmeasdl (dl!) DECLARE SUB dmeasdlav (dl!, sdl!) DECLARE SUB dmeashar (nh%, bl!(), th!(), r!()) DECLARE SUB dmeasharav (nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) DECLARE SUB dpltdlvsi (logfile$, magname$, run$, ni%, imag!(), dl!(), sdl!(), tf!(), stf!()) DECLARE SUB dpltharvsi (logfile$, magname$, run$, nh%, ni%, inom!(), rvsi!(), srvsi!()) DECLARE SUB coilmeas (nh%, f!, vm!(), vp!()) DECLARE SUB ibopmeas (imag!, simag!) DECLARE SUB ibopramp (inom!) '**************************************************************************** 'Module DIPOLE.BAS ' 'These subroutines perform calculations related to dipole magnet 'measurements. ' 'Zachary Wolf '1/2/95 '**************************************************************************** 'Open the parameter file REM $INCLUDE: 'param.inc' SUB dcalcdl (nh%, fcoil!, vm!(), vp!(), v1!, dl!) '**************************************************************************** 'This subroutine calculates the integrated dipole strength. ' 'Input: ' nh%, the number of voltage harmonics recorded ' fcoil!, the coil rotation frequency (1/s) ' vm!(1 to nh%), the voltage magnitudes (V) ' vp!(1 to nh%), the voltage phases (deg) ' 'Output: ' v1!, the value of vm!(1), the voltage at the first harmonic ' dl!, the integrated dipole strength (Tm) ' 'Zachary Wolf '1/2/94 '**************************************************************************** 'Some Math 'v1 = Nturns * velocity * B1 * L ' = Nturns * Rcoil * ang_freq * dl 'dl = v1 / (Nturns * Rcoil * ang_freq) 'Simplify the notation pi! = 3.1415926# 'Coil parameters nturns% = nturnscoilP% rcoil! = rcoilP! 'Get V1 v1! = vm!(1) 'Compute DL dl! = v1! / (nturns% * rcoil! * 2! * pi! * fcoil!) END SUB SUB dcalchar (nh%, fcoil!, vm!(), vp!(), bl!(), th!(), r!()) '**************************************************************************** 'This subroutine calculates the integrated field strength of each harmonic 'and the ratio of each harmonic strength to the dipole strength at the 'coil radius. It also calculates the angle of the first south pole of 'each harmonic field. ' 'Input: ' nh%, the number of voltage harmonics recorded ' fcoil!, the coil rotation frequency (1/s) ' vm!(1 to nh%), the voltage magnitudes (V) ' vp!(1 to nh%), the voltage phases (deg) ' 'Output: ' bl!(1 to nh%), the integrated strength of each harmonic at the coil radius (Tm) ' th!(1 to nh%), the angle of the first south pole of each harmonic wrt horizontal (deg) ' r!(1 to nh%), the ratio bl(n)/bl(1) at rcoil ' 'Zachary Wolf '1/2/94 '**************************************************************************** 'Some Math 'R 'Vn = Nturns * velocity * Bn * L ' = Nturns * Rcoil * ang_freq * (BLn) 'BLn = Vn / (Nturns * Rcoil * ang_freq) 'Rn = BLn / BL1 = Vn / V1 'TH 'Field expansion of intz(Br): BLr(r,th) = Sum BLrn(r,th) ' BLrn(r,th) = bln * r^(n-1) * cos(n*(th - THspole)) 'At the coil radius, BLrn(th) = BLn * cos(n*(th - THspole)) 'The coil voltage Vn(th) = Nturns * velocity * BLrn(th) ' = Nturns * Rcoil * 2pi * Freq * BLn * cos(n*(th - THspole)) 'The FFT gives Vn and PhiVn in the formula 'Vn(i) = Vn * cos(n*2pi*i/N + PhiVn), V(i) = Sum(Vn(i)) 'So, Nturns * Rcoil * 2pi * Freq * BLn = Vn ' -n * THspole = PhiVn 'Then, BLn = Vn / (Nturns * Rcoil * 2pi * Freq) ' THspole = -PhiVn / n 'Simplify the notation pi! = 3.1415926# 'Coil parameters nturns% = nturnscoilP% rcoil! = rcoilP! 'Compute the strength of each field harmonic at the coil radius FOR i% = 1 TO nh% bl!(i%) = vm!(i%) / (nturns% * rcoil! * 2! * pi! * fcoil!) NEXT i% 'Compute the angle of the first south pole wrt horizontal for each harmonic FOR i% = 1 TO nh% th!(i%) = -vp!(i%) / i% NEXT i% 'Compute the field strength ratios at the coil radius FOR i% = 1 TO nh% r!(i%) = vm!(i%) / vm!(1) NEXT i% END SUB SUB dimagloop '**************************************************************************** 'This subroutine controls the magnetic measurements at various currents. ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Message PRINT PRINT "Beginning the magnetic field measurement cycle..." 'Simplify the notation ni% = nimagtestP% nh% = nhardisplayP% nih% = nimagharP% 'Initialize data arrays and counters ih% = 0 DIM imagvsi!(1 TO ni%) 'measured magnet current DIM simagvsi!(1 TO ni%) 'standard deviation of imag DIM dlvsi!(1 TO ni%) 'integrated dipole strength at each current DIM sdlvsi!(1 TO ni%) 'standard deviation of dl DIM tfvsi!(1 TO ni%) 'transfer function DIM stfvsi!(1 TO ni%) 'standard deviation of tf DIM bl!(1 TO nh%) 'field strength at Rcoil of the n'th harmonic DIM sbl!(1 TO nh%) 'standard deviation of Bn DIM th!(1 TO nh%) 'field angle DIM sth!(1 TO nh%) 'standard deviation of THn DIM r!(1 TO nh%) 'BLn/BL1 DIM sr!(1 TO nh%) 'standard deviation of r DIM rvsi!(1 TO nh%, 1 TO ni%) 'BLn/BL1 vs I DIM srvsi!(1 TO nh%, 1 TO ni%) 'standard deviation of BLn/BL1 vs I DIM inomhar!(1 TO ni%) 'nominal harmonics currents 'Loop over test currents FOR i% = 1 TO ni% 'Message PRINT PRINT "Ramping to "; imagtestP!(i%); " Amps..." 'Ramp to the desired current CALL ibopramp(imagtestP!(i%)) 'Measure the current CALL ibopmeas(imag!, simag!) 'DL 'Set the parameters for the DL measurement coilhpchanP% = coil1hpchanP% nturnscoilP% = nturnscoil1P% rcoilP! = rcoil1P! 'Measure the integrated dipole strength CALL dmeasdlav(dl!, sdl!) 'Compute the transfer function tf! = dl! / imag! stf! = tf! * SQR((sdl! / dl!) ^ 2 + (simag! / imag!) ^ 2) 'Save the results for summaries and plots imagvsi!(i%) = imag! simagvsi!(i%) = simag! dlvsi(i%) = dl! sdlvsi(i%) = sdl! tfvsi!(i%) = tf! stfvsi!(i%) = stf! 'HARMONICS 'See if the harmonics are desired at this current har% = 0 FOR j% = 1 TO nih% IF imagharP!(j%) = imagtestP!(i%) THEN har% = 1 NEXT j% IF har% = 0 THEN GOTO skiphar 'not a harmonics current IF ih% >= nih% THEN GOTO skiphar 'harmonics only on up ramp ih% = ih% + 1 'if here, measure harmonics, ++ counter 'Set the parameters for the harmonics measurement coilhpchanP% = coil1hpchanP% nturnscoilP% = nturnscoil1P% rcoilP! = rcoil1P! 'Measure the harmonics CALL dmeasharav(nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) 'Write the results to the harmonics dat file CALL dlogharvsi(hardatP$, rcoilP!, nturnscoilP%, nrotaveP%, nmeasaveP%, nh%, imag!, simag!, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) 'Save the ratios for plotting inomhar!(ih%) = imagtestP!(i%) FOR j% = 1 TO nh% rvsi!(j%, ih%) = r!(j%) srvsi!(j%, ih%) = sr!(j%) NEXT j% 'Come here to skip the harmonics measurement skiphar: 'End loop over currents NEXT i% 'DL data and plot files 'Write a summary of the results to the dat file and log file CALL dlogdlvsi(dldatP$, rcoil12P!, nturnscoil12P%, nrotaveP%, nmeasaveP%, ni%, imagvsi!(), simagvsi!(), dlvsi!(), sdlvsi!(), tfvsi!(), stfvsi!()) CALL dlogdlvsi(logfileP$, rcoil12P!, nturnscoil12P%, nrotaveP%, nmeasaveP%, ni%, imagvsi!(), simagvsi!(), dlvsi!(), sdlvsi!(), tfvsi!(), stfvsi!()) 'Write the results to the plotting file CALL dpltdlvsi(dlpltP$, magnameP$, runP$, ni%, imagvsi!(), dlvsi!(), sdlvsi!(), tfvsi!(), stfvsi!()) 'Write a summary of the calculations to the dat file CALL dlognewpage(dldatP$) CALL dlogcalc(dldatP$) 'Harmonics data and plot files 'Plot the results CALL dpltharvsi(harpltP$, magnameP$, runP$, nh%, ih%, inomhar!(), rvsi!(), srvsi!()) 'Write a summary of the calculations to the dat file CALL dlognewpage(hardatP$) CALL dlogcalc(hardatP$) 'Log file 'Write a summary of the calculations to the log file CALL dlognewpage(logfileP$) CALL dlogcalc(logfileP$) END SUB SUB dipole '**************************************************************************** 'This subroutine controls the dipole magnetic measurements. ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Loop over test currents, measure dl and the harmonics CALL dimagloop END SUB SUB dlogcalc (logfile$) '**************************************************************************** 'This subroutine summarizes the calculations used in the program. ' 'Inputs: ' logfile$, the name of the log file ' 'Zachary Wolf '9/22/94, 12/3/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Header PRINT #filenum%, PRINT #filenum%, " SUMMARY OF THE CALCULATIONS AND CONVENTIONS USED" 'Summarize the calculations used for DL vs I PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, "Calculation of DL using a double coil (assumed flat):" PRINT #filenum%, "V1 = (Nturns * velocity * B1 * L)_1 + (Nturns * velocity * B1 * L)_2" PRINT #filenum%, " = (Nturns1 * Rcoil1 * ang_freq * DL)" PRINT #filenum%, " + (Nturns2 * Rcoil2 * ang_freq * DL)" PRINT #filenum%, " = (Nturns1 * Rcoil1 + Nturns2 * Rcoil2) * ang_freq * DL" PRINT #filenum%, "If Nturns1 = Nturns2 == Nturns12, then" PRINT #filenum%, "V1 = Nturns12 * (Rcoil1 + Rcoil2) * ang_freq * DL" PRINT #filenum%, "Let Reff = Rcoil1 + Rcoil2, then" PRINT #filenum%, "V1 = Nturns12 * Reff * ang_freq * DL" PRINT #filenum%, "Or," PRINT #filenum%, "DL = V1 / (Nturns12 * Reff * ang_freq)" 'Harmonics PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, "Calculation of the harmonics:" PRINT #filenum%, "The integrated radial field for the n'th harmonic at the" PRINT #filenum%, "coil radius is given by" PRINT #filenum%, "BLn(th) = BLn * cos(n*(th - THspole))" PRINT #filenum%, "The coil voltage is V = Nturns * v_theta * B_r * L" PRINT #filenum%, "Vn(th) = Nturns * velocity * BLn(th)" PRINT #filenum%, " = Nturns * Rcoil * ang_freq * BLn * cos(n*(th - THspole))" PRINT #filenum%, "The FFT gives Vn and PhiVn in the formula" PRINT #filenum%, "Vn(i) = Vn * cos(n*2pi*i/N + PhiVn)" PRINT #filenum%, "Then," PRINT #filenum%, "Vn = Nturns * Rcoil * ang_freq * BLn" PRINT #filenum%, "PhiVn = - n * THspole" PRINT #filenum%, "Or," PRINT #filenum%, "BLn = Vn / (Nturns * Rcoil * ang_freq)" PRINT #filenum%, "THspole = - PhiVn / n" 'Close the log file CLOSE filenum% END SUB SUB dlogdl (logfile$, rcoil!, nturns%, nrot%, f!, v1!, dl!) '**************************************************************************** 'This subroutine writes a summary of a DL measurement to the log file. ' 'Input: ' logfile$, the name of the log file ' rcoil!, the coil radius ' nturns%, the number of turns on the coil ' nrot%, the number of coil rotations for average ' f!, the coil rotation frequency ' v1!, the voltage at the first rotation harmonic ' dl!, the integrated dipole strength at each current ' 'Zachary Wolf '8/15/94, 1/5/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Integrated Dipole Strength:" PRINT #filenum%, "Coil: Radius = "; rcoil!; " m,"; " # Turns = "; nturns% PRINT #filenum%, "Average, # Rotations/Measurement = "; nrot% PRINT #filenum%, "Coil Rotation Frequency, Fcoil = "; f!; " 1/s" PRINT #filenum%, "Coil Voltage, V1 = "; v1!; " V" PRINT #filenum%, "Integrated Dipole Strength, DL = "; dl!; " Tm" 'Close the log file CLOSE filenum% END SUB SUB dlogdlav (logfile$, rcoil!, nturns%, nrotave%, nmeasave%, dl!, sdl!) '**************************************************************************** 'This subroutine writes a summary of an average DL measurement to the log file. ' 'Input: ' logfile$, the name of the log file ' rcoil!, the coil radius ' nturns%, the number of turns on the coil ' nrotave%, the number of coil rotations for average ' nmeasave%, the number of measurements for the average and standard deviation ' dl!, the average of the integrated dipole strength measurements ' sdl!, the rms variation of DL ' 'Zachary Wolf '8/15/94, 1/3/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, PRINT #filenum%, TIME$; " Integrated Dipole Strength Measurement:" PRINT #filenum%, "Coil: Radius = "; rcoil!; " m,"; " # Turns = "; nturns% PRINT #filenum%, "Average, # Rotations/Measurement = "; nrotave%; ", # Measurements = "; nmeasave% PRINT #filenum%, "Integrated Dipole Strength, DL = "; dl!; " +- "; sdl!; " Tm" 'Close the log file CLOSE filenum% END SUB SUB dlogdlvsi (logfile$, rcoil!, nturns%, nrot%, nmeas%, ni%, imag!(), simag!(), dl!(), sdl!(), tf!(), stf!()) '**************************************************************************** 'This subroutine writes a summary of the DL vs I measurements. ' 'Input: ' logfile$, the name of the log file ' rcoil!, the coil radius ' nturns%, the number of turns on the coil ' nrot%, the number of rotations for average ' nmeas%, the number of measurements for average and standard deviation ' ni%, the number of currents ' imag!(1 to ni%), the measured currents ' simag!(1 to ni%), the standard deviation of imag ' dl!(1 to ni%), the integrated dipole strength at each current ' sdl!(1 to ni%), the standard deviation of DL ' tf!(1 to ni%), DL/I ' stf!(1 to ni%), the standard deviation of TF ' 'Zachary Wolf '8/14/94, 1/4/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write a header for the hysteresis loop PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, " INTEGRATED DIPOLE STRENGTH VS CURRENT" PRINT #filenum%, PRINT #filenum%, "Double Coil: Effective Radius = "; rcoil!; " m,"; " # Turns = "; nturns% PRINT #filenum%, "Average: # Rotations/Measurement = "; nrot%; ", # Measurements = "; nmeas% PRINT #filenum%, PRINT #filenum%, " Imag sigImag BL sigBL BL/I sigBL/I " PRINT #filenum%, " (A) (A) (Gm) (Gm) (Gm/A) (Gm/A) " PRINT #filenum%, "--------+-------- --------+-------- --------+--------" 'Write the results FOR i% = 1 TO ni% PRINT #filenum%, USING "####.###"; imag!(i%); PRINT #filenum%, USING " ####.###"; simag!(i%); PRINT #filenum%, USING " ##.#####"; 10000 * dl!(i%); PRINT #filenum%, USING " ##.#####"; 10000 * sdl!(i%); PRINT #filenum%, USING " ####.###"; 10000 * tf!(i%); PRINT #filenum%, USING " ####.###"; 10000 * stf!(i%) NEXT i% 'Close the log file CLOSE filenum% END SUB SUB dloghar (logfile$, rcoil!, nturns%, nh%, fcoil!, vm!(), vp!(), bl!(), th!(), r!()) '**************************************************************************** 'This subroutine writes the harmonics measurements to the log file. ' 'Inputs: ' logfile$, the name of the log file ' rcoil!, coil radius ' nturns%, the number of turns on the coil ' nh%, the number of harmonics to print out ' fcoil!, the coil rotation frequency ' vm!(1 to nh%), voltage magnitudes ' vp!(1 to nh%), voltage phases ' bl!(1 TO nh%), field strength at Rcoil of the n'th harmonic ' th!(1 TO nh%), field angle in degrees ' r!(1 TO nh%), BLn/BL1 ' 'Zachary Wolf '1/5/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results to the log file PRINT #filenum%, PRINT #filenum%, " FIELD HARMONICS" PRINT #filenum%, PRINT #filenum%, "Coil Radius, Rcoil = "; rcoil!; " m, # Turns, Nturns = "; nturns% PRINT #filenum%, "Coil Rotation Frequency, Fcoil = "; fcoil! PRINT #filenum%, PRINT #filenum%, " N Vm Vp BLn THspole BLn/BL1" PRINT #filenum%, " (mV) (deg) (Gm) (deg) (%) " PRINT #filenum%, "--- ------- ------- ------- ------- -------" FOR j% = 1 TO nh% PRINT #filenum%, USING "###"; j%; PRINT #filenum%, USING " ###.###"; vm!(j%) * 1000!; PRINT #filenum%, USING " ####.##"; vp!(j%); PRINT #filenum%, USING " ###.###"; bl!(j%) * 10000!; PRINT #filenum%, USING " ####.##"; th!(j%); PRINT #filenum%, USING " ###.###"; r!(j%) * 100! NEXT j% 'Close the log file CLOSE filenum% END SUB SUB dlogharav (logfile$, rcoil!, nturns%, nrot%, nmeas%, nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) '**************************************************************************** 'This subroutine writes the harmonics measurements to the log file. ' 'Inputs: ' logfile$, the name of the log file ' rcoil!, coil radius ' nturns%, the number of turns on the coil ' nrot%, the number of rotations for average ' nmeas%, the number of measurements for average and standard deviation ' nh%, the number of harmonics to print out ' bl!(1 TO nh%), field strength at Rcoil of the n'th harmonic ' sbl!(1 TO nh%), standard deviation of Bn ' th!(1 TO nh%), field angle in degrees ' sth!(1 TO nh%), standard deviation of THn ' r!(1 TO nh%), BLn/BL1 ' sr!(1 TO nh%), standard deviation of r ' 'Zachary Wolf '7/9/94, 8/14/94, 1/4/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results to the log file PRINT #filenum%, PRINT #filenum%, " FIELD HARMONICS" PRINT #filenum%, PRINT #filenum%, "Coil Radius, Rcoil = "; rcoil!; " m" PRINT #filenum%, "Coil # Turns, Nturns = "; nturns% PRINT #filenum%, "Average, # Rotations/Measurement = "; nrot%; ", # Measurements = "; nmeas% PRINT #filenum%, PRINT #filenum%, " N BLn sigBLn THspole sigTH BLn/BL1 sBLn/BL1" PRINT #filenum%, " (Gm) (Gm) (deg) (deg) (%) (%) " PRINT #filenum%, "--- -------+------- -------+------- -------+------- " FOR j% = 1 TO nh% PRINT #filenum%, USING "###"; j%; PRINT #filenum%, USING " ###.###"; bl!(j%) * 10000!; PRINT #filenum%, USING " ###.###"; sbl!(j%) * 10000!; PRINT #filenum%, USING " ####.##"; th!(j%); PRINT #filenum%, USING " ####.##"; sth!(j%); PRINT #filenum%, USING " ###.###"; r!(j%) * 100!; PRINT #filenum%, USING " ###.###"; sr!(j%) * 100! NEXT j% 'Close the log file CLOSE filenum% END SUB SUB dlogharvsi (logfile$, rcoil!, nturns%, nrot%, nmeas%, nh%, imag!, simag!, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) '**************************************************************************** 'This subroutine writes the harmonics measurements to the log file. ' 'Inputs: ' logfile$, the name of the log file ' rcoil!, coil radius ' nturns%, the number of turns on the coil ' nrot%, the number of rotations for average ' nmeas%, the number of measurements for average and standard deviation ' nh%, the number of harmonics to print out ' imag!, the magnet current ' simag!, rms variation of imag measurements ' bl!(1 TO nh%), field strength at Rcoil of the n'th harmonic ' sbl!(1 TO nh%), standard deviation of Bn ' th!(1 TO nh%), field angle in degrees ' sth!(1 TO nh%), standard deviation of THn ' r!(1 TO nh%), BLn/BL1 ' sr!(1 TO nh%), standard deviation of r ' 'Zachary Wolf '7/9/94, 8/14/94, 1/4/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Keep track of # times called STATIC ncall% ncall% = ncall% + 1 'On first call print a header to the cover page IF ncall% = 1 THEN PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, " HARMONICS MEASUREMENTS" END IF 'Start a new page for each harmonics printout 'Write a page break character PRINT #filenum%, CHR$(12) 'Print a header PRINT #filenum%, "Date: "; DATE$ PRINT #filenum%, "Time: "; TIME$ PRINT #filenum%, "Magnet Name: "; magnameP$ PRINT #filenum%, "Project: "; projectP$ PRINT #filenum%, "Run Number: "; runP$ 'Print the results to the log file PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, " FIELD HARMONICS" PRINT #filenum%, PRINT #filenum%, "Magnet Current, Imag = "; imag!; " +- "; simag!; " A" PRINT #filenum%, "Coil Radius, Rcoil = "; rcoil!; " m" PRINT #filenum%, "Coil # Turns, Nturns = "; nturns% PRINT #filenum%, "Average, # Rotations/Measurement = "; nrot%; ", # Measurements = "; nmeas% PRINT #filenum%, PRINT #filenum%, " N BLn sigBLn THspole sigTH BLn/BL1 sBLn/BL1" PRINT #filenum%, " (Gm) (Gm) (deg) (deg) (%) (%) " PRINT #filenum%, "--- -------+------- -------+------- -------+------- " FOR j% = 1 TO nh% PRINT #filenum%, USING "###"; j%; PRINT #filenum%, USING " ###.###"; bl!(j%) * 10000!; PRINT #filenum%, USING " ###.###"; sbl!(j%) * 10000!; PRINT #filenum%, USING " ####.##"; th!(j%); PRINT #filenum%, USING " ####.##"; sth!(j%); PRINT #filenum%, USING " ###.###"; r!(j%) * 100!; PRINT #filenum%, USING " ###.###"; sr!(j%) * 100! NEXT j% 'Close the log file CLOSE filenum% END SUB SUB dlognewpage (logfile$) '**************************************************************************** 'This subroutine writes a page break character to the log file. ' 'Inputs: ' logfile$, the name of the log file ' 'Zachary Wolf '8/20/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write a page break character PRINT #filenum%, CHR$(12) 'Close the log file CLOSE filenum% END SUB SUB dmeasdl (dl!) '**************************************************************************** 'This subroutine performs one measurement of the integrated dipole strength. ' 'Output: ' dl!, the integrated dipole strength ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Simplify the notation nh% = nhardisplayP% 'Initialize data arrays DIM vm!(1 TO nh%) DIM vp!(1 TO nh%) 'Measure the coil voltage CALL coilmeas(nh%, fcoil!, vm!(), vp!()) 'Compute the integrated gradient CALL dcalcdl(nh%, fcoil!, vm!(), vp!(), v1!, dl!) 'Log the result CALL dlogdl(logfileP$, rcoilP!, nturnscoilP%, nrotaveP%, fcoil!, v1!, dl!) END SUB SUB dmeasdlav (dl!, sdl!) '**************************************************************************** 'This subroutine performs multiple measurements and returns average values 'and rms variations. ' 'Output: ' dl!, the average integrated dipole field strength ' sdl!, rms variation of dl ' 'Zachary Wolf '1/3/95 '**************************************************************************** 'Simplify the notation nm% = nmeasaveP% 'Initialize data arrays DIM dlmeas!(1 TO nm%) 'Loop over the measurements FOR i% = 1 TO nm% 'Measure the integrated dipole strength CALL dmeasdl(dlmeas!(i%)) 'End the loop over the measurements NEXT i% 'Compute averages dl! = 0! FOR i% = 1 TO nm% dl! = dl! + dlmeas!(i%) NEXT i% dl! = dl! / nm% 'Compute rms deviations sdl! = 0! FOR i% = 1 TO nm% sdl! = sdl! + (dlmeas!(i%) - dl!) ^ 2 NEXT i% sdl! = SQR(sdl! / nm%) 'Print the results to the screen PRINT PRINT "Integrated Dipole Strength:" PRINT "DL = "; dl!; " +- "; sdl!; " Tm" 'Write these results to the log file CALL dlogdlav(logfileP$, rcoilP!, nturnscoilP%, nrotaveP%, nmeasaveP%, dl!, sdl!) END SUB SUB dmeashar (nh%, bl!(), th!(), r!()) '**************************************************************************** 'This subroutine performs one harmonics measurement. ' 'Input: ' nh%, the number of harmonics to record ' 'Output: ' bl!(1 to nh%), the integrated strength of each harmonic at the coil radius (T) ' th!(1 to nh%), the angle of the first south pole of each harmonic wrt horizontal (deg) ' r!(1 to nh%), the ratio bl(n)/bl(1) at rcoil ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Initialize data arrays DIM vm!(1 TO nh%) DIM vp!(1 TO nh%) 'Measure the coil voltage CALL coilmeas(nh%, fcoil!, vm!(), vp!()) 'Compute the harmonics CALL dcalchar(nh%, fcoil!, vm!(), vp!(), bl!(), th!(), r!()) 'Log the results CALL dloghar(logfileP$, rcoilP!, nturnscoilP%, nh%, fcoil!, vm!(), vp!(), bl!(), th!(), r!()) END SUB SUB dmeasharav (nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) '**************************************************************************** 'This subroutine performs averave and rms harmonics measurements. ' 'Input: ' nh%, the number of harmonics to record ' 'Output: ' bl!(1 to nh%), the integrated strength of each harmonic at the coil radius (T) ' sbl!(1 to nh%), rms variation of bl ' th!(1 to nh%), the angle of the first south pole of each harmonic wrt horizontal (deg) ' sth!(1 to nh%), rms variation of th ' r!(1 to nh%), the ratio bl(n)/bl(1) at rcoil ' sr!(1 to nh%), rms variation of r ' 'Zachary Wolf '1/4/95 '**************************************************************************** 'Simplify the notation nm% = nmeasaveP% 'Initialize data arrays DIM bl1!(1 TO nh%) DIM th1!(1 TO nh%) DIM r1!(1 TO nh%) DIM blmeas!(1 TO nh%, 1 TO nm%) DIM thmeas!(1 TO nh%, 1 TO nm%) DIM rmeas!(1 TO nh%, 1 TO nm%) 'Loop over the measurements FOR i% = 1 TO nm% 'Measure the harmonics CALL dmeashar(nh%, bl1!(), th1!(), r1!()) 'Store the results FOR j% = 1 TO nh% blmeas!(j%, i%) = bl1!(j%) thmeas!(j%, i%) = th1!(j%) rmeas!(j%, i%) = r1!(j%) NEXT j% 'End the loop over the measurements NEXT i% 'Compute averages FOR j% = 1 TO nh% bl!(j%) = 0! th!(j%) = 0! r!(j%) = 0! FOR i% = 1 TO nm% bl!(j%) = bl!(j%) + blmeas!(j%, i%) th!(j%) = th!(j%) + thmeas!(j%, i%) r!(j%) = r!(j%) + rmeas!(j%, i%) NEXT i% bl!(j%) = bl!(j%) / nm% th!(j%) = th!(j%) / nm% r!(j%) = r!(j%) / nm% NEXT j% 'Compute rms deviations FOR j% = 1 TO nh% sbl!(j%) = 0! sth!(j%) = 0! sr!(j%) = 0! FOR i% = 1 TO nm% sbl!(j%) = sbl!(j%) + (blmeas!(j%, i%) - bl!(j%)) ^ 2 sth!(j%) = sth!(j%) + (thmeas!(j%, i%) - th!(j%)) ^ 2 sr!(j%) = sr!(j%) + (rmeas!(j%, i%) - r!(j%)) ^ 2 NEXT i% sbl!(j%) = SQR(sbl!(j%) / nm%) sth!(j%) = SQR(sth!(j%) / nm%) sr!(j%) = SQR(sr!(j%) / nm%) NEXT j% 'Print the results to the screen PRINT PRINT "Harmonics:" PRINT " N BLn sigBLn THspole sigTH BLn/BL1 sBLn/BL1" PRINT " (Gm) (Gm) (deg) (deg) (%) (%) " PRINT "--- -------+------- -------+------- -------+------- " IF nh% > 10 THEN nprint% = 10 ELSE nprint% = nh% FOR j% = 1 TO nprint% PRINT USING "###"; j%; PRINT USING " ###.###"; bl!(j%) * 10000!; PRINT USING " ###.###"; sbl!(j%) * 10000!; PRINT USING " ####.##"; th!(j%); PRINT USING " ####.##"; sth!(j%); PRINT USING " ###.###"; r!(j%) * 100!; PRINT USING " ###.###"; sr!(j%) * 100! NEXT j% 'Write the results to the log file CALL dlogharav(logfileP$, rcoilP!, nturnscoilP%, nrotaveP%, nmeasaveP%, nh%, bl!(), sbl!(), th!(), sth!(), r!(), sr!()) END SUB SUB dpltdlvsi (logfile$, magname$, run$, ni%, imag!(), dl!(), sdl!(), tf!(), stf!()) '**************************************************************************** 'This subroutine write a summary of the DL vs I measurements for plotting. ' 'Input: ' logfile$, the name of the log file ' magname$, the magnet name ' run$, the run number ' ni%, the number of currents ' imag!(1 to ni%), the measured currents ' dl!(1 to ni%), the integrated dipole strength at each current ' sdl!(1 to ni%), the standard deviation of dl ' tf!(1 to ni%), the transfer function at each current ' stf!(1 to ni%), the standard deviation of tf ' 'Zachary Wolf '7/16/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the title for plotting PRINT #filenum%, "/et g '" + magname$ + ", Run " + run$ + "'" PRINT #filenum%, ";i dl sdl tf stf" 'Write the values FOR i% = 1 TO ni% PRINT #filenum%, USING "####.#####"; imag!(i%); PRINT #filenum%, USING " ##.######"; dl!(i%); PRINT #filenum%, USING " ##.######"; sdl!(i%); PRINT #filenum%, USING " #.#######"; tf!(i%); PRINT #filenum%, USING " #.#######"; stf!(i%) NEXT i% 'Close the log file CLOSE filenum% END SUB SUB dpltharvsi (logfile$, magname$, run$, nh%, ni%, inom!(), rvsi!(), srvsi!()) '**************************************************************************** 'This subroutine write a summary of the harmonics measurements for plotting. ' 'Input: ' logfile$, the name of the log file ' magname$, the magnet name ' run$, the run number ' nh%, the number of harmonics to record ' ni%, the number of currents ' inom!(1 to ni%), the nominal currents the harmonics are measured at ' rvsi!(1 to nh%, 1 to ni%), BLn/BL1 vs n and I ' srvsi!(1 to nh%, 1 to ni%), standard deviation of rvsi! ' 'Zachary Wolf '8/16/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the title for plotting PRINT #filenum%, "/et g '" + magname$ + ", Run " + run$ + "'" PRINT #filenum%, ";n r sr r sr ... for different currents" 'Write the legends for the curves FOR i% = 1 TO ni% PRINT #filenum%, "/sa l 'I = "; PRINT #filenum%, USING "###"; inom!(i%); PRINT #filenum%, " A' " + STR$(2 * i%) NEXT i% 'Write the values FOR i% = 1 TO nh% PRINT #filenum%, USING "###"; i%; FOR j% = 1 TO ni% PRINT #filenum%, USING " ###.#######"; rvsi!(i%, j%); PRINT #filenum%, USING " ###.#######"; srvsi!(i%, j%); NEXT j% PRINT #filenum%, NEXT i% 'Close the log file CLOSE filenum% END SUB