From fc819b6a82bf68443dc959845fc71f1a175e0237 Mon Sep 17 00:00:00 2001 From: shimwell Date: Wed, 29 Mar 2023 00:23:27 +0100 Subject: [PATCH 1/3] trying openmc data downloader --- .devcontainer/Dockerfile | 1 + .devcontainer/base.Dockerfile | 19 +++++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 13d78b81..21cd24af 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -16,6 +16,7 @@ FROM ghcr.io/fusion-energy/neutronics-workshop:base as base +# FROM neutronics-workshop:base as base # Copy over the local repository files COPY tasks tasks/ diff --git a/.devcontainer/base.Dockerfile b/.devcontainer/base.Dockerfile index 040b6207..33532d46 100644 --- a/.devcontainer/base.Dockerfile +++ b/.devcontainer/base.Dockerfile @@ -79,8 +79,8 @@ RUN apt-get --yes install libeigen3-dev \ RUN conda install -c conda-forge -c python python=3.8 -RUN conda install -c conda-forge mamba -y -RUN mamba install -c fusion-energy -c cadquery -c conda-forge paramak==0.8.7 -y +# RUN conda install -c conda-forge mamba -y +RUN conda install -c fusion-energy -c cadquery -c conda-forge paramak==0.8.7 -y # python packages from the neutronics workflow @@ -94,6 +94,7 @@ RUN pip install neutronics_material_maker[density] \ openmc_source_plotter \ openmc_depletion_plotter \ openmc_data_downloader \ + openmc_data \ openmc_plot \ dagmc_geometry_slice_plotter @@ -226,19 +227,13 @@ RUN cd /opt && \ # installs TENDL and ENDF nuclear data. Performed after openmc install as # openmc is needed to write the cross_Sections.xml file + # RUN pip install openmc_data_downloader && \ -# openmc_data_downloader -d nuclear_data -l ENDFB-7.1-NNDC TENDL-2019 -p neutron photon -e all -i H3 --no-overwrite +RUN openmc_data_downloader -d nuclear_data -l ENDFB-8.0-NNDC TENDL-2019 -p neutron photon -e all -i H3 --no-overwrite RUN pip install openmc_data && \ mkdir -p /nuclear_data && \ - download_nndc_chain -d nuclear_data -r b8.0 && \ - download_nndc -d nuclear_data -r b8.0 --cleanup && \ - rm -rf nndc-b8.0-download -# The last line here deletes the downloaded compressed nuclear datafile -# not sure why but cleanup is not working, trackign on issue -# https://github.com/openmc-data-storage/openmc_data/issues/29 - - + download_nndc_chain -d nuclear_data -r b8.0 # install WMP nuclear data RUN wget https://github.com/mit-crpg/WMP_Library/releases/download/v1.1/WMP_Library_v1.1.tar.gz && \ @@ -246,4 +241,4 @@ RUN wget https://github.com/mit-crpg/WMP_Library/releases/download/v1.1/WMP_Libr rm WMP_Library_v1.1.tar.gz ENV OPENMC_CROSS_SECTIONS=/nuclear_data/endfb-viii.0-hdf5/cross_sections.xml -ENV OPENMC_CHAIN_FILE=/nuclear_data/cross_sections.xml +ENV OPENMC_CHAIN_FILE=/nuclear_data/chain-nndc-b8.0.xml From b8d47eebd0d5e5e44f52243fa1cf2f5bc6e89c75 Mon Sep 17 00:00:00 2001 From: shimwell Date: Wed, 29 Mar 2023 08:07:30 +0100 Subject: [PATCH 2/3] changed base image --- .devcontainer/base.Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.devcontainer/base.Dockerfile b/.devcontainer/base.Dockerfile index 33532d46..44ca1712 100644 --- a/.devcontainer/base.Dockerfile +++ b/.devcontainer/base.Dockerfile @@ -30,7 +30,8 @@ # and then run with this command # docker run -it neutronics-workshop:base -FROM mcr.microsoft.com/vscode/devcontainers/miniconda:0-3 as dependencies +# FROM mcr.microsoft.com/vscode/devcontainers/miniconda:0-3 as dependencies +FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.9-bullseye as dependencies RUN apt-get --allow-releaseinfo-change update RUN apt-get --yes update && apt-get --yes upgrade @@ -77,11 +78,11 @@ RUN apt-get --yes install libeigen3-dev \ libxft2 -RUN conda install -c conda-forge -c python python=3.8 +# RUN conda install -c conda-forge -c python python=3.8 # RUN conda install -c conda-forge mamba -y -RUN conda install -c fusion-energy -c cadquery -c conda-forge paramak==0.8.7 -y - +# RUN conda install -c fusion-energy -c cadquery -c conda-forge paramak==0.8.7 -y +RUN pip install cadquery # python packages from the neutronics workflow RUN pip install neutronics_material_maker[density] \ From 884984842cdb90cf011985356a9edf5a67637460 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 29 Mar 2023 16:54:03 +0100 Subject: [PATCH 3/3] updated docker images and plotting api usage --- .devcontainer/Dockerfile | 14 +++++--- .devcontainer/base.Dockerfile | 35 +++++++++++++------ .../task_01_cross_sections/plotting_utils.py | 6 ++-- .../generate_single_ww_and_apply.ipynb | 2 +- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 21cd24af..1ad1fb05 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,13 +9,12 @@ # To build this Dockerfile into a docker image: # docker build -t neutronics-workshop -f .devcontainer/Dockerfile . -# for local testing I tend to use this build command -# docker build -t neutronics-workshop -# and then run with this command +# then run with this command # docker run -p 8888:8888 neutronics-workshop - +# remote image FROM ghcr.io/fusion-energy/neutronics-workshop:base as base +# local image # FROM neutronics-workshop:base as base # Copy over the local repository files @@ -29,5 +28,12 @@ FROM base as jupyter_cmd ENV PORT 8888 +# ENV PYTHONPATH="/MOAB/moab/pymoab" +# RUN pip install gmsh +# RUN apt-get install libxcursor-dev -y +# RUN apt-get install libxinerama-dev -y + +# libXinerama.so.1: cannot open shared object file: No such file or directory + # could switch to --ip='*' CMD ["jupyter", "lab", "--notebook-dir=/tasks", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"] diff --git a/.devcontainer/base.Dockerfile b/.devcontainer/base.Dockerfile index 44ca1712..4a6b6326 100644 --- a/.devcontainer/base.Dockerfile +++ b/.devcontainer/base.Dockerfile @@ -82,7 +82,15 @@ RUN apt-get --yes install libeigen3-dev \ # RUN conda install -c conda-forge mamba -y # RUN conda install -c fusion-energy -c cadquery -c conda-forge paramak==0.8.7 -y -RUN pip install cadquery +RUN pip install cadquery \ + paramak + +RUN pip install gmsh +# needed for gmsh +RUN apt-get install libxcursor-dev -y +# needed for gmsh +RUN apt-get install libxinerama-dev -y +# might be libxinerama1 # python packages from the neutronics workflow RUN pip install neutronics_material_maker[density] \ @@ -94,7 +102,7 @@ RUN pip install neutronics_material_maker[density] \ spectrum_plotter \ openmc_source_plotter \ openmc_depletion_plotter \ - openmc_data_downloader \ + openmc_data_downloader>=0.6.0 \ openmc_data \ openmc_plot \ dagmc_geometry_slice_plotter @@ -158,7 +166,8 @@ RUN if [ "$build_double_down" = "ON" ] ; \ # Clone and install MOAB RUN mkdir MOAB && \ cd MOAB && \ - git clone --single-branch --branch 5.4.1 --depth 1 https://bitbucket.org/fathomteam/moab.git && \ + # newer versions of moab (5.4.0, 5.4.1) don't produce an importable pymoab package! + git clone --single-branch --branch 5.3.1 --depth 1 https://bitbucket.org/fathomteam/moab.git && \ mkdir build && \ cd build && \ cmake ../moab -DENABLE_HDF5=ON \ @@ -168,8 +177,13 @@ RUN mkdir MOAB && \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_PYMOAB=ON \ -DCMAKE_INSTALL_PREFIX=/MOAB && \ - make -j"$compile_cores" && \ - make -j"$compile_cores" install + mkdir -p MOAB/lib/pymoab/lib/python3.9/site-packages && \ + PYTHONPATH=/MOAB/lib/pymoab/lib/python3.9/site-packages:${PYTHONPATH} make -j && \ + PYTHONPATH=/MOAB/lib/pymoab/lib/python3.9/site-packages:${PYTHONPATH} make install -j + +ENV PYTHONPATH="/MOAB/lib/python3.9/site-packages/pymoab-5.3.1-py3.9-linux-x86_64.egg/" + +RUN python -c "import pymoab" ENV PATH=$PATH:/MOAB/bin @@ -211,10 +225,9 @@ ENV PATH=$PATH:/DAGMC/bin ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/DAGMC/lib # installs OpenMc from source -RUN cd /opt && \ - # switch back to tagged version when 0.13.3 is released as develop depletion is used - # git clone --single-branch --branch v0.13.3 --depth 1 https://github.com/openmc-dev/openmc.git && \ - git clone --single-branch --branch develop --depth 1 https://github.com/openmc-dev/openmc.git && \ +# switch back to tagged version when 0.13.3 is released as develop depletion is used +# git clone --single-branch --branch v0.13.3 --depth 1 https://github.com/openmc-dev/openmc.git && \ +RUN git clone --single-branch --branch develop --depth 1 https://github.com/openmc-dev/openmc.git && \ cd openmc && \ mkdir build && \ cd build && \ @@ -223,7 +236,7 @@ RUN cd /opt && \ -DHDF5_PREFER_PARALLEL=OFF .. && \ make -j"$compile_cores" && \ make -j"$compile_cores" install && \ - cd /opt/openmc/ && \ + cd /openmc/ && \ pip install . # installs TENDL and ENDF nuclear data. Performed after openmc install as @@ -241,5 +254,5 @@ RUN wget https://github.com/mit-crpg/WMP_Library/releases/download/v1.1/WMP_Libr tar -xf WMP_Library_v1.1.tar.gz -C / && \ rm WMP_Library_v1.1.tar.gz -ENV OPENMC_CROSS_SECTIONS=/nuclear_data/endfb-viii.0-hdf5/cross_sections.xml +ENV OPENMC_CROSS_SECTIONS=/nuclear_data/cross_sections.xml ENV OPENMC_CHAIN_FILE=/nuclear_data/chain-nndc-b8.0.xml diff --git a/tasks/task_01_cross_sections/plotting_utils.py b/tasks/task_01_cross_sections/plotting_utils.py index 752c4773..3b29240f 100644 --- a/tasks/task_01_cross_sections/plotting_utils.py +++ b/tasks/task_01_cross_sections/plotting_utils.py @@ -27,7 +27,7 @@ def create_isotope_plot(isotopes, reaction): isotope_object = openmc.Nuclide(isotope_name) energy, cross_sections = openmc.calculate_cexs( - isotope_object, "nuclide", [reaction] + isotope_object, [reaction] ) cross_section = cross_sections[0] if cross_section.sum() != 0.0: @@ -78,7 +78,7 @@ def create_element_plot(elements, reaction): continue energy, cross_sections = openmc.calculate_cexs( - element_object, "element", [reaction] + element_object, [reaction] ) cross_section = cross_sections[0] if cross_section.sum() != 0.0: @@ -118,7 +118,7 @@ def create_material_plot(materials, reaction): for material in materials: # extracts energy and cross section for the material for the provided MT reaction mumber - energy, xs_data = openmc.calculate_cexs(material, "material", [MT_number]) + energy, xs_data = openmc.calculate_cexs(material, [MT_number]) # adds the energy dependnat cross sction to the plot fig.add_trace( diff --git a/tasks/task_13_variance_reduction/generate_single_ww_and_apply.ipynb b/tasks/task_13_variance_reduction/generate_single_ww_and_apply.ipynb index 6a32ebb4..f2b0c24a 100644 --- a/tasks/task_13_variance_reduction/generate_single_ww_and_apply.ipynb +++ b/tasks/task_13_variance_reduction/generate_single_ww_and_apply.ipynb @@ -249,7 +249,7 @@ "\n", "\n", "model.settings.weight_windows = weight_windows\n", - "model.settings.max_split = 1_000_000\n", + "model.settings.max_split = 1_000 # might want to increase this to 1_000_000 and get a better result \n", "model.run()" ] },