Warwick-Plasma / epoch

Particle-in-cell code for plasma physics simulations
https://epochpic.github.io
GNU General Public License v3.0
186 stars 59 forks source link

density profile (see attached file) #593

Closed MKR100 closed 9 months ago

MKR100 commented 1 year ago

Hello, @Status-Mirror

Hope, you are good. I want to make a density profile, not a Gaussian profile (see attached file); density in front part increases quadratically with X [micron], it then get a peak (slightly wider), then decreases with X (not sharply, but decreases rapidly compared to the front part).

Thanks a lot.

densityProfile.pdf

Status-Mirror commented 1 year ago

Hey @MKR100,

For this example, I have taken the basic target demo, and constructed a functional form for the density in a constant block. We start with a quadratic rise and apply an exponential decay after the peak - the individual parameters can be tweaked to your needs. Functions can be expressed in the input.deck using maths parser expressions.

The input.deck:

begin:control
    nx = 500
    ny = 500
    t_end = 1.0e-15
    x_min = 0
    x_max = 25e-6
    y_min = 0
    y_max = 25e-6
    stdout_frequency = 100
    npart = 50 * (5.0e-6/(x_max-x_min)) * nx * ny
end:control

begin:boundaries
    bc_x_min = open
    bc_x_max = open
    bc_y_min = open
    bc_y_max = open
end:boundaries

begin:constant
    x_quad_start = 5.0e-6
    x_quad_end = 10.0e-6
    dens_10 = 1.0e28
    exp_fac = 0.2e-6
    quad_func = dens_10 * ((x - x_quad_start) / (x_quad_end - x_quad_start))^2
    exp_func = exp(-(x - x_quad_end)/exp_fac) * quad_func
end:constant

begin:species
    name = Electron
    mass = 1.0
    charge = -1.0
    frac = 0.8
    density = if (x gt x_quad_start, quad_func, 0)
    density = if (x gt x_quad_end, exp_func, density(Electron))
    density = if (x gt x_quad_end + 8 * exp_fac, 0, density(Electron))
    temp_ev = 1000
end:species

begin:species
    name = Carbon
    mass = 22033.0
    charge = 6.0
    frac = 0.2
    density = density(Electron) / 6
    temp_ev = 1000
end:species

begin:output
    dt_snapshot = t_end
    number_density = always
end:output

produces the density distribution:

density_in_parts

Hope this helps, Stuart

MKR100 commented 1 year ago

Thanks a lot @Status-Mirror for your helpful suggestions, but I'm looking for a wider peak width, like a hump (not a sharp peak). If you have any idea about this please let me know. Thank you so much.