Rectangular_prism; bad operand type for unary -: 'Intersection'

Hi, dear users and experts, i am facing an error while trying to create a rectengular prism geometry for research reactor. Please, help me to find the misake. Below i provide my code and error. Thank you!

The code:
fuel_or = openmc.model.rectangular_prism(0.9, 0.9, corner_radius=1)
clad_ir = openmc.model.rectangular_prism(1, 1, corner_radius=1)
clad_or = openmc.model.rectangular_prism(2, 2, corner_radius=1)

fuel_region = -fuel_or
gap_region = +fuel_or & -clad_ir
clad_region = +clad_ir & -clad_or

fuel_c = openmc.Cell(1, ‘fuel’)
fuel_c.fill = fuel
fuel_c.region = fuel_region

gap = openmc.Cell(2, ‘gap’)
gap.region = gap_region

clad = openmc.Cell(3, ‘clad’)
clad.fill = zirconium
clad.region = clad_region

Error:

image

Hi umarov,

As a rectangular_prism is a macrobody made up of multiple planes, the complement operator ~ should be used. It is not suitable for use of + or -, as it can be seen as a sortof cell. Use ~ for outside and nothing for inside. Your code will then become:

fuel_region = fuel_or
gap_region = ~fuel_or & clad_ir
clad_region = ~clad_ir & clad_or

This is explained in more depth in the user guide for geometry OpenMC user guide.

Kind regards,
Daan

Just to add on to Daan’s response (which is correct) — in the latest version of OpenMC (0.14.0), there is now a RectangularPrism class that acts like a normal surface (you can use the - and + operators on it) but is otherwise equivalent to the rectangular_prism function. This is noted in the release notes for 0.14.0.

Mr. Daan, thank you, its working now!
Thank you Mr. Paul, maybe i will update my version later.