Skip to content

Commit

Permalink
More linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkumar committed Oct 30, 2023
1 parent bc18100 commit 7fe0dda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extend-exclude = ["thirdparty"]
"__init__.py" = ["E402","F401"]
"src/simsopt/field/magneticfieldclasses.py" = ["E743"]
"src/simsopt/mhd/bootstrap.py" = ["F841"]
"src/simsopt/mhd/vmec_diagnostics.py" = ["F841"]
"tests/verify_MPI_not_initialized.py" = ["F401"]
"tests/geo/test_plot.py" = ["F401"]
"tests/geo/test_curve.py" = ["F401"]
Expand Down
14 changes: 5 additions & 9 deletions src/simsopt/field/magneticfieldclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def _B_impl(self, B):

def _dB_by_dX_impl(self, dB):
points = self.get_points_cart_ref()
phi = np.arctan2(points[:, 1], points[:, 0])
R = np.sqrt(np.square(points[:, 0]) + np.square(points[:, 1]))

x = points[:, 0]
Expand All @@ -66,8 +65,6 @@ def _dB_by_dX_impl(self, dB):

def _d2B_by_dXdX_impl(self, ddB):
points = self.get_points_cart_ref()
x = points[:, 0]
y = points[:, 1]
ddB[:] = 2*self.B0*self.R0*np.multiply(
1/(points[:, 0]**2+points[:, 1]**2)**3, np.array([
[[3*points[:, 0]**2+points[:, 1]**3, points[:, 0]**3-3*points[:, 0]*points[:, 1]**2, np.zeros((len(points)))], [
Expand Down Expand Up @@ -397,7 +394,6 @@ def _B_impl(self, B):
k = np.sqrt(1-np.divide(np.square(alpha), np.square(beta)))
ellipek2 = ellipe(k**2)
ellipkk2 = ellipk(k**2)
gamma = np.square(points[:, 0]) - np.square(points[:, 1])
B[:] = np.dot(self.rotMatrix, np.array(
[self.Inorm*points[:, 0]*points[:, 2]/(2*alpha**2*beta*rho**2+1e-31)*((self.r0**2+r**2)*ellipek2-alpha**2*ellipkk2),
self.Inorm*points[:, 1]*points[:, 2]/(2*alpha**2*beta*rho**2+1e-31)*((self.r0**2+r**2)*ellipek2-alpha**2*ellipkk2),
Expand Down Expand Up @@ -666,7 +662,6 @@ def _toVTK(self, vtkname):
mx = np.ascontiguousarray(self.m_vec[:, 0])
my = np.ascontiguousarray(self.m_vec[:, 1])
mz = np.ascontiguousarray(self.m_vec[:, 2])
mmag = np.sqrt(mx ** 2 + my ** 2 + mz ** 2)
mx_normalized = np.ascontiguousarray(mx / self.m_maxima)
my_normalized = np.ascontiguousarray(my / self.m_maxima)
mz_normalized = np.ascontiguousarray(mz / self.m_maxima)
Expand All @@ -680,11 +675,12 @@ def _toVTK(self, vtkname):
mtheta_normalized = np.ascontiguousarray(mtheta / self.m_maxima)

# Save all the data to a vtk file which can be visualized nicely with ParaView
data = {"m": (mx, my, mz), "m_normalized": (mx_normalized, my_normalized, mz_normalized), "m_rphiz": (mr, mphi, mz), "m_rphiz_normalized": (mr_normalized, mphi_normalized, mz_normalized), "m_rphitheta": (mrminor, mphi, mtheta), "m_rphitheta_normalized": (mrminor_normalized, mphi_normalized, mtheta_normalized)}
data = {"m": (mx, my, mz), "m_normalized": (mx_normalized, my_normalized, mz_normalized),
"m_rphiz": (mr, mphi, mz), "m_rphiz_normalized": (mr_normalized, mphi_normalized, mz_normalized),
"m_rphitheta": (mrminor, mphi, mtheta),
"m_rphitheta_normalized": (mrminor_normalized, mphi_normalized, mtheta_normalized)}
from pyevtk.hl import pointsToVTK
pointsToVTK(
str(vtkname), ox, oy, oz, data=data
)
pointsToVTK(str(vtkname), ox, oy, oz, data=data)


class Dommaschk(MagneticField):
Expand Down
4 changes: 0 additions & 4 deletions src/simsopt/mhd/vmec_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def compute(self):
d_psi_d_s = -self.vmec.wout.phi[-1] / (2 * np.pi)

# First, interpolate in s to get the quantities we need on the surfaces we need.
method = 'linear'

interp = interp1d(vmec.s_half_grid, vmec.wout.iotas[1:], fill_value="extrapolate")
iota = interp(self.surfaces)
Expand Down Expand Up @@ -1277,9 +1276,6 @@ def vmec_fieldlines(vs, s, alpha, theta1d=None, phi1d=None, phi_center=0, plot=F
mnmax = vs.mnmax
xm = vs.xm
xn = vs.xn
mnmax_nyq = vs.mnmax_nyq
xm_nyq = vs.xm_nyq
xn_nyq = vs.xn_nyq

# Now that we have an s grid, evaluate everything on that grid:
iota = vs.iota(s)
Expand Down

0 comments on commit 7fe0dda

Please sign in to comment.