connect_len_bkd.m
SYNTAX: [conlen,crospos,turns] = ...
connect_len_bkd(rlb,zlb,rgg,zgg,brg,bzg,rsb,zsb,Bt,R0,[maxturns])
PURPOSE: Calculate the approximate field line connection length from given
starting points on a subgrid of the standard efit grid to a specified
boundary. Also return the crossing point coords and the number of turns
around the torus required to get there.
INPUTS:
[rsb,zsb]: (r,z) coordinates defining a boundary, the interior of which
specifies the subset of rgg, zgg grid points that are used as
the starting locations of the field lines to follow (meters).
[rlb,zlb]: (r,z) coordinates defining 'limiter' boundary upon which the
field lines impact that terminates the field line length
calculation for each line (meters).
rgg: Vector or matrix of poloidal radii of standard nz x nr tokamak
grid (m)
zgg: Vector or matrix of poloidal z-coords of standard tokamak grid (m)
brg: Radial field value on standard tokamak grid (T)
bzg: Verical field value on standard tokamak grid (T)
Bt: Toroidal field (T) at radius R0
R0: Radius (m) where toroidal field is quoted. Bt(r) = Bt*R0/r
maxturns: Maximum number of toroidal circuits to follow field lines.
Default = 5000 if omitted.
OUTPUTS:
conlen: Vector of approximate length of field lines (meters) starting on
grid points within [rsb,zsb] and ending on [rlb,zlb] defined 'limiter'.
crospos: Matrix of final field line coords as they cross [rlb,zlb].
Rf=crospos(2,:); Zf=crospos(1,:)
turns: Vector of number of toroidal circuits required for field line to
cross [rlb,zlb] boundary.
RESTRICTIONS:
1. Only valid if input fields brg, bzg are the entire poloidal field, so be sure
to add PF coil and vacuum vessel contributions together to form brg, bzg.
2. The grid brg & bzg must be regular in the sense that the poloidal positions
of brg, etc, can be defined by two vectors, rg (columns) and zg (rows).
This is true for the standard tokamak poloidal grids. Substitute grids could
be used if they follow this restriction.
METHOD:
This subroutine approximates the dR and dZ a field line traces out over one
full circuit around the tokamak by calculating the slope the line has at a
starting point in (R,phi) and (Z,phi) space, and intgrating that slope over
2*pi in phi. The connection length is then approximated as 2*pi*R and new
slopes are calculated at the new R=R_old+dR, Z=Z_old+dZ and the process is
iterated until R,Z cross the limiter boundary. The length of the last partial
turn as the line crosses the boundary is NOT added to the total connection
length for that line.
Dependencies