Plotting Geometry Problem

Hello everyone,

I am new openmc. I want to make a simple geometry of a wall filled with rock with thickness 0.5m. I have created the geometry following the examples. I tried to plot the geometry and I just see a 2D image which is not very clear to me. I was expecting the wall in 3D. this is my code and the output. how can I visualise my geometry well. thank you all.
“”"
import openmc
import numpy as np
import openmc.data
import matplotlib.pyplot as plt

import os

os.environ[“OPENMC_CROSS_SECTIONS”] = “/home/harriet/OPENMC/mcnp_endfb70/cross_sections.xml”

print(os.environ[“OPENMC_CROSS_SECTIONS”])

###############################################################################

Simulation Input File Parameters

###############################################################################

OpenMC simulation parameters

batches = 20
inactive = 10
particles = 10000

###############################################################################

Exporting to OpenMC materials.xml file

###############################################################################

Create materials

rock = openmc.Material(material_id=1, name=‘Rock’)
rock.add_element(‘Si’, 0.277)
rock.add_nuclide(‘O16’, 0.622)
rock.add_element(‘Al’, 0.101)
rock.add_element(‘Fe’,1.0)

rock.set_density(‘g/cm3’, 2.65)

water = openmc.Material(material_id=2,name=‘Water’)
water.add_element(‘H’, 2)
water.add_nuclide(‘O16’, 1)
water.set_density(‘g/cm3’, 1.0)
water.add_s_alpha_beta(‘c_H_in_H2O’)

Instantiate a Materials collection and export to XML

materials_file = openmc.Materials([water, rock])
materials_file.export_to_xml()

###############################################################################

Exporting to OpenMC geometry.xml file

###############################################################################

Create surfaces

wall_thickness = 0.5
water_thickness = 0.5
wall_length= 1.5

Create surfaces for rock wall

left_surface_rock = openmc.XPlane(surface_id=1,x0=-wall_length/2, boundary_type=‘vacuum’)
right_surface_rock = openmc.XPlane(surface_id=2,x0=wall_length/2, boundary_type=‘vacuum’)
bottom_surface_rock = openmc.YPlane(surface_id=3,y0=-wall_length/2, boundary_type=‘vacuum’)
top_surface_rock = openmc.YPlane(surface_id=4,y0=wall_length/2, boundary_type=‘vacuum’)
front_surface_rock = openmc.ZPlane(surface_id=5,z0=-wall_thickness/2, boundary_type=‘vacuum’)
back_surface_rock = openmc.ZPlane(surface_id=6,z0=wall_thickness/2, boundary_type=‘vacuum’)

Instantiate Cells

cell1 = openmc.Cell(cell_id=1, name=‘Cell 1’)
cell1.region = +left_surface_rock & -right_surface_rock & +bottom_surface_rock & -top_surface_rock & +front_surface_rock & -back_surface_rock

Register Materials with Cells

cell1.fill = rock

Create universe

root = openmc.Universe(universe_id=0, name=‘root universe’)
root.add_cell(cell1)

Instantiate a Geometry, register the root Universe, and export to XML

geometry = openmc.Geometry(root)
geometry.export_to_xml()

plot=openmc.Plot()
plot.geometry=geometry
openmc.plot_inline(plot)
“”

plot_1

The plot() method plots a slice through the geometry. The geometry is 3D but a slice through the geometry gives a 2D image.

There are ways of making a 3D view using the voxel plot method
https://docs.openmc.org/en/latest/usersguide/plots.html#voxel-plots

There is another 3D plotting method in development that might also be of interest

thank you for the response. I have followed the manual. I have this in my code but the geometry is not showing is there something I did wrong. I do not get any errors though. vox_plot = openmc.Plot(plot_id=2)

vox_plot.type = ‘voxel’

vox_plot.width = [100., 100.,50.]

vox_plot.pixels = [400, 400,200]

vox_plot.color_by = ‘material’

Instantiate a Plots collection and export to XML

plot = openmc.Plots([vox_plot])

vox_plot.geometry=geometry