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

cad_geometry_example #29

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,86 +13,110 @@ In this example, you'll learn how to:
caption=OpenMC and MOOSE Coupling
style=width:60%;margin-left:auto;margin-right:auto

An extremely simplified tokamak was modeled in CAD and was considered for this example. The meshed geometry was prepared using direct accelerated geometry Monte Carlo (DAGMC) for particle transport, and a volumetric mesh was also prepared to be used in MOOSE’s finite element solver and to tally OpenMC results for heat source distribution and tritium production. Cardinal was used to run OpenMC Monte Carlo particle transport within MOOSE framework. The data transfer system transfered heat source and temperature distribution between OpenMC and MOOSE as shown in Figure 1, with coupling between neutron transport and heat conduction achieved via Picard iteration.
An extremely simplified tokamak was modeled in CAD and was considered for this example. The meshed geometry was prepared using direct accelerated geometry Monte Carlo (DAGMC) for particle transport, and a volumetric mesh was also prepared to be used in MOOSE’s finite element solver and to tally OpenMC results for heat source distribution and tritium production. Cardinal was used to run OpenMC Monte Carlo particle transport within MOOSE framework. The data transfer system transferred heat source and temperature distribution between OpenMC and MOOSE as shown in [transfers], with coupling between neutron transport and heat conduction achieved via Picard iteration.

## Generating the meshes

The CAD model was first developed in FUSION360 and was imported into Cubit to assign blocks, materials, and side sets and generate the mesh (Figure 2). A corresponding DAGMC surface mesh (Figure 3) was exported directly from the meshed geometry in Cubit (by loading the volumetric meshed geometry in Cubit and exporting a DAGMC surface mesh).
The CAD model was first developed in FUSION360 and was imported into Cubit to assign blocks, materials, and side sets and generate the mesh ([volumetric_mesh]). A corresponding DAGMC surface mesh ([dagmc]) was exported directly from the meshed geometry in Cubit (by loading the volumetric meshed geometry in Cubit and exporting a DAGMC surface mesh).

In this example, `tmesh_1.e` (Figure 2) is the finite element mesh used in MOOSE on which the heat conduction physics is solved. `tmesh_1.h5m` (Figure 3) is the DAGMC surface mesh used for particle transport in OpenMC (which bounds the surfaces between different materials). Cardinal also allows for mesh tallying for tallying OpenMC results directly on the mesh overlayed on the OpenMC geometry which `tmesh_1.e` (Figure 2) could be used for as well as an unstructered volume mesh. This could be used by changing the tally type and adding a mesh template (`tally_type = mesh`, `mesh_template = tmesh_1.e`) in Cardinal input under Problem.
In this example, `tmesh_1.e` ([volumetric_mesh]) is the finite element mesh used in MOOSE on which the heat conduction physics is solved. `tmesh_1.h5m` ([dagmc]) is the DAGMC surface mesh used for particle transport in OpenMC (which bounds the surfaces between different materials). Cardinal also allows for mesh tallying for tallying OpenMC results directly on the mesh overlayed on the OpenMC geometry which `tmesh_1.e` ([volumetric_mesh]) could be used for as well as an unstructured volume mesh. This could be used by changing the tally type and adding a mesh template (`tally_type = mesh`, `mesh_template = tmesh_1.e`) in Cardinal input under Problem.

 

!row! style=display:inline-flex;
!col! small=12 medium=4 large=3

!media figures/mesh_1.png style=width:130%;display:block;
id=volumetric_mesh caption=Volumetric mesh
!media figures/mesh_1.png
style=width:130%;display:block;
id=volumetric_mesh
caption=Volumetric mesh

!col-end!

!col! small=12 medium=4 large=3

!media figures/d1.png style=width:130%;display:block;
id=dagmc caption=DAGMC mesh
!media figures/d1.png
style=width:130%;display:block;
id=dagmc
caption=DAGMC mesh

!col-end!
!row-end!

## OpenMC

The OpenMC input files is as follows:

!listing /test/tests/cad_geometry_example/model.py language=python
meltawila marked this conversation as resolved.
Show resolved Hide resolved

## Cardinal

The Cardinal input files is as follows:

!listing /test/tests/cad_geometry_example/openmc.i
meltawila marked this conversation as resolved.
Show resolved Hide resolved

## MOOSE Heat transfer
## FENIX (MOOSE) Heat transfer

The FENIX input files is as follows:

!listing /test/tests/cad_geometry_example/solid.i
meltawila marked this conversation as resolved.
Show resolved Hide resolved

## Execution

To run the coupled calculation:
To generate OpenMC xml files, run:

```
mpiexec -np 2 cardinal-opt -i solid.i --n-threads=2
python model.py
```

This will run both MOOSE and OpenMC with 2 MPI processes and 2 OpenMP threads per rank. To run the simulation faster, you can increase the parallel processes/threads, or simply decrease the number of particles used in OpenMC. When the simulation has completed, you will have created a number of different output files:
Then to run the coupled calculation:

```
mpiexec -np 2 fenix-opt -i solid.i --n-threads=2
```

- `solid_out.e`, an Exodus output with the solid mesh and solution
This will run both MOOSE and OpenMC (with Cardinal) with 2 MPI processes and 2 OpenMP threads per rank. To run the simulation faster, you can increase the parallel processes/threads, or simply decrease the number of particles used in OpenMC. When the simulation has completed, you will have created a number of different output files:

- `solid_out.e`, an Exodus output with the solid mesh and solution from the MOOSE/FENIX input file
- `solid_out_openmc0.e`, an Exodus output with the OpenMC solution and the data that was ultimately transferred in/out of OpenMC

## Results

 

meltawila marked this conversation as resolved.
Show resolved Hide resolved
The results of this simulation are shown in [temps], [h3production], and [results]. More information - including a mesh sensitivity study and results from a finer mesh - is available in [!cite](Eltawila2024PBNC).

 

!row! style=display:inline-flex;
!col! small=12 medium=4 large=3

!media figures/Temps.png style=width:130%;display:block;
id=temps caption=Temperature distribution
!media figures/Temps.png
style=width:130%;display:block;
id=temps
caption=Temperature distribution

!col-end!

!col! small=12 medium=4 large=3

!media figures/tritium_production.png style=width:130%;display:block;
id=h3production caption=Tritium production rate density
!media figures/tritium_production.png
style=width:130%;display:block;
id=h3production
caption=Tritium production rate density

!col-end!
!row-end!

 

!table id=results caption=Results summary
| Parameter | Value |
| Parameter (Units) | Value |
| :- | :- |
| Armor Max. Temp. (K) | 1062.4 |
| First Wall Max. Temp. (K) | 1057.6 |
| Breeder Max. Temp. (K) | 987.4 |
| Heat Source (W) | 2.44 × 10^5^ ± 3 × 10^3^ |
| Tritium Production (atoms/s) | 4.70 × 10^13^ ± 8 × 10^11^ |

 
 
2 changes: 1 addition & 1 deletion doc/content/verification_validation_examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ FENIX is under active development and does not currently have any benchmarking c

# List of example cases

[CAD-based geometry workflow example](cad_geometry_model/cad_model.md)
- [CAD-based geometry workflow example for fusion problems using OpenMC in FENIX](cad_geometry_model/cad_model.md) based on [!cite](Eltawila2024PBNC).

4 changes: 4 additions & 0 deletions test/tests/cad_geometry_example/gold/solid_out.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
time,max_T,source_integral
0,0,0
1,800,244158.40396983
2,1058.7439583588,243141.87849132
Binary file added test/tests/cad_geometry_example/gold/solid_out.e
Binary file not shown.
4 changes: 4 additions & 0 deletions test/tests/cad_geometry_example/gold/solid_out_openmc0.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
time,heat_source,heat_source_RelativeError,tritium_RelativeError,tritium_production
0,0,0,0,0
1,244158.40396983,0.0039604975020543,0.0030447507289791,47082007910425
2,243141.87849132,0.39003312775355,0.39353117228504,46825507978724
Binary file not shown.
6 changes: 3 additions & 3 deletions test/tests/cad_geometry_example/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Helium.add_element('He', 1.0)
Helium.set_density("kg/m3", 0.166)

mat2 = openmc.Material.mix_materials([eurofer, Helium], [0.65, 0.35], 'ao')
mat2 = openmc.Material.mix_materials([eurofer, Helium], [0.65, 0.35], 'ao', name="mat2")

beryllium = openmc.Material(name="beryllium")
beryllium.add_element('Be', 1.0)
Expand All @@ -48,7 +48,7 @@
Li4SiO4.add_element('O', 4.0)
Li4SiO4.set_density("g/cm3", 2.39)

mat3 = openmc.Material.mix_materials([eurofer, beryllium, Li4SiO4, Helium], [0.1, 0.37, 0.15, 0.38], 'ao')
mat3 = openmc.Material.mix_materials([eurofer, beryllium, Li4SiO4, Helium], [0.1, 0.37, 0.15, 0.38], 'ao',name="mat3")

mats = openmc.Materials([mat1, eurofer, Helium, mat2, beryllium, Li4SiO4, mat3])
mats.export_to_xml()
Expand Down Expand Up @@ -94,7 +94,7 @@
settings.source = source
settings.export_to_xml()

dagmc_univ = openmc.DAGMCUniverse(filename='torus7v2t2.h5m')
dagmc_univ = openmc.DAGMCUniverse(filename='tmesh_1.h5m')

geometry = openmc.Geometry(root=dagmc_univ)
geometry.export_to_xml()
4 changes: 2 additions & 2 deletions test/tests/cad_geometry_example/openmc.i
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
lowest_cell_level = 0
temperature_blocks = '1 2 3'
check_tally_sum = false
source_strength = 1e18 # Particles/sec.
source_strength = 1e18 # Particles/s.
volume_calculation = vol
tally_score = 'heating_local H3_production'
tally_trigger = 'rel_err none'
Expand All @@ -48,7 +48,7 @@
type = MoabSkinner
temperature_min = 800
temperature_max = 1100
n_temperature_bins = 100
n_temperature_bins = 10
temperature = temp
build_graveyard = true
[]
Expand Down
1 change: 1 addition & 0 deletions test/tests/cad_geometry_example/solid.i
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
exodus = true
print_linear_residuals = false
perf_graph = true
csv = true
[]

[MultiApps]
Expand Down
18 changes: 18 additions & 0 deletions test/tests/cad_geometry_example/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Tests]
design = 'cad_model.md'
issues = '#30'
[solid_diff]
type = Exodiff
input = 'solid.i'
exodiff = solid_out.e
requirement = "The system shall be able to solve for the temperature distribution."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
requirement = "The system shall be able to solve for the temperature distribution."
requirement = "The system shall be able to run a coupled neutronics and heat conduction simulation and solve for the temperature distribution."

required_objects = 'OpenMCCellAverageProblem'
[]
[openmc_diff]
type = Exodiff
input = 'solid.i'
exodiff = solid_out_openmc0.e
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exodiff = solid_out_openmc0.e
exodiff = solid_out_openmc0.e
should_execute = False # this test relies on the output files from solid_diff, so it shouldn't be run twice
prereq = solid_diff

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents the same test from being run twice, it simply leverages the results from the previous test.

requirement = "The system shall be able to solve for the heat source and tritium production."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
requirement = "The system shall be able to solve for the heat source and tritium production."
requirement = "The system shall be able to run a coupled neutronics and heat conduction simulation and solve for the heat source and tritium production."

required_objects = 'OpenMCCellAverageProblem'
[]
[]