Skip to content

Commit 668a920

Browse files
committed
New stuff for validation
1 parent 91dbe17 commit 668a920

12 files changed

+44
-22
lines changed

Siewert:s=1.dat

0 Bytes
Binary file not shown.

Siewert:s=Inf.dat

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
�_ĺ�?ݦ�'i�?�����?|�<�F�?0��
2-
q��?�&To65�?�������?T��*�?��d[��?xG�'�$�?r�����?x�D��)�? ���Ƕ�?�2�����?�Q�.���?#܉�;�?�ˌB&+�?��<�A�?6�5T�?l�b�?��`�l�?(��ʸ�?
1+
x�����?f�E'i�?'����?p?e F�?mT4&q��?,�y�65�?u��ą��?����*�?$�>u[��?�,�6�$�?B
2+
����?`�%b�)�?��k�Ŷ�?0&!?���?��7����?�Lg;�?�+��%+�?4$��A�?�ʟ�4T�?���*�b�?�i#$�l�?���ʸ�?

src/NDA_QMC.jl

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export ctk_qmc_test
2828
export qmc_vs_sn
2929
export makeqmctab
3030
export readdata
31+
export sn_validate
3132

3233
include("validate.jl")
3334
include("sn_angles.jl")

src/Siewert:s=1.dat

0 Bytes
Binary file not shown.

src/Siewert:s=Inf.dat

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
�_ĺ�?ݦ�'i�?�����?|�<�F�?0��
2-
q��?�&To65�?�������?T��*�?��d[��?xG�'�$�?r�����?x�D��)�? ���Ƕ�?�2�����?�Q�.���?#܉�;�?�ˌB&+�?��<�A�?6�5T�?l�b�?��`�l�?(��ʸ�?
1+
x�����?f�E'i�?'����?p?e F�?mT4&q��?,�y�65�?u��ą��?����*�?$�>u[��?�,�6�$�?B
2+
����?`�%b�)�?��k�Ŷ�?0&!?���?��7����?�Lg;�?�+��%+�?4$��A�?�ʟ�4T�?���*�b�?�i#$�l�?���ʸ�?

src/Tim_QMC/ctk_qmc_source_iteration.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#using LinearAlgebra
22
#include("qmc_sweep.jl")
33
"""
4-
qmc_source_iteration(s, qmc_data,tol=1.e-8)
4+
qmc_source_iteration(s, qmc_data,tol=1.e-4)
55
quasi-monte carlo source iteration example script for transport equation.
66
77
This is one of the test cases from

src/Tim_QMC/ctk_qmc_test.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include("ckt_qmc_init.jl")
33
#include("ctk_qmc_source_iteration.jl")
44

5-
function ctk_qmc_test(N=10^4, Nx=50, na2=11; s=1, plotme=false)
5+
function ctk_qmc_test(N=10^4, Nx=50, na2=11; s=1, plotme=false, tol=1.e-4)
66

77
###############################################################################
88
#### Inputs
@@ -19,7 +19,7 @@ function ctk_qmc_test(N=10^4, Nx=50, na2=11; s=1, plotme=false)
1919
# initialize qmc
2020
qmc_data = qmc_init(N, Nx, na2, s)
2121
# call qmc SI
22-
phi_avg, phi_edge, J_avg, J_edge, psi_right, psi_left, history, itt = qmc_source_iteration(s,qmc_data)
22+
phi_avg, phi_edge, J_avg, J_edge, psi_right, psi_left, history, itt = qmc_source_iteration(s,qmc_data,tol)
2323
#
2424
if plotme
2525
plotqmd(phi_avg, phi_edge, J_avg, J_edge,

src/siewert.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ siewert(s=1.0)
33
44
Gets the Garcia-Siewert tabular data and parks it where it's easy to find.
55
"""
6-
function siewert(s=1.0; filedump=false)
7-
na2 = 20
8-
nx = 2001
6+
function siewert(s=1.0; filedump=false, na2=80, nx=16001)
7+
# na2 = 20; nx = 2001;
8+
# na2 = 80; nx = 16001;
99
#
1010
# precomputed data
1111
#
@@ -15,7 +15,7 @@ function siewert(s=1.0; filedump=false)
1515
#
1616
gout=gmres_iteration(sn_data,s)
1717
fgm = gout.sol
18-
tabout=sn_tabulate(s, nx, fgm; maketab=false)
18+
tabout=sn_tabulate(s, nx, fgm; maketab=false, phiedge=true)
1919
Dout=[tabout.left tabout.right]
2020
if filedump
2121
s == 1.0 ? sstr=string(1) : sstr="Inf"

src/sn_init.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
sn_init(nx, na2, s)
2+
sn_init(nx, na2, s; siewert=false, phiedge=true)
33
44
I pass a named tuple of precomputed and preallocated data to
55
all the functions and solvers.
@@ -15,7 +15,7 @@ s = parameter in Garcia/Siewert
1515
1616
angles, weights = nodes and weights for the angular quadrature
1717
"""
18-
function sn_init(nx, na2, s; siewert=false)
18+
function sn_init(nx, na2, s; siewert=false, phiedge=true)
1919
if siewert
2020
angles = [-.05; collect(-.1:-.1:-1.0); 0.05; collect(0.1:0.1:1.0)]
2121
weights = angles
@@ -31,7 +31,8 @@ function sn_init(nx, na2, s; siewert=false)
3131
psi_left = ones(na)
3232
source = zeros(nx)
3333
ptmp = zeros(na)
34-
psi = zeros(na2, nx)
34+
phiedge ? np=nx : np=nx+1
35+
psi = zeros(na2, np)
3536
return sn_data = (
3637
c = c,
3738
dx = dx,

src/sn_tabulate.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function sn_tabulate(s, nx, flux; maketab=true, phiedge=true)
1313
#
1414
na2 = length(angleout)
1515
na = floor(Int, na2 / 2)
16-
sn_data = sn_init(nx, na2, s; siewert=true)
16+
sn_data = sn_init(nx, na2, s; siewert=true, phiedge=phiedge)
1717
psi = sn_data.psi
1818
psi = transport_sweep!(psi, flux, sn_data; phiedge=phiedge)
1919
if maketab

src/transport_sweep.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ function transport_sweep!(psi, phi, sn_data; phiedge=true)
1717
na2 = length(angles)
1818
na = floor(Int, na2 / 2)
1919
nx = length(phi)
20+
phiedge ? np=nx : np=nx+1
2021
#
2122
# Initialize the angular flux and set the boundary conditions.
2223
#
2324
psi *= 0.0
24-
@views psi[1:na, nx] = psi_right
25+
@views psi[1:na, np] = psi_right
2526
@views psi[na+1:na2, 1] = psi_left
2627
#
2728
#
@@ -41,7 +42,7 @@ function transport_sweep!(psi, phi, sn_data; phiedge=true)
4142
#
4243
# Forward sweep
4344
#
44-
@views for ix = 2:nx
45+
@views for ix = 2:np
4546
copy!(psi[na+1:na2, ix], psi[na+1:na2, ix-1])
4647
psi[na+1:na2, ix] .*= vfr
4748
psi[na+1:na2, ix] .+= source_average[ix-1]
@@ -50,7 +51,7 @@ function transport_sweep!(psi, phi, sn_data; phiedge=true)
5051
#
5152
# Backward sweep
5253
#
53-
@views for ix = nx-1:-1:1
54+
@views for ix = np-1:-1:1
5455
copy!(psi[1:na, ix], psi[1:na, ix+1])
5556
psi[1:na, ix] .*= vfr
5657
psi[1:na, ix] .+= source_average[ix]

src/validate.jl

+23-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
This makes the table in the notebook showing the errors in QMC as a
33
function of Nx and N
44
5-
qmc_vs_sn(levels=6, Nrange=4; s=1.0)
5+
qmc_vs_sn(levels=6, Nrange=3; s=1.0)
66
"""
7-
function qmc_vs_sn(levels=6, Nrange=4; s=1.0)
7+
function qmc_vs_sn(levels=6, Nrange=3; s=1.0)
88
NVals=zeros(Int64,Nrange)
9-
NVals[1]=1000
9+
NVals[1]=2000
1010
for i=2:Nrange
1111
NVals[i]=2*NVals[i-1]
1212
end
@@ -25,6 +25,23 @@ makeqmctab(Dcomp,NVals,NxVals)
2525
return Dcomp
2626
end
2727

28+
function sn_validate(Nrange=3; s=1.0)
29+
NVals=zeros(Int64,Nrange)
30+
NVals[1]=100
31+
for i=2:Nrange
32+
NVals[i]=2*NVals[i-1]
33+
end
34+
Dcomp=zeros(Nrange);
35+
#
36+
DataGS=readdata(s)
37+
for idv=1:Nrange
38+
Dval=siewert(s; nx=NVals[idv], na2=80)
39+
Dcomp[idv]=norm(Dval-DataGS,Inf)
40+
end
41+
return Dcomp
42+
end
43+
44+
2845
function makeqmctab(Dcomp,NVals,NxVals)
2946
printf(fmt::String, args...) = @eval @printf($fmt, $(args...))
3047
levels=length(NxVals)
@@ -49,9 +66,11 @@ function validate(N, levels, DataGS, s=1.0)
4966
Nx = 50
5067
Diffs=zeros(levels,)
5168
for il=0:levels-1
52-
DataQMC=ctk_qmc_test(N, Nx; s=s, plotme=false)
69+
DataQMC=ctk_qmc_test(N, Nx; s=s, plotme=false, tol=1.e-4)
5370
EDiff=(DataGS-DataQMC)./DataGS;
5471
Diffs[il+1]=norm(EDiff,Inf);
72+
#EDiff=(DataGS-DataQMC)
73+
#Diffs[il+1]=norm(EDiff)/norm(DataGS)
5574
Nx *= 2
5675
end
5776
return Diffs

0 commit comments

Comments
 (0)