本文整理汇总了Python中pyne.material.Material.from_atom_frac方法的典型用法代码示例。如果您正苦于以下问题:Python Material.from_atom_frac方法的具体用法?Python Material.from_atom_frac怎么用?Python Material.from_atom_frac使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyne.material.Material
的用法示例。
在下文中一共展示了Material.from_atom_frac方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AtomicDensityToMassDensity
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import from_atom_frac [as 别名]
def AtomicDensityToMassDensity(heu_atom):
print "\n\n",heu_atom
print "========heu_atom molecular mass ",heu_atom.molecular_mass()
heu=Material()
heu.from_atom_frac(heu_atom)
print "\n\n",heu
print "ERROR: heu molecular mass is not correct heu.molecular_mass() = ", heu.molecular_mass()
heu.metadata=heu_atom.metadata
heu.metadata['density_g_per_cc']=heu.mass
heu.normalize()
return heu
示例2: test_from_atom_frac_meth
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import from_atom_frac [as 别名]
def test_from_atom_frac_meth():
h2o = {10010000: 2.0, 80160000: 1.0}
mat = Material()
mat.from_atom_frac(h2o)
assert_equal(mat.atoms_per_molecule, 3.0)
assert_equal(mat.comp[10010000], 0.11191487328808077)
assert_equal(mat.comp[80160000], 0.8880851267119192)
assert_equal(mat.mass, 18.01056468403)
assert_equal(mat.molecular_mass(), 18.01056468403)
h2 = Material({10010000: 1.0}, atoms_per_molecule=2.0)
h2o = {'O16': 1.0, h2: 1.0}
mat = Material()
mat.from_atom_frac(h2o)
assert_equal(mat.atoms_per_molecule, 3.0)
assert_equal(mat.comp[10010000], 0.11191487328808077)
assert_equal(mat.comp[80160000], 0.8880851267119192)
assert_equal(mat.molecular_mass(), 18.01056468403)
ihm = Material()
ihm.from_atom_frac({922350000: 0.5, 922380000: 0.5})
uox = {ihm: 1.0, 'O16': 2.0}
mat = Material()
mat.from_atom_frac(uox)
assert_equal(mat.atoms_per_molecule, 3.0)
assert_almost_equal(mat.comp[80160000], 0.11912625367051276, 16)
assert_almost_equal(mat.comp[922350000], 0.43763757904405304, 15)
assert_almost_equal(mat.comp[922380000], 0.44323616728543414, 15)
assert_almost_equal(mat.molecular_mass()/268.53718851614, 1.0, 15)
示例3: test_matlib_json
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import from_atom_frac [as 别名]
def test_matlib_json():
filename = "matlib.json"
water = Material()
water.from_atom_frac({10000000: 2.0, 80000000: 1.0})
water.metadata["name"] = "Aqua sera."
lib = {"leu": Material(leu), "nucvec": nucvec, "aqua": water}
wmatlib = MaterialLibrary(lib)
wmatlib.write_json(filename)
rmatlib = MaterialLibrary()
rmatlib.from_json(filename)
assert_equal(set(wmatlib), set(rmatlib))
for key in rmatlib:
assert_mat_almost_equal(wmatlib[key], rmatlib[key])
os.remove(filename)
示例4: test_from_atom_frac_meth
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import from_atom_frac [as 别名]
def test_from_atom_frac_meth():
h2o = {10010: 2.0, 80160: 1.0}
mat = Material()
mat.from_atom_frac(h2o)
assert_equal(mat.atoms_per_mol, 3.0)
assert_equal(mat.comp[10010], 0.11191487328808077)
assert_equal(mat.comp[80160], 0.8880851267119192)
assert_equal(mat.mass, 18.01056468403)
assert_equal(mat.molecular_weight(), 18.01056468403)
h2 = Material({10010: 1.0}, atoms_per_mol=2.0)
h2o = {'O16': 1.0, h2: 1.0}
mat = Material()
mat.from_atom_frac(h2o)
assert_equal(mat.atoms_per_mol, 3.0)
assert_equal(mat.comp[10010], 0.11191487328808077)
assert_equal(mat.comp[80160], 0.8880851267119192)
assert_equal(mat.molecular_weight(), 18.01056468403)
ihm = Material()
ihm.from_atom_frac({922350: 0.5, 922380: 0.5})
uox = {ihm: 1.0, 'O16': 2.0}
mat = Material()
mat.from_atom_frac(uox)
assert_equal(mat.atoms_per_mol, 3.0)
assert_almost_equal(mat.comp[80160], 0.11912625316479536, 16)
assert_almost_equal(mat.comp[922350], 0.43763757948940346, 15)
assert_almost_equal(mat.comp[922380], 0.44323616734580107, 15)
assert_almost_equal(mat.molecular_weight()/268.53718965614, 1.0, 15)
示例5: test_matlib_hdf5
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import from_atom_frac [as 别名]
def test_matlib_hdf5():
filename = "matlib.h5"
if filename in os.listdir('.'):
os.remove(filename)
water = Material()
water.from_atom_frac({10000000: 2.0, 80000000: 1.0})
water.metadata["name"] = "Aqua sera."
lib = {"leu": Material(leu), "nucvec": nucvec, "aqua": water}
wmatlib = MaterialLibrary(lib)
wmatlib.write_hdf5(filename)
rmatlib = MaterialLibrary()
rmatlib.from_hdf5(filename)
os.remove(filename)
# Round trip!
rmatlib.write_hdf5(filename)
wmatlib = MaterialLibrary(filename)
assert_equal(set(wmatlib), set(rmatlib))
for key in rmatlib:
assert_mat_almost_equal(wmatlib[key], rmatlib[key])
os.remove(filename)
示例6: test_natural_elements
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import from_atom_frac [as 别名]
def test_natural_elements():
water = Material()
water.from_atom_frac({10000000: 2.0, 80000000: 1.0})
expected_comp = {10000000: 0.11189838783149784, 80000000: 0.8881016121685023}
for key in expected_comp:
assert_almost_equal(water.comp[key], expected_comp[key])