Example #1
0
bunch_tmp = Bunch()
bunch.copyEmptyBunchTo(bunch_tmp)
bunch_tmp.addPartAttr('ParticlePhaseAttributes')

#----------------------------------------------------
# Define twiss analysis and output dictionary
#----------------------------------------------------
bunchtwissanalysis = BunchTwissAnalysis() #Prepare the analysis class that will look at emittances, etc.
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'])
Example #2
0
# Twiss_at_parentnode_entrance = Lattice.getNodes()[parentnode_number-1].getParamsDict()
# tunes = TeapotTuneAnalysisNode("tune_analysis")
# tunes.assignTwiss(Twiss_at_parentnode_entrance['betax'], Twiss_at_parentnode_entrance['alphax'], Twiss_at_parentnode_entrance['etax'], Twiss_at_parentnode_entrance['etapx'], Twiss_at_parentnode_entrance['betay'], Twiss_at_parentnode_entrance['alphay'])
# addTeapotDiagnosticsNodeAsChild(Lattice, parentnode, tunes)
#

#----------------------------------------------------
# Define output dictionary
#----------------------------------------------------

output_dictionary = Output_dictionary()
output_dictionary.addParameter('turn', lambda: turn)
output_dictionary.addParameter('intensity',
                               lambda: bunchtwissanalysis.getGlobalMacrosize())
output_dictionary.addParameter('n_mp',
                               lambda: bunchtwissanalysis.getGlobalCount())
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(