Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CylinderSector can't have an aperture angle greater than 180° #3293

Open
nplinden opened this issue Feb 5, 2025 · 0 comments
Open

CylinderSector can't have an aperture angle greater than 180° #3293

nplinden opened this issue Feb 5, 2025 · 0 comments
Labels

Comments

@nplinden
Copy link
Contributor

nplinden commented Feb 5, 2025

Bug Description

Hi,
I am trying to build a cylinder sector with an aperture angle higher than 180°. This seems to not be possible using the current implementation of the openmc.model.CylinderSector class.

Here are the result when using the default CylinderSector constructor with $\theta_1 = 0$ and $\theta_2 \in [10, 350]$:

Image

And here are the results when using the CylinderSector.from_theta_alpha constructor with $\alpha = 45°$ and $\theta \in [10, 350]$:

Image

It's seems that once the place defined by $\theta_2$ crosses the other plane, the boolean operations used to get the sector change and the current implementation fails.
Here's what I mean:

Image

Steps to Reproduce

Here's the script I use to generate the gif:

import openmc
import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path


def build_default(angle):
    openmc.reset_auto_ids()
    model = openmc.Model()
    fuel = openmc.Material()
    fuel.add_nuclide("Pu239", 1.)
    fuel.set_density("g/cm3", 10)
    coolant = openmc.Material()
    coolant.add_nuclide("Cl35", 1.)
    coolant.set_density("g/cm3", 2)
    model.materials = openmc.Materials(materials=[fuel, coolant])

    sector = openmc.model.CylinderSector(
        r1 = 1,
        r2 = 2,
        theta1=0,
        theta2=angle,
        center=(0, 0),
        axis="z"
    )
    cells = [
        openmc.Cell(region=-sector, fill=fuel),
        openmc.Cell(region=+sector, fill=coolant)
    ]
    model.geometry = openmc.Geometry(root=openmc.Universe(cells=cells))
    return model

def build_alpha(angle):
    openmc.reset_auto_ids()
    model = openmc.Model()
    fuel = openmc.Material()
    fuel.add_nuclide("Pu239", 1.)
    fuel.set_density("g/cm3", 10)
    coolant = openmc.Material()
    coolant.add_nuclide("Cl35", 1.)
    coolant.set_density("g/cm3", 2)
    model.materials = openmc.Materials(materials=[fuel, coolant])

    sector = openmc.model.CylinderSector.from_theta_alpha(
        r1 = 1,
        r2 = 2,
        theta=angle,
        alpha=45,
        center=(0, 0),
        axis="z"
    )
    cells = [
        openmc.Cell(region=-sector, fill=fuel),
        openmc.Cell(region=+sector, fill=coolant)
    ]
    model.geometry = openmc.Geometry(root=openmc.Universe(cells=cells))
    return model


Path("default").mkdir(exist_ok=True)
for i, angle in enumerate(np.arange(10, 360, 10)):
    fig, ax = plt.subplots(1, 1)
    model = build_default(angle)
    fig.suptitle("Default Constructor")
    print(i)
    print("built")
    model.plot(pixels=(700, 700), axes=ax)
    print("plotted")
    ax.set_title(r"$\theta_1 = %d \quad \theta_2 = %d$" % (0, angle))
    fig.savefig(f"default/{i:03d}.png")
    plt.close()

Path("alpha").mkdir(exist_ok=True)
for i, angle in enumerate(np.arange(10, 360, 10)):
    fig, ax = plt.subplots(1, 1)
    model = build_alpha(angle)
    fig.suptitle("theta_alpha Constructor")
    print(i)
    print("built")
    model.plot(pixels=(700, 700), axes=ax)
    print("plotted")
    ax.set_title(r"$\theta = %d \quad \alpha = %d$" % (angle, 45))
    fig.savefig(f"alpha/{i:03d}.png")
    plt.close()

Environment

I use the develop branch on Ubuntu 20.04

I have a new implementation ready but i'd love some feedback on this issue before making a PR.

Cheers

@nplinden nplinden added the Bugs label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant