当前位置: 首页>>代码示例>>Python>>正文


Python Material.molecular_weight方法代码示例

本文整理汇总了Python中pyne.material.Material.molecular_weight方法的典型用法代码示例。如果您正苦于以下问题:Python Material.molecular_weight方法的具体用法?Python Material.molecular_weight怎么用?Python Material.molecular_weight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyne.material.Material的用法示例。


在下文中一共展示了Material.molecular_weight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_from_atom_frac_meth

# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import molecular_weight [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)
开发者ID:AliZeineddine,项目名称:pyne,代码行数:31,代码来源:test_material.py

示例2: test_to_atom_frac

# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import molecular_weight [as 别名]
def test_to_atom_frac():
    h2o = {10010: 0.11191487328808077, 80160: 0.8880851267119192}
    mat = Material(h2o, atoms_per_mol=3.0)
    af = mat.to_atom_frac()
    assert_equal(mat.atoms_per_mol, 3.0)
    assert_equal(af[10010], 2.0)
    assert_equal(af[80160], 1.0)
    assert_equal(mat.molecular_weight(), 18.01056468403)    
开发者ID:AliZeineddine,项目名称:pyne,代码行数:10,代码来源:test_material.py

示例3: test_molecular_weight

# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import molecular_weight [as 别名]
    def test_molecular_weight(self):
        mat_empty = Material({})
        assert_equal(mat_empty.molecular_weight(), 0.0)

        mat_u238 = Material({922380: 1.0})
        mw_u238 = mat_u238.molecular_weight()
        try:
            assert_almost_equal(mw_u238, 238.050789466)
        except AssertionError:
            assert_almost_equal(mw_u238, 238.0)            

        mat_mixed = Material({922350: 0.5, 922380: 0.5})
        mw_mixed = mat_mixed.molecular_weight()
        try:
            assert_almost_equal(mw_mixed/236.547360417, 1.0, 4)            
        except AssertionError:
            assert_almost_equal(mw_mixed/236.5, 1.0, 4)
开发者ID:AliZeineddine,项目名称:pyne,代码行数:19,代码来源:test_material.py


注:本文中的pyne.material.Material.molecular_weight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。