Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
bc0da85
Added basic outline for the magnetic field class portion that reads i…
akaptano Jul 6, 2022
41f484b
Added the fake biot savart calculation files to python.cpp so they ar…
akaptano Jul 6, 2022
c5e1a34
wrote something quick and plausible for a fast bfield calculation for…
Jul 6, 2022
6d10c0c
Wrote up plausible simd versions for the B, dB, A, dB calculations fo…
Jul 7, 2022
b5579bf
Made some small comments to the winding surface calculation. Will che…
Jul 7, 2022
741c25f
Fixed the winding surface fields so that the c++ compilation works. A…
akaptano Jul 7, 2022
9fcca7c
Initial commit of CurrentPotential.
Jul 11, 2022
11cadfb
Now compiles.
Jul 12, 2022
51d6dca
Missing import.
Jul 15, 2022
a014413
Added more tests for CurrentPotentialFourier. Now passing.
Jul 31, 2022
2126f69
Changes to SurfaceXYZFourier and SurfaceXYZTensorFourier to be compat…
Jul 31, 2022
8dd6628
Added taylor tests for currentpotential.
Jul 31, 2022
ebb4107
Added net_poloidal/toroidal_current_amperes.
Aug 1, 2022
fd18fe2
Not working yet, but pushing intermediate changes.
Aug 1, 2022
3885669
Added an easy test problem (Jackson 5.32) that works nicely with the …
akaptano Aug 3, 2022
7f26077
I think I fixed the issues with surface inheritance.
Aug 4, 2022
64b11f5
Fix test file location and CurrentPotential -> CurrentPotentialFourier.
Aug 4, 2022
fe546c1
Intermediate commit of CurrentPotential.
Aug 5, 2022
6d14651
CurrentPotential inheritance working, but not Surface inheritance...
Aug 7, 2022
05a965d
Found workaround for CurrentPotential inheritance error. Test now pas…
Aug 8, 2022
31d890b
Forgot to push one file.
Aug 8, 2022
787c7d1
Got the infinitesimal current loop calculation working correctly agai…
akaptano Aug 19, 2022
37ca769
Added regcoil comparison test for W7-X. Not quite passing.
Aug 31, 2022
3784a12
Providing ntheta, nphi, and quadpoints now optional in CurrentPotenti…
Aug 31, 2022
e38535b
Added testing files.
Aug 31, 2022
64488d7
Linting.
Aug 31, 2022
b728a0e
Linting.
Aug 31, 2022
438bffd
Initial commit with K matrix.
Sep 7, 2022
142b4d4
Beginning to implement K Tikhonov solve.
Sep 8, 2022
87ed71c
Merging master into regcoil to get the newer changes.
akaptano Sep 14, 2022
47a6403
Added CurrentPotentialSolve.
Sep 15, 2022
6baced7
Merge branch 'master' into regcoil
akaptano Sep 20, 2022
799611b
Trying to get surfacerz fourier object to initialize correctly. Think…
akaptano Sep 20, 2022
46015b0
Attempt to reconcile the surface initializations between the current …
akaptano Sep 20, 2022
737d1a4
Trying to get the branch consistent with the Surface class in the mai…
akaptano Sep 20, 2022
58a3000
Fixed most of the issues by deleting the winding surface in the c++ p…
akaptano Sep 22, 2022
5049933
Merge branch 'master' into regcoil
akaptano Sep 28, 2022
1c1bd62
Okay fixed the weird surface issues I have been having. Basically ini…
akaptano Sep 29, 2022
fcdd2ce
Added something like half the functionality needed for computing the …
akaptano Sep 29, 2022
7d4b53d
Getting close to getting unoptimized REGCOIL solve working with the B…
akaptano Sep 30, 2022
4d169b2
Feel tantalizingly close to getting the regcoil solve working without…
akaptano Sep 30, 2022
19e1a5d
Update to axisymmetric regcoil with save_level=0.
Oct 3, 2022
bf4091b
Added nescin files.
Oct 3, 2022
5bf3d4c
Added regcoil input files.
Oct 3, 2022
51cdbf7
Checking just B-GI calculationn for now, which is currently in disagr…
akaptano Oct 3, 2022
7f48a85
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
akaptano Oct 3, 2022
0bbe724
K_rhs now agrees with regcoil.
Oct 5, 2022
168a325
Linear solve with only K now works.
Oct 5, 2022
2819857
Adding tinny change so can merge with Elizbaths fixes.
akaptano Oct 13, 2022
80242af
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
akaptano Oct 13, 2022
74f4986
Merge branch 'master' into regcoil
akaptano Oct 13, 2022
bacddcd
Commited some changes so I can do a git pull.
akaptano Oct 25, 2022
7dff154
Merge branch 'master' into regcoil
akaptano Oct 25, 2022
39bcb2a
Added from_netcdf class method for CurrentPotentialFourier.
Oct 26, 2022
1b58d08
Added from_netcdf class method for CurrentPotentialSolveTikhnov.
Oct 26, 2022
723bd2b
Fixed an error that was preventing B-GI from being computed correctly…
akaptano Oct 26, 2022
c8b74b0
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
akaptano Oct 26, 2022
82b394e
Linted and almost have the full regcoil calculation and example worki…
akaptano Oct 31, 2022
2c9cff8
Okay I think the regcoil solve is actually working correctly in the c…
akaptano Nov 1, 2022
325998e
Changed test file back to w7x_infty
akaptano Nov 1, 2022
91f4f62
Lower resolution stellarator regcoil files for faster testing.
Nov 17, 2022
4f29ea6
Fix to dofs definition for stellarator symmetry breaking. Added optio…
Nov 17, 2022
e7d5333
Some modification to the solve object to initialize with plasma surfa…
Nov 17, 2022
ec30fc4
Cleanup of test using from_netcdf class methods.
Nov 17, 2022
eb1a5ab
Cleanup of tests using from_netcdf class methods. Stellarator symmetr…
Nov 17, 2022
776240a
Added stellarator symmetry breaking regcoil test file.
Nov 17, 2022
bf79be0
Commiting to get most recent changes, then try to debug small Bfield …
akaptano Nov 26, 2022
cf86ca9
Got changes from Elizabeth debugging
akaptano Nov 26, 2022
a876cb8
Merge branch 'master' into regcoil
akaptano Nov 26, 2022
cd1ed5a
Did some linting and merged main branch.
akaptano Nov 26, 2022
0db8732
Merge branch 'master' into regcoil
akaptano Nov 30, 2022
df935d9
Simplified the BiotSavart calculation, getting rid of the XSIMD and o…
akaptano Nov 30, 2022
e8587ed
Removing xsmid and openmp from currentpotentialfourier for debugging.
Dec 8, 2022
7298a50
For benchmarking, reimplemented two methods for computing Bnormal.
Dec 9, 2022
f793da9
Revert xsimd and openmp in CurrentPotentialFourier.
Dec 16, 2022
01d7b02
Added back in the xsimd and openmp calculations of biot savart. Added…
akaptano Dec 16, 2022
69fade9
Found the bug. Needed to reshape the coil normal vector before passin…
akaptano Dec 17, 2022
f3e0164
Started an example with paraview plotting, and noticing that it is no…
akaptano Dec 17, 2022
b042632
Fixed set_dofs.
Dec 18, 2022
7a4d0e8
Modification to test now that set_dofs is fixed.
Dec 18, 2022
7f0ecc6
Added some documentation. Got the lasso solve in there, but not worki…
akaptano Dec 18, 2022
cc745d5
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
akaptano Dec 18, 2022
0f42ca9
Got the examples fully working, including with the L1 norm. Trying to…
akaptano Dec 18, 2022
677b8c7
Think my example should be working with both l2 and l1 results, but n…
akaptano Dec 19, 2022
1730a06
Somehow broke the K_rhs calculation. Commiting and pushing so I can s…
akaptano Dec 19, 2022
89ed0f7
Fixed the issue in test_regcoil. Had a leftover factor of 2 in the np…
akaptano Dec 19, 2022
13b4c8e
Think I have found the source of (some?) the issues. The current pote…
akaptano Dec 19, 2022
8891ce4
Added a quick fix in the current potential fourier python initializat…
akaptano Dec 20, 2022
2ff32f9
Okay, fixed the f_B and f_K errors for the most part. Realized that I…
akaptano Dec 21, 2022
b867bc1
Going to merge in main branch real quick.
akaptano Dec 22, 2022
d14751c
Merge branch 'master' into regcoil
akaptano Dec 22, 2022
28d3d2e
Still not quite getting the correct f_K (computing the |Ax - b|2 rela…
akaptano Dec 23, 2022
bfa4f65
Still failing to find the issue with computing fK. Presumably there i…
akaptano Dec 23, 2022
90fae5f
Fix to setting of net_poloidal/toroidal_current_amperes.
Dec 24, 2022
9235611
Got the fK calculation working from the baseline matrices. Got L1 wor…
akaptano Jan 3, 2023
e9a3449
Got an example working that appears to show L1 is doing what we expec…
akaptano Jan 3, 2023
f78f6d3
Added some documentation and cleaned up a bit. Got the example workin…
akaptano Jan 3, 2023
dfcdf0c
Updated the example to produce fB vs fK plots and so on for high reso…
akaptano Jan 4, 2023
eb7ae39
Working on the fb vs fk plots still. some small changes to plot both …
akaptano Jan 4, 2023
169f3cf
Fixed the two issues exposed from the example script. The first was t…
akaptano Jan 7, 2023
b508229
Made a bunch of changes to get the FISTA algorithm working faster, wi…
akaptano Jan 9, 2023
3adbcee
Switching to pm branch to fix something. Most updates here getting th…
akaptano Jan 10, 2023
6e5f49c
Cleaned up the tests and winding surface example script. Ran the exam…
akaptano Jan 10, 2023
fa52fbd
Fixed some lingering issues in the tests and example, such as not con…
akaptano Jan 10, 2023
41bb72d
Hopefully last few weeks to get the lasso tests and example working j…
akaptano Jan 10, 2023
f4d4aba
Tiny change to get the objective history plotted correctly (was savin…
akaptano Jan 11, 2023
d10d753
Fix to WindingSurface for stellsym=False.
Jan 23, 2023
140d38b
Ensuring m = 0 and n <= 0 don't contribute to Phidash.
Jan 24, 2023
082384e
Swapped axisymmetric asym test for near-axis test. Now passes up to B…
Jan 30, 2023
fa49106
Remove unnecessary comment.
Jan 30, 2023
1d18a15
Merged with main branch.
Feb 20, 2023
2733de2
Added a method in the currentpotentialsolve class to write out a full…
Feb 20, 2023
86f1647
Slowly figuring out how to write netcdf files in python. I think I ha…
akaptano Feb 21, 2023
3ce1e34
Fixed a bunch of the non-stellarator-symmetric bugs. Almost got the f…
akaptano Feb 27, 2023
dc50698
Merge branch 'master' into regcoil
akaptano Feb 27, 2023
7853f23
Got rid of the Phic(0,0) component, as should be. Fixed the unit test…
akaptano Feb 28, 2023
11bd94e
Added and reran the example to check still working with everythiing. …
akaptano Feb 28, 2023
533d055
Added L1 variables to the regcoil write unit tests.
akaptano Mar 7, 2023
ceb4258
Bug at mpol > 16 appears to be because Ak matrix gets large enough th…
akaptano Mar 8, 2023
f3b693c
Got rid of print statement in cpp file.
akaptano Mar 8, 2023
278222d
Added better plotting and reran the example script. Added option to i…
akaptano Mar 9, 2023
ae449bf
Small change to the example script that Im committing to switch to ot…
akaptano Mar 9, 2023
d86500e
Another small change before switching branches/
akaptano Mar 9, 2023
e8c66ef
Trying to figure out how to plot the currentpotential with its secula…
akaptano Mar 10, 2023
92b14d9
Added bug fix where current_potential_thetazeta was not getting writt…
akaptano Mar 10, 2023
6d3489a
Merged master into regcoil, resolved merge conflicts
landreman Oct 3, 2023
cf97636
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
Nov 23, 2023
9d23aa3
net_toroidal/poloidal_current_amperes -> net_toroidal/poloidal_curren…
Nov 23, 2023
4e80026
Fix to surface reading.
Jan 17, 2024
54251e8
Modifying CurrentPotentialSolve init to calculate B_GI, rather than r…
Feb 15, 2024
ef26800
Fixed the issue with calculating K in different ways and added it to …
akaptano Jul 26, 2024
cc5d221
Fixed the nnorm scaling in the L1 norm I think.
Jul 28, 2024
b1abe82
Adding an error message for B_normal_plasma with mismatching shape wi…
lankef Jul 31, 2024
fde4543
changing 'from jax.config import config' to 'from jax import config' …
lankef Aug 7, 2024
8471782
Allowing B_normal_plasma to be a scalar, a flattened array, or an arr…
Aug 30, 2024
def6e3f
Merge branch 'master' into regcoil
akaptano Mar 8, 2025
7dbc1e3
Did some linting with autopep script.
akaptano Mar 8, 2025
c68d911
Added the quadcoil objectives and solve so far. Did some linting and …
akaptano Mar 9, 2025
5adfcc4
Added the utils file.
akaptano Mar 9, 2025
b4c76ce
Added the __all__ at the top and the cvxpy util file contents.
akaptano Mar 9, 2025
11f8ab0
Added the plotting utils file.
akaptano Mar 9, 2025
17e4ef6
Added coil utils file.
akaptano Mar 9, 2025
4d8c1ff
Added the simple_L2 test to the unit tests. Got some of the circular …
akaptano Mar 9, 2025
8f7535a
Got a version of the code compiled where the biest and sctl libraries…
akaptano Mar 9, 2025
5505726
Still trying to get BIEST properly incorporated.
akaptano Mar 10, 2025
9200ed3
removing BIEST because QUADCOIL is now a separate code
Sep 26, 2025
8af3aa3
remiving pybind11 from thirdparty (I think this comes from QUADCOIL)
Sep 26, 2025
d202023
Fixing pybind11 version issue and removing unneeded requirements. The…
Sep 26, 2025
e381c27
Removing quadcoil prototype codes because quadcoil is now a separate …
Sep 26, 2025
476392e
Added WindingSurfaceField to __all__
Dec 18, 2025
fffa997
Merge pull request #579 from daringli/regcoil
lankef Dec 18, 2025
45f8477
Adding some basic input shape checks for winding_surface and plasma_…
Jan 16, 2026
4069088
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
Jan 16, 2026
86ff673
Merge branch 'master' into regcoil
Jan 16, 2026
6976545
Fixing cmake
Jan 16, 2026
4366fe6
Merge branch 'master' into regcoil
akaptano Feb 9, 2026
e6b5195
Fix linting.
akaptano Feb 9, 2026
c6e3379
CMakelist changes to get this working properly with the wireframe stu…
akaptano Feb 9, 2026
b25bbc5
Attempt to merge with latest regcoil changes, which I forgot to do be…
akaptano Feb 9, 2026
d4f69fe
Fix linting.
akaptano Feb 9, 2026
5287455
Remove optax and cvxpy requirements.
akaptano Feb 9, 2026
a633d29
Merge branch 'master' into regcoil
akaptano Feb 9, 2026
5c71123
Reduce number of changes with master, lots of little unnecessary spac…
akaptano Feb 9, 2026
a050e6b
Accidentally chopped the winding surface file from CMakeLists, adding…
akaptano Feb 9, 2026
09aaff9
Still debugging unit test and syntax errors. taking a break until thi…
akaptano Feb 9, 2026
1ba9fc6
Remove unnecessary changes and files.
akaptano Feb 10, 2026
fe92c8a
Still getting unit tests up to speed, they are slow too but improveme…
akaptano Feb 10, 2026
e144c17
Regcoil branch still needs serious work. The example in 2_Intermediat…
akaptano Feb 10, 2026
225f4c2
Merge branch 'master' into regcoil
akaptano Feb 11, 2026
f798828
Sped up the C++ calculation of the winding surface Bn. Sped up FISTA …
akaptano Feb 11, 2026
0dc0612
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
akaptano Feb 11, 2026
cc538be
clean up old code in the c++. fix xsimd build on the ci for when xsim…
akaptano Feb 11, 2026
3b9be0f
Attempt to fix remaining ill conditioning ci errors.
akaptano Feb 11, 2026
beddaf0
Fix scipy backup pinv call.
akaptano Feb 11, 2026
f751088
plot poincare data throwing mysterious error on CI, despite having no…
akaptano Feb 11, 2026
3998135
Improve coverage by adding unit tests, try to debug remaining issues.
akaptano Feb 12, 2026
05b9e0d
Fix lingering coverage issues, get unit tests fully working.
akaptano Feb 12, 2026
a90701d
Fix unit test and remaining coverage.
akaptano Feb 13, 2026
075021f
In the process of adding and cleaning up and debugging todds old scri…
akaptano Feb 14, 2026
0873e31
Merge branch 'regcoil' of https://github.com/hiddenSymmetries/simsopt…
akaptano Feb 14, 2026
46ff18f
Helical coil cutting still finicky, committing what I have for now, w…
akaptano Feb 15, 2026
d4b9dc5
Increase coverage on new functions from Todd.
akaptano Feb 17, 2026
c88b7cf
Reduced number of files by combining src and test files for currentpo…
akaptano Feb 18, 2026
c2eff06
Merge branch 'master' into regcoil
akaptano Feb 18, 2026
f22081d
Add more robust example runs for winding_surface_advanced. Still to d…
akaptano Feb 18, 2026
0909257
Fix default stellsym=True in load_CP_and_geometries, which caused err…
akaptano Feb 19, 2026
971c735
Fix unit tests, break up run_cut_coils into lots of private functions…
akaptano Feb 21, 2026
b842e6d
Get coverage up, fix any lingering unit test issues, improve docstrin…
akaptano Feb 21, 2026
d57684a
Get coverage higher.
akaptano Feb 25, 2026
aba9f4c
Merge branch 'master' into regcoil
akaptano Mar 1, 2026
4213ed1
Merge branch 'master' into regcoil
akaptano Mar 23, 2026
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ pybind11_add_module(${PROJECT_NAME}
src/simsoptpp/magneticfield_wireframe.cpp
src/simsoptpp/boozerradialinterpolant.cpp
src/simsoptpp/wireframe_optimization.cpp
src/simsoptpp/python_currentpotential.cpp
src/simsoptpp/currentpotential.cpp
src/simsoptpp/currentpotentialfourier.cpp
src/simsoptpp/winding_surface.cpp
)

set_target_properties(${PROJECT_NAME}
Expand Down
439 changes: 439 additions & 0 deletions examples/2_Intermediate/winding_surface.py

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions examples/3_Advanced/winding_surface_advanced.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/usr/bin/env python3
"""
Cut Coils: Extract discrete coils from a current potential on a winding surface.

This example demonstrates how to extract coil contours from a regularized current
potential (from REGCOIL or simsopt-regcoil) and convert them into simsopt Coil
objects. The workflow includes:

1. Loading current potential data from a NetCDF file (simsopt-regcoil or legacy REGCOIL)
2. Computing the current potential φ and |∇φ| on a (θ, ζ) grid
3. Selecting contours by:
- Interactive double-click selection
- Specifying (θ, ζ) points that lie on desired contours
- Specifying contour level values
- Choosing N contours per field period
4. Classifying contours as window-pane (closed), modular, or helical
5. Computing currents for each contour
6. Converting contours to 3D curves and Coil objects
7. Applying stellarator symmetry to get the full coil set

Usage
-----
From the simsopt root directory:

python winding_surface_advanced.py --surface regcoil_out.hsx.nc

With custom options:

python winding_surface_advanced.py \\
--surface /path/to/simsopt_regcoil_out.nc \\
--ilambda 2 \\
--points "0.5,1.0" "1.0,0.5" \\
--output my_output_dir

For interactive mode (double-click to select contours):

python winding_surface_advanced.py --surface file.nc --interactive

Requirements
------------
- A simsopt-regcoil or REGCOIL NetCDF output file
- For legacy REGCOIL: a surface file (nescin format) for 3D mapping
- matplotlib for contour visualization
"""

import argparse
from pathlib import Path

# Add parent to path for standalone run
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))

from simsopt.util import run_cut_coils

# Default test file
TEST_DIR = (Path(__file__).parent / ".." / ".." / "tests" / "test_files").resolve()
DEFAULT_REGCOIL = TEST_DIR / "regcoil_out.hsx.nc"


def main():
parser = argparse.ArgumentParser(
description="Extract coils from a current potential (REGCOIL / simsopt-regcoil output).",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=__doc__,
)
parser.add_argument(
"--surface",
type=Path,
default=DEFAULT_REGCOIL,
help="REGCOIL or simsopt-regcoil NetCDF file (relative paths are resolved against tests/test_files).",
)
parser.add_argument(
"--ilambda",
type=int,
default=-1,
help="Lambda index (0-based) to use.",
)
parser.add_argument(
"--points",
nargs="*",
type=str,
default=None,
help='(θ,ζ) points as "theta,zeta" for contour selection.',
)
parser.add_argument(
"--no-sv",
action="store_false",
help="Use full (multi-valued) current potential with net toroidal/poloidal currents.",
)
parser.add_argument(
"--interactive",
action="store_true",
help="Use interactive double-click contour selection.",
)
parser.add_argument(
"--output",
type=Path,
default=None,
help="Output directory for VTK and JSON (default: winding_surface_<surface_stem>/).",
)
parser.add_argument(
"--no-plot",
action="store_true",
help="Do not show final coil plot.",
)
parser.add_argument(
"--save",
action="store_true",
help="Save coils to JSON file.",
)
args = parser.parse_args()

points = None
if args.points:
points = []
for s in args.points:
parts = s.split(",")
if len(parts) != 2:
parser.error(f"Invalid point format: {s}. Use theta,zeta")
points.append([float(parts[0]), float(parts[1])])

surface_filename = args.surface if args.surface.is_absolute() else TEST_DIR / args.surface
output_path = args.output or Path(f"winding_surface_{surface_filename.stem}")
run_cut_coils(
surface_filename=surface_filename,
ilambda=args.ilambda,
points=points,
single_valued=not args.no_sv,
interactive=args.interactive,
show_final_coilset=not args.no_plot,
write_coils_to_file=args.save,
output_path=output_path,
)


if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions examples/run_serial_examples
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set -ex
./2_Intermediate/stage_two_optimization_stochastic.py
./2_Intermediate/stage_two_optimization_finite_beta.py
./2_Intermediate/strain_optimization.py
./2_Intermediate/winding_surface.py
./2_Intermediate/permanent_magnet_MUSE.py
./2_Intermediate/permanent_magnet_QA.py
./2_Intermediate/permanent_magnet_PM4Stell.py
Expand All @@ -30,3 +31,7 @@ set -ex
./3_Advanced/stage_two_optimization_finitebuild.py
./3_Advanced/coil_forces.py
./3_Advanced/wireframe_gsco_multistep.py
./3_Advanced/winding_surface_advanced.py --surface regcoil_out.hsx.nc
./3_Advanced/winding_surface_advanced.py --surface regcoil_out.w7x.nc --ilambda 0
./3_Advanced/winding_surface_advanced.py --surface regcoil_out.near_axis.nc --points "0.5,0.5" "1.0,0.3"
./3_Advanced/winding_surface_advanced.py --surface regcoil_out.near_axis_asym.nc --no-sv --output winding_surface_near_axis_asym
2 changes: 2 additions & 0 deletions src/simsopt/field/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .mgrid import *
from .normal_field import *
from .tracing import *
from .currentpotential import *
from .wireframefield import *
from .selffield import *
from .magnetic_axis_helpers import *
Expand All @@ -16,6 +17,7 @@
biotsavart.__all__
+ boozermagneticfield.__all__
+ coil.__all__
+ currentpotential.__all__
+ coilset.__all__
+ magneticfield.__all__
+ magneticfieldclasses.__all__
Expand Down
11 changes: 6 additions & 5 deletions src/simsopt/field/coil.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,15 @@ def coils_to_vtk(coils, filename, close=False, extra_data=None):
ppl = np.asarray([c.gamma().shape[0]+1 for c in curves])
else:
ppl = np.asarray([c.gamma().shape[0] for c in curves])
ppl_cumsum = np.concatenate([[0], np.cumsum(ppl)])

# get the current data, which is the same at every point on a given coil
contig = np.ascontiguousarray
pointData = {}
data = np.concatenate([i*np.ones((ppl[i], )) for i in range(len(curves))])
coil_data = np.zeros(data.shape)
for i in range(len(currents)):
coil_data[i * ppl[i]: (i + 1) * ppl[i]] = currents[i]
coil_data[ppl_cumsum[i]:ppl_cumsum[i+1]] = currents[i]
coil_data = np.ascontiguousarray(coil_data)
pointData['I'] = coil_data
pointData['I_mag'] = contig(np.abs(coil_data))
Expand All @@ -593,20 +594,20 @@ def coils_to_vtk(coils, filename, close=False, extra_data=None):
if close:
coil_force_temp = np.vstack((coil_force_temp, coil_force_temp[0, :]))
coil_torque_temp = np.vstack((coil_torque_temp, coil_torque_temp[0, :]))
coil_forces[i * ppl[i]: (i + 1) * ppl[i], :] = coil_force_temp
coil_torques[i * ppl[i]: (i + 1) * ppl[i], :] = coil_torque_temp
coil_forces[ppl_cumsum[i]:ppl_cumsum[i+1], :] = coil_force_temp
coil_torques[ppl_cumsum[i]:ppl_cumsum[i+1], :] = coil_torque_temp

# copy force and torque data over to pointwise data on a coil curve
coil_data = np.zeros((data.shape[0], 3))
for i in range(len(coils)):
coil_data[i * ppl[i]: (i + 1) * ppl[i], :] = net_forces[i, :]
coil_data[ppl_cumsum[i]:ppl_cumsum[i+1], :] = net_forces[i, :]
coil_data = np.ascontiguousarray(coil_data)
pointData['NetForces'] = (contig(coil_data[:, 0]),
contig(coil_data[:, 1]),
contig(coil_data[:, 2]))
coil_data = np.zeros((data.shape[0], 3))
for i in range(len(coils)):
coil_data[i * ppl[i]: (i + 1) * ppl[i], :] = net_torques[i, :]
coil_data[ppl_cumsum[i]:ppl_cumsum[i+1], :] = net_torques[i, :]
coil_data = np.ascontiguousarray(coil_data)

# Add pointwise force and torque data to the dictionary
Expand Down
Loading
Loading