7272#N = 100 # number grid points in time
7373#dt = tmax/float(N)
7474nproc = int (tmax )
75+ nfine = 10
76+ ncoarse = 2
77+
7578
7679Kiter_v = [5 , 10 , 15 ]
7780
8487# Initial data
8588sig = 1.0
8689u = np .exp (- (x - 0.5 * L )** 2 / sig ** 2 )
87- u = np .exp (2.0 * np .pi * 1j * x )
90+ # u = np.exp(2.0*np.pi*1j*x)
8891uhat0 = np .fft .fft (u )
8992
9093yend = np .zeros ((3 ,m ), dtype = 'complex' )
9497### ...we use the JobLib module to speed up the computational
9598def run_parareal (uhat , D , k ):
9699 sol = solution_linear (np .asarray ([[uhat ]]), np .asarray ([[D ]]))
97- para = parareal (tstart = 0.0 , tend = tmax , nslices = nproc , fine = intexact , coarse = impeuler , nsteps_fine = 10 , nsteps_coarse = 1 , tolerance = 0.0 , iter_max = k , u0 = sol )
100+ para = parareal (tstart = 0.0 , tend = tmax , nslices = nproc , fine = intexact , coarse = impeuler , nsteps_fine = nfine , nsteps_coarse = ncoarse , tolerance = 0.0 , iter_max = k , u0 = sol )
98101 stab_coarse = para .timemesh .slices [0 ].get_coarse_update_matrix (sol )
99102 stab_ex = np .exp (D )
100103
@@ -103,16 +106,18 @@ def run_parareal(uhat, D, k):
103106 elif artificial_coarse == 1 :
104107 stab_tailor = abs (stab_ex )* np .exp (1j * np .angle (stab_coarse [0 ,0 ])) # exact amplification factor
105108
109+ # If some artificial propagator is used, need to re-compute Parareal stability matrix with newly designed
110+ # stability matrix
106111 if not artificial_coarse == 0 :
107112 stab_tailor = sp .csc_matrix (np .array ([stab_tailor ], dtype = 'complex' ))
108- para = parareal (tstart = 0.0 , tend = tmax , nslices = nproc , fine = intexact , coarse = stab_tailor , nsteps_fine = 10 , nsteps_coarse = 1 , tolerance = 0.0 , iter_max = k , u0 = sol )
113+ para = parareal (tstart = 0.0 , tend = tmax , nslices = nproc , fine = intexact , coarse = stab_tailor , nsteps_fine = nfine , nsteps_coarse = ncoarse , tolerance = 0.0 , iter_max = k , u0 = sol )
109114
110115 if artificial_fine == 1 :
111116 assert artificial_coarse == 0 , "Using artifical coarse and fine propagators together is not implemented and probably not working correctly"
112117 stab_fine = abs (stab_ex )* np .exp (1j * np .angle (stab_coarse [0 ,0 ]))
113118 stab_fine = sp .csc_matrix (np .array ([stab_fine ], dtype = 'complex' ))
114119 # Must use nfine=1 in this case
115- para = parareal (tstart = 0.0 , tend = tmax , nslices = nproc , fine = stab_fine , coarse = impeuler , nsteps_fine = 1 , nsteps_coarse = 1 , tolerance = 0.0 , iter_max = k , u0 = sol )
120+ para = parareal (tstart = 0.0 , tend = tmax , nslices = nproc , fine = stab_fine , coarse = impeuler , nsteps_fine = nfine , nsteps_coarse = ncoarse , tolerance = 0.0 , iter_max = k , u0 = sol )
116121
117122 para .run ()
118123 temp = para .get_last_end_value ()
@@ -160,4 +165,4 @@ def run_parareal(uhat, D, k):
160165plt .legend (loc = 'upper right' , fontsize = fs , prop = {'size' :fs - 2 })
161166filename = 'parareal-gauss-peak-spectrum.pdf'
162167plt .gcf ().savefig (filename , bbox_inches = 'tight' )
163- call (["pdfcrop" , filename , filename ])
168+ call (["pdfcrop" , filename , filename ])
0 commit comments