Locality rotation and translation

Hello, everyone!I use the rotation and translation functions to do partial rotate and translate of the model。Such as:

# Materials definitions
m1 = openmc.Material(material_id=1,name='AIR')   #空气
m1.add_element('C',0.001205,'wo')
m1.add_nuclide('N14',0.7552927,'wo')
m1.add_nuclide('O16',0.231787,'wo')
m1.add_element('Ca',0.0128004,'wo')
m1.set_density('g/cm3', 0.001293)

m2 = openmc.Material(material_id=2, name='Pb')
m2.set_density('g/cc', 11.35)
m2.add_nuclide('Pb204', 0.0148 ,'wo')    #1
m2.add_nuclide('Pb206',0.241,'wo')
m2.add_nuclide('Pb207', 0.226,'wo')   #7
m2.add_nuclide('Pb208', 0.523,'wo')   #8

m3 = openmc.Material(material_id=3, name='polyethylene')
m3.set_density('g/cc', 0.9843)
m3.add_nuclide('H1', 0.5262,'wo')    #1
m3.add_element('C',0.2969,'wo')
m3.add_nuclide('O16', 0.1007,'wo')   #7
m3.add_nuclide('Li6', 0.0724,'wo')   #8
m3.add_nuclide('Li7', 0.0038,'wo')  #11
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()

# surface
sphere100 = openmc.Sphere(x0=0,y0=0,z0=0,r=1000, boundary_type='vacuum')
ZCone6 = openmc.ZCone(x0=0,y0=0,z0=5.4,        r2=(18/5.4)**2,boundary_type='transmission') 
zplane25 = openmc.ZPlane(z0=-10.8,boundary_type='vacuum')  
zplane4 = openmc.ZPlane(z0=0.0,boundary_type='transmission')
zplane8 = openmc.ZPlane(z0=3.0,boundary_type='transmission') 
xplane1 = openmc.XPlane(x0=-40,boundary_type='transmission')  
xplane2 = openmc.XPlane(x0=40,boundary_type='transmission')    
yplane1 = openmc.YPlane(y0=-40,boundary_type='transmission')  
yplane2 = openmc.YPlane(y0=40,boundary_type='transmission')

# Air preceeding Skin
cell3 = openmc.Cell(cell_id=3,fill =m3,region=+xplane1 & -xplane2 & +yplane1 & -yplane2 & -zplane4 & +zplane25) 
cell4 = openmc.Cell(cell_id=4,fill =m2,region= +zplane4 &-zplane8 & -ZCone6) 

rpp = openmc.model.RectangularParallelepiped(-5, 5, -5, 5, 23.5, 33.5)
rpp1 = openmc.model.RectangularParallelepiped(-3, 3, -3, 3, 25.5, 31.5)
cell23= openmc.Cell(cell_id=23,fill =m3,region= -rpp & +rpp1)
cell24= openmc.Cell(cell_id=24,fill =m2,region= -rpp1)
root1 = openmc.Universe(cells=[cell23,cell24 ])
cell21= openmc.Cell(cell_id=21,fill =root1,region= -rpp)
cell21.rotation=(0,45,45)   #旋转参考x y z轴
cell21.translation=(0,20,20)

region1=cell21.region

cell30 = openmc.Cell(cell_id=30,fill =m1,region= ~((+xplane1 & -xplane2 & +yplane1 & -yplane2 & -zplane4 & +zplane25 )
                           | ( +zplane4 &-zplane8 & -ZCone6)| region1) 
                            & -sphere100)
root_universe = openmc.Universe(cells=( cell3, cell4, cell21, cell30 ))
geometry = openmc.Geometry(root_universe)
geometry.export_to_xml()

# 画图形
root_universe .plot(origin=(0, 0, 23.5),basis = 'yz',width=(100,100) ,color_by = 'material')
plt.show()
root_universe .plot(origin=(0, 0, 23.5),basis = 'xz',width=(100, 100),color_by = 'cell')
plt.show()
root_universe .plot(origin=(0, 0, 28.5),basis = 'xy',width=(100, 100),color_by = 'cell')
plt.show()

but,The result is that:There was a particle leak。
Modeling model:
image
image

how do it?
thanks very much!

Hi @ZENGJIE,

Thanks for your post. I think the problem is that you’re creating the cells in their final position and rotating+translating them into place. It also helps to define universes with an infinite cell surrounding all other cells to avoid lost particle problems. I’ve created a notebook to demonstrate how some of these transformations work in more detail. I hope it’s helpful: