44from parareal import parareal
55from impeuler import impeuler
66from intexact import intexact
7+ from trapezoidal import trapezoidal
78from special_integrator import special_integrator
89from solution_linear import solution_linear
910import numpy as np
@@ -22,7 +23,7 @@ def solve_omega(R):
2223
2324def findroots (R , n ):
2425 assert abs (n - float (int (n )))< 1e-14 , "n must be an integer or a float equal to an integer"
25- p = np .zeros (n + 1 , dtype = 'complex' )
26+ p = np .zeros (int ( n ) + 1 , dtype = 'complex' )
2627 p [- 1 ] = - R
2728 p [0 ] = 1.0
2829 return np .roots (p )
@@ -60,8 +61,8 @@ def normalise(R, T, target):
6061 for i in range (0 ,np .size (k_vec )):
6162
6263 symb = - (1j * U_speed * k_vec [i ] + nu * k_vec [i ]** 2 )
63- symb_coarse = symb
64- # symb_coarse = -(1.0/dx)*(1.0 - np.exp(-1j*k_vec[i]*dx))
64+ # symb_coarse = symb
65+ symb_coarse = - (1.0 / dx )* (1.0 - np .exp (- 1j * k_vec [i ]* dx ))
6566
6667 # Solution objects define the problem
6768 u0 = solution_linear (u0_val , np .array ([[symb ]],dtype = 'complex' ))
@@ -94,24 +95,24 @@ def normalise(R, T, target):
9495 #
9596
9697 # for stab = r*exp(i*theta), r defines the amplitude factor and theta the phase speed
97- stab_tailor = abs (stab_coarse [0 ,0 ])* np .exp (1j * np .angle (stab_ex )) # exact phase speed
98+ # stab_tailor = abs(stab_coarse[0,0])*np.exp(1j*np.angle(stab_ex)) # exact phase speed
9899 # stab_tailor = abs(stab_ex)*np.exp(1j*np.angle(stab_coarse[0,0])) # exact amplification factor
99100
100101 # coarse method with exact phase but amplification factor corresponding to a single large backward Euler step
101- stab_coarse_limit = 1.0 / (1.0 - Tend * symb_coarse )
102- stab_tailor = abs (stab_coarse_limit )* np .exp (1j * np .angle (stab_ex )) # exact phase speed, massively diffusive amplification factor
102+ # stab_coarse_limit = 1.0/(1.0 - Tend*symb_coarse)
103+ # stab_tailor = abs(stab_coarse_limit)*np.exp(1j*np.angle(stab_ex)) # exact phase speed, massively diffusive amplification factor
103104
104105 # stab_tailor = abs(stab_ex)*np.exp(1j*np.angle(stab_ex)) ## for testing
105106 # stab_tailor = abs(stab_coarse[0,0])*np.exp(1j*np.angle(stab_coarse[0,0])) ## for testing
106107
107108 # Re-Create the parareal object to be used in the remainder
108- stab_tailor = sparse .csc_matrix (np .array ([stab_tailor ], dtype = 'complex' ))
109- para = parareal (0.0 , Tend , nslices , intexact , stab_tailor , nfine , ncoarse , 0.0 , niter_v [0 ], u0 )
109+ # stab_tailor = sparse.csc_matrix(np.array([stab_tailor], dtype='complex'))
110+ # para = parareal(0.0, Tend, nslices, intexact, stab_tailor, nfine, ncoarse, 0.0, niter_v[0], u0)
110111
111112 #################################################
112113
113114 # Compute Parareal phase velocity and amplification factor
114- # svds[0,i] = para.get_max_svd(ucoarse=ucoarse)
115+ svds [0 ,i ] = para .get_max_svd (ucoarse = ucoarse )
115116 for jj in range (0 ,3 ):
116117 stab_para = para .get_parareal_stab_function (k = niter_v [jj ], ucoarse = ucoarse )
117118
0 commit comments