|
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)+')') |
135 |
| - 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 |
| - plt.plot(P.mesh, pnew_dirk, color='g', label='DIRK('+str(dirk.order)+')') |
| 134 | + if dirk.order==2: |
| 135 | + plt.plot(P.mesh, pnew_bdf, 'd-', color='c', label='BDF-2',markevery=(50,75)) |
| 136 | + p_slow = np.exp(-np.square( np.mod( P.mesh-pparams['cadv']*Tend, 1.0 ) -x_0 )/(sigma_0*sigma_0)) |
| 137 | + plt.plot(P.mesh, p_slow, '--', color='k', markersize=fs-2, label='Slow mode', dashes=(10,2)) |
| 138 | + if np.linalg.norm(pnew_imex, np.inf)<=2: |
| 139 | + plt.plot(P.mesh, pnew_imex, '+-', color='r', label='IMEX('+str(rkimex.order)+')',markevery=(1,75),mew=1.0) |
| 140 | + plt.plot(P.mesh, uend.values[1,:], 'o-', color='b', label='SDC('+str(sparams['maxiter'])+')',markevery=(25,75)) |
| 141 | + plt.plot(P.mesh, pnew_dirk, '-', color='g', label='DIRK('+str(dirk.order)+')') |
138 | 142 | #plt.plot(P.mesh, uex.values[1,:], '+', color='r', label='p (exact)')
|
139 | 143 | #plt.plot(P.mesh, uend.values[1,:], '-', color='b', linewidth=2.0, label='p (SDC)')
|
140 | 144 |
|
141 |
| - p_slow = np.exp(-np.square( np.mod( P.mesh-pparams['cadv']*Tend, 1.0 ) -x_0 )/(sigma_0*sigma_0)) |
142 |
| - plt.plot(P.mesh, p_slow, '+', color='k', markersize=fs-2, label='Slow mode', markevery=10) |
143 | 145 | plt.xlabel('x', fontsize=fs, labelpad=0)
|
144 | 146 | plt.ylabel('Pressure', fontsize=fs, labelpad=0)
|
145 | 147 | fig.gca().set_xlim([0, 1.0])
|
146 | 148 | fig.gca().set_ylim([-0.5, 1.1])
|
147 | 149 | fig.gca().tick_params(axis='both', labelsize=fs)
|
148 |
| - plt.legend(loc='upper left', fontsize=fs, prop={'size':fs}) |
| 150 | + plt.legend(loc='upper left', fontsize=fs, prop={'size':fs}, handlelength=3) |
149 | 151 | fig.gca().grid()
|
150 | 152 | #plt.show()
|
151 | 153 | filename = 'sdc-fwsw-multiscale-K'+str(sparams['maxiter'])+'-M'+str(description['num_nodes'])+'.pdf'
|
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