def fieldlines_hlcy_jpar_len(self, r0, th0, ph0): # fl = [] nmax = 1000 maxError = 0.003**2 minB = 1e-4 r1, th1, ph1 = tracer.fieldline(self.brg, self.bthg, self.bphg, \ self.r, self.th, self.ph, r0, th0, ph0, \ nmax, maxError, minB) ## Here, we can compute the field-line helicity by integrating ## A dot B / |B| along each fieldline hlarg = ((self.arg * self.brg) + (self.athg * self.bthg) + (self.aphg * self.bphg)) / (self.bbg) hlcy = tracer.jsq(hlarg, r1, th1, ph1, self.r, self.th, self.ph) jparg = ((self.brg * self.jrg) + (self.bthg * self.jthg) + (self.bphg * self.jphg)) / (self.bbg)**2 jpar = tracer.jsq(jparg, r1, th1, ph1, self.r, self.th, self.ph) # Pack fieldlines into same structure as before (and strip # blank entries): for i in range(0, len(r0)): th2 = th1[i, :] ph2 = ph1[i, :] r2 = r1[i, :] th2 = th2[r2 > 0.0] ph2 = ph2[r2 > 0.0] r2 = r2[r2 > 0.0] fl.append(np.array([r2, th2, ph2])) return hlcy, jpar, fl
def fieldlines_jpar(self, r0, th0, ph0): # fl = [] nmax = 1000 maxError = 0.003**2 minB = 1e-4 r1, th1, ph1 = tracer.fieldline(self.brg, self.bthg, self.bphg, \ self.r, self.th, self.ph, r0, th0, ph0, \ nmax, maxError, minB) ## Here, we can use the existing routine to average |J|^2 along ## the field line to instead average the parallel current. ## Just pass along a computed array of the parallel current. jparg = ((self.brg * self.jrg) + (self.bthg * self.jthg) + (self.bphg * self.jphg)) / (self.bbg)**2 jpar = tracer.njsq(jparg, r1, th1, ph1, self.r, self.th, self.ph) # Pack fieldlines into same structure as before (and strip # blank entries): for i in range(0, len(r0)): th2 = th1[i, :] ph2 = ph1[i, :] r2 = r1[i, :] th2 = th2[r2 > 0.0] ph2 = ph2[r2 > 0.0] r2 = r2[r2 > 0.0] fl.append(np.array([r2, th2, ph2])) return jpar, fl
def fieldlines(self, r0, th0, ph0, cubic): fl = [] nmax = 1000 maxError = 0.003**2 minB = 1e-4 if (cubic): r1, th1, ph1 = tracer.fieldline_cubic(self.brg, self.bthg, self.bphg, \ self.r, self.th, self.ph, r0, th0, ph0, \ nmax, maxError, minB) else: r1, th1, ph1 = tracer.fieldline(self.brg, self.bthg, self.bphg, \ self.r, self.th, self.ph, r0, th0, ph0, \ nmax, maxError, minB) # Pack fieldlines into same structure as before (and strip # blank entries): for i in range(0, len(r0)): th2 = th1[i, :] ph2 = ph1[i, :] r2 = r1[i, :] th2 = th2[r2 > 0.0] ph2 = ph2[r2 > 0.0] r2 = r2[r2 > 0.0] x2 = r2 * np.sin(th2) * np.cos(ph2) y2 = r2 * np.sin(th2) * np.sin(ph2) z2 = r2 * np.cos(th2) fl.append(np.array([x2, y2, z2])) return fl
def fieldlines_sph(self, r0, th0, ph0): fl = [] nmax = 1000 maxError = 0.003**2 minB = 1e-4 r1, th1, ph1 = tracer.fieldline(self.brg, self.bthg, self.bphg, \ self.r, self.th, self.ph, r0, th0, ph0, \ nmax, maxError, minB) # Pack fieldlines into same structure as before (and strip # blank entries): for i in range(0, len(r0)): th2 = th1[i, :] ph2 = ph1[i, :] r2 = r1[i, :] th2 = th2[r2 > 0.0] ph2 = ph2[r2 > 0.0] r2 = r2[r2 > 0.0] fl.append(np.array([r2, th2, ph2])) return fl
def fieldlines_jsq(self, r0, th0, ph0): # fl = [] nmax = 1000 maxError = 0.003**2 minB = 1e-4 r1, th1, ph1 = tracer.fieldline(self.brg, self.bthg, self.bphg, \ self.r, self.th, self.ph, r0, th0, ph0, \ nmax, maxError, minB) jsq = tracer.jsq(self.jjg**2, r1, th1, ph1, self.r, self.th, self.ph) # Pack fieldlines into same structure as before (and strip # blank entries): for i in range(0, len(r0)): th2 = th1[i, :] ph2 = ph1[i, :] r2 = r1[i, :] th2 = th2[r2 > 0.0] ph2 = ph2[r2 > 0.0] r2 = r2[r2 > 0.0] #x2 = r2*np.sin(th2)*np.cos(ph2) #y2 = r2*np.sin(th2)*np.sin(ph2) #z2 = r2*np.cos(th2) fl.append(np.array([r2, th2, ph2])) return jsq, fl