Exemplo n.º 1
0
def advance_particles_and_moments(pos, vel, Ie, W_elec, Ib, W_mag, idx, Ep, Bp, v_prime, S, T, temp_N,\
                                  B, E, DT, q_dens_adv, Ji, ni, nu, flux_rem, pc=0):
    '''
    Container function to group and order the particle advance and moment collection functions
    '''
    velocity_update(pos, vel, Ie, W_elec, Ib, W_mag, idx, Ep, Bp, B, E,
                    v_prime, S, T, temp_N, DT)
    position_update(pos, vel, idx, DT, Ie, W_elec)

    if particle_open == 1:
        inject_particles(pos, vel, idx, flux_rem, DT, pc)

    collect_velocity_moments(pos, vel, Ie, W_elec, idx, nu, Ji)
    collect_position_moment(pos, Ie, W_elec, idx, q_dens_adv, ni)
    return
Exemplo n.º 2
0
def advance_particles_and_moments(pos, vel, Ie, W_elec, Ib, W_mag, idx, Ep, Bp, v_prime, S, T, temp_N,\
                                  B, E, DT, q_dens, Ji, ni, nu, pc=0):
    '''
    Helper function to group the particle advance and moment collection functions
    
    Note: use pc = 1 for predictor corrector to not collect new density. 
    Actually, E_pred at N + 3/2 (used to get E(N+1) by averaging at 1/2, 3/2) requires
    density at N + 3/2 to be known, so density at N + 2 is still required (and so
    second position push also still required).
    
    Maybe maths this later on? How did Verbonceur (2005) get around this?
    '''
    velocity_update(pos, vel, Ie, W_elec, Ib, W_mag, idx, Ep, Bp, B, E,
                    v_prime, S, T, temp_N, DT)
    position_update(pos, vel, idx, Ep, DT, Ie, W_elec)

    if OPT_moments == True:
        OPT_collect_moments(vel, Ie, W_elec, idx, q_dens, Ji, ni, nu)
    else:
        collect_velocity_moments(pos, vel, Ie, W_elec, idx, nu, Ji)
        collect_position_moment(pos, Ie, W_elec, idx, q_dens, ni)
    return
Exemplo n.º 3
0
from simulation_parameters_1D import save_particles, save_fields, xmin, xmax, E_nodes, B_nodes, dx
import diagnostics as diag

if __name__ == '__main__':
    start_time = timer()

    # Initialize simulation: Allocate memory and set time parameters
    pos, vel, Ie, W_elec, Ib, W_mag, idx, Ep, Bp, temp_N = init.initialize_particles(
    )
    B, E_int, E_half, Ve, Te, Te0 = init.initialize_fields()
    q_dens, q_dens_adv, Ji, ni, nu = init.initialize_source_arrays()
    old_particles, old_fields, temp3De, temp3Db, temp1D,\
                                          v_prime, S, T = init.initialize_tertiary_arrays()

    # Collect initial moments and save initial state
    sources.collect_velocity_moments(pos, vel, Ie, W_elec, idx, nu, Ji)
    sources.collect_position_moment(pos, Ie, W_elec, idx, q_dens, ni)

    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)

    #diag.plot_initial_sources(q_dens, Ji, E_int, B)

    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,
Exemplo n.º 4
0
    B_damping_array = np.ones(NC + 1, dtype=float)
    E_damping_array = np.ones(NC, dtype=float)
    set_damping_array(B_damping_array, E_damping_array, DT)

    print('Timestep: %.4fs, %d iterations total\n' % (DT, max_inc))
    return DT, max_inc, part_save_iter, field_save_iter, B_damping_array, E_damping_array


if __name__ == '__main__':
    import matplotlib.pyplot as plt

    POS, VEL, IE, WE, IB, WM, IDX, EP, BP, TEMP_N = initialize_particles()
    QD, QD2, JI, NI, NU, PI = initialize_source_arrays()

    #pos, vel, Ie, W_elec, idx, nu, Ji, Pi
    sources.collect_velocity_moments(POS, VEL, IE, WE, IDX, NU, JI, PI)

    plt.plot(const.E_nodes, NU[:, 1, 0])
    plt.show()

    #POS, VEL, IDX = uniform_gaussian_distribution_quiet()

    # =============================================================================
    #     V_MAG  = np.sqrt(VEL[0] ** 2 + VEL[1] ** 2 + VEL[2] ** 2) / va
    #     V_PERP = np.sign(VEL[2]) * np.sqrt(VEL[1] ** 2 + VEL[2] ** 2) / va
    #     V_PARA = VEL[0] / va
    # =============================================================================

    #diag.check_velocity_components_vs_space(POS, VEL, jj=1)
    #diag.plot_temperature_extremes()
    #diag.check_cell_velocity_distribution_2D(POS, VEL, node_number=None, jj=1, save=True)