diff --git a/.circleci/config.yml b/.circleci/config.yml index ce33b44..e95f435 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ jobs: - run: name: install command: | - conda install -c conda-forge openmc==0.13.2 + conda install -c conda-forge openmc==0.13.3=*nompi* pip install .[density,tests] # run tests! diff --git a/src/neutronics_material_maker/data/insulators.json b/src/neutronics_material_maker/data/insulators.json index 1ca7490..0507e54 100644 --- a/src/neutronics_material_maker/data/insulators.json +++ b/src/neutronics_material_maker/data/insulators.json @@ -1,7 +1,8 @@ { "Rexolite 1422": { "elements": { - "C": 1.0 + "C": 0.077421, + "H": 0.922579 }, "density": 1.06, "density_unit": "g/cm3", @@ -9,4 +10,3 @@ "percent_type": "wo" } } - \ No newline at end of file diff --git a/src/neutronics_material_maker/material.py b/src/neutronics_material_maker/material.py index 141ce9b..ba86a86 100644 --- a/src/neutronics_material_maker/material.py +++ b/src/neutronics_material_maker/material.py @@ -156,7 +156,6 @@ def __init__( volume_in_cm3: Optional[float] = None, additional_end_lines: Optional[Dict[str, List[str]]] = None, ): - self.name = name self.temperature = temperature self.temperature_to_neutronics_code = temperature_to_neutronics_code @@ -631,17 +630,18 @@ def _make_openmc_material(self): openmc_material.temperature = self.temperature if self.isotopes is not None: - openmc_material = self._add_isotopes(openmc_material) if self.elements is not None: - openmc_material = self._add_elements_from_dict(openmc_material) if self.chemical_equation is not None: - openmc_material = self._add_elements_from_equation(openmc_material) + # sorts the materials to avoid differently ordered material xml files + # resulting in different neutronics results + openmc_material._nuclides = sorted(openmc_material._nuclides) + openmc_material = self._add_density(openmc_material) if original_cross_sections is not None: @@ -650,7 +650,6 @@ def _make_openmc_material(self): return openmc_material def _check_enrichment_attributes(self): - if self.enrichment is None: return None @@ -699,7 +698,6 @@ def _add_elements_from_dict(self, openmc_material): for element_symbol, element_number in zip( self.elements.keys(), self.elements.values() ): - if element_symbol == enrichment_element: openmc_material.add_element( element_symbol, @@ -753,7 +751,6 @@ def _add_density(self, openmc_material): # a density equation is being used elif isinstance(self.density, str): - if self.density.startswith("PropsSI"): from CoolProp.CoolProp import PropsSI @@ -790,7 +787,6 @@ def _add_density(self, openmc_material): self.atoms_per_unit_cell is not None and self.volume_of_unit_cell_cm3 is not None ): - molar_mass = ( self._get_atoms_in_crystal() * openmc_material.average_molar_mass ) @@ -831,7 +827,6 @@ def _get_atoms_in_crystal(self): return sum(list_of_fractions) def from_json_file(filename: str, name: str, **kwargs): - with open(filename, "r") as file: new_data = json.load(file) diff --git a/src/neutronics_material_maker/utils.py b/src/neutronics_material_maker/utils.py index fb9099a..7fcb2dd 100644 --- a/src/neutronics_material_maker/utils.py +++ b/src/neutronics_material_maker/utils.py @@ -569,7 +569,6 @@ def make_mcnp_material(mat) -> str: + " g/cm3" ] for i, isotope in enumerate(mat.openmc_material.nuclides): - if i == 0: start = f"M{mat.material_id: <5}" else: diff --git a/tests/test_Material.py b/tests/test_Material.py index 1af5298..2c89de3 100644 --- a/tests/test_Material.py +++ b/tests/test_Material.py @@ -13,7 +13,6 @@ class test_object_properties(unittest.TestCase): def test_error_raised_when_enrichment_and_enrichment_target(self): def error_raised_correctly(): - test_material = nmm.Material.from_library( name="WC", enrichment=90, enrichment_target=None ) @@ -145,7 +144,7 @@ def test_fispact_material(self): line_by_line_material = test_mat.fispact_material.split("\n") assert len(line_by_line_material) == 10 - assert line_by_line_material[0].startswith("DENSITY 2.31899993235464") + assert line_by_line_material[0].startswith("DENSITY 2.318999932") assert line_by_line_material[1] == "FUEL 8" dict_of_fispact_mats = {} @@ -169,7 +168,7 @@ def test_fispact_material_with_volume(self): line_by_line_material = test_mat.fispact_material.split("\n") assert len(line_by_line_material) == 10 - assert line_by_line_material[0].startswith("DENSITY 2.31899993235464") + assert line_by_line_material[0].startswith("DENSITY 2.3189999") assert line_by_line_material[1] == "FUEL 8" dict_of_fispact_mats = {} @@ -388,7 +387,6 @@ def test_serpent_material_lines_with_decimal_places(self): assert " 050116.30c 3.6350e-02" in line_by_line_material def test_material_creation_from_chemical_formula_with_enrichment(self): - pb_fraction = 3 li_fraction = 7 enrichment = 20 @@ -431,7 +429,6 @@ def test_material_creation_from_chemical_formula_with_enrichment(self): ) def test_material_creation_from_chemical_formula_with_enrichment2(self): - pb_fraction = 3 li_fraction = 7 enrichment = 20 @@ -471,7 +468,6 @@ def test_material_creation_from_chemical_formula_with_enrichment2(self): ) def test_density_of_crystals(self): - # these tests fail because the density value is too far away from calculated value # however, this could be becuase the density values are rounded to 2 dp @@ -508,7 +504,6 @@ def test_density_of_crystals(self): # TODO extra checks for all the crystals needed here def test_density_of_enriched_crystals(self): - test_mat = nmm.Material.from_library(name="Li4SiO4") test_mat_enriched = nmm.Material.from_library( name="Li4SiO4", @@ -521,7 +516,6 @@ def test_density_of_enriched_crystals(self): ) def test_density_of_packed_crystals(self): - test_mat = nmm.Material.from_library(name="Li4SiO4") test_mat_packed = nmm.Material.from_library( name="Li4SiO4", packing_fraction=0.35 @@ -532,7 +526,6 @@ def test_density_of_packed_crystals(self): ) def test_material_creation_from_chemical_formula(self): - pb_fraction = 3 li_fraction = 7 @@ -993,5 +986,4 @@ def test_restricted_eval(): if __name__ == "__main__": - unittest.main() diff --git a/tests/test_Material_from_mixture.py b/tests/test_Material_from_mixture.py index 45fd693..36ee90a 100644 --- a/tests/test_Material_from_mixture.py +++ b/tests/test_Material_from_mixture.py @@ -13,7 +13,6 @@ class test_object_properties(unittest.TestCase): def test_serpent_from_mixture_type(self): - test_material = nmm.Material.from_mixture( name="test_material", materials=[ @@ -28,7 +27,6 @@ def test_serpent_from_mixture_type(self): assert isinstance(test_material.serpent_material, str) def test_mcnp_from_mixture_type(self): - test_material = nmm.Material.from_mixture( name="test_material", materials=[ @@ -44,7 +42,6 @@ def test_mcnp_from_mixture_type(self): assert isinstance(test_material.mcnp_material, str) def test_shift_from_mixture_type(self): - test_material = nmm.Material.from_mixture( name="test_material", materials=[ @@ -61,7 +58,6 @@ def test_shift_from_mixture_type(self): assert isinstance(test_material.shift_material, str) def test_fispact_from_mixture_type(self): - test_material = nmm.Material.from_mixture( name="test_material", materials=[ @@ -111,7 +107,6 @@ def test_make_from_mixture_from_openmc_materials(self): assert isinstance(test_material.openmc_material, openmc.Material) def test_mutliname_setting(self): - test_material = nmm.Material.from_mixture( materials=[ nmm.Material.from_library("Pb842Li158", temperature=500), @@ -169,7 +164,6 @@ def test_from_mixture_attributes_from_material_objects_and_openmc_materials(self assert test_material_1.nuclides == test_material_2.nuclides def test_density_of_mixed_two_packed_crystals(self): - test_material_1 = nmm.Material.from_library(name="Li4SiO4") test_material_packed_1 = nmm.Material.from_library( name="Li4SiO4", packing_fraction=0.65 @@ -202,7 +196,6 @@ def test_density_of_mixed_two_packed_crystals(self): ) def test_density_of_mixed_two_packed_and_non_packed_crystals(self): - test_material_1 = nmm.Material.from_library(name="Li4SiO4") test_material_1_packed = nmm.Material.from_library( name="Li4SiO4", packing_fraction=0.65 @@ -221,7 +214,6 @@ def test_density_of_mixed_two_packed_and_non_packed_crystals(self): ) def test_density_of_mixed_materials_from_density(self): - test_material = nmm.Material.from_library( "H2O", temperature=300, pressure=100000 ) @@ -234,7 +226,6 @@ def test_density_of_mixed_materials_from_density(self): ) def test_density_of_mixed_one_packed_crystal_and_one_non_crystal(self): - test_material_1 = nmm.Material.from_library( name="H2O", temperature=300, pressure=100000 ) @@ -260,7 +251,6 @@ def test_density_of_mixed_one_packed_crystal_and_one_non_crystal(self): ) def test_packing_fraction_for_single_materials(self): - test_material_1 = nmm.Material.from_library("Li4SiO4").openmc_material test_material_2 = nmm.Material.from_library( @@ -282,7 +272,6 @@ def test_packing_fraction_for_single_materials(self): assert test_material_4.density == pytest.approx(test_material_1.density * 0.75) def test_packing_fraction_for_from_mixture_function(self): - test_material_5 = nmm.Material.from_mixture( name="test_material_5", materials=[ @@ -315,7 +304,6 @@ def test_packing_fraction_for_from_mixture_function(self): assert test_material_7.density == pytest.approx(test_material_5.density * 0.5) def test_packing_fraction_of_a_from_mixture(self): - test_material_6 = nmm.Material.from_mixture( name="test_material_6", materials=[ @@ -340,7 +328,6 @@ def test_packing_fraction_of_a_from_mixture(self): ) def test_packing_fraction_for_mix_materials_function(self): - test_material_8 = openmc.Material.mix_materials( name="test_material_8", materials=[ @@ -384,7 +371,6 @@ def test_packing_fraction_for_mix_materials_function(self): assert test_material_10.density == pytest.approx(test_material_8.density * 0.5) def test_from_mixture_vs_mix_materials(self): - test_material_11 = nmm.Material.from_mixture( name="test_material_11", materials=[ diff --git a/tests/test_utils.py b/tests/test_utils.py index 676dc9c..113be62 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -17,7 +17,6 @@ class test_object_properties(unittest.TestCase): def test_additional_lines_multimaterial_mcnp(self): - test_mat1 = nmm.Material.from_library( "Li4SiO4", additional_end_lines={"mcnp": ["mat1_additional"]} ) @@ -46,7 +45,6 @@ def test_additional_lines_multimaterial_mcnp(self): assert test_mat3.shift_material.split("\n")[-1] == "extra_shift_lin" def test_additional_lines_mcnp(self): - test_mat = nmm.Material.from_library( "H2O", pressure=1e6, @@ -223,7 +221,6 @@ def test_number_of_materials_in_dict(self): assert len(nmm_again.AvailableMaterials().keys()) >= 418 def test_dictionary_of_materials_makes_openmc_materials(self): - for mat in nmm.AvailableMaterials().keys(): print(mat) test_mat = nmm.Material.from_library(mat, temperature=300, pressure=5e6) @@ -231,7 +228,6 @@ def test_dictionary_of_materials_makes_openmc_materials(self): assert isinstance(test_mat.openmc_material, openmc.Material) def test_dictionary_of_materials_makes_mcnp_materials(self): - for mat in nmm.AvailableMaterials().keys(): print(mat) test_mat = nmm.Material.from_library( @@ -241,7 +237,6 @@ def test_dictionary_of_materials_makes_mcnp_materials(self): assert isinstance(test_mat.mcnp_material, str) def test_dictionary_of_materials_makes_shift_materials(self): - for mat in nmm.AvailableMaterials().keys(): print(mat) test_mat = nmm.Material.from_library( @@ -251,7 +246,6 @@ def test_dictionary_of_materials_makes_shift_materials(self): assert isinstance(test_mat.shift_material, str) def test_dictionary_of_materials_makes_fispact_materials(self): - for mat in nmm.AvailableMaterials().keys(): print(mat) test_mat = nmm.Material.from_library( @@ -261,7 +255,6 @@ def test_dictionary_of_materials_makes_fispact_materials(self): assert isinstance(test_mat.fispact_material, str) def test_dictionary_of_materials_makes_serpent_materials(self): - for mat in nmm.AvailableMaterials().keys(): print(mat) test_mat = nmm.Material.from_library(mat, temperature=300, pressure=5e6)