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

adds CI #3

Merged
merged 13 commits into from
Mar 24, 2022
56 changes: 56 additions & 0 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# This CI will launch a Docker image that contains all the dependencies required
# within that image the pytest test suite is run


name: CI with install

on:
pull_request:
branches:
- develop
- main

jobs:
testing:
runs-on: ubuntu-latest
container:
image: continuumio/miniconda3
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: install dependencies package
run: |
apt update -y
apt-get install ffmpeg libsm6 libxext6 -y

- name: create environment 1
run: |
conda env create -f environment_cad.yml
conda init bash
.source ~/.bashrc
conda activate env_cad

- name: conda init
run: |
bash -i conda_init_for_ci.sh

- name: run script 1 of 3
run: |
python 1_creation_of_dagmc_geometry.py

- name: create environment 1
run: |
conda env create -f environment_neutronics.yml
conda init bash
.source ~/.bashrc
conda activate env_neutronics

- name: run script 2 of 3
run: |
2_run_openmc_dagmc_simulation.py

- name: run script 3 of 3
run: |
3_extract_results.py
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,12 @@ dmypy.json

# Pyre type checker
.pyre/

# output files
*.h5m
*.html
*.xml
*.h5
*.out
*.xml
*.vtk
23 changes: 15 additions & 8 deletions 2_run_openmc_dagmc_simulation.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import openmc
import openmc_data_downloader as odd


# Names of material tags can be found with the command line tool
# mbsize -ll dagmc.h5m | grep 'NAME = mat:'


mat_vacuum_vessel = openmc.Material(name="mat_vacuum_vessel")
mat_vacuum_vessel = openmc.Material(name="vacuum_vessel")
mat_vacuum_vessel.add_element("Fe", 1, "ao")
mat_vacuum_vessel.set_density("g/cm3", 7.7)

mat_upper_blanket = openmc.Material(name="mat_upper_blanket")
mat_upper_blanket = openmc.Material(name="upper_blanket")
mat_upper_blanket.add_element("Li", 1, "ao")
mat_upper_blanket.set_density("g/cm3", 0.5)

mat_lower_blanket = openmc.Material(name="mat_lower_blanket")
mat_lower_blanket = openmc.Material(name="lower_blanket")
mat_lower_blanket.add_element("Li", 1, "ao")
mat_lower_blanket.set_density("g/cm3", 0.5)

mat_lower_vacuum_vessel = openmc.Material(name="mat_lower_vacuum_vessel")
mat_lower_vacuum_vessel = openmc.Material(name="lower_vacuum_vessel")
mat_lower_vacuum_vessel.add_element("Fe", 1, "ao")
mat_lower_vacuum_vessel.set_density("g/cm3", 7.7)

mat_upper_vacuum_vessel = openmc.Material(name="mat_upper_vacuum_vessel")
mat_upper_vacuum_vessel = openmc.Material(name="upper_vacuum_vessel")
mat_upper_vacuum_vessel.add_element("Fe", 1, "ao")
mat_upper_vacuum_vessel.set_density("g/cm3", 7.7)

mat_blanket = openmc.Material(name="mat_blanket")
mat_blanket = openmc.Material(name="blanket")
mat_blanket.add_element("Li", 1, "ao")
mat_blanket.set_density("g/cm3", 0.5)

Expand All @@ -39,6 +40,12 @@
]
)

#downloads the nuclear data and sets the openmc_cross_sections environmental variable
odd.just_in_time_library_generator(
libraries='ENDFB-7.1-NNDC',
materials=materials
)

# makes use of the dagmc geometry
dag_univ = openmc.DAGMCUniverse("dagmc.h5m")

Expand All @@ -62,7 +69,7 @@
# specifies the simulation computational intensity
settings = openmc.Settings()
settings.batches = 10
settings.particles = 100000
settings.particles = 10000
settings.inactive = 0
settings.run_mode = "fixed source"
settings.source = my_source
Expand Down
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
This example simulates a simplfied model of an inertial confinement fusion reactor.
<!-- [![CI with install](https://github.com/shimwell/cad-to-dagmc-to-openmc-example/actions/workflows/ci_with_install.yml/badge.svg)](https://github.com/shimwell/cad-to-dagmc-to-openmc-example/actions/workflows/ci_with_install.yml) -->

This example simulates a simplified model of an inertial confinement fusion reactor.

- A CAD model is made and automatically converted to a DAGMC geometry that is then used in OpenMC for a neutronics simulation.
- The neutronics simulation obtains the tritium breeding ratio and a 3D map of tritium production.
- The simulation outputs are post processed to display the results and produce a VTK file for visualization.

# Prerequisites

This minimal example makes use of Conda to manage and install the packages.

You will need one of these conda distributions to be installed or work within a [Docker image](https://hub.docker.com/r/continuumio/miniconda3)

- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)

- [Anaconda](https://www.anaconda.com/)

- [Miniforge](https://github.com/conda-forge/miniforge)

- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)

# First clone the repository
```bash
git clone https://github.com/shimwell/cad-to-dagmc-to-openmc-example.git
cd cad-to-dagmc-to-openmc-example
```

# Making the DAGMC model.
# Making the DAGMC model

Make an environment for the model preparation
```
conda create --name paramak_env python=3.9
conda activate paramak_env
conda install -c fusion-energy -c cadquery -c conda-forge paramak
pip install jupyter_cadquery
conda env create -f environment_cad.yml
conda activate env_cad
```

Then run the script for making the DAGMC model.
Expand All @@ -29,25 +43,20 @@ Then open the ```dagmc.html``` file in an internet browser to view the CAD creat

![CAD geometry image](https://user-images.githubusercontent.com/8583900/159698975-d82544c7-635b-4117-b4bc-4d61a8cf9ecc.png)


Optionally you can inspect the DAGMC file at this stage by converting the h5m file to a vtk file and opening this with [Paraview](https://www.paraview.org/)
```
mbconvert dagmc.h5m dagmc.vtk
paraview dagmc.vtk
```
![DAGMC model image](https://user-images.githubusercontent.com/8583900/159698979-3665e14b-ca42-4df2-8a1e-deee6597efc0.png)



# Simulating the model in OpenMC.
# Simulating the model in OpenMC

First make an environment for simulation.

```
conda create --name openmc_dagmc_env python=3.9
conda activate openmc_dagmc_env
conda install -c conda-forge openmc
pip install openmc_mesh_tally_to_vtk
conda env create -f environment_neutronics.yml
conda activate env_neutronics
```

Then run the simulation which will produce a statepoint.10.h5 file that contains the simulation outputs
Expand All @@ -60,7 +69,7 @@ Then run the post processing script that should output the Tritium Breeding Rati
python 3_extract_results.py
```

Open up the VTK file with paraview
Open up the VTK file with Paraview and slice the data to see the high tritium breeding region
```bash
paraview tritium_production_map.vtk
```
Expand Down
1 change: 1 addition & 0 deletions conda_init_for_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda init
13 changes: 13 additions & 0 deletions environment_cad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


name: env_cad
channels:
- fusion-energy
- cadquery
- conda-forge
dependencies:
- python=3.9
- paramak=0.7.2
- pip
- pip:
- jupyter-cadquery
12 changes: 12 additions & 0 deletions environment_neutronics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


name: env_neutronics
channels:
- conda-forge
dependencies:
- python=3.9
- openmc=0.13.0
- pip
- pip:
- openmc_data_downloader
- openmc_mesh_tally_to_vtk