コード例 #1
0
def initialize():
    pos, vel, Ie, W_elec, idx = init.initialize_particles()
    B, E_int = init.initialize_fields()
    DT, max_inc, data_iter = aux.set_timestep(vel)

    if data_iter == 0:
        data_iter = max_inc

    q_dens, Ji = sources.collect_moments(vel, Ie, W_elec, idx)

    E_int, Ve, Te = fields.calculate_E(B, Ji, q_dens)
    vel = particles.velocity_update(pos, vel, Ie, W_elec, idx, B, E_int,
                                    -0.5 * DT)
    return pos, vel, Ie, W_elec, idx, B, E_int, q_dens, Ji, Ve, Te, DT, max_inc, data_iter
コード例 #2
0
ファイル: main_1D.py プロジェクト: cycle13/hybrid
import auxilliary_1D as aux
import particles_1D as particles
import fields_1D as fields
import sources_1D as sources
import plot_and_save as pas
import diagnostics as diag

from simulation_parameters_1D import generate_data, generate_plots

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

    part = init.initialize_particles()
    B, E = init.initialize_magnetic_field()

    DT, max_inc, data_dump_iter, plot_dump_iter = aux.set_timestep(part)

    if generate_data == 1:
        pas.store_run_parameters(DT, data_dump_iter)

    print('Loading initial state...\n')
    part, dns_int, dns_half, J_plus, J_minus, G, L = sources.init_collect_moments(
        part, 0.5 * DT)

    qq = 0
    while qq < max_inc:
        part, qq, DT, max_inc, data_dump_iter, plot_dump_iter, change_flag = aux.check_timestep(
            qq, DT, part, B, E, dns_int, max_inc, data_dump_iter,
            plot_dump_iter)

        if change_flag == 1:
コード例 #3
0
import init_1D as init
import auxilliary_1D as aux
import particles_1D as particles
import fields_1D as fields
import sources_1D as sources
import save_routines as save

from simulation_parameters_1D import generate_data, NX

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

    pos, vel, Ie, W_elec, idx = init.initialize_particles()
    B, E_int = init.initialize_fields()

    DT, max_inc, data_iter = aux.set_timestep(vel)
    print 'Timestep: %.4fs, %d iterations total' % (DT, max_inc)
    if generate_data == 1:
        save.store_run_parameters(DT, data_iter)

    q_dens, Ji = sources.collect_moments(vel, Ie, W_elec, idx)

    E_int, Ve, Te = fields.calculate_E(B, Ji, q_dens)
    vel = particles.velocity_update(pos, vel, Ie, W_elec, idx, B, E_int,
                                    -0.5 * DT)

    qq = 0
    while qq < max_inc:
        # Check timestep
        vel, qq, DT, max_inc, data_iter, ch_flag \
        = aux.check_timestep(qq, DT, pos, vel, B, E_int, q_dens, Ie, W_elec, max_inc, data_iter, idx)
コード例 #4
0
    temp3d = np.zeros((size, 3), dtype=np.float64)

    if False:
        pos, idx = init.uniform_distribution()
        vel = init.gaussian_distribution()
    else:
        pos, vel, idx = init.quiet_start()

    B[:, 0] = Bc[0]  # Set Bx initial
    B[:, 1] = Bc[1]  # Set By initial
    B[:, 2] = Bc[2]  # Set Bz initial

    particles.assign_weighting_TSC(pos, Ie, W_elec)

    DT, max_inc, part_save_iter, field_save_iter, subcycles = aux.set_timestep(
        vel)

    print('Loading initial state...\n')
    sources.init_collect_moments(pos, vel, Ie, W_elec, idx, ni_init, nu_init,
                                 ni, nu_plus, rho_int, rho_half, J, J_plus, L,
                                 G, 0.5 * DT)

    # Put init into qq = 0 and save as usual, qq = 1 will be at t = dt
    qq = 0
    print('Starting loop...')
    while qq < max_inc:
        ############################
        ##### EXAMINE TIMESTEP #####
        ############################
        if adaptive_timestep == 1:
            qq, DT, max_inc, part_save_iter, field_save_iter, change_flag, subcycles =\
コード例 #5
0
ファイル: main_1D.py プロジェクト: cycle13/hybrid
## HYBRID MODULES ##
import init_1D       as init
import auxilliary_1D as aux
import particles_1D  as particles
import fields_1D     as fields
import sources_1D    as sources
import plot_and_save as pas

from simulation_parameters_1D import generate_data, generate_plots

if __name__ == '__main__':
    start_time = timer()
    
    pos, vel, Ie, W_elec, idx                    = init.initialize_particles()
    B, E_int                                     = init.initialize_fields()
    DT, max_inc, data_iter, plot_iter, subcycles = aux.set_timestep(vel)

    q_dens, Ji    = sources.collect_moments(vel, Ie, W_elec, idx)
    E_int, Ve, Te = fields.calculate_E(B, Ji, q_dens)
    vel           = particles.velocity_update(pos, vel, Ie, W_elec, idx, B, E_int, -0.5*DT)
    
    qq      = 0
    while qq < max_inc:
        # Check timestep
        pos, vel, qq, DT, max_inc, data_iter, plot_iter, subcycles \
        = aux.check_timestep(qq, DT, pos, vel, B, E_int, q_dens, Ie, W_elec, max_inc, data_iter, plot_iter, subcycles, idx)
        
        # Main loop
        pos, vel, Ie, W_elec, q_dens_adv, Ji = particles.advance_particles_and_moments(pos, vel, Ie, W_elec, idx, B, E_int, DT)
        q_dens                               = 0.5 * (q_dens + q_dens_adv)
        B, E_half, Ve, Te                    = fields.cyclic_leapfrog(B, q_dens, Ji, DT, subcycles)
コード例 #6
0
ファイル: main_1D.py プロジェクト: cycle13/hybrid
import init_1D as init
import auxilliary_1D as aux
import particles_1D as particles
import fields_1D as fields
import sources_1D as sources
import save_routines as save

from simulation_parameters_1D import save_particles, save_fields

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

    pos, vel, Ie, W_elec, idx = init.initialize_particles()
    B, E_int = init.initialize_fields()

    DT, max_inc, part_save_iter, field_save_iter = aux.set_timestep(vel)
    print('Timestep: %.4fs, %d iterations total\n' % (DT, max_inc))

    # Collect initial moments and save initial state
    q_dens, Ji = sources.collect_moments(vel, Ie, W_elec, idx)
    E_int, Ve, Te = fields.calculate_E(B, Ji, q_dens)

    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)

    vel = particles.velocity_update(pos, vel, Ie, W_elec, idx, B, E_int,
                                    -0.5 * DT)