Created
November 18, 2024 22:32
-
-
Save pshriwise/c55a68cb462d4711167d4759bb05a07f to your computer and use it in GitHub Desktop.
Plots a plane and generates a Cubit file for an OpenMC general plane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmc | |
from openmc_cad_adapter import to_cubit_journal | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# Define the coefficients of the plane | |
a, b, c, d = 1, 2, -3, 1 | |
plane = openmc.Plane(a, b, c, d) | |
c1 = openmc.Cell(region=-plane) | |
c2 = openmc.Cell(region=+plane) | |
u = openmc.Universe(cells=[c1, c2]) | |
to_cubit_journal(openmc.Geometry(u), world=[100, 100, 100]) | |
# Create the x, y, and z arrays | |
xx, yy = np.meshgrid(range(10), range(10)) | |
z = (d - a*xx - b*yy) * 1.0 / c | |
# Create a 3D plot | |
fig = plt.figure() | |
ax = fig.add_subplot(111, projection='3d') | |
ax.plot_surface(xx, yy, z) | |
# Set the axis labels | |
ax.set_xlabel('X') | |
ax.set_ylabel('Y') | |
ax.set_zlabel('Z') | |
# Show the plot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment