diff --git a/Dockerfile b/Dockerfile
index 11ae6da..5ed87e3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -58,10 +58,9 @@ RUN apt-get --yes install libeigen3-dev \
# installing cadquery and jupyter
-RUN conda install jupyter -y && \
- conda install -c conda-forge -c python python=3.7.8 && \
- conda install -c conda-forge -c cadquery cadquery=2
-# cadquery master dose not appear to show the .solid in the notebook
+RUN conda install -c conda-forge -c python python=3.8 && \
+ conda install -c conda-forge -c cadquery cadquery=2.1 && \
+ pip install jupyter-cadquery==2.0.0-rc1
# Python libraries used in the workshop
@@ -250,8 +249,9 @@ COPY tasks tasks/
WORKDIR /tasks
-#this sets the port, gcr looks for this varible
+#this sets the port, gcr looks for this ENV varible
ENV PORT 8888
+EXPOSE 8888
# could switch to --ip='*'
-CMD ["jupyter", "notebook", "--notebook-dir=/tasks", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
+CMD ["jupyter", "lab", "--notebook-dir=/tasks", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
diff --git a/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb b/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb
index 75dd8ad..471b979 100644
--- a/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb
+++ b/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb
@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 1,
"metadata": {},
"outputs": [
{
@@ -216,5 +216,5 @@
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/tasks/task_08_CSG_mesh_tally/2_example_3d_mesh_tallies.ipynb b/tasks/task_08_CSG_mesh_tally/2_example_3d_mesh_tallies.ipynb
index 670cd6e..e68173d 100644
--- a/tasks/task_08_CSG_mesh_tally/2_example_3d_mesh_tallies.ipynb
+++ b/tasks/task_08_CSG_mesh_tally/2_example_3d_mesh_tallies.ipynb
@@ -89,15 +89,39 @@
"sett.batches = batches\n",
"sett.inactive = 0\n",
"sett.particles = 5000\n",
- "sett.run_mode = 'fixed source'\n",
+ "sett.run_mode = 'fixed source'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from parametric_plasma_source import PlasmaSource, SOURCE_SAMPLING_PATH\n",
"\n",
- "# Create a DT point source\n",
- "source = openmc.Source()\n",
- "source.angle = openmc.stats.Isotropic()\n",
- "source.energy = openmc.stats.Discrete([14e6], [1])\n",
- "source.space = openmc.stats.Point((150, 150, 0))\n",
+ "my_plasma = PlasmaSource(\n",
+ " ion_density_origin=1.09e20,\n",
+ " ion_density_peaking_factor=1,\n",
+ " ion_density_pedestal=1.09e20,\n",
+ " ion_density_separatrix=3e19,\n",
+ " ion_temperature_origin=45.9,\n",
+ " ion_temperature_peaking_factor=8.06,\n",
+ " ion_temperature_pedestal=6.09,\n",
+ " ion_temperature_separatrix=0.1,\n",
+ " elongation=2,\n",
+ " triangularity=0.55,\n",
+ " major_radius=4.5, # note the source takes m arguments\n",
+ " minor_radius=1.,\n",
+ " pedestal_radius=0.8 * 100,\n",
+ " plasma_id=1,\n",
+ " shafranov_shift=0.44789,\n",
+ " ion_temperature_beta=6\n",
+ ")\n",
"\n",
- "sett.source = source"
+ "source = openmc.Source()\n",
+ "source.library = SOURCE_SAMPLING_PATH\n",
+ "source.parameters = str(my_plasma)"
]
},
{
@@ -138,16 +162,22 @@
"# Create mesh filter for tally\n",
"mesh_filter = openmc.MeshFilter(mesh)\n",
"\n",
- "# Create flux mesh tally to score flux\n",
+ "# Create tritium production mesh tally to score flux\n",
"mesh_tally = openmc.Tally(tally_id=1, name='tbr_on_mesh') # note the tally_id is specified\n",
"mesh_tally.filters = [mesh_filter]\n",
"mesh_tally.scores = ['(n,Xt)']\n",
"tallies.append(mesh_tally)\n",
"\n",
- "# Create flux mesh tally to score flux\n",
+ "# Create heat mesh tally to score flux\n",
"mesh_tally = openmc.Tally(tally_id=2, name='heating_on_mesh') # note the tally_id is specified\n",
"mesh_tally.filters = [mesh_filter]\n",
"mesh_tally.scores = ['heating']\n",
+ "tallies.append(mesh_tally)\n",
+ "\n",
+ "# Create flux mesh tally to score flux\n",
+ "mesh_tally = openmc.Tally(tally_id=3,name='flux_on_mesh') # note the tally_id is specified\n",
+ "mesh_tally.filters = [mesh_filter]\n",
+ "mesh_tally.scores = ['flux']\n",
"tallies.append(mesh_tally)"
]
},
@@ -185,7 +215,7 @@
"metadata": {},
"outputs": [],
"source": [
- "from statepoint_to_vtk import initiate_mesh\n",
+ "from statepoint_to_vtk import *\n",
"\n",
"initiate_mesh(\n",
" statepoint_filename=sp_filename,\n",
@@ -201,6 +231,14 @@
" output_filename='heating_tally_on_mesh.vtk',\n",
" mesh_id=1, # note the mesh_id from earlier is used\n",
" tally_id=2 # note the tally_id from earlier is used\n",
+ ")\n",
+ "\n",
+ "initiate_mesh(\n",
+ " statepoint_filename=sp_filename,\n",
+ " tally_name='flux_on_mesh',\n",
+ " output_filename='flux_tally_on_mesh.vtk',\n",
+ " mesh_id=1, # note the mesh_id from earlier is used\n",
+ " tally_id=3 # note the tally_id from earlier is used\n",
")"
]
},
diff --git a/tasks/task_10_making_CAD_geometry/1_make_CAD_shapes_from_points.ipynb b/tasks/task_10_making_CAD_geometry/1_make_CAD_shapes_from_points.ipynb
index 9041b66..c61012c 100644
--- a/tasks/task_10_making_CAD_geometry/1_make_CAD_shapes_from_points.ipynb
+++ b/tasks/task_10_making_CAD_geometry/1_make_CAD_shapes_from_points.ipynb
@@ -25,23 +25,9 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 2,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
"from IPython.display import HTML\n",
"HTML('')"
@@ -63,6 +49,8 @@
"outputs": [],
"source": [
"import paramak\n",
+ "from jupyter_cadquery.cadquery import show\n",
+ "\n",
"my_shape = paramak.RotateStraightShape(\n",
" points=[\n",
" (50,50),\n",
@@ -73,7 +61,7 @@
" rotation_angle=180\n",
")\n",
"\n",
- "my_shape.solid"
+ "show(my_shape.solid)"
]
},
{
@@ -99,7 +87,7 @@
" rotation_angle=180\n",
")\n",
"\n",
- "my_shape.solid"
+ "show(my_shape.solid)"
]
},
{
@@ -125,7 +113,7 @@
" distance=20\n",
")\n",
"\n",
- "my_shape.solid"
+ "show(my_shape.solid)"
]
},
{
@@ -151,7 +139,7 @@
" distance=20\n",
")\n",
"\n",
- "my_shape.solid"
+ "show(my_shape.solid)"
]
},
{
@@ -190,7 +178,7 @@
" cut=small_Shape\n",
")\n",
"\n",
- "my_shape.solid"
+ "show(my_shape.solid)"
]
},
{
diff --git a/tasks/task_10_making_CAD_geometry/2_make_CAD_components_from_parameters.ipynb b/tasks/task_10_making_CAD_geometry/2_make_CAD_components_from_parameters.ipynb
index 064da0e..1af99d5 100644
--- a/tasks/task_10_making_CAD_geometry/2_make_CAD_components_from_parameters.ipynb
+++ b/tasks/task_10_making_CAD_geometry/2_make_CAD_components_from_parameters.ipynb
@@ -47,6 +47,7 @@
"outputs": [],
"source": [
"import paramak\n",
+ "from jupyter_cadquery.cadquery import show\n",
"\n",
"pf_1 = paramak.PoloidalFieldCoil(\n",
" height=50,\n",
@@ -55,7 +56,7 @@
" rotation_angle=180\n",
")\n",
"\n",
- "pf_1.solid"
+ "show(pf_1.solid)"
]
},
{
@@ -93,7 +94,7 @@
" rotation_angle=180\n",
")\n",
"\n",
- "tf.solid"
+ "show(tf.solid)"
]
},
{
@@ -130,7 +131,7 @@
" rotation_angle=180\n",
")\n",
"\n",
- "plasma.solid"
+ "show(plasma.solid)"
]
},
{
@@ -168,7 +169,7 @@
" rotation_angle=180\n",
")\n",
"\n",
- "blanket.solid"
+ "show(blanket.solid)"
]
},
{
@@ -191,7 +192,7 @@
"my_reactor.export_stp()\n",
"my_reactor.export_stl()\n",
"\n",
- "my_reactor.solid"
+ "show(my_reactor.solid)"
]
},
{
diff --git a/tasks/task_10_making_CAD_geometry/3_make_CAD_reactors.ipynb b/tasks/task_10_making_CAD_geometry/3_make_CAD_reactors.ipynb
index 25491fd..f6b6e49 100644
--- a/tasks/task_10_making_CAD_geometry/3_make_CAD_reactors.ipynb
+++ b/tasks/task_10_making_CAD_geometry/3_make_CAD_reactors.ipynb
@@ -46,6 +46,7 @@
"outputs": [],
"source": [
"import paramak\n",
+ "from jupyter_cadquery.cadquery import show\n",
"\n",
"my_reactor = paramak.BallReactor(\n",
" inner_bore_radial_thickness=10,\n",
@@ -70,7 +71,7 @@
" outboard_tf_coil_poloidal_thickness=50\n",
")\n",
"\n",
- "my_reactor.solid"
+ "show(my_reactor.solid)"
]
},
{
diff --git a/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb b/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb
index c5830dc..d2de5b0 100644
--- a/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb
+++ b/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb
@@ -23,6 +23,7 @@
"outputs": [],
"source": [
"import paramak\n",
+ "from jupyter_cadquery.cadquery import show\n",
"\n",
"pf_1 = paramak.PoloidalFieldCoil(\n",
" height=50,\n",
@@ -44,7 +45,6 @@
" with_inner_leg=True\n",
")\n",
"\n",
- "\n",
"plasma = paramak.Plasma(\n",
" minor_radius=150.,\n",
" major_radius=450.,\n",
@@ -69,7 +69,7 @@
"# so it has been removed to speed up the example\n",
"\n",
"my_reactor.rotation_angle=360 # this is a small \"feature\" which we will fix soon\n",
- "my_reactor.solid"
+ "show(my_reactor.solid)"
]
},
{
@@ -185,7 +185,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.5"
+ "version": "3.8.3"
}
},
"nbformat": 4,
diff --git a/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb b/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb
index b41d822..b66b5fd 100644
--- a/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb
+++ b/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb
@@ -27,6 +27,7 @@
"outputs": [],
"source": [
"import paramak\n",
+ "from jupyter_cadquery.cadquery import show\n",
"\n",
"pf_coil = paramak.RotateStraightShape(\n",
" points=[\n",
@@ -39,7 +40,7 @@
" material_tag = 'pf_coil_material'\n",
")\n",
"\n",
- "pf_coil.solid"
+ "show(pf_coil.solid)"
]
},
{
@@ -67,7 +68,7 @@
" material_tag = 'center_column_material'\n",
")\n",
"\n",
- "center_column.solid"
+ "show(center_column.solid)"
]
},
{
@@ -100,7 +101,7 @@
" material_tag = 'blanket_material'\n",
")\n",
"\n",
- "blanket.solid"
+ "show(blanket.solid)"
]
},
{
diff --git a/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb b/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb
index 5e56347..f4b0eaf 100644
--- a/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb
+++ b/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb
@@ -27,7 +27,7 @@
"outputs": [],
"source": [
"import paramak\n",
- "\n",
+ "from jupyter_cadquery.cadquery import show\n",
"\n",
"pf_coil = paramak. PoloidalFieldCoil(\n",
" height=50,\n",
@@ -37,7 +37,7 @@
" material_tag = 'pf_coil_material'\n",
")\n",
"\n",
- "pf_coil.solid"
+ "show(pf_coil.solid)"
]
},
{
@@ -62,7 +62,7 @@
" material_tag = 'center_column_material'\n",
")\n",
"\n",
- "center_column.solid"
+ "show(center_column.solid)"
]
},
{
@@ -89,7 +89,7 @@
" material_tag = 'blanket_material'\n",
")\n",
"\n",
- "blanket.solid"
+ "show(blanket.solid)"
]
},
{
@@ -107,7 +107,7 @@
"source": [
"my_reactor = paramak.Reactor([blanket, pf_coil,center_column])\n",
"\n",
- "my_reactor.solid"
+ "show(my_reactor.solid)"
]
},
{
diff --git a/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb b/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb
index ff0d7e8..fa3f826 100644
--- a/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb
+++ b/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb
@@ -34,6 +34,7 @@
"outputs": [],
"source": [
"import paramak\n",
+ "from jupyter_cadquery.cadquery import show\n",
"\n",
"my_reactor = paramak.BallReactor(\n",
" inner_bore_radial_thickness=50,\n",
@@ -56,7 +57,7 @@
"# see the documentation for more details \n",
"# https://paramak.readthedocs.io/en/main/paramak.parametric_reactors.html\n",
"\n",
- "my_reactor.solid"
+ "show(my_reactor.solid)"
]
},
{
diff --git a/tests/test_all_tasks.py b/tests/test_all_tasks.py
index 6b6149f..bb01b73 100644
--- a/tests/test_all_tasks.py
+++ b/tests/test_all_tasks.py
@@ -1,4 +1,4 @@
-
+0
"""
tests the create_isotope_plot from plotting_utils in the same way the examples
use the function.
@@ -12,6 +12,7 @@
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from nbconvert.preprocessors.execute import CellExecutionError
+from nbformat.validator import NotebookValidationError
def _notebook_run(path):
@@ -40,8 +41,12 @@ def _notebook_run(path):
return nb, errors
+cwd = os.getcwd()
+
+
class test_tasks(unittest.TestCase):
+
def test_task_1(self):
for notebook in Path().rglob("tasks/tasks/task_01_*/*.ipynb"):
print(notebook)
@@ -60,69 +65,102 @@ def test_task_3(self):
nb, errors = _notebook_run(notebook)
assert errors == []
-# ModuleNotFoundError: No module named 'source_extraction_utils
+
+ # ModuleNotFoundError: No module named 'source_extraction_utils
+ # or fails to find initial_source.h5 file
+ # also tried adding this to the Notebook
+ # import sys
+ # sys.path.insert(0, '/home/jshim/openmc_workshop/tasks/task_04_make_sources/')
# def test_task_4(self):
- # print(notebook)
- # for notebook in Path().rglob("tasks/task_04_*/*.ipynb"):
+ # os.chdir('tasks/task_04_make_sources/')
+ # for notebook in Path().rglob("*.ipynb"):
+ # print(notebook)
# nb, errors = _notebook_run(notebook)
# assert errors == []
def test_task_5(self):
- for notebook in Path().rglob("tasks/task_05_*/*.ipynb"):
+ os.chdir(cwd)
+ os.chdir('tasks/task_05_CSG_cell_tally_TBR/')
+ for notebook in Path().rglob("*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
def test_task_6(self):
- for notebook in Path().rglob("tasks/task_06_*/*.ipynb"):
+ os.chdir(cwd)
+ os.chdir('tasks/task_06_CSG_cell_tally_DPA/')
+ for notebook in Path().rglob("*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
-# ModuleNotFoundError: No module named 'plotting_utils'
+ # ModuleNotFoundError: No module named 'plotting_utils'
# def test_task_7(self):
- # for notebook in Path().rglob("tasks/task_07_*/*.ipynb"):
- # print(notebook)
+ # os.chdir(cwd)
+ # os.chdir('tasks/task_07_CSG_cell_tally_spectra/')
+ # for notebook in Path().rglob("*.ipynb"):
+ # print(notebook)
# nb, errors = _notebook_run(notebook)
# assert errors == []
# ModuleNotFoundError: No module named 'statepoint_to_vtk'
-# def test_task_8(self):
-# for notebook in Path().rglob("tasks/task_08_*/*.ipynb"):
-# print(notebook)
-# nb, errors = _notebook_run(notebook)
-# assert errors == []
+ # def test_task_8(self):
+ # os.chdir(cwd)
+ # os.chdir('tasks/task_08_CSG_mesh_tally/')
+ # for notebook in Path().rglob("*.ipynb"):
+ # print(notebook)
+ # nb, errors = _notebook_run(notebook)
+ # assert errors == []
def test_task_9(self):
- for notebook in Path().rglob("tasks/task_09_*/*.ipynb"):
+ os.chdir(cwd)
+ os.chdir('tasks/task_09_CSG_surface_tally_dose/')
+ for notebook in Path().rglob("*.ipynb"):
print(notebook)
nb, errors = _notebook_run(notebook)
assert errors == []
-# FileNotFoundError: The dagmc_not_watertight.h5m was not found
-# def test_task_10(self):
-# for notebook in Path().rglob("tasks/task_10_*/*.ipynb"):
-# print(notebook)
-# nb, errors = _notebook_run(notebook)
-# assert errors == []
+# 'Compound' object has no attribute 'val'
+ # def test_task_10(self):
+ # os.chdir(cwd)
+ # os.chdir('tasks/task_10_making_CAD_geometry/')
+ # for notebook in Path().rglob("*.ipynb"):
+ # print(notebook)
+ # nb, errors = _notebook_run(notebook)
+ # assert errors == []
-# TimeoutError: Cell execution timed out
-# def test_task_11(self):
-# for notebook in Path().rglob("tasks/task_11_*/*.ipynb"):
-# print(notebook)
-# nb, errors = _notebook_run(notebook)
-# assert errors == []
+# AttributeError: 'Compound' object has no attribute 'val'
+ # def test_task_11(self):
+ # os.chdir(cwd)
+ # os.chdir('tasks/task_11_CAD_cell_tally_heat/')
+ # for notebook in Path().rglob("*.ipynb"):
+ # print(notebook)
+ # nb, errors = _notebook_run(notebook)
+ # assert errors == []
-# FileNotFoundError: The dagmc_not_watertight.h5m was not found
-# def test_task_12(self):
-# for notebook in Path().rglob("tasks/task_12_*/*.ipynb"):
-# print(notebook)
-# nb, errors = _notebook_run(notebook)
-# assert errors == []
+# AttributeError: 'Compound' object has no attribute 'val'
+ # def test_task_12(self):
+ # os.chdir(cwd)
+ # os.chdir('tasks/task_12_CAD_mesh_fast_flux/')
+ # for notebook in Path().rglob("*.ipynb"):
+ # print(notebook)
+ # nb, errors = _notebook_run(notebook)
+ # assert errors == []
-# ModuleNotFoundError: No module named 'statepoint_to_vtk'
+# # ModuleNotFoundError: No module named 'statepoint_to_vtk'
# def test_task_13(self):
-# for notebook in Path().rglob("tasks/task_13_*/*.ipynb"):
+# os.chdir(cwd)
+# os.chdir('tasks/task_13_parameter_study_sampling/')
+# for notebook in Path().rglob("*.ipynb"):
# print(notebook)
# nb, errors = _notebook_run(notebook)
# assert errors == []
+
+# ModuleNotFoundError: No module named 'statepoint_to_vtk'
+ # def test_task_14(self):
+ # os.chdir(cwd)
+ # os.chdir('tasks/task_14_parameter_study_optimisation//')
+ # for notebook in Path().rglob("*.ipynb"):
+ # print(notebook)
+ # nb, errors = _notebook_run(notebook)
+ # assert errors == []