示例#1
0
def test_read_mcnp_wcomments():
    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

    read_materials = mats_from_inp('mcnp_inp_comments.txt')
    assert_equal(expected_material, read_materials[1])
示例#2
0
def uwuw_matlib(inp, out):
    mats = mats_from_inp(inp)
    uwuw_mats = {}
    for mat in mats.values():
        if isinstance(mat, MultiMaterial):
            m = mat._mats.keys()[0]
        else:
            m = mat
        mat_name = "m{0}".format(m.metadata["mat_number"])
        m.metadata["name"] = mat_name
        uwuw_mats[mat_name] = m
           
    ml = MaterialLibrary(uwuw_mats) 
    ml.write_hdf5(out, datapath='/material_library/materials', 
                       nucpath='/material_library/nucid')
示例#3
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)
示例#4
0
        for zaid, atomfraction in zip(zaids, atomfractions):
            f.write(zaid + '    ' + atomfraction + '\n')
        f.write('/m' + material_number + '\n')

    f.close()


parser = argparse.ArgumentParser()
parser.add_argument('-of',
                    '--output_filename',
                    type=str,
                    default='materials.h5')
args = parser.parse_args()
output_filename = args.output_filename

mcnp_lib_nbi_2017 = mats_from_inp("mcnp_models/DEMO_NBI_.i")
mcnp_lib = mats_from_inp("mcnp_models/demo.inp")
mcnp_lib_generic = mats_from_inp(
    "mcnp_models/2017_Generic_DEMO_MCNP_22_5deg_v1_1.txt")

my_material_library = MaterialLibrary()

#check_materials_are_the_same(mat1=mcnp_lib_generic[25],mat2=mcnp_lib_nbi_2017[25])

my_material_library['homogenised_magnet'] = mcnp_lib_generic[
    25].expand_elements()
#my_material_library['homogenised_magnet'].metadata='homogenised_magnet used in the central sol, poloidal and toroidal magnets'

my_material_library['SS-316L(N)-IG'] = mcnp_lib_generic[50].expand_elements()
# my_material_library['SS-316L(N)-IG'].metadata='SS-316L(N)-IG used in the magnet casing and vacuum vessel skin, cyrostat and NBI vessel'
示例#5
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 = mats_from_inp('mcnp_inp.txt')
    assert_equal(expected_material, read_materials[1])
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].comp,
        list(read_materials[2]._mats.keys())[0].comp)
    assert_equal(
        list(expected_multimaterial._mats.keys())[0].mass,
        list(read_materials[2]._mats.keys())[0].mass)
    assert_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,
        list(read_materials[2]._mats.keys())[1].comp)
    assert_equal(
        list(expected_multimaterial._mats.keys())[1].mass,
        list(read_materials[2]._mats.keys())[1].mass)
    assert_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)
示例#6
0
    material.metadata["table_ids"] = table_ids

    # Optionally output material information
    if (verbose):
        print material
        print material.mcnp()

    # Return the material
    return material


##############################
# Import materials from MCNP #
##############################

mat = pyne_mcnp.mats_from_inp(input_mcnp_file)

###################################
# Update materials for PyNE/DAGMC #
###################################

# Add necessary data to the MCNP materials

mat[1].density = 8.9
mat[1].metadata = {"name": "CuCrZr", "density_unit": "g/cm3"}
mat[1] = set_xs_library(mat[1], fendl3)

# Remove the pre-existing library file
os.system('rm Materials.h5m -f')

# Create a PyNE materials library object