def get_kinetic_and_classicB(path, fprefix, time, xlim=-1): ''' classic_biermann,kinetic_biermann = get_kinetic_and_classicB(path,fprefix,time) ''' dict = cf.load_data_all_1D(path, fpre(path), time) ne = dict['ne'] Te = dict['Te'] qx = dict['qx'] qy = dict['qy'] jx = dict['jx'] jy = dict['jy'] dxT = dict['dxT'] dyT = dict['dyT'] Bz = dict['Bz'] x_grid = dict['x_grid'] y_grid = dict['y_grid'] Z2ni = dict['Z2ni'] prof_Z = dict['Z'] fo = dict['fo'] nv = dict['nv'] ny = dict['ny'] nx = dict['nx'] rA = (Z2ni)**-1 dict_fo = cf.load_dict_1D(path, fpre(path), 'fo', time) fo = dict_fo['mat'] time_col = dict_fo['time'] * tstep_factor rA = (Z2ni)**-1 #=============== grid = dict['grid'] dxfo, dyfo = cf.get_grad_3d_varZ(grid, fo) omega = Bz * rA rho_vyx = extend_grid_xy_to_vxy(nv, ny, nx, rA) Bz_vyx = extend_grid_xy_to_vxy(nv, ny, nx, Bz) omega_vyx = extend_grid_xy_to_vxy(nv, ny, nx, omega) Te_vyx = extend_grid_xy_to_vxy(nv, ny, nx, Te) ne_vyx = extend_grid_xy_to_vxy(nv, ny, nx, ne) #------ NERNST ----------------------------------------------------- print '\n\n--------- time ==================== ', time #v_nx,v_ny = get_v_N(grid,rho_vyx,Bz_vyx,fo) print(' bier init= ', np.shape(rho_vyx), np.shape(Bz_vyx), np.shape(ne_vyx), np.shape(Te_vyx)) classic_biermann = get_Biermann_classic(grid, rho_vyx, Bz_vyx, ne_vyx, Te_vyx) kinetic_biermann = get_Biermann(grid, rho_vyx, Bz_vyx, fo) classic_biermann = np.transpose(classic_biermann) kinetic_biermann = np.transpose(kinetic_biermann) return classic_biermann, kinetic_biermann
def get_vN_from_path(path, fprefix, time): ''' v_nx,v_ny = get_vN_from_path(path,fprefix,time) ''' dict = cf.load_data_all_1D(path, fpre(path), time) ne = dict['ne'] Te = dict['Te'] qx = dict['qx'] qy = dict['qy'] jx = dict['jx'] jy = dict['jy'] dxT = dict['dxT'] dyT = dict['dyT'] Bz = dict['Bz'] x_grid = dict['x_grid'] y_grid = dict['y_grid'] Z2ni = dict['Z2ni'] prof_Z = dict['Z'] fo = dict['fo'] nv = dict['nv'] ny = dict['ny'] nx = dict['nx'] rA = (Z2ni)**-1 dict_fo = cf.load_dict_1D(path, fpre(path), 'fo', time) fo = dict_fo['mat'] grid = fo v_grid = dict_fo['v_grid'] nv, ny, nx = np.shape(fo) v_nx = np.zeros((ny, nx)) v_ny = np.zeros((ny, nx)) v_nx_hf = np.zeros((ny, nx)) v_ny_hf = np.zeros((ny, nx)) #v_nx,v_ny = get_v_N(grid,rho_vyx,Bz_vyx,fo) for ix in range(nx): for iy in range(ny): Z2ni_loc = Z2ni[iy, ix] v_nx[iy, ix], v_ny[iy, ix] = get_v_N_classical(v_grid, Z2ni_loc, ne[iy, ix], Te[iy, ix], Bz[iy, ix], dxT[iy, ix], dyT[iy, ix]) v_nx_hf[iy, ix] = qx[iy, ix] / (2.5 * ne[iy, ix] * Te[iy, ix]) v_ny_hf[iy, ix] = qy[iy, ix] / (2.5 * ne[iy, ix] * Te[iy, ix]) v_nx = np.where(Bz == 0.0, 0.0, v_nx) v_ny = np.where(Bz == 0.0, 0.0, v_ny) return v_nx, v_ny, v_nx_hf, v_ny_hf
def get_Nernst_abs(path, time): ''' data_x,data_y = get_Nernst_ratio(path,time) ''' dict = cf.load_data_all_1D(path, fpre(path), time) ne = dict['ne'] Te = dict['Te'] qx = dict['qx'] qy = dict['qy'] jx = dict['jx'] jy = dict['jy'] dxT = dict['dxT'] dyT = dict['dyT'] Bz = dict['Bz'] x_grid = dict['x_grid'] y_grid = dict['y_grid'] Z2ni = dict['Z2ni'] prof_Z = dict['Z'] fo = dict['fo'] nv = dict['nv'] ny = dict['ny'] nx = dict['nx'] rA = (Z2ni)**-1 dict_fo = cf.load_dict_1D(path, fpre(path), 'fo', time) fo = dict_fo['mat'] rA = (Z2ni)**-1 #=============== grid = dict['grid'] dxfo, dyfo = cf.get_grad_3d_varZ(grid, fo) rho = rA omega = Bz * rA rho_vyx = extend_grid_xy_to_vxy(nv, ny, nx, rA) Bz_vyx = extend_grid_xy_to_vxy(nv, ny, nx, Bz) omega_vyx = extend_grid_xy_to_vxy(nv, ny, nx, omega) #------ NERNST ----------------------------------------------------- v_nx, v_ny = get_v_N(grid, rho_vyx, Bz_vyx, fo) v_nx_classical, v_ny_classical, v_nx_hf, v_ny_hf = get_vN_from_path( path, fpre(path), time) v_nx_c = np.transpose(v_nx_classical) v_ny_c = np.transpose( v_ny_classical) #np.transpoe(v_ny_classical)#[:,::-1] v_nx_k = np.transpose(v_nx) v_ny_k = np.transpose(v_ny) #np.transpose(v_ny)#[:,::-1] return v_nx_k, v_ny_k, v_nx_c, v_ny_c
def get_kinetic_heatflow_b(path, time): ''' dict = get_kinetic_heatflow_b(path,time) var_list = ['q_SH_x','q_SH_y','q_RL_x','q_RL_y','q_TE_x','q_TE_y','q_E_x','q_E_y'] for var in range(len(dict.keys())): var_name = var_list[var] ax = fig.add_subplot(ny_plots,nx_plots,var+1) plot_2D(ax,dict[var_name]['data'],dict[var_name]['name']) ''' dict = cf.load_data_all_1D(path, fpre(path), time) ne = dict['ne'] Te = dict['Te'] qx = dict['qx'] qy = dict['qy'] jx = dict['jx'] jy = dict['jy'] dxT = dict['dxT'] dyT = dict['dyT'] Bz = dict['Bz'] x_grid = dict['x_grid'] y_grid = dict['y_grid'] Z2ni = dict['Z2ni'] prof_Z = dict['Z'] fo = dict['fo'] nv = dict['nv'] ny = dict['ny'] nx = dict['nx'] rA = (Z2ni)**-1 dict_fo = cf.load_dict_1D(path, fpre(path), 'fo', time) #=============== grid = dict['grid'] dxfo, dyfo = cf.get_grad_3d_varZ(grid, fo) rho = rA omega = Bz * rA rho_vyx = extend_grid_xy_to_vxy(nv, ny, nx, rA) Bz_vyx = extend_grid_xy_to_vxy(nv, ny, nx, Bz) omega_vyx = extend_grid_xy_to_vxy(nv, ny, nx, omega) dict = get_qSH_kinetic(grid, rho_vyx, Bz_vyx, jx, jy, fo) dict['x_grid'] = dict_fo['x_grid'] dict['y_grid'] = dict_fo['y_grid'] dict['v_grid'] = dict_fo['v_grid'] dict['time'] = dict_fo['time'] return dict
def get_q_abs(path, time): ''' dict_ratio = get_q_ratio(path,time) ''' time_int = int(time) dict = cf.load_data_all_1D(path, fpre(path), time) ne = dict['ne'] Te = dict['Te'] qx = dict['qx'] qy = dict['qy'] jx = dict['jx'] jy = dict['jy'] dxT = dict['dxT'] dyT = dict['dyT'] Bz = dict['Bz'] U = dict['U'] x_grid = dict['x_grid'] y_grid = dict['y_grid'] Z2ni = dict['Z2ni'] prof_Z = dict['Z'] fo = dict['fo'] nv = dict['nv'] ny = dict['ny'] nx = dict['nx'] rA = (Z2ni)**-1 dict_fo = cf.load_dict_1D(path, fpre(path), 'fo', time) fo = dict_fo['mat'] rA = (Z2ni)**-1 #=============== grid = dict['grid'] dxfo, dyfo = cf.get_grad_3d_varZ(grid, fo) rho = rA omega = Bz * rA rho_vyx = extend_grid_xy_to_vxy(nv, ny, nx, rA) Bz_vyx = extend_grid_xy_to_vxy(nv, ny, nx, Bz) omega_vyx = extend_grid_xy_to_vxy(nv, ny, nx, omega) #heat flow ratios #--- kinetic dict = get_qSH_kinetic(grid, rho_vyx, Bz_vyx, jx, jy, fo) name_list = [ 'q_SH_x', 'q_SH_y', 'q_RL_x', 'q_RL_y', 'q_TE_x', 'q_TE_y', 'q_E_x', 'q_E_y' ] for name in name_list: dict[name]['data'] = np.transpose(dict[name]['data'])[:] q_KSH_x, q_KSH_y, q_KRL_x, q_KRL_y, q_KTE_x, q_KTE_y, q_KE_x, q_KE_y = dict[ 'q_SH_x']['data'], dict['q_SH_y']['data'], dict['q_RL_x'][ 'data'], dict['q_RL_y']['data'], dict['q_TE_x']['data'], dict[ 'q_TE_y']['data'], dict['q_E_x']['data'], dict['q_E_y']['data'] #--- classical q_dir = path + '/' q_SH_x = np.load(q_dir + 'q_SH_x.txt.npy') q_SH_y = np.load(q_dir + 'q_SH_y.txt.npy') q_RL_x = np.load(q_dir + 'q_RL_x.txt.npy') q_RL_y = np.load(q_dir + 'q_RL_y.txt.npy') q_E_x = np.load(q_dir + 'q_E_x.txt.npy') q_E_y = np.load(q_dir + 'q_E_y.txt.npy') q_xX = np.load(q_dir + 'q_xX.txt.npy') q_yY = np.load(q_dir + 'q_yY.txt.npy') #nt,ny,nx q_x_VFP = (q_xX[:, 1:, :] + q_xX[:, :-1, :]) * 0.5 q_y_VFP = (q_yY[:, :, 1:] + q_yY[:, :, :-1]) * 0.5 q_x_B = q_RL_x + q_E_x + q_SH_x q_y_B = q_RL_y + q_E_y + q_SH_y dict_c = {} dict_c['tot x'] = q_x_B[time_int, :, :] #q_xc dict_c['tot y'] = q_y_B[time_int, :, :] dict_c['SH x'] = q_SH_x[time_int, :, :] #q_SH_x[time_int,:x_lim,:] dict_c['SH y'] = q_SH_y[time_int, :, :] #q_SH_y[time_int,:x_lim,:] dict_c['RL x'] = q_RL_x[time_int, :, :] dict_c['RL y'] = q_RL_y[time_int, :, :] dict_c['E x'] = q_E_x[time_int, :, :] dict_c['E y'] = q_E_y[time_int, :, :] dict_k = {} dict_k['tot x'] = q_x_VFP[time_int, :, :] dict_k['tot y'] = q_y_VFP[time_int, :, :] dict_k['SH x'] = q_KSH_x #q_SH_x[time_int,:x_lim,:] dict_k['SH y'] = q_KSH_y #q_SH_y[time_int,:x_lim,:] dict_k['RL x'] = q_KRL_x dict_k['RL y'] = q_KRL_y dict_k['E x'] = q_KTE_x + q_KE_x dict_k['E y'] = q_KTE_y + q_KE_y dict_k['time'] = dict_fo['time'] dict_c['x_grid'] = x_grid[1:-1] dict_c['y_grid'] = y_grid dict_k['x_grid'] = x_grid[1:-1] dict_k['y_grid'] = y_grid dict_k['ne'] = np.transpose(ne) dict_k['Te'] = np.transpose(Te) dict_k['jx'] = np.transpose(jx) dict_k['jy'] = np.transpose(jy) dict_k['dxT'] = np.transpose(dxT) dict_k['dyT'] = np.transpose(dyT) dict_k['Bz'] = np.transpose(Bz) dict_k['Z2ni'] = np.transpose(Z2ni) dict_k['U'] = np.transpose(U) return dict_c, dict_k
def __init__(self, run_obj, **kwargs): path = run_obj.path self.time = kwargs.get('time', run_obj.time_max) iy = kwargs.get('iy', 20) self.dim = run_obj.dim self.cfg = run_obj.norm if self.dim == '1D': dict_load = cf.load_data_all_1D(path, fpre(path), self.time) convert_array = lambda key: dict_load[key] convert_array_dy = lambda key: dict_load[key] self.ny = 1 else: dict_load = cf.load_data_all(path, fpre(path), self.time) convert_array = lambda key: dict_load[key] convert_array_dy = lambda key: np.transpose(dict_load[key] )[:, ::-1][:, iy] self.ny = dict_load['ny'] # data in self.ne_ref = self.cfg.n0 self.Te_ref = self.cfg.T0 self.Bz_ref = ( m_e / (q_e * self.cfg.tau_ei)) * 1.0 # assumes that norm Bz is 1T self.v_te = self.cfg.v_te self.tau_ei = self.cfg.tau_ei self.Z_ref = self.cfg.Z self.Ar = self.cfg.Ar self.lambda_mfp = self.cfg.lambda_mfp # Only load in line outs of arrays # swap y direction after transpose for y gradients self.time_secs = dict_load['time'] * self.tau_ei if self.dim == '1D': self.dyB = None self.dyT = None else: self.dyB = convert_array_dy('dyB') self.dyT = convert_array_dy('dyT') self.dict_load = dict_load self.fo = dict_load['fo'] self.Te1 = cf.get_U_dev(dict_load['Te'].T) self.Bz1 = cf.get_U_dev(dict_load['Bz'].T) self.Z = convert_array('Z') * self.Z_ref self.U = convert_array('U') self.Te = convert_array('Te') self.ne = convert_array('ne') self.Cx = convert_array('Cx') self.wt = convert_array('wt') self.Bz = convert_array('Bz') if self.dim == '1D': self.x_grid = cf.trim_array_1D(dict_load['x_grid'], dict_load['nx'], 1) self.y_grid = None else: self.x_grid = cf.trim_array_1D(dict_load['x_grid'], dict_load['nx'], self.ny) self.y_grid = cf.trim_array_1D(dict_load['y_grid'], dict_load['ny'], dict_load['nx']) self.v_grid = dict_load['v_grid'] self.dxT = convert_array('dxT') self.dxB = convert_array('dxB') self.n_factor = 1.0 self.Te_factor = 1.0 self.Bz_factor = 1.0 self.C_factor = 1.0 self.P_factor = 2.0 / 3.0 self.x_factor = 1.0