How do you rotate this model by 180/90 degrees

Hello!
I’m a new openmc scholar. Now I have a problem: I need to rotate this brain model 180/90 degrees along the z axis。
image

This is geometry part:

import glob
from IPython.display import Image
import matplotlib.pyplot as plt
import scipy.stats
import numpy as np
import pandas as pd
import openmc
from math import pi, cos
import os
%matplotlib inline

# Materials definitions
m400 = openmc.Material(material_id=4,name='AIR')   #空气
m400.add_element('C',0.00012,'wo')
m400.add_element('N',0.7552927,'wo')
m400.add_element('O',0.231787,'wo')
m400.add_element('Ca',0.0128004,'wo')
m400.set_density('g/cm3', 0.001293)

m100 = openmc.Material(material_id=1, name='brain')
m100.set_density('g/cc', 1.04)
m100.add_nuclide('H1', 0.107 ,'wo')    #1
m100.add_element('C',0.145,'wo')
m100.add_nuclide('N14', 0.022,'wo')   #7
m100.add_nuclide('O16', 0.712,'wo')   #8
m100.add_nuclide('Na23', 0.002,'wo')  #11
m100.add_nuclide('P31', 0.004,'wo')   #15
m100.add_nuclide('S32', 0.002,'wo')   #16
m100.add_element('C', 0.003,'wo')  #17
m100.add_element('K', 0.003,'wo')   #19
m100.add_s_alpha_beta('c_H_in_H2O')

m200 = openmc.Material(material_id=2, name='Cranium')
m200.set_density('g/cc', 1.61)
m200.add_nuclide('H1', 0.05 ,'wo')    #1
m200.add_element('C',0.212,'wo')
m200.add_nuclide('N14', 0.04,'wo')   #7
m200.add_nuclide('O16', 0.435,'wo')   #8
m200.add_nuclide('Na23', 0.001,'wo')  #11
m200.add_element('Mg', 0.002,'wo')     #12
m200.add_nuclide('P31', 0.081,'wo')   #15
m200.add_nuclide('S32', 0.003,'wo')   #16
m200.add_element('Ca', 0.176,'wo')  #20
m200.add_s_alpha_beta('c_H_in_H2O')

m300 = openmc.Material(material_id=3, name='SCALP')
m300.set_density('g/cc', 1.09)
m300.add_nuclide('H1', 0.1 ,'wo')    #1
m300.add_element('C',0.204,'wo')
m300.add_nuclide('N14', 0.042,'wo')   #7
m300.add_nuclide('O16', 0.645,'wo')   #8
m300.add_nuclide('Na23', 0.002,'wo')  #11
m300.add_nuclide('P31', 0.001,'wo')   #15
m300.add_nuclide('S32', 0.002,'wo')   #16
m300.add_element('C', 0.003,'wo')  #17
m300.add_element('K', 0.001,'wo')   #19
m300.add_s_alpha_beta('c_H_in_H2O')

# Instantiate a Materials collection and export to xml
materials = openmc.Materials([m100,m200,m300,m400])
materials.export_to_xml()

# Geometry definitions
# surface
quadric10 = openmc.Quadric(a=0.0277778, b=0.0123456,c=0.0236686,
                           d=0,e=0,f=0,
                           g=0, h=0, j=-0.04337,
                           k=-0.97633)
quadric20 = openmc.Quadric(a=0.0216263, b=0.0104123,c=0.0145159,
                           d=0,e=0,f=0,
                           g=0, h=0, j=0,
                           k=-1)
quadric30 = openmc.Quadric(a=0.0187652, b=0.0094260,c=0.0129133,
                           d=0,e=0,f=0,
                           g=0, h=0, j=0,
                           k=-1)
sphere40 = openmc.Sphere(x0=0,y0=0,z0=0,r=40, boundary_type='vacuum')
xplane50 = openmc.XPlane(x0=-0.8)  
xplane52 = openmc.XPlane(x0=0.8)    
yplane150 = openmc.YPlane(y0=-0.8)  
yplane152 = openmc.YPlane(y0=0.8)  
zplane228 = openmc.ZPlane(z0=-8.8)  
zplane229 = openmc.ZPlane(z0=-8.4)  
zplane230 = openmc.ZPlane(z0=-8.0) 
zplane231 = openmc.ZPlane(z0=-7.6)  
zplane232 = openmc.ZPlane(z0=-7.2)  
zplane233 = openmc.ZPlane(z0=-6.8) 
zplane234 = openmc.ZPlane(z0=-6.4) 
zplane235 = openmc.ZPlane(z0=-6.0)  
zplane236 = openmc.ZPlane(z0=-5.6)  
zplane237 = openmc.ZPlane(z0=-5.2) 
zplane238 = openmc.ZPlane(z0=-4.8)  
zplane239 = openmc.ZPlane(z0=-4.4) 
zplane240 = openmc.ZPlane(z0=-4.0) 
zplane241 = openmc.ZPlane(z0=-3.6)  
zplane242 = openmc.ZPlane(z0=-3.2)  
zplane243 = openmc.ZPlane(z0=-2.8) 
zplane244 = openmc.ZPlane(z0=-2.4) 
zplane245 = openmc.ZPlane(z0=-2.0)  
zplane246 = openmc.ZPlane(z0=-1.6)  
zplane247 = openmc.ZPlane(z0=-1.2) 
zplane248 = openmc.ZPlane(z0=-0.8)  
zplane249 = openmc.ZPlane(z0=-0.4) 
zplane250 = openmc.ZPlane(z0=0.0) 
zplane251 = openmc.ZPlane(z0=0.4)  
zplane252 = openmc.ZPlane(z0=0.8)  
zplane253 = openmc.ZPlane(z0=1.2) 
zplane254 = openmc.ZPlane(z0=1.6) 
zplane255 = openmc.ZPlane(z0=2.0)  
zplane256 = openmc.ZPlane(z0=2.4)  
zplane257 = openmc.ZPlane(z0=2.8) 
zplane258 = openmc.ZPlane(z0=3.2)  
zplane259 = openmc.ZPlane(z0=3.6) 
zplane260 = openmc.ZPlane(z0=4.0) 
zplane261 = openmc.ZPlane(z0=4.4)  
zplane262 = openmc.ZPlane(z0=4.8)  
zplane263 = openmc.ZPlane(z0=5.2) 
zplane264 = openmc.ZPlane(z0=5.6) 
zplane265 = openmc.ZPlane(z0=6.0)  
zplane266 = openmc.ZPlane(z0=6.4)  
zplane267 = openmc.ZPlane(z0=6.8) 
zplane268 = openmc.ZPlane(z0=7.2)  
zplane269 = openmc.ZPlane(z0=7.6) 
zplane270 = openmc.ZPlane(z0=8.0) 
zplane271 = openmc.ZPlane(z0=8.4)  
zplane272 = openmc.ZPlane(z0=8.8)  
zplane273 = openmc.ZPlane(z0=9.2) 
zplane274 = openmc.ZPlane(z0=9.6) 

# Air preceeding Skin
cell2 = openmc.Cell(cell_id=2,fill =m400,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane273 & -zplane274 ) 
cell3 = openmc.Cell(cell_id=3,fill =m400,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane272 & -zplane273 ) 
cell4 = openmc.Cell(cell_id=4,fill =m400,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane271 & -zplane272 & +quadric30 ) 
# Skin
cell5 = openmc.Cell(cell_id=5,fill =m300,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane271 & -quadric30 ) 
cell6 = openmc.Cell(cell_id=6,fill =m300,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane250 & -zplane271 & +quadric20 ) 
# Bone
cell7 = openmc.Cell(cell_id=7,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane270 & -quadric20 ) 
cell8 = openmc.Cell(cell_id=8,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane269 & -zplane270 ) 
cell9 = openmc.Cell(cell_id=9,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & -zplane269 & +zplane250 & +quadric10 ) 
# Brain 
cell10 = openmc.Cell(cell_id=10,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane268 & -quadric10  ) 
cell11 = openmc.Cell(cell_id=11,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane267 & -zplane268 )
cell12 = openmc.Cell(cell_id=12,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane266 & -zplane267 ) 
cell13 = openmc.Cell(cell_id=13,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane265 & -zplane266 )
cell14 = openmc.Cell(cell_id=14,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane264 & -zplane265 ) 
cell15 = openmc.Cell(cell_id=15,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane263 & -zplane264 )
cell16 = openmc.Cell(cell_id=16,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane262 & -zplane263 ) 
cell17 = openmc.Cell(cell_id=17,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane261 & -zplane262 )
cell18 = openmc.Cell(cell_id=18,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane260 & -zplane261 ) 
cell19 = openmc.Cell(cell_id=19,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane259 & -zplane260 )
cell20 = openmc.Cell(cell_id=20,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane258 & -zplane259 ) 
cell21 = openmc.Cell(cell_id=21,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane257 & -zplane258 )
cell22 = openmc.Cell(cell_id=22,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane256 & -zplane257 ) 
cell23 = openmc.Cell(cell_id=23,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane255 & -zplane256 )
cell24 = openmc.Cell(cell_id=24,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane254 & -zplane255 ) 
cell25 = openmc.Cell(cell_id=25,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane253 & -zplane254 )
cell26 = openmc.Cell(cell_id=26,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane252 & -zplane253 ) 
cell27 = openmc.Cell(cell_id=27,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane251 & -zplane252 )
cell28 = openmc.Cell(cell_id=28,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane250 & -zplane251 ) 
cell29 = openmc.Cell(cell_id=29,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane249 & -zplane250 )
cell30 = openmc.Cell(cell_id=30,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane248 & -zplane249 ) 
cell31 = openmc.Cell(cell_id=31,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane247 & -zplane248 )
cell32 = openmc.Cell(cell_id=32,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane246 & -zplane247 ) 
cell33 = openmc.Cell(cell_id=33,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane245 & -zplane246 )
cell34 = openmc.Cell(cell_id=34,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane244 & -zplane245 ) 
cell35 = openmc.Cell(cell_id=35,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane243 & -zplane244 )
cell36 = openmc.Cell(cell_id=36,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane242 & -zplane243 ) 
cell37 = openmc.Cell(cell_id=37,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane241 & -zplane242 )
cell38 = openmc.Cell(cell_id=38,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane240 & -zplane241 ) 
cell39 = openmc.Cell(cell_id=39,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane239 & -zplane240 )
cell40 = openmc.Cell(cell_id=40,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane238 & -zplane239 ) 
cell41 = openmc.Cell(cell_id=41,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane237 & -zplane238 )
cell42 = openmc.Cell(cell_id=42,fill =m100,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & -zplane237 & -quadric10 ) 
# Bone 
cell43 = openmc.Cell(cell_id=43,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane236 & -zplane250 & +quadric10 )
cell44 = openmc.Cell(cell_id=44,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane235 & -zplane236 ) 
cell45 = openmc.Cell(cell_id=45,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane234 & -zplane235 )
cell46 = openmc.Cell(cell_id=46,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane233 & -zplane234 ) 
cell47 = openmc.Cell(cell_id=47,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane232 & -zplane233 )
cell48 = openmc.Cell(cell_id=48,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane231 & -zplane232 ) 
cell49 = openmc.Cell(cell_id=49,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane230 & -zplane231 )
cell50 = openmc.Cell(cell_id=50,fill =m200,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & -quadric20 & -zplane230 ) 
# Skin  
cell51 = openmc.Cell(cell_id=51,fill =m300,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane229 & -zplane250 &+quadric20)
cell52 = openmc.Cell(cell_id=52,fill =m300,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & -quadric30 & -zplane229 )
# Air at end
cell53 = openmc.Cell(cell_id=53,fill =m400,region= +xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane228 & -zplane229 & +quadric30)

cell100 = openmc.Cell(cell_id=100,fill =m100,region= ~(+xplane50 & -xplane52 & +yplane150 & -yplane152 ) & -quadric10 )
cell200 = openmc.Cell(cell_id=200,fill =m200,region= ~(+xplane50 & -xplane52 & +yplane150 & -yplane152 ) & +quadric10 & -quadric20 ) 
cell300 = openmc.Cell(cell_id=300,fill =m300,region= ~(+xplane50 & -xplane52 & +yplane150 & -yplane152 ) & +quadric20 & -quadric30 )
cell400 = openmc.Cell(cell_id=400,fill =m400,region= ~((+xplane50 & -xplane52 & +yplane150 & -yplane152 & +zplane228 & -zplane274)| -quadric30) & -sphere40  )
# Instantiate a geometry collection and export to xml
root_universe = openmc.Universe(cells=(
                               cell2, cell3, cell4,
                                cell5, cell6, 
                                cell7 , cell8, cell9,
                                cell10,cell11, cell12, cell13,cell14,cell15, cell16,cell17, cell18, cell19, cell20,
                                cell21, cell22, cell23,cell24,cell25, cell26,cell27, cell28, cell29, cell30,cell31,
                                cell32, cell33,cell34,cell35, cell36,cell37, cell38, cell39, cell40,cell41, cell42,
                                cell43,cell44,cell45, cell46,cell47, cell48, cell49, cell50,
                                cell51, cell52,
                               cell53,
                                cell100,cell200,cell300,cell400
                                ))
geometry = openmc.Geometry(root_universe)
geometry.export_to_xml()

# 画图形
root_universe .plot(origin=(0, 0, 0),basis = 'yz',width=(25, 25),color_by = 'cell')
plt.show()

#root_universe .plot(origin=(0, 0, 0),basis = 'xz',width=(25, 25),color_by = 'material')
root_universe .plot(origin=(0, 0, 0),basis = 'xz',width=(25, 25),color_by = 'cell')
plt.show()

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

Hello,

You could use the rotation tool I think by defining a new universe like this :slight_smile:

cell_rotated = openmc.Cell(fill =root_universe ,rotation=(0,0,X))
rotated_universe=openmc.Universe(cells=cell_rotated)
geometry = openmc.Geometry(rotated_universe)

something like this could work i think.

https://docs.openmc.org/en/stable/io_formats/geometry.html?highlight=rotation

thanks very mush! @Thomas
I took your advice and made a simpler model to verify the rotation test.
the simpler model is:
image

import glob
from IPython.display import Image
import matplotlib.pyplot as plt
import scipy.stats
import numpy as np
import pandas as pd
import openmc
from math import pi, cos
import os
%matplotlib inline

# Materials definitions
m400 = openmc.Material(material_id=4,name='AIR')   #空气
m400.add_element('C',0.00012,'wo')
m400.add_element('N',0.7552927,'wo')
m400.add_element('O',0.231787,'wo')
m400.add_element('Ca',0.0128004,'wo')
m400.set_density('g/cm3', 0.001293)

m100 = openmc.Material(material_id=1, name='brain')
m100.set_density('g/cc', 1.04)
m100.add_nuclide('H1', 0.107 ,'wo')    #1
m100.add_element('C',0.145,'wo')
m100.add_nuclide('N14', 0.022,'wo')   #7
m100.add_nuclide('O16', 0.712,'wo')   #8
m100.add_nuclide('Na23', 0.002,'wo')  #11
m100.add_nuclide('P31', 0.004,'wo')   #15
m100.add_nuclide('S32', 0.002,'wo')   #16
m100.add_element('C', 0.003,'wo')  #17
m100.add_element('K', 0.003,'wo')   #19


m200 = openmc.Material(material_id=2, name='Cranium')
m200.set_density('g/cc', 1.61)
m200.add_nuclide('H1', 0.05 ,'wo')    #1
m200.add_element('C',0.212,'wo')
m200.add_nuclide('N14', 0.04,'wo')   #7
m200.add_nuclide('O16', 0.435,'wo')   #8
m200.add_nuclide('Na23', 0.001,'wo')  #11
m200.add_element('Mg', 0.002,'wo')     #12
m200.add_nuclide('P31', 0.081,'wo')   #15
m200.add_nuclide('S32', 0.003,'wo')   #16
m200.add_element('Ca', 0.176,'wo')  #20


m300 = openmc.Material(material_id=3, name='SCALP')
m300.set_density('g/cc', 1.09)
m300.add_nuclide('H1', 0.1 ,'wo')    #1
m300.add_element('C',0.204,'wo')
m300.add_nuclide('N14', 0.042,'wo')   #7
m300.add_nuclide('O16', 0.645,'wo')   #8
m300.add_nuclide('Na23', 0.002,'wo')  #11
m300.add_nuclide('P31', 0.001,'wo')   #15
m300.add_nuclide('S32', 0.002,'wo')   #16
m300.add_element('C', 0.003,'wo')  #17
m300.add_element('K', 0.001,'wo')   #19


# Instantiate a Materials collection and export to xml
materials = openmc.Materials([m100,m200,m300,m400])
materials.export_to_xml()

# Geometry definitions
# surface
quadric10 = openmc.Quadric(a=0.0277778, b=0.0123456,c=0.0236686,
                           d=0,e=0,f=0,
                           g=0, h=0, j=-0.04337,
                           k=-0.97633)
quadric20 = openmc.Quadric(a=0.0216263, b=0.0104123,c=0.0145159,
                           d=0,e=0,f=0,
                           g=0, h=0, j=0,
                           k=-1)
quadric30 = openmc.Quadric(a=0.0187652, b=0.0094260,c=0.0129133,
                           d=0,e=0,f=0,
                           g=0, h=0, j=0,
                           k=-1)
sphere40 = openmc.Sphere(x0=0,y0=0,z0=0,r=40, boundary_type='vacuum')

cell100 = openmc.Cell(cell_id=100,fill =m100,region= -quadric10 )
cell200 = openmc.Cell(cell_id=200,fill =m200,region= +quadric10 & -quadric20 )
cell300 = openmc.Cell(cell_id=300,fill =m300,region= +quadric20 & -quadric30 )
cell400 = openmc.Cell(cell_id=400,fill =m400,region= +quadric30 & -sphere40  )

root_universe = openmc.Universe(cells=(cell100,cell200,cell300,cell400))
geometry = openmc.Geometry(root_universe)
geometry.export_to_xml()

It outputs the result shown above.

while I add the rotary card, but there is this problem:


Its source program is:

# Geometry definitions
# surface
quadric10 = openmc.Quadric(a=0.0277778, b=0.0123456,c=0.0236686,
                           d=0,e=0,f=0,
                           g=0, h=0, j=-0.04337,
                           k=-0.97633)
quadric20 = openmc.Quadric(a=0.0216263, b=0.0104123,c=0.0145159,
                           d=0,e=0,f=0,
                           g=0, h=0, j=0,
                           k=-1)
quadric30 = openmc.Quadric(a=0.0187652, b=0.0094260,c=0.0129133,
                           d=0,e=0,f=0,
                           g=0, h=0, j=0,
                           k=-1)
sphere40 = openmc.Sphere(x0=0,y0=0,z0=0,r=40, boundary_type='vacuum')

cell100 = openmc.Cell(cell_id=100,fill =m100,region= -quadric10 )
cell200 = openmc.Cell(cell_id=200,fill =m200,region= +quadric10 & -quadric20 )
cell300 = openmc.Cell(cell_id=300,fill =m300,region= +quadric20 & -quadric30 )
cell400 = openmc.Cell(cell_id=400,fill =m400,region= +quadric30 & -sphere40  )

root_universe = openmc.Universe(cells=(cell100,cell200,cell300,cell400))

cell_rotated = openmc.Cell(fill =root_universe ,rotation=(0,0,180))
rotated_universe=openmc.Universe(cells=cell_rotated)
geometry = openmc.Geometry(rotated_universe)
geometry.export_to_xml()


# 画图形
root_universe .plot(origin=(0, 0, 0),basis = 'yz',width=(25, 25),color_by = 'cell')
plt.show()

root_universe .plot(origin=(0, 0, 0),basis = 'xz',width=(25, 25),color_by = 'cell')
plt.show()

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

while Its source program is:

cell100 = openmc.Cell(cell_id=100,fill =m100,region= -quadric10 )
cell200 = openmc.Cell(cell_id=200,fill =m200,region= +quadric10 & -quadric20 )
cell300 = openmc.Cell(cell_id=300,fill =m300,region= +quadric20 & -quadric30 )
cell400 = openmc.Cell(cell_id=400,fill =m400,region= +quadric30 & -sphere40  )

root_universe = openmc.Universe(cells=(cell100,cell200,cell300,cell400))


cell_rotated = openmc.Cell(fill =root_universe,region= -sphere40 )
cell_rotated.rotation=(0,0,180)
rotated_universe=openmc.Universe(cells=cell_rotated)
geometry = openmc.Geometry(rotated_universe)
geometry.export_to_xml()

The question arises:


NOW, I do not know what to do?

`

rotated_universe=openmc.Universe(cells=[cell_rotated])

and use an other value than 180 :smiley:

I do hope you will find the way you want to interact with your model.

Have fun :wink:

thank you very mush!@Thomas
After I changed “rotated_universe=openmc.Universe(cells=(cell_rotated))” to “rotated_universe=openmc.Universe(cells=[cell_rotated])”, the program will run.
but, It feels like the model doesn’t rotation.
I rotated 45 degrees along the z axis:

root_universe = openmc.Universe(cells=(cell100,cell200,cell300,cell400))

#cell_rotated = openmc.Cell(fill =root_universe ,rotation=(0,0,180))
cell_rotated = openmc.Cell(fill =root_universe )
cell_rotated.rotation=(0,0,45)
rotated_universe=openmc.Universe(cells=[cell_rotated])
geometry = openmc.Geometry(rotated_universe)
geometry.export_to_xml()


# 画图形
root_universe .plot(origin=(0, 0, 0),basis = 'yz',width=(25, 25),color_by = 'cell')
plt.show()

root_universe .plot(origin=(0, 0, 0),basis = 'xz',width=(25, 25),color_by = 'cell')
plt.show()

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

the geometry.xml:

<?xml version='1.0' encoding='utf-8'?>
<geometry>
  <cell fill="33" id="17" rotation="0 0 45" universe="34" />
  <cell id="100" material="1" region="-73" universe="33" />
  <cell id="200" material="2" region="73 -74" universe="33" />
  <cell id="300" material="3" region="74 -75" universe="33" />
  <cell id="400" material="4" region="75 -76" universe="33" />
  <surface coeffs="0.0277778 0.0123456 0.0236686 0 0 0 0 0 -0.04337 -0.97633" id="73" type="quadric" />
  <surface coeffs="0.0216263 0.0104123 0.0145159 0 0 0 0 0 0 -1" id="74" type="quadric" />
  <surface coeffs="0.0187652 0.009426 0.0129133 0 0 0 0 0 0 -1" id="75" type="quadric" />
  <surface boundary="vacuum" coeffs="0 0 0 40" id="76" type="sphere" />
</geometry>

From geometer.xml, the model should be rotated 45° along the z axis. But in fact, there is no rotation.
so, How to do?