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

Adding domain decomposition #129

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a00ff82
Current domain decomp implementation
shac170 Sep 14, 2023
4a90f5d
added reeds test example
shac170 Sep 14, 2023
3092392
Reverting to current MCDC
shac170 Sep 14, 2023
6c1208e
Update loop.py
shac170 Sep 14, 2023
9bc6e5e
revert
shac170 Sep 14, 2023
c229a0d
domain decomp in current MCDC1
shac170 Sep 14, 2023
627eea5
Merge branch 'main' of https://github.com/shac170/MCDC
shac170 Sep 14, 2023
f02179e
Current implimentation
shac170 Sep 14, 2023
64816e0
tweaks to dd
shac170 Sep 14, 2023
b8ff213
switch to current regression tests
shac170 Sep 14, 2023
b38cb21
test stuff
shac170 Sep 14, 2023
ee6ce80
urrent domain decomp
shac170 Sep 19, 2023
ee2b86f
Added dd test
shac170 Sep 19, 2023
beb172c
removed print statements
shac170 Sep 19, 2023
6606600
update gitignore
Sep 20, 2023
fc72894
Corrected particle transfer for multiple processors
shac170 Sep 22, 2023
c6750c6
Correcting
shac170 Sep 22, 2023
006941e
Formatting
shac170 Sep 22, 2023
4d331bc
Removing csvs
shac170 Sep 22, 2023
ad9c83b
Added reproducibility
shac170 Sep 26, 2023
70683c3
Added domain_decomp examples
shac170 Sep 27, 2023
d0589b6
use print_error and back in black
Sep 28, 2023
fdebe8a
fix some dd numba issues: objmode and required dd parameters in type_.py
Sep 28, 2023
bfe0c9d
removed print statements, changed termination criteria
shac170 Oct 1, 2023
69c8b96
make dd work on Numba
Oct 3, 2023
8b60d13
fixed termination criteria
shac170 Oct 9, 2023
46a9e89
added test problems
shac170 Oct 9, 2023
b96da09
fixing unnecessary errors
shac170 Oct 10, 2023
29eb872
working update
Nov 9, 2023
44b64e9
Merge branch 'domain_decomposition' of https://github.com/shac170/MCD…
Nov 9, 2023
11a4f79
Merge branch 'main' of https://github.com/shac170/MCDC
shac170 Nov 9, 2023
16535ab
Merge branch 'domain_decomposition'
shac170 Nov 9, 2023
2f0d8b0
fixed bugs
shac170 Nov 9, 2023
bc62fba
style changes
shac170 Nov 9, 2023
1979d24
Delete examples/fixed_source/c5g7 directory
shac170 Nov 9, 2023
0533ef2
iqmc source tilting and refactorization
spasmann Dec 13, 2023
f3a2a61
black reformat
spasmann Dec 13, 2023
cc9a45a
Cleanup examples folder
spasmann Dec 14, 2023
e127fe2
MESH_* flags and remove iQMC sweep counter
spasmann Dec 15, 2023
417068f
Merge branch 'main' into pr/129
spasmann Dec 15, 2023
f2bc87a
Two fixed source DD regression tests if mpiexec=4
spasmann Dec 15, 2023
aaaf602
regression/run.py bug fix
spasmann Dec 15, 2023
816e58d
Adding domain event to move_to_event function
shac170 Dec 20, 2023
52804a0
style changes
shac170 Dec 20, 2023
7bf584a
Remove duplicate MESH flags in constant.py
spasmann Dec 20, 2023
0672c30
Added point source support for non-repro dd
shac170 Dec 20, 2023
737f93b
Merge remote-tracking branch 'refs/remotes/origin/main'
shac170 Dec 20, 2023
7d84f17
style changes
shac170 Dec 20, 2023
7bed157
Fix ups for 2d problem and surface distance evaluation
shac170 Dec 20, 2023
a9ed5b5
fix for domain crossing event
shac170 Jan 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ pytestdebug.log
docs/build
docs/source/pythonapi/generated/

*.csv
Binary file added examples/eigenvalue/2d_c5g7/2d_c5g7_xs.h5
Binary file not shown.
Binary file removed examples/eigenvalue/2d_c5g7/c5g7.h5
Binary file not shown.
15 changes: 4 additions & 11 deletions examples/eigenvalue/2d_c5g7/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# =============================================================================

# Load material data
lib = h5py.File("c5g7.h5", "r")
lib = h5py.File("2d_c5g7_xs.h5", "r")


# Materials
Expand All @@ -17,22 +17,17 @@ def set_mat(mat):
capture=mat["capture"][:],
scatter=mat["scatter"][:],
fission=mat["fission"][:],
nu_p=mat["nu_p"][:],
nu_d=mat["nu_d"][:],
chi_p=mat["chi_p"][:],
chi_d=mat["chi_d"][:],
speed=mat["speed"],
decay=mat["decay"],
nu_p=mat["nu"][:],
chi_p=mat["chi"][:],
)


mat_uo2 = set_mat(lib["uo2"])
mat_mox43 = set_mat(lib["mox43"])
mat_mox7 = set_mat(lib["mox7"])
mat_mox7 = set_mat(lib["mox70"])
mat_mox87 = set_mat(lib["mox87"])
mat_gt = set_mat(lib["gt"])
mat_fc = set_mat(lib["fc"])
mat_cr = set_mat(lib["cr"])
mat_mod = set_mat(lib["mod"])

# =============================================================================
Expand All @@ -52,7 +47,6 @@ def set_mat(mat):
mox8 = mcdc.cell([-cy], mat_mox87)
gt = mcdc.cell([-cy], mat_gt)
fc = mcdc.cell([-cy], mat_fc)
cr = mcdc.cell([-cy], mat_cr)
mod = mcdc.cell([+cy], mat_mod)
modi = mcdc.cell([-cy], mat_mod) # For all-water lattice

Expand All @@ -63,7 +57,6 @@ def set_mat(mat):
n = mcdc.universe([mox8, mod])["ID"]
g = mcdc.universe([gt, mod])["ID"]
f = mcdc.universe([fc, mod])["ID"]
c = mcdc.universe([cr, mod])["ID"]
w = mcdc.universe([modi, mod])["ID"]

# =============================================================================
Expand Down
Binary file added examples/eigenvalue/2d_c5g7_iqmc/2d_c5g7_xs.h5
Binary file not shown.
37 changes: 14 additions & 23 deletions examples/eigenvalue/2d_c5g7_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# =============================================================================

# Load material data
lib = h5py.File("c5g7.h5", "r")
lib = h5py.File("2d_c5g7_xs.h5", "r")


# Materials
Expand All @@ -17,22 +17,17 @@ def set_mat(mat):
capture=mat["capture"][:],
scatter=mat["scatter"][:],
fission=mat["fission"][:],
nu_p=mat["nu_p"][:],
nu_d=mat["nu_d"][:],
chi_p=mat["chi_p"][:],
chi_d=mat["chi_d"][:],
speed=mat["speed"],
decay=mat["decay"],
nu_p=mat["nu"][:],
chi_p=mat["chi"][:],
)


mat_uo2 = set_mat(lib["uo2"])
mat_mox43 = set_mat(lib["mox43"])
mat_mox7 = set_mat(lib["mox7"])
mat_mox7 = set_mat(lib["mox70"])
mat_mox87 = set_mat(lib["mox87"])
mat_gt = set_mat(lib["gt"])
mat_fc = set_mat(lib["fc"])
mat_cr = set_mat(lib["cr"])
mat_mod = set_mat(lib["mod"])

# =============================================================================
Expand All @@ -52,7 +47,6 @@ def set_mat(mat):
mox8 = mcdc.cell([-cy], mat_mox87)
gt = mcdc.cell([-cy], mat_gt)
fc = mcdc.cell([-cy], mat_fc)
cr = mcdc.cell([-cy], mat_cr)
mod = mcdc.cell([+cy], mat_mod)
modi = mcdc.cell([-cy], mat_mod) # For all-water lattice

Expand All @@ -63,7 +57,6 @@ def set_mat(mat):
n = mcdc.universe([mox8, mod])["ID"]
g = mcdc.universe([gt, mod])["ID"]
f = mcdc.universe([fc, mod])["ID"]
c = mcdc.universe([cr, mod])["ID"]
w = mcdc.universe([modi, mod])["ID"]

# =============================================================================
Expand Down Expand Up @@ -171,29 +164,28 @@ def set_mat(mat):
# =============================================================================
# iQMC Parameters
# =============================================================================
N = 1e5
N = 1e4
maxit = 10
tol = 1e-3
pre_sweeps = 9
x_grid = np.linspace(0.0, pitch * 17 * 3, 17 * 3 * 2 + 1)
y_grid = np.linspace(-pitch * 17 * 3, 0.0, 17 * 3 * 2 + 1)
Nx = 17 * 3 * 2
Ny = 17 * 3 * 2
G = 7
x_grid = np.linspace(0.0, pitch * 17 * 3, Nx + 1)
y_grid = np.linspace(-pitch * 17 * 3, 0.0, Ny + 1)

generator = "halton"
solver = "davidson"

phi0 = np.zeros((x_grid.size - 1, y_grid.size - 1))
np.random.seed(123456)
phi0[: int(pitch * 17 * 2), int(-pitch * 17 * 2) :] = np.random.random((42, 42))
solver = "power_iteration"

phi0 = np.ones((G, Nx, Ny))
fixed_source = np.zeros_like(phi0)

mcdc.iQMC(
x=x_grid,
y=y_grid,
g=np.ones(G),
phi0=phi0,
fixed_source=fixed_source,
eigenmode_solver=solver,
preconditioner_sweeps=pre_sweeps,
maxitt=maxit,
tol=tol,
generator=generator,
Expand All @@ -203,9 +195,8 @@ def set_mat(mat):
# run mcdc
# =============================================================================


# Setting
mcdc.setting(N_particle=N, output_name="davidson_output")
mcdc.setting(N_particle=N)
mcdc.eigenmode()

# Run
Expand Down
4 changes: 2 additions & 2 deletions examples/eigenvalue/2d_c5g7_iqmc/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# =============================================================================

# Load iqmc result
with h5py.File("PI_output.h5", "r") as f:
with h5py.File("output.h5", "r") as f:
x = f["iqmc/grid/x"][:]
y = f["iqmc/grid/y"][:]
phi_avg = f["iqmc/flux"][:]
phi_avg = f["iqmc/tally/flux"][:]
f.close()


Expand Down
15 changes: 1 addition & 14 deletions examples/eigenvalue/slab_2gu_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
# "Analytical Benchmark Test Set For Criticality Code Verification"

# Set materials

# 1G-PU Slab data
# m1 = mcdc.material(
# capture=np.array([0.019584]),
# scatter=np.array([[0.225216]]),
# fission=np.array([0.081600]),
# nu_p=np.array([2.84]),
# chi_p=np.array([1.0]),
# )
# R = [0.0, 4.513502]

# 2G-U Slab data
m1 = mcdc.material(
capture=np.array([0.01344, 0.00384]),
Expand Down Expand Up @@ -48,9 +37,7 @@
generator = "halton"
solver = "davidson"
fixed_source = np.zeros((2, Nx))
np.random.seed(123456)
phi0 = np.random.random((2, Nx))
# phi0 = np.ones((2, Nx))
phi0 = np.ones((2, Nx))

# =============================================================================
# Set tally, setting, and run mcdc
Expand Down
7 changes: 4 additions & 3 deletions examples/eigenvalue/slab_kornreich_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
# =============================================================================
# iQMC Parameters
# =============================================================================
N = 1000
maxit = 10
N = 5000
maxit = 25
tol = 1e-3
x = np.arange(0.0, 2.6, 0.1)
Nx = len(x) - 1
generator = "halton"
solver = "davidson"
solver = "power_iteration"
fixed_source = np.zeros(Nx)
phi0 = np.ones((Nx))

Expand All @@ -57,6 +57,7 @@
tol=tol,
generator=generator,
eigenmode_solver=solver,
score=["tilt-x"],
)
# Setting
mcdc.setting(N_particle=N)
Expand Down
87 changes: 21 additions & 66 deletions examples/eigenvalue/slab_kornreich_iqmc/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
import h5py
import sys

# =============================================================================
# Import data
# =============================================================================

with h5py.File("output.h5", "r") as f:
# Note the spatial (dx) and source strength (100+1) normalization
keff = f["k_eff"][()]
phi_avg = f["iqmc/tally/flux"][:]
sweeps = f["iqmc/sweep_count"][()]
x = f["iqmc/grid/x"][:]
dx = x[1] - x[0]
x_mid = 0.5 * (x[:-1] + x[1:])
f.close()

tmp = 0.5 * (phi_avg[1:] + phi_avg[:-1])
norm = np.sum(tmp * dx)
phi_avg /= norm
print("Keff = ", keff)
print("Number of QMC Transport Sweeps = ", sweeps)

# =============================================================================
# Reference solution
# =============================================================================
Expand Down Expand Up @@ -69,72 +89,7 @@
plt.figure(dpi=300, figsize=(8, 5))
plt.plot(x_exact, phi_exact, label="sol")

# =============================================================================
# MCDC results
# =============================================================================
# Results
with h5py.File("mc_output.h5", "r") as f:
x = f["tally/grid/x"][:]
dx = x[1:] - x[:-1]
phi_avg = f["tally/flux-x/mean"][:]
phi_sd = f["tally/flux-x/sdev"][:]
k = f["k_cycle"][:]
k_avg = f["k_mean"][()]
k_sd = f["k_sdev"][()]
rg = f["gyration_radius"][:]
f.close()
# Note the spatial (dx) and source strength (100+1) normalization
tmp = 0.5 * (phi_avg[1:] + phi_avg[:-1])
norm = np.sum(tmp * dx)
phi_avg /= norm

print("MC Keff = ", k_avg)
plt.plot(x, phi_avg, label="MC")


# =============================================================================
# Power Iteration Results
# =============================================================================

with h5py.File("PI_output.h5", "r") as f:
# Note the spatial (dx) and source strength (100+1) normalization
keff = f["k_eff"][()]
phi_avg = f["tally/iqmc_flux"][:]
x = f["iqmc/grid/x"][:]
dx = x[1] - x[0]
x_mid = 0.5 * (x[:-1] + x[1:])
f.close()

tmp = 0.5 * (phi_avg[1:] + phi_avg[:-1])
norm = np.sum(tmp * dx)
phi_avg /= norm
print("PI Keff = ", keff)
plt.plot(x_mid, phi_avg, label="PI")

# =============================================================================
# Davidson Results
# =============================================================================

with h5py.File("davidson_output.h5", "r") as f:
# Note the spatial (dx) and source strength (100+1) normalization
keff = f["k_eff"][()]
phi_avg = f["tally/iqmc_flux"][:]
x = f["iqmc/grid/x"][:]
dx = x[1] - x[0]
x_mid = 0.5 * (x[:-1] + x[1:])
f.close()

tmp = 0.5 * (phi_avg[1:] + phi_avg[:-1])
norm = np.sum(tmp * dx)
phi_avg /= norm

print("davidson Keff = ", keff)
plt.plot(x_mid, phi_avg, label="davidson")


# =============================================================================
# Finish Plot
# =============================================================================
plt.plot(x_mid, phi_avg)
plt.title("Kornreich et al. Slab")
plt.ylabel(r"$\phi(x)$")
plt.xlabel(r"$x$")
Expand Down
9 changes: 6 additions & 3 deletions examples/fixed_source/cooper2_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
# =============================================================================
# iQMC Parameters
# =============================================================================
N = 1e1
N = 1e4
Nx = Ny = 40
maxit = 1
tol = 1e-3
maxit = 30
tol = 1e-6
x = np.linspace(0, 4, num=Nx + 1)
y = np.linspace(0, 4, num=Ny + 1)
generator = "halton"
solver = "gmres"

# fixed source in lower left corner
fixed_source = np.zeros((Nx, Ny))
Expand All @@ -55,6 +56,8 @@
maxitt=maxit,
tol=tol,
generator=generator,
fixed_source_solver=solver,
score=["tilt-x", "tilt-y"],
)

# =============================================================================
Expand Down
Loading
Loading