Rotating rectangular_prism()

I want to create a rectangular prism shape with circular corner sides. I am using openmc.model.rectangular_prism to create it. I have successfully created it and positioned it in coordinates. I want to rotate the prism by 45 degrees, so I added the “rotate()” command to rotate it. However, the result I obtained changed the initial coordinates of the prism, and the prism did not rotate according to the desired inclination. How should I rotate it so that it has the correct inclination but still remains at the same (x, y) coordinates?

r_ch 	= 98.6
r_cir 	= 3
s_rec	= 10
h_rec	= 2* r_cir

pipe = openmc.model.rectangular_prism(s_rec, h_rec, axis='z', origin=((sin(pi/4)*r_ch), (cos(pi/4)*r_ch)), corner_radius=r_cir,  )

ppu	= (pipe).rotate((0,45,0))

pipe_cell = openmc.Cell(fill= helium , region=ppu & -t_act_core & +ct_dum_core)

@Ruri The rotate method has a pivot argument that allows you to choose that point around which things are rotated. If it is not specified, the point (0, 0, 0) is used as the pivot, which is why your prism will get shifted. I believe you should use the origin of your prism as the pivot point too so that it is rotated about its center. Also, assuming based on the figres that the direction into/out of the page is the z direction, you probably want to rotate about the z axis (e.g., (0, 0, 45))

1 Like

Thank you, Dr. @paulromano . I have completed the problem with your guidance.

r_ch 	= 98.6
r_cir 	= 3
s_rec	= 10
h_rec	= 2* r_cir

pipe = openmc.model.rectangular_prism(s_rec, h_rec, axis='z', origin=((sin(pi/4)*r_ch), (cos(pi/4)*r_ch)), corner_radius=r_cir,  )

ppu	= (pipe).rotate((0,0,-45), pivot=((sin(pi/4)*r_ch), (cos(pi/4)*r_ch), 0.0), order='xyz', inplace=False, memo=None)

pipe_cell = openmc.Cell(fill= fuel, region=ppu & -t_act_core & +ct_dum_core)

Currently, I would like to distribute 2-3 different types of pebbles (fuel pebble, moderator pebble) within a 3D core randomly. Is the approach for doing this the same as distributing TRISO particles within a spherical geometry ?, but this time using the boundaries of a cylindrical geometry type?

Is it possible to distribute the three pebbles randomly with a specific ratio? If possible, could you provide guidance for me to solve this problem?

You can use the openmc.model.pack_spheres function to get the coordinates of all pebbles (fuel + moderator + …). Then you can split them up as desired between the different pebble types, creating an openmc.model.TRISO object for each.

I’ve created a model as shown in " Modeling TRISO Particles", and I’m trying to distribute fuel and moderator, but only one type of pebble is coming out in the geometry.

##fuel 1 distribution
fuel1_pebble 			= openmc.model.pack_spheres(radius=outer_radius, region= active_core , pf=0.3, num_spheres=0.57*tot_pebble)
fuel1_pack			    = [openmc.model.TRISO(outer_radius, fill = fuel_spheres_unv , center=c) for c in fuel1_pebble ]

fuel_1_box 			            = openmc.Cell(region = active_core )
lower_left_f1, upper_right_f1 	= fuel_1_box.region.bounding_box
shape_f1 			            = (5, 5, 5)
pitch_f1 			            = (upper_right_f1 - lower_left_f1)/shape_f1
lattice_f1 			            = openmc.model.create_triso_lattice(fuel1_pack, lower_left_f1, pitch_f1, shape_f1, helium)
fuel_1_box.fill 		        = lattice_f1

pebble_universe 		        = openmc.Universe(cells = ([fuel_1_box,]))
fuel1_cell_distribution 	    = openmc.Cell(region = active_core, fill = pebble_universe)


##moderator distribution
moderator_pebble 		        = openmc.model.pack_spheres(radius=outer_radius, region= active_core , pf=0.3, num_spheres=0.43*tot_pebble)
moderator_pack			        = [openmc.model.TRISO(outer_radius, fill = moderator_spheres_unv , center=c) for c in moderator_pebble]

moderator_box 			        = openmc.Cell(region = active_core )
lower_left_mod, upper_right_mod	= moderator_box.region.bounding_box
shape_mod			            = (4, 4, 4)
pitch_mod 			            = (upper_right_mod - lower_left_mod)/shape_mod
lattice_mod 			        = openmc.model.create_triso_lattice(moderator_pack, lower_left_mod, pitch_mod, shape_mod, helium)
moderator_box.fill 		        = lattice_mod

mod_pebble_universe 		    = openmc.Universe(cells = ([moderator_box,]))
mod_cell_distribution 		    = openmc.Cell(region = active_core, fill = mod_pebble_universe)

Sorry @paulromano , I’ve tried to adjust my code, but I still can’t distribute 2 pebbles at once, only 1 type of pebble appears when I plot the code. Can you point out the error in my code

Again, you should have only a single call to pack_spheres that generates the pebble locations for both fuel/moderator pebbles. Then your pack variable, which is a list, needs to include both TRISO(..., fill=fuel_spheres_univ) and TRISO(..., fill=moderator_spheres_univ) wherever you want fuel and moderator pebbles to show up. It is up to you how you want to split up the pebble locations that are returned by pack_spheres. For example if you wanted to randomly pick fuel/moderator with probability 0.5:

pebbles = openmc.model.pack_spheres(...)
pack = []
for c in pebbles:
    if random.random() < 0.5:
        pack.append(openmc.model.TRISO(fill=fuel_spheres_univ, ...))
    else:
        pack.append(openmc.model.TRISO(fill=moderator_spheres_univ, ...))

This is just one way you could go about it.

Thanks @paulromano , it solved the problem