Warwick-Plasma/epoch

Request for new feature: spatially varying number of macro-particles

Wang-Zhongwei opened this issue · 2 comments

Hi,

The epoch user manual says At a later stage this may be extended to allow “nparticles_per_cell” to be a spatially varying function. Just want to confirm that it is feature still unavailable right?

Since some regions are denser I want to use more macroparticles. I expect something like this would be pretty helpful

begin:species
  name = Electron
  nparticles_per_cell = if(x > 0, 64, 8)

  charge = -1.0
  mass = 1.0
  temperature_ev = elec_temp
  drift_px = 0.0
  drift_py = 0.0
  drift_pz = 0.0

  number_density = n_elec * density_profile
end:species

But for right now it gives a parsing error on the third line.

As far as I know, it still has to be a single value. Would enabling the PER_SPECIES_WEIGHT compile flag (see: https://epochpic.github.io/documentation/basic_usage/compiler_flags.html) give you the behaviour you want?

Alternatively, in your simple example, you could use two different electron species for the two different regions.

begin:species
  name = Electron_x_lt_0
  nparticles_per_cell = 8
  charge = -1.0
  mass = 1.0
  temperature_ev = elec_temp
  number_density = if(x lt 0, n_elec * density_profile, 0)
end:species

begin:species
  name = Electron_x_gt_0
  nparticles_per_cell = 64
  charge = -1.0
  mass = 1.0
  temperature_ev = elec_temp
  number_density = if(x gt 0, n_elec * density_profile, 0)
end:species

This approach would become impractical if you wanted many different ppc in many different regions. It would also slow down physics packages which perform species-species interactions, like collisions.

The only way to have total control over how your particles are loaded is to define them all yourself. This is quite a complicated approach, but you can use the particles_from_file block to manually specify the positions and weights of each loaded particle.

Hope this helps,
Stuart