-
Notifications
You must be signed in to change notification settings - Fork 7
cad_geometry_example #29
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
Closed
Closed
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f75d6c6
cad_geometry_example
fcd85c4
Apply suggestions from code review
meltawila d6c0fde
delete unnecessary code
meltawila 95e5a50
Merge branch 'devel' into cardinal_example
7b75887
moved to new path
58079fe
fix errors
88e264d
..
f6dad69
(Ref. #30)
5b1b2d5
fixing more errors
7495739
Apply suggestions from code review
meltawila 48e96a9
Update cad_model.md
meltawila a7298b7
.
10273f2
edititng format
effd00b
fix format
9b00808
fix format
adf691c
formatting
f11264c
formatting
193d3c6
.
23938be
..
8bc1c03
...
3705d83
add test files
1a3ebb2
add execution instructions
f02657c
Apply suggestions from code review
meltawila 7c8b95c
Apply more suggestions from code review
meltawila 09a3c46
figures formatting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
122 changes: 122 additions & 0 deletions
122
doc/content/verification_validation_examples/cad_geometry_model/cad_model.md
This file contains hidden or 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,122 @@ | ||
# 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). | ||
|
||
In this example, you'll learn how to: | ||
|
||
- 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 | ||
|
||
!media figures/transfers.png | ||
id=transfers | ||
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 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 ([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/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 | ||
|
||
!col-end! | ||
!row-end! | ||
|
||
## OpenMC | ||
|
||
The OpenMC input files is as follows: | ||
|
||
!listing /test/tests/cad_geometry_example/model.py language=python | ||
|
||
## 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
|
||
|
||
## 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 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 | ||
|
||
| ||
|
||
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 | ||
|
||
!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 | ||
|
||
!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^ | | ||
|
||
|
Binary file added
BIN
+316 KB
doc/content/verification_validation_examples/cad_geometry_model/figures/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
BIN
+2.64 MB
doc/content/verification_validation_examples/cad_geometry_model/figures/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
BIN
+2.64 MB
doc/content/verification_validation_examples/cad_geometry_model/figures/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.
Binary file added
BIN
+825 KB
...ntent/verification_validation_examples/cad_geometry_model/figures/transfers.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
BIN
+205 KB
...ification_validation_examples/cad_geometry_model/figures/tritium_production.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,4 @@ | ||
time,max_T,source_integral | ||
0,0,0 | ||
1,800,244158.40396983 | ||
2,1058.7439583588,243141.87849132 |
Binary file not shown.
This file contains hidden or 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,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.
This file contains hidden or 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,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() |
This file contains hidden or 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,83 @@ | ||
[Mesh] | ||
[file] | ||
type = FileMeshGenerator | ||
file = tmesh_1.e | ||
[] | ||
[] | ||
|
||
[AuxVariables] | ||
[cell_temperature] | ||
family = MONOMIAL | ||
order = CONSTANT | ||
[] | ||
[] | ||
|
||
[AuxKernels] | ||
[cell_temperature] | ||
type = CellTemperatureAux | ||
variable = cell_temperature | ||
[] | ||
[] | ||
|
||
[Problem] | ||
type = OpenMCCellAverageProblem | ||
tally_type = cell | ||
tally_name = 'heat_source H3' | ||
lowest_cell_level = 0 | ||
temperature_blocks = '1 2 3' | ||
check_tally_sum = false | ||
source_strength = 1e18 # Particles/s. | ||
volume_calculation = vol | ||
tally_score = 'heating_local H3_production' | ||
tally_trigger = 'rel_err none' | ||
tally_trigger_threshold = '0.1 0.1' | ||
verbose = true | ||
max_batches = 10 | ||
batch_interval = 5 | ||
particles = 5000 | ||
output = unrelaxed_tally_std_dev | ||
skinner = moab | ||
[] | ||
|
||
[UserObjects] | ||
[vol] | ||
type = OpenMCVolumeCalculation | ||
n_samples = 5000 | ||
[] | ||
[moab] | ||
type = MoabSkinner | ||
temperature_min = 800 | ||
temperature_max = 1100 | ||
n_temperature_bins = 10 | ||
temperature = temp | ||
build_graveyard = true | ||
[] | ||
[] | ||
|
||
[Postprocessors] | ||
[heat_source] | ||
type = ElementIntegralVariablePostprocessor | ||
variable = heat_source | ||
[] | ||
[tritium_production] | ||
type = ElementIntegralVariablePostprocessor | ||
variable = H3 | ||
[] | ||
[tritium_RelativeError] | ||
type = TallyRelativeError | ||
tally_score = h3_production | ||
[] | ||
[heat_source_RelativeError] | ||
type = TallyRelativeError | ||
tally_score = heating_local | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
csv = true | ||
[] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.