Skip to content

Commit

Permalink
back in black
Browse files Browse the repository at this point in the history
  • Loading branch information
ilhamv committed Jul 17, 2024
1 parent 459d3aa commit 063ee6a
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 82 deletions.
4 changes: 2 additions & 2 deletions test/verification/analytic/azurv1/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
# Flux - average
fig = plt.figure()
ax = plt.axes(
xlim=(-2,2),#(-21.889999999999997, 21.89),
ylim=(-0.042992644459595206, 2)#0.9028455336514992)
xlim=(-2, 2), # (-21.889999999999997, 21.89),
ylim=(-0.042992644459595206, 2), # 0.9028455336514992)
)
ax.grid()
ax.set_xlabel(r"$x$")
Expand Down
17 changes: 11 additions & 6 deletions test/verification/analytic/azurv1_gaussianIC/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@
# Set source
# =============================================================================
# Isotropic pulse at x=t=0
x = np.linspace(-15,15,int(1e4))
gaussian = np.exp(-4*x**2)
dx = x[2]-x[1]
edges_x = np.append(x-dx/2,x[-1]+dx/2)
for ii, (x1,x2) in enumerate(zip(edges_x[:-1],edges_x[1:])):
mcdc.source(x=[x1,x2],prob=gaussian[ii]*0.8862269254527580136490837416705725913987747280611935641069038949,time=[1e-10, 1e-10])
x = np.linspace(-15, 15, int(1e4))
gaussian = np.exp(-4 * x**2)
dx = x[2] - x[1]
edges_x = np.append(x - dx / 2, x[-1] + dx / 2)
for ii, (x1, x2) in enumerate(zip(edges_x[:-1], edges_x[1:])):
mcdc.source(
x=[x1, x2],
prob=gaussian[ii]
* 0.8862269254527580136490837416705725913987747280611935641069038949,
time=[1e-10, 1e-10],
)


# =============================================================================
Expand Down
21 changes: 12 additions & 9 deletions test/verification/analytic/azurv1_gaussianIC/makereference.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import numpy as np
import h5py
import scipy
x = np.linspace(-20.5,20.5,202)
t = np.linspace(.5,19.5,20)
phi = np.empty((10001,201))
tavg = np.linspace(0,20,10001)
with h5py.File("../benchmarks.hdf5",'r') as f:

x = np.linspace(-20.5, 20.5, 202)
t = np.linspace(0.5, 19.5, 20)
phi = np.empty((10001, 201))
tavg = np.linspace(0, 20, 10001)
with h5py.File("../benchmarks.hdf5", "r") as f:
for i in range(10001):
key = 'gaussian_IC/t = '+str(tavg[i])+'x0=0.5'
phi[i,:] = f[key][1,:]
phiavg = np.empty((20,201))
key = "gaussian_IC/t = " + str(tavg[i]) + "x0=0.5"
phi[i, :] = f[key][1, :]
phiavg = np.empty((20, 201))
for i in range(20):
for j in range(201):
phiavg[i,j] = scipy.integrate.simpson(y = phi[(500*i):(500*i+500),j],x = tavg[(500*i):(500+500*i)])
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(500 * i) : (500 * i + 500), j], x=tavg[(500 * i) : (500 + 500 * i)]
)
np.savez("reference.npz", x=x, t=t, phi=phiavg)
5 changes: 4 additions & 1 deletion test/verification/analytic/azurv1_gaussianIC/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
dt = t[1:] - t[:-1]
K = len(t) - 1

phi = f["tally/flux/mean"][:]*0.8862269254527580136490837416705725913987747280611935641069038949
phi = (
f["tally/flux/mean"][:]
* 0.8862269254527580136490837416705725913987747280611935641069038949
)
phi_sd = f["tally/flux/sdev"][:]

# Normalize
Expand Down
5 changes: 4 additions & 1 deletion test/verification/analytic/azurv1_gaussianIC/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
dt = t[1:] - t[:-1]
K = len(t) - 1

phi = f["tally/flux/mean"][:]*0.8862269254527580136490837416705725913987747280611935641069038949
phi = (
f["tally/flux/mean"][:]
* 0.8862269254527580136490837416705725913987747280611935641069038949
)

# Normalize
for k in range(K):
Expand Down
17 changes: 11 additions & 6 deletions test/verification/analytic/azurv1_gaussiansource/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@
# Set source
# =============================================================================
# Isotropic pulse at x=t=0
x = np.linspace(-15,15,int(1e4))
gaussian = np.exp(-4*x**2)
dx = x[2]-x[1]
edges_x = np.append(x-dx/2,x[-1]+dx/2)
for ii, (x1,x2) in enumerate(zip(edges_x[:-1],edges_x[1:])):
mcdc.source(x=[x1,x2],prob=gaussian[ii]*0.8862269254527580136490837416705725913987747280611935641069038949,time=[1e-10, 5])
x = np.linspace(-15, 15, int(1e4))
gaussian = np.exp(-4 * x**2)
dx = x[2] - x[1]
edges_x = np.append(x - dx / 2, x[-1] + dx / 2)
for ii, (x1, x2) in enumerate(zip(edges_x[:-1], edges_x[1:])):
mcdc.source(
x=[x1, x2],
prob=gaussian[ii]
* 0.8862269254527580136490837416705725913987747280611935641069038949,
time=[1e-10, 5],
)


# =============================================================================
Expand Down
21 changes: 12 additions & 9 deletions test/verification/analytic/azurv1_gaussiansource/makereference.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import numpy as np
import h5py
import scipy
x = np.linspace(-20.5,20.5,202)
t = np.linspace(.5,19.5,20)
phi = np.empty((10001,201))
tavg = np.linspace(0,20,10001)
with h5py.File("../benchmarks.hdf5",'r') as f:

x = np.linspace(-20.5, 20.5, 202)
t = np.linspace(0.5, 19.5, 20)
phi = np.empty((10001, 201))
tavg = np.linspace(0, 20, 10001)
with h5py.File("../benchmarks.hdf5", "r") as f:
for i in range(10001):
key = 'gaussian_source/t = '+str(tavg[i])+'x0=0.5'
phi[i,:] = f[key][1,:]
phiavg = np.empty((20,201))
key = "gaussian_source/t = " + str(tavg[i]) + "x0=0.5"
phi[i, :] = f[key][1, :]
phiavg = np.empty((20, 201))
for i in range(20):
for j in range(201):
phiavg[i,j] = scipy.integrate.simpson(y = phi[(500*i):(500*i+500),j],x = tavg[(500*i):(500+500*i)])
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(500 * i) : (500 * i + 500), j], x=tavg[(500 * i) : (500 + 500 * i)]
)
np.savez("reference.npz", x=x, t=t, phi=phiavg)
6 changes: 5 additions & 1 deletion test/verification/analytic/azurv1_gaussiansource/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
dt = t[1:] - t[:-1]
K = len(t) - 1

phi = f["tally/flux/mean"][:]*5*0.8862269254527580136490837416705725913987747280611935641069038949
phi = (
f["tally/flux/mean"][:]
* 5
* 0.8862269254527580136490837416705725913987747280611935641069038949
)
phi_sd = f["tally/flux/sdev"][:]

# Normalize
Expand Down
6 changes: 5 additions & 1 deletion test/verification/analytic/azurv1_gaussiansource/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
dt = t[1:] - t[:-1]
K = len(t) - 1

phi = f["tally/flux/mean"][:]*5*0.8862269254527580136490837416705725913987747280611935641069038949
phi = (
f["tally/flux/mean"][:]
* 5
* 0.8862269254527580136490837416705725913987747280611935641069038949
)

# Normalize
for k in range(K):
Expand Down
34 changes: 22 additions & 12 deletions test/verification/analytic/azurv1_planeIC/makereference.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import numpy as np
import h5py
import scipy
x = np.linspace(-20.5,20.5,202)
t = np.linspace(.5,19.5,20)
phi = np.empty((100001,201))
tavg = np.linspace(0,20,100001)
with h5py.File("../benchmarks.hdf5",'r') as f:

x = np.linspace(-20.5, 20.5, 202)
t = np.linspace(0.5, 19.5, 20)
phi = np.empty((100001, 201))
tavg = np.linspace(0, 20, 100001)
with h5py.File("../benchmarks.hdf5", "r") as f:
for i in range(100001):
key = 'plane_IC/t = '+str(tavg[i])
phi[i,:] = f[key][1,:]
phiavg = np.empty((20,201))
key = "plane_IC/t = " + str(tavg[i])
phi[i, :] = f[key][1, :]
phiavg = np.empty((20, 201))
for i in range(20):
for j in range(201):
if i == 0:
if np.fabs(x[j])-.25<0:
phiavg[i,j] = scipy.integrate.simpson(y = phi[(5000*i+200):(5000*i+5000),j],x = tavg[(5000*i+200):(5000+5000*i)])
if np.fabs(x[j]) - 0.25 < 0:
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(5000 * i + 200) : (5000 * i + 5000), j],
x=tavg[(5000 * i + 200) : (5000 + 5000 * i)],
)
else:
phiavg[i,j] = scipy.integrate.simpson(y = phi[(5000*i):(5000*i+5000),j],x = tavg[(5000*i):(5000+5000*i)])
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(5000 * i) : (5000 * i + 5000), j],
x=tavg[(5000 * i) : (5000 + 5000 * i)],
)
else:
phiavg[i,j] = scipy.integrate.simpson(y = phi[(5000*i):(5000*i+5000),j],x = tavg[(5000*i):(5000+5000*i)])
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(5000 * i) : (5000 * i + 5000), j],
x=tavg[(5000 * i) : (5000 + 5000 * i)],
)
np.savez("reference.npz", x=x, t=t, phi=phiavg)
5 changes: 2 additions & 3 deletions test/verification/analytic/azurv1_planeIC/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
# Flux - average
fig = plt.figure()
ax = plt.axes(
xlim=(-21.889999999999997, 21.89),
ylim=(-0.042992644459595206, 0.9028455336514992)
xlim=(-21.889999999999997, 21.89), ylim=(-0.042992644459595206, 0.9028455336514992)
)
ax.grid()
ax.set_xlabel(r"$x$")
Expand All @@ -45,7 +44,7 @@


def animate(k):

global fb
fb.remove()
line1.set_data(x_mid, phi[k, :])
Expand Down
2 changes: 1 addition & 1 deletion test/verification/analytic/azurv1_squareIC/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# =============================================================================
# Isotropic pulse at x=t=0

mcdc.source(x=[-.5,.5], isotropic=True, time=[1e-10, 1e-10])
mcdc.source(x=[-0.5, 0.5], isotropic=True, time=[1e-10, 1e-10])

# =============================================================================
# Set tally, setting, and run mcdc
Expand Down
34 changes: 22 additions & 12 deletions test/verification/analytic/azurv1_squareIC/makereference.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import numpy as np
import h5py
import scipy
x = np.linspace(-20.5,20.5,202)
t = np.linspace(.5,19.5,20)
phi = np.empty((100001,201))
tavg = np.linspace(0,20,100001)
with h5py.File("../benchmarks.hdf5",'r') as f:

x = np.linspace(-20.5, 20.5, 202)
t = np.linspace(0.5, 19.5, 20)
phi = np.empty((100001, 201))
tavg = np.linspace(0, 20, 100001)
with h5py.File("../benchmarks.hdf5", "r") as f:
for i in range(100001):
key = 'square_IC/t = '+str(tavg[i])+'x0=0.5'
phi[i,:] = f[key][1,:]
phiavg = np.empty((20,201))
key = "square_IC/t = " + str(tavg[i]) + "x0=0.5"
phi[i, :] = f[key][1, :]
phiavg = np.empty((20, 201))
for i in range(20):
for j in range(201):
if i == 0:
if np.fabs(x[j])-.25<0:
phiavg[i,j] = scipy.integrate.simpson(y = phi[(5000*i):(5000*i+5000),j],x = tavg[(5000*i):(5000+5000*i)])
if np.fabs(x[j]) - 0.25 < 0:
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(5000 * i) : (5000 * i + 5000), j],
x=tavg[(5000 * i) : (5000 + 5000 * i)],
)
else:
phiavg[i,j] = scipy.integrate.simpson(y = phi[(5000*i):(5000*i+5000),j],x = tavg[(5000*i):(5000+5000*i)])
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(5000 * i) : (5000 * i + 5000), j],
x=tavg[(5000 * i) : (5000 + 5000 * i)],
)
else:
phiavg[i,j] = scipy.integrate.simpson(y = phi[(5000*i):(5000*i+5000),j],x = tavg[(5000*i):(5000+5000*i)])
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(5000 * i) : (5000 * i + 5000), j],
x=tavg[(5000 * i) : (5000 + 5000 * i)],
)
np.savez("reference.npz", x=x, t=t, phi=phiavg)
2 changes: 1 addition & 1 deletion test/verification/analytic/azurv1_squaresource/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# =============================================================================
# Isotropic pulse at x=t=0

mcdc.source(x=[-.5,.5], isotropic=True, time=[1e-10, 5])
mcdc.source(x=[-0.5, 0.5], isotropic=True, time=[1e-10, 5])

# =============================================================================
# Set tally, setting, and run mcdc
Expand Down
21 changes: 12 additions & 9 deletions test/verification/analytic/azurv1_squaresource/makereference.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import numpy as np
import h5py
import scipy
x = np.linspace(-20.5,20.5,202)
t = np.linspace(.5,19.5,20)
phi = np.empty((10001,201))
tavg = np.linspace(0,20,10001)
with h5py.File("../benchmarks.hdf5",'r') as f:

x = np.linspace(-20.5, 20.5, 202)
t = np.linspace(0.5, 19.5, 20)
phi = np.empty((10001, 201))
tavg = np.linspace(0, 20, 10001)
with h5py.File("../benchmarks.hdf5", "r") as f:
for i in range(10001):
key = 'square_source/t = '+str(tavg[i])+'x0=0.5'
phi[i,:] = f[key][1,:]
phiavg = np.empty((20,201))
key = "square_source/t = " + str(tavg[i]) + "x0=0.5"
phi[i, :] = f[key][1, :]
phiavg = np.empty((20, 201))
for i in range(20):
for j in range(201):
phiavg[i,j] = scipy.integrate.simpson(y = phi[(500*i):(500*i+500),j],x = tavg[(500*i):(500+500*i)])
phiavg[i, j] = scipy.integrate.simpson(
y=phi[(500 * i) : (500 * i + 500), j], x=tavg[(500 * i) : (500 + 500 * i)]
)
np.savez("reference.npz", x=x, t=t, phi=phiavg)
2 changes: 1 addition & 1 deletion test/verification/analytic/azurv1_squaresource/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
dt = t[1:] - t[:-1]
K = len(t) - 1

phi = f["tally/flux/mean"][:]*5
phi = f["tally/flux/mean"][:] * 5
phi_sd = f["tally/flux/sdev"][:]

# Normalize
Expand Down
2 changes: 1 addition & 1 deletion test/verification/analytic/azurv1_squaresource/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
dt = t[1:] - t[:-1]
K = len(t) - 1

phi = f["tally/flux/mean"][:]*5
phi = f["tally/flux/mean"][:] * 5

# Normalize
for k in range(K):
Expand Down
12 changes: 6 additions & 6 deletions test/verification/analytic/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
# Azurv1 variants
# Plane IC
task["azurv1_planeIC"] = {}
task["azurv1_planeIC"]["N_lim"] = [3,6]
task["azurv1_planeIC"]["N_lim"] = [3, 6]
task["azurv1_planeIC"]["N"] = 9

# Square IC
task["azurv1_squareIC"] = {}
task["azurv1_squareIC"]["N_lim"] = [3,6]
task["azurv1_squareIC"]["N_lim"] = [3, 6]
task["azurv1_squareIC"]["N"] = 9

# Square Source
task["azurv1_squaresource"] = {}
task["azurv1_squaresource"]["N_lim"] = [3,6]
task["azurv1_squaresource"]["N_lim"] = [3, 6]
task["azurv1_squaresource"]["N"] = 9

# Gaussian IC
task["azurv1_gaussianIC"] = {}
task["azurv1_gaussianIC"]["N_lim"] = [3,6]
task["azurv1_gaussianIC"]["N_lim"] = [3, 6]
task["azurv1_gaussianIC"]["N"] = 9

# Gaussian Source
task["azurv1_gaussiansource"] = {}
task["azurv1_gaussiansource"]["N_lim"] = [3,7]
task["azurv1_gaussiansource"]["N"] = 7
task["azurv1_gaussiansource"]["N_lim"] = [3, 7]
task["azurv1_gaussiansource"]["N"] = 7

0 comments on commit 063ee6a

Please sign in to comment.