本文整理汇总了Python中pyne.material.Material.to_atom_frac方法的典型用法代码示例。如果您正苦于以下问题:Python Material.to_atom_frac方法的具体用法?Python Material.to_atom_frac怎么用?Python Material.to_atom_frac使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyne.material.Material
的用法示例。
在下文中一共展示了Material.to_atom_frac方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_atom_frac
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import to_atom_frac [as 别名]
def test_to_atom_frac():
h2o = {10010000: 0.11191487328808077, 80160000: 0.8880851267119192}
mat = Material(h2o, atoms_per_molecule=3.0)
af = mat.to_atom_frac()
assert_equal(mat.atoms_per_molecule, 3.0)
assert_equal(af[10010000], 2.0)
assert_equal(af[80160000], 1.0)
assert_equal(mat.molecular_mass(), 18.01056468403)
示例2: transmute
# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import to_atom_frac [as 别名]
def transmute(self, x, t=None, phi=None, tol=None, log=None, *args, **kwargs):
"""Transmutes a material into its daughters.
Parameters
----------
x : Material or similar
Input material for transmutation.
t : float
Transmutations time [sec].
phi : float or array of floats
Neutron flux vector [n/cm^2/sec]. Currently this must either be
a scalar or match the group structure of EAF.
tol : float
Tolerance level for chain truncation.
log : file-like or None
The log file object should be written. A None imples the log is
not desired.
Returns
-------
y : Material
The output material post-transmutation.
"""
if not isinstance(x, Material):
x = Material(x)
if t is not None:
self.t = t
if phi is not None:
self.phi = phi
if log is not None:
self.log = log
if tol is not None:
self.tol = tol
x_atoms = x.to_atom_frac()
y_atoms = {}
for nuc, adens in x_atoms.items():
# Find output for root of unit density and scale all output by
# actual nuclide density and add to final output.
partial = self._transmute_partial(nuc)
for part_nuc, part_adens in partial.items():
y_atoms[part_nuc] = part_adens * adens + y_atoms.get(part_nuc, 0.0)
mw_x = x.molecular_mass()
y = from_atom_frac(y_atoms, atoms_per_molecule=x.atoms_per_molecule)
# even though it doesn't look likt it, the following line is actually
# mass_y = MW_y * mass_x / MW_x
y.mass *= x.mass / mw_x
return y