def test_multimaterial_attributes_from_material_objects_and_openmc_materials( self): # tests that multimaterials made from material objects and neutronics # materials have the same properties test_material_1 = nmm.MultiMaterial( "test_material_1", materials=[nmm.Material("Li4SiO4"), nmm.Material("Be12Ti")], fracs=[0.5, 0.5], percent_type="vo", ).openmc_material test_material_2 = nmm.MultiMaterial( "test_material_2", materials=[ nmm.Material("Li4SiO4").openmc_material, nmm.Material("Be12Ti").openmc_material, ], fracs=[0.5, 0.5], percent_type="vo", ).openmc_material assert test_material_1.density == test_material_2.density assert test_material_1.nuclides == test_material_2.nuclides
def test_packing_fraction_for_multimaterial_function(self): test_material_5 = nmm.MultiMaterial( "test_material_5", materials=[nmm.Material("tungsten"), nmm.Material("eurofer")], fracs=[0.5, 0.5], ).openmc_material test_material_6 = nmm.MultiMaterial( "test_material_6", materials=[ nmm.Material("tungsten", packing_fraction=1), nmm.Material("eurofer", packing_fraction=1), ], fracs=[0.5, 0.5], ).openmc_material assert test_material_5.density == test_material_6.density test_material_7 = nmm.MultiMaterial( "test_material_7", materials=[ nmm.Material("tungsten", packing_fraction=0.5), nmm.Material("eurofer", packing_fraction=0.5), ], fracs=[0.5, 0.5], ).openmc_material assert test_material_7.density == pytest.approx( test_material_5.density * 0.5)
def test_mutlimaterial_material_tag_setting(self): test_material = nmm.MultiMaterial(materials=[ nmm.Material('Pb842Li158', temperature_in_K=500), nmm.Material('SiC') ], fracs=[0.5, 0.5]) assert test_material.material_tag is None test_material.material_tag = 'tag_set_after_creation' assert test_material.material_tag == 'tag_set_after_creation' test_material.openmc_material assert test_material.openmc_material.name == 'tag_set_after_creation' test_material = nmm.MultiMaterial(materials=[ nmm.Material('Pb842Li158', temperature_in_K=500), nmm.Material('SiC') ], fracs=[0.5, 0.5], material_tag='tag_set_on_creation') assert test_material.material_tag == 'tag_set_on_creation' test_material.openmc_material assert test_material.openmc_material.name == 'tag_set_on_creation'
def test_density_of_mixed_two_packed_crystals(self): test_material_1 = nmm.Material(material_name="Li4SiO4") test_material_packed_1 = nmm.Material(material_name="Li4SiO4", packing_fraction=0.65) assert (test_material_1.openmc_material.density * 0.65 == test_material_packed_1.openmc_material.density) test_material_2 = nmm.Material(material_name="Be12Ti") test_material_packed_2 = nmm.Material(material_name="Be12Ti", packing_fraction=0.35) assert (test_material_2.openmc_material.density * 0.35 == test_material_packed_2.openmc_material.density) mixed_packed_crystals = nmm.MultiMaterial( material_tag="mixed_packed_crystals", materials=[test_material_packed_1, test_material_packed_2], fracs=[0.75, 0.25], percent_type="vo", ) assert mixed_packed_crystals.openmc_material.density == pytest.approx( (test_material_1.openmc_material.density * 0.65 * 0.75) + (test_material_2.openmc_material.density * 0.35 * 0.25), rel=0.01, )
def setUp(self): # makes the 3d geometry self.my_reactor = paramak.BallReactor( inner_bore_radial_thickness=1, inboard_tf_leg_radial_thickness=30, center_column_shield_radial_thickness=60, divertor_radial_thickness=50, inner_plasma_gap_radial_thickness=30, plasma_radial_thickness=300, outer_plasma_gap_radial_thickness=30, firstwall_radial_thickness=3, blanket_radial_thickness=100, blanket_rear_wall_radial_thickness=3, elongation=2.75, triangularity=0.5, rotation_angle=360, ) # makes a homogenised material for the blanket from lithium lead and # eurofer self.blanket_material = nmm.MultiMaterial( fracs=[0.8, 0.2], materials=[ nmm.Material('SiC'), nmm.Material('eurofer') ]) self.source = openmc.Source() # sets the location of the source to x=0 y=0 z=0 self.source.space = openmc.stats.Point((0, 0, 0)) # sets the direction to isotropic self.source.angle = openmc.stats.Isotropic() # sets the energy distribution to 100% 14MeV neutrons self.source.energy = openmc.stats.Discrete([14e6], [1])
def test_json_dump_works(self): test_material = nmm.MultiMaterial( "test_material", materials=[ nmm.Material("tungsten", packing_fraction=0.6), nmm.Material("eurofer", packing_fraction=0.8), ], fracs=[0.3, 0.7], ) assert isinstance(json.dumps(test_material), str)
def too_small_fracs(): """checks a ValueError is raised when the fracs are above 1""" nmm.MultiMaterial( "test_material", materials=[ nmm.Material("tungsten", packing_fraction=0.6), nmm.Material("eurofer", packing_fraction=0.8), ], fracs=[0.3, 0.65], )
def test_multimaterial_vs_mix_materials(self): test_material_11 = nmm.MultiMaterial( "test_material_11", materials=[nmm.Material("tungsten"), nmm.Material("eurofer")], fracs=[0.5, 0.5], ).openmc_material test_material_12 = openmc.Material.mix_materials( name="test_material_12", materials=[ nmm.Material("tungsten").openmc_material, nmm.Material("eurofer").openmc_material, ], fracs=[0.5, 0.5], percent_type="vo", ) assert test_material_11.density == test_material_12.density test_material_13 = nmm.MultiMaterial( "test_material_13", materials=[ nmm.Material("tungsten", packing_fraction=0.6), nmm.Material("eurofer", packing_fraction=0.8), ], fracs=[0.3, 0.7], ).openmc_material test_material_14 = openmc.Material.mix_materials( name="test_material_14", materials=[ nmm.Material("tungsten", packing_fraction=0.6).openmc_material, nmm.Material("eurofer", packing_fraction=0.8).openmc_material, ], fracs=[0.3, 0.7], percent_type="vo", ) assert test_material_13.density == test_material_14.density
def test_density_of_mixed_materials_from_density_equation(self): test_material = nmm.Material("H2O", temperature_in_C=25, pressure_in_Pa=100000) test_mixed_material = nmm.MultiMaterial( material_tag="test_mixed_material", materials=[test_material], fracs=[1]) assert test_material.openmc_material.density == pytest.approx( test_mixed_material.openmc_material.density)
def test_serpent_multimaterial_type(self): test_material = nmm.MultiMaterial( "test_material", materials=[nmm.Material("Li4SiO4"), nmm.Material("Be12Ti")], fracs=[0.50, 0.50], percent_type="vo", ) assert len(test_material.serpent_material) > 100 assert isinstance(test_material.serpent_material, str)
def test_too_small_packing_fraction(): """checks a ValueError is raised when the packing_fraction is the too large""" nmm.MultiMaterial("test_material", materials=[ nmm.Material("tungsten", packing_fraction=0.6), nmm.Material("eurofer", packing_fraction=0.8), ], fracs=[0.3, 0.7], packing_fraction=-0.1)
def test_incorrect_packing_fraction(): """checks a ValueError is raised when the packing_fraction is the wrong type""" nmm.MultiMaterial("test_material", materials=[ nmm.Material("tungsten", packing_fraction=0.6), nmm.Material("eurofer", packing_fraction=0.8), ], fracs=[0.3, 0.7], packing_fraction="1")
def test_packing_fraction_of_a_multimaterial(self): test_material_6 = nmm.MultiMaterial( "test_material_6", materials=[ nmm.Material("tungsten", packing_fraction=0.34), nmm.Material("eurofer", packing_fraction=0.60), ], fracs=[0.5, 0.5], ).openmc_material test_material_7 = nmm.MultiMaterial( "test_material_7", materials=[ nmm.Material("tungsten", packing_fraction=0.34), nmm.Material("eurofer", packing_fraction=0.60), ], fracs=[0.5, 0.5], packing_fraction=0.25, ).openmc_material assert test_material_6.get_mass_density() * 0.25 == pytest.approx( test_material_7.get_mass_density())
def test_make_multimaterial_from_material_objects(self): # tests that a multimaterial can be created by passing Material objects # into the MultiMaterial function test_material = nmm.MultiMaterial( "test_material", materials=[nmm.Material("Li4SiO4"), nmm.Material("Be12Ti")], fracs=[0.50, 0.50], percent_type="vo", ) assert isinstance(test_material, openmc.Material) is False assert isinstance(test_material.openmc_material, openmc.Material)
def test_json_dump_contains_correct_values(self): test_material = nmm.MultiMaterial( "test_material", materials=[ nmm.Material("tungsten", packing_fraction=0.6), nmm.Material("eurofer", packing_fraction=0.8), ], fracs=[0.3, 0.7], ) test_material_in_json_form = test_material.to_json() assert test_material_in_json_form["material_tag"] == "test_material" assert len(test_material_in_json_form["materials"]) == 2 assert test_material_in_json_form["fracs"] == [0.3, 0.7] assert test_material_in_json_form["percent_type"] == "vo" assert test_material_in_json_form["packing_fraction"] == 1.0
def test_density_of_mixed_two_packed_and_non_packed_crystals(self): test_material_1 = nmm.Material(material_name="Li4SiO4") test_material_1_packed = nmm.Material(material_name="Li4SiO4", packing_fraction=0.65) mixed_material = nmm.MultiMaterial( material_tag="mixed_material", materials=[test_material_1, test_material_1_packed], fracs=[0.2, 0.8], percent_type="vo", ) assert mixed_material.openmc_material.density == pytest.approx( (test_material_1.openmc_material.density * 0.2) + (test_material_1.openmc_material.density * 0.65 * 0.8))
def test_json_dump_contains_correct_keys(self): test_material = nmm.MultiMaterial( "test_material", materials=[ nmm.Material("tungsten", packing_fraction=0.6), nmm.Material("eurofer", packing_fraction=0.8), ], fracs=[0.3, 0.7], ) test_material_in_json_form = test_material.to_json() assert "material_tag" in test_material_in_json_form.keys() assert "materials" in test_material_in_json_form.keys() assert "fracs" in test_material_in_json_form.keys() assert "percent_type" in test_material_in_json_form.keys() assert "packing_fraction" in test_material_in_json_form.keys()
def test_temperature_from_C_in_multimaterials(self): """checks that the temperature set in C ends up in the temperature attribute of the openmc multimaterials""" test_material = nmm.MultiMaterial("test_material", materials=[ nmm.Material("tungsten"), nmm.Material("eurofer"), ], fracs=[0.3, 0.7], temperature_in_C=10) assert test_material.temperature_in_K == 283.15 assert test_material.temperature_in_C == 10 assert test_material.openmc_material.temperature == 283.15 line_by_line_material = test_material.serpent_material.split("\n") assert line_by_line_material[0].split()[-1] == "283.15" assert line_by_line_material[0].split()[-2] == "tmp"
def test_temperature_from_K_in_multimaterials(self): """checks that the temperature set in K ends up in the temperature attribute of the openmc multimaterials""" test_material = nmm.MultiMaterial("test_material", materials=[ nmm.Material("tungsten"), nmm.Material("eurofer"), ], fracs=[0.3, 0.7], temperature_in_K=300) assert test_material.temperature_in_K == 300 assert test_material.temperature_in_C == pytest.approx(26.85) assert test_material.openmc_material.temperature == 300 line_by_line_material = test_material.serpent_material.split("\n") assert line_by_line_material[0].split()[-1] == "300" assert line_by_line_material[0].split()[-2] == "tmp"
def test_density_of_mixed_one_packed_crystal_and_one_non_crystal(self): test_material_1 = nmm.Material(material_name="H2O", temperature_in_C=25, pressure_in_Pa=100000) test_material_2 = nmm.Material(material_name="Li4SiO4") test_material_2_packed = nmm.Material(material_name="Li4SiO4", packing_fraction=0.65) mixed_packed_crystal_and_non_crystal = nmm.MultiMaterial( material_tag="mixed_packed_crystal_and_non_crystal", materials=[test_material_1, test_material_2_packed], fracs=[0.5, 0.5], percent_type="vo", ) assert (mixed_packed_crystal_and_non_crystal.openmc_material.density == pytest.approx((test_material_1.openmc_material.density * 0.5) + (test_material_2.openmc_material.density * 0.65 * 0.5)))
def make_model_and_simulate(): """Makes a neutronics Reactor model and simulates the TBR""" # makes the 3d geometry my_reactor = paramak.BallReactor( inner_bore_radial_thickness=1, inboard_tf_leg_radial_thickness=30, center_column_shield_radial_thickness=60, divertor_radial_thickness=50, inner_plasma_gap_radial_thickness=30, plasma_radial_thickness=300, outer_plasma_gap_radial_thickness=30, firstwall_radial_thickness=3, blanket_radial_thickness=100, blanket_rear_wall_radial_thickness=3, elongation=2.75, triangularity=0.5, number_of_tf_coils=16, rotation_angle=360, ) # makes a homogenised material for the blanket from lithium lead and # eurofer blanket_material = nmm.MultiMaterial(fracs=[0.8, 0.2], materials=[ nmm.Material( 'Pb842Li158', enrichment=90, temperature_in_K=500), nmm.Material('eurofer') ]) source = openmc.Source() # sets the location of the source to x=0 y=0 z=0 source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0)) # sets the direction to isotropic source.angle = openmc.stats.Isotropic() # sets the energy distribution to 100% 14MeV neutrons source.energy = openmc.stats.Discrete([14e6], [1]) # makes the neutronics material neutronics_model = paramak.NeutronicsModel( geometry=my_reactor, source=source, materials={ 'inboard_tf_coils_mat': 'copper', 'center_column_shield_mat': 'WC', 'divertor_mat': 'eurofer', 'firstwall_mat': 'eurofer', 'blanket_mat': blanket_material, # use of homogenised material 'blanket_rear_wall_mat': 'eurofer' }, cell_tallies=['TBR'], simulation_batches=5, simulation_particles_per_batch=1e4, ) # starts the neutronics simulation neutronics_model.simulate(method='trelis') # prints the results to screen print('TBR', neutronics_model.results['TBR'])
def make_model_and_simulate(): """Makes a neutronics Reactor model and simulates the TBR with specified materials""" # based on # http://www.euro-fusionscipub.org/wp-content/uploads/WPBBCP16_15535_submitted.pdf firstwall_radial_thickness = 3.0 firstwall_armour_material = "tungsten" firstwall_coolant_material = "He" firstwall_structural_material = "eurofer" firstwall_armour_fraction = 0.106305 firstwall_coolant_fraction = 0.333507 firstwall_coolant_temperature_C = 400 firstwall_coolant_pressure_Pa = 8e6 firstwall_structural_fraction = 0.560188 firstwall_material = nmm.MultiMaterial( material_tag="firstwall_mat", materials=[ nmm.Material( material_name=firstwall_coolant_material, temperature_in_C=firstwall_coolant_temperature_C, pressure_in_Pa=firstwall_coolant_pressure_Pa, ), nmm.Material(material_name=firstwall_structural_material), nmm.Material(material_name=firstwall_armour_material), ], fracs=[ firstwall_coolant_fraction, firstwall_structural_fraction, firstwall_armour_fraction, ], percent_type="vo") # based on # https://www.sciencedirect.com/science/article/pii/S2352179118300437 blanket_rear_wall_coolant_material = "H2O" blanket_rear_wall_structural_material = "eurofer" blanket_rear_wall_coolant_fraction = 0.3 blanket_rear_wall_structural_fraction = 0.7 blanket_rear_wall_coolant_temperature_C = 200 blanket_rear_wall_coolant_pressure_Pa = 1e6 blanket_rear_wall_material = nmm.MultiMaterial( material_tag="blanket_rear_wall_mat", materials=[ nmm.Material( material_name=blanket_rear_wall_coolant_material, temperature_in_C=blanket_rear_wall_coolant_temperature_C, pressure_in_Pa=blanket_rear_wall_coolant_pressure_Pa, ), nmm.Material(material_name=blanket_rear_wall_structural_material), ], fracs=[ blanket_rear_wall_coolant_fraction, blanket_rear_wall_structural_fraction, ], percent_type="vo") # based on # https://www.sciencedirect.com/science/article/pii/S2352179118300437 blanket_lithium6_enrichment_percent = 60 blanket_breeder_material = "Li4SiO4" blanket_coolant_material = "He" blanket_multiplier_material = "Be" blanket_structural_material = "eurofer" blanket_breeder_fraction = 0.15 blanket_coolant_fraction = 0.05 blanket_multiplier_fraction = 0.6 blanket_structural_fraction = 0.2 blanket_breeder_packing_fraction = 0.64 blanket_multiplier_packing_fraction = 0.64 blanket_coolant_temperature_C = 500 blanket_coolant_pressure_Pa = 1e6 blanket_breeder_temperature_C = 600 blanket_breeder_pressure_Pa = 8e6 blanket_material = nmm.MultiMaterial( material_tag="blanket_mat", materials=[ nmm.Material( material_name=blanket_coolant_material, temperature_in_C=blanket_coolant_temperature_C, pressure_in_Pa=blanket_coolant_pressure_Pa, ), nmm.Material(material_name=blanket_structural_material), nmm.Material( material_name=blanket_multiplier_material, packing_fraction=blanket_multiplier_packing_fraction, ), nmm.Material( material_name=blanket_breeder_material, enrichment=blanket_lithium6_enrichment_percent, packing_fraction=blanket_breeder_packing_fraction, temperature_in_C=blanket_breeder_temperature_C, pressure_in_Pa=blanket_breeder_pressure_Pa, ), ], fracs=[ blanket_coolant_fraction, blanket_structural_fraction, blanket_multiplier_fraction, blanket_breeder_fraction, ], percent_type="vo") # based on # https://www.sciencedirect.com/science/article/pii/S2352179118300437 divertor_coolant_fraction = 0.57195798876 divertor_structural_fraction = 0.42804201123 divertor_coolant_material = "H2O" divertor_structural_material = "tungsten" divertor_coolant_temperature_C = 150 divertor_coolant_pressure_Pa = 5e6 divertor_material = nmm.MultiMaterial( material_tag="divertor_mat", materials=[ nmm.Material( material_name=divertor_coolant_material, temperature_in_C=divertor_coolant_temperature_C, pressure_in_Pa=divertor_coolant_pressure_Pa, ), nmm.Material(material_name=divertor_structural_material), ], fracs=[divertor_coolant_fraction, divertor_structural_fraction], percent_type="vo") # based on # https://pdfs.semanticscholar.org/95fa/4dae7d82af89adf711b97e75a241051c7129.pdf center_column_shield_coolant_fraction = 0.13 center_column_shield_structural_fraction = 0.57 center_column_shield_coolant_material = "H2O" center_column_shield_structural_material = "tungsten" center_column_shield_coolant_temperature_C = 150 center_column_shield_coolant_pressure_Pa = 5e6 center_column_shield_material = nmm.MultiMaterial( material_tag="center_column_shield_mat", materials=[ nmm.Material( material_name=center_column_shield_coolant_material, temperature_in_C=center_column_shield_coolant_temperature_C, pressure_in_Pa=center_column_shield_coolant_pressure_Pa, ), nmm.Material( material_name=center_column_shield_structural_material), ], fracs=[ center_column_shield_coolant_fraction, center_column_shield_structural_fraction, ], percent_type="vo") # based on # https://pdfs.semanticscholar.org/95fa/4dae7d82af89adf711b97e75a241051c7129.pdf inboard_tf_coils_conductor_fraction = 0.57 inboard_tf_coils_coolant_fraction = 0.05 inboard_tf_coils_structure_fraction = 0.38 inboard_tf_coils_conductor_material = "copper" inboard_tf_coils_coolant_material = "He" inboard_tf_coils_structure_material = "SS_316L_N_IG" inboard_tf_coils_coolant_temperature_C = 30 inboard_tf_coils_coolant_pressure_Pa = 8e6 inboard_tf_coils_material = nmm.MultiMaterial( material_tag="inboard_tf_coils_mat", materials=[ nmm.Material( material_name=inboard_tf_coils_coolant_material, temperature_in_C=inboard_tf_coils_coolant_temperature_C, pressure_in_Pa=inboard_tf_coils_coolant_pressure_Pa, ), nmm.Material(material_name=inboard_tf_coils_conductor_material), nmm.Material(material_name=inboard_tf_coils_structure_material), ], fracs=[ inboard_tf_coils_coolant_fraction, inboard_tf_coils_conductor_fraction, inboard_tf_coils_structure_fraction, ], percent_type="vo") # makes the 3d geometry my_reactor = paramak.BallReactor( inner_bore_radial_thickness=1, inboard_tf_leg_radial_thickness=30, center_column_shield_radial_thickness=60, divertor_radial_thickness=50, inner_plasma_gap_radial_thickness=30, plasma_radial_thickness=300, outer_plasma_gap_radial_thickness=30, firstwall_radial_thickness=firstwall_radial_thickness, # http://www.euro-fusionscipub.org/wp-content/uploads/WPBBCP16_15535_submitted.pdf blanket_radial_thickness=100, blanket_rear_wall_radial_thickness=3, elongation=2.75, triangularity=0.5, number_of_tf_coils=16, rotation_angle=360, ) source = openmc.Source() # sets the location of the source to x=0 y=0 z=0 source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0)) # sets the direction to isotropic source.angle = openmc.stats.Isotropic() # sets the energy distribution to 100% 14MeV neutrons source.energy = openmc.stats.Discrete([14e6], [1]) # makes the neutronics material neutronics_model = paramak.NeutronicsModel( geometry=my_reactor, source=source, materials={ 'inboard_tf_coils_mat': inboard_tf_coils_material, 'center_column_shield_mat': center_column_shield_material, 'divertor_mat': divertor_material, 'firstwall_mat': firstwall_material, 'blanket_mat': blanket_material, 'blanket_rear_wall_mat': blanket_rear_wall_material }, cell_tallies=['TBR'], simulation_batches=5, simulation_particles_per_batch=1e4, ) # starts the neutronics simulation neutronics_model.simulate(method='trelis') # prints the simulation results to screen print('TBR', neutronics_model.results['TBR'])