Skip to content

Commit

Permalink
Merge branch 'sorting_nuclides' of github.com:fusion-energy/neutronic…
Browse files Browse the repository at this point in the history
…s_material_maker into sorting_nuclides
  • Loading branch information
shimwell committed Apr 21, 2023
2 parents daf27fd + 8d55df7 commit c032465
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 39 deletions.
9 changes: 0 additions & 9 deletions src/neutronics_material_maker/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -631,15 +630,12 @@ 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
Expand All @@ -654,7 +650,6 @@ def _make_openmc_material(self):
return openmc_material

def _check_enrichment_attributes(self):

if self.enrichment is None:
return None

Expand Down Expand Up @@ -703,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,
Expand Down Expand Up @@ -757,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

Expand Down Expand Up @@ -794,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
)
Expand Down Expand Up @@ -835,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)

Expand Down
1 change: 0 additions & 1 deletion src/neutronics_material_maker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 0 additions & 8 deletions tests/test_Material.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -993,5 +986,4 @@ def test_restricted_eval():


if __name__ == "__main__":

unittest.main()
14 changes: 0 additions & 14 deletions tests/test_Material_from_mixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand All @@ -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=[
Expand All @@ -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=[
Expand All @@ -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=[
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -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(
Expand All @@ -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=[
Expand Down Expand Up @@ -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=[
Expand All @@ -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=[
Expand Down Expand Up @@ -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=[
Expand Down
7 changes: 0 additions & 7 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -223,15 +221,13 @@ 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)

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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit c032465

Please sign in to comment.