Skip to content
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
350 commits
Select commit Hold shift + click to select a range
d36ef4b
Tests passing nicely. Trying to get a version of stage_two_optimizati…
akaptano Sep 26, 2024
9384734
Seems I have gotten the stage two example working with all Jax object…
akaptano Sep 26, 2024
6f499b9
got force minimization working to some extent.
akaptano Sep 26, 2024
af2d133
Playing with the force min example.
akaptano Sep 26, 2024
75c082b
Started attempt at torques.
akaptano Sep 27, 2024
efd3d5b
First attempt at getting a full planar coil optimization working with…
akaptano Sep 27, 2024
6316ef8
After lots of debugging, believe I have gotten the torques and total …
akaptano Sep 27, 2024
2792427
Attempted to get the self force working and immediately find issue th…
akaptano Sep 27, 2024
5a42a44
Added some more examples for scanning and baselining. Added optimizat…
akaptano Sep 29, 2024
e78b247
Did some more fiddling with the QA example to see improvements. With …
akaptano Sep 30, 2024
cf9a995
Didnt do much beyond mess around a bit trying to find what the issue …
akaptano Sep 30, 2024
78c86f0
Scans are too slow on laptop so saving current status and going to tr…
akaptano Oct 1, 2024
c18c648
Some more fiddling with the examples. Saving to try this on a gpu on …
akaptano Oct 2, 2024
2de04a3
Tried speeding up some of the biotsavart stuff but no luck with jax s…
akaptano Oct 3, 2024
4dc12b4
Merge branch 'master' into planar_coil_arrays
akaptano Oct 4, 2024
34cf164
Merged with coil_forces branch
akaptano Oct 4, 2024
1d3fa27
Added some of my metrics. Comparing pointwise and net force minimizat…
akaptano Oct 4, 2024
1194dba
Saving example for running at home on laptop to generate the figures …
akaptano Oct 4, 2024
b3885f6
Added reactor scale examples and new speedup python code for gamma ca…
akaptano Oct 9, 2024
5fbf636
Performed a lot of debugging, including trying to speed up Sienas for…
akaptano Oct 14, 2024
fcd3dff
Merged with recent coil_forces branch changes.
akaptano Oct 14, 2024
426cf6b
Merged with laptop changes
akaptano Oct 14, 2024
8eb1b6b
prepping to try pareto scans with net force and torques.
akaptano Oct 15, 2024
31a1d92
Getting ready to merge with laptop changes, minimal changes to exampl…
akaptano Oct 15, 2024
1089ac9
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Oct 15, 2024
76319eb
Made a bunch of fixes in the direct force and torque calculations. Tr…
akaptano Oct 17, 2024
92cc378
Tweaked the examples a tiny bit.
akaptano Oct 17, 2024
68219b4
Some more tweaks to the examples to get rid of interlocking coils and…
akaptano Oct 17, 2024
97d9acb
More example tweaking.
akaptano Oct 17, 2024
9801fe5
Added updated examples.
akaptano Oct 23, 2024
bf3dab0
Trying to get the fixed surface dipole example working better.
akaptano Oct 23, 2024
02473f8
Added poincare plotting and example updates.
akaptano Oct 25, 2024
09f4aaa
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Oct 25, 2024
c57a07e
Added new example updates.
akaptano Oct 25, 2024
3bdf169
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Oct 25, 2024
16bb776
Rerunning the fixed orientations one to remove the interlinking coils…
akaptano Oct 25, 2024
8a2e57b
Made some example changes. Need to increase the force weighting on th…
akaptano Oct 25, 2024
aea2f37
Updated the torques to be computed with respect to the coil barycente…
akaptano Oct 29, 2024
beb74ec
More example tweaking. QA example essentially there with params QA_fi…
akaptano Oct 29, 2024
b3d7ac4
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Oct 29, 2024
4802d6e
Merge branch 'master' into planar_coil_arrays
akaptano Oct 29, 2024
5ae14c0
Made some more useful changes. Got the MixedLpCurve class running fas…
akaptano Nov 1, 2024
b08061a
Isolated the weak reference spawning in the jacobian calculation of J…
akaptano Nov 1, 2024
45dd058
Updating laptop branch.
akaptano Nov 2, 2024
cc527f7
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Nov 2, 2024
3f19636
Still struggling to find out why JaxCurves seem to spawn so many opti…
akaptano Nov 4, 2024
b0243bf
Fixed a bug from when i added openmp loops in the c++ files for curve…
akaptano Nov 7, 2024
ff70274
Did nothing beyond tune the QH example a bit.
akaptano Nov 8, 2024
ec33cdd
Trying to finalize examples.
akaptano Nov 13, 2024
cefa722
Got the QA example working well, including getting QFMs working and s…
akaptano Nov 21, 2024
c7ef948
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Nov 21, 2024
ddc1e16
Merge branch 'master' into planar_coil_arrays
akaptano Nov 21, 2024
4c4048c
Added continuation script for QH.
akaptano Nov 25, 2024
7727f8f
Merged with desktop changes.
akaptano Nov 25, 2024
ae98781
Cleaned up the post processing plots. Going to reorganize and delete …
akaptano Nov 27, 2024
318b993
Moved all the planar coil files into separate folder.
akaptano Nov 27, 2024
c2ab3eb
Got the self field unit tests working again, just some normalization …
akaptano Nov 27, 2024
a53d85a
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Nov 27, 2024
6e1e6d9
Merge branch 'master' into planar_coil_arrays
akaptano Nov 27, 2024
2606407
QH example tweaks but mostly just merging ith desktop code.
akaptano Nov 27, 2024
f1fb5f7
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Nov 27, 2024
b47a168
Removing some more files. Adding henneberg example.
akaptano Nov 28, 2024
be71b5e
Okay now adding henneberg example
akaptano Nov 28, 2024
525c170
Added henneberg example.
akaptano Nov 29, 2024
a2e278d
Tweaked all the examples. Tried to rename some stuff. Got the hennebe…
akaptano Dec 1, 2024
b9c7fc4
Updating pareto script. Going to try running it on greene.
akaptano Dec 3, 2024
6fc842d
Adding pareto updates to run on greene in parallel.
akaptano Dec 4, 2024
810a42e
Additional tweaking, switching to laptop.
akaptano Dec 5, 2024
e608730
Merging with desktop changes.
akaptano Dec 10, 2024
3286f1f
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Dec 10, 2024
a80b167
Testing merging.
akaptano Dec 11, 2024
9e629e1
Merge branch 'master' into planar_coil_arrays
akaptano Dec 11, 2024
6746873
Tweaking examples so they reproduce the results in the paper.
akaptano Dec 12, 2024
664ef77
Getting all the eamples reproducing the paper results.
akaptano Dec 13, 2024
b5f2bee
Autopepped all the files, which seems hasnt been done in a while on m…
akaptano Dec 13, 2024
d84735e
Fixed the force tests with downsampling.
akaptano Dec 13, 2024
fa54c27
Did some linting with ruff.
akaptano Dec 13, 2024
18a8c6f
Cleaning up code and writing up tve calculation with my current metho…
akaptano Dec 13, 2024
d05ccfe
Still linting. Added henneberg example without dipoles.
akaptano Dec 14, 2024
b8933f5
Got linting fully working. Added some tests of the self and mutual in…
akaptano Dec 14, 2024
329d266
Working on getting all unit tests running properly on the github CI a…
akaptano Dec 15, 2024
6cc7cfb
Got the TVE working
akaptano Dec 15, 2024
742954c
Adding pareto change from greene runs.
akaptano Dec 15, 2024
a4c3be8
Removed omp functionality from dipoles to check for a race condition …
akaptano Dec 15, 2024
a9158f1
Moved all the coil force stuff to single folder inside 3_Advanced.
akaptano Dec 15, 2024
28a0b4b
Deleting old files.
akaptano Dec 15, 2024
b19ad46
Tweaked pareto runs to do the same for TVE.
akaptano Dec 16, 2024
4f3aea5
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Dec 16, 2024
8cd3ef7
Put back the omp, didnt seem to fix the unit test.
akaptano Dec 16, 2024
c6e5c1b
Merged with laptop changes that moved coil force examples.
akaptano Dec 16, 2024
2ef63db
Fixed the input file in the pareto scan.
akaptano Dec 16, 2024
dcd1a50
played with the tve a bit more in the coil force scan.
akaptano Dec 16, 2024
2793011
Still trying to get unit tests working on github CI, but cannot repro…
akaptano Dec 16, 2024
a9e1378
Did tiny bit of linting.
akaptano Dec 16, 2024
3ec484c
Got the examples running better.
akaptano Dec 16, 2024
a7571fa
Removed some old stuff from RotatedCurve related to previous optimiza…
akaptano Dec 16, 2024
2cea459
Did some TVE runs but results look a big strange so going to debug a …
akaptano Dec 17, 2024
d6327e8
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Dec 17, 2024
88ee6ad
Downsampled tve calculation looks quite accurate still and speeds up …
akaptano Dec 17, 2024
d0d729f
Fixed a dumb bug in the TVE where the magnitude of the currents were …
akaptano Dec 17, 2024
220c0d6
Finished up the TVE scan.
akaptano Dec 18, 2024
0f97eae
Took first stab at redoing the passive coil terms.
akaptano Dec 19, 2024
965500c
Merge branch 'planar_coil_arrays' of https://github.com/hiddenSymmetr…
akaptano Dec 20, 2024
2fc5da8
Added psc example test.
akaptano Dec 20, 2024
18540a0
Amazingly, example seems to be running properly but its too slow beca…
akaptano Dec 20, 2024
bc80c68
Still working on getting the PSC jacobian integrated properly. Is tri…
akaptano Dec 22, 2024
31ead00
Think I went down a wrong road trying to combine the biotsavart objec…
akaptano Dec 25, 2024
5eb4f4f
Got the PSC array working much more effectively by avoiding a call to…
akaptano Dec 26, 2024
f154608
Made the jacobian calculation much faster by swapping jacfwd with jac…
akaptano Dec 27, 2024
d08042b
Debugging. Added a test to see if I can even get dI_dgammas through j…
akaptano Dec 27, 2024
15df425
I tentatively may have fixed the jacobian calculation by just directl…
akaptano Dec 28, 2024
c6cc816
Fixed some lingering bugs. Seems the jacobian is fully working, inclu…
akaptano Dec 28, 2024
af29321
Continuing to clean up the code and speed up the jacobian calculation…
akaptano Dec 28, 2024
3a9997d
Fixed a bug in the A() calculation where I wasnt dividing by the numb…
akaptano Dec 28, 2024
9143cff
Moved the passive coil example files. Fixed lingering bug that the ja…
akaptano Dec 28, 2024
f7907d4
Working on getting a final solution for the schuett-henneberg configu…
akaptano Dec 29, 2024
90ea154
Got the henneberg example finalized. Working on a QH example now. Sav…
akaptano Dec 30, 2024
bfc20a7
Finalizing poincare plots and other postprocessing thngs.
akaptano Jan 4, 2025
6786968
Added CSX files.
akaptano Jan 4, 2025
f3c7ff4
Saving final status of the psc branch before cleaning it up.
akaptano Jan 12, 2025
ec870e4
Committing last changes from desktop, will merge with latest changes …
akaptano Jan 13, 2025
4c66b93
Merge branch 'passive_coil_arrays' of https://github.com/hiddenSymmet…
akaptano Jan 13, 2025
25d8c49
Merge branch 'passive_coil_arrays' of https://github.com/hiddenSymmet…
akaptano Jan 13, 2025
07f3c35
Merge branch 'planar_coil_arrays' into passive_coil_arrays
akaptano Jan 13, 2025
036f698
Some small reorganizing and rerunning for setting up the dipole array…
akaptano Feb 28, 2025
a019f44
Small changes to compare with florians coils.
akaptano Mar 7, 2025
ec84832
small change to coil forces script.
akaptano Mar 14, 2025
3c87248
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Mar 14, 2025
b095f22
Merged with main
akaptano Mar 14, 2025
5a74c3b
Ran ruff, still fixes to make.
akaptano Mar 14, 2025
a9e6435
Did some linting and added Taylor test for all the force and dipole r…
akaptano Mar 14, 2025
c2f63a0
Linting and added doc files.
akaptano Mar 14, 2025
2487bba
Got CSX passive coil example cleaned up, and only requiring one scrip…
akaptano Mar 15, 2025
3330e6f
Made some renaming changes and tried to get both the initial optimiza…
akaptano Mar 16, 2025
9262a73
Still in the process of dipole array script clean up and linting and …
akaptano Mar 16, 2025
2c984c7
Almost got the dipole array examples fully in order. Need to get the …
akaptano Mar 17, 2025
fd39c9f
Tweaking and cleaning the examples. QH example with continuation not …
akaptano Mar 17, 2025
3c199fd
Moved all the postprocessing into a single script. Got the examples w…
akaptano Mar 17, 2025
cb42ed7
Combined the nodipole scripts.
akaptano Mar 17, 2025
9cc8c3d
Added in Jakes tokamak stellarator hybrid example.
akaptano Mar 20, 2025
4953de8
Fixed SchuettHenneberg example to include the bootstrap current contr…
akaptano Mar 24, 2025
b2bc210
Added some linting and improvements on Jakes script, including use th…
akaptano Mar 26, 2025
b8163fd
Added Jakes grid setup to a LP QA reactor scale example. Got it runni…
akaptano Mar 26, 2025
b68e493
Did some linting
akaptano Mar 26, 2025
c5cc698
Merge with wireframe update
akaptano Mar 27, 2025
185567f
Minor fix in the import file.
akaptano Apr 16, 2025
202c1ba
Edited the muse examples.
akaptano Apr 17, 2025
f377670
Cleaned up the passive coil scripts in anticipation for making a Zeno…
akaptano Apr 20, 2025
b5382ef
Did a round of autopep
akaptano Apr 20, 2025
07a2e1e
Linted a bit more. Ran ruff and recommit. Cleaned up the SchuettHenne…
akaptano Apr 20, 2025
ebe5029
Renamed the folder.
akaptano Apr 20, 2025
36eeb25
Added a detailed dipole array tutorial example, as well as renamed so…
akaptano Apr 21, 2025
2617435
Did some linting.
akaptano Apr 21, 2025
9477c09
Deleted old file from Jake.
akaptano Apr 21, 2025
16d6ece
Fixed a bug from a conflict between an initialize_coils function from…
akaptano Apr 21, 2025
57f8c8b
Reorganizing and renaming files while I debug the tests.
akaptano Apr 21, 2025
a19dbc1
Renamed dipole array reproducing files.
akaptano Apr 21, 2025
c45aafa
Made a bunch of files executable to run all the example scripts. Fixe…
akaptano Apr 21, 2025
210a3a2
Fixed some lingering issues running the serial examples.
akaptano Apr 21, 2025
764c06e
Added the zenodo links for both papers.
akaptano Apr 21, 2025
2905a8a
Added all the dipole scripts to run at low resolution if CI is going.
akaptano Apr 21, 2025
704b356
Finalized linting.
akaptano Apr 21, 2025
9930aee
Fixed the CI I think.
akaptano Apr 21, 2025
3612d57
Think I fixed an error in running the coil force examples.
akaptano Apr 21, 2025
94b15de
Merge branch 'master' into passive_coil_arrays
akaptano Apr 25, 2025
fa889c6
Linted and added a lot coverage.
akaptano Apr 26, 2025
caf4ce8
Attempting to rerun code coverage on pull request updates.
akaptano Apr 26, 2025
8501859
Fixed some little bugs in the tests, including a factor of two missin…
akaptano Apr 26, 2025
6123079
Attempted to fix the planar curve test failure in the CI, which appea…
akaptano Apr 27, 2025
fcd7f35
Started fixing a substantial bug I found in the course of checking ou…
akaptano Apr 28, 2025
abd0b4f
Got rid of the pyplot show.
akaptano Apr 28, 2025
760a768
Think I fixed the test error. Going to try and see if the tests pass …
akaptano Apr 28, 2025
3bb65ff
Tiny change to get the Taylor test working on CI.
akaptano Apr 28, 2025
b79f48e
Got the passive coil jacobians looking good with the mixed force and …
akaptano Apr 29, 2025
ca2e826
Linted and fixed the Taylor test.
akaptano Apr 30, 2025
55bd042
Fixed a small error introduced in the inductance calculation when ref…
akaptano Apr 30, 2025
c82ee22
Added some wireframe tests missing from coverage. Wireframe optimizat…
akaptano Apr 30, 2025
e245139
Got the QFM with nontrivial Bnormal_plasma working in the jacobian ca…
akaptano Apr 30, 2025
6322a44
Fix wireframe optimization test with target bnormal
kchammond May 1, 2025
8960f04
Finalized the passive coil example scripts and debugged a little erro…
akaptano May 2, 2025
e3dce55
Merge branch 'passive_coil_arrays' of https://github.com/hiddenSymmet…
akaptano May 2, 2025
f413dec
Did tiny linting on change from Ken.
akaptano May 2, 2025
678c23a
Think I fixed the issue with the force and torque and other objective…
akaptano May 3, 2025
4862fde
Added comments about the optimizable graph blow up issue. Will open a…
akaptano May 3, 2025
734fe08
Added much more rigorous taylor tests for the force terms. Still seei…
akaptano May 5, 2025
9315d34
Attempting a major overhaul of the force and torque calculations. Dep…
akaptano May 5, 2025
ba4fabb
slow work trying to get the new force objectives into shape.
akaptano May 5, 2025
b336ba7
Finally got something decent working in the new coil coil force and t…
akaptano May 6, 2025
cde8bf9
Changed all the dipole and other example files to use the new force a…
akaptano May 6, 2025
2e1d3bb
Linted the code.
akaptano May 6, 2025
432a4fa
Tried fixing the Taylor tests. It looks like the issue that the jacob…
akaptano May 6, 2025
785d407
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano May 7, 2025
7e5c606
Resolved merge conflicts with main branch with autopep pull request m…
akaptano May 7, 2025
b8ea42d
Merge branch 'master' into passive_coil_arrays
akaptano May 7, 2025
8202f24
Linted after merge with main.
akaptano May 7, 2025
6970841
Added some little fixes from Misha review. Deleted 3_Advanced/inputs/…
akaptano May 8, 2025
87f936f
Deleted all the changes to non-relevant example files. deleted all th…
akaptano May 8, 2025
5bcaaec
Deleted a lot more files. Revert a few other changes related to the Q…
akaptano May 8, 2025
535f376
Fixed the init files which I had accidentally swapped.
akaptano May 8, 2025
c7dc84c
Reverted the name change in coil_initialization in the permanent magn…
akaptano May 8, 2025
5b274e8
Readded some files that shouldnt have been deleted, and reverted some…
akaptano May 8, 2025
d70cd33
Fixed the CI error. Did some linting and documentation, responding to…
akaptano May 8, 2025
0a8bae2
Made the fixes initially from Matt. Cleaned up the coil_force_optimiz…
akaptano May 8, 2025
003b4e6
Making a number of simplifications along the lines of Matt Landremans…
akaptano May 8, 2025
578e59b
Think I polished off lingering failing unit tests from all the change…
akaptano May 9, 2025
799f5fe
Fixed a few more unit tests that were perturbed by the changes to the…
akaptano May 9, 2025
0ebb93b
Fixed the ruff check and added coverage, which had decreased because …
akaptano May 9, 2025
37ca7bc
Fixed coils_to_vtk working.
akaptano May 9, 2025
420c44a
Deprecated functions still making the Taylor test fail, so removed th…
akaptano May 9, 2025
3e3374d
added some documentation. got the self force functions to also use th…
akaptano May 9, 2025
18b8319
Forgot to rename the coils in the last commit.
akaptano May 9, 2025
f8188df
1. The CurvePlanarFourier class now is initialized without the stells…
akaptano May 13, 2025
9953db6
Made the recommended fixes from Andrew G. Cleaned up the coil force p…
akaptano May 13, 2025
55f53fb
Few more small changes from Andrews suggestion, fixed a lot of docstr…
akaptano May 13, 2025
c5e3f49
Fix the tests, which failed because optimization_tools.py in examples…
akaptano May 13, 2025
1cbdb5b
Finished off remaining test failures and other comments from Andrew. …
akaptano May 14, 2025
d772aa5
Merged with master branch changes.
akaptano May 14, 2025
02a019d
Merged with curve helical changes from master branch. Added curveheli…
akaptano May 14, 2025
4f3787d
Merge branch 'master' into force_and_torque_overhaul
akaptano May 14, 2025
8aca047
Added a tiny bit of coverage. Checks now that shortest_distance still…
akaptano May 14, 2025
ef96aad
Merge branch 'master' into force_and_torque_overhaul
akaptano May 14, 2025
fc16454
Made a bunch of docstring and other changes along the lines of Mishas…
akaptano May 14, 2025
1eae0b2
Finished off lingering import issues from renaming some parameters.
akaptano May 14, 2025
b2c66c2
Merge branch 'master' into force_and_torque_overhaul
akaptano May 14, 2025
26de6e7
Fixed some docstrings and other things.
akaptano May 14, 2025
e496823
Added tiny amount of coverage. Fixed the setup_uniform_grid function …
akaptano May 15, 2025
066a004
Removed deprecated force objectives, curveplanarellipticalcylindrical…
akaptano May 15, 2025
42e81db
Got the tests running again after all the deletions.
akaptano May 15, 2025
a931cf9
Merge branch 'master' into force_and_torque_overhaul
akaptano May 26, 2025
725c153
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano May 29, 2025
2d05b76
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Jul 10, 2025
8f07751
Merge branch 'jax_curve_PR' into force_and_torque_overhaul
akaptano Jul 11, 2025
d1954bf
Fixed testing issues from merging with jax_curve_PR.
akaptano Jul 11, 2025
9e69e12
Merge branch 'master' into force_and_torque_overhaul
akaptano Jul 11, 2025
e39413d
Corrected the example files to use the new jax curve flag.
akaptano Jul 11, 2025
2612630
Made a new util file with the coil pareto scans and other coil optimi…
akaptano Jul 13, 2025
be428e7
Fixed some unit test and example issues coming from moving all the pa…
akaptano Jul 14, 2025
77e926d
Think I fixed the example failures.
akaptano Jul 14, 2025
0aeb369
Tried to get the unit test folders created correctly.
akaptano Jul 14, 2025
9bb1ffc
Trying to remove the unit test issue.
akaptano Jul 14, 2025
900c7c0
Trying a different way to save the files.
akaptano Jul 14, 2025
ec10885
Improved the code coverage, which had depreciated since the migration…
akaptano Jul 15, 2025
af1545a
Hopefully fixed remaining unit test issues.
akaptano Jul 15, 2025
3cd4aaf
Added paretoset package to be downloaded for unit tests.
akaptano Jul 15, 2025
161ff15
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Aug 14, 2025
8051df9
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Aug 28, 2025
6d239fa
Merge branch 'master' into force_and_torque_overhaul
akaptano Oct 12, 2025
dbc53f3
Added small fix from merge.
akaptano Oct 12, 2025
e9e5b4e
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
akaptano Oct 15, 2025
b80af5d
Merge branch 'master' into force_and_torque_overhaul
akaptano Oct 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .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 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 pandas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is pandas necessary? Curious why we need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for doing database querying in the pareto scans (see optimization_tools.py in the examples)


- name: Install booz_xform
if: contains(matrix.packages, 'vmec') || contains(matrix.packages, 'all')
Expand Down
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 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 pandas

- name: Install booz_xform
run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
tags-ignore: [v*]
pull_request:
branches-ignore: [master]
types: [opened, synchronize, reopened]

jobs:
test:
Expand Down Expand Up @@ -93,7 +94,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
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
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 pandas

- name: Install pyoculus
run: pip install -v git+https://github.com/zhisong/pyoculus
Expand Down
2 changes: 1 addition & 1 deletion examples/2_Intermediate/permanent_magnet_MUSE.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
bs = BiotSavart(coils)

# Calculate average, approximate on-axis B field strength
calculate_on_axis_B(bs, s)
calculate_modB_on_major_radius(bs, s)

# Make higher resolution surface for plotting Bnormal
qphi = 2 * nphi
Expand Down
4 changes: 2 additions & 2 deletions examples/2_Intermediate/permanent_magnet_QA.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
bs = BiotSavart(coils)

# Calculate average, approximate on-axis B field strength
calculate_on_axis_B(bs, s)
calculate_modB_on_major_radius(bs, s)

# Make higher resolution surface for plotting Bnormal
qphi = 2 * nphi
Expand All @@ -102,7 +102,7 @@
Bnormal = np.sum(bs.B().reshape((nphi, ntheta, 3)) * s.unitnormal(), axis=2)

# check after-optimization average on-axis magnetic field strength
calculate_on_axis_B(bs, s)
calculate_modB_on_major_radius(bs, s)

# Set up correct Bnormal from TF coils
bs.set_points(s.gamma().reshape((-1, 3)))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
#!/usr/bin/env python

"""
coil_force_objectives_scan.py
----------------------------

This script scans and compares different force and torque objective terms in stage-two coil optimization
for stellarator design using SIMSOPT. It sets up an optimization problem for magnetic
coils, with selectable force/torque objectives and engineering constraints, and solves it using
SciPy's L-BFGS-B optimizer. The script outputs VTK files for visualization and prints diagnostic
information about the optimization process. The goal is to see how different force/torque/magnetic energy
terms affect the optimization and the various trade-offs. This scan we used to generate the results in the paper:

Kaptanoglu, A.A., Wiedman, A., Halpern, J., Hurwitz, S., Paul, E.J. and Landreman, M., 2025.
Reactor-scale stellarators with force and torque minimized dipole coils.
Nuclear Fusion, 65(4), p.046029.
https://iopscience.iop.org/article/10.1088/1741-4326/adc318/meta

Main steps:
- Parse command-line arguments to select the force/torque objective and its weight.
- Define input parameters for coil geometry, penalties, and weights.
- Set up the magnetic surface and initial coil configuration.
- Construct the objective function as a weighted sum of physics and engineering terms, with the selected force/torque objective.
- Perform a Taylor test to verify gradient correctness.
- Run the optimization and save results.

Usage:
python coil_force_objectives_scan.py <ObjectiveType> <ForceWeight> [<Threshold>]
where <ObjectiveType> is one of: SquaredMeanForce, SquaredMeanTorque, LpCurveForce, LpCurveTorque, B2_Energy, NetFluxes
and <ForceWeight> is the weight for the force/torque term.
<Threshold> is optional for LpCurveForce/LpCurveTorque.

"""
import os
import sys
from pathlib import Path
import shutil
from scipy.optimize import minimize
import numpy as np
from simsopt.geo import create_equally_spaced_curves
from simsopt.geo import SurfaceRZFourier
from simsopt.field import Current, coils_via_symmetries, coils_to_vtk
from simsopt.objectives import SquaredFlux, Weight, QuadraticPenalty
from simsopt.geo import (CurveLength, CurveCurveDistance, CurveSurfaceDistance,
MeanSquaredCurvature, LpCurveCurvature)
from simsopt.field import BiotSavart
from simsopt.field.force import LpCurveForce, \
SquaredMeanForce, SquaredMeanTorque, LpCurveTorque, B2_Energy, NetFluxes
from simsopt.field.selffield import regularization_circ
from simsopt.util import in_github_actions

# --- Argument check and usage warning ---
if len(sys.argv) < 3:
print("\nUsage: python coil_force_objectives_scan.py <ObjectiveType> <ForceWeight> [<Threshold>]")
print(" <ObjectiveType>: SquaredMeanForce, SquaredMeanTorque, LpCurveForce, LpCurveTorque, B2_Energy, NetFluxes")
print(" <ForceWeight>: weight for the force/torque term (float)")
print(" <Threshold>: (optional) threshold for LpCurveForce/LpCurveTorque (float)")
print("\nExample: python coil_force_objectives_scan.py LpCurveForce 1e-3 0.0\n")
sys.exit(1)

###############################################################################
# INPUT PARAMETERS
###############################################################################

# Number of unique coil shapes, i.e. the number of coils per half field period:
# (Since the configuration has nfp = 2, multiply by 4 to get the total number of coils.)
ncoils = 4

# Major radius for the initial circular coils:
R0 = 1.0

# Minor radius for the initial circular coils:
R1 = 0.5

# Number of Fourier modes describing each Cartesian component of each coil:
order = 5

# Weight on the curve lengths in the objective function. We use the `Weight`
# class here to later easily adjust the scalar value and rerun the optimization
# without having to rebuild the objective.
LENGTH_WEIGHT = Weight(1e-1)
LENGTH_TARGET = 15.0

# Threshold and weight for the coil-to-coil distance penalty in the objective function:
CC_THRESHOLD = 0.1
CC_WEIGHT = 1e3

# Threshold and weight for the coil-to-surface distance penalty in the objective function:
CS_THRESHOLD = 0.3
CS_WEIGHT = 1e2

# Threshold and weight for the curvature penalty in the objective function:
CURVATURE_THRESHOLD = 5.
CURVATURE_WEIGHT = 1e-6

# Threshold and weight for the mean squared curvature penalty in the objective function:
MSC_THRESHOLD = 5
MSC_WEIGHT = 1e-6

# Number of iterations to perform:
MAXITER = 200 if not in_github_actions else 10

# File for the desired boundary magnetic surface:
TEST_DIR = (Path(__file__).parent / ".." / ".." / ".." / "tests" / "test_files").resolve()
filename = TEST_DIR / 'input.LandremanPaul2021_QA'

# Directory for output
OUT_DIR = "./coil_forces_scan_" + sys.argv[1] + '_Weight' + sys.argv[2] + '/'
if os.path.exists(OUT_DIR):
shutil.rmtree(OUT_DIR)
os.makedirs(OUT_DIR, exist_ok=True)

###############################################################################
# SET UP OBJECTIVE FUNCTION
###############################################################################

# Initialize the boundary magnetic surface:
nphi = 32 if not in_github_actions else 8
ntheta = 32 if not in_github_actions else 8
s = SurfaceRZFourier.from_vmec_input(filename, range="half period", nphi=nphi, ntheta=ntheta)

qphi = nphi * 2
qtheta = ntheta * 2
quadpoints_phi = np.linspace(0, 1, qphi, endpoint=True)
quadpoints_theta = np.linspace(0, 1, qtheta, endpoint=True)
# Make high resolution, full torus version of the plasma boundary for plotting
s_plot = SurfaceRZFourier.from_vmec_input(
filename,
quadpoints_phi=quadpoints_phi,
quadpoints_theta=quadpoints_theta
)

# Create the initial coils:
base_curves = create_equally_spaced_curves(
ncoils, s.nfp, stellsym=True, R0=R0, R1=R1, order=order, jax_flag=False)
base_currents = [Current(1e5) for i in range(ncoils)]
# Since the target field is zero, one possible solution is just to set all
# currents to 0. To avoid the minimizer finding that solution, we fix one
# of the currents:
base_currents[0].fix_all()

coils = coils_via_symmetries(base_curves, base_currents, s.nfp, True)
base_coils = coils[:ncoils]
bs = BiotSavart(coils)
bs.set_points(s.gamma().reshape((-1, 3)))

a = 0.02
a_list = np.ones(len(coils)) * a
nturns = 100
curves = [c.curve for c in coils]
coils_to_vtk(coils, OUT_DIR + "coils_init", close=True)
pointData = {"B_N": np.sum(bs.B().reshape((nphi, ntheta, 3)) * s.unitnormal(), axis=2)[:, :, None]}
s.to_vtk(OUT_DIR + "surf_init", extra_data=pointData)
bs.set_points(s_plot.gamma().reshape((-1, 3)))
pointData = {"B_N": np.sum(bs.B().reshape((qphi, qtheta, 3)) * s_plot.unitnormal(), axis=2)[:, :, None]}
s_plot.to_vtk(OUT_DIR + "surf_full_init", extra_data=pointData)
bs.set_points(s.gamma().reshape((-1, 3)))

# Define the individual terms objective function:
Jf = SquaredFlux(s, bs)
Jls = [CurveLength(c) for c in base_curves]
Jccdist = CurveCurveDistance(curves, CC_THRESHOLD, num_basecurves=ncoils)
Jcsdist = CurveSurfaceDistance(curves, s, CS_THRESHOLD)
Jcs = [LpCurveCurvature(c, 2, CURVATURE_THRESHOLD) for c in base_curves]
Jmscs = [MeanSquaredCurvature(c) for c in base_curves]
Jlength = QuadraticPenalty(sum(Jls), LENGTH_TARGET)
for c in coils:
c.regularization = regularization_circ(0.05)

if sys.argv[1] == 'SquaredMeanForce':
Jforce = SquaredMeanForce(base_coils, coils)
elif sys.argv[1] == 'SquaredMeanTorque':
Jforce = SquaredMeanTorque(base_coils, coils)
elif sys.argv[1] == 'LpCurveForce':
print('If user did not specify the threshold as the third command line argument, it will be set to zero ')
try:
Jforce = LpCurveForce(base_coils, coils, p=2, threshold=float(sys.argv[3]))
except:
Jforce = LpCurveForce(base_coils, coils, p=2, threshold=0.0)
elif sys.argv[1] == 'LpCurveTorque':
print('If user did not specify the threshold as the third command line argument, it will be set to zero ')
try:
Jforce = LpCurveTorque(base_coils, coils, p=2, threshold=float(sys.argv[3]))
except:
Jforce = LpCurveTorque(base_coils, coils, p=2, threshold=0.0)
elif sys.argv[1] == 'B2_Energy':
Jforce = B2_Energy(coils)
elif sys.argv[1] == 'NetFluxes':
Jforce = sum([NetFluxes(c, coils) for c in base_coils])
else:
print('User did not input a valid Force/Torque objective. Defaulting to no force term')
FORCE_WEIGHT = 1e-100

# Weight on the mean squared force penalty in the objective function
try:
FORCE_WEIGHT = Weight(sys.argv[2])
except:
FORCE_WEIGHT = Weight(1e-100)

JF = Jf \
+ LENGTH_WEIGHT * Jlength \
+ CC_WEIGHT * Jccdist \
+ CS_WEIGHT * Jcsdist \
+ CURVATURE_WEIGHT * sum(Jcs) \
+ MSC_WEIGHT * sum(QuadraticPenalty(J, MSC_THRESHOLD, "max") for J in Jmscs) \
+ FORCE_WEIGHT * Jforce

# We don't have a general interface in SIMSOPT for optimisation problems that
# are not in least-squares form, so we write a little wrapper function that we
# pass directly to scipy.optimize.minimize


def fun(dofs):
"""
Wrapper for the total objective function and its gradient for use with SciPy's optimizer.

Parameters
----------
dofs : np.ndarray
Array of degrees of freedom (optimization variables).

Returns
-------
J : float
Value of the total objective function.
grad : np.ndarray
Gradient of the objective function with respect to dofs.
"""
JF.x = dofs
J = JF.J()
grad = JF.dJ()
BdotN = np.mean(np.abs(np.sum(bs.B().reshape((nphi, ntheta, 3)) * s.unitnormal(), axis=2)))
BdotN_over_B = BdotN / np.mean(bs.AbsB())
outstr = f"J={J:.1e}, Jf={Jf.J():.1e}, ⟨B·n⟩={BdotN:.1e}, ⟨B·n⟩/⟨B⟩={BdotN_over_B:.1e}"
cl_string = ", ".join([f"{J.J():.1f}" for J in Jls])
outstr += f", Len=sum([{cl_string}])={sum(J.J() for J in Jls):.2f}"
outstr += f", C-C-Sep={Jccdist.shortest_distance():.2f}, C-S-Sep={Jcsdist.shortest_distance():.2f}"
length_val = LENGTH_WEIGHT.value * Jlength.J()
cc_val = CC_WEIGHT * Jccdist.J()
cs_val = CS_WEIGHT * Jcsdist.J()
forces_val = FORCE_WEIGHT.value * Jforce.J()
valuestr = f"J={J:.2e}, Jf={Jf.J():.2e}"
valuestr += f", LenObj={length_val:.2e}"
valuestr += f", ccObj={cc_val:.2e}"
valuestr += f", csObj={cs_val:.2e}"
valuestr += f", forceObj={forces_val:.2e}"
outstr += f", F={Jforce.J():.2e}"
outstr += f", ║∇J║={np.linalg.norm(grad):.1e}"
print(outstr)
print(valuestr)
return J, grad


print("""
###############################################################################
# Perform a Taylor test
###############################################################################
""")
print("(It make take jax several minutes to compile the objective for the first evaluation.)")
f = fun
dofs = JF.x
np.random.seed(1)
h = np.random.uniform(size=dofs.shape)
J0, dJ0 = f(dofs)
dJh = sum(dJ0 * h)
for eps in [1e-3, 1e-4, 1e-5, 1e-6, 1e-7]:
J1, _ = f(dofs + eps*h)
J2, _ = f(dofs - eps*h)
print("err", (J1-J2)/(2*eps) - dJh)

###############################################################################
# RUN THE OPTIMIZATION
###############################################################################

dofs = JF.x
print(f"Optimization with FORCE_WEIGHT={FORCE_WEIGHT.value} and LENGTH_WEIGHT={LENGTH_WEIGHT.value}")
res = minimize(fun, dofs, jac=True, method='L-BFGS-B', options={'maxiter': MAXITER, 'maxcor': MAXITER}, tol=1e-12)
coils_to_vtk(coils, OUT_DIR + "coils_opt", close=True)

pointData_surf = {"B_N": np.sum(bs.B().reshape((nphi, ntheta, 3)) * s.unitnormal(), axis=2)[:, :, None]}
s.to_vtk(OUT_DIR + "surf_opt", extra_data=pointData_surf)
bs.set_points(s_plot.gamma().reshape((-1, 3)))
pointData = {"B_N": np.sum(bs.B().reshape((qphi, qtheta, 3)) * s_plot.unitnormal(), axis=2)[:, :, None]}
s_plot.to_vtk(OUT_DIR + "surf_full_opt", extra_data=pointData)
Loading
Loading