def B_term(r, z, *p): n1, a1, b1 = p br, bz = rt1.bvec(r, z, separatrix) bb = np.sqrt(br**2 + bz**2) if rt1.check_coilcase(r, z): return 0.0 else: return (bb / rt1.b0(r, z, separatrix))**(-b1)
def ne_single_gaussian(r, z, *p): n1, a1, b1, rm = p br, bz = rt1.bvec(r, z, separatrix) bb = np.sqrt(br**2 + bz**2) if r == 0.0: return n1 * np.exp(-a1 * abs((rt1.psi(r, 0.0, separatrix)-psix)/psi0)**2) if rt1.check_coilcase(r, z): return 0.0 else: return n1 * np.exp(-a1*abs((rt1.psi(r, z, separatrix) - psix)/psi0)**2) * (bb/rt1.b0(r, z, separatrix))**(-b1)
psi0 = rt1.psi(1.0, 0.0, separatrix) # psi at the vacuum chamber psi_x450 = np.zeros(len(x450)) psi_z620 = np.zeros(len(z620)) psi_z700 = np.zeros(len(z700)) bb620 = np.zeros(len(z620)) bb700 = np.zeros(len(z700)) b0620 = np.zeros(len(z620)) b0700 = np.zeros(len(z700)) for i, x in enumerate(x450): rx = np.sqrt(x**2 + r450_para**2) psi_x450[i] = rt1.psi(rx, 0.0, separatrix) for j, z in enumerate(z620): psi_z620[j] = rt1.psi(r620_perp, z, separatrix) br, bz = rt1.bvec(r620_perp, z, separatrix) bb620[j] = np.sqrt(br**2 + bz**2) b0620[j] = rt1.b0(r620_perp, z, separatrix) for j, z in enumerate(z700): psi_z700[j] = rt1.psi(r700_perp, z, separatrix) br, bz = rt1.bvec(r700_perp, z, separatrix) bb700[j] = np.sqrt(br**2 + bz**2) b0700[j] = rt1.b0(r700_perp, z, separatrix) print(' ') print(' start 1st optimization.... ') print(' ') err_max = 1e10 if not (view_mode is True):