Example #1
0
def test_get_material_lib_no_names():
    """Test get_material_lib without a provided nuc_names list.
    """

    # Path to hdf5 test file
    THIS_DIR = os.path.dirname(os.path.realpath(__file__))
    hdf5 = THIS_DIR + '/files_test_partisn/partisn_test_geom.h5m'
    data_hdf5path = '/materials'
    nuc_hdf5path = '/nucid'

    mat_lib, unique_names = partisn._get_material_lib(
        hdf5, data_hdf5path, nuc_hdf5path)
    mat_lib_expected = {'MERCURY1': {802020000: 1.2060451913893048e-02,
                                     802000000: 9.423512145483618e-03,
                                     802010000: 5.3498985962366465e-03,
                                     801960000: 6.24414427454006e-05,
                                     802040000: 2.7475463582858147e-03,
                                     801980000: 4.108325935058038e-03,
                                     801990000: 6.916609590819954e-03},
                        'HELIUMNA': {20040000: 2.4975599277878773e-05,
                                     20030000: 4.4414858514189387e-11}}
    expected_unique_names = {
        'mat:Helium, Natural': 'HELIUMNA', 'mat:Mercury': 'MERCURY1'}
    assert(unique_names == expected_unique_names)
    assert(mat_lib == mat_lib_expected)
Example #2
0
def test_get_material_lib_with_names():
    """Test get_material_lib with a provided nuc_names list.
    """

    # Path to hdf5 test file
    THIS_DIR = os.path.dirname(os.path.realpath(__file__))
    hdf5 = THIS_DIR + '/files_test_partisn/partisn_test_geom.h5m'
    data_hdf5path = '/materials'
    nuc_hdf5path = '/nucid'

    # nuc_names list
    names = {}
    names[800000000] = 'hg'
    names[20030000] = 'he3'
    names[20040000] = 'he4'

    mat_lib, unique_names = partisn._get_material_lib(
        hdf5, data_hdf5path, nuc_hdf5path, nuc_names=names)
    mat_lib_expected = {u'MERCURY1': {800000000: 4.066613534078662e-2},
                        u'HELIUMNA': {20040000: 2.4975599277878773e-05,
                                      20030000: 4.4414858514189387e-11}}
    expected_unique_names = {
        'mat:Helium, Natural': 'HELIUMNA', 'mat:Mercury': 'MERCURY1'}
    assert(unique_names == expected_unique_names)
    assert(mat_lib == mat_lib_expected)
Example #3
0
def test_get_material_lib_no_names():
    """Test get_material_lib without a provided nuc_names list."""

    # Path to hdf5 test file
    THIS_DIR = os.path.dirname(os.path.realpath(__file__))
    hdf5 = THIS_DIR + "/files_test_partisn/partisn_test_geom.h5m"
    data_hdf5path = "/materials"

    mat_lib, unique_names = partisn._get_material_lib(hdf5, data_hdf5path)
    mat_lib_expected = {
        "HELIUMNA": {
            20040000: 2.4975599277878773e-05,
            20030000: 4.4414858514189387e-11,
        },
        "MERCURY1": {
            802020000: 1.2060451913893048e-02,
            802000000: 9.423512145483618e-03,
            802010000: 5.3498985962366465e-03,
            801960000: 6.24414427454006e-05,
            802040000: 2.7475463582858147e-03,
            801980000: 4.108325935058038e-03,
            801990000: 6.916609590819954e-03,
        },
    }
    expected_unique_names = {
        "mat:Helium, Natural": "HELIUMNA",
        "mat:Mercury": "MERCURY1",
    }
    assert unique_names == expected_unique_names
    for matname, mat in mat_lib_expected.items():
        for nuc, frac in mat.items():
            assert_almost_equal(mat_lib[matname][nuc], frac)
Example #4
0
def test_get_material_lib_with_names():
    """Test get_material_lib with a provided nuc_names list."""

    # Path to hdf5 test file
    THIS_DIR = os.path.dirname(os.path.realpath(__file__))
    hdf5 = THIS_DIR + "/files_test_partisn/partisn_test_geom.h5m"
    data_hdf5path = "/materials"

    # nuc_names list
    names = {}
    names[800000000] = "hg"
    names[20030000] = "he3"
    names[20040000] = "he4"

    mat_lib, unique_names = partisn._get_material_lib(hdf5,
                                                      data_hdf5path,
                                                      nuc_names=names)
    mat_lib_expected = {
        "MERCURY1": {
            800000000: 4.066613534078662e-2
        },
        "HELIUMNA": {
            20040000: 2.4975599277878773e-05,
            20030000: 4.4414858514189387e-11,
        },
    }
    expected_unique_names = {
        "mat:Helium, Natural": "HELIUMNA",
        "mat:Mercury": "MERCURY1",
    }

    assert unique_names == expected_unique_names
    for matname, mat in mat_lib_expected.items():
        for nuc, frac in mat.items():
            assert_almost_equal(mat_lib[matname][nuc], frac)
Example #5
0
def test_get_material_lib_no_names():
    """Test get_material_lib without a provided nuc_names list.
    """
    
    # Path to hdf5 test file
    THIS_DIR = os.path.dirname(os.path.realpath(__file__))
    hdf5 = THIS_DIR + '/files_test_partisn/partisn_test_geom.h5m'
    data_hdf5path = '/materials'
    nuc_hdf5path = '/nucid'
    
    mat_lib = partisn._get_material_lib(hdf5, data_hdf5path, nuc_hdf5path)
    mat_lib_expected = {'mat:Mercury': {802020000:1.2060451913893048e-02, 
                                        802000000:9.423512145483618e-03,
                                        802010000:5.3498985962366465e-03, 
                                        801960000:6.24414427454006e-05, 
                                        802040000:2.7475463582858147e-03, 
                                        801980000:4.108325935058038e-03, 
                                        801990000:6.916609590819954e-03},
                        'mat:Helium, Natural':{20040000:2.4975599277878773e-05, 
                                            20030000:4.4414858514189387e-11}}
    assert(mat_lib == mat_lib_expected)
Example #6
0
def test_get_material_lib_with_names():
    """Test get_material_lib with a provided nuc_names list.
    """
    
    # Path to hdf5 test file
    THIS_DIR = os.path.dirname(os.path.realpath(__file__))
    hdf5 = THIS_DIR + '/files_test_partisn/partisn_test_geom.h5m'
    data_hdf5path = '/materials'
    nuc_hdf5path = '/nucid'
    
    # nuc_names list
    names = {}
    names[800000000] = 'hg'
    names[20030000] = 'he3'
    names[20040000] = 'he4'
    
    mat_lib = partisn._get_material_lib(hdf5, data_hdf5path, nuc_hdf5path, nuc_names=names)
    mat_lib_expected = {u'mat:Mercury':{800000000:4.066613534078662e-2}, 
                        u'mat:Helium, Natural':{20040000:2.4975599277878773e-05, 
                                                20030000:4.4414858514189387e-11}}
    assert(mat_lib == mat_lib_expected)