def __init__ (self) : self.Rmin = 0.0 self.Rmax = 0.0 self.BtRmin = 0.0 self.al, self.bl, self.cl = 0.0, 0.0, 0.0 self.p0, self.p1, self.p2, self.p3 = 0.0, 0.0, 0.0, 0.0 self.a_psi, self.b_psi, self.c_psi, self.d_psi = 0.0, 0.0, 0.0, 0.0 self.axis = -1 self.axis_label = -1 self.root_err = 1e-4 self.axis_err = 1e-4 self.surfaces = [] # memoization values for psi_solver self.R_saved = 0.0 self.Rh_saved = 0.0 # pressure and flux splines... self.p_s = blob.spline() self.Psi_s = blob.spline() # ...and their derivatives self.dp_s = blob.spline() self.dPsi_s = blob.spline() # memoizatized quantities for for G_s self.G_s_last_i = 0 self.G_s_last_j = 0 self.G_s_K = [] # and the R-Rhat spline for handling the branch cut in G_s self.rPsi_s = blob.spline()
def __init__ (self) : self.Rmin = 0.0 self.Rmax = 0.0 self.axis = -1 # memoization values for psi_solver self.R_saved = 0.0 self.Rh_saved = 0.0 # pressure and flux splines... self.p_s = blob.spline() self.Psi_s = blob.spline() # ...and their derivatives self.dp_s = blob.spline() self.dPsi_s = blob.spline() # memoizatized quantities for for G_s self.G_s_last_i = 0 self.G_s_last_j = 0 self.G_s_K = [] # and the R-Rhat spline for handling the branch cut in G_s self.rPsi_s = blob.spline()
def find_lcfs( self, a, Rin, Rout, Zin, Zout ) : """ Return a spline of a splined interpolation of the last closed flux surface of a CUBE solution. """ NX = len(a) NY = len(a[0]) def r_coor( n ) : return Rin + (Rout - Rin) * ( float(n) / float(NX) ) def z_coor( n ) : return Zin + (Zout - Zin) * ( float(n) / float(NY) ) R = [] for i in range(len(a)) : R.append( r_coor(i) ) roots_lx_top = [] roots_ly_top = [] roots_rx_top = [] roots_ry_top = [] roots_lx_bot = [] roots_ly_bot = [] roots_rx_bot = [] roots_ry_bot = [] s_top = blob.spline() s_bot = blob.spline() s = blob.spline() # WARNING! This function receives input by side # effect! [ R1, R2, s ] def ss( R ) : if R > R1 and R < R2 : try : Z = s.get_Z_for_R( R ) except blob.SplineError, e : print e return 1.0 if type(Z) == float : return Z else : return 1.0 else :
def Rbranch_build (self, aa, RRR ) : """ Builds the rPsi_s spline used to handle the branch cut in the G_s function. aa is a table of flux values across the midplane, and RRR is a table of their radial coordinates. """ psi_max = max(aa) for i in range(len(aa)) : if aa[i] >= psi_max : break i = i + 1 psi = blob.spline() psi.build(RRR,aa) self.rPsi_s.build(aa[:i], RRR[:i]) RR = [] Rbranch = [] psi_min = min(aa[:i]) for j in range(len(aa)) : if j < i : Rbranch.append(RRR[j]) RR.append(RRR[j]) if j >= i and psi.get_Z_for_R(RRR[j]) >= psi_min : Rbranch.append(self.rPsi_s.get_Z_for_R(psi.get_Z_for_R(RRR[j]))) RR.append(RRR[j]) self.rPsi_s.build(RR, Rbranch)
def __init__ (self) : self.Rhat = -1 self.root = -1 self.spline = blob.spline()