Warwick-Plasma / epoch

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

Hi @feelingxxxxxxx, #709

Closed bear-maker closed 2 months ago

bear-maker commented 2 months ago
          Hi @feelingxxxxxxx,

I've adapted the uniform load demo to show you how you can run a dist_fn. I'll include the input deck at the end.

I've made some changes to your block, these are:

Our new input deck can run, and we get the following distribution function:

result

Here is the deck I used:

begin:control
    nx = 500
    ny = 500
    t_end = 1.0e-15
    x_min = -10.0e-6
    x_max = 15e-6
    y_min = 0
    y_max = 25e-6
    stdout_frequency = 100
    npart = 50 * 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:species
    name = electron
    mass = 1.0
    charge = -1.0
    frac = 0.8
    density = 1.0e24
    temp_ev = 1e7
end:species

begin:species
    name = C6
    mass = 22033.0
    charge = 6.0
    frac = 0.2
    density = density(electron) / 6
    temp_ev = 1e7
end:species

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

begin:constant
  # Set speed range
  vx_low = 2.25e8
  vx_high = 0.999*c

  # Calculate Lorentz gamma for these speeds
  gamma_low = 1.0 / sqrt(1.0 - (vx_low/c)^2)
  gamma_high = 1.0 / sqrt(1.0 - (vx_high/c)^2)

  # Electron px range (p = gamma * mass * v)
  px_e_low = gamma_low * me * vx_low
  px_e_high = gamma_high * me * vx_high

  # Carbon px range
  px_c_low = gamma_low * 22033*me * vx_low
  px_c_high = gamma_high * 22033*me * vx_high
end:constant

begin:dist_fn
  name = electron_dist
  ndims = 2
  dumpmask = always
  direction1 = dir_x
  direction2 = dir_px
  range1 = (-0.8e-6, 0.3e-6)
  range2 = (-px_e_high, -px_e_low)
  resolution1 = 200
  resolution2 = 200
  include_species:electron
end:dist_fn

begin:dist_fn
  name = carbon_dist
  ndims = 2
  dumpmask = always
  direction1 = dir_x
  direction2 = dir_px
  range1 = (-0.8e-6, 0.3e-6)
  range2 = (-px_c_high, -px_c_low)
  resolution1 = 200
  resolution2 = 200
  include_species:C6
end:dist_fn

Hope this helps, Stuart

Originally posted by @Status-Mirror in https://github.com/Warwick-Plasma/epoch/issues/706#issuecomment-2344061372

Status-Mirror commented 2 months ago

Answered in Issue #706.