|
28 | 28 |
|
29 | 29 | sparams = {} |
30 | 30 |
|
31 | | - |
32 | 31 | # This comes as read-in for the problem class |
33 | 32 | pparams = {} |
34 | | - pparams['nvars'] = [(2,300)] |
35 | 33 | pparams['cadv'] = 0.1 |
36 | 34 | pparams['cs'] = 1.00 |
37 | 35 | pparams['order_adv'] = 5 |
38 | | - pparams['waveno'] = 5 |
| 36 | + pparams['waveno'] = 0 |
39 | 37 |
|
40 | 38 | # Fill description dictionary for easy hierarchy creation |
41 | 39 | description = {} |
42 | 40 | description['problem_class'] = acoustic_1d_imex |
43 | 41 | description['problem_params'] = pparams |
44 | 42 | description['dtype_u'] = mesh |
45 | 43 | description['dtype_f'] = rhs_imex_mesh |
46 | | - description['collocation_class'] = collclass.CollGaussLegendre |
| 44 | + #description['collocation_class'] = collclass.CollGaussLobatto |
| 45 | + #description['collocation_class'] = collclass.CollGaussLegendre |
| 46 | + description['collocation_class'] = collclass.CollGaussRadau_Right |
47 | 47 | description['sweeper_class'] = imex_1st_order |
48 | 48 | description['do_coll_update'] = True |
49 | 49 | description['level_params'] = lparams |
50 | 50 | description['hook_class'] = plot_solution |
51 | 51 |
|
52 | | - Nsteps = [30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80] |
| 52 | + nsteps = np.zeros((3,7)) |
| 53 | + nsteps[0,:] = [10, 15, 20, 25, 30, 35, 40] |
| 54 | + nsteps[1,:] = nsteps[0,:] |
| 55 | + nsteps[2,:] = nsteps[0,:] |
53 | 56 |
|
54 | | - for order in [2, 3, 4]: |
| 57 | + for order in [3, 4, 5]: |
55 | 58 |
|
56 | | - error = np.zeros(np.size(Nsteps)) |
| 59 | + error = np.zeros(np.shape(nsteps)[1]) |
57 | 60 |
|
58 | 61 | # setup parameters "in time" |
59 | 62 | t0 = 0 |
60 | 63 | Tend = 1.0 |
61 | 64 |
|
62 | | - if order==2: |
| 65 | + if order==3: |
63 | 66 | file = open('conv-data.txt', 'w') |
64 | 67 | else: |
65 | 68 | file = open('conv-data.txt', 'a') |
66 | 69 |
|
67 | | - if order==2: |
68 | | - description['num_nodes'] = 2 |
69 | | - elif order==3: |
| 70 | + if order==3: |
70 | 71 | description['num_nodes'] = 3 |
71 | 72 | elif order==4: |
72 | 73 | description['num_nodes'] = 3 |
73 | | - |
| 74 | + elif order==5: |
| 75 | + description['num_nodes'] = 3 |
74 | 76 | sparams['maxiter'] = order |
75 | 77 |
|
76 | | - # quickly generate block of steps |
77 | | - MS = mp.generate_steps(num_procs,sparams,description) |
78 | | - for ii in range(0,np.size(Nsteps)): |
| 78 | + for ii in range(0,np.shape(nsteps)[1]): |
79 | 79 |
|
80 | | - dt = Tend/float(Nsteps[ii]) |
| 80 | + ns = nsteps[order-3,ii] |
| 81 | + if ((order==3) or (order==4)): |
| 82 | + pparams['nvars'] = [(2,4*ns)] |
| 83 | + elif order==5: |
| 84 | + pparams['navrs'] = [(2,3*ns)] |
| 85 | + |
| 86 | + # quickly generate block of steps |
| 87 | + MS = mp.generate_steps(num_procs,sparams,description) |
| 88 | + |
| 89 | + dt = Tend/float(ns) |
81 | 90 |
|
82 | 91 | # get initial values on finest level |
83 | 92 | P = MS[0].levels[0].prob |
|
94 | 103 | uex = P.u_exact(Tend) |
95 | 104 |
|
96 | 105 | error[ii] = np.linalg.norm(uex.values-uend.values,np.inf)/np.linalg.norm(uex.values,np.inf) |
97 | | - file.write(str(order)+" "+str(Nsteps[ii])+" "+str(error[ii])+"\n") |
| 106 | + file.write(str(order)+" "+str(ns)+" "+str(error[ii])+"\n") |
98 | 107 |
|
99 | 108 | file.close() |
100 | 109 |
|
101 | | - if np.size(Nsteps)==1: |
| 110 | + if np.shape(nsteps)[1]==1: |
102 | 111 | fig = plt.figure(figsize=(8,8)) |
103 | 112 |
|
104 | 113 | plt.plot(P.mesh, uex.values[0,:], '+', color='b', label='u (exact)') |
|
110 | 119 | plt.ylim([-1.0, 1.0]) |
111 | 120 | plt.show() |
112 | 121 | else: |
113 | | - for ii in range(0,np.size(Nsteps)): |
114 | | - print('error for nsteps= %s: %s' % (Nsteps[ii], error[ii])) |
| 122 | + for ii in range(0,np.shape(nsteps)[1]): |
| 123 | + print('error for nsteps= %s: %s' % (nsteps[order-3,ii], error[ii])) |
0 commit comments