-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: two touching cuboids - cad to dagmc | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
- main | ||
push: | ||
- main | ||
|
||
jobs: | ||
testing: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: checkout actions | ||
uses: actions/checkout@v4 | ||
|
||
- name: use upstream test composite action | ||
uses: ./.github/actions/dependencies | ||
|
||
- shell: bash | ||
env: | ||
OPENMC_CROSS_SECTIONS: /home/runner/work/model_benchmark_zoo/model_benchmark_zoo/cross_sections.xml | ||
run: | | ||
source "${HOME}/conda/etc/profile.d/conda.sh" | ||
source "${HOME}/conda/etc/profile.d/mamba.sh" | ||
mamba activate | ||
pytest tests/test_cad_to_dagmc/test_csg_cad_simple_tokamak.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from model_benchmark_zoo import SimpleTokamak | ||
import openmc | ||
import math | ||
|
||
def test_compare(): | ||
# single material used in both simulations | ||
mat1 = openmc.Material(name='1') | ||
mat1.add_nuclide('Fe56', 1) | ||
mat1.set_density('g/cm3', 1) | ||
|
||
mat2 = openmc.Material(name='2') | ||
mat2.add_nuclide('Be9', 1) | ||
mat2.set_density('g/cm3', 1) | ||
my_materials = openmc.Materials([mat1, mat2]) | ||
|
||
# geometry used in both simulations | ||
common_geometry_object = SimpleTokamak(materials=my_materials, radius1=10, radius2=1) | ||
# just writing a CAD step file for visulisation | ||
common_geometry_object.export_stp_file("SimpleTokamak.stp") | ||
|
||
mat1_filter = openmc.MaterialFilter(mat1) | ||
tally1 = openmc.Tally(name='mat1_flux_tally') | ||
tally1.filters = [mat1_filter] | ||
tally1.scores = ['flux'] | ||
|
||
mat2_filter = openmc.MaterialFilter(mat2) | ||
tally2 = openmc.Tally(name='mat2_flux_tally') | ||
tally2.filters = [mat2_filter] | ||
tally2.scores = ['flux'] | ||
|
||
my_tallies = openmc.Tallies([tally1, tally2]) | ||
|
||
my_settings = openmc.Settings() | ||
my_settings.batches = 10 | ||
my_settings.inactive = 0 | ||
my_settings.particles = 500 | ||
my_settings.run_mode = 'fixed source' | ||
|
||
# Create a DT point source | ||
my_source = openmc.Source() | ||
my_source.space = openmc.stats.Point((0, 0, 0)) | ||
my_source.angle = openmc.stats.Isotropic() | ||
my_source.energy = openmc.stats.Discrete([14e6], [1]) | ||
my_settings.source = my_source | ||
|
||
# making openmc.Model with CSG geometry | ||
csg_model = common_geometry_object.csg_model() | ||
csg_model.tallies = my_tallies | ||
csg_model.settings = my_settings | ||
|
||
output_file_from_csg = csg_model.run() | ||
|
||
# extracting the tally result from the CSG simulation | ||
with openmc.StatePoint(output_file_from_csg) as sp_from_csg: | ||
csg_result_mat_1 = sp_from_csg.get_tally(name="mat1_flux_tally") | ||
csg_result_mat_2 = sp_from_csg.get_tally(name="mat2_flux_tally") | ||
|
||
# making openmc.Model with DAGMC geometry and specifying mesh sizes to get a good representation of a sphere | ||
dag_model = common_geometry_object.dagmc_model(min_mesh_size=0.01, max_mesh_size=0.5) | ||
dag_model.tallies = my_tallies | ||
dag_model.settings = my_settings | ||
|
||
output_file_from_cad = dag_model.run() | ||
|
||
# extracting the tally result from the DAGMC simulation | ||
with openmc.StatePoint(output_file_from_cad) as sp_from_cad: | ||
cad_result_mat_1 = sp_from_cad.get_tally(name="mat1_flux_tally") | ||
cad_result_mat_2 = sp_from_cad.get_tally(name="mat2_flux_tally") | ||
|
||
assert math.isclose(cad_result_mat_1.mean, csg_result_mat_1.mean) | ||
assert math.isclose(cad_result_mat_2.mean, csg_result_mat_2.mean) |