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

Ensuring only exact "vacuum" assignment is detected as vacuum #3264

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ea4b8c1
adding vacuum test
bam241 Jan 9, 2025
4c42068
testing vacuum keyword detection with DAGMC geometry
bam241 Jan 9, 2025
6f30373
does it run by default ?
bam241 Jan 9, 2025
ef6f083
set my box boundary as vacuum
bam241 Jan 10, 2025
ce1646a
typo
bam241 Jan 12, 2025
af7726f
test tally
bam241 Jan 13, 2025
4a9b560
new suf tally
bam241 Jan 13, 2025
3583011
printing tally content
bam241 Jan 13, 2025
8f6d1bd
add vacuum test
bam241 Jan 14, 2025
f2aded5
now all run in tmp
bam241 Jan 14, 2025
16169d3
Apply suggestions from code review
bam241 Jan 14, 2025
30ca476
revert 2 change
bam241 Jan 14, 2025
5fb1640
Update tests/unit_tests/dagmc/test_model.py
bam241 Jan 14, 2025
a483ab1
Update tests/unit_tests/dagmc/test_model.py
bam241 Jan 15, 2025
bc7fa45
Update tests/unit_tests/dagmc/test_model.py
bam241 Jan 15, 2025
63ccfe0
This look good
bam241 Jan 15, 2025
b36da05
fixing comments
bam241 Jan 15, 2025
ea29f54
Apply suggestions from code review
bam241 Jan 15, 2025
6915706
increasing density a bit
bam241 Jan 15, 2025
d4c45f8
Revmoving locally required import
bam241 Jan 15, 2025
de6d8ba
working
bam241 Jan 15, 2025
85802f5
trying to tweak tempdir
bam241 Jan 15, 2025
ae28125
update path management
bam241 Jan 15, 2025
761d22c
enabling ssh
bam241 Jan 16, 2025
ef989df
fixing formating
bam241 Jan 16, 2025
d2c4882
putting ssh session at the right place
bam241 Jan 16, 2025
9958ac0
tweaking mat composition
bam241 Jan 16, 2025
ee84c13
restoring the exact ci.yml
bam241 Jan 16, 2025
ffe27fd
woudl a finalize() help ?
bam241 Jan 16, 2025
d806829
Simplifying vacuum assignment test
pshriwise Jan 21, 2025
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
62 changes: 61 additions & 1 deletion tests/unit_tests/dagmc/test_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from pathlib import Path

import os
import h5py
import shutil
import lxml.etree as ET
import numpy as np
import pytest
import openmc
from openmc.utility_funcs import change_directory

import openmc.lib
pytestmark = pytest.mark.skipif(
not openmc.lib._dagmc_enabled(),
reason="DAGMC CAD geometry is not enabled.")
Expand Down Expand Up @@ -254,3 +257,60 @@ def test_dagmc_xml(model):

for xml_mats, model_mats in zip(xml_dagmc_univ._material_overrides.values(), dag_univ._material_overrides.values()):
assert all([xml_mat.id == orig_mat.id for xml_mat, orig_mat in zip(xml_mats, model_mats)])

def test_dagmc_vacuum(run_in_tmpdir, request):
# Required initial mats
mats = {}
mats["41"] = openmc.Material(name="41")
mats["41"].add_nuclide("H1", 1.0)
mats["41"].set_density("g/cm3", 1.0)

# Not a vacuum material
na_vacuum_str = "not_a_vacuum"
mats[na_vacuum_str] = openmc.Material(name=na_vacuum_str)
mats[na_vacuum_str].add_nuclide("U238", 1.0)
mats[na_vacuum_str].set_density("g/cm3", 10.0)

model = openmc.Model()
model.settings = openmc.Settings()
model.settings.batches = 10
model.settings.particles = 100
model.materials = openmc.Materials(mats.values())

orig_h5m = Path(request.fspath).parent / "dagmc.h5m"

# Tweaking the h5m file to change the material assignment
na_vacuum_h5 = Path(f"dagmc_{na_vacuum_str}.h5m")
shutil.copy(orig_h5m, na_vacuum_h5)
hf = h5py.File(na_vacuum_h5, 'r+')
new_assignment = 'mat:not_a_vacuum'.encode('utf-8')
hf['/tstt/tags/NAME']['values'][1] = new_assignment
hf.close()

# Set the Model
daguniv = openmc.DAGMCUniverse(na_vacuum_h5.absolute(),
auto_geom_ids=True).bounded_universe()
model.geometry = openmc.Geometry(root=daguniv)

# Vacuum material
vacuum_str = "vacuum"

# Tweaking the h5m file to change the material assignment
vacuum_h5 = Path(f"dagmc_{vacuum_str}.h5m")
shutil.copy(orig_h5m, vacuum_h5)
hf = h5py.File(vacuum_h5, 'r+')
hf = h5py.File(vacuum_h5, 'r+')
new_assignment = 'mat:vacuum'.encode('utf-8')
hf['/tstt/tags/NAME']['values'][1] = new_assignment
hf.close()

# Create a new DAGMC unvierse
daguniv = openmc.DAGMCUniverse(vacuum_h5.absolute(),
auto_geom_ids=True).bounded_universe()
# Update the model geometry
model.geometry = openmc.Geometry(root=daguniv)

model.export_to_model_xml()
with openmc.lib.run_in_memory():
material = openmc.lib.find_material((0, 0, 0))
assert material is None
Loading