Skip to content

Commit

Permalink
auto width origin for voxel plot
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Jul 17, 2023
1 parent beafda0 commit 873bf0a
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -16,6 +17,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -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"
]
},
{
Expand All @@ -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')"
]
},
Expand All @@ -122,6 +136,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -147,7 +162,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 873bf0a

Please sign in to comment.