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

Arbitrary Distribution functions #567

Closed konghz closed 1 year ago

konghz commented 1 year ago

Hi, I use the Arbitrary Distribution functions method to initialize the drift-ring-beam distribution of particles. Are there any other methods for initializing the drift-ring-beam distribution of particles?

drift-ring-beam distribution: image

input.deck begin:constant malpha = 1836.04me vp =malpha 0.0431618 c #the unique perpendicular speed vpt=0.001vp #the perpendicular velocity spread of the fast ions
vparat=malpha
1000 #the parallel velocity spread of the fast ions

vrange =3.0* vp end:constant

begin:species name =alpha charge = 2.0 mass = 1836.04 npart = 100 nx number_density = 1.e16

ring beam distribution in velocity space

dist_fn =exp(-(sqrt(px^(2)+py^(2))-vp)^(2)/vpt^2)*exp(-pz^2/vparat^2)

dist_fn_px_range = (-vrange, vrange) dist_fn_py_range = (-vrange, vrange) dist_fn_pz_range = (-3vparat, 3vparat) end:species

Status-Mirror commented 1 year ago

I think this would be the easiest method for your distribution.

If you wanted to specify the start position, momentum and weight of each macro-particle, you could use the particles_from_file block, but this would be more involved than what you're currently doing.

Hope this helps, Stuart

konghz commented 1 year ago

Thank you very much for your response! It has been very helpful to me. One more thing I need to confirm with you is whether the initialization distribution function does not include the normalization factor, like in the following form: image

Status-Mirror commented 1 year ago

When sampling a generic distribution, EPOCH will randomly choose a $p_x$, $p_y$ and $p_z$ within the limits you give it. EPOCH then calculates your $f$ using these momenta, which it expects to be a number between 0 and 1. It then draws a uniformly distributed random number between 0 and 1, and if the number is lower than your $f$, it saves these momenta, otherwise the momenta are dismissed. The code then samples a new set of momenta and repeats the process.

Hence, EPOCH will generate momenta most efficiently when your maximum $f$ is 1. If your maximum $f$ was 0.5, then EPOCH would produce the same distribution, but it would take twice as long because half the samples would always be dismissed.

Hope this helps, Stuart