SmileiPIC / Smilei

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

Alfven wave injection and absorption #565

Closed fyli16 closed 1 year ago

fyli16 commented 1 year ago

I wonder if an Alfven wave can be injected into the simulation like the attached paper for Osiris. Though the low-frequency Alfven wave is normally studied with MHD and hybrid codes at ion scales, in some important cases the electron scale physics is also very important which needs the use of full PIC. The availbility of this feature would enable the study of a variety of laboratory and space plasma issues using Smilei. Thanks.

2005_Tsung_1.1832602.pdf

MickaelGrech commented 1 year ago

Hello Feiyu. I had a look at the boundary conditions used in the paper by Tsung and co-workers. I think you can do something very similar in Smilei right now.

Considering a 2D geometry in Smilei we have axes (x,y) [corresponding to (z,x) in Tsung et al.] and I'll use this convention for the axes. In the y-direction, you will use periodic boundary conditions. In the x-direction, you will use:

Now, in Tsung's paper, they use a boundary condition that requires you to define the transverse electric field. In Smilei, we instead define the transverse magnetic field. I think defining a magnetic field as given by Eq. (1) of Tsung's paper should work for you. This you can do addind a "laser"

Laser(
    box_side = "xmin",
    space_time_profile = [ By_profile, Bz_profile ]
)

where By_profile and Bz_profile are function of y and time 't', e.g. you could use:

def Bz_profile(y,t):
    return E0 * numpy.exp(-(y-y0)**2/w**2) * g(t/tau) * numpy.cos(w*t+theta)

with E0, y0, w, g(t/tau) and theta defined in Tsung's paper.

fyli16 commented 1 year ago

@MickaelGrech Hi Mickael, thanks for your response! I will try this out and update later here on the performance. It might be useful for others needing the same feature.

mccoys commented 1 year ago

@fyli16 Any news on your attempts? Is this issue still relevant?

fyli16 commented 1 year ago

Will update later.

fyli16 commented 1 year ago

sorry for late update, finally got time to try this out. Following @MickaelGrech advice, by injecting the wave using the transverse B field, it looks like the wave can be successfully injected. Here is the input deck (for anyone who might be interested, and also for diagnosing potential issues): input.txt

Here is a snapshot of the wave injection:

image

However, there is an issue. Despite using 'silver-muller' for absorption EM boundary conditions, the Alfven wave is reflected upon reaching the right boundary; see this space-time plot of the By field component:

image

This is a 1D simulation. Anyone could help with or comment on this issue, i.e. how to effectively/efficiently achieve absorption boundary conditions for an Alfven wave in the PIC code?

I also found 'PML' boundary condition is not available with 1D, otherwise, perhaps I may try increasing the 'number_of_pml_cells' to achieve a more gradual absorption of the wave, which may help?

Thanks.

mccoys commented 1 year ago

@fyli16 I had a new look on this issue. If I understand correctly, your normalized ion plasma frequency wpi = 1. It means that the normalized wci ~ 1/100. Thus I imagine your Alfvén wave frequency much lower than 1.

However, the current boundary conditions are made for frequencies close to 1. There is even a fixed value hardcoded here: #src/ElectroMagnBC/ElectroMagnBC2D_SM.cpp#LL52C12-L52C17 This is in 2D but the idea is likely identical in 1D.

Is there a way you could re-scale your frequencies and plasma parameters so that the wave frequency equals 1?

fyli16 commented 1 year ago

@mccoys It is possible to reccale the frequencies to have the wave frequency ~1 ref. frequency, but the resulting plasma density will be exceedingly large.

Say ref. frequency wci (Alfven wave frequency to be studied is typically ~0.5 wci), then the plasma density will be

n0 = epsilon0 mi wpi^2/e = (epsilon0 me wci^2/e) (mi/me) (wpi/wci)^2 ~ 10^6 * Nr, assuming reduced mass ratio mi/me ~ 100, wpi/wci ~ 100

That might be very demanding in computing, e.g. requiring very large number of particle per cell to have reasonable particle noise?

mccoys commented 1 year ago

You don't need to have your reference frequency wr equal to wpi or wci. You can set it to whatever you like, and maybe you should chose wr equal to the wave frequency. These do not affect the computing time as you can also scale your cell length and timestep accordingly. The point is that you need your wave frequency close to 1, in normalized units.

mccoys commented 1 year ago

Another way to put it is that you change the units system, not the physical setup

fyli16 commented 1 year ago

I was just wondering if the large plasma density ( ~ 10^6 N_r) under the new frequency normalization (where wave frequency ~ ref. freq.) is numerically a concern or not for Smilei. Perhaps I can do some tests to find out.

Anyway thanks for pointing out the wave freq. ~ 1 issue in the boundary implementation @mccoys

fyli16 commented 1 week ago

Hello developers, a late update: I tried setting the reference frequency wr to wci, so the launched Alfven wave frequency is 0.63 wr, very close to the ref. frequency. I still got nearly complete reflections on the right boundary.

So far, I've tried 3 scenarios: 1) 1D, silver-muller, wr=wpi, external field for the background magnetic field Bx0 2) 1D, silver-muller, wr=wci, external field for the background magnetic field Bx0 3) 2D, PML in X, periodic in Y, wr=wci, prescribed field for the background magnetic field Bx0

The input for 3) is attached here: input_quasi-1d_PML_prescribedfield.txt

The results are shown below. I don't see an improvement in wave absorption using wr=wci. Near-complete reflections are found in all 3 scenarios.

image

Is there anything else missing, other than letting the wave frequency be as close to the ref. frequency as possible? Any thoughts and suggestions for further investigations in order to realize an absorption boundary condition for Alfven waves in SMILEI? Thanks.