Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strain optimization #346

Merged
merged 48 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2273bf8
first commit for implementing accurate self field
phuslage May 26, 2023
5ab839b
First commit on coil_forces branch
phuslage Jun 6, 2023
1b0a95c
initial commit
phuslage Jun 6, 2023
98ab424
initial commit for strain optimization
phuslage Jun 6, 2023
b96555d
class file for frenet frame finite build
phuslage Jun 6, 2023
3e2c0c5
make basic example work
phuslage Jun 6, 2023
ca39c78
cleanups & comments
phuslage Jun 13, 2023
051abb3
fix typo
phuslage Jun 13, 2023
1e748b4
Initial refactoring.
ejpaul Aug 2, 2023
bf70cfa
Cleanup and refactoring.
ejpaul Aug 4, 2023
d8debdd
Refactoring of strain optimization classes.
ejpaul Aug 6, 2023
d09d909
Adding more documentation.
ejpaul Aug 7, 2023
818d041
Autopep.
ejpaul Aug 7, 2023
87e8e7e
Tests now passing.
ejpaul Aug 8, 2023
72632ae
Autopep.
ejpaul Aug 8, 2023
9926c78
Added unit tests for strains.
ejpaul Aug 8, 2023
acd058f
Added unit tests for strains.
ejpaul Aug 8, 2023
51674cf
Added simple example.
ejpaul Aug 8, 2023
e9f154f
Removed old example.
ejpaul Aug 8, 2023
bff6c2c
Small cleanup.
ejpaul Aug 8, 2023
ee25256
Fix to test.
ejpaul Aug 8, 2023
7ebe834
Delete biotsavart_mod.py
phuslage Aug 16, 2023
1d790b9
Delete self_field.py
phuslage Aug 16, 2023
645add2
minor changes
phuslage Sep 1, 2023
b1c9c59
more minor changes
phuslage Sep 1, 2023
f698fc8
Fix some docs formatting. Renamed strain examples
landreman Sep 2, 2023
8d3e607
Add strain_optimization example to CI
landreman Sep 2, 2023
d04ec4c
Revert changes to CMakeLists.txt.
ejpaul Sep 9, 2023
6c8c9e3
Merge branch 'strain_optimization_cu' of https://github.com/hiddenSym…
ejpaul Sep 9, 2023
6f7e6c6
Added Paz-Soldan reference to example.
ejpaul Sep 9, 2023
d3cffb3
Now using in_github_actions.
ejpaul Sep 9, 2023
3728c0b
Removed strain_plot.py.
ejpaul Sep 9, 2023
a3152d5
Removed unneeded imports.
ejpaul Sep 9, 2023
e565c92
Removed unneeded imports.
ejpaul Sep 9, 2023
7641765
Remove unused imports.
ejpaul Sep 9, 2023
77c1787
Remove unused commits.
ejpaul Sep 9, 2023
50eee3f
Responding to comments.
ejpaul Sep 9, 2023
468ed74
Autopep.
ejpaul Sep 9, 2023
c41f5af
Fixing build errors.
ejpaul Sep 9, 2023
054ecd8
Adding required import.
ejpaul Sep 9, 2023
9a1c51f
Fix typo.
ejpaul Sep 9, 2023
077462e
Including in_github_actions.
ejpaul Sep 9, 2023
705053a
Tweak to test to change coverage.
ejpaul Sep 9, 2023
2e3d79e
Merge branch 'master' of https://github.com/hiddenSymmetries/simsopt
ejpaul Sep 12, 2023
882d7e7
Add unit test to minimize strain for circular coil.
ejpaul Sep 14, 2023
d131aed
Autopep.
ejpaul Sep 14, 2023
26ef5ef
Merged in master.
ejpaul Sep 30, 2023
60329b3
Tidy up docs for strain optimization. Renamed StrainOpt -> CoilStrain.
landreman Sep 30, 2023
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
16 changes: 16 additions & 0 deletions docs/source/simsopt.geo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ simsopt.geo.finitebuild module
:undoc-members:
:show-inheritance:

simsopt.geo.framedcurve module
------------------------------

.. automodule:: simsopt.geo.framedcurve
:members:
:undoc-members:
:show-inheritance:

simsopt.geo.jit module
----------------------

Expand Down Expand Up @@ -108,6 +116,14 @@ simsopt.geo.qfmsurface module
:undoc-members:
:show-inheritance:

simsopt.geo.strain_optimization module
--------------------------------------

.. automodule:: simsopt.geo.strain_optimization
:members:
:undoc-members:
:show-inheritance:

simsopt.geo.surface module
--------------------------

Expand Down
1 change: 0 additions & 1 deletion examples/2_Intermediate/stage_two_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from pathlib import Path
import numpy as np
from scipy.optimize import minimize

from simsopt.field import BiotSavart, Current, coils_via_symmetries
from simsopt.geo import (SurfaceRZFourier, curves_to_vtk, create_equally_spaced_curves,
CurveLength, CurveCurveDistance, MeanSquaredCurvature,
Expand Down
60 changes: 60 additions & 0 deletions examples/2_Intermediate/strain_optimization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python

"""
This script performs an optimization of the HTS tape winding angle
with respect to binormal curvature and torsional strain cost functions as defined in

Paz Soldan, "Non-planar coil winding angle optimization for compatibility with
non-insulated high-temperature superconducting magnets", Journal of Plasma Physics
86 (2020), doi:10.1017/S0022377820001208.

The orientation of the tape is defined with respect to the Frenet-Serret Frame
"""

import numpy as np
from scipy.optimize import minimize
from simsopt.geo import CoilStrain, LPTorsionalStrainPenalty, LPBinormalCurvatureStrainPenalty
from simsopt.geo import FrameRotation, FramedCurveFrenet, CurveXYZFourier
from simsopt.configs import get_hsx_data
from simsopt.util import in_github_actions

MAXITER = 50 if in_github_actions else 400

curves, currents, ma = get_hsx_data(Nt_coils=10, ppp=10)
curve = curves[1]
scale_factor = 0.1
curve_scaled = CurveXYZFourier(curve.quadpoints, curve.order)
curve_scaled.x = curve.x * scale_factor # scale coil to magnify the strains
rot_order = 10 # order of the Fourier expression for the rotation of the filament pack
width = 1e-3 # tape width

curve_scaled.fix_all() # fix curve DOFs -> only optimize winding angle
rotation = FrameRotation(curve_scaled.quadpoints, rot_order)

framedcurve = FramedCurveFrenet(curve_scaled, rotation)

tor_threshold = 0.02 # Threshold for strain parameters
cur_threshold = 0.02

Jtor = LPTorsionalStrainPenalty(framedcurve, p=2, threshold=tor_threshold)
Jbin = LPBinormalCurvatureStrainPenalty(
framedcurve, p=2, threshold=cur_threshold)

strain = CoilStrain(framedcurve, width)
JF = Jtor + Jbin


def fun(dofs):
JF.x = dofs
J = JF.J()
grad = JF.dJ()
outstr = f"Max torsional strain={np.max(strain.torsional_strain()):.1e}, Max curvature strain={np.max(strain.binormal_curvature_strain()):.1e}"
print(outstr)
return J, grad


f = fun
dofs = JF.x

res = minimize(fun, dofs, jac=True, method='L-BFGS-B',
options={'maxiter': MAXITER, 'maxcor': 10, 'gtol': 1e-20, 'ftol': 1e-20}, tol=1e-20)
1 change: 1 addition & 0 deletions examples/run_serial_examples
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set -ex
./2_Intermediate/stage_two_optimization.py
./2_Intermediate/stage_two_optimization_stochastic.py
./2_Intermediate/stage_two_optimization_finite_beta.py
./2_Intermediate/strain_optimization.py
./2_Intermediate/permanent_magnet_MUSE.py
./2_Intermediate/permanent_magnet_QA.py
./2_Intermediate/permanent_magnet_PM4Stell.py
Expand Down
4 changes: 3 additions & 1 deletion src/simsopt/geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .curvexyzfourier import *
from .curveperturbed import *
from .curveobjectives import *

from .framedcurve import *
from .finitebuild import *
from .plotting import *

Expand All @@ -21,6 +21,7 @@
from .surfacerzfourier import *
from .surfacexyzfourier import *
from .surfacexyztensorfourier import *
from .strain_optimization import *

from .permanent_magnet_grid import *

Expand All @@ -33,4 +34,5 @@
surfacegarabedian.__all__ + surfacehenneberg.__all__ +
surfacerzfourier.__all__ + surfacexyzfourier.__all__ +
surfacexyztensorfourier.__all__ + surfaceobjectives.__all__ +
strain_optimization.__all__ + framedcurve.__all__ +
permanent_magnet_grid.__all__)
Loading
Loading