Пример #1
0
def _import_bunch(lattice, data):
    from synergia.foundation import pconstants
    if not lattice.has_reference_particle() \
       or lattice.get_reference_particle().get_charge() == 0:
        # create a default reference particle, proton,energy=1.5
        lattice.set_reference_particle(
            foundation.Reference_particle(
                pconstants.proton_charge,
                foundation.Four_momentum(pconstants.mp, 1.5)
            )
        )
    ref = lattice.get_reference_particle()
    four_momentum = ref.get_four_momentum()
    bunch = data.models.bunch
    bunch.update({
        'beam_definition': 'gamma',
        'charge': ref.get_charge(),
        'gamma': format_float(four_momentum.get_gamma()),
        'energy': format_float(four_momentum.get_total_energy()),
        'momentum': format_float(four_momentum.get_momentum()),
        'beta': format_float(four_momentum.get_beta()),
        'mass': format_float(four_momentum.get_mass()),
        'particle': 'other',
    })
    if bunch.mass == pconstants.mp:
        if bunch.charge == pconstants.proton_charge:
            bunch.particle = 'proton'
        #TODO(pjm): antiproton (anti-proton) not working with synergia
    elif bunch.mass == pconstants.me:
        bunch.particle = 'positron' if bunch.charge == pconstants.positron_charge else 'electron'
    elif bunch.mass == pconstants.mmu:
        bunch.particle = 'posmuon' if bunch.charge == pconstants.antimuon_charge else 'negmuon'
Пример #2
0
def _import_bunch(lattice, data):
    from synergia.foundation import pconstants
    if not lattice.has_reference_particle():
        # create a default reference particle, proton,energy=1.5
        lattice.set_reference_particle(
            foundation.Reference_particle(
                pconstants.proton_charge,
                foundation.Four_momentum(pconstants.mp, 1.5)))
    ref = lattice.get_reference_particle()
    bunch = data['models']['bunch']
    bunch['beam_definition'] = 'gamma'
    bunch['charge'] = ref.get_charge()
    four_momentum = ref.get_four_momentum()
    bunch['gamma'] = format_float(four_momentum.get_gamma())
    bunch['energy'] = format_float(four_momentum.get_total_energy())
    bunch['momentum'] = format_float(four_momentum.get_momentum())
    bunch['beta'] = format_float(four_momentum.get_beta())
    bunch['mass'] = format_float(four_momentum.get_mass())
    bunch['particle'] = 'other'
    if bunch['mass'] == pconstants.mp:
        if bunch['charge'] == pconstants.proton_charge:
            bunch['particle'] = 'proton'
        #TODO(pjm): antiproton (anti-proton) not working with synergia
    elif bunch['mass'] == pconstants.me:
        bunch['particle'] = 'positron' if bunch[
            'charge'] == pconstants.positron_charge else 'electron'
    elif bunch['mass'] == pconstants.mmu:
        bunch['particle'] = 'posmuon' if bunch[
            'charge'] == pconstants.antimuon_charge else 'negmuon'
Пример #3
0
def _calc_bunch_parameters(bunch):
    bunch_def = bunch.beam_definition
    bunch_enums = get_enums(_SCHEMA, 'BeamDefinition')
    mom = foundation.Four_momentum(bunch.mass)
    _calc_particle_info(bunch)
    try:
        if bunch_def == bunch_enums.energy:
            mom.set_total_energy(bunch.energy)
        elif bunch_def == bunch_enums.momentum:
            mom.set_momentum(bunch.momentum)
        elif bunch_def == bunch_enums.gamma:
            mom.set_gamma(bunch.gamma)
        else:
            assert False, 'invalid bunch def: {}'.format(bunch_def)
        bunch.gamma = format_float(mom.get_gamma())
        bunch.energy = format_float(mom.get_total_energy())
        bunch.momentum = format_float(mom.get_momentum())
        bunch.beta = format_float(mom.get_beta())
    except Exception as e:
        bunch[bunch_def] = ''
    return {
        'bunch': bunch,
    }