Skip to content

Commit

Permalink
Merge pull request #27 from fusion-energy/develop
Browse files Browse the repository at this point in the history
Updating the paramak version used to 0.6.7
  • Loading branch information
shimwell authored Feb 15, 2022
2 parents 1012c90 + 1cde4cc commit 84939c6
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 201 deletions.
55 changes: 16 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# docker build -t fusion-neutronics-workflow:embree-avx --build-arg compile_cores=7 --build-arg build_double_down=ON --build-arg include_avx=false .


# TODO save build time by basing this on FROM ghcr.io/fusion-energy/paramak:latest
# This can't be done currently as the base images uses conda installs for moab / dagmc which don't compile with OpenMC
FROM ghcr.io/openmc-data-storage/miniconda3_4.9.2_endfb-7.1_nndc_tendl_2019:latest

Expand Down Expand Up @@ -64,9 +63,13 @@ RUN pip install cython
RUN conda install -c anaconda numpy==1.21.2

# Installing CadQuery
RUN conda install -c conda-forge -c cadquery cadquery=2.1 && \
RUN conda install -c conda-forge -c cadquery cadquery=master && \
pip install jupyter-cadquery==2.1.0

# Installing Gmsh
RUN conda install -c conda-forge gmsh && \
conda install -c conda-forge python-gmsh

# Install neutronics dependencies from Debian package manager
RUN apt-get install -y \
wget \
Expand All @@ -89,20 +92,6 @@ RUN apt-get --yes install libeigen3-dev && \
apt-get --yes install libtbb-dev && \
apt-get --yes install libglfw3-dev

# install Cubit dependencies
RUN apt-get install -y libx11-6
RUN apt-get install -y libxt6
RUN apt-get install -y libgl1
RUN apt-get install -y libglu1-mesa
RUN apt-get install -y libgl1-mesa-glx
RUN apt-get install -y libxcb-icccm4
RUN apt-get install -y libxcb-image0
RUN apt-get install -y libxcb-keysyms1
RUN apt-get install -y libxcb-render-util0
RUN apt-get install -y libxkbcommon-x11-0
RUN apt-get install -y libxcb-randr0
RUN apt-get install -y libxcb-xinerama0


# Clone and install Embree
# embree from conda is not supported yet
Expand Down Expand Up @@ -196,10 +185,8 @@ RUN mkdir DAGMC && \
# Clone and install OpenMC with DAGMC
# TODO clone a specific release when the next release containing (PR 1825) is avaialble.
RUN cd /opt && \
git clone --single-branch --branch develop https://github.com/openmc-dev/openmc.git && \
git clone --single-branch --branch v0.13.0 --depth 1 https://github.com/openmc-dev/openmc.git && \
cd openmc && \
# this commit is from this PR https://github.com/openmc-dev/openmc/pull/1900
git checkout 0157dc219ff8dca814859b3140c6cef1e78cdee1 && \
cd /opt/openmc && \
mkdir build && \
cd build && \
Expand All @@ -212,33 +199,23 @@ RUN cd /opt && \
cd .. && \
pip install -e .[test]

# Download Cubit
RUN wget -O coreform-cubit-2021.5.deb https://f002.backblazeb2.com/file/cubit-downloads/Coreform-Cubit/Releases/Linux/Coreform-Cubit-2021.5%2B15962_5043ef39-Lin64.deb

# Install cubit
RUN dpkg -i coreform-cubit-2021.5.deb

# installs svalinn plugin for cubit
RUN wget https://github.com/svalinn/Cubit-plugin/releases/download/0.2.1/svalinn-plugin_debian-10.10_cubit_2021.5.tgz
RUN tar -xzvf svalinn-plugin_debian-10.10_cubit_2021.5.tgz -C /opt/Coreform-Cubit-2021.5

# writes a non commercial license file
RUN mkdir -p /root/.config/Coreform/licenses
RUN printf 'Fri May 28 2021' >> /root/.config/Coreform/licenses/cubit-learn.lic

# needed to prevent hdf5 conflict between MOAB and Cubit
ENV HDF5_DISABLE_VERSION_CHECK=1

# helps to identify Cubit related errrors
ENV CUBIT_VERBOSE=5


COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

# installs python packages and nuclear data
# solves binary incompatabilitiy error
RUN pip install numpy --upgrade


# installs python packages and nuclear data (quick as it does not overwrite existing h5 files)
RUN openmc_data_downloader -d nuclear_data -e all -i H3 -l ENDFB-7.1-NNDC TENDL-2019 -p neutron photon --no-overwrite

# solves OSError: libXft.so.2: cannot open shared object file: No such file or directory
RUN apt-get install libxft2
#libxft2:i386 lib64ncurses5
#RUN apt install libxext6
#RUN apt install libxext6:i386

# setting enviromental varibles
ENV OPENMC_CROSS_SECTIONS=/nuclear_data/cross_sections.xml
Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

[![CI with install](https://github.com/fusion-energy/fusion_neutronics_workflow/actions/workflows/ci_with_install.yml/badge.svg)](https://github.com/fusion-energy/fusion_neutronics_workflow/actions/workflows/ci_with_install.yml)

<!-- [![docker-publish-release](https://github.com/fusion-energy/fusion_neutronics_workflow/actions/workflows/docker_publish.yml/badge.svg)](https://github.com/fusion-energy/fusion_neutronics_workflow/actions/workflows/docker_publish.yml) -->
[![docker-publish-release](https://github.com/fusion-energy/fusion_neutronics_workflow/actions/workflows/docker_publish.yml/badge.svg)](https://github.com/fusion-energy/fusion_neutronics_workflow/actions/workflows/docker_publish.yml)


# Fusion Neutronics Workflow

![fusion neutronics workflow](https://user-images.githubusercontent.com/8583900/145485618-d4733a82-4f8a-4f8d-a669-7419f076a567.png)
![fusion neutronics workflow](https://user-images.githubusercontent.com/8583900/150701623-29fbf50b-0203-4818-b318-2f3a996e1db7.png)

Diagram showing the connectivity of software packages that make up the Fusion
Neutronics Workflow. Software that the user interacts with directly are shown
Expand All @@ -27,7 +27,8 @@ that is:
- Automated - the entire workflow can be run automatically. Care has been taken
to code out all manual processes so that the neutronics analysis can be
performed in an API manner. As a result it is therefore possible to drive
the workflow with machine learning, optimization or parameter space sampling methods.
the workflow with machine learning, optimization or parameter space
sampling methods.
- Scalable - by using efficient interfaces (Embree, Double Down) and
accelerated geometry (DAGMC) together with scalable Monte Carlo transport
(OpenMC) the resulting workflow scales well with computational power.
Expand Down Expand Up @@ -101,36 +102,43 @@ Links to the packages that are utilized by the fusion-neutronics-workflow
needed for OpenMC neutronics simulations.

* [openmc-plasma-source](https://github.com/fusion-energy/openmc-plasma-source/)
Creates a plasma source as an openmc.source object from input parameters that describe the plasma

* [spectrum_plotter](https://github.com/fusion-energy/spectrum_plotter)
A Python package for creating publication quality plots for neutron / photon / particle spectrum

* [openmc_mesh_tally_to_vtk](https://github.com/fusion-energy/openmc_mesh_tally_to_vtk)
A Python package for converting OpenMC mesh tallies to VTK files and optionally converting the units

* [regular_mesh_plotter](https://github.com/fusion-energy/regular_mesh_plotter)
A Python package for plotting regular mesh tally results from neutronics simulations.

* [dagmc_geometry_slice_plotter](https://github.com/fusion-energy/dagmc_geometry_slice_plotter)
* [dagmc_geometry_slice_plotter](https://github.com/fusion-energy/dagmc_geometry_slice_plotter) A minimal Python package that produces slice plots through h5m DAGMC geometry files

* [dagmc_bounding_box](https://github.com/fusion-energy/dagmc_bounding_box)
Finds the bounding box and related properties of a DAGMC geometry

* [remove_dagmc_tags](https://github.com/svalinn/remove_dagmc_tags)
* [remove_dagmc_tags](https://github.com/svalinn/remove_dagmc_tags) A python package and command line tool for removing DAGMC tags such as graveyard and vacuum

* [dagmc_h5m_file_inspector](https://github.com/fusion-energy/dagmc_h5m_file_inspector)
Extracts information from DAGMC h5m files including volumes number, material tags

* [brep_to_h5m](https://github.com/fusion-energy/brep_to_h5m) Converts Brep CAD geometry files to h5m geometry files compatible with DAGMC simulations

* [brep_part_finder](https://github.com/fusion-energy/brep_part_finder) A Python package to identify the part ID number in Brep format CAD files

* Open source projects that are utilized and contributed to

* [OpenMC](https://github.com/openmc-dev/openmc) The OpenMC project, a
Monte Carlo particle transport code based on modern methods.

* [DAGMC](https://github.com/svalinn/DAGMC) Direct Accelerated Geometry
Monte Carlo Toolkit
Monte Carlo Toolkit

* [Svalinn Cubit Plugin](https://github.com/svalinn/Cubit-plugin/) a plugin
and command extensions for Cubit that allows h5m files to be exported.
* [SphinxCadQuery](https://github.com/CadQuery/sphinxcadquery) An extension to visualize CadQuery 3D files in your Sphinx documentation

* [SphinxCadQuery](https://github.com/CadQuery/sphinxcadquery)


* OpenMC source projects utilized in the software stack
* Open source projects utilized in the software stack

* [MOAB and pymoab](https://github.com/svalinn/Cubit-plugin/) the
Mesh-Oriented datABase MOAB is a component for representing and evaluating
Expand All @@ -145,12 +153,7 @@ Links to the packages that are utilized by the fusion-neutronics-workflow
* [Embree](https://github.com/embree/embree) high-performance ray tracing
kernels

* [Gmsh](https://gitlab.onelab.info/gmsh/gmsh) A three-dimensional finite
element mesh generator with built-in pre- and post-processing facilities

* Scipy, Numpy, Plotly, Pint and other standard scientific Python packages


* Commercial codes (with non commercial license available)

* [Coreform Cubit](https://github.com/svalinn/Cubit-plugin/) - advanced
meshing for challenging simulations. Supports imprinting and merging of
surfaces which speed up the neutronics transport time required for
simulations through faceted geometry.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@
# A surrounding volume called a graveyard is needed for neutronics simulations

import paramak
from stl_to_h5m import stl_to_h5m

import os

my_shape = paramak.ExtrudeStraightShape(
name='my_material',
points=[(400, 100), (400, 200), (600, 200), (600, 100)],
distance=180,
)

my_shape.export_stl("steel.stl")

# This script converts the CAD stp files generated into h5m files that can be
# used in DAGMC enabled codes. One of the key aspects of this is the assignment
# of materials to the volumes present in the CAD files.
my_shape.export_dagmc_h5m('dagmc.h5m')

stl_to_h5m(
files_with_tags=[
("steel.stl", "mat1"),
],
h5m_filename="dagmc.h5m",
)
# this converts the neutronics geometry h5m file into a vtk file for
# visualisation in Paraview or Visit
os.system('mbconvert dagmc.h5m dagmc.vtk')
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
# sets the material to use
materials = odw.Materials(
h5m_filename='dagmc.h5m',
correspondence_dict={"mat1": "eurofer"}
correspondence_dict={"mat_my_material": "eurofer"}
)

# creates a cell tally for neutron flux
tally1 = odw.CellTally(
tally_type="neutron_flux",
target="mat1",
target="mat_my_material",
materials=materials
)

# creates a cell tally for neutron spectra
tally2 = odw.CellTally(
tally_type="neutron_spectra",
target="mat1",
target="mat_my_material",
materials=materials
)

Expand All @@ -63,7 +63,7 @@
statepoint = openmc.StatePoint(filepath=statepoint_file)

# gets the first tally using its name
my_tally_1 = statepoint.get_tally(name="mat1_neutron_flux")
my_tally_1 = statepoint.get_tally(name="mat_my_material_neutron_flux")

# gets number of neutron for a 1.3 mega joule shot
source_strength = otuc.find_source_strength(fusion_energy_per_second_or_per_pulse=1.3e6)
Expand All @@ -78,7 +78,7 @@
print(f"flux per second = {result}", end="\n\n")

# gets the second tally using its name
my_tally_2 = statepoint.get_tally(name="mat1_neutron_spectra")
my_tally_2 = statepoint.get_tally(name="mat_my_material_neutron_spectra")

# returns the tally converted to MeV, scaled and normalisation for source strength
result = otuc.process_spectra_tally(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# A surrounding volume called a graveyard is needed for neutronics simulations

import paramak
import os


my_reactor = paramak.BallReactor(
Expand All @@ -20,52 +21,13 @@
elongation=2.75,
triangularity=0.5,
number_of_tf_coils=16,
rotation_angle=360
rotation_angle=180
)

# exports the reactor shapes to stp files. The list of stp filenames provided
# is made from the shape names with ".stp" added to each one using python
# list comprehension.
# exports the reactor shapes as a DAGMC h5m file which can be used as
# neutronics geometry by OpenMC
my_reactor.export_dagmc_h5m('dagmc.h5m')


# exports the reactor shapes as separate stp files using default stp filenames
stp_filenames = my_reactor.export_stp()


# This script converts the CAD stp files generated into h5m files that can be
# used in DAGMC enabled codes. h5m files created in this way are imprinted,
# merged, faceted and ready for use in OpenMC.

# One of the key aspects of this is the assignment of materials to the volumes present in the CAD files.
# The stp files along with their material tags are based on the names of the
# shapes in the reactor using dictionary comprehension.


# method uses cubit to create dagmc h5m file.

# files_with_tags = [{'cad_filename':stp_filename, 'material_tag':name} for name, stp_filename in zip(my_reactor.name, stp_filenames)]
# produces a list of dictionaries of with cad_filename and material_tag as the keys.
# the values are the stp filename and the name of the component
# [{'cad_filename': 'plasma.stp', 'material_tag': 'plasma'}, {'cad_filename': 'inboard_tf_coils.stp', 'material_tag': 'inboard_tf_coils'}, {'cad_filename': 'center_column_shield.stp', 'material_tag': 'center_column_shield'}, {'cad_filename': 'firstwall.stp', 'material_tag': 'firstwall'}, {'cad_filename': 'blanket.stp', 'material_tag': 'blanket'}, {'cad_filename': 'blanket_rear_wall.stp', 'material_tag': 'blanket_rear_wall'}, {'cad_filename': 'divertor.stp', 'material_tag': 'divertor'}]

# from cad_to_h5m import cad_to_h5m
# cad_to_h5m(
# files_with_tags=files_with_tags,
# h5m_filename='dagmc.h5m',
# cubit_path='/opt/Coreform-Cubit-2021.5/bin/'
# )


# in case you don't have Cubit with the Svalin plugin installed you could use
# stl_to_h5m. This doesn't imprint and merge the geometry so there could be
# overlaps and tunneling particles.
from stl_to_h5m import stl_to_h5m

# exports the reactor shapes as separate stl files using default stl filenames
stl_filenames = my_reactor.export_stl()
files_with_tags = [(stl_filename, name) for name, stl_filename in zip(my_reactor.name, stl_filenames)]

stl_to_h5m(
files_with_tags=files_with_tags,
h5m_filename='dagmc_not_imprinted_and_merged.h5m',
)
# this converts the neutronics geometry h5m file into a vtk file for
# visualisation in Paraview or Visit
os.system('mbconvert dagmc.h5m dagmc.vtk')
37 changes: 21 additions & 16 deletions example_02_multi_volume_cell_tally/2_run_neutronics_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,28 @@
import openmc_plasma_source as ops
import openmc_tally_unit_converter as otuc

dagmc_filename = "dagmc_not_imprinted_and_merged.h5m"
# geometry = odw.Geometry(h5m_filename="dagmc.h5m")
geometry = odw.Geometry(h5m_filename=dagmc_filename)
# makes an OpenMC geometry object from the dagmc file
geometry = odw.Geometry(
h5m_filename="dagmc.h5m",
reflective_angles=(0, 180)
)


# this links the material tags in the dagmc h5m file with materials.
# these materials are input as strings so they will be looked up in the
# neutronics material maker package
material_tag_to_material_dict = {
"plasma": "DT_plasma",
"inboard_tf_coils": "copper",
"center_column_shield": "tungsten",
"firstwall": "tungsten",
"blanket": "Li4SiO4",
"blanket_rear_wall": "eurofer",
"divertor": "tungsten",
}

materials = odw.Materials(
h5m_filename=dagmc_filename, correspondence_dict=material_tag_to_material_dict
h5m_filename=geometry.h5m_filename,
correspondence_dict={
"mat_plasma": "DT_plasma",
"mat_inboard_tf_coils": "copper",
"mat_center_column_shield": "tungsten",
"mat_firstwall": "tungsten",
"mat_blanket": "Li4SiO4",
"mat_blanket_rear_wall": "eurofer",
"mat_divertor_upper": "tungsten",
"mat_divertor_lower": "tungsten",
}
)

tally1 = odw.CellTally(tally_type="TBR", target="blanket", materials=materials)
Expand All @@ -39,7 +42,7 @@
tallies = openmc.Tallies([tally1, tally2])

settings = odw.FusionSettings()
settings.batches = 1
settings.batches = 2
settings.particles = 100
# assigns a ring source of DT energy neutrons to the source using the
# openmc_plasma_source package
Expand All @@ -64,7 +67,9 @@

# returns the tally with normalisation for source strength
result = otuc.process_dose_tally(
source_strength=1.3e6, tally=my_tally_2, required_units="Sv / second",
source_strength=1.3e6,
tally=my_tally_2,
required_units="Sv / second",
volume= 100 # in the future this volume of the component will be found automatically
)
print(f"effective dose = {result}", end="\n\n")
Loading

0 comments on commit 84939c6

Please sign in to comment.