Exemplo n.º 1
0
def nuclearLevel(Z, A, data):

    symbol = chemicalElementModule.symbolFromZ[Z]
    isotopeID = isotopeModule.isotopeIDFromElementIDAndA(symbol, A)
    keys = random.sample([key for key in data], len(data))
    for index in keys:
        name = nucleusModule.levelNameFromIsotopeNameAndIndex(isotopeID, index)
        nameLower = name[:1].lower() + name[1:]
        nucleus = nucleusModule.particle(nameLower, index)
        level = nuclearLevelModule.particle(name, nucleus)

        atomicMass, nuclearMass, energy, charge, halflife, spin, parity = data[
            index]

        energy = nuclearEnergyLevelModule.double(
            'base', energy, quantityModule.stringToPhysicalUnit('keV'))
        level.energy.add(energy)

        if (atomicMass is not None):
            mass = massModule.double(
                'base', atomicMass, quantityModule.stringToPhysicalUnit('amu'))
            level.mass.add(mass)

        if (nuclearMass is not None):
            mass = massModule.double(
                'base', nuclearMass,
                quantityModule.stringToPhysicalUnit('amu'))
            nucleus.mass.add(mass)

        if (charge is not None):
            charge = chargeModule.integer(
                'base', charge, quantityModule.stringToPhysicalUnit('e'))
            nucleus.charge.add(charge)

        if (halflife is not None):
            if (halflife == 'stable'):
                halflife = halflifeModule.string(
                    'base', halflife, quantityModule.stringToPhysicalUnit('s'))
            else:
                time, unit = halflife.split()
                halflife = halflifeModule.double(
                    'base', float(time),
                    quantityModule.stringToPhysicalUnit(unit))
            nucleus.halflife.add(halflife)

        if (spin is not None):
            spin = spinModule.fraction(
                'base', spinModule.fraction.toValueType(spin),
                quantityModule.stringToPhysicalUnit('hbar'))
            nucleus.spin.add(spin)

        if (parity is not None):
            parity = parityModule.integer(
                'base', parity, quantityModule.stringToPhysicalUnit(''))
            nucleus.parity.add(parity)

        database.add(level)
Exemplo n.º 2
0
lepton = leptonModule.particle( 'mu-_anti', generation = 'muonic' )
database.add( lepton )

#
# Test adding baryons to database.
#
baryon = baryonModule.particle( 'p' )
database.add( baryon )

baryon = baryonModule.particle( 'n_anti' )
database.add( baryon )

#
# Test adding a nuclear level to database.
#
nucleus = nucleusModule.particle( 'o16_e12', index = '12' )
level = nuclearLevelModule.particle( 'O16_e12', nucleus )
database.add( level )

#
# Test adding an isotope to database.
#
isotope = isotopeModule.suite( 'N15', '15' )
database.add( isotope )
nucleus = nucleusModule.particle( 'n15_e5', index = '5' )
level = nuclearLevelModule.particle( 'N15_e5', nucleus )
database.add( level )

#
# Test adding a nuclear level to an isotope.
#
Exemplo n.º 3
0
from PoPs.families import nucleus as nucleusModule
from PoPs.families import nuclearLevel as nuclearLevelModule
from PoPs.groups import isotope as isotopeModule

A = '16'
isotopeID = isotopeModule.isotopeIDFromElementIDAndA('O', A)
isotope = isotopeModule.suite(isotopeID, A)

data = [['0', 15.99491461956, 0, None, None, None, None],
        ['1', None, 6049400, None, None, None, None],
        ['2', None, 6129893, None, None, None, None],
        ['3', None, 6917100, None, None, None, None]]

for index, mass, energy, charge, halflife, spin, parity in data:
    name = nucleusModule.nucleusNameFromNucleusNameAndIndex(isotopeID, index)
    nucleus = nucleusModule.particle(name, index)
    energy = nuclearEnergyLevelModule.double(
        'base', energy, quantityModule.stringToPhysicalUnit('eV'))
    nucleus.energy.add(energy)

    name = nucleusModule.levelNameFromIsotopeNameAndIndex(isotopeID, index)
    level = nuclearLevelModule.particle(name, nucleus)

    if (mass is not None):
        mass = massModule.double('base', mass,
                                 quantityModule.stringToPhysicalUnit('amu'))
        level.mass.add(mass)

    if (charge is not None):
        charge = chargeModule.integer('base', charge,
                                      quantityModule.stringToPhysicalUnit('e'))
Exemplo n.º 4
0
        pops.add(chemicalElementModule.suite.parseXMLNodeAsClass(
            child, [], []))


for child in element:
    if (child.tag == 'aliases'):
        aliases(child)
    elif (child.tag == 'gaugeBosons'):
        gaugeBosons(child)
    elif (child.tag == 'baryons'):
        baryons(child)
    elif (child.tag == 'chemicalElements'):
        chemicalElements(child)

for chemicalElement in pops.chemicalElements:
    for isotope in chemicalElement:
        for level in isotope:
            nucleusName = level.id
            nucleusName = nucleusName[0].lower() + nucleusName[1:]
            nucleus = nucleusModule.particle(nucleusName, '0')
            level.nucleus = nucleus

fOut = open('p.xml', 'w')
fOut.write(pops.toXML() + '\n')
fOut.close()

pops2 = databaseModule.database.readFile('p.xml')
fOut = open('p2.xml', 'w')
fOut.write(pops2.toXML() + '\n')
fOut.close()
Exemplo n.º 5
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)