Skip to content

Commit

Permalink
cad_workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoud Eltawila committed Nov 22, 2024
1 parent 6ae5cf4 commit 0bbfd23
Show file tree
Hide file tree
Showing 20 changed files with 529 additions and 0 deletions.
52 changes: 52 additions & 0 deletions doc/content/bib/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,55 @@ @book{lieberman1994principles
edition = {2nd},
year = {2005}
}

@article{giudicelli2024moose,
title = {3.0 - {MOOSE}: Enabling massively parallel multiphysics simulations},
author = {Guillaume Giudicelli and Alexander Lindsay and Logan Harbour and Casey Icenhour and
Mengnan Li and Joshua E. Hansel and Peter German and Patrick Behne and Oana Marin and
Roy H. Stogner and Jason M. Miller and Daniel Schwen and Yaqi Wang and Lynn Munday and
Sebastian Schunert and Benjamin W. Spencer and Dewen Yushu and Antonio Recuero and
Zachary M. Prince and Max Nezdyur and Tianchen Hu and Yinbin Miao and
Yeon Sang Jung and Christopher Matthews and April Novak and Brandon Langley and
Timothy Truster and Nuno Nobre and Brian Alger and David Andr{\v{s}} and
Fande Kong and Robert Carlsen and Andrew E. Slaughter and John W. Peterson and
Derek Gaston and Cody Permann},
year = {2024},
journal = {{SoftwareX}},
volume = {26},
pages = {101690},
issn = {2352-7110},
doi = {https://doi.org/10.1016/j.softx.2024.101690},
url = {https://www.sciencedirect.com/science/article/pii/S235271102400061X},
keywords = {Framework, Finite-element, Finite-volume, Parallel, Multiphysics, Multiscale},
}

@article{gaston2015physics,
title = {Physics-based multiscale coupling for full core nuclear reactor simulation},
author = {Derek R. Gaston and Cody J. Permann and John W. Peterson and Andrew E. Slaughter and
David Andr{\v{s}} and Yaqi Wang and Michael P. Short and Danielle M. Perez and Michael
R. Tonks and Javier Ortensi and Ling Zou and Richard C. Martineau},
year = {2015},
journal = {Annals of Nuclear Energy},
volume = {84},
pages = {45--54},
publisher = {Elsevier}
}

@Article{openmc,
author = {P.K. Romano and N.E. Horelik and B.R. Herman and A.G. Nelson and B. Forget and K. Smith},
title = {{OpenMC: A State-of-the-Art {Monte} {Carlo} Code for Research and Development}},
journal = {Annals of Nuclear Energy},
year = 2015,
volume = 82,
pages = {90--97},
DOI = {10.1016/j.anucene.2014.07.048}
}

@article{shimwell2021paramak,
title={The Paramak: automated parametric geometry construction for fusion reactor designs.},
author={Shimwell, Jonathan and Billingsley, John and Delaporte-Mathurin, R{\'e}mi and Morbey, Declan and Bluteau, Matthew and Shriwise, Patrick and Davis, Andrew},
journal={F1000Research},
volume={10},
year={2021},
publisher={Faculty of 1000 Ltd}
}
Binary file added doc/content/figures/cad_workflow_Temps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/content/figures/cad_workflow_d1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/content/figures/cad_workflow_mesh_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/content/figures/cad_workflow_transfers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# CAD-based Geometry Workflow for Multiphysics Fusion Problems Using OpenMC and MOOSE

This demonstration describes a workflow for modeling fusion problems in OpenMC and MOOSE using a computer aided design (CAD)-based geometry workflow. It is based on the work published in [!cite](Eltawila2024PBNC).

Fusion system designs are complex and require intricate and accurate models that can be best represented using CAD-based geometry. Fusion neutronics models are frequently leverage on CAD based geometries. An example is the Paramak python package [!cite](shimwell2021paramak) which allows production of 3D CAD models of fusion reactors. The model shown in [paramak] is based on the same generic workflow described in this tutorial.

!media figures/cad_workflow_transfers.png
id=paramak
caption=Tokamak model based on CAD generated with Paramak package
style=width:90%;display:block;margin-left:auto;margin-right:auto;

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

The results of the coupled neutronics and heat transfer model are shown in [tok_temps] and [tok_h3production] for the temperature distribution and tritium production rate density.

!media figures/cad_workflow_tokamak_temps.png
id=tok_temps
caption=Example Paramak tokamak model temperature distribution result
style=width:90%;display:block;margin-left:auto;margin-right:auto;

!col-end!

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

!media figures/cad_workflow_tokamak_tritium_production.png
id=tok_h3production
caption=Example Paramak tokamak model tritium production rate density result
style=width:90%;display:block;margin-left:auto;margin-right:auto;

!col-end!
!row-end!

In this example, you'll learn how to:
- Generate meshes for a coupled multiphysics FENIX model.
- Couple OpenMC [!cite](openmc) and MOOSE [!cite](giudicelli2024moose) using Cardinal for fixed source Monte Carlo calculations.
- Use Cardinal [!cite](novak2022_cardinal) to tally values of interest such as tritium production and heating which would be used in MOOSE to solve for the temperature distribution

We describe this workflow for a generic CAD model which is extremely simplified for the purpose of presenting the modeling workflow. This model was also used in [!cite](Eltawila2024PBNC) to perform mesh refinement studies to investigate how the different model meshes refinement affect multiphysics results. 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.

!media figures/cad_workflow_transfers.png
id=transfers
caption=OpenMC and MOOSE Coupling
style=width:90%;display:block;margin-left:auto;margin-right:auto;

## 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 ([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` ([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/cad_workflow_mesh_1.png
id=volumetric_mesh
caption=Model volumetric mesh
style=width:90%;display:block;margin-left:auto;margin-right:auto;

!col-end!

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

!media figures/cad_workflow_d1.png
id=dagmc
caption=Model DAGMC mesh
style=width:90%;display:block;margin-left:auto;margin-right:auto;

!col-end!
!row-end!

## OpenMC

The OpenMC input files is as follows:

!listing /test/tests/examples/cad_workflow/model.py language=python

## Cardinal

The Cardinal input files is shown below. The ([MoabSkinner](https://cardinal.cels.anl.gov/source/userobjects/MoabSkinner.html)) was chosen in this model to update the DAGMC geometry from the MOOSE mesh directly ensuring meshes matching which is furhter discussed in[!cite](Eltawila2024PBNC) as well as the use of cell tallies.

!listing /test/tests/examples/cad_workflow/openmc.i

## FENIX (MOOSE) Heat transfer

The FENIX input files is as follows:

!listing /test/tests/examples/cad_workflow/solid.i

## Execution

To generate OpenMC xml files, run:

```
python model.py
```

Then to run the coupled calculation:

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

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

 

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/cad_workflow_Temps.png
id=temps
caption=Temperature distribution result from [!cite](Eltawila2024PBNC)
style=width:90%;display:block;margin-left:auto;margin-right:auto;

!col-end!

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

!media figures/cad_workflow_tritium_production.png
id=h3production
caption=Tritium production rate density result from [!cite](Eltawila2024PBNC)
style=width:90%;display:block;margin-left:auto;margin-right:auto;

!col-end!
!row-end!

 

!table id=results caption=Results summary
| 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^ |

 
3 changes: 3 additions & 0 deletions doc/content/verification_validation_examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ FENIX is under active development and does not currently have any validation cas
!alert construction title=Under development - no example cases are available yet
FENIX is under active development and does not currently have any example cases available to users.

| Case | Title |
| ------- | ---------------------------------------------------------------------------------- |
| 1 | [CAD Workflow Example](CAD_based_workflow/CAD_workflow.md) based on [!cite](Eltawila2024PBNC). |
4 changes: 4 additions & 0 deletions test/tests/examples/cad_workflow/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/examples/cad_workflow/gold/solid_out.e
Binary file not shown.
4 changes: 4 additions & 0 deletions test/tests/examples/cad_workflow/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.
100 changes: 100 additions & 0 deletions test/tests/examples/cad_workflow/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import openmc
import math

mat1 = openmc.Material(name="mat1")
mat1.set_density('g/cc', 19.30)
mat1.add_element('W', 1.0)

eurofer = openmc.Material(name="eurofer")
eurofer.add_element('Fe', 0.011 , 'wo')
eurofer.add_element('Al', 0.002 , 'wo')
eurofer.add_element('As', 0.0002 , 'wo')
eurofer.add_element('B', 0.0012 , 'wo')
eurofer.add_element('C', 0.0005 , 'wo')
eurofer.add_element('Co', 0.0005 , 'wo')
eurofer.add_element('Cr', 0.0005 , 'wo')
eurofer.add_element('Cu', 0.00005 , 'wo')
eurofer.add_element('Mn', 0.00005 , 'wo')
eurofer.add_element('Mo', 0.0001 , 'wo')
eurofer.add_element('N', 0.0001 , 'wo')
eurofer.add_element('Nb', 0.00005 , 'wo')
eurofer.add_element('Ni', 0.0003 , 'wo')
eurofer.add_element('O', 0.00005 , 'wo')
eurofer.add_element('P', 0.004 , 'wo')
eurofer.add_element('S', 0.0001 , 'wo')
eurofer.add_element('Sb', 0.09 , 'wo')
eurofer.add_element('Sn', 0.0001 , 'wo')
eurofer.add_element('Si', 0.0011 , 'wo')
eurofer.add_element('Ta', 0.00002 , 'wo')
eurofer.add_element('Ti', 0.0005 , 'wo')
eurofer.add_element('V', 0 , 'wo')
eurofer.add_element('W', 0.0001 , 'wo')
eurofer.add_element('Zr', 0.88698 , 'wo')
eurofer.set_density("g/cm3", 7.798)

Helium = openmc.Material(name="Helium")
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', name="mat2")

beryllium = openmc.Material(name="beryllium")
beryllium.add_element('Be', 1.0)
beryllium.set_density("g/cm3", 1.85)

Li4SiO4 = openmc.Material(name="Li4SiO4")
Li4SiO4.add_element('Li', 4.0)
Li4SiO4.add_element('Si', 1.0)
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',name="mat3")

mats = openmc.Materials([mat1, eurofer, Helium, mat2, beryllium, Li4SiO4, mat3])
mats.export_to_xml()

pz = openmc.Plot()
pz.basis = 'yz'
pz.origin = (0.0, 0.0, 0.0)
pz.width = (200.0, 200.0)
pz.pixels = (500, 500)
pz.color_by = 'material'

px = openmc.Plot()
px.basis = 'xy'
px.origin = (0.0, 0.0, 0.0)
px.width = (200, 200)
px.pixels = (500, 500)
px.color_by = 'material'

plots = openmc.Plots([pz,px])
plots.export_to_xml()

settings = openmc.Settings()
settings.dagmc = True
settings.batches = 100
settings.particles = 10000000
settings.run_mode = "fixed source"

settings.temperature = {'default': 800.0,
'method': 'interpolation',
'range': (294.0, 3000.0),
'tolerance': 1000.0}

source = openmc.Source()

r = openmc.stats.PowerLaw(55, 65, 1.0)
phi = openmc.stats.Uniform(0.0, 2*math.pi)
z = openmc.stats.Discrete([0,], [1.0,])
spatial_dist = openmc.stats.CylindricalIndependent(r, phi, z)

source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14.08e6], [1.0])
source.space=spatial_dist
settings.source = source
settings.export_to_xml()

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

geometry = openmc.Geometry(root=dagmc_univ)
geometry.export_to_xml()
Loading

0 comments on commit 0bbfd23

Please sign in to comment.