Skip to content

Commit c82703f

Browse files
committed
beautified precond plots
1 parent 1c80085 commit c82703f

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

projects/parallelSDC/preconditioner_playground.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,50 @@ def plot_iterations():
187187
assert len(qd_type_list) == 5, 'ERROR did not find five preconditioners, got %s' % qd_type_list
188188
assert len(setup_list) == 4, 'ERROR: did not find three setup, got %s' % setup_list
189189

190+
qd_type_list = ['LU', 'IE', 'IEpar', 'Qpar', 'MIN']
191+
marker_list = [None, None, 's', 'o', '^']
192+
color_list = ['k', 'k', 'r', 'g', 'b']
193+
190194
# loop over setups and Q-delta types: one figure per setup, all Qds in one plot
191195
for setup in setup_list:
192196

193197
plt.figure()
194-
for qd_type in qd_type_list:
198+
for qd_type, marker, color in zip(qd_type_list, marker_list, color_list):
195199
niter_heat = np.zeros(len(results[setup][1]))
196200
for key in results.keys():
197201
if isinstance(key, ID):
198202
if key.setup == setup and key.qd_type == qd_type:
199203
xvalue = results[setup][1].index(key.param)
200204
niter_heat[xvalue] = results[key]
201-
plt.semilogx(results[setup][1], niter_heat, label=qd_type, lw=2)
205+
if qd_type == 'LU':
206+
ls = '--'
207+
lw = 2
208+
elif qd_type == 'IE':
209+
ls = '-.'
210+
lw = 2
211+
else:
212+
ls = '-'
213+
lw = 3
214+
plt.semilogx(results[setup][1], niter_heat, label=qd_type, lw=lw, linestyle=ls, color=color, marker=marker,
215+
markersize=10)
216+
217+
if setup == 'heat':
218+
xlabel = r'$\nu$'
219+
elif setup == 'advection':
220+
xlabel = r'$c$'
221+
elif setup == 'fisher':
222+
xlabel = r'$\lambda_0$'
223+
elif setup == 'vanderpol':
224+
xlabel = r'$\mu$'
225+
else:
226+
print('Setup not implemented..', setup)
227+
exit()
202228

203229
plt.ylim([0, 60])
204-
plt.legend(loc=2, ncol=1)
205-
plt.title(setup)
230+
plt.legend(loc=2, ncol=1, numpoints=1)
231+
# plt.title(setup)
206232
plt.ylabel('number of iterations')
207-
plt.xlabel('parameter')
233+
plt.xlabel(xlabel)
208234
plt.grid()
209235

210236
# save plot as PDF, beautify
@@ -215,5 +241,5 @@ def plot_iterations():
215241

216242

217243
if __name__ == "__main__":
218-
main()
244+
# main()
219245
plot_iterations()

0 commit comments

Comments
 (0)