surf_rz
Module Contents
- class surf_rz.SurfaceRZFourier(nfp=1, stellsym=True, mpol=1, ntor=0, quadpoints_phi=None, quadpoints_theta=None, dofs=None)
Bases:
spectre.surfaces.surf.SurfaceSurfaceRZFourieris a surface that is represented in cylindrical coordinates using the following Fourier series:\[r(\theta, \phi) = \sum_{m=0}^{m_{\text{pol}}} \sum_{n=-n_{\text{tor}}}^{n_\text{tor}} [ r_{c,m,n} \cos(m \theta - n_{\text{fp}} n \phi) + r_{s,m,n} \sin(m \theta - n_{\text{fp}} n \phi) ]\]and the same for \(z(\theta, \phi)\).
Here, \((r,\phi, z)\) are standard cylindrical coordinates, and theta is any poloidal angle.
Note that for \(m=0\) we skip the \(n<0\) term for the cos terms, and the \(n \leq 0\) for the sin terms.
In addition, in the
stellsym=Truecase, we skip the sin terms for \(r\), and the cos terms for \(z\).- Args:
nfp: The number of field periods. stellsym: Whether the surface is stellarator-symmetric, i.e.
symmetry under rotation by \(\pi\) about the x-axis.
mpol: Maximum poloidal mode number included. ntor: Maximum toroidal mode number included, divided by
nfp. quadpoints_phi: Set this to a list or 1D array to set the \(\phi_j\) grid points directly. quadpoints_theta: Set this to a list or 1D array to set the \(\theta_j\) grid points directly.
- quadpoints_phi
- quadpoints_theta
- mpol = 1
- ntor = 0
- nfp = 1
- stellsym = True
- rc
- zs
- get_dofs()
Return the dofs associated to this surface.
- set_dofs(dofs)
- set_dofs_impl(dofs)
- copy(**kwargs)
Return a copy of the
SurfaceRZFourierobject, but with the specified attributes changed. Keyword arguments accepted:ntheta: number of quadrature points in the theta directionnphi: number of quadrature points in the phi directionmpol: number of poloidal Fourier modes for the surfacentor: number of toroidal Fourier modes for the surfacenfp: number of field periodsstellsym: whether the surface is stellarator-symmetricquadpoints_theta: theta grid pointsquadpoints_phi: phi grid points
- change_resolution(mpol, ntor)
Change the values of mpol and ntor. Any new Fourier amplitudes will have a magnitude of zero. Any previous nonzero Fourier amplitudes that are not within the new range will be discarded.
- to_RZFourier()
No conversion necessary.
- get_rc(m, n)
Return a particular rc Parameter.
- get_rs(m, n)
Return a particular rs Parameter.
- get_zc(m, n)
Return a particular zc Parameter.
- get_zs(m, n)
Return a particular zs Parameter.
- set_rc(m, n, val)
Set a particular rc Parameter.
- set_rs(m, n, val)
Set a particular rs Parameter.
- set_zc(m, n, val)
Set a particular zc Parameter.
- set_zs(m, n, val)
Set a particular zs Parameter.
- fixed_range(mmin, mmax, nmin, nmax, fixed=True)
Set the ‘fixed’ property for a range of m and n values.
All modes with m in the interval [mmin, mmax] and n in the interval [nmin, nmax] will have their fixed property set to the value of the fixed parameter. Note that mmax and nmax are included (unlike the upper bound in python’s range(min, max).)
- darea()
Short hand for Surface.darea_by_dcoeff()
- dvolume()
Short hand for Surface.dvolume_by_dcoeff()
- get_nml()
Generates a fortran namelist file containing the RBC/RBS/ZBC/ZBS coefficients, in the form used in VMEC and SPEC input files. The result will be returned as a string. For saving a file, see the
write_nml()function.
- write_nml(filename: str)
Writes a fortran namelist file containing the RBC/RBS/ZBC/ZBS coefficients, in the form used in VMEC and SPEC input files. To just generate the namelist as a string without saving a file, see the
get_nml()function.- Args:
filename: Name of the file to write.
- extend_via_normal(distance)
Extend the surface in the normal direction by a uniform distance.
- Args:
distance: The distance to extend the surface.
- fourier_transform_scalar(scalar, mpol=None, ntor=None, normalization=None, **kwargs)
Compute the Fourier components of a scalar on the surface. The scalar is evaluated at the quadrature points on the surface. The Fourier uses the conventions of the
SurfaceRZFourierseries, withnpolgoing from-ntortontorandmpolfrom 0 tompoli.e.:\[f(\theta, \phi) = \sum_{m=0}^{mpol} \sum_{n=-npol}^{npol} A^{mn}_s \sin(m\theta - n N_{fp} \phi) + A^{mn}_c \cos(m\theta - n N_{fp} \phi)\]Where the cosine series is only evaluated if the surface is not stellarator symmetric (if the scalar does not adhere to the symmetry of the surface, request the cosine series by setting the kwarg
stellsym=False) By default, the poloidal and toroidal resolution are the same as those of the surface, but different quantities can be specified in the kwargs.- Args:
scalar: 2D array of shape
(numquadpoints_phi, numquadpoints_theta). mpol: maximum poloidal mode number of the transform, ifNone,the mpol attribute of the surface is used.
- ntor: maximum toroidal mode number of the transform if
None, the ntor attribute of the surface is used.
- normalization: (optional) Fourier transform normalization. Can be:
None: forward and back transform are not normalized.float: forward transform is divided by this number.- stellsym: (optional) boolean to override the stellsym attribute
of the surface if you want to force the calculation of the cosine series
- ntor: maximum toroidal mode number of the transform if
- Returns:
2-element tuple
(A_mns, A_mnc), whereA_mnsis a 2D array of shape(mpol+1, 2*ntor+1)containing the sine coefficients, andA_mncis a 2D array of shape(mpol+1, 2*ntor+1)containing the cosine coefficients (these are zero if the surface is stellarator symmetric).
- inverse_fourier_transform_scalar(A_mns, A_mnc, normalization=None, **kwargs)
Compute the inverse Fourier transform of a scalar on the surface, specified by the Fourier coefficients. The quantity must be is evaluated at the quadrature points on the surface. The Fourier transform is defined as \(f(\theta, \phi) = \Sum_{m=0}^{mpol} \Sum_{n=-npol}^{npol} A^{mn}_s \sin(m\theta - n*Nfp*\phi) + A^{mn}_c \cos(m\theta - n*Nfp*\phi)\) Where the cosine series is only evaluated if the surface is not stellarator symmetric. Arguments:
A_mns: 2D array of shape (mpol+1, 2*ntor+1) containing the sine coefficients
- A_mnc: 2D array of shape (mpol+1, 2*ntor+1) containing the cosine coefficients
(these are zero if the surface is stellarator symmetric)
Optional keyword arguments:
- normalization: Fourier transform normalization. Can be:
None: forward and back transform are not normalized float: inverse transform is multiplied by this number
stellsym: boolean to override the stellsym attribute of the surface
- make_rotating_ellipse(major_radius, minor_radius, elongation, torsion=0)
Set the surface shape to be a rotating ellipse with the given parameters.
Values of
elongationlarger than 1 will result in the elliptical cross-section at \(\phi=0\) being taller than it is wide. Values ofelongationless than 1 will result in the elliptical cross-section at \(\phi=0\) being wider than it is tall.The sign convention is such that both the rotating elongation and positive
torsionwill contribute positively to iota according to VMEC’s sign convention.- Args:
major_radius: Average major radius of the surface. minor_radius: Average minor radius of the surface. elongation: Elongation of the elliptical cross-section. torsion: Value to use for the (m,n)=(0,1) mode of RC and -ZS, which
controls the torsion of the magnetic axis.
- gamma_lin(data, quadpoints_phi, quadpoints_theta)
Evaluate the position vector on the surface in Cartesian coordinates, for a list of (phi, theta) points.
- gamma()
- gamma_rz()
- gamma_impl(data, quadpoints_phi, quadpoints_theta)
Evaluate the position vector on the surface in Cartesian coordinates, for a tensor product grid of points in theta and phi.
- get_rz(quadpoints_phi=None, quadpoints_theta=None)
- get_rz_dtheta(quadpoints_phi=None, quadpoints_theta=None)
- plot_spectrum(field='rc', ax=None, figsize=(6, 5), vmin=1, vmax=-9, mpol=None, ntor=None)