示例#1
0
mpi_mkdir_p('lost')

#----------------------------------------------
# Generate Lattice (MADX + PTC)
#----------------------------------------------
if not rank:
	os.system("/afs/cern.ch/eng/sl/MAD-X/pro/releases/5.02.00/madx-linux64 < Input/SIS18.madx")
orbit_mpi.MPI_Barrier(comm)

#----------------------------------------------
# Initialize a Teapot-Style PTC lattice
#----------------------------------------------
PTC_File = "SIS_18_BENCHMARK.flt"
Lattice = PTC_Lattice("MACHINE")
Lattice.readPTC(PTC_File)
readScriptPTC('Input/time.ptc')

paramsDict = {}
paramsDict["length"]=Lattice.getLength()/Lattice.nHarm

#----------------------------------------------
# Add apertures
#----------------------------------------------
position = 0
for node in Lattice.getNodes():
	myaperturenode = TeapotApertureNode(1, 10, 10, position)
	node.addChildNode(myaperturenode, node.ENTRANCE)
	node.addChildNode(myaperturenode, node.BODY)
	node.addChildNode(myaperturenode, node.EXIT)
	position += node.getLength()
# nb of turns to run after injection:
nb_turn_after_inj = 10

#----------------------------------------------
turn = index_files_max + 1
turns_max = index_files_max + nb_turn_after_inj
turns_print = xrange(-1, turns_max, 2)

#----------------------------------------------
# Initialize a Teapot-Style PTC lattice
#----------------------------------------------
PTC_File = 'Input/PSB_FLAT_Pert_r0.TXT'
Lattice = PTC_Lattice("PSB")
Lattice.readPTC(PTC_File)
readScriptPTC('ptc/fringe.txt')
readScriptPTC('ptc/time.txt')
readScriptPTC('ptc/chrom.txt')
readScriptPTC('ptc/ramp_magnet.ptc')
readScriptPTC('ptc/ramp_cavities.ptc')
readScriptPTC('ptc/energize_lattice.ptc')
readScriptPTC('ptc/twiss_script.ptc')
readScriptPTC('ptc/write_FINAL_SETTINGS.ptc')

paramsDict = {}
paramsDict["length"] = Lattice.getLength() / Lattice.nHarm
print '\nLattice parameters ...'
print '  circumference: \t', Lattice.getLength(), 'm'
print '  alphax0: \t\t', Lattice.alphax0
print '  betax0: \t\t', Lattice.betax0, 'm'
print '  alphay0: \t\t', Lattice.alphay0
# Generate PTC RF table
#-----------------------------------------------------------------------
print '\nstart RF file on MPI process: ', rank
from lib.write_ptc_table import write_RFtable
from simulation_parameters import RFparameters as RF 
write_RFtable('input/RF_table.ptc', *[RF[k] for k in ['harmonic_factors','time','Ekin_GeV','voltage_MV','phase']])

# Initialize a Teapot-Style PTC lattice
#-----------------------------------------------------------------------
print '\nstart PTC Flat file on MPI process: ', rank
PTC_File = 'PTC-PyORBIT_flat_file.flt'
Lattice = PTC_Lattice("PS")
Lattice.readPTC(PTC_File)

readScriptPTC('Input/fringe.ptc')
readScriptPTC('Input/time.ptc')
readScriptPTC('Input/ramp_cavities.ptc')

# Create a dictionary of parameters
#-----------------------------------------------------------------------
print '\nparamsDict on MPI process: ', rank
paramsDict = {}
paramsDict["length"] = Lattice.getLength()/Lattice.nHarm

# Add apertures
#-----------------------------------------------------------------------
print '\nAdd apertures on MPI process: ', rank
position = 0
for node in Lattice.getNodes():
	# This creates an aperture node. Shape: 1 = circle, 2 = ellipse,
示例#4
0
#----------------------------------------------
# Initialize a Teapot-Style PTC lattice
#----------------------------------------------

PTC_File = "BUMP_STUDIES.flt"
length_of_name = len(PTC_File)
ptc_init_(PTC_File, length_of_name - 1)
Lattice = PTC_Lattice("PS")
Lattice.readPTC(PTC_File)

# readScriptPTC('Input/fringe.txt')
# readScriptPTC('Input/time.txt')
# readScriptPTC('Input/chrom.ptc')
#~ readScriptPTC('madx/ptc/chrom.txt')
readScriptPTC('Input/PS-TIME-TABLES.PTC')

print '\nLattice parameters ...'
print '  circumference: \t', Lattice.getLength(), 'm'
print '  alphax0: \t\t', Lattice.alphax0
print '  betax0: \t\t', Lattice.betax0, 'm'
print '  alphay0: \t\t', Lattice.alphay0
print '  betay0: \t\t', Lattice.betay0, 'm'
print '  Dx0: \t\t\t', Lattice.etax0, 'm'
print '  Dpx0: \t\t', Lattice.etapx0
print '  harm. number: \t', Lattice.nHarm
print '  nodes: \t\t', Lattice.nNodes

paramsDict = {}
paramsDict["length"] = Lattice.getLength() / Lattice.nHarm
'''
示例#5
0
updateParamsPTC(Lattice, b)

synchronousSetPTC(-1)

"""
synchronousAfterPTC(-1)
"""

Turns = 1
for i in range(Turns):
    print i
    trackBunchThroughLatticePTC(Lattice, b, PhaseLength)

"""
trackBunchInRangePTC(Lattice, b, PhaseLength, 0, 500)

trackBunchInRangePTC(Lattice, b, PhaseLength, 501, 932)

trackBunchInRangePTC(Lattice, b, PhaseLength, 0, 10)

trackBunchInRangePTC(Lattice, b, PhaseLength, 11, 20)

trackBunchInRangePTC(Lattice, b, PhaseLength, 21, 932)
"""

b.dumpBunch("bunch_temp.dat")
bunch_pyorbit_to_orbit(Lattice.getLength(), b, "bunch_final.dat")

readScriptPTC("ptc_data_test_0.txt")
示例#6
0
b.macroSize(total_macroSize / nParticlesGlobal)
print nParticlesGlobal, b.macroSize()

updateParamsPTC(Lattice, b)

synchronousSetPTC(-1)
"""
synchronousAfterPTC(-1)
"""

Turns = 1
for i in range(Turns):
    print i
    trackBunchThroughLatticePTC(Lattice, b, PhaseLength)
"""
trackBunchInRangePTC(Lattice, b, PhaseLength, 0, 500)

trackBunchInRangePTC(Lattice, b, PhaseLength, 501, 932)

trackBunchInRangePTC(Lattice, b, PhaseLength, 0, 10)

trackBunchInRangePTC(Lattice, b, PhaseLength, 11, 20)

trackBunchInRangePTC(Lattice, b, PhaseLength, 21, 932)
"""

b.dumpBunch("bunch_temp.dat")
bunch_pyorbit_to_orbit(Lattice.getLength(), b, "bunch_final.dat")

readScriptPTC("ptc_data_test_0.txt")