init_extended_zgrid Subroutine

public subroutine init_extended_zgrid()

phase shift due to the twist-and-shift boundary condition Usually set to zero for standard local simulation, but can have an effect for global simulations and simulations with low magnetic shear that use periodic boundary conditions everywhere

all periodic modes (e.g., the zonal mode) have no connections phi(kx-kx_shift,-nzgrid) = phi(kx,nzgrid) from twist-and-shift BC for positive (negative) magnetic shear, kx_shift is positive (negative), so start at most positive (negative) kx and progress to smaller (larger) kx values as connections occur figure out how much to shift ikx by to get to the end of the kx chain for positive (negative) magnetic shear, this is the left-most (right-most) theta-theta0 in each set of connected 2pi segments note that theta0 goes from 0 to theta0_max and then from theta0_min back to -dtheta0 first ikx_max=nakx/2+1 theta0s are 0 and all positive theta0 values remainder are negative theta0s theta_0 = kx / ky / shat if ky > 0, then most positive theta_0 corresponds to most positive kx first consider case where shift in kx is negative (corresponds to positive magnetic shear) then consider case where shift in kx is positive note that zero shift case is taken care of by initialization of ikx_shift_end

ikx_shift is how much to shift each ikx by to connect to the next theta0 (from most positive to most negative for positive magnetic shear and vice versa for negative magnetic shear) first consider shift in index for case where shift is negative (corresponds to positive magnetic shear) if ky > 0, then going to more negative theta0 corresponds to going to more negative kx if theta0 is sufficiently positive, shifting to more negative theta0 corresponds to decreasing ikx if a positive theta0 connects to a negative theta0 must do more complicated mapping of ikx if theta0 is negative, then shifting to more negative theta0 corresponds to decreasing ikx if theta0 is sufficiently negative, it has no more negative theta0 with which it can connect theta0 is positive if ky > 0, then going to more positive theta0 corresponds to going to more positive kx if shift in kx, kx_shift, is less than kx-kx_max, then shift by the appropriate amount otherwise, no kx on grid to connect with if kx+kx_shift < 0, then simple shift by neigen if 0 < kx+kx_shift <= kx_max, then more complicated shift to positive set of kx values otherwise, no kx on grid with which to connect this is the number of 2pi poloidal segments in the extended theta domain, which is needed in initializing the reponse matrix and doing the implicit sweep

iz_low(j) is the ig index corresponding to the inboard midplane from below (theta=-pi) within the jth segment iz_mid(j) is the ig index corresponding to the outboard midplane (theta=0) within the jth segment initialize ikxmod to nakx should not be necessary but just in case one tries to access a value beyond nsegments(ie,iky) only do the following once for each independent set of theta0s the assumption here is that all kx are on processor and sequential remap to start at theta0 = theta0_max (theta0_min) for negative (positive) kx shift for this set of connected theta0s this is the number of unique zed values in all segments but the first the first has one extra unique zed value (all others have one grid common with the previous segment due to periodicity)

Arguments

None