Skip to content

Commit

Permalink
Merge pull request #61 from fusion-energy/geting_um_mesh_working_in_ci
Browse files Browse the repository at this point in the history
get umesh example working in CI
  • Loading branch information
shimwell authored Mar 15, 2024
2 parents 7b49c87 + ad39fbb commit 72de14d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 35 deletions.
32 changes: 14 additions & 18 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,25 @@ jobs:
pytest -v tests/test_loading_from_file_vs_shape_object.py
pytest -v tests/test_python_api.py
pytest -v tests/test_version.py
cd examples/surface_mesh
python create_stp_files_for_examples.py
python cadquery_assembly.py
python cadquery_compound.py
python cadquery_object_and_stp_file.py
python cadquery_text.py
python curved_cadquery_object_to_dagmc_surface_mesh.py
python multiple_cadquery_objects.py
python multiple_stp_files.py
python single_stp_file_multiple_volumes.py
python single_cadquery_object.py
python single_stp_file.py
cd ../..
cd examples/unstrucutred_volume_mesh
python curved_cadquery_object_to_dagmc_volume_mesh.py
cd ../..
python examples/surface_mesh/create_stp_files_for_examples.py
python examples/surface_mesh/cadquery_assembly.py
python examples/surface_mesh/cadquery_compound.py
python examples/surface_mesh/cadquery_object_and_stp_file.py
python examples/surface_mesh/cadquery_text.py
python examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py
python examples/surface_mesh/multiple_cadquery_objects.py
python examples/surface_mesh/multiple_stp_files.py
python examples/surface_mesh/single_stp_file_multiple_volumes.py
python examples/surface_mesh/single_cadquery_object.py
python examples/surface_mesh/single_stp_file.py
python examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py
pytest -v tests/test_model_creation_for_transport.py
mamba activate base
mamba create -y --name openmc python=3.10
mamba activate openmc
mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*"
python -m pip install pytest
python -m pip install vtk
pytest -v tests/test_h5m_in_simulation.py
pytest -v tests/test_h5m_in_transport.py
cd examples/unstrucutred_volume_mesh
python simulate_unstrucutred_volume_mesh_with_openmc.py
python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@

import 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"/>
</cross_sections>
"""
)
openmc.config["cross_sections"] = "cross_sections.xml"

umesh = openmc.UnstructuredMesh("umesh.h5m", library="moab")
mesh_filter = openmc.MeshFilter(umesh)
tally = openmc.Tally(name="t1")
tally = openmc.Tally(name="unstrucutred_mesh_tally")
tally.filters = [mesh_filter]
tally.scores = ["flux"]
tally.estimator = "tracklength"
my_tallies = openmc.Tallies([tally])


mat1 = openmc.Material()
mat1.add_element("Pb", 84.2, percent_type="ao")
mat1.add_element(
"Li",
15.8,
percent_type="ao",
enrichment=50.0,
enrichment_target="Li6",
enrichment_type="ao",
)
mat1.set_density("g/cm3", 11)
mat1.add_nuclide("H1", 1, percent_type="ao")
mat1.set_density("g/cm3", 0.001)
my_materials = openmc.Materials([mat1])

surf1 = openmc.Sphere(r=500, boundary_type="vacuum")
Expand All @@ -33,16 +36,14 @@

my_geometry = openmc.Geometry([cell1])


my_settings = openmc.Settings()
my_settings.batches = 10
my_settings.inactive = 0
my_settings.particles = 5000
my_settings.run_mode = "fixed source"

# Create a DT point source
my_source = openmc.Source()
# my_source = openmc.IndependentSource()
my_source = openmc.IndependentSource()
my_source.space = openmc.stats.Point((0, 0, 0))
my_source.angle = openmc.stats.Isotropic()
my_source.energy = openmc.stats.Discrete([14e6], [1])
Expand All @@ -53,12 +54,16 @@

sp = openmc.StatePoint(sp_filename)

tally_result = sp.get_tally(name="t1")

tally_result = sp.get_tally(name="unstrucutred_mesh_tally")

# normally with regular meshes I would get the mesh from the tally
# but with unstrucutred meshes the tally does not contain the mesh
# however we can get it from the statepoint file
# umesh = tally_result.find_filter(openmc.MeshFilter)
umesh_from_sp = sp.meshes[1]

# these trigger internal code in the mesh object so that its centroids and volumes become known.
# centroids and volumes are needed for the get_values and write_data_to_vtk steps
centroids = umesh_from_sp.centroids
mesh_vols = umesh_from_sp.volumes

Expand Down
2 changes: 1 addition & 1 deletion tests/test_h5m_in_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def transport_particles_on_h5m_geometry(
h5m_filename,
h5m_filename: str,
material_tags,
):
"""A function for testing the geometry file with particle transport in DAGMC OpenMC"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_h5m_in_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def transport_particles_on_h5m_geometry(
settings.inactive = 0
settings.run_mode = "fixed source"
settings.source = my_source
settings.photon_transport = False

# adds a tally to record the heat deposited in entire geometry
cell_tally = openmc.Tally(name="flux")
Expand Down

0 comments on commit 72de14d

Please sign in to comment.