Skip to content

Commit 02dee92

Browse files
author
Daniel Ruprecht
committed
script to plot abs(R) versus k for a different M at one specific lambda_s/lambda_f ; marked positions in stability plots by a cross
1 parent b58a8f3 commit 02dee92

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

examples/fwsw/plot_stab_vs_k.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616

1717
if __name__ == "__main__":
1818
mvals = [2, 3, 4]
19-
kvals = np.arange(2,10)
20-
lambda_fast = 15j
21-
lambda_slow = 3j
19+
kvals = np.arange(1,10)
20+
lambda_fast = 10j
21+
slow_resolved = False
22+
if slow_resolved:
23+
lambda_slow = 1j
24+
else:
25+
lambda_slow = 4j
2226
stabval = np.zeros((np.size(mvals), np.size(kvals)))
2327

2428
for i in range(0,np.size(mvals)):
@@ -68,18 +72,25 @@
6872
rcParams['figure.figsize'] = 2.5, 2.5
6973
fig = plt.figure()
7074
fs = 8
71-
plt.plot(kvals, stabval[0,:], 'o-', color='b', label=("M=%2i" % mvals[0]))
72-
plt.plot(kvals, stabval[1,:], 's-', color='r', label=("M=%2i" % mvals[1]))
73-
plt.plot(kvals, stabval[2,:], 'd-', color='g', label=("M=%2i" % mvals[2]))
75+
plt.plot(kvals, stabval[0,:], 'o-', color='b', label=("M=%2i" % mvals[0]), markersize=fs-2)
76+
plt.plot(kvals, stabval[1,:], 's-', color='r', label=("M=%2i" % mvals[1]), markersize=fs-2)
77+
plt.plot(kvals, stabval[2,:], 'd-', color='g', label=("M=%2i" % mvals[2]), markersize=fs-2)
7478
plt.plot(kvals, 1.0+0.0*kvals, '--', color='k')
7579
plt.xlabel('Number of iterations K', fontsize=fs)
7680
plt.ylabel(r'Modulus of stability function $\left| R \right|$', fontsize=fs)
7781
plt.ylim([0.0, 1.2])
78-
plt.legend(loc='lower left', fontsize=fs, prop={'size':fs})
82+
if slow_resolved:
83+
plt.legend(loc='upper right', fontsize=fs, prop={'size':fs})
84+
else:
85+
plt.legend(loc='lower left', fontsize=fs, prop={'size':fs})
86+
7987
plt.gca().get_xaxis().get_major_formatter().labelOnlyBase = False
8088
plt.gca().get_xaxis().set_major_formatter(ScalarFormatter())
81-
plt.show()
82-
83-
# filename = 'stablimit-M'+str(mvals[0])+'.pdf'
84-
# fig.savefig(filename, bbox_inches='tight')
85-
# call(["pdfcrop", filename, filename])
89+
#plt.show()
90+
if slow_resolved:
91+
filename = 'stab_vs_k_resolved.pdf'
92+
else:
93+
filename = 'stab_vs_k_unresolved.pdf'
94+
95+
fig.savefig(filename, bbox_inches='tight')
96+
call(["pdfcrop", filename, filename])

examples/fwsw/plot_stab_vs_m.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
if __name__ == "__main__":
1818
mvals = np.arange(2,10)
1919
kvals = [3, 5, 7]
20-
lambda_fast = 8j
21-
lambda_slow = 4j
20+
lambda_fast = 10j
21+
lambda_slow = 3j
2222
stabval = np.zeros((np.size(kvals), np.size(mvals)))
2323

2424
for i in range(0,np.size(mvals)):

examples/fwsw/plot_stability.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
swparams['collocation_class'] = collclass.CollGaussRadau_Right
3636

3737
### SET NUMBER OF QUADRATURE NODES ###
38-
swparams['num_nodes'] = 4
38+
swparams['num_nodes'] = 3
3939

4040
### SET NUMBER OF ITERATIONS - SET K=0 FOR COLLOCATION SOLUTION ###
41-
K = 3
41+
K = 5
4242

4343
do_coll_update = True
4444

@@ -89,6 +89,9 @@
8989
# levels = np.array([1.0])
9090
CS1 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), levels, colors='k', linestyles='dashed')
9191
CS2 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), [1.0], colors='k')
92+
# Set markers at points used in plot_stab_vs_k
93+
plt.plot(4, 10, 'x', color='k', markersize=fs-4)
94+
plt.plot(1, 10, 'x', color='k', markersize=fs-4)
9295
plt.clabel(CS1, inline=True, fmt='%3.2f', fontsize=fs-2)
9396
manual_locations = [(1.5, 2.5)]
9497
if K>0: # for K=0 and no 1.0 isoline, this crashes Matplotlib for somer reason

0 commit comments

Comments
 (0)