Skip to content

Commit 3b791c3

Browse files
authored
Added plot showing sorted eigenvectors (#175)
* Added plot showing sorted eigenvectors I added a few lines so that users can see how to plot the eigenvectors with the lowest/highest growth rates. It took me a while to figure out the new `set_state` method API that requires specifying the `subsystem` in addition to the index, so I thought it would be useful to include it in at least one of the EVP examples. * Update waves_on_a_string.py
1 parent 59d01bc commit 3b791c3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

examples/evp_1d_waves_on_a_string/waves_on_a_string.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,14 @@
6767
plt.tight_layout()
6868
plt.savefig('eigenvalue_error.pdf')
6969

70+
plt.figure(figsize=(6, 4))
71+
x = dist.local_grid(xbasis)
72+
for n, idx in enumerate(np.argsort(solver.eigenvalues)[:5], start=1):
73+
solver.set_state(idx, solver.subsystems[0])
74+
plt.plot(x, (u['g']/np.max(u['g'])).real, label=f"n={n}")
75+
plt.xlim(0, 1)
76+
plt.legend(loc="lower right")
77+
plt.ylabel(r"mode structure")
78+
plt.xlabel(r"x")
79+
plt.tight_layout()
80+
plt.savefig("eigenvectors.pdf")

0 commit comments

Comments
 (0)