-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for archimedian spiral without function arguments
- Loading branch information
Showing
2 changed files
with
735 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
Oops, something went wrong.