11"""
22qmc_gmres(N=10^4, Nx=100, na2=11; s=1.0)
3+ Solves the linear system you get from QMC with GMRES.
34"""
45function qmc_gmres (N= 10 ^ 3 , Nx= 100 , na2= 11 ; s= 1.0 , tol= 1.e-10 )
56mdata= mdata_init (N, Nx, na2, s)
@@ -12,13 +13,21 @@ return gmout
1213end
1314
1415
16+ """
17+ tab_test(N=10^3, Nx=100, na2=11; s=1.0, tol=1.e-8)
18+ Makes a table to compare to Garcia-Siewert
19+ """
1520function tab_test (N= 10 ^ 3 , Nx= 100 , na2= 11 ; s= 1.0 , tol= 1.e-8 )
1621itout= qmc_gmres (N, Nx, na2; s= s, tol= tol)
1722qmctab= sn_tabulate (s, Nx, itout. sol; maketab= false , phiedge= false )
1823return [qmctab. left qmctab. right]
1924end
2025
2126
27+ """
28+ qmc_si(N=10^4, Nx=100, na2=11; s=1.0, tol=1.e-8, maxit=100)
29+ Source iteration using QMC. Nothing magic here.
30+ """
2231function qmc_si (N= 10 ^ 4 , Nx= 100 , na2= 11 ; s= 1.0 , tol= 1.e-8 , maxit= 100 )
2332qmc_data= qmc_init (N, Nx, na2, s)
2433phic= zeros (Nx,);
@@ -37,21 +46,40 @@ return ( sol=phic, history=reshist)
3746end
3847
3948
49+ """
50+ axb(phi,mdata)
51+ Matrix-vector product to feed to linear solvers.
52+ """
4053function axb (phi,mdata)
4154qmc_data= mdata. qmc_data;
4255frhs= mdata. frhs
4356matvec= Qlin (phi,qmc_data,frhs)
4457end
4558
59+ """
60+ Qlin(phi,qmc_data,frhs)
61+ Does a QMC transport sweep with flux phi, subtracts off the zero bc solution
62+ to obtain the linear integral operator. The subtract that from the identity.
63+ """
4664function Qlin (phi,qmc_data,frhs)
4765nullout= qmc_sweep (phi,qmc_data)
4866Mprod= phi- (nullout. phi_avg- frhs)
4967end
5068
69+
70+ """
71+ mdata_init(N, Nx, na2, s)
72+ Collects the precomputed data for QMC and does a sweep with
73+ zero boundary data to get the right hand side for the linear
74+ equation forumlation.
75+ """
5176function mdata_init (N, Nx, na2, s)
77+ # Precomputed data
5278qmc_data = qmc_init (N, Nx, na2, s);
79+ # Sweep with zero RHS
5380phizero= zeros (Nx,);
5481nullout= qmc_sweep (phizero,qmc_data);
5582frhs= nullout. phi_avg;
83+ #
5684mdata= (frhs= frhs, qmc_data = qmc_data)
5785end
0 commit comments