@@ -43,7 +43,7 @@ def trap(z):
4343Tend , nslices , maxiter , nfine , ncoarse , tol , epsilon , ndof_f = par .getpar ()
4444
4545nsteps = [1 , 2 , 4 , 8 , 12 , 16 , 20 ]
46- nsteps = [1 , 10 , 25 , 50 , 75 , 100 ]
46+ # nsteps = [10, 100, 1000, 10000, 100000 ]
4747
4848ndof_c_v = [16 , 24 , 30 ]
4949xaxis_f = np .linspace (0.0 , 1.0 , ndof_f + 1 )[0 :ndof_f ]
@@ -52,6 +52,8 @@ def trap(z):
5252if figure == 5 :
5353 A_f = get_upwind (ndof_f , dx_f )
5454 u0fine = solution_linear (np .zeros (ndof_f ), A_f )
55+ D = A_f * A_f .H - A_f .H * A_f
56+ print ("Normality number of the system matrix (this should be zero): %5.3f" % np .linalg .norm (D .todense ()))
5557elif figure == 6 or figure == 7 :
5658 A_f = get_centered (ndof_f , dx_f )
5759 u0fine = solution_linear (np .zeros (ndof_f ), A_f )
@@ -78,15 +80,15 @@ def trap(z):
7880 if figure == 5 :
7981 A_c = get_upwind (ndof_c , dx_c )
8082 u0coarse = solution_linear (np .zeros (ndof_c ), A_c )
81- filename = 'figure_5 .pdf'
83+ filename = 'figure_5_mod .pdf'
8284 elif figure == 6 :
8385 A_c = get_centered (ndof_c , dx_c )
8486 u0coarse = solution_linear (np .zeros (ndof_c ), A_c )
85- filename = 'figure_6 .pdf'
87+ filename = 'figure_6_mod .pdf'
8688 elif figure == 7 :
8789 A_c = get_centered (ndof_c , dx_c )
8890 u0coarse = solution_linear (np .zeros (ndof_c ), A_c )
89- filename = 'figure_7 .pdf'
91+ filename = 'figure_7_mod .pdf'
9092 elif figure == 8 :
9193 u0coarse = solution_dedalus (np .zeros (ndof_c ), ndof_c )
9294 filename = 'figure_8.pdf'
@@ -109,24 +111,21 @@ def trap(z):
109111 Pmat , Bmat = para .get_parareal_matrix ()
110112 dt_f_v [0 ,mm ] = para .timemesh .slices [0 ].int_fine .dt
111113 dt_c_v [0 ,mm ] = para .timemesh .slices [0 ].int_coarse .dt
112-
113114 # Sort according to absolute values of R(z) with z = lambda*dt_f
114115 sort_index = np .argsort (np .abs (Rz (eig_val * dt_f_v [0 ,mm ])))
115116
116117 # Store eigenvalue ndof_c+1. first "truncated" EV
117- A_f_eig [nn ,mm ] = np .flip ((eig_val [sort_index ]))[ndof_c + 1 ]
118-
118+ A_f_eig [nn ,mm ] = np .flip ((eig_val [sort_index ]))[ndof_c ]
119119 ### Parareal iteration: y^k+1 = Pmat*y^k + Bmat*b
120120 norm_l2 [nn ,mm ] = np .linalg .norm (Pmat .todense (), 2 )
121-
122121
123122rcParams ['figure.figsize' ] = 2.5 , 2.5
124123fs = 8
125124ms = 4
126125fig = plt .figure (1 )
127- plt .loglog (dt_f_v [0 ,:], norm_l2 [0 ,:]- np .abs (np .exp (np .multiply (A_f_eig [0 ,:],dt_f_v [0 ,:]))), 'bo-' , label = 'm=' + str (ndof_c_v [0 ]), markersize = ms )
128- plt .loglog (dt_f_v [0 ,:], norm_l2 [1 ,:]- np .abs (np .exp (np .multiply (A_f_eig [1 ,:],dt_f_v [0 ,:]))), 'rx-' , label = 'm=' + str (ndof_c_v [1 ]), markersize = ms )
129- plt .loglog (dt_f_v [0 ,:], norm_l2 [2 ,:]- np .abs (np .exp (np .multiply (A_f_eig [2 ,:],dt_f_v [0 ,:]))), 'cd-' , label = 'm=' + str (ndof_c_v [2 ]), markersize = ms )
126+ plt .loglog (dt_f_v [0 ,:], norm_l2 [0 ,:]- np .abs (np .exp (np .multiply (A_f_eig [0 ,:],np . multiply ( dt_f_v [0 ,:], nsteps [:]) ))), 'bo-' , label = 'm=' + str (ndof_c_v [0 ]), markersize = ms )
127+ plt .loglog (dt_f_v [0 ,:], norm_l2 [1 ,:]- np .abs (np .exp (np .multiply (A_f_eig [1 ,:],np . multiply ( dt_f_v [0 ,:], nsteps [:]) ))), 'rx-' , label = 'm=' + str (ndof_c_v [1 ]), markersize = ms )
128+ plt .loglog (dt_f_v [0 ,:], norm_l2 [2 ,:]- np .abs (np .exp (np .multiply (A_f_eig [2 ,:],np . multiply ( dt_f_v [0 ,:], nsteps [:]) ))), 'cd-' , label = 'm=' + str (ndof_c_v [2 ]), markersize = ms )
130129plt .legend (loc = 'best' , bbox_to_anchor = (0.5 , 0.5 ), fontsize = fs , prop = {'size' :fs - 2 }, handlelength = 3 )
131130plt .xlabel (r'$\delta t = \Delta t$' , fontsize = fs )
132131plt .ylabel (r'$|| \mathbf{E} ||_2 - | \exp(\lambda_{m+1} \delta t) |$' , fontsize = fs )
0 commit comments