Hexagonal prism aligned to z-axis

I’m working on a model (that will eventually be used in a Cardinal multiphysics simulation) for a reactor with coolant that flows in the y-direction. According to the documentation for HexagonalPrism, orientation can only be 'x' or 'y'

It seems like for my picture, by definition of orientation in the docs, I’d want orientation = 'z', but that isn’t an option. What is the recommendation here?

I will answer my own question, in case others are wondering the same in the future.

The best way is to use one of the options available and then rotate the geometry to be in the desired reference frame. The key here is that two rotation calls are necessary. First, the region (intersection of hex cell and bounding z-planes) must be rotated via openmc.Region.rotate(). Then, the cell that contains the universe must be rotated by specifying openmc.Cell.rotation on the cell after it is created. Here’s some code to show how I do this

    zplane_min = openmc.ZPlane(z0=z_min, boundary_type="vacuum")
    zplane_max = openmc.ZPlane(z0=z_max, boundary_type="vacuum")
    hex_boundary_region = openmc.model.HexagonalPrism(
        edge_length=lattice_flat_to_flat * f / math.sqrt(3),
        orientation="y"
    )
    region = -hex_boundary_region & +zplane_min & -zplane_max
    rotated_region = region.rotate((-90.0, 0.0, 0.0))
    core_cell = openmc.Cell(
        region=rotated_region,
        fill=core_lattice
    )
    core_cell.rotation = (-90.0, 0.0, 0.0)
    geometry = openmc.Geometry([core_cell])

(note the definition of core_lattice is not shown, but I used a HexLattice)

Important to note that openmc.Cell.rotation applies to the fill of the cell and doesn’t actually rotate the cell itself, which is why openmc.Region.rotate() must be used.

1 Like