Last active
February 5, 2022 03:46
-
-
Save pshriwise/75b022bbeb2c113a70bc69b922e1aef4 to your computer and use it in GitHub Desktop.
Check for axial homogeneity in OpenMC model
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
#!/usr/bin/env python | |
import numpy as np | |
from progressbar import progressbar | |
import openmc | |
import openmc.lib | |
# main parameters | |
n_axial = 500 | |
h_res = 800 | |
v_res = 100 | |
# get the bounding box of this model | |
openmc.lib.init() | |
bbox = openmc.lib.global_bounding_box() | |
print("Model bounding box: {}".format(bbox)) | |
# setup a plot object with the global extents | |
p = openmc.lib.plot._PlotBase() | |
p.basis = 'xz' | |
p.origin = (0.0, 0.0, 0.0) | |
p.width = 200 | |
p.height = 1.0 | |
p.h_res = h_res | |
p.v_res = v_res | |
x_vals = np.linspace(bbox[0][0], bbox[1][0], n_axial) | |
y_vals = np.linspace(bbox[0][1], bbox[1][1], n_axial) | |
vals = np.asarray((x_vals, y_vals)).T | |
print("Checking for axial changes...") | |
for x_val, y_val in progressbar(vals): | |
# check x | |
p.basis = 'yz' | |
p.origin = (x_val, 0.0, 0.0) | |
id_map = openmc.lib.id_map(p) | |
if not (id_map == id_map[0, :]).all(): | |
# print(f'Inhomogeneity detected at y={val} cm !') | |
print(p) | |
raise ValueError(f'Inhomogeneity detected at x={x_val} cm !') | |
# check y | |
p.basis = 'xz' | |
p.origin = (0.0, y_val, 0.0) | |
id_map = openmc.lib.id_map(p) | |
if not (id_map == id_map[0, :]).all(): | |
# print(f'Inhomogeneity detected at y={val} cm !') | |
print(p) | |
raise ValueError(f'Inhomogeneity detected at y={y_val} cm !') | |
print("All materials are the same axially.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment