Ejemplo n.º 1
0
def test_transversal_current(init_pos, init_vx, expected):
    S = laser("test_current", 0, 0, 0, 0)
    print(f"dx: {S.grid.dx}, dt: {S.grid.dt}, Neuler: {S.grid.NG}")
    init_vy = 0.01
    p = Particle(S.grid,
                 init_pos * S.grid.dx,
                 init_vx * lightspeed,
                 init_vy * lightspeed,
                 q=-electric_charge,
                 m=electron_rest_mass,
                 scaling=npic)
    S.grid.list_species = [p]
    S.grid.gather_current([p])
    investigated_density = S.grid.current_density_yz[
        9:14, 0] / p.eff_q / init_vy / lightspeed
    target_density = expected
    error = (investigated_density - target_density) * 100
    error[investigated_density != 0] /= investigated_density[
        investigated_density != 0]
    print(
        pd.DataFrame({
            "indices": np.arange(9, 14) - 2,
            "found density": investigated_density,
            "target density": target_density,
            "error %": error
        }))
    assert np.allclose(investigated_density,
                       target_density,
                       rtol=1e-2,
                       atol=1e-3)
Ejemplo n.º 2
0
def test_longitudinal_current(init_pos, init_vx, expected):
    S = laser("test_current", 0, 0, 0, 0)
    print(f"dx: {S.grid.dx}, dt: {S.grid.dt}, Neuler: {S.grid.NG}")
    p = Particle(S.grid,
                 init_pos * S.grid.dx,
                 init_vx * lightspeed,
                 q=-electric_charge,
                 m=electron_rest_mass,
                 scaling=npic)
    S.grid.list_species = [p]
    S.grid.gather_current([p])
    investigated_density = S.grid.current_density_x[9:13] / (
        p.eff_q * init_vx * lightspeed)
    if init_vx == 0.0:
        investigated_density[...] = 0

    target_density = expected
    error = (investigated_density - target_density) / target_density * 100
    error[(investigated_density - target_density) == 0] = 0
    print(
        pd.DataFrame({
            "indices": np.arange(9, 13) - 1,
            "found density": investigated_density,
            "target density": target_density,
            "error %": error
        }))
    assert np.allclose(target_density,
                       investigated_density,
                       rtol=1e-2,
                       atol=1e-3)
Ejemplo n.º 3
0
def run():
    perturbation_amplitude = 0
    number_particles = 10000
    power = 21
    intensity = 10**power
    s = laser(f"{number_particles}_run_{power}_{perturbation_amplitude}",
              number_particles, impulse_duration, intensity,
              perturbation_amplitude).run()
    return s
Ejemplo n.º 4
0
def test_laser_pusher():
    S = laser("test_current", 0, 0, 0, 0)
    p = Particle(S.grid,
                 9.45*S.grid.dx,
                 0,
                 0,
                 q=-electric_charge,
                 m=electron_rest_mass,
                 scaling=npic)
    S.grid.list_species = [p]
    Ev, Bv = (np.array([[0, 1.228e12, 0]]), np.array([[0,0,4.027e3]]))
    E = lambda x: (Ev, Bv)
    p.push(E)
    print(p.v)
    expected_u = np.array([[5.089e4, -5.5698e6, 0]]) # this is u!
    expected_v = expected_u #* gamma_from_u(expected_u, S.grid.c)
    print(expected_v)
    print((p.v - expected_v)[0,:2] / p.v[0,:2] * 100, "%")
    # print(f"vx:{a:.9e}\n"
    #       f"vy:{b:.9e}\n"
    #       f"vz:{c:.9e}\n"
    #       f"KE:{e:.9e}\n")
    assert np.allclose(expected_v, p.v, atol=1e-1, rtol=1e-2)
Ejemplo n.º 5
0
# coding=utf-8
from pythonpic import plotting_parser
from pythonpic.configs.run_laser import laser, impulse_duration, n_macroparticles, plots

args = plotting_parser("Hydrogen shield")
perturbation_amplitude = 0
number_particles = 10000
powers = range(23, 20, -1)
for power in powers:
    intensity = 10**power
    s = laser(f"{number_particles}_run_{power}_{perturbation_amplitude}",
              number_particles, impulse_duration, intensity,
              perturbation_amplitude).lazy_run()
    if any(args):
        plots(s, *args, frames="few")
Ejemplo n.º 6
0
# coding=utf-8
from pythonpic import plotting_parser
from pythonpic.configs.run_laser import laser, impulse_duration, n_macroparticles, plots

args = plotting_parser("Hydrogen shield")
perturbation_amplitude = 0
number_particles = 10000
powers = range(23, 20, -1)
for power in powers:
    intensity = 10**power
    s = laser(f"production_run_{power}_{perturbation_amplitude}", n_macroparticles, impulse_duration, intensity, perturbation_amplitude).lazy_run()
    if any(args):
        plots(s, *args, frames="all")
    del s
# s = laser("production_run_nolaser_e-3", n_macroparticles, impulse_duration, 0, perturbation_amplitude).lazy_run()
# plots(s, *args, frames="few")
# s = laser("field_only", 0, impulse_duration, 1e21, perturbation_amplitude).lazy_run()
# plots(s, *args, frames="few")
Ejemplo n.º 7
0
# coding=utf-8
from pythonpic import plotting_parser
from pythonpic.configs.run_laser import laser, impulse_duration, n_macroparticles, plots

args = plotting_parser("Hydrogen shield")
perturbation_amplitude = 0
intensities = [5e20, 1e21, 5e21, 1e21, 5e21, 1e22, 5e22, 1e23]
scalings = [0.5, 0.9, 1, 1.1, 1.5]
for intensity in intensities:
    for scaling in scalings:
        s = laser(f"production_run_{intensity}_{scaling}", n_macroparticles,
                  impulse_duration, intensity, perturbation_amplitude,
                  scaling).lazy_run()
        if any(args):
            plots(s, *args, frames="few")
        del s