|
32 | 32 | lparams['restol'] = 1E-10 |
33 | 33 |
|
34 | 34 | sparams = {} |
35 | | - sparams['maxiter'] = 2 |
| 35 | + sparams['maxiter'] = 4 |
36 | 36 |
|
37 | 37 | # setup parameters "in time" |
38 | 38 | t0 = 0.0 |
|
59 | 59 | description['dtype_f'] = rhs_imex_mesh |
60 | 60 | description['collocation_class'] = collclass.CollGaussLegendre |
61 | 61 | # Number of nodes |
62 | | - description['num_nodes'] = 2 |
| 62 | + description['num_nodes'] = 3 |
63 | 63 | description['sweeper_class'] = imex_1st_order |
64 | 64 | description['level_params'] = lparams |
65 | 65 | description['hook_class'] = plot_solution |
|
118 | 118 | unew_dirk, pnew_dirk = np.split(ynew_dirk, 2) |
119 | 119 | unew_imex, pnew_imex = np.split(ynew_imex, 2) |
120 | 120 |
|
121 | | - rcParams['figure.figsize'] = 5, 2.5 |
| 121 | + rcParams['figure.figsize'] = 2.5, 2.5 |
122 | 122 | fig = plt.figure() |
123 | 123 |
|
124 | 124 | sigma_0 = 0.1 |
|
131 | 131 | print ('Maximum pressure in RK-IMEX: %5.3e' % np.linalg.norm(pnew_imex, np.inf)) |
132 | 132 |
|
133 | 133 | #plt.plot(P.mesh, pnew_tp, '-', color='c', label='Trapezoidal') |
134 | | - plt.plot(P.mesh, pnew_imex, '-', color='c', label='IMEX('+str(rkimex.order)+')') |
| 134 | + if np.linalg.norm(pnew_imex, np.inf)<=2: |
| 135 | + plt.plot(P.mesh, pnew_imex, '-', color='c', label='IMEX('+str(rkimex.order)+')') |
135 | 136 | plt.plot(P.mesh, uend.values[1,:], '--', color='b', label='SDC('+str(sparams['maxiter'])+')') |
136 | | - plt.plot(P.mesh, pnew_bdf, '-', color='r', label='BDF-2') |
| 137 | + if dirk.order==2: |
| 138 | + plt.plot(P.mesh, pnew_bdf, '-', color='r', label='BDF-2') |
137 | 139 | plt.plot(P.mesh, pnew_dirk, color='g', label='DIRK('+str(dirk.order)+')') |
138 | 140 | #plt.plot(P.mesh, uex.values[1,:], '+', color='r', label='p (exact)') |
139 | 141 | #plt.plot(P.mesh, uend.values[1,:], '-', color='b', linewidth=2.0, label='p (SDC)') |
|
152 | 154 | plt.gcf().savefig(filename, bbox_inches='tight') |
153 | 155 | call(["pdfcrop", filename, filename]) |
154 | 156 |
|
| 157 | + #plt.plot(P.mesh, uend.values[1,:], '-', color='b', linewidth=2.0, label='p (SDC)') |
| 158 | + |
| 159 | + fig = plt.figure() |
| 160 | + p_slow = np.exp(-np.square( np.mod( P.mesh-pparams['cadv']*Tend, 1.0 ) -x_0 )/(sigma_0*sigma_0)) |
| 161 | + plt.plot(P.mesh, uinit.values[1,:], '-', color='b') |
| 162 | + plt.xlabel('x', fontsize=fs, labelpad=0) |
| 163 | + plt.ylabel('Pressure', fontsize=fs, labelpad=0) |
| 164 | + fig.gca().set_xlim([0, 1.0]) |
| 165 | + fig.gca().set_ylim([-0.5, 1.1]) |
| 166 | + fig.gca().tick_params(axis='both', labelsize=fs) |
| 167 | + fig.gca().grid() |
| 168 | + #plt.show() |
| 169 | + filename = 'sdc-fwsw-multiscale-initial.pdf' |
| 170 | + plt.gcf().savefig(filename, bbox_inches='tight') |
| 171 | + call(["pdfcrop", filename, filename]) |
0 commit comments