From 22e1e7cea55917faa23677ecfd51c3455b232fe0 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 7 Nov 2024 17:17:56 +0100 Subject: [PATCH 01/14] Bugfix for SPEC non-stellerator symmetric case --- src/simsopt/mhd/spec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simsopt/mhd/spec.py b/src/simsopt/mhd/spec.py index 8a9655efc..7e0e40aae 100644 --- a/src/simsopt/mhd/spec.py +++ b/src/simsopt/mhd/spec.py @@ -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() From bf57aceadc18fab146e488ee3128fcfc46ad3cbe Mon Sep 17 00:00:00 2001 From: AWS ParallelCluster user Date: Tue, 12 Nov 2024 19:07:09 +0000 Subject: [PATCH 02/14] Remove 3.8 from supported python versions --- .coveragerc | 1 - .github/workflows/extensive_test.yml | 2 +- .github/workflows/non_simd_tests.yml | 2 +- .github/workflows/tests.yml | 2 +- .github/workflows/wheel.yml | 6 +++--- ci/singularity.def | 10 ++++++---- pyproject.toml | 5 ++--- requirements.txt | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.coveragerc b/.coveragerc index 2f74e1948..cd290e8f8 100644 --- a/.coveragerc +++ b/.coveragerc @@ -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 diff --git a/.github/workflows/extensive_test.yml b/.github/workflows/extensive_test.yml index 681930653..cef5f1452 100644 --- a/.github/workflows/extensive_test.yml +++ b/.github/workflows/extensive_test.yml @@ -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') diff --git a/.github/workflows/non_simd_tests.yml b/.github/workflows/non_simd_tests.yml index 121cc36ee..b59209470 100644 --- a/.github/workflows/non_simd_tests.yml +++ b/.github/workflows/non_simd_tests.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6b6671de7..b17d75970 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index f2593af6c..815647fda 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -20,12 +20,12 @@ jobs: uses: pypa/cibuildwheel@v2.11.4 # 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 diff --git a/ci/singularity.def b/ci/singularity.def index 83652710b..b61f212df 100644 --- a/ci/singularity.def +++ b/ci/singularity.def @@ -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 . && \ diff --git a/pyproject.toml b/pyproject.toml index b89247f2c..0667b0aae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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", diff --git a/requirements.txt b/requirements.txt index b3d4e772a..1c1011a24 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 From 1807ac4198dbe4153f9d1e21a806ab41dd8be709 Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Tue, 12 Nov 2024 19:30:22 +0000 Subject: [PATCH 03/14] Bump upload artifact version --- .github/workflows/wheel.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 815647fda..fdfab0834 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -28,7 +28,7 @@ jobs: CIBW_SKIP: cp27-* cp36-* cp37-* cp38-* CIBW_DEPENDENCY_VERSIONS: latest - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./wheelhouse/*.whl @@ -56,7 +56,7 @@ jobs: - name: Build sdist run: python -m build -s -o dist . - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: dist/*.tar.gz @@ -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@v4 with: name: artifact path: dist From af93be08deef15923c4814a3e1dcbc4a7f07850a Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Tue, 12 Nov 2024 19:36:40 +0000 Subject: [PATCH 04/14] Update codecov action version --- .github/workflows/extensive_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extensive_test.yml b/.github/workflows/extensive_test.yml index cef5f1452..6c12f81bf 100644 --- a/.github/workflows/extensive_test.yml +++ b/.github/workflows/extensive_test.yml @@ -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 From a725cbc4f447ab76af8a1fba64a830225bb116c6 Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Tue, 12 Nov 2024 19:37:33 +0000 Subject: [PATCH 05/14] Change ruff action to the one actively supported --- .github/workflows/linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 5eea66ef0..012d7bb77 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -20,5 +20,5 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run ruff - uses: chartboost/ruff-action@v1 + uses: astral-sh/ruff-action@v1 From b1d993140e11fff963f6757af96e9b1075c8e4fb Mon Sep 17 00:00:00 2001 From: Matt Landreman Date: Tue, 12 Nov 2024 14:47:44 -0500 Subject: [PATCH 06/14] Force mpi4py < 4 in Dockerfile due to shifter problem --- ci/Dockerfile.ubuntu | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/Dockerfile.ubuntu b/ci/Dockerfile.ubuntu index 02ead7dac..cb0db3447 100644 --- a/ci/Dockerfile.ubuntu +++ b/ci/Dockerfile.ubuntu @@ -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 && \ From d2bcef2ab2ee29747a52b09a251c98c9ab87f099 Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Tue, 12 Nov 2024 19:51:04 +0000 Subject: [PATCH 07/14] Bumpy cibuildwheel action version --- .github/workflows/wheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index fdfab0834..272858e0a 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -17,7 +17,7 @@ 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.{9,10,11,12} From 0b00a2c0e2796fbf8dcd97b70920d1d77bff80bd Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Mon, 18 Nov 2024 09:38:54 +0100 Subject: [PATCH 08/14] np.NINF to -np.inf for np2.0 compatibility --- src/simsopt/_core/optimizable.py | 4 ++-- tests/core/test_dofs.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/simsopt/_core/optimizable.py b/src/simsopt/_core/optimizable.py index e95228b1d..58a3d6ba7 100644 --- a/src/simsopt/_core/optimizable.py +++ b/src/simsopt/_core/optimizable.py @@ -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 """ @@ -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) diff --git a/tests/core/test_dofs.py b/tests/core/test_dofs.py index 1c6c00c4a..452f7ffe7 100755 --- a/tests/core/test_dofs.py +++ b/tests/core/test_dofs.py @@ -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]) @@ -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, From ab6f79932f2b3f686759267851fd02a49eff7544 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 21 Nov 2024 16:12:35 +0100 Subject: [PATCH 09/14] Missing J in eval function of docs --- docs/source/example_islands.rst | 8 ++++---- docs/source/example_quasisymmetry.rst | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/example_islands.rst b/docs/source/example_islands.rst index a85b68a9a..674777ff0 100644 --- a/docs/source/example_islands.rst +++ b/docs/source/example_islands.rst @@ -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 diff --git a/docs/source/example_quasisymmetry.rst b/docs/source/example_quasisymmetry.rst index 1f18b4224..f8689fffb 100644 --- a/docs/source/example_quasisymmetry.rst +++ b/docs/source/example_quasisymmetry.rst @@ -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.J, 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 / @@ -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.J, 0, 1)]) It can be seen here that we are seeking a configuration with aspect ratio 6, and iota slightly below 0.5. From 6c2ba240cb57a9110cba7b10018f0693e9ea26eb Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 21 Nov 2024 16:18:15 +0100 Subject: [PATCH 10/14] residuals, not J of course --- docs/source/example_quasisymmetry.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/example_quasisymmetry.rst b/docs/source/example_quasisymmetry.rst index f8689fffb..e46d04085 100644 --- a/docs/source/example_quasisymmetry.rst +++ b/docs/source/example_quasisymmetry.rst @@ -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.J, 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. From e806fea29c15bcd83582567bb84129e6014205aa Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 21 Nov 2024 16:20:14 +0100 Subject: [PATCH 11/14] residuals not J --- docs/source/example_quasisymmetry.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/example_quasisymmetry.rst b/docs/source/example_quasisymmetry.rst index e46d04085..407343af7 100644 --- a/docs/source/example_quasisymmetry.rst +++ b/docs/source/example_quasisymmetry.rst @@ -268,7 +268,7 @@ axisymmetric:: # Define objective function prob = LeastSquaresProblem.from_tuples([(vmec.aspect, 6, 1), (vmec.mean_iota, 0.42, 1), - (qs.J, 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 / From 82d0471d69028d1fe2c24a190b953759e2b013e0 Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Thu, 21 Nov 2024 19:49:39 -0500 Subject: [PATCH 12/14] Try with downgraded upload-artifact version in wheel.yml --- .github/workflows/wheel.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 272858e0a..2f21606bb 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -28,7 +28,7 @@ jobs: CIBW_SKIP: cp27-* cp36-* cp37-* cp38-* CIBW_DEPENDENCY_VERSIONS: latest - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v3 with: path: ./wheelhouse/*.whl @@ -56,7 +56,7 @@ jobs: - name: Build sdist run: python -m build -s -o dist . - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v3 with: path: dist/*.tar.gz From 6b29fdfd94abe1ddbcd081f3cfff5436f8e4a263 Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Thu, 21 Nov 2024 20:24:04 -0500 Subject: [PATCH 13/14] Update conda_build_config.yaml --- conda.recipe/conda_build_config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/conda.recipe/conda_build_config.yaml b/conda.recipe/conda_build_config.yaml index 364f82234..fc418211e 100644 --- a/conda.recipe/conda_build_config.yaml +++ b/conda.recipe/conda_build_config.yaml @@ -2,7 +2,6 @@ numpy: - 1.23 - 1.24 python: - - 3.8 - 3.9 - 3.10 - 3.11 From d6bea2bd62b76f46e0a3bbcdecf1944a35d5b92b Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Fri, 22 Nov 2024 09:24:36 -0500 Subject: [PATCH 14/14] Update wheel.yml --- .github/workflows/wheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 2f21606bb..7a80408a6 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -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 + - uses: actions/download-artifact@v3 with: name: artifact path: dist