Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove testing dependency to easy conda packaging #30

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ dependencies:
- openmc=0.13.3=dagmc*
- networkx
- pip
- pip:
- openmc_data_downloader
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ write_to = "src/_version.py"

[project.optional-dependencies]
tests = [
"pytest",
"openmc_data_downloader"
"pytest"
]

[project.urls]
Expand Down
Binary file added tests/ENDFB-7.1-NNDC_H1.h5
Binary file not shown.
59 changes: 40 additions & 19 deletions tests/test_brep_to_h5m/test_h5m_in_transport.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import openmc
import openmc_data_downloader
from cad_to_dagmc.brep_to_h5m import brep_to_h5m
import math

Expand All @@ -25,8 +24,7 @@ def transport_particles_on_h5m_geometry(
):
"""A function for testing the geometry file with particle transport in
DAGMC OpenMC. Requires openmc and either the cross_sections_xml to be
specified or openmc_data_downloader installed. Returns the flux on each
volume
specified. Returns the flux on each volume

Arg:
h5m_filename: The name of the DAGMC h5m file to test
Expand All @@ -47,19 +45,26 @@ def transport_particles_on_h5m_geometry(
# simplified material definitions have been used to keen this example minimal
mat_dag_material_tag = openmc.Material(name=material_tag)
mat_dag_material_tag.add_nuclide(nuclides[i], 1, "ao")
mat_dag_material_tag.set_density("g/cm3", 0.1)
mat_dag_material_tag.set_density("g/cm3", 0.01)

materials.append(mat_dag_material_tag)

if cross_sections_xml:
materials.cross_sections = cross_sections_xml
openmc.config["cross_sections"] = cross_sections_xml

else:
# downloads the nuclear data and sets the openmc_cross_sections environmental variable
materials.download_cross_section_data(
libraries=["ENDFB-7.1-NNDC"],
set_OPENMC_CROSS_SECTIONS=True,
particles=["neutron"],
)
with open("cross_sections.xml", "w") as file:
file.write(
"""
<?xml version='1.0' encoding='UTF-8'?>
<cross_sections>
<library materials="H1" path="tests/ENDFB-7.1-NNDC_H1.h5" type="neutron"/>
<library materials="H2" path="ENDFB-7.1-NNDC_H2.h5" type="neutron"/>
</cross_sections>
"""
)

openmc.config["cross_sections"] = "cross_sections.xml"

dag_univ = openmc.DAGMCUniverse(filename=h5m_filename)
bound_dag_univ = dag_univ.bounded_universe()
Expand Down Expand Up @@ -133,7 +138,9 @@ def test_transport_on_h5m_with_6_volumes():
)

transport_particles_on_h5m_geometry(
h5m_filename=h5m_filename, material_tags=material_tags
h5m_filename=h5m_filename,
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)


Expand All @@ -153,7 +160,9 @@ def test_transport_on_h5m_with_1_volumes():
)

transport_particles_on_h5m_geometry(
h5m_filename=h5m_filename, material_tags=material_tags
h5m_filename=h5m_filename,
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)


Expand All @@ -173,7 +182,9 @@ def test_transport_on_h5m_with_2_joined_volumes():
)

transport_particles_on_h5m_geometry(
h5m_filename=h5m_filename, material_tags=material_tags
h5m_filename=h5m_filename,
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)


Expand All @@ -193,7 +204,9 @@ def test_transport_on_h5m_with_2_sep_volumes():
)

transport_particles_on_h5m_geometry(
h5m_filename=h5m_filename, material_tags=material_tags
h5m_filename=h5m_filename,
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)


Expand All @@ -213,7 +226,9 @@ def test_transport_result_h5m_with_2_sep_volumes():
)

new_tally = transport_particles_on_h5m_geometry(
h5m_filename=h5m_filename, material_tags=material_tags
h5m_filename=h5m_filename,
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)

brep_to_h5m(
Expand All @@ -225,7 +240,9 @@ def test_transport_result_h5m_with_2_sep_volumes():
mesh_algorithm=1,
)
stl_tally = transport_particles_on_h5m_geometry(
h5m_filename=h5m_filename, material_tags=material_tags
h5m_filename=h5m_filename,
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)

assert math.isclose(new_tally, stl_tally)
Expand All @@ -250,7 +267,9 @@ def test_stl_vs_in_memory_1_volume():
)

transport_particles_on_h5m_geometry(
h5m_filename="h5m_from_in_memory_method.h5m", material_tags=material_tags
h5m_filename="h5m_from_in_memory_method.h5m",
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)


Expand All @@ -273,5 +292,7 @@ def test_stl_vs_in_memory_2_joined_volume():
)

transport_particles_on_h5m_geometry(
h5m_filename="h5m_from_in_memory_method.h5m", material_tags=material_tags
h5m_filename="h5m_from_in_memory_method.h5m",
material_tags=material_tags,
nuclides=["H1"] * len(material_tags),
)
23 changes: 14 additions & 9 deletions tests/test_cad_to_dagmc/test_h5m_in_simulation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import openmc
import openmc_data_downloader


"""
- h5m files can be used a transport geometry in DAGMC with OpenMC
Expand All @@ -13,21 +11,28 @@ def transport_particles_on_h5m_geometry(
):
"""A function for testing the geometry file with particle transport in DAGMC OpenMC"""

with open("cross_sections.xml", "w") as file:
file.write(
"""
<?xml version='1.0' encoding='UTF-8'?>
<cross_sections>
<library materials="H1" path="tests/ENDFB-7.1-NNDC_H1.h5" type="neutron"/>
<library materials="H2" path="ENDFB-7.1-NNDC_H2.h5" type="neutron"/>
</cross_sections>
"""
)

openmc.config["cross_sections"] = "cross_sections.xml"

materials = openmc.Materials()
for material_tag in material_tags:
# simplified material definitions have been used to keen this example minimal
mat_dag_material_tag = openmc.Material(name=material_tag)
mat_dag_material_tag.add_nuclide("H1", 1, "ao")
mat_dag_material_tag.set_density("g/cm3", 2)
mat_dag_material_tag.set_density("g/cm3", 0.01)

materials.append(mat_dag_material_tag)

materials.download_cross_section_data(
libraries=["ENDFB-7.1-NNDC"],
set_OPENMC_CROSS_SECTIONS=True,
particles=["neutron"],
)

# makes use of the dagmc geometry
dag_univ = openmc.DAGMCUniverse(h5m_filename)

Expand Down
26 changes: 18 additions & 8 deletions tests/test_vertices_to_h5m/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np
import openmc
import openmc_data_downloader
import pymoab as mb
from pymoab import core, types

Expand Down Expand Up @@ -58,20 +57,31 @@ def transport_particles_on_h5m_geometry(
for material_tag in material_tags:
# simplified material definitions have been used to keen this example minimal
mat_dag_material_tag = openmc.Material(name=material_tag)
mat_dag_material_tag.add_element("H", 1, "ao")
mat_dag_material_tag.set_density("g/cm3", 2)
mat_dag_material_tag.add_nuclide("H1", 1, "ao")
mat_dag_material_tag.set_density("g/cm3", 0.01)

materials.append(mat_dag_material_tag)

if cross_sections_xml:
materials.cross_sections = cross_sections_xml
# downloads the nuclear data and sets the openmc_cross_sections environmental variable

materials.download_cross_section_data(
libraries=["ENDFB-7.1-NNDC"],
set_OPENMC_CROSS_SECTIONS=True,
particles=["neutron"],
)
if cross_sections_xml:
openmc.config["cross_sections"] = cross_sections_xml

else:
with open("cross_sections.xml", "w") as file:
file.write(
"""
<?xml version='1.0' encoding='UTF-8'?>
<cross_sections>
<library materials="H1" path="tests/ENDFB-7.1-NNDC_H1.h5" type="neutron"/>
<library materials="H2" path="ENDFB-7.1-NNDC_H2.h5" type="neutron"/>
</cross_sections>
"""
)

openmc.config["cross_sections"] = "cross_sections.xml"

# makes use of the dagmc geometry
dag_univ = openmc.DAGMCUniverse(h5m_filename)
Expand Down