Skip to content

Commit

Permalink
Cleanup and refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejpaul committed Aug 4, 2023
1 parent 1e748b4 commit bf70cfa
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 454 deletions.
17 changes: 6 additions & 11 deletions examples/3_Advanced/strain_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from simsopt.objectives import SquaredFlux
from simsopt.objectives import QuadraticPenalty
from simsopt.geo.strain_optimization_classes import StrainOpt
from simsopt.geo.finitebuild import create_multifilament_grid
from simsopt.geo import create_multifilament_grid, ZeroRotation, FramedCurveFrenet, FrameRotation
# from exportcoils import export_coils, import_coils, import_coils_fb, export_coils_fb
from simsopt.configs import get_ncsx_data
import matplotlib.pyplot as plt
Expand All @@ -26,20 +26,14 @@
curve = curves[0]

# Set up the winding pack
numfilaments_n = 1 # number of filaments in normal direction
numfilaments_b = 1 # number of filaments in bi-normal direction
gapsize_n = 0.02 # gap between filaments in normal direction
gapsize_b = 0.03 # gap between filaments in bi-normal direction
rot_order = 5 # order of the Fourier expression for the rotation of the filament pack

scale = 1
width = 12

# use sum here to concatenate lists
filaments = create_multifilament_grid(curve, numfilaments_n, numfilaments_b, gapsize_n,
gapsize_b, rotation_order=rot_order, frame='frenet')
rotation = FrameRotation(curve.quadpoints,rot_order)
framedcurve = FramedCurveFrenet(curve, rotation)

strain = StrainOpt(filaments[0], width=width)
strain = StrainOpt(framedcurve, width=width)

tor = strain.binormal_curvature_strain()

Expand All @@ -48,8 +42,9 @@
plt.show()

# tor = strain.torsional_strain()
tor_frame = filaments[0].frame_torsion()
tor_frame = framedcurve.frame_torsion()
tor_curve = curve.torsion()
dl = curve.incremental_arclength()

plt.figure()
plt.plot(tor_frame)
Expand Down
4 changes: 2 additions & 2 deletions src/simsopt/field/magneticfieldclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def __init__(self, phi_str):
self.phi_str = phi_str
self.phi_parsed = parse_expr(phi_str)
R, Z, Phi = sp.symbols('R Z phi')
self.Blambdify = sp.lambdify((R, Z, Phi), [self.phi_parsed.diff(R)+1e-30*Phi*R*Z,\
self.phi_parsed.diff(Phi)/R+1e-30*Phi*R*Z,\
self.Blambdify = sp.lambdify((R, Z, Phi), [self.phi_parsed.diff(R)+1e-30*Phi*R*Z, \
self.phi_parsed.diff(Phi)/R+1e-30*Phi*R*Z, \
self.phi_parsed.diff(Z)+1e-30*Phi*R*Z])
self.dBlambdify_by_dX = sp.lambdify(
(R, Z, Phi),
Expand Down
2 changes: 1 addition & 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 Down
Loading

0 comments on commit bf70cfa

Please sign in to comment.