示例#1
0
get_dpp = lambda b, bta: np.sqrt(bta.getCorrelation(5,5)) / (b.getSyncParticle().gamma()*b.mass()*b.getSyncParticle().beta()**2)
get_bunch_length = lambda b, bta: 4 * np.sqrt(bta.getCorrelation(4,4)) / (speed_of_light*b.getSyncParticle().beta())
get_eps_z = lambda b, bta: 1e9 * 4 * pi * bta.getEmittance(2) / (speed_of_light*b.getSyncParticle().beta())

output = Output_dictionary()
output.addParameter('turn', lambda: turn)
output.addParameter('intensity', lambda: bunchtwissanalysis.getGlobalMacrosize())
output.addParameter('n_mp', lambda: bunchtwissanalysis.getGlobalCount())
output.addParameter('gamma', lambda: bunch.getSyncParticle().gamma())
output.addParameter('mean_x', lambda: bunchtwissanalysis.getAverage(0))
output.addParameter('mean_xp', lambda: bunchtwissanalysis.getAverage(1))
output.addParameter('mean_y', lambda: bunchtwissanalysis.getAverage(2))
output.addParameter('mean_yp', lambda: bunchtwissanalysis.getAverage(3))
output.addParameter('mean_z', lambda: bunchtwissanalysis.getAverage(4))
output.addParameter('mean_dE', lambda: bunchtwissanalysis.getAverage(5))
output.addParameter('epsn_x', lambda: bunchtwissanalysis.getEmittanceNormalized(0))
output.addParameter('epsn_y', lambda: bunchtwissanalysis.getEmittanceNormalized(1))
output.addParameter('eps_z', lambda: get_eps_z(bunch, bunchtwissanalysis))
output.addParameter('bunchlength', lambda: get_bunch_length(bunch, bunchtwissanalysis))
output.addParameter('dpp_rms', lambda: get_dpp(bunch, bunchtwissanalysis))

if frozen or slicebyslice:
        output.addParameter('BE_intensity1', lambda: sc_params1['intensity'])
        output.addParameter('BE_epsn_x1', lambda: sc_params1['epsn_x'])
        output.addParameter('BE_epsn_y1', lambda: sc_params1['epsn_y'])
        output.addParameter('BE_dpp_rms1', lambda: sc_params1['dpp_rms'])

#-----------------------------------------------------------------------
# Define particle output dictionary - used to plot trapping
#-----------------------------------------------------------------------
particle_output = Particle_output_dictionary()
示例#2
0
file_writer.close()

b.dumpBunch(pre_list + "/initial_bunch_" + str(test_name) + ".dat")

ana = BunchTwissAnalysis()

f = open(pre_list + "/tracking_" + str(test_name) + ".txt", 'w')

for i in range(1000):

    ana.analyzeBunch(b)

    if rank == 0:
        f.write(
            str(i) + " " + str(ana.getEmittanceNormalized(0)) + " " +
            str(ana.getEmittanceNormalized(1)) + " " + str(ana.getBeta(0)) +
            " " + str(ana.getBeta(1)) + " " + str(lostbunch.getSize()) + "\n")

    lattice.trackBunch(b, paramsDict)

    if rank == 0:
        print("==========================")
        print("turn: " + str(i))
        print("lost: " + str(lostbunch.getSize()))
        print("remain: " + str(b.getSize()))
        print("charge: " + str(b.macroSize()))
        print("intensity: " + str(b.macroSize() * b.getSize() * size))
        print(
            str(ana.getEmittanceNormalized(0)) + " " +
            str(ana.getEmittanceNormalized(1)))
示例#3
0
output_dictionary.addParameter('gamma',
                               lambda: bunch.getSyncParticle().gamma())
output_dictionary.addParameter('mean_x',
                               lambda: bunchtwissanalysis.getAverage(0))
output_dictionary.addParameter('mean_xp',
                               lambda: bunchtwissanalysis.getAverage(1))
output_dictionary.addParameter('mean_y',
                               lambda: bunchtwissanalysis.getAverage(2))
output_dictionary.addParameter('mean_yp',
                               lambda: bunchtwissanalysis.getAverage(3))
output_dictionary.addParameter('mean_z',
                               lambda: bunchtwissanalysis.getAverage(4))
output_dictionary.addParameter('mean_dE',
                               lambda: bunchtwissanalysis.getAverage(5))
output_dictionary.addParameter(
    'epsn_x', lambda: bunchtwissanalysis.getEmittanceNormalized(0))
output_dictionary.addParameter(
    'epsn_y', lambda: bunchtwissanalysis.getEmittanceNormalized(1))
output_dictionary.addParameter(
    'eps_z', lambda: bunchtwissanalysis.getEmittance(2) /
    (speed_of_light * bunch.getSyncParticle().beta()) * 1e9 * 4 * pi)
output_dictionary.addParameter(
    'bunchlength', lambda: np.sqrt(bunchtwissanalysis.getCorrelation(4, 4)) /
    (speed_of_light * bunch.getSyncParticle().beta()) * 4)
output_dictionary.addParameter(
    'dpp_rms', lambda: np.sqrt(bunchtwissanalysis.getCorrelation(5, 5)) /
    (bunch.getSyncParticle().gamma() * bunch.mass() * bunch.getSyncParticle().
     beta()**2))

# save initial distribution
mainbunch_file = 'output/mainbunch_start.dat'
output_file = 'Output/output.dat'
output = Output_dictionary()
output.addParameter('turn', lambda: turn)
output.addParameter('intensity',
                    lambda: bunchtwissanalysis.getGlobalMacrosize())
output.addParameter('n_mp', lambda: bunchtwissanalysis.getGlobalCount())
output.addParameter('gamma', lambda: bunch.getSyncParticle().gamma())
output.addParameter('mean_x', lambda: bunchtwissanalysis.getAverage(0))
output.addParameter('mean_xp', lambda: bunchtwissanalysis.getAverage(1))
output.addParameter('mean_y', lambda: bunchtwissanalysis.getAverage(2))
output.addParameter('mean_yp', lambda: bunchtwissanalysis.getAverage(3))
output.addParameter('mean_z', lambda: bunchtwissanalysis.getAverage(4))
output.addParameter('mean_dE', lambda: bunchtwissanalysis.getAverage(5))
output.addParameter('epsn_x',
                    lambda: bunchtwissanalysis.getEmittanceNormalized(0))
output.addParameter('epsn_y',
                    lambda: bunchtwissanalysis.getEmittanceNormalized(1))
output.addParameter('eps_z', lambda: get_eps_z(bunch, bunchtwissanalysis))
output.addParameter('bunchlength',
                    lambda: get_bunch_length(bunch, bunchtwissanalysis))
output.addParameter('dpp_rms', lambda: get_dpp(bunch, bunchtwissanalysis))
if os.path.exists(output_file):
    output.import_from_matfile(output_file)

#----------------------------------------------------
# Injecting turn by turn
#----------------------------------------------------
print '\n\n now start injecting...'

for index_files in range(index_files, index_files_max + 1):
示例#5
0
        print("==========================")
    lattice.trackBunch(b, paramsDict)

for i in range(5000):

    ana.analyzeBunch(b)

    #if rank == 0:
    #    f.write(str(i) + " " + str(ana.getEmittanceNormalized(0)) + " " + str(ana.getEmittanceNormalized(1)) + " " + str(ana.getBeta(0)) + " " + str(ana.getBeta(1)) + " " + str(lostbunch.getSize()) + "\n")

    lattice.trackBunch(b, paramsDict)

    if rank == 0:
        print("==========================")
        print("turn: " + str(i))
        print("lost: " + str(lostbunch.getSize()))
        print("remain: " + str(b.getSize()))
        print("charge: " + str(b.macroSize()))
        print("intensity: " + str(b.macroSize() * b.getSize() * size))
        print(
            str(ana.getEmittanceNormalized(0)) + " " +
            str(ana.getEmittanceNormalized(1)))
        print("==========================")

    for j in range(b.getSize()):
        id = int(b.partAttrValue("ParticleIdNumber", j, 0))

        f = f_list[id]

        f.write(str(i) + " " + str(b.x(j)) + " " + str(b.y(j)) + "\n")