surf_henneberg
Module Contents
- class surf_henneberg.SurfaceHenneberg(nfp: int = 1, alpha_fac: int = 1, mmax: int = 1, nmax: int = 0, quadpoints_phi=None, quadpoints_theta=None, dofs=None)
Bases:
spectre.surfaces.surf.SurfaceThis class represents a toroidal surface using the parameterization in Henneberg, Helander, and Drevlak, Journal of Plasma Physics 87, 905870503 (2021). The main benefit of this representation is that there is no freedom in the poloidal angle, i.e. \(\theta\) is uniquely defined, in contrast to other parameterizations like
SurfaceRZFourier. Stellarator symmetry is assumed.In this representation by Henneberg et al, the cylindrical coordinates \((R,\phi,Z)\) are written in terms of a unique poloidal angle \(\theta\) as follows:
\[\begin{split}R(\theta,\phi) = R_0^H(\phi) + \rho(\theta,\phi) \cos(\alpha\phi) - \zeta(\theta,\phi) \sin(\alpha\phi), \\ Z(\theta,\phi) = Z_0^H(\phi) + \rho(\theta,\phi) \sin(\alpha\phi) + \zeta(\theta,\phi) \cos(\alpha\phi),\end{split}\]where
\[\begin{split}R_0^H(\phi) &=& \sum_{n=0}^{nmax} R_{0,n}^H \cos(n_{fp} n \phi), \\ Z_0^H(\phi) &=& \sum_{n=1}^{nmax} Z_{0,n}^H \sin(n_{fp} n \phi), \\ \zeta(\theta,\phi) &=& \sum_{n=0}^{nmax} b_n \cos(n_{fp} n \phi) \sin(\theta - \alpha \phi), \\ \rho(\theta,\phi) &=& \sum_{n,m} \rho_{n,m} \cos(m \theta - n_{fp} n \phi - \alpha \phi).\end{split}\]The continuous degrees of freedom are \(\{\rho_{m,n}, b_n, R_{0,n}^H, Z_{0,n}^H\}\). These variables correspond to the attributes
rhomn,bn,R0nH, andZ0nHrespectively, which are all numpy arrays. There is also a discrete degree of freedom \(\alpha\) which should be \(\pm n_{fp}/2\) where \(n_{fp}\) is the number of field periods. The attributealpha_faccorresponds to \(2\alpha/n_{fp}\), soalpha_facis either 1, 0, or -1. Usingalpha_fac = 0is appropriate for axisymmetry, while values of 1 or -1 are appropriate for a stellarator, depending on the handedness of the rotating elongation.For \(R_{0,n}^H\) and \(b_n\), \(n\) is 0 or any positive integer up through
nmax(inclusive). For \(Z_{0,n}^H\), \(n\) is any positive integer up throughnmax. For \(\rho_{m,n}\), \(m\) is an integer from 0 throughmmax(inclusive). For positive values of \(m\), \(n\) can be any integer from-nmaxthroughnmax. For \(m=0\), \(n\) is restricted to integers from 1 throughnmax. Note that we exclude the element of \(\rho_{m,n}\) with \(m=n=0\), because this degree of freedom is already represented in \(R_{0,0}^H\).For the 2D array
rhomn, functionsset_rhomn()andget_rhomn()are provided for convenience so you can specifyn, since the corresponding array index is shifted bynmax. There are no corresponding functions for the 1D arraysR0nH,Z0nH, andbnsince these arrays all have a first index corresponding ton=0.- Args:
nfp: The number of field periods. alpha_fac: Should be +1 or -1 for a stellarator, depending on the handedness
by which the elongation rotates, or 0 for axisymmetry.
mmax: Maximum poloidal mode number included. nmax: 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.
- nfp = 1
- alpha_fac = 1
- mmax = 1
- nmax = 1
- stellsym = True
- quadpoints_theta
- quadpoints_phi
- allocate()
Create the arrays for the continuous degrees of freedom. Also set the names of the dofs.
- get_rhomn(m, n)
Return a particular \(\rho_{m,n}\) coefficient.
- set_rhomn(m, n, val)
Set a particular \(\rho_{m,n}\) coefficient.
- get_dofs()
Return a 1D numpy array with all the degrees of freedom.
- set_dofs(dofs)
- num_dofs()
Return the number of degrees of freedom.
- set_dofs_impl(v)
Set the shape coefficients from a 1D list/array
- fixed_range(mmax, nmax, fixed=True)
Set the
fixedproperty for a range ofmandnvalues.All modes with
m <= mmaxand|n| <= nmaxwill have their fixed property set to the value of thefixedparameter. Note thatmmaxandnmaxare included.Both
mmaxandnmaxmust be >= 0.For any value of
mmax, thefixedproperties ofR0nH,Z0nH, andrhomnare set. Thefixedproperties ofbnare set only ifmmax > 0. In other words, thebnmodes are treated as havingm=1.
- to_RZFourier(mpol_tgt=None, ntor_tgt=None)
Return a
SurfaceRZFourierobject with the identical shape. This routine implements eq (4.5)-(4.6) in the Henneberg paper, plus m=0 terms for R0 and Z0.
- classmethod from_RZFourier(surf, alpha_fac: int, mmax=None, nmax=None, ntheta=None, nphi=None, verbose=False)
Convert a
SurfaceRZFouriersurface to aSurfaceHennebergsurface.- Args:
surf: The
SurfaceRZFourierobject to convert. mmax: Maximum poloidal mode number to include in the new surface. IfNone,the value
mpolfrom the old surface will be used.- nmax: Maximum toroidal mode number to include in the new surface. If
None, the value
ntorfrom the old surface will be used.- ntheta: Number of grid points in the poloidal angle used for the transformation.
If
None, the value3 * nthetawill be used.- nphi: Number of grid points in the toroidal angle used for the transformation.
If
None, the value3 * nphiwill be used.
- nmax: Maximum toroidal mode number to include in the new surface. If
- classmethod surfaces_from_spectre_xmn(xmn, bnd_rc, bnd_zs, test, alpha_fac=1, nmax=6, mmax=6, ntheta=48, nphi=24, verbose=False)
- classmethod surfaces_to_spectre_xmn(surfaces, test)
- classmethod surfaces_to_spectre_dxmn_dxdof(surfaces, test)
- gamma()
- gammadash1()
- gammadash2()
- 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_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.
- gammadash1_impl(data)
Evaluate the derivative of the position vector with respect to the toroidal angle phi.
- gammadash2_impl(data)
Evaluate the derivative of the position vector with respect to theta.
- normal()
- volume()
- area()
- surf_henneberg.b_min(theta, rc, zs, phi0, cosaphi, sinaphi, mpol, ntor, nfp)
This function is minimized as part of finding b.
- surf_henneberg.b_max(theta, rc, zs, phi0, cosaphi, sinaphi, mpol, ntor, nfp)