From cf87481ebc3677fdfa043e2dc0e6521450ac3eca Mon Sep 17 00:00:00 2001 From: Andreas D Date: Sun, 14 Mar 2021 21:22:18 +0100 Subject: [PATCH] add test for archimedian spiral without function arguments --- test/test_archimedean_spiral_noargs.py | 57 ++ test/test_archimedean_spiral_noargs.svg | 678 ++++++++++++++++++++++++ 2 files changed, 735 insertions(+) create mode 100644 test/test_archimedean_spiral_noargs.py create mode 100644 test/test_archimedean_spiral_noargs.svg diff --git a/test/test_archimedean_spiral_noargs.py b/test/test_archimedean_spiral_noargs.py new file mode 100644 index 0000000..21921fd --- /dev/null +++ b/test/test_archimedean_spiral_noargs.py @@ -0,0 +1,57 @@ +import matplotlib.pyplot as plt +import numpy as np +import pytest + +import contique + + +def fun(x, l): + a = 1 + r = a * l + return np.array([-x[0] + r * np.cos(l), -x[1] + r * np.sin(l)]) + + +def test_archimedian_spiral_noargs(): + + # initial solution + x0 = np.zeros(2) + lpf0 = 0.0 + + # numeric continuation + Res = contique.solve( + fun=fun, + x0=x0, + lpf0=lpf0, + dxmax=0.2, + dlpfmax=0.2, + maxsteps=500, + maxcycles=4, + maxiter=8, + tol=1e-10, + overshoot=1.05, + ) + + X = np.array([res.x for res in Res]) + + plt.plot(X[:, 0], X[:, 1], "-") + plt.xlabel("$x_1$") + plt.ylabel("$x_2$") + plt.xlim(-15, 15) + plt.ylim(-15, 15) + plt.plot([0], [0], "C0o", lw=3) + plt.arrow( + X[-2, 0], + X[-2, 1], + X[-1, 0] - X[-2, 0], + X[-1, 1] - X[-2, 1], + head_width=1, + head_length=2, + fc="C0", + ec="C0", + ) + plt.gca().set_aspect("equal") + plt.savefig("test_archimedean_spiral_noargs.svg") + + +if __name__ == "__main__": + test_archimedian_spiral_noargs() diff --git a/test/test_archimedean_spiral_noargs.svg b/test/test_archimedean_spiral_noargs.svg new file mode 100644 index 0000000..de87bd5 --- /dev/null +++ b/test/test_archimedean_spiral_noargs.svg @@ -0,0 +1,678 @@ + + + + + + + + + 2021-03-14T21:21:51.178730 + image/svg+xml + + + Matplotlib v3.3.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +