SmileiPIC / Smilei

Particle-in-cell code for plasma simulation
https://smileipic.github.io/Smilei
335 stars 119 forks source link

Injector initialization crashes if temperature profile not defined #666

Closed mccoys closed 10 months ago

mccoys commented 10 months ago
# -------------------
# MY PYTHON VARIABLES
# -------------------

output_every = 25
n_part       = 50
velocity     = 0.05
amplitude    = 0.001
length       = 10
L=length
# --------------------------------------
# SMILEI's VARIABLES (DEFINED IN BLOCKS)
# --------------------------------------

Main(
    geometry = "1Dcartesian",
    interpolation_order = 2,
    simulation_time = 10.0*2*math.pi,
    timestep = 0.01,
    grid_length  = [length],
    cell_length = [length/64],
    number_of_patches = [ 4 ],
    solve_poisson = False,
    EM_boundary_conditions = [ ['silver-muller'] ]
)

def l_dens(x):
        if(x<L/2):
                return(1)
        else:
                return(0)
def r_dens(x):
        if(x>L/2):
                return(1)
        else:
                return(0)

Species(
    name = 'ion1',
    position_initialization = 'random',
    momentum_initialization = 'cold',
    particles_per_cell = n_part,
    mass = 1,
    charge = 1.0,
    number_density = l_dens,
    mean_velocity = [velocity, 0, 0],
    boundary_conditions = [
        ['remove'],
    ]
)

Species(
    name = 'ion2',
    position_initialization = 'random',
    momentum_initialization = 'cold',
    particles_per_cell = n_part,
    mass = 1,
    charge = 1.0,
    number_density = r_dens,
    mean_velocity = [-velocity, 0, 0], 
    boundary_conditions = [
        ['remove'],
    ]
)

Species(
    name = 'eon1',
    position_initialization = 'ion1',
    momentum_initialization = 'cold',
    particles_per_cell = n_part,
    mass = 1.0,
    charge = -1.0,
    number_density = l_dens,
    mean_velocity = [velocity, 0, 0],
    boundary_conditions = [
        ['remove'],
    ]
)

Species(
    name = 'eon2',
    position_initialization = 'ion2',
    momentum_initialization = 'cold',
    particles_per_cell = n_part,
    mass = 1.0,
    charge = -1.0,
    number_density = r_dens,
    mean_velocity = [-velocity, 0, 0],
    boundary_conditions = [
        ['remove'],
    ]
)

ParticleInjector(
    name = "injector1",
    species = "ion1",
    box_side = "xmin",
    position_initialization='random',
    #temperature = [0,0,0],
)

ParticleInjector(
    name = "injector2",
    species = "eon1",
    box_side = "xmin",
    position_initialization='random',
    #temperature = [0,0,0],
)

DiagScalar (
    precision = 3,
    every=output_every,
    vars = ['Utot', 'Ukin', 'Uelm', 'Ukin_eon1', 'Ukin_eon2', 'Uelm_Ex']
)

DiagParticleBinning(
    deposited_quantity = "weight",
    every = output_every,
    species = ['eon1','eon2'],
    axes = [
        ["x", 0., length, 200],
        ["vx", -4*velocity, 4*velocity, 300]
    ]
)

DiagFields(
    every = output_every,
)
mccoys commented 10 months ago

fixed in last push