Esempio n. 1
0
from PoPs.families import gaugeBoson as gaugeBosonModule
from PoPs.families import lepton as leptonModule
from PoPs.families import baryon as baryonModule
from PoPs.families import nucleus as nucleusModule
from PoPs.families import nuclearLevel as nuclearLevelModule

from PoPs.groups import isotope as isotopeModule
from PoPs.groups import chemicalElement as chemicalElementModule

database = databaseModule.database( 'test', '1.2.3' )

#
# Test adding an isotope to database.
#
photon = gaugeBosonModule.particle( 'photon' )
database.add( photon )

#
# Test adding leptons to database.
#
lepton = leptonModule.particle( 'e-', generation = 'electronic' )
database.add( lepton )

lepton = leptonModule.particle( 'mu-_anti', generation = 'muonic' )
database.add( lepton )

#
# Test adding baryons to database.
#
baryon = baryonModule.particle( 'p' )
Esempio n. 2
0
def getPoPsParticle(info,
                    ZA,
                    name=None,
                    levelIndex=None,
                    level=0.,
                    levelUnit='MeV'):

    if (levelIndex not in ['c', 's', None]):
        levelIndex = int(levelIndex)
        if (levelIndex < 0):
            raise Exception('levelIndex = %d must be >= 0' % levelIndex)

    particle = None

    if (ZA in [0, 17]): ZA = 7
    if (name is not None):
        pass
    elif (ZA == 1):
        particle = baryonModule.particle('n')
        addParticleData(particle, info, 1.00866491574, "1/2", 1, 0, 881.5)
        name = particle.id
    elif (ZA == 7):
        particle = gaugeBosonModule.particle(IDsPoPsModule.photon)
        addParticleData(particle, info, 0.0, "1", 1, 0, halflifeModule.STABLE)
        name = particle.id
    elif (ZA == 8):
        particle = leptonModule.particle('e+', generation='electronic')
        # BRB need to make it 'e-_anti' and alias to 'e+'.
        #        particle = leptonModule.particle( 'e-_anti', generation = 'electronic' )
        addParticleData(particle, info, 5.485799090e-4, "1/2", -1, 1,
                        halflifeModule.STABLE)
        name = particle.id
    elif (ZA == 9):
        particle = leptonModule.particle('e-', generation='electronic')
        addParticleData(particle, info, 5.485799090e-4, "1/2", 1, -1,
                        halflifeModule.STABLE)
        name = particle.id
    elif (ZA in [99120, 99125]):
        name = ZAToName(ZA)
        particle = unorthodoxModule.particle(name)
        mass = massModule.double(info.PoPsLabel, 117.5,
                                 quantityModule.stringToPhysicalUnit('amu'))
        particle.mass.add(mass)
    else:
        name = ZAToName(ZA)
        if (levelIndex is None):
            levelIndex = 0
            level = 0.
        if (level < 0.):
            raise Exception(
                'Negative value = %s for continuum is not allowed' % level)
        if (levelIndex in ['c', 's']):  # to continuum or sum of all levels.
            level = PQUModule.PQU(
                PQUModule.pqu_float.surmiseSignificantDigits(level), levelUnit)
            name += "_%s" % levelIndex
        else:
            level = PQUModule.PQU(
                PQUModule.pqu_float.surmiseSignificantDigits(level), levelUnit)
            name += '_e%d' % levelIndex

    nucleus = None
    if ((particle is None) and (name not in info.PoPs)):

        if (level is not None):  # Add a nuclearLevel/isotope.
            baseName = name.split('_')[
                0]  # Always need to add ground state before excited level.
            if ('natural' in name):
                baseName = '_'.join(name.split('_')[:2])
            elif ('FissionProduct' in name):
                baseName = name.split('_')[0]

            index = levelIndex
            if (level.getValueAs('MeV') == 0.): index = 0

            particle = nuclearLevelModule.particle(name)
            charge = chargeModule.integer(info.PoPsLabel, 0,
                                          chargeModule.baseUnit)
            particle.charge.add(charge)

            nucleusName = name[0].lower() + name[1:]
            nucleus = nucleusModule.particle(nucleusName, str(levelIndex))
            energy = nuclearEnergyLevelModule.double(info.PoPsLabel,
                                                     float(level), level.unit)
            nucleus.energy.add(energy)
            charge = chargeModule.integer(info.PoPsLabel, ZA / 1000,
                                          chargeModule.baseUnit)
            nucleus.charge.add(charge)
            particle.nucleus = nucleus
            addNucleusInfoForLightNuclei(ZA, nucleus, info)
        else:
            if (particle is None):
                if ('FissionProduct' in name):
                    particleOrLevel = gnd.xParticle.FissionProduct(
                        name, mass=massUnit, attributes=particleQualifiers)
                elif ('TNSL' in name):
                    particleOrLevel = gnd.xParticle.thermalNeutronScatteringLawIsotope(
                        name, mass=massUnit, attributes=particleQualifiers)
                else:
                    particleOrLevel = gnd.xParticle.isotope(
                        name, mass=massUnit, attributes=particleQualifiers)
    else:
        if (particle is None): particle = info.PoPs[name]

    if (name not in info.PoPs): info.PoPs.add(particle)

    if (isinstance(particle, nuclearLevelModule.particle)):
        if (particle.intIndex == 0): particle = particle.getAncestor()

    return (particle)