-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Making this a subissue to switching to a standardized spline package since there's no use in doing this before.
Right now, our usage of splines is all over the place in the vacuum module. For example:
- We have the
periodic_cubic_derivfunction for thedx/z_dthetasplines (ininitialize_plasma_surface!)
# Plasma boundary theta derivative: length mth with θ = [0, 1)
θ_grid = range(; start=0, length=mtheta, step=2π/mtheta)
dx_dtheta = periodic_cubic_deriv(θ_grid, x_plasma)
dz_dtheta = periodic_cubic_deriv(θ_grid, z_plasma)- Sometimes, we just call
cubic_spline_interpolationdirectly (inkernel!)
# Used for Z'_θ and X'_θ in eq.(51)
spline_x = cubic_spline_interpolation(theta_grid, x_sourcepoints; extrapolation_bc=Interpolations.Periodic())
spline_z = cubic_spline_interpolation(theta_grid, z_sourcepoints; extrapolation_bc=Interpolations.Periodic())
dx_dtheta = [Interpolations.gradient(spline_x, t)[1] for t in theta_grid]
dz_dtheta = [Interpolations.gradient(spline_z, t)[1] for t in theta_grid]- Sometimes, we just use
cubic_spline_interpolationwith no BCs (ininterp_to_new_grid)
# Input grids are from [0, 1] inclusive, since no interpolants will fall outside of this, we don't need periodic extrapolation
θin = range(0.0, 1.0; length=mtheta_in)
itp = cubic_spline_interpolation(θin, vecin)- And sometimes, we use the hardcoded lagrange1D interpolation (in
distribute_to_equal_arc_grid)
# Calculate dx/dt and dz/dt using Lagrange interpolation (order 3)
_, d_xin = lagrange1d(theta_in1, xin1, mtheta1, 3, theta, 1)
_, d_zin = lagrange1d(theta_in1, zin1, mtheta1, 3, theta, 1)This is super confusing and could definitely be simplified (and can easily mask hidden bugs), considering we're splining the same thing almost every time and in a nearly identical way (a x/z grid over theta that ranges from [0, 2pi). Once we have a standardized spline package, we should go through and ensure a consistent usage of splines
Reactions are currently unavailable