SmileiPIC / Smilei

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

beam injection #430

Closed ccaizergues closed 3 years ago

ccaizergues commented 3 years ago

Hi Smilei developpers,

I'm trying to inject electrons in a 2D box.

For now, electrons are initialized inside the box, with a supposed vx=0.9, yet they do not seem to move. Is something wrong in the joined namelist ?

For injection from xmin shifting the profile to x<0 and uncommenting the ParticleInjector bloc should be ok ? with the x-axis interpreted as c*t for injection. then, no beam enters the box.

thanks,

beam_injection (1).py.txt beam_injection_out (1).txt

Z10Frank commented 3 years ago

Hello, before a developer more expert in Particle Injector answers, do you confirm that this is the way you want to inject particles in your simulation? Particle Injector normally is recommended to be used with both positively and negatively charged particles to enforce neutrality.

If you want to initialise only a relativistic electron beam inside the box, you may prefer an initialization with a numpy array for example.

mccoys commented 3 years ago

@ccaizergues Your issue is that you don't solve Poisson initially. You essentially create high-velocity charges in a space without fields. This is impossible in electrodynamics. What happens is that the code sees that as if there was a background population of charges making a neutral plasma initially. But this non-existent population does not make a current as it does not move. Thus the electrons are repelled very strongly by fast-growing fields, making them almost static (as if they were experiencing refluxing in a solid plasma). In the meantime, a lot of electromagnetic emission is created, which you can see in the simulation.

If you want a realistic simulation of a beam, you will need to initialize fields according to Poisson. As your beam is relativistic, you need the relativistic solver, and this requires a very large transverse box size to accommodate for the far-reaching fields (soon we will add specific boundary conditions to make this easier). One solution is to go for the AM geometry.

ccaizergues commented 3 years ago

Thanks you for the detailed explanation.

So at the beginning of the simulation, without Poisson correction an ion background of same density and velocity as the beam is assumed by Esirkepov. Then, if the density is high (Ekin<E_Coulomb) then this ghost contribution stops the electrons (making them radiate). Decreasing the beam density (nmax=1e-10) effectively enables electrons to move, whatever the initial conditions.

Only one of poisson or relativistic_poisson should be True (for now it seems that the two can simultaneously contribute without error/warning)

For injection from xmin, I still can get the beam entering correctly in the window.

first, for the spatial profile, it seems that the new electrons to be injected already have (x>0). Then, some part of the beam should necessarily already be inside the box at t=0. For example, this spatial profile do not permit to inject electrons:

beam_profile = lambda x,y: nmax (x<0) (Lsim[1]0.25<y<Lsim[1]0.75)

Also, I cannot have a personnalized time_enveloppe accepted in the namelist for the injector. Only tconstant or ttrapezoidal seem to work (not sure for tgaussian).

beam_tprofile = lambda t: (1+np.cos(t))

gives the following error

On rank 63 [Python] Exception: ERROR in the namelist: cannot define time_enveloppe in block ParticleInjector() ERROR src/Params/Params.cpp:1369 (runScript) error parsing test.py