From 51b37b42006e0159660c4684745ed63ac39f1e8c Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Fri, 6 Oct 2023 12:53:27 -0400 Subject: [PATCH 1/7] Initial commit. --- src/simsopt/field/tracing.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/simsopt/field/tracing.py b/src/simsopt/field/tracing.py index d8fe8c3ba..f5ab3d164 100644 --- a/src/simsopt/field/tracing.py +++ b/src/simsopt/field/tracing.py @@ -799,7 +799,8 @@ class IterationStoppingCriterion(sopp.IterationStoppingCriterion): pass -def plot_poincare_data(fieldlines_phi_hits, phis, filename, mark_lost=False, aspect='equal', dpi=300, xlims=None, ylims=None, surf=None): +def plot_poincare_data(fieldlines_phi_hits, phis, filename, mark_lost=False, aspect='equal', dpi=300, xlims=None, + ylims=None, surf=None, s=2, marker='o'): """ Create a poincare plot. Usage: @@ -846,7 +847,7 @@ def plot_poincare_data(fieldlines_phi_hits, phis, filename, mark_lost=False, asp if data_this_phi.size == 0: continue r = np.sqrt(data_this_phi[:, 2]**2+data_this_phi[:, 3]**2) - axs[row, col].scatter(r, data_this_phi[:, 4], marker='o', s=2, linewidths=0, c=color) + axs[row, col].scatter(r, data_this_phi[:, 4], marker=marker, s=s, linewidths=0, c=color) plt.rc('axes', axisbelow=True) axs[row, col].grid(True, linewidth=0.5) From e3568fc685f90012f0e5afdd4d9a5cac45cc6101 Mon Sep 17 00:00:00 2001 From: Matt Landreman Date: Fri, 27 Oct 2023 06:55:21 -0400 Subject: [PATCH 2/7] fixed url for vmec repository --- src/simsopt/mhd/vmec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simsopt/mhd/vmec.py b/src/simsopt/mhd/vmec.py index e78a37c11..0214fab0f 100644 --- a/src/simsopt/mhd/vmec.py +++ b/src/simsopt/mhd/vmec.py @@ -308,7 +308,7 @@ def __init__(self, raise RuntimeError( "Running VMEC from simsopt requires VMEC python extension. " "Install the VMEC python extension from " - "https://https://github.com/hiddenSymmetries/VMEC2000") + "https://github.com/hiddenSymmetries/VMEC2000") comm = self.mpi.comm_groups self.fcomm = comm.py2f() From 6fa8b371a8e08354dc259b162780076fb21415b4 Mon Sep 17 00:00:00 2001 From: Matt Landreman Date: Fri, 27 Oct 2023 07:05:06 -0400 Subject: [PATCH 3/7] Installation docs: clarification about vmec python extension --- docs/source/installation.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 4a3f5dca4..b2d0fbeb5 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -25,16 +25,19 @@ Optional Packages ----------------- Several other optional packages are needed for certain aspects of -simsopt, such as visualization/graphics and building the documentation. These -requirements can be found in the ``[options.extras_require]`` section -of -`setup.cfg `_. +simsopt, such as running SPEC or VMEC, visualization/graphics, and building the +documentation. These requirements can be found in the +``[options.extras_require]`` section of `setup.cfg +`_. Also, - For MPI support: * mpi4py - For VMEC support: - * https://github.com/hiddenSymmetries/vmec2000 + * https://github.com/hiddenSymmetries/vmec2000 Note that the + python extension in this repository is required to run VMEC or + optimize VMEC configurations, but is not needed for computing + properties of existing ``wout`` output files. - For computing Boozer coordinates: * `booz_xform `_ - For SPEC support: From b43e40a3ee4c3e61cf12850eedea0760579ce90a Mon Sep 17 00:00:00 2001 From: Matt Landreman Date: Fri, 27 Oct 2023 08:29:32 -0400 Subject: [PATCH 4/7] Fix readthedocs build error --- .readthedocs.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 03d679bc1..90dc5fffc 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,6 +1,11 @@ # Required version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.8" + # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/source/conf.py @@ -11,9 +16,7 @@ sphinx: # formats: # - pdf -# Optionally set the version of Python and requirements required to build your docs python: - version: 3.8 install: - requirements: docs/requirements.txt - requirements: requirements.txt From a4acab6a64963013f5796d59122f8d6d17e5e82f Mon Sep 17 00:00:00 2001 From: Matt Landreman Date: Fri, 27 Oct 2023 09:09:22 -0400 Subject: [PATCH 5/7] Fix readthedocs build error --- .readthedocs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 90dc5fffc..b959ec9b8 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -3,8 +3,8 @@ version: 2 build: os: ubuntu-22.04 - tools: - python: "3.8" + tools: + python: "3.8" # Build documentation in the docs/ directory with Sphinx sphinx: From a72392cfa04527715f69958087d9a7fb267c893c Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Sat, 28 Oct 2023 14:45:36 -0400 Subject: [PATCH 6/7] bug fix in test_biotsavart.py --- tests/field/test_biotsavart.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tests/field/test_biotsavart.py b/tests/field/test_biotsavart.py index 872d03c2a..e95fc322e 100644 --- a/tests/field/test_biotsavart.py +++ b/tests/field/test_biotsavart.py @@ -33,33 +33,21 @@ def test_biotsavart_both_interfaces_give_same_result(self): assert np.allclose(B1, B2) def test_biotsavart_exponential_convergence(self): - coil = BiotSavart([Coil(get_curve(), Current(1e4))]) - from time import time - # points = np.asarray(17 * [[-1.41513202e-03, 8.99999382e-01, -3.14473221e-04 ]]) points = np.asarray(10 * [[-1.41513202e-03, 8.99999382e-01, -3.14473221e-04]]) - tic = time() btrue = BiotSavart([Coil(get_curve(1000), Current(1e4))]).set_points(points).B() - # print(btrue) bcoarse = BiotSavart([Coil(get_curve(10), Current(1e4))]).set_points(points).B() bfine = BiotSavart([Coil(get_curve(20), Current(1e4))]).set_points(points).B() assert np.linalg.norm(btrue-bfine) < 1e-4 * np.linalg.norm(bcoarse-bfine) - # print(time()-tic) - tic = time() dbtrue = BiotSavart([Coil(get_curve(1000), Current(1e4))]).set_points(points).dB_by_dX() - # print(dbtrue) dbcoarse = BiotSavart([Coil(get_curve(10), Current(1e4))]).set_points(points).dB_by_dX() dbfine = BiotSavart([Coil(get_curve(20), Current(1e4))]).set_points(points).dB_by_dX() - assert np.linalg.norm(btrue-bfine) < 1e-4 * np.linalg.norm(bcoarse-bfine) - # print(time()-tic) + assert np.linalg.norm(dbtrue-dbfine) < 1e-4 * np.linalg.norm(dbcoarse-dbfine) - tic = time() dbtrue = BiotSavart([Coil(get_curve(1000), Current(1e4))]).set_points(points).d2B_by_dXdX() - # print("dbtrue", dbtrue) dbcoarse = BiotSavart([Coil(get_curve(10), Current(1e4))]).set_points(points).d2B_by_dXdX() dbfine = BiotSavart([Coil(get_curve(20), Current(1e4))]).set_points(points).d2B_by_dXdX() - assert np.linalg.norm(btrue-bfine) < 1e-4 * np.linalg.norm(bcoarse-bfine) - # print(time()-tic) + assert np.linalg.norm(dbtrue-dbfine) < 1e-4 * np.linalg.norm(dbcoarse-dbfine) def test_dB_by_dcoilcoeff_reverse_taylortest(self): np.random.seed(1) @@ -180,7 +168,7 @@ def subtest_biotsavart_d2B_by_dXdX_taylortest(self, idx): bs = BiotSavart([coil]) points = np.asarray(17 * [[-1.41513202e-03, 8.99999382e-01, -3.14473221e-04]]) bs.set_points(points) - dB_by_dX, d2B_by_dXdX = bs.dB_by_dX(), bs.d2B_by_dXdX() + d2B_by_dXdX = bs.d2B_by_dXdX() for d1 in range(3): for d2 in range(3): second_deriv = d2B_by_dXdX[idx, d1, d2] @@ -255,7 +243,7 @@ def subtest_biotsavart_d2A_by_dXdX_taylortest(self, idx): bs = BiotSavart([coil]) points = np.asarray(17 * [[-1.41513202e-03, 8.99999382e-01, -3.14473221e-04]]) bs.set_points(points) - dA_by_dX, d2A_by_dXdX = bs.dA_by_dX(), bs.d2A_by_dXdX() + d2A_by_dXdX = bs.d2A_by_dXdX() for d1 in range(3): for d2 in range(3): second_deriv = d2A_by_dXdX[idx, d1, d2] From 61b39962207ca232f5e327819d6a62686df31948 Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Sat, 28 Oct 2023 14:48:56 -0400 Subject: [PATCH 7/7] Keep the initial call to BiotSavart --- tests/field/test_biotsavart.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/field/test_biotsavart.py b/tests/field/test_biotsavart.py index e95fc322e..1eef4f380 100644 --- a/tests/field/test_biotsavart.py +++ b/tests/field/test_biotsavart.py @@ -33,6 +33,7 @@ def test_biotsavart_both_interfaces_give_same_result(self): assert np.allclose(B1, B2) def test_biotsavart_exponential_convergence(self): + BiotSavart([Coil(get_curve(), Current(1e4))]) points = np.asarray(10 * [[-1.41513202e-03, 8.99999382e-01, -3.14473221e-04]]) btrue = BiotSavart([Coil(get_curve(1000), Current(1e4))]).set_points(points).B() bcoarse = BiotSavart([Coil(get_curve(10), Current(1e4))]).set_points(points).B()