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


Python Material.write_mcnp方法代码示例

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


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

示例1: test_write_mcnp

# 需要导入模块: from pyne.material import Material [as 别名]
# 或者: from pyne.material.Material import write_mcnp [as 别名]
def test_write_mcnp():
    if 'mcnp_mass_fracs.txt' in os.listdir('.'):
        os.remove('mcnp_mass_fracs.txt')

    leu = Material(nucvec={'U235': 0.04, 'U238': 0.96}, 
                   metadata={'mat_number': 2, 
                          'table_ids': {'92235':'15c', '92238':'25c'},
                          'mat_name':'LEU', 
                          'source':'Some URL',
                          'comments': ('this is a long comment that will definitly '
                                       'go over the 80 character limit, for science'),
                          'name':'leu'}, 
                   density=19.1)

    leu.write_mcnp('mcnp_mass_fracs.txt')
    leu.write_mcnp('mcnp_mass_fracs.txt', frac_type='atom')

    with open('mcnp_mass_fracs.txt') as f:
        written = f.read()
    expected = ('C name: leu\n'
                'C density = 19.1\n'
                'C source: Some URL\n'
                'C comments: this is a long comment that will definitly go over the 80 character\n'
                'C  limit, for science\n'
                'm2\n'
                '     92235.15c -4.0000E-02\n'
                '     92238.25c -9.6000E-01\n'
                'C name: leu\n'
                'C density = 19.1\n'
                'C source: Some URL\n'
                'C comments: this is a long comment that will definitly go over the 80 character\n'
                'C  limit, for science\n'
                'm2\n'
                '     92235.15c 4.0491E-02\n'
                '     92238.25c 9.5951E-01\n')
    assert_equal(written, expected)
    os.remove('mcnp_mass_fracs.txt')
开发者ID:NukespudWork,项目名称:pyne,代码行数:39,代码来源:test_material.py


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