Skip to content

Commit

Permalink
Merge pull request #34 from fusion-energy/develop
Browse files Browse the repository at this point in the history
latest Develop updates
  • Loading branch information
shimwell authored Apr 21, 2023
2 parents 45b2cb4 + 3dafd53 commit 55fa45b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
4 changes: 2 additions & 2 deletions src/neutronics_material_maker/data/insulators.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"Rexolite 1422": {
"elements": {
"C": 1.0
"C": 0.077421,
"H": 0.922579
},
"density": 1.06,
"density_unit": "g/cm3",
"comment": "Rexolite 1422 http://hdl.handle.net/11375/24061",
"percent_type": "wo"
}
}

13 changes: 4 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,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:
Expand All @@ -650,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 @@ -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,
Expand Down Expand Up @@ -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

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

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
12 changes: 2 additions & 10 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 @@ -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 = {}
Expand All @@ -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 = {}
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 55fa45b

Please sign in to comment.