def driftTest(): rl = lc.getReferenceLattice() vals = np.zeros((6, 1, 3, 100)) n = np.zeros((1, 100)) n[0, :] = [0.1 * x for x in range(100)] for j in range(100): rl = lc.getReferenceLattice() rl.addMarkerDef('IP1') rl.addElement(name='IP1', pos=j * 0.1) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('IP1', 'ip1')) loadValues(vals, 0, j, diff, mad, six2mad) return n, vals
def exampleTest(): nbr_turns = 10 E0_GeV = 15 mad_init_coords = (0.001, 0.002, 0.003, 0.004, 0.005, 0.0) l = lc.Lattice(20) l.addMultipoleDef(name='qf', order=2, KN=0.11755705) l.addMultipoleDef(name='qd', order=2, KN=-0.11755705) l.addRFCavityDef(name='cav', VOLT=100, LAG=0.0, L=0.0, HARMON=100, FREQ=0) l.addElement(name='qd', pos=10) l.addElement(name='cav', pos=10.001) l.addElement(name='qf', pos=19.9999) l_s = l.getLatticeDefinition() diff = csm.compare('element_test', nbr_turns, E0_GeV, mad_init_coords, printToFile=1, lattice=l_s, norm='', verbose=0, all_files=0, trk_element=('cav', 'cav')) print(diff)
def testMatrix(): rl = lc.getReferenceLattice() kick = np.zeros(6) rm = np.eye(6) vals = np.zeros((6, 6, 3, 100)) n = np.zeros((6, 100)) for k in range(6): n[k, :] = [0.0001 * (x + 1) for x in range(100)] for i in range(6): for j in range(100): kick = np.zeros(6) kick[i] = (j + 1) * 0.0001 rl.addMatrixDef(name='trkstrt', L=0.0, KICK=kick, RM=rm) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, i, j, diff, mad, six2mad) return n, vals
def testKicker(): rl = lc.getReferenceLattice() vals = np.zeros((6, 3, 3, 100)) n = np.zeros((3, 100)) n[0, :] = [0.0003 * (x + 1) for x in range(100)] for j in range(100): rl.addKickerDef(name='trkstrt', HKICK=0.0003 * (j + 1), VKICK=0, L=0, TILT=0) rl.addElement(name='trkstrt', pos=0.01) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 0, j, diff, mad, six2mad) n[1, :] = [0.0003 * (x + 1) for x in range(100)] for j in range(100): rl.addKickerDef(name='trkstrt', HKICK=0, VKICK=0.0003 * (j + 1), L=0, TILT=0) rl.addElement(name='trkstrt', pos=0.01) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 1, j, diff, mad, six2mad) n[2, :] = [np.pi * x / 50 for x in range(100)] for j in range(100): rl.addKickerDef(name='trkstrt', HKICK=0.003, VKICK=0, L=0, TILT=np.pi * j / 50) rl.addElement(name='trkstrt', pos=0.01) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 2, j, diff, mad, six2mad) return n, vals
def testSolenoid(): rl = lc.getReferenceLattice() vals = np.zeros((6, 3, 3, 100)) n = np.zeros((3, 100)) n[0, :] = [0.1 * x for x in range(100)] for j in range(100): rl.addSolenoidDef(name='trkstrt', KS=j * 0.1, KSI=0.000001, L=0.0) rl.addElement(name='trkstrt', pos=0.0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 0, j, diff, mad, six2mad) n[1, :] = [0.01 * x for x in range(100)] for j in range(100): rl.addSolenoidDef(name='trkstrt', KS=0.000001, KSI=j * 0.01, L=0.0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 1, j, diff, mad, six2mad) n[2, :] = [0.005 * x for x in range(100)] for j in range(100): rl.addSolenoidDef(name='trkstrt', KS=j * 0.005, KSI=j * 0.005, L=0.0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 2, j, diff, mad, six2mad) return n, vals
def testRFCavity(): rl = lc.getReferenceLattice() vals = np.zeros((6, 3, 3, 100)) n = np.zeros((3, 100)) n[0, :] = range(1, 101) for j in range(100): rl.addRFCavityDef(name='trkstrt', VOLT=j + 1, LAG=0.25, L=0, HARMON=100, FREQ=0) rl.addElement(name='trkstrt', pos=0.0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 0, j, diff, mad, six2mad) n[1, :] = [0.01 * x for x in range(100)] for j in range(100): rl.addRFCavityDef(name='trkstrt', VOLT=100, LAG=0.01 * j, L=0, HARMON=100, FREQ=0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 1, j, diff, mad, six2mad) n[2, :] = range(1, 101) for j in range(100): rl.addRFCavityDef(name='trkstrt', VOLT=100, LAG=0.25, L=0, HARMON=j + 1, FREQ=0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 2, j, diff, mad, six2mad) return n, vals
def testMultipole(orde): rl = lc.getReferenceLattice() vals = np.zeros((6, 4, 3, 100)) n = np.zeros((4, 100)) n[0, :] = [0.001 * x for x in range(1, 101)] for j in range(100): rl.addMultipoleDef(name='trkstrt', order=orde, KN=(j + 1) * 0.0008, KS=0, TILT=0, THICK=False) rl.addElement(name='trkstrt', pos=0.0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 0, j, diff, mad, six2mad) n[1, :] = [0.001 * x for x in range(1, 101)] for j in range(100): rl.addMultipoleDef(name='trkstrt', order=orde, KN=0, KS=(j + 1) * 0.0008, TILT=0, THICK=False) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 1, j, diff, mad, six2mad) n[2, :] = [np.pi * 0.02 * x for x in range(100)] for j in range(100): rl.addMultipoleDef(name='trkstrt', order=orde, KN=0.008, KS=0, TILT=str(0.02 * j) + '*PI', THICK=False) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 2, j, diff, mad, six2mad) n[3, :] = [np.pi * 0.02 * x for x in range(100)] for j in range(100): rl.addMultipoleDef(name='trkstrt', order=orde, KN=0, KS=0.008, TILT=str(0.02 * j) + '*pi', THICK=False) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1) loadValues(vals, 3, j, diff, mad, six2mad) return n, vals
def testRFMultipole(orde): symb = ('', 'd', 'q', 's', 'o') rl = lc.getReferenceLattice() vals = np.zeros((6, 7, 3, 100)) n = np.zeros((7, 100)) n[0, :] = [0.0002 * x for x in range(1, 101)] for j in range(100): rl.addRFMultipoleDef(name='trkstrt', order=orde, VOLT=0, LAG=0.25, HARMON=0, FREQ=200, TILT=0, KN=0.0002 * (j + 1), KS=0.0, PN=0.0, PS=0.0) rl.addElement(name='trkstrt', pos=0.0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('trkstrt', 'trkstrt' + symb[orde])) loadValues(vals, 0, j, diff, mad, six2mad) n[1, :] = [0.0002 * x for x in range(1, 101)] for j in range(100): rl.addRFMultipoleDef(name='trkstrt', order=orde, VOLT=0, LAG=0.25, HARMON=0, FREQ=200, TILT=0, KN=0.0, KS=0.0002 * (j + 1), PN=0.0, PS=0.0) rl.addElement(name='trkstrt', pos=0.0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('trkstrt', 'trkstrt' + symb[orde] + 's')) loadValues(vals, 1, j, diff, mad, six2mad) n[2, :] = [2 * (x + 1) for x in range(100)] for j in range(100): rl.addRFMultipoleDef(name='trkstrt', order=orde, VOLT=0, LAG=0.25, HARMON=0, FREQ=2 * (j + 1), TILT=0, KN=0.02, KS=0.0, PN=0.0, PS=0.0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('trkstrt', 'trkstrt' + symb[orde])) loadValues(vals, 2, j, diff, mad, six2mad) n[3, :] = [x * 0.01 for x in range(100)] for j in range(100): rl.addRFMultipoleDef(name='trkstrt', order=orde, VOLT=0, LAG=0.25, HARMON=0, FREQ=200, TILT=0, KN=0.02, KS=0.0, PN=0.01 * j, PS=0.0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('trkstrt', 'trkstrt' + symb[orde])) loadValues(vals, 3, j, diff, mad, six2mad) n[4, :] = [np.pi * x / 50 for x in range(100)] for j in range(100): rl.addRFMultipoleDef(name='trkstrt', order=orde, VOLT=0, LAG=0.25, HARMON=0, FREQ=200, TILT=np.pi * j / 50, KN=0.02, KS=0.0, PN=0.0, PS=0.0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('trkstrt', 'trkstrt' + symb[orde])) loadValues(vals, 4, j, diff, mad, six2mad) n[5, :] = [np.pi * x / 50 for x in range(100)] for j in range(100): rl.addRFMultipoleDef(name='trkstrt', order=orde, VOLT=0, LAG=0.25, HARMON=0, FREQ=200, TILT=np.pi * j / 50, KN=0.0, KS=0.02, PN=0.0, PS=0.0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('trkstrt', 'trkstrt' + symb[orde] + 's')) loadValues(vals, 5, j, diff, mad, six2mad) n[6, :] = [0.02 * x for x in range(100)] for j in range(100): rl.addRFMultipoleDef(name='trkstrt', order=orde, VOLT=0.02 * j, LAG=0.25, HARMON=0, FREQ=200, TILT=0, KN=0.02, KS=0.0, PN=0.0, PS=0.0) rl.addElement(name='trkstrt', pos=0) rl_s = rl.getLatticeDefinition() diff, mad, six2mad = csm.compare('element_test', nbr_turns, energy_GeV, init_coords, 0, rl_s, norm='', verbose=1, all_files=1, trk_element=('trkstrt', 'trkstrt' + symb[orde])) loadValues(vals, 6, j, diff, mad, six2mad) return n, vals