예제 #1
0
def test_multi_material():
    mat1 = Material(nucvec={
        120240: 0.3,
        300000: 0.2,
        10010: 0.1
    },
                    density=2.71)
    mat2 = Material(nucvec={60120: 0.2, 280640: 0.5, 10010: 0.12}, density=8.0)
    mix = MultiMaterial({mat1: 0.5, mat2: 0.21})
    mat3 = mix.mix_by_mass()
    mat4 = mix.mix_by_volume()

    assert_equal(mat3.density, -1.0)
    assert_equal(mat3.comp[10010], 0.16065498683155846)
    assert_equal(mat3.comp[60120], 0.0721401580212985)
    assert_equal(mat3.comp[120240], 0.352112676056338)
    assert_equal(mat3.comp[280640], 0.18035039505324627)
    assert_equal(mat3.comp[300000], 0.2347417840375587)

    assert_equal(mat4.density, -1.0)
    assert_equal(mat4.comp[10010], 0.15541581280722197)
    assert_equal(mat4.comp[60120], 0.13501024631333625)
    assert_equal(mat4.comp[120240], 0.2232289950576606)
    assert_equal(mat4.comp[280640], 0.33752561578334067)
    assert_equal(mat4.comp[300000], 0.14881933003844042)
예제 #2
0
def test_multimaterial_mix_density():
    mat1 = Material(nucvec={120240000:0.3, 300000000:0.2, 10010000:0.1}, density=1.0)
    mat2 = Material(nucvec={60120000:0.2, 280640000:0.5, 10010000:0.12}, density=2.0)
    # mixing by hand to get density 1.5 when 50:50 by volume of density 1 & 2
    mix = MultiMaterial({mat1:0.5, mat2:0.5})
    mat3 = mix.mix_by_volume()
    # calculated mass fracs by hand, same problem as above stated in mass fraction terms
    # rather than volume fraction terms.
    mix = MultiMaterial({mat1:1/3., mat2:2/3.})
    mat4 = mix.mix_by_mass()

    assert_equal(mat3.density, 1.5)
    assert_equal(mat4.density, 1.5)

    assert_equal(mat3.density, mat4.density)
예제 #3
0
def test_multimaterial_mix_composition():
    mat1 = Material(nucvec={120240000:0.3, 300000000:0.2, 10010000:0.1}, density=2.71)
    mat2 = Material(nucvec={60120000:0.2, 280640000:0.5, 10010000:0.12}, density=8.0)
    mix = MultiMaterial({mat1:0.5, mat2:0.21})
    mat3 = mix.mix_by_mass()
    mat4 = mix.mix_by_volume()

    assert_equal(mat3.comp[10010000], 0.16065498683155846)
    assert_equal(mat3.comp[60120000], 0.0721401580212985)
    assert_equal(mat3.comp[120240000], 0.352112676056338)
    assert_equal(mat3.comp[280640000], 0.18035039505324627)
    assert_equal(mat3.comp[300000000], 0.2347417840375587)

    assert_equal(mat4.comp[10010000], 0.15541581280722197)
    assert_equal(mat4.comp[60120000], 0.13501024631333625)
    assert_equal(mat4.comp[120240000], 0.2232289950576606)
    assert_equal(mat4.comp[280640000], 0.33752561578334067)
    assert_equal(mat4.comp[300000000], 0.14881933003844042)
예제 #4
0
def test_multimaterial_mix_density():
    mat1 = Material(nucvec={
        120240000: 0.3,
        300000000: 0.2,
        10010000: 0.1
    },
                    density=1.0)
    mat2 = Material(nucvec={
        60120000: 0.2,
        280640000: 0.5,
        10010000: 0.12
    },
                    density=2.0)
    # mixing by hand to get density 1.5 when 50:50 by volume of density 1 & 2
    mix = MultiMaterial({mat1: 0.5, mat2: 0.5})
    mat3 = mix.mix_by_volume()
    # calculated mass fracs by hand, same problem as above stated in mass fraction terms
    # rather than volume fraction terms.
    mix = MultiMaterial({mat1: 1 / 3., mat2: 2 / 3.})
    mat4 = mix.mix_by_mass()

    assert_equal(mat3.density, 1.5)
    assert_equal(mat4.density, 1.5)

    assert_equal(mat3.density, mat4.density)
예제 #5
0
#m1.density = 1.037 
#matlib["mat:m1/rho:1.0E+00"] = m1
#print m1


he = Material({'He': 1.0})
he = he.expand_elements()
he.name = "he"
he.density = 0.000166
matlib["he"] = he
matlib["m3"] = he
print he

#m4 = Material({'He': 1.0})
#m4 = m4.expand_elements()
#m4.name = "mat:m4/rho:1.7E-4"
#m4.density = 0.000166
#matlib["m4"] = m4
#print m4

#steel_he = MultiMaterial({he:0.75, ss316:0.25}).mix_by_mass()
#steel_he.name = "steel_he"
#matlib["steel_he"] = steel_he
m4 = MultiMaterial({he:0.75, ss316:0.25}).mix_by_volume()
m4.name = "m4"
matlib["m4"] = m4
print m4


matlib.write_hdf5("basic_mat_lib_3.h5")
예제 #6
0
def test_read_mcnp():
    expected_material = Material(nucvec={
        922350000: 0.04,
        922380000: 0.96
    },
                                 mass=-1.0,
                                 density=19.1,
                                 metadata={
                                     "comments":
                                     (" first line of comments second line of "
                                      "comments third line of comments forth "
                                      "line of comments"),
                                     "mat_number":
                                     "1",
                                     "name":
                                     " leu",
                                     "source":
                                     " Some http://URL.com",
                                     "table_ids": {
                                         '922350': "15c"
                                     }
                                 })
    expected_material.mass = -1.0  # to avoid reassignment to +1.0
    expected_material_default_lib = Material(
        {
            10000000: 0.037298334378933776,
            60000000: 0.6666767493126631,
            80000000: 0.29602491630840305
        }, 54.04749412269001, 1.1, 6.0, {
            "mat_number": "3",
            "HLIB": "42h",
            "NLIB": "60c",
            "PLIB": "01p",
            "table_ids": {}
        })
    expected_multimaterial = MultiMaterial({
        Material({
            10000000: 0.1118983878322976,
            80000000: 0.8881016121677024
        }, -1.0, 0.9, 3, {
                     "comments": (" Here are comments the comments "
                                  "continue here are more even more"),
                     "mat_number":
                     "2",
                     "name":
                     " water",
                     "source":
                     " internet",
                     "table_ids": {
                         '10000': "05c"
                     }
                 }):
        1,
        Material({
            10000000: 0.1118983878322976,
            80000000: 0.8881016121677024
        }, -1.0, 1.0021552889251644, 3, {
                     "comments": (" Here are comments the comments "
                                  "continue here are more even more"),
                     "mat_number":
                     "2",
                     "name":
                     " water",
                     "source":
                     " internet",
                     "table_ids": {
                         '10000': "05c"
                     }
                 }):
        1,
        Material({
            10000000: 0.1118983878322976,
            80000000: 0.8881016121677024
        }, -1.0, 1.1, 3, {
                     "comments": (" Here are comments the comments "
                                  "continue here are more even more"),
                     "mat_number":
                     "2",
                     "name":
                     " water",
                     "source":
                     " internet",
                     "table_ids": {
                         '10000': "05c"
                     }
                 }):
        1
    })

    read_materials = mats_from_inp('mcnp_inp.txt')
    assert_almost_equal(expected_material, read_materials[1])
    assert_equal(expected_material_default_lib, read_materials[3])
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].comp.keys(),
        list(read_materials[2]._mats.keys())[0].comp.keys())
    for i in range(2):
        assert_almost_equal(
            list(list(
                expected_multimaterial._mats.keys())[0].comp.values())[i],
            list(list(read_materials[2]._mats.keys())[0].comp.values())[i])
    assert_almost_equal(
        list(expected_multimaterial._mats.keys())[0].mass,
        list(read_materials[2]._mats.keys())[0].mass)
    assert_almost_equal(
        list(expected_multimaterial._mats.keys())[0].density,
        list(read_materials[2]._mats.keys())[0].density)
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].atoms_per_molecule,
        list(read_materials[2]._mats.keys())[0].atoms_per_molecule)
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].metadata,
        list(read_materials[2]._mats.keys())[0].metadata)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].comp.keys(),
        list(read_materials[2]._mats.keys())[1].comp.keys())
    for i in range(2):
        assert_almost_equal(
            list(list(
                expected_multimaterial._mats.keys())[1].comp.values())[i],
            list(list(read_materials[2]._mats.keys())[1].comp.values())[i])
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].mass,
        list(read_materials[2]._mats.keys())[1].mass)
    assert_almost_equal(
        list(expected_multimaterial._mats.keys())[1].density,
        list(read_materials[2]._mats.keys())[1].density)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].atoms_per_molecule,
        list(read_materials[2]._mats.keys())[1].atoms_per_molecule)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].metadata,
        list(read_materials[2]._mats.keys())[1].metadata)
    assert_almost_equal(
        list(expected_multimaterial._mats.keys())[2].density,
        list(read_materials[2]._mats.keys())[2].density)
예제 #7
0
def test_read_mcnp():
    expected_material = Material(nucvec={
        922350000: 0.04,
        922380000: 0.96
    },
                                 mass=-1.0,
                                 density=19.1,
                                 metadata={
                                     "comments":
                                     (" first line of comments second line of "
                                      "comments third line of comments forth "
                                      "line of comments"),
                                     "mat_number":
                                     "1",
                                     "name":
                                     " leu",
                                     "source":
                                     " Some http://URL.com",
                                     "table_ids": {
                                         '922350': "15c"
                                     }
                                 })
    expected_material.mass = -1.0  # to avoid reassignment to +1.0

    expected_multimaterial = MultiMaterial({
        Material({
            10000000: 0.11189838783149784,
            80000000: 0.8881016121685023
        }, -1.0, 0.9, 3, {
                     "comments": (" Here are comments the comments "
                                  "continue here are more even more"),
                     "mat_number":
                     "2",
                     "name":
                     " water",
                     "source":
                     " internet",
                     "table_ids": {
                         '10000': "05c"
                     }
                 }):
        1,
        Material({
            10000000: 0.11189838783149784,
            80000000: 0.8881016121685023
        }, -1.0, 1.0021552889223864, 3, {
                     "comments": (" Here are comments the comments "
                                  "continue here are more even more"),
                     "mat_number":
                     "2",
                     "name":
                     " water",
                     "source":
                     " internet",
                     "table_ids": {
                         '10000': "05c"
                     }
                 }):
        1
    })

    read_materials = read_mcnp_inp('mcnp_inp.txt')
    assert_equal(expected_material, read_materials[0])
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].comp,
        list(read_materials[1]._mats.keys())[0].comp)
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].mass,
        list(read_materials[1]._mats.keys())[0].mass)
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].density,
        list(read_materials[1]._mats.keys())[0].density)
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].atoms_per_molecule,
        list(read_materials[1]._mats.keys())[0].atoms_per_molecule)
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].metadata,
        list(read_materials[1]._mats.keys())[0].metadata)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].comp,
        list(read_materials[1]._mats.keys())[1].comp)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].mass,
        list(read_materials[1]._mats.keys())[1].mass)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].density,
        list(read_materials[1]._mats.keys())[1].density)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].atoms_per_molecule,
        list(read_materials[1]._mats.keys())[1].atoms_per_molecule)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].metadata,
        list(read_materials[1]._mats.keys())[1].metadata)