B, E_int, E_half, Ve, Te, = init.initialize_fields() q_dens, q_dens_adv, Ji, ni, nu = init.initialize_source_arrays() old_particles, old_fields, temp3Da, temp3Db, temp3Dc = init.initialize_tertiary_arrays( ) DT, max_inc, part_save_iter, field_save_iter = init.set_timestep(vel) # Collect initial moments and save initial state sources.collect_moments(vel, Ie, W_elec, idx, q_dens, Ji, ni, nu) fields.calculate_E(B, Ji, q_dens, E_int, Ve, Te, temp3Da, temp3Db, temp3Dc) if save_particles == 1: save.save_particle_data(DT, part_save_iter, 0, pos, vel) if save_fields == 1: save.save_field_data(DT, field_save_iter, 0, Ji, E_int, B, Ve, Te, q_dens) particles.velocity_update(vel, Ie, W_elec, Ib, W_mag, idx, B, E_int, -0.5 * DT) qq = 1 print('Starting main loop...') while qq < max_inc: qq, DT, max_inc, part_save_iter, field_save_iter = \ aux.main_loop(pos, vel, idx, Ie, W_elec, Ib, W_mag, \ B, E_int, E_half, q_dens, q_dens_adv, Ji, ni, nu, \ Ve, Te, temp3Da, temp3Db, temp3Dc, old_particles, old_fields,\ qq, DT, max_inc, part_save_iter, field_save_iter) if qq % part_save_iter == 0 and save_particles == 1: save.save_particle_data(DT, part_save_iter, qq, pos, vel)
if te0_equil == 1: init.set_equilibrium_te0(q_dens, Te0) DT, max_inc, part_save_iter, field_save_iter, B_damping_array, E_damping_array\ = init.set_timestep(vel, Te0) fields.calculate_E(B, Ji, q_dens, E_int, Ve, Te, Te0, temp3De, temp3Db, temp1D, E_damping_array, 0, DT, 0) print('Saving initial conditions...') if save_particles == 1: save.save_particle_data(0, DT, part_save_iter, 0, pos, vel, idx) if save_fields == 1: save.save_field_data(0, DT, field_save_iter, 0, Ji, E_int,\ B, Ve, Te, q_dens, B_damping_array, E_damping_array) # Retard velocity print('Retarding velocity...') particles.velocity_update(pos, vel, Ie, W_elec, Ib, W_mag, idx, Ep, Bp, B, E_int, v_prime, S, T, temp_N, -0.5 * DT) qq = 1 sim_time = DT print('Starting main loop...') while qq < max_inc: qq, DT, max_inc, part_save_iter, field_save_iter = \ aux.main_loop(pos, vel, idx, Ie, W_elec, Ib, W_mag, Ep, Bp, v_prime, S, T, temp_N,\ B, E_int, E_half, q_dens, q_dens_adv, Ji, ni, nu, mp_flux, \ Ve, Te, Te0, temp3De, temp3Db, temp1D, old_particles, old_fields, \ B_damping_array, E_damping_array, qq, DT, max_inc, part_save_iter, field_save_iter)
rho_int += rho_half rho_int /= 2.0 J = 0.5 * (J_plus + J_minus) fields.cyclic_leapfrog(B, B2, rho_int, J, temp3d, DT, subcycles) E, Ve, Te = fields.calculate_E(B, J, rho_int) # This one's just for output ######################## ##### OUTPUT DATA ##### ######################## if qq % part_save_iter == 0 and save_particles == 1: # Save data, if flagged save.save_particle_data(DT, part_save_iter, qq, pos, vel) if qq % field_save_iter == 0 and save_fields == 1: # Save data, if flagged save.save_field_data(DT, field_save_iter, qq, J, E, B, Ve, Te, rho_int) if qq % 50 == 0: running_time = int(timer() - start_time) hrs = running_time // 3600 rem = running_time % 3600 mins = rem // 60 sec = rem % 60 print('Step {} of {} :: Current runtime {:02}:{:02}:{:02}'.format( qq, max_inc, hrs, mins, sec)) # ============================================================================= # if qq == 100: # aux.dump_to_file(pos, vel, E, Ve, Te, B, J, J_minus, J_plus, rho_int, rho_half, qq, suff='')