Skip to content

Commit

Permalink
Merge pull request #222 from fusion-energy/more_automatic_voxel_plots
Browse files Browse the repository at this point in the history
More automatic voxel plots
  • Loading branch information
shimwell authored Jul 17, 2023
2 parents beafda0 + 249656b commit de49514
Showing 1 changed file with 21 additions and 7 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 All @@ -29,7 +31,6 @@
"outputs": [],
"source": [
"import openmc\n",
"import os\n",
"\n",
"mats = openmc.Materials()\n",
"\n",
Expand Down Expand Up @@ -80,9 +81,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 +105,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 +135,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -147,7 +161,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 de49514

Please sign in to comment.