Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Jonathan Shimwell
John Billingsley
Remi Delaporte-Mathurin
Declan Morbey
Matthew Bluteau
Patrick Shriwise
213 changes: 213 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# This dockerfile can be built in a few different ways.
Copy link
Author

Choose a reason for hiding this comment

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

BUG RISK
Currently, the project is installed in /. This is fine, but it clutters the root directory of the docker image and makes it so that the user cannot simply volume mount their current directory to test its changes via:

docker run -ti --rm -v `pwd`:/paramak ukaea/paramak bash

If the user tries to volume mount inside of /, then they'll replace the entire filesystem.

# Docker build commands must be run from within the base repository directory
#
# There are build args availalbe for specifying the:
# - cq_version
# The version of CadQuery to use master or 2.
# Default is 2.
# Options: [master, 2]
#
# - include_neutronics
# If software dependencies needed for neutronics simulations should be
# included true or false.
# Default is false.
# Options: [true, false]
#
# - compile_cores
# The number of CPU cores to compile the image with.
# Default is 1.
# Options: [1, 2, 3, 4, 5, 6...]
#
# Example builds:
# Building using the defaults (cq_version 2, no neutronics and 1 core compile)
# docker build -t ukaea/paramak .
#
# Building to include cadquery master, neutronics dependencies and use 8 cores.
# Run command from within the base repository directory
# docker build -t ukaea/paramak --build-arg include_neutronics=true --build-arg compile_cores=8 --build-arg cq_version=master .

# Once build the dockerimage can be run in a few different ways.
#
# Run with the following command for a terminal notebook interface
# docker run -it ukaea/paramak .
#
# Run with the following command for a jupyter notebook interface
# docker run -p 8888:8888 ukaea/paramak /bin/bash -c "jupyter notebook --notebook-dir=/examples --ip='*' --port=8888 --no-browser --allow-root"


# Once built, the docker image can be tested with either of the following commands
# docker run --rm ukaea/paramak pytest /tests
# docker run --rm ukaea/paramak /bin/bash -c "cd .. && bash run_tests.sh"

FROM continuumio/miniconda3

# By default this Dockerfile builds with the latest release of CadQuery 2
ARG cq_version=2
ARG include_neutronics=false
ARG compile_cores=1

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 \
PATH=/opt/openmc/bin:/opt/NJOY2016/build:$PATH \
LD_LIBRARY_PATH=/opt/openmc/lib:$LD_LIBRARY_PATH \
CC=/usr/bin/mpicc CXX=/usr/bin/mpicxx \
DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y && \
apt-get upgrade -y

RUN apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev \
freeglut3-dev libosmesa6 libosmesa6-dev \
libgles2-mesa-dev && \
apt-get clean

# Installing CadQuery
# jupyter is installed before cadquery to avoid a conflict
RUN echo installing CadQuery version $cq_version && \
conda install jupyter -y --quiet && \
conda install -c cadquery -c conda-forge cadquery="$cq_version" && \
conda clean -afy

# Install neutronics dependencies from Debian package manager
RUN if [ "$include_neutronics" = "true" ] ; \
then echo installing with include_neutronics=true ; \
apt-get install -y \
wget git gfortran g++ cmake \
mpich libmpich-dev libhdf5-serial-dev libhdf5-mpich-dev \
imagemagick ; \
fi

# install addition packages required for MOAB
RUN if [ "$include_neutronics" = "true" ] ; \
then echo installing with include_neutronics=true ; \
apt-get --yes install libeigen3-dev ; \
apt-get --yes install libblas-dev ; \
apt-get --yes install liblapack-dev ; \
apt-get --yes install libnetcdf-dev ; \
apt-get --yes install libtbb-dev ; \
apt-get --yes install libglfw3-dev ; \
fi

# Clone and install NJOY2016
RUN if [ "$include_neutronics" = "true" ] ; \
then git clone https://github.com/njoy/NJOY2016 /opt/NJOY2016 ; \
cd /opt/NJOY2016 ; \
mkdir build ; \
cd build ; \
cmake -Dstatic=on .. ; \
make 2>/dev/null ; \
make install ; \
fi

# Clone and install Embree
RUN if [ "$include_neutronics" = "true" ] ; \
then git clone https://github.com/embree/embree ; \
cd embree ; \
mkdir build ; \
cd build ; \
cmake .. -DCMAKE_INSTALL_PREFIX=.. \
-DEMBREE_ISPC_SUPPORT=OFF ; \
make -j"$compile_cores" ; \
make -j"$compile_cores" install ; \
fi

# Clone and install MOAB
RUN if [ "$include_neutronics" = "true" ] ; \
then pip install --upgrade numpy cython ; \
mkdir MOAB ; \
cd MOAB ; \
mkdir build ; \
git clone --single-branch --branch develop https://bitbucket.org/fathomteam/moab/ ; \
cd build ; \
cmake ../moab -DENABLE_HDF5=ON \
-DENABLE_NETCDF=ON \
-DBUILD_SHARED_LIBS=OFF \
-DENABLE_FORTRAN=OFF \
-DCMAKE_INSTALL_PREFIX=/MOAB ; \
make -j"$compile_cores" ; \
make -j"$compile_cores" install ; \
rm -rf * ; \
cmake ../moab -DBUILD_SHARED_LIBS=ON \
-DENABLE_HDF5=ON \
-DENABLE_PYMOAB=ON \
-DENABLE_BLASLAPACK=OFF \
-DENABLE_FORTRAN=OFF \
-DCMAKE_INSTALL_PREFIX=/MOAB ; \
make -j"$compile_cores" ; \
make -j"$compile_cores" install ; \
cd pymoab ; \
bash install.sh ; \
python setup.py install ; \
fi


# Clone and install Double-Down
RUN if [ "$include_neutronics" = "true" ] ; \
then git clone https://github.com/pshriwise/double-down ; \
cd double-down ; \
mkdir build ; \
cd build ; \
cmake .. -DCMAKE_INSTALL_PREFIX=.. \
-DMOAB_DIR=/MOAB \
-DEMBREE_DIR=/embree/lib/cmake/embree-3.12.1 \
-DEMBREE_ROOT=/embree/lib/cmake/embree-3.12.1 ; \
make -j"$compile_cores" ; \
make -j"$compile_cores" install ; \
fi

# Clone and install DAGMC
RUN if [ "$include_neutronics" = "true" ] ; \
then mkdir DAGMC ; \
cd DAGMC ; \
git clone -b develop https://github.com/svalinn/dagmc ; \
mkdir build ; \
cd build ; \
cmake ../dagmc -DBUILD_TALLY=ON \
-DCMAKE_INSTALL_PREFIX=/dagmc/ \
-DMOAB_DIR=/MOAB \
-DBUILD_STATIC_LIBS=OFF \
-DBUILD_STATIC_EXE=OFF ; \
make -j"$compile_cores" install ; \
rm -rf /DAGMC/dagmc /DAGMC/build ; \
fi

# Clone and install OpenMC with DAGMC
RUN if [ "$include_neutronics" = "true" ] ; \
then git clone --recurse-submodules https://github.com/openmc-dev/openmc.git /opt/openmc ; \
cd /opt/openmc ; \
mkdir build ; \
cd build ; \
cmake -Doptimize=on -Ddagmc=ON \
-DDAGMC_DIR=/DAGMC/ \
-DHDF5_PREFER_PARALLEL=on .. ; \
make -j"$compile_cores" ; \
make -j"$compile_cores" install ; \
cd .. ; \
pip install -e .[test] ; \
/opt/openmc/tools/ci/download-xs.sh ; \
fi

ENV OPENMC_CROSS_SECTIONS=/root/nndc_hdf5/cross_sections.xml

# Copies over the Paramak code from the local repository

RUN if [ "$include_neutronics" = "true" ] ; \
then pip install neutronics_material_maker ; \
pip install parametric_plasma_source ; \
fi

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


# Copy over the source code, examples and tests
COPY run_tests.sh run_tests.sh
COPY paramak paramak/
COPY examples examples/
COPY setup.py setup.py
COPY tests tests/
COPY README.md README.md

# using setup.py instead of pip due to https://github.com/pypa/pip/issues/5816
RUN python setup.py install

WORKDIR examples
Copy link
Author

@PullRequest-Agent PullRequest-Agent Dec 16, 2020

Choose a reason for hiding this comment

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

MAINTAINABILITY
Attempting to run one of the examples inside of the Docker container, this error was encountered:

(base) root@07c6f4d85ce9:/# python examples/example_neutronics_simulations/ball_reactor.py 
/opt/conda/lib/python3.7/site-packages/neutronics_material_maker/utils.py:14: UserWarning: OpenMC not found, .openmc_material, .serpent_material, .mcnp_material,            .fispact_material not avaiable
  .fispact_material not avaiable")
/opt/conda/lib/python3.7/site-packages/neutronics_material_maker/material.py:29: UserWarning: OpenMC python package not found, .openmc_material, .serpent_material,             .mcnp_material, .fispact_material methods not avaiable
  .mcnp_material, .fispact_material methods not avaiable")
/opt/conda/lib/python3.7/site-packages/neutronics_material_maker/mutlimaterial.py:21: UserWarning: OpenMC python package not found, .openmc_material, .serpent_material,             .mcnp_material, .fispact_material methods not avaiable
  .mcnp_material, .fispact_material methods not avaiable")
/opt/conda/lib/python3.7/site-packages/paramak-0.1.0-py3.7.egg/paramak/parametric_neutronics/neutronics_model_from_reactor.py:14: UserWarning: parametric_plasma_source not found distributed plasma             sources are not avaialbe in Neutronics simulations
  sources are not avaialbe in Neutronics simulations', UserWarning)
/opt/conda/lib/python3.7/site-packages/paramak-0.1.0-py3.7.egg/paramak/parametric_neutronics/neutronics_model_from_reactor.py:20: UserWarning: OpenMC not found, NeutronicsModelFromReactor.simulate             method not available
  method not available', UserWarning)
Traceback (most recent call last):
  File "examples/example_neutronics_simulations/ball_reactor.py", line 66, in <module>
    make_model_and_simulate()
  File "examples/example_neutronics_simulations/ball_reactor.py", line 39, in make_model_and_simulate
    temperature_in_K=500),
  File "/opt/conda/lib/python3.7/site-packages/neutronics_material_maker/material.py", line 206, in __init__
    self._populate_from_inbuilt_dictionary()
  File "/opt/conda/lib/python3.7/site-packages/neutronics_material_maker/material.py", line 745, in _populate_from_inbuilt_dictionary
    "enrichment_target"
  File "/opt/conda/lib/python3.7/site-packages/neutronics_material_maker/material.py", line 528, in enrichment_target
    if value not in openmc.data.NATURAL_ABUNDANCE.keys():
NameError: name 'openmc' is not defined

It would appear that one of the projects that paramak depends on (openmc) isn't installed in the Dockerfile or it's not available in the default environment.


When we were able to run the tests after fixing the issue above , we came across a string of warnings:

==================================== warnings summary =====================================
paramak/shape.py:5
  /paramak/shape.py:5: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
    from collections import Iterable

paramak/parametric_neutronics/neutronics_model_from_reactor.py:14
  /paramak/parametric_neutronics/neutronics_model_from_reactor.py:14: UserWarning: parametric_plasma_source not found distributed plasma             sources are not avaialbe in Neutronics simulations
    sources are not avaialbe in Neutronics simulations', UserWarning)

paramak/parametric_neutronics/neutronics_model_from_reactor.py:20
  /paramak/parametric_neutronics/neutronics_model_from_reactor.py:20: UserWarning: OpenMC not found, NeutronicsModelFromReactor.simulate             method not available
    method not available', UserWarning)

opt/conda/lib/python3.7/site-packages/neutronics_material_maker/utils.py:14
  /opt/conda/lib/python3.7/site-packages/neutronics_material_maker/utils.py:14: UserWarning: OpenMC not found, .openmc_material, .serpent_material, .mcnp_material,            .fispact_material not avaiable
    .fispact_material not avaiable")

opt/conda/lib/python3.7/site-packages/neutronics_material_maker/material.py:29
  /opt/conda/lib/python3.7/site-packages/neutronics_material_maker/material.py:29: UserWarning: OpenMC python package not found, .openmc_material, .serpent_material,             .mcnp_material, .fispact_material methods not avaiable
    .mcnp_material, .fispact_material methods not avaiable")

opt/conda/lib/python3.7/site-packages/neutronics_material_maker/mutlimaterial.py:21
  /opt/conda/lib/python3.7/site-packages/neutronics_material_maker/mutlimaterial.py:21: UserWarning: OpenMC python package not found, .openmc_material, .serpent_material,             .mcnp_material, .fispact_material methods not avaiable
    .mcnp_material, .fispact_material methods not avaiable")

...

tests/test_example_reactors.py::test_object_properties::test_make_parametric_ball_rector
tests/test_example_reactors.py::test_object_properties::test_make_parametric_single_null_ball_reactor
tests/test_parametric_reactors/test_BallReactor.py::test_BallReactor::test_creation_with_narrow_divertor
tests/test_parametric_reactors/test_BallReactor.py::test_BallReactor::test_divertor_upper_lower
tests/test_parametric_reactors/test_BallReactor.py::test_BallReactor::test_svg_creation
tests/test_parametric_reactors/test_BallReactor.py::test_BallReactor::test_with_pf_and_tf_coils
tests/test_parametric_reactors/test_BallReactor.py::test_BallReactor::test_with_pf_coils
tests/test_parametric_reactors/test_SegmentedBlanketBallReactor.py::test_SegmentedBlanketBallReactor::test_gap_between_blankets_impacts_volume
tests/test_parametric_reactors/test_SegmentedBlanketBallReactor.py::test_SegmentedBlanketBallReactor::test_number_of_blanket_segments_impacts_volume
  /paramak/parametric_components/blanket_fp.py:227: UserWarning:
  
  BlanketFP: Some points with negative R coordinate have been ignored.

tests/test_parametric_components/test_PoloidallySegmentedBlanketFP.py::test_BlanketFP::test_segment_angles_affects_solid
  /paramak/parametric_components/blanket_poloidal_segment.py:61: UserWarning:
  
  start_angle and stop_angle attributes will be ignored if segments_angles is not None

tests/test_parametric_components/test_casing.py::test_TFCoilCasing::test_creation
  /paramak/parametric_components/tf_coil_casing.py:31: UserWarning:
  
  Casing azimuth_placement_angle should be the same value as TFCoilCasing.magnet.

tests/test_parametric_components/test_casing.py::test_TFCoilCasing::test_creation
  /paramak/utils.py:226: RuntimeWarning:
  
  divide by zero encountered in true_divide

-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================== 362 passed, 228 warnings in 402.34s (0:06:42) ======================

There were more than those listed above, shortening for brevity.

It's best practice to ensure minimal warnings when running tests. In this case, there seem to be 228 warnings.

21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 UKAEA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.md
include requirements.txt
include LICENSE.txt
Loading