Use lattiece to build 3D models

hello,Developer!
I am new to openmc。 I use lattiece to build 3D models。This input file:

# Materials definitions
m1= openmc.Material()   #空气
m1.add_element('C',0.5,'wo')
m1.add_element('N',0.5,'wo')
m1.set_density('g/cm3', 1.13)

m2 = openmc.Material(material_id=1, name='fuel')
m2.set_density('g/cc', 4.5)
m2.add_nuclide('U235', 1.)

m3 = openmc.Material(material_id=2, name='moderator')
m3.set_density('g/cc', 1.0)
m3.add_element('H', 2.)
m3.add_element('O', 1.)
m3.add_s_alpha_beta('c_H_in_H2O')

# Instantiate a Materials collection and export to xml
materials = openmc.Materials([m1,m2,m3])
materials.export_to_xml()

# Geometry definitions
# surface
r1=50
sphere1 = openmc.Sphere(x0=0,y0=0,z0=0,r=r1, boundary_type='vacuum')
xplane1 = openmc.XPlane(x0=-11.2)  
xplane2 = openmc.XPlane(x0=-5.60)  
xplane3 = openmc.XPlane(x0=11.20)  
yplane1 = openmc.YPlane(y0=-10.4)  
yplane2 = openmc.YPlane(y0=-5.20)  
yplane3 = openmc.YPlane(y0=10.40)  
zplane1 = openmc.ZPlane(z0=-8.80)  
zplane2 = openmc.ZPlane(z0=-4.40)  
zplane3 = openmc.ZPlane(z0=8.800)  

# regions
region1= +xplane1 & -xplane2 & +yplane1 & -yplane2  & +zplane1 & -zplane2  
region2= +xplane1 & -xplane3 & +yplane1 & -yplane3  & +zplane1 & -zplane3 
region3= -sphere1 &(~(-xplane3 & +yplane1 & -yplane3  & +zplane1 & -zplane3 ))

# cell
cell1 = openmc.Cell() 
cell1.fill =m1
cell1.region = region1

cell2 = openmc.Cell() 
cell2.fill =m2 
cell2.region = region1

cell3 = openmc.Cell() 
cell3.fill =m3 
cell3.region = region1

cell4 = openmc.Cell() 
cell4.region = region3
cell4.fill =m3 

cell5 = openmc.Cell() 
cell5.region = region2

# universe 
u1 = openmc.Universe()
u1.add_cell(cell1)
u2 = openmc.Universe()
u2.add_cell(cell2)
u3 = openmc.Universe()
u3.add_cell(cell3)
root = openmc.Universe()
root.add_cell(cell5)

# Instantiate a Lattice
# Create  Lattice
lat3d = openmc.RectLattice(name='Head mold') #长方形的格子,长方形矩阵
lat3d.pitch = (5.6, 5.2, 4.4) 
lat3d.lower_left = (-11.2, -10.4, -8.8)
lat3d.universes = [  [[u1, u2, u1, u2],
                     [u2, u3, u2, u3],
                     [u1, u2, u1, u2],
                     [u2, u3, u2, u3]],
                     [[u1, u2, u2, u2],
                     [u3, u3, u2, u3],
                     [u1, u2, u2, u2],
                     [u2, u1, u2, u3]],
                     [[u1, u2, u3, u2],
                     [u2, u1, u2, u3],
                     [u1, u2, u3, u2],
                     [u2, u3, u2, u3]],
                     [[u1, u1, u1, u2],
                     [u3, u3, u2, u3],
                     [u1, u2, u2, u2],
                     [u1, u3, u2, u3]]]
# Fill Cell with the Lattice
cell5.fill = lat3d


# Instantiate a geometry collection and export to xml
geometry = openmc.Geometry(root)
geometry.export_to_xml()

root.plot(origin=(0, 0, 0),basis = 'xy',width=(25, 25),color_by = 'material')
plt.show()

but,The graphic output is blank。
image

Why is this the case? (The image is blank)

Hello @ZENGJIE

There is just an omission in the definition of region 3:

Blockquote
region3= -sphere1 &(~(-xplane3 & +yplane1 & -yplane3 & +zplane1 & -zplane3 ))

which should be (you forgot to close your excluded volume : +xplane1)
region3= -sphere1 &(~(+xplane1 & -xplane3 & +yplane1 & -yplane3 & +zplane1 & -zplane3 ))

and if I’m not wrong you should get the following scheme

image

thank you very mush.@ bentridisalah
Maybe when I wrote it, I forgot to write this:+xplane1.
Just now, I re-wrote this sentence(region3= -sphere1 &(~(+xplane1 & -xplane3 & +yplane1 & -yplane3 & +zplane1 & -zplane3 ))) to the original program, the calculation graph is still blank.

image

hi @ZENGJIE

Here the notebook with which I could generate correctly the figure.
ZENGJIE_3D.ipynb (9.9 KB)
it should work also for you.

best regards