Example #1
0
def nuclides(Z, A, data):

    symbol = chemicalElementMiscModule.symbolFromZ[Z]
    isotopeID = chemicalElementMiscModule.isotopeSymbolFromChemicalElementIDAndA(
        symbol, A)
    keys = random.sample([key for key in data], len(data))
    for index in keys:
        name = chemicalElementMiscModule.nuclideIDFromIsotopeSymbolAndIndex(
            isotopeID, index)
        nameLower = name[:1].lower() + name[1:]
        level = nuclideModule.particle(name)
        nucleus = level.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)
Example #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.
#
level = nuclideModule.particle('O16_e12')
database.add(level)

#
# Test adding an isotope to database.
#
isotope = isotopeModule.isotope('N15', 15)
database.add(isotope)
level = nuclideModule.particle('N15_e5')
database.add(level)

#
# Test adding a nuclear level to an isotope.
#
level = nuclideModule.particle('N15_e7')
database.add(level)
Example #3
0
from PoPs.quantities import quantity as quantityModule
from PoPs.quantities import mass as massModule
from PoPs.quantities import spin as spinModule
from PoPs.quantities import parity as parityModule
from PoPs.quantities import charge as chargeModule
from PoPs.quantities import halflife as halflifeModule
from PoPs.quantities import nuclearEnergyLevel as nuclearEnergyLevelModule

from PoPs.families import nuclide as nuclideModule

index = 3
name = chemicalElementMiscModule.nuclideIDFromIsotopeSymbolAndIndex(
    'O16', index)

level = nuclideModule.particle(name)
energy = nuclearEnergyLevelModule.double(
    'base', 6917100, quantityModule.stringToPhysicalUnit('eV'))
level.nucleus.energy.add(energy)

mass = massModule.double('base', 15.99491461956,
                         quantityModule.stringToPhysicalUnit('amu'))
level.mass.add(mass)

charge = chargeModule.integer('base', 0,
                              quantityModule.stringToPhysicalUnit('e'))
level.charge.add(charge)

halflife = halflifeModule.double('base', 1e100,
                                 quantityModule.stringToPhysicalUnit('s'))
level.halflife.add(halflife)