Skip to content

Commit

Permalink
Merge branch 'master' into ruff2
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkumar committed Oct 30, 2023
2 parents 7fe0dda + 10daafb commit 172e991
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
7 changes: 5 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/hiddenSymmetries/simsopt/blob/master/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
<https://github.com/hiddenSymmetries/simsopt/blob/master/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 <https://hiddensymmetries.github.io/booz_xform/>`_
- For SPEC support:
Expand Down
5 changes: 3 additions & 2 deletions src/simsopt/field/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,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:
Expand Down Expand Up @@ -845,7 +846,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)
Expand Down
2 changes: 1 addition & 1 deletion src/simsopt/mhd/vmec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
21 changes: 5 additions & 16 deletions tests/field/test_biotsavart.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,22 @@ 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 ]])
BiotSavart([Coil(get_curve(), Current(1e4))])
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)
Expand Down Expand Up @@ -180,7 +169,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]
Expand Down Expand Up @@ -255,7 +244,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]
Expand Down

0 comments on commit 172e991

Please sign in to comment.