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)
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: mass, energy, charge, halflife, spin, parity = data[index] name = nucleusModule.nucleusNameFromNucleusNameAndIndex( isotopeID, index) nucleus = nucleusModule.particle(name, index) energy = nuclearEnergyLevelModule.double( 'base', energy, quantityModule.stringToPhysicalUnit('keV')) 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')) level.charge.add(charge) if (halflife is not None): time, unit = halflife.split() halflife = halflifeModule.double( 'base', float(time), quantityModule.stringToPhysicalUnit(unit)) level.halflife.add(halflife) if (spin is not None): spin = spinModule.fraction( 'base', spinModule.fraction.toValueType(spin), quantityModule.stringToPhysicalUnit('hbar')) level.spin.add(spin) if (parity is not None): parity = parityModule.integer( 'base', parity, quantityModule.stringToPhysicalUnit('')) level.parity.add(parity) database.add(level)
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')) level.charge.add(charge)
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)