def f(z0): z0 = np.array([z0]) Nz0 = -np.array([0.03]) #x0=-np.array([0.13]) x0 = -np.array([0.20]) r = np.array([z0, x0]) X = p.X(r) Y = mf.Yabs(r) Nx0 = coldNx_Xm(X, Y, Nz0) data = X, Y, p.gamma(Te), Nz0 Nx0 = fsolve(hot_disp_rel_wrapp, Nx0, args=data) N = np.array([Nz0, Nx0]) nz, nx = ri.nz(r, N), ri.nx(r, N) init_cond = np.array([z0, x0, Nz0, Nx0]) soln = hot.get_ray(init_cond, ncycle) #make gamma in the config! soln = { "init_cond": init_cond, "soln": soln, "ncycle": ncycle, "gamma": p.gamma(Te) } #make file exist check np.save( os.path.abspath("results/mirror/simple/gamma" + str(Te) + "/soln_" + str(z0[0])), soln) return soln
def f(z0): z0 = np.array([z0]) x0 = np.array([0.01]) r = np.array([z0, x0]) X = p.X(r) Y = mf.Yabs(r) Nz0 = np.sqrt(Y / (1 + Y)) - 0.001 print "Nz_opt", Nz0 Nx0 = coldNx_Om(X, Y, Nz0) data = X, Y, p.gamma(10), Nz0 Nx0 = fsolve(hot_disp_rel_wrapp, Nx0, args=data) print Nx0 N = np.array([Nz0, Nx0]) nz, nx = ri.nz(r, N), ri.nx(r, N) init_cond = np.array([z0, x0, Nz0, Nx0]) print init_cond soln = hot.get_ray(init_cond, ncycle) #make gamma in the config! soln = { "init_cond": init_cond, "soln": soln, "ncycle": ncycle, "gamma": p.gamma(10) } #make file exist check #np.save(os.path.abspath("results/mirror/simple/Obeam/plasma_bvp/gamma10/soln_"+str(z0[0])),soln) return soln
def f(delta_Nz0): z0 = np.array([0]) x0 = np.array([1.05]) r = np.array([z0, x0]) X = p.X(r) Y = mf.Yabs(r) Nz0 = np.sqrt(Y / (1 + Y)) + delta_Nz0 print "Nz_opt", X, Y Nx0 = coldNx_Om(X, Y, Nz0) data = X, Y, p.gamma(10), Nz0 Nx0 = fsolve(hot_disp_rel_wrapp, Nx0, args=data) print Nx0 N = np.array([Nz0, Nx0]) nz, nx = ri.nz(r, N), ri.nx(r, N) init_cond = np.array([z0, x0, Nz0, Nx0]) print init_cond soln = hot.get_ray(init_cond, ncycle) #make gamma in the config! print(init_cond) soln = { "init_cond": init_cond, "soln": soln, "ncycle": ncycle, "gamma": p.gamma(10) } #make file exist check return soln
def f(Y): params.Y = Y X = p.X(r) Nz0 = np.array([np.sqrt(Y / (1 + Y))]) Nx0 = -coldNx_Om( X, Y, Nz0) #Om should be called "+" mode. we actually above the O-cutoff data = X, Y, p.gamma(Te), Nz0 Nx0 = fsolve(hot_disp_rel_wrapp, Nx0, args=data) N = np.array([Nz0, Nx0]) nz, nx = ri.nz(r, N), ri.nx(r, N) init_cond = np.array([z0, x0, Nz0, Nx0]) print mf.Yabs(np.array([z0, x0])), init_cond soln = hot.get_ray(init_cond, ncycle) soln = { "init_cond": init_cond, "soln": soln, "Y": params.Y, "ncycle": ncycle }
def f(q, t): z, x, Nz, Nx = q.reshape(4, Num) # all the variables are in global CS r = np.array([z, x]) X = p.X(r) Y = mf.Yabs(r) gamma = p.gamma(Te) N = np.array([Nz, Nx]) dnz_dN = ri.dnz_dN(r, N) dnx_dN = ri.dnx_dN(r, N) dnz_dr = ri.dnz_dr(r, N) dnx_dr = ri.dnx_dr(r, N) dX_dr = p.dX_dr(r) dY_dr = mf.dY_dr(r) dgamma_dr = p.dgamma_dr(r) nz, nx = ri.nz(r, N), ri.nx(r, N) n = np.array([nz, nx]) if nx < 1: vg = -dD_dN(X, Y, gamma, nz, nx, dnz_dN, dnx_dN) / dD_dw( X, Y, gamma, nz, nx) a = dD_dr(X, Y, gamma, nz, nx, dnz_dr, dnx_dr, dX_dr, dY_dr, dgamma_dr) / dD_dw(X, Y, gamma, nz, nx) if conf.verbose == True: print('disp rel cold:{}, disp rel:{},x:{} '.format( cold_disp_rel(X, Y, nz, nx, "Xm"), disp_rel(X, Y, gamma, nz, nx), x)) #if disp_rel(X,Y,gamma,nz,nx)>0: #break else: vg = -np.real( ebw.dD_dN(X, Y, gamma, nz, nx, dnz_dN, dnx_dN) / ebw.dD_dw(X, Y, gamma, nz, nx)) if vg[0] > 1 or vg[1] > 1: print("vg", vg[0], vg[1]) if conf.verbose == True: print( "EBW", 'x:{},X:{},dispRel:{},nx:{},nz:{},'.format( x, X, disp_rel_ebw(X, Y, gamma, nz, nx), nx, nz)) #if np.abs(disp_rel_ebw(X,Y,gamma,nz,nx))>1e-4: #break a = ebw.dD_dr(X, Y, gamma, nz, nx, dnz_dr, dnx_dr, dX_dr, dY_dr, dgamma_dr) / ebw.dD_dw(X, Y, gamma, nz, nx) arr = np.array([vg, a]) arr = np.real(np.real(arr.astype(np.complex64))) return arr.reshape(4 * Num)
def f(q, t): z, x, Nz, Nx = q.reshape(4, Num) # all the variables are in global CS r = np.array([z, x]) N = np.array([Nz, Nx]) X = p.X(r) Y = mf.Yabs(r) gamma = p.gamma(10) """ if localNx<1: vg = -np.real( dD_dN( X,Y,gamma,localNz,localNx,dNz_dN,dNx_dN ) / dD_dw( X,Y,gamma,localNz,localNx ) ) a = np.real( dD_dr(X,Y,gamma,localNz,localNx,dNz_dr,dNx_dr,dX_dr,dY_dr,dgamma_dr) / dD_dw( X,Y,gamma,localNz,localNx ) ) A,B,C=get_ABC(X,Y,gamma,localNz,localNx) #print A*localNx**4 arr = np.array([vg,a]) """ dnz_dN = ri.dnz_dN(r, N) dnx_dN = ri.dnx_dN(r, N) dnz_dr = ri.dnz_dr(r, N) dnx_dr = ri.dnx_dr(r, N) dX_dr = p.dX_dr(r) dY_dr = mf.dY_dr(r) dgamma_dr = p.dgamma_dr(r) nz, nx = ri.nz(r, N), ri.nx(r, N) n = np.array([nz, nx]) if nx < 1: vg = -np.real(dD_dN(X, Y, gamma, nz, nx, dnz_dN, dnx_dN)) a = np.real( dD_dr(X, Y, gamma, nz, nx, dnz_dr, dnx_dr, dX_dr, dY_dr, dgamma_dr)) arr = np.array([vg, a]) if conf.verbose == True: print "dr", disp_rel(X, Y, gamma, nz, nx), x else: vg = -np.real(ebw.dD_dN(X, Y, gamma, nz, nx, dnz_dN, dnx_dN)) if vg[0] > 1 or vg[1] > 1: print "vg", vg[0], vg[1] if conf.verbose == True: print "EBW", x, X, disp_rel_ebw(X, Y, gamma, nz, nx), nx, nz a = np.real( ebw.dD_dr(X, Y, gamma, nz, nx, dnz_dr, dnx_dr, dX_dr, dY_dr, dgamma_dr)) arr = np.array([vg, a]) return arr.reshape(4)
def f(Y): params.Y = Y Nz0_opt = np.array([np.sqrt(Y / (1 + Y))]) allSolns = [] for Nz0 in np.linspace(Nz0_opt + 0.001, Nz0_opt + 0.001, 1): Nz0 = np.array([Nz0]) #TODO: use the cold dispersion relation to find which refractive index to use, becasue I want to do the angular scan. We need to choose the proper branch if (Nz0 < Nz0_opt): #get the starting point of a ray x0 = np.array([brentq(cold_C_wrapp, 1.001, 40, args=(Y, Nz0)) ]) + 0.001 print "x0", x0 else: x0 = np.array([1.001]) #more or less arbitrary z0 = np.array([0]) r = np.array([z0, x0]) X = p.X(r) print r, X Nx0 = -coldNx_Om(X, Y, Nz0) print Nx0 data = X, Y, p.gamma(10), Nz0 Nx0 = fsolve(hot_disp_rel_wrapp, Nx0, args=data) N = np.array([Nz0, Nx0]) nz, nx = ri.nz(r, N), ri.nx(r, N) init_cond = np.array([z0, x0, Nz0, Nx0]) print mf.Yabs(np.array([z0, x0])), init_cond soln = hot.get_ray(init_cond, ncycle) soln = { "init_cond": init_cond, "soln": soln, "Y": params.Y, "ncycle": ncycle } allSolns.append(soln) #Idea: investigate vg_perp/v_parallel of as function of Nz in the slabb model. We willl find the that the dependy is weak! (hopefully) -> EBW is not affected much the injection angle #np.save(os.path.abspath("results/slab/Obeam/harm1/gamma10/NzScan/soln_"+str(params.Y)),allSolns) return np.array(allSolns)
def f(r,N): X=p.X(r) Y=mf.Yabs(r) gamma = p.gamma(10) """ if localNx<1: vg = -np.real( dD_dN( X,Y,gamma,localNz,localNx,dNz_dN,dNx_dN ) / dD_dw( X,Y,gamma,localNz,localNx ) ) a = np.real( dD_dr(X,Y,gamma,localNz,localNx,dNz_dr,dNx_dr,dX_dr,dY_dr,dgamma_dr) / dD_dw( X,Y,gamma,localNz,localNx ) ) A,B,C=get_ABC(X,Y,gamma,localNz,localNx) #print A*localNx**4 arr = np.array([vg,a]) """ dnz_dN=ri.dnz_dN(r,N) dnx_dN=ri.dnx_dN(r,N) dnz_dr=ri.dnz_dr(r,N) dnx_dr=ri.dnx_dr(r,N) dX_dr = p.dX_dr(r) dY_dr = mf.dY_dr(r) dgamma_dr = p.dgamma_dr(r) nz,nx=ri.nz(r,N),ri.nx(r,N) n = np.array([nz,nx]) if nx<1: a = np.real( dD_dr(X,Y,gamma,nz,nx,dnz_dr,dnx_dr,dX_dr,dY_dr,dgamma_dr) / dD_dw( X,Y,gamma,nz,nx ) ) else: a = np.real( ebw.dD_dr(X,Y,gamma,nz,nx,dnz_dr,dnx_dr,dX_dr,dY_dr,dgamma_dr) / ebw.dD_dw( X,Y,gamma,nz,nx ) ) return a
#type of simulation #### #f for pool Te = params.Te #set the the Te z0 = np.array([0.001]) x0=np.array([-0.77]) r = np.array([z0,x0]) X = p.X(r) Y = mf.Yabs(r) data = X,Y,p.gamma(500),Nz0 Nx0 = coldNx_Xm(X,Y,Nz0) Nx0=fsolve(hot_disp_rel_wrapp,Nx0,args=data) print(Nx0) N = np.array([Nz0,Nx0]) nz,nx=ri.nz(r,N),ri.nx(r,N) init_cond=np.array([z0,x0,Nz0,Nx0]) soln=hot.get_ray(init_cond,ncycle) #make gamma in the config! print(init_cond) soln = {"init_cond":init_cond,"soln":soln,"ncycle":ncycle,"gamma":p.gamma(500)}
path = os.path.abspath("results/slab/harm1") files = os.listdir(os.path.abspath(path)) soln = np.load(path + "/" + files[0]).item()["soln"] soln_init_cond = np.load(path + "/" + files[0]).item()["init_cond"] params.Y = float(files[0][files[0].index("_") + 1:-4]) NN = [] acc = soln_init_cond[2:4] dt = 10. / 2e4 for i in range(0, soln[:, 0].size)[0:2]: r = soln[i, 0:2] N = soln[i, 2:4] X = p.X(r) Y = mf.Yabs(r) Nz, Nx = N acc = acc + e.f(soln[i, 0:2].reshape(2, 1), soln[i, 2:4].reshape( 2, 1)) * dt * 200 #print acc[1] NN.append(acc) nz, nx = ri.nz(r.reshape(2, 1), N.reshape(2, 1)), ri.nx(r.reshape(2, 1), N.reshape(2, 1)) if np.abs(nx) < 1: print soln[i, 1], disp_rel(X, Y, p.gamma(10), nz, nx), cold_disp_rel(X, Y, nz, nx, "Xm") else: print soln[i, 1], ebw.disp_rel(X, Y, p.gamma(10), nz, nx), cold_disp_rel(X, Y, nz, nx, "Xm") NN = np.array(NN)