From 873bf0aa4ef1be828e0ef4aeda8b7d776c01adb4 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 17 Jul 2023 10:40:45 +0100 Subject: [PATCH 1/2] auto width origin for voxel plot --- .../3_viewing_the_geometry_as_vtk.ipynb | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb b/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb index 9ac9ba82..cde98c01 100644 --- a/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb +++ b/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -16,6 +17,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -80,9 +82,9 @@ "\n", "universe = openmc.Universe(cells=[central_sol_cell,central_shield_cell,first_wall_cell, breeder_blanket_cell])\n", "\n", - "geom = openmc.Geometry(universe)\n", + "my_geometry = openmc.Geometry(universe)\n", "\n", - "geom.export_to_xml()\n" + "my_geometry.export_to_xml()\n" ] }, { @@ -104,10 +106,22 @@ "# makes the 3d \"cube\" style geometry\n", "vox_plot = openmc.Plot()\n", "vox_plot.type = 'voxel'\n", - "vox_plot.width = (1500., 1500., 1500.)\n", - "vox_plot.pixels = (200, 200, 200)\n", + "\n", + "# makes sure the bounds of the plot include the whole geometry\n", + "vox_plot.width = my_geometry.bounding_box.width\n", + "\n", + "# makes sure the voxel plot is centered at the center of the geometry\n", + "vox_plot.origin = my_geometry.bounding_box.center\n", + "\n", + "# sets the pixels in each direction to be proportional to the size of the geometry in that direction\n", + "# Your computer RAM will limit the number of pixels you can set in each direction.\n", + "# The * 0.1 part of this line reduces the number of pixels in each direction to a reasonable amount but this could be increased if you want more resolution.\n", + "vox_plot.pixels = [int(w* 0.1) for w in my_geometry.bounding_box.width]\n", + "\n", "vox_plot.color_by = 'material'\n", - "vox_plot.colors = {copper: 'blue'} # materials can be coloured using this command\n", + "# materials can be coloured using this command and the available openmc colors\n", + "# vox_plot.colors = {copper: 'blue'}\n", + "\n", "vox_plot.to_vtk(output='voxel_plot.vti')" ] }, @@ -122,6 +136,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -147,7 +162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.10" + "version": "3.8.13" } }, "nbformat": 4, From 249656bf8d1b59c8b81ab0df76851711a7638ff5 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 17 Jul 2023 10:45:23 +0100 Subject: [PATCH 2/2] removed unused import --- .../3_viewing_the_geometry_as_vtk.ipynb | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb b/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb index cde98c01..35de0a1e 100644 --- a/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb +++ b/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb @@ -31,7 +31,6 @@ "outputs": [], "source": [ "import openmc\n", - "import os\n", "\n", "mats = openmc.Materials()\n", "\n",