Skip to content

Commit 5bf9867

Browse files
author
Daniel Ruprecht
committed
number of coarse and fine steps now set at beginning of run.py; changed to ncoarse=2 which is the value that generates the figure in the paper
1 parent 4493ddb commit 5bf9867

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

example/run.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
#N = 100 # number grid points in time
7373
#dt = tmax/float(N)
7474
nproc = int(tmax)
75+
nfine = 10
76+
ncoarse = 2
77+
7578

7679
Kiter_v = [5, 10, 15]
7780

@@ -84,7 +87,7 @@
8487
# Initial data
8588
sig = 1.0
8689
u = 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)
8891
uhat0 = np.fft.fft(u)
8992

9093
yend = np.zeros((3,m), dtype='complex')
@@ -94,7 +97,7 @@
9497
### ...we use the JobLib module to speed up the computational
9598
def 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):
160165
plt.legend(loc='upper right', fontsize=fs, prop={'size':fs-2})
161166
filename = 'parareal-gauss-peak-spectrum.pdf'
162167
plt.gcf().savefig(filename, bbox_inches='tight')
163-
call(["pdfcrop", filename, filename])
168+
call(["pdfcrop", filename, filename])

0 commit comments

Comments
 (0)