Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
Browse files Browse the repository at this point in the history
…into I_current_profiles
  • Loading branch information
Stefan Buller committed Jan 13, 2025
2 parents 88d7d89 + d6bea2b commit c0d6df9
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 32 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ relative_files = true
[paths]
sources =
src/
/**/lib/python3.8/site-packages
/**/lib/python3.9/site-packages
/**/lib/python3.10/site-packages
/**/lib/python3.11/site-packages
4 changes: 2 additions & 2 deletions .github/workflows/extensive_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install wheel "numpy<2.0.0" scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann f90wrap
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann f90wrap
- name: Install booz_xform
if: contains(matrix.packages, 'vmec') || contains(matrix.packages, 'all')
Expand Down Expand Up @@ -290,7 +290,7 @@ jobs:
- name: Upload coverage to Codecov
# The next line prevents github from trying to upload to Codecov on forks of the repository, avoiding a permissions error
if: github.repository_owner == 'hiddenSymmetries'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Run ruff
uses: chartboost/ruff-action@v1
uses: astral-sh/ruff-action@v1

2 changes: 1 addition & 1 deletion .github/workflows/non_simd_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install wheel "numpy<2.0.0" scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann
- name: Install booz_xform
run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install "numpy<2.0.0" cmake scikit-build f90nml ninja wheel setuptools sympy qsc pyevtk matplotlib plotly networkx pygraphviz mpi4py py_spec h5py ground bentley_ottmann f90wrap
pip install numpy cmake scikit-build f90nml ninja wheel setuptools sympy qsc pyevtk matplotlib plotly networkx pygraphviz mpi4py py_spec h5py ground bentley_ottmann f90wrap
- name: Install pyoculus
run: pip install -v git+https://github.com/zhisong/pyoculus
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
run: git fetch --prune --unshallow

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.4
uses: pypa/cibuildwheel@v2.21.3
# To supply options, put them in 'env'
env:
# Only build for python 3.{8,9,10,11}
CIBW_BUILD : cp38-* cp39-* cp310-* cp311-*
# Only build for python 3.{9,10,11,12}
CIBW_BUILD : cp39-* cp310-* cp311-* cp312-*
# Supports only x86_64 arch for linux
CIBW_ARCHS_LINUX: x86_64
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_SKIP: cp27-* cp36-* cp37-*
CIBW_SKIP: cp27-* cp36-* cp37-* cp38-*
CIBW_DEPENDENCY_VERSIONS: latest

- uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4.1.7
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
Expand Down
5 changes: 4 additions & 1 deletion ci/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ RUN python3 -m pip install wheel
RUN python3 -m venv /venv/

RUN /venv/bin/pip install -U pip
RUN /venv/bin/python -m pip install numpy scipy jax jaxlib f90nml mpi4py jupyter notebook ipython qsc sympy scikit-build ninja "pybind11[global]" cmake f90wrap h5py
# 2024-11-12 MJL: mpi4py < 4.0 in the next line is due to
# https://github.com/hiddenSymmetries/simsopt/issues/455
# Once NERSC gets Shifter working with mpi4py >= 4 we can remove this inequality
RUN /venv/bin/python -m pip install numpy scipy jax jaxlib f90nml "mpi4py<4.0" jupyter notebook ipython qsc sympy scikit-build ninja "pybind11[global]" cmake f90wrap h5py
ENV PATH="/venv/bin:${PATH}"

RUN git clone --depth 1 https://github.com/PrincetonUniversity/SPEC.git /src/SPEC && \
Expand Down
10 changes: 6 additions & 4 deletions ci/singularity.def
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ Stage: devel

git clone --depth 1 https://github.com/mpi4py/mpi4py.git && \
cd mpi4py && \
/venv/bin/python setup.py build --mpicc=mpicc --mpicxx=mpicxx --mpifort=mpifort --mpif90=mpif90 --mpif77=mpif77 --mpild=mpicc && \
/venv/bin/python setup.py install && \
# /venv/bin/python setup.py build --mpicc=mpicc --mpicxx=mpicxx --mpifort=mpifort --mpif90=mpif90 --mpif77=mpif77 --mpild=mpicc && \
# /venv/bin/python setup.py install && \
/venv/bin/pip install . && \
cd .. && \
rm -rf mpi4py

git clone --depth 1 https://github.com/PrincetonUniversity/SPEC.git && \
cd SPEC && \
/venv/bin/python setup.py bdist_wheel && \
/venv/bin/pip install -v dist/*.whl && \
# /venv/bin/python setup.py bdist_wheel && \
# /venv/bin/pip install -v dist/*.whl && \
/venv/bin/pip install -v .
cd Utilities/pythontools && \
/venv/bin/pip install -r requirements.txt && \
/venv/bin/pip install . && \
Expand Down
1 change: 0 additions & 1 deletion conda.recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ numpy:
- 1.23
- 1.24
python:
- 3.8
- 3.9
- 3.10
- 3.11
Expand Down
8 changes: 4 additions & 4 deletions docs/source/example_islands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ We now combine the four residues into a least-squares objective
function, by summing the squares of the residues::

# Objective function is \sum_j residue_j ** 2
prob = LeastSquaresProblem.from_tuples([(residue1, 0, 1),
(residue2, 0, 1),
(residue3, 0, 1),
(residue4, 0, 1)])
prob = LeastSquaresProblem.from_tuples([(residue1.J, 0, 1),
(residue2.J, 0, 1),
(residue3.J, 0, 1),
(residue4.J, 0, 1)])

If you wanted an island to be present instead of absent, which might
be the case when designing an island divertor, a value other than zero
Expand Down
4 changes: 2 additions & 2 deletions docs/source/example_quasisymmetry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ axisymmetric::
# Define objective function
prob = LeastSquaresProblem.from_tuples([(vmec.aspect, 6, 1),
(vmec.mean_iota, 0.42, 1),
(qs, 0, 1)])
(qs.residuals, 0, 1)])

It can be seen here that we are seeking a configuration with aspect
ratio 6, and average iota of 0.42, slightly above the resonance at 2 /
Expand Down Expand Up @@ -387,7 +387,7 @@ at the edge and magnetic axis, in order to prescribe the magnetic shear::
prob = LeastSquaresProblem.from_tuples([(vmec.aspect, 6, 1),
(vmec.iota_axis, 0.465, 1),
(vmec.iota_edge, 0.495, 1),
(qs, 0, 1)])
(qs.residuals, 0, 1)])

It can be seen here that we are seeking a configuration with aspect
ratio 6, and iota slightly below 0.5.
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
requires = [
"scikit-build-core",
"pybind11",
"numpy >= 2.0.0; python_version > '3.8'",
"oldest-supported-numpy; python_version <= '3.8'",
"numpy >= 2.0.0",
"setuptools_scm>=8.0",
'tomli; python_version < "3.11"',]
build-backend = "scikit_build_core.build"
Expand Down Expand Up @@ -53,7 +52,7 @@ keywords = [
"magnetostatics"
]
dependencies = [
"numpy>=1.21,<2.0.0",
"numpy>=1.21",
"jax>=0.2.5",
"jaxlib>=0.1.56",
"scipy>=1.5.4",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
setuptools_scm >= 6.0
numpy >= 1.19.4
numpy >= 1.21.0
jax >= 0.2.5
jaxlib >= 0.1.56
scipy >= 1.5.4
Expand Down
4 changes: 2 additions & 2 deletions src/simsopt/_core/optimizable.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self,
free: Array of boolean values denoting if the DOFs is are free.
False values implies the corresponding DOFs are fixed
lower_bounds: Lower bounds for the DOFs. Meaningful only if
DOF is not fixed. Default is np.NINF
DOF is not fixed. Default is -np.inf
upper_bounds: Upper bounds for the DOFs. Meaningful only if
DOF is not fixed. Default is np.inf
"""
Expand All @@ -106,7 +106,7 @@ def __init__(self,
free = np.asarray(free, dtype=np.bool_)

if lower_bounds is None:
lower_bounds = np.full(len(x), np.NINF)
lower_bounds = np.full(len(x), -np.inf)
else:
lower_bounds = np.asarray(lower_bounds, np.double)

Expand Down
2 changes: 1 addition & 1 deletion src/simsopt/mhd/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def __init__(self,
mpol=self.mpol, ntor=self.ntor)
self._boundary.rc[:] = self.array_translator(si.rbc, style='spec').as_simsopt
self._boundary.zs[:] = self.array_translator(si.zbs, style='spec').as_simsopt
if not self.freebound:
if not self.stellsym:
self._boundary.rs[:] = self.array_translator(si.rbs, style='spec').as_simsopt
self._boundary.zc[:] = self.array_translator(si.zbc, style='spec').as_simsopt
self._boundary.local_full_x = self._boundary.get_dofs()
Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_dofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_lower_bounds(self):
names=np.array(['x', 'y', 'z']),
free=np.array([True, True, False]))
self.assertTrue(np.allclose(dofs.free_lower_bounds,
np.array([np.NINF, np.NINF])))
np.array([-np.inf, -np.inf])))

with self.assertRaises(DofLengthMismatchError):
dofs.free_lower_bounds = np.array([-1000.0, -1001.0, -1002.0])
Expand All @@ -180,7 +180,7 @@ def test_lower_bounds(self):

dofs.unfix_all()
self.assertTrue(np.allclose(dofs.free_lower_bounds,
np.array([-1000.0, -1001.0, np.NINF])))
np.array([-1000.0, -1001.0, -np.inf])))

dofs.free_lower_bounds = np.array([-1000.0, -1001.0, -1002.])
self.assertTrue(np.allclose(dofs.free_lower_bounds,
Expand Down

0 comments on commit c0d6df9

Please sign in to comment.