advection_terms, collision_operator.BGK, moment_defs) N_g = system.N_ghost # Pass this system to the linear solver object when # a single mode only needs to be evolved. This solver # would only evolve the single mode, and hence requires # much lower time and memory for the computations: linearized_system = physical_system(domain, boundary_conditions, params, initialize, advection_terms, collision_operator.linearized_BGK, moment_defs) # Declaring a linear system object which will evolve the defined physical system: nls = nonlinear_solver(system) ls = linear_solver(linearized_system) # Time parameters: dt = 0.001 t_final = 0.0005 time_array = np.arange(0, t_final + dt, dt) rho_data_nls = np.zeros(time_array.size) rho_data_ls = np.zeros(time_array.size) # Storing data at time t = 0: n_nls = nls.compute_moments('density') rho_data_nls[0] = af.max(n_nls[:, N_g:-N_g, N_g:-N_g]) n_ls = ls.compute_moments('density')
import params import initialize import bolt.src.nonrelativistic_boltzmann.advection_terms as advection_terms import bolt.src.nonrelativistic_boltzmann.collision_operator \ as collision_operator import bolt.src.nonrelativistic_boltzmann.moment_defs as moment_defs # Defining the physical system to be solved: system = physical_system(domain, boundary_conditions, params, initialize, advection_terms, collision_operator.BGK, moment_defs) # Declaring a nonlinear system object which will evolve the defined physical system: ls = linear_solver(system) # Timestep as set by the CFL condition: dt = params.N_cfl * min(ls.dq1, ls.dq2) \ / max(domain.p1_end, domain.p2_end, domain.p3_end) if (params.t_restart == 0): time_elapsed = 0 ls.dump_distribution_function('dump_f/t=0.000') ls.dump_moments('dump_moments/t=0.000') else: time_elapsed = params.t_restart ls.load_distribution_function('dump_f/t=' + '%.3f' % time_elapsed) while (time_elapsed < params.t_final):
def run_cases(q_dim, p_dim, charge_electron, tau): params.charge_electron = charge_electron params.tau = tau # Running the setup for all resolutions: for i in range(N.size): af.device_gc() domain.N_q1 = int(N[i]) if (q_dim == 2): domain.N_q2 = int(N[i]) params.k_q2 = 4 * np.pi if (p_dim == 2): domain.N_p2 = 32 domain.p2_start = -10 domain.p2_end = 10 if (p_dim == 3): domain.N_p3 = 32 domain.p3_start = -10 domain.p3_end = 10 if (charge_electron != 0): domain.N_p1 = int(N[i]) if (p_dim == 2): domain.N_p2 = int(N[i]) if (p_dim == 3): domain.N_p3 = int(N[i]) params.p_dim = p_dim dt = 1e-3 / (2**i) # Defining the physical system to be solved: system = physical_system(domain, boundary_conditions, params, initialize, advection_terms, collision_operator.BGK, moment_defs) linearized_system = physical_system(domain, boundary_conditions, params, initialize, advection_terms, collision_operator.linearized_BGK, moment_defs) # Declaring a linear system object which will # evolve the defined physical system: nls = nonlinear_solver(system) ls = linear_solver(system) time_array = np.arange(dt, t_final + dt, dt) for time_index, t0 in enumerate(time_array): print(t0) nls.strang_timestep(dt) ls.RK4_timestep(dt) nls.dump_distribution_function('dump_files/nlsf_' + str(N[i])) ls.dump_distribution_function('dump_files/lsf_' + str(N[i]))