Hello, I just installed OpenMC a few days ago and I am working on a big project using it, I’m running into a few issues and I would benefit a lot from clarifications:
1- What is the best IDE to write and execute OpenMC simulation, I am used to PyCharm, is it a good IDE for OpenMC ?, I see most people are using Jupiter notebook.
2- When I try to plot a piece of geometry, a cell or a universe, I always get this error:
===> fuel_assembly_cell.plot()
===> OSError: \path\. so: cannot open shared object file: No such file or directory
3- after I build the geometry, it gets exported to xml just fine, but when I try to plot it through:
===> plot = mc.Plot()
===>plots = openmc.Plots([plot])
===>plots.export_to_xml()
===>openmc.plot_geometry()
or run a simulation through openmc.run(), I get the following error:
Simulating batch 1
ERROR: Particle -1 left lattice 2, but it has no outer definition.
ERROR: Particle -1 left lattice 2, but it has no outer definition.
Traceback (most recent call last):
File “/mnt/c/openMC/UFTR/test.py”, line 126, in
mc.run()
File “/home/eastdusty/openmc_env/lib/python3.11/site-packages/openmc/executor.py”, line 314, in run
_run(args, output, cwd)
File “/home/eastdusty/openmc_env/lib/python3.11/site-packages/openmc/executor.py”, line 125, in _run
raise RuntimeError(error_msg)
RuntimeError: Particle -1 left lattice 2, but it has no outer definition. ERROR: Particle -1 left lattice 2, but it has no outer definition.
Since I can not include my code in a pdf file, I will include it below as plain text, and please let me know if there is an issue with geometry definition or program installation, I am new to OpenMC and trying to learn, and has been stuck for about two days now with this issue.
import os
import matplotlib.pyplot as plt
os.environ[‘OPENMC_CROSS_SECTIONS’] = ‘/home/eastdusty/openmc_env/share/data/endfb80/endfb-viii.0-hdf5/cross_sections.xml’
import openmc as mc
import openmc.plotter as plotter
U3Si2Al = mc.Material(name=‘U3Si2Al’)
U3Si2Al.add_nuclide(‘U238’, 3 * 0.8025)
U3Si2Al.add_nuclide(‘U235’, 3 * 0.1975)
U3Si2Al.add_nuclide(‘Si28’, 2 * 0.922545)
U3Si2Al.add_nuclide(‘Si29’, 2 * 0.04672)
U3Si2Al.add_nuclide(‘Si30’, 2 * 0.030735)
U3Si2Al.add_nuclide(‘Al27’, 1)
U3Si2Al.set_density(‘g/cm3’, 5.55)
Al6061 = mc.Material(name=‘Al6061’)
Al6061.add_nuclide(‘Al27’, 1)
Al6061.set_density(‘g/cm3’, 2.7)
water = mc.Material(name=‘Water’)
water.add_nuclide(‘H1’, 0.111877)
water.add_nuclide(‘H2’, 0.000013)
water.add_nuclide(‘O16’, 0.88811)
water.set_density(‘g/cm3’, 1.0)
materials = mc.Materials([U3Si2Al, Al6061, water])
materials.export_to_xml()
fuel_top = mc.ZPlane(z0=30)
fuel_bottom = mc.ZPlane(z0=-30)
fuel_right = mc.XPlane(x0=2.98)
fuel_left = mc.XPlane(x0=-2.98)
fuel_front = mc.YPlane(y0=0.0255)
fuel_back = mc.YPlane(y0=-0.0255)
fuel_region = +fuel_bottom & -fuel_top & +fuel_left & -fuel_right & -fuel_front & +fuel_back
fuel_cell = mc.Cell(region=fuel_region, fill=U3Si2Al)
clad_top = mc.ZPlane(z0=32.55, boundary_type = ‘vacuum’)
clad_bottom = mc.ZPlane(z0=-32.55, boundary_type = ‘vacuum’)
clad_right = mc.XPlane(x0=3.615, boundary_type = ‘vacuum’)
clad_left = mc.XPlane(x0=-3.615, boundary_type = ‘vacuum’)
clad_front = mc.YPlane(y0=0.0636)
clad_back = mc.YPlane(y0=-0.0636)
clad_region = +clad_bottom & -clad_top & +clad_left & -clad_right & -clad_front & +clad_back & ~fuel_region
clad_cell = mc.Cell(region=clad_region, fill=Al6061)
coolant_top = mc.ZPlane(z0=32.55)
coolant_bottom = mc.ZPlane(z0=-32.55)
coolant_front = mc.YPlane(y0=0.2046)
coolant_back = mc.YPlane(y0=-0.2046)
coolant_left = clad_left
coolant_right = clad_right
coolant_region = -coolant_top & + coolant_bottom & -coolant_front & +coolant_back & +coolant_left & -coolant_right & ~clad_region & ~ fuel_region
coolant = mc.Cell(region=coolant_region, fill=water)
fuel_plate = mc.Universe(cells=[fuel_cell, clad_cell, coolant])
fuel_assembly = mc.RectLattice(name = ‘fuel assembly’)
fuel_assembly.lower_left = (0,-2.8644)
fuel_assembly.pitch = (1, 0.2046)
fuel_assembly.universes = [[fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate, fuel_plate]]
fuel_assembly_cell = mc.Cell()
fuel_assembly_cell.fill = fuel_assembly
fuel_assembly_universe = mc.Universe(cells=[fuel_assembly_cell])
front_boundary = mc.YPlane(y0=2.8644, boundary_type = ‘vacuum’)
back_boundary = mc.YPlane(y0=-2.8644, boundary_type = ‘vacuum’)
geometry = mc.Geometry(fuel_assembly_universe)
geometry.export_to_xml()
color = {fuel_cell: ‘red’, clad_cell: ‘green’, coolant: ‘blue’}
plot = mc.Plot()
plot.basis = ‘xy’
plot.origin = (0, 0, 0)
plot.width = (7.25, 5.73)
plot.pixels = (500, 500)
plot.colors = color
plot.filename = ‘geometry_plot’
plot.filetype = ‘png’
plots = mc.Plots([plot])
plots.export_to_xml()
mc.plot_geometry()
settings = mc.Settings()
settings.run_mode = ‘fixed source’
source = mc.Source()
source.space = mc.stats.Point((0.0, 0.0, 0.0))
source.angle = mc.stats.Isotropic()
source.energy = mc.stats.Discrete([1.0e6], [1.0])
settings.source = source
settings.batches = 50
settings.particles = 1000
settings.inactive = 10
settings.export_to_xml()
mc.run()