Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More automatic voxel plots #222

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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