-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Particle Injector and the boundary conditions #293
Comments
Dear @Tissot11, Thank you for summarizing your issues. So far, I only looked at the first case. You have done a mistake in the namelist. The injection is set to |
For the case 2, I observe as well the reflection although I cannot explain why. However, it is normal that you do not have the spike at the left and that you do not have particle injection. It is because your injector is related to the |
Thanks for the reply. But in Case 1, (PI_3.py.txt), I do inject plasma from xmin. Is there a mix-up in the Namelists? |
I followed as described in the documentation. Since the number_density parameter is inherited from the species, I didn't define it again. In some cases I had define it also and I had not succeeded. Besides, I want to inject the same density as the plasma species. So can this number_density parameter for ParticleInjector be equal to the density of the plasma species instead one 1? |
Sorry my mistake. I found why you have no injection. You should inject the particles at the same positions: ParticleInjector(
name = "Inj_eon",
species = "eon",
box_side = "xmin",
)
ParticleInjector(
name = "Inj_ion",
position_initialization = 'Inj_eon',
species = "ion",
box_side = "xmin",
) I am not sure about the reason but your ions seem to be quasi-immobile due to the low momentum. Therefore, it is possible that without charge neutrality, they hold back the electrons. One more thing. I can understand that you though you were injecting at the same location because you have associated injectors to the species but no. Since a species can have several injectors, you have to specify again in the injector to initialize at the same location. I should add this in the doc. |
If your plasma is not defined until the border of the simulation box, you can still create a parameter called |
Actually ions should have higher momenta since they are heavier and have the same velocity as electrons in my case.
Thanks for the clarification. Indeed I had thought associating with the species should have assigned the same location as the species itself. Though, I had done some simulations to explicitly assign the initialisation as mentioned in #271. So does the Case 2 works with your workaround? I'll check it tonight. |
Normally I assign the plasma and the injector to the same boundaries as I mentioned in #283. I wanted to understand the behaviour of ParticleInjector and the boundary conditions because of the problems seen in #283 that's why I created these four cases. In Case 4, I initialise the plasma closer to the right boundary but the injector should inject the plasma in +x direction. This parameter maximum_density isn't mentioned in the documentation. How does it work and where should I define it, in the Species or in the ParticleInjector block? Does it equal to the density of the plasma and density of the injected particle? |
I am still surprised by the behavior of the case 2. I don't understand this reflection and moreover it seems independent from the injection because when I switch it off the reflection still occurs. Concerning the maximum_density = 1.
Species(
...
number_density = trapezoidal(maximum_density , xvacuum=50.0, xplateau=10.0),
...
)
ParticleInjector(
...
number_density = maximum_density ,
...
) So that you keep the same density everywhere in a simple way. I did not have a look to 3 and 4 for the moment. |
Yes, this reflection is hard to understand. I tried removing magnetic field components and this reflection still persists. Are there some issues with the right boundary? I see some issues while using a moving window and I'll post it in another thread. |
Here is the explanation that I found for this reflection at the right boundary. As there is some randomness in positions and momenta, electrons and ions will slowly separate, thus creating random electric + magnetic field noise. When the plasma reaches the boundaries, it may happen that an electron is removed, but the ion is still in the box (because the two particles are separated). This creates a local space-charge field that is later compensated by the ion leaving the box. But in the meantime, you have this short-lived noise. When particles come from far from boundary they get more separated over time, thus this noise becomes more and more important. As a consequence, you reach a point where you can add the noise from several particles and it is enough to reflect one other particle. This is why you see particles reflected after a while. Several ways you can stop this effect:
I know these solutions are not very convenient, but I think the problem is very general in PIC codes. Removing particles is a very tricky business and should be done very carefully. In any case, I believe this is not a problem in Smilei, but a general difficulty in all PIC codes. |
Hi mccoys, |
@phi-kafka there is the "stop" boundary condition |
@mccoys I'm not sure the "stop" bc implemented in Smilei will do the work (I explain below). |
Thanks for your valuable insights! I'll try your suggestions. I still wanted to clarify few things.
I'll take more particles for simulating this kind of problems. Thankfully Smilei is super-fast so more particles in a simulation are not an issue on our cluster. |
Just out of curiosity, can applying field filtering around the boundaries help in this situation? Or this is not feasible? |
|
Thanks! Do the other issues noted in Cases 3 and 4 can also be taken care of if one tries your suggestions? |
Case 3 seems to be just the same without injection, so same as case 2 in my opinion. Case 4 clearly shows a bug in xmax injection. @xxirii did you notice this bug before. |
I did not study case 4 for the moment but I did not see it before |
Hi @mccoys @MickaelGrech ,
So, if there would be not just "stop" but "stop"+freeze (switch of pusher for these particles), it would be perfect in this case. This solution would perfectly work in 1D. In 2D and 3D this would not be perfect, (but still much better). For instance, for non-neutral beam near the boundary it would create artificially stronger fields in the box, than it would be when particles escape the box and go to infinity. For that 2D and 3D situation it can be more elaborated, I understand that it is a serious work, so why don't just add the bc "stop + frozen"? |
As Mickaël said, frozen particles do not participate in any equations in the code. They would have no effect at all on the fields. The Poisson equation is only solved at the beginning of the simulation but never after. This means that charge has no effects. Only current has. Frozen particles have no current. |
Yes, indeed, thank you @mccoys, I of course missed this step in my proposition. Yes, it is not enough just to freeze particles, after a "prescribed field" created by these particles should be applied to the box according to the Coulomb law. It is a summation over the surface cells of an analytical expression, seems to be numerically fast. But it is more work with the code, almost the same development work as in the second proposed approach "For that 2D and 3D situation it can be more elaborated...". |
Boundary conditions are very often a huge difficulty in all sorts of simulations. What you are asking is basically to create a field that is equal to that of particles exiting the box. If you just make the field of particles stopped at the border, this is NOT equal to the field of escaping particles. Instead, particles that would travel far away would contribute less and less. As a consequence, what you are asking is to do another simulation outside of the box, which is not reasonable. Generally, the solution would be to make the box much larger and stop the simulation before the perturbation has come back in the center. Otherwise, you have to invent a new boundary condition that would absorb better particles and their fields. |
I ran some initial simulations choosing higher number of particles and regular initialization does seem to improve things a bit. If I understood correctly, then these fluctuations might not be an issue if we inject and choose to simulate electron-positron plasmas? Also could choosing smaller grid size and time step also help in easing this sort of fluctuation? |
@mccoys, sorry, I don't agree that I ask for another simulation outside. There is no need of grid, no need of self-consistency. Knowing particle velocity you just have analytical expression x=x_0+v_0 t, x_0 and v_0 are coordinates and velocities at the boundary. Yes, you are right that particles will contribute less when they far, but only in 2D and 3D. That is what I told before. In 1D it would work perfect even if they stay at the boundary. In 2D and 3D what is written in #293 (comment) can make it more precise. Actually this is what you say "invent a new boundary condition", though not ideal of course. |
@Tissot11 I haven't tried e-p plasmas. But it might help. I don't know if resolutions can help, but maybe. @phi-kafka Assuming ballistic positions is still somewhat disturbing in a PIC simulation. But it might do things better. Who knows. For now, we cannot dedicate time to this subject. |
@mccoys Ok. I'll try e-p plasmas to see. Any thoughts if the thermalize boundary condition can be useful in this type of situation? |
Do not use regular spacing if you have nonrelativistic plasmas. The explanation has been revently added in the doc. |
I have always non-relativistic plasma. Following @mccoys earlier suggestion I tried |
The issue was unrelated to the injector. It is only boundary condition stuff. I gave an explanation above. |
Ok. I think these issues with I have also done another simulation with that many particles per cell but without the reflecting wall on the right hand side. I'll always see an issue about the buildup of the plasma density and fields on the right hand boundary. I had chosen Case 3 above to mitigate this charge build up on the right hand side, since I was injecting the plasma at the right boundary in |
Hi @Tissot11, I do not recommend the use of the regular init for non-maxwellian distributions. This is explained by hand in this link : https://smileipic.github.io/Smilei/particle_injector.html. With the way we inject particles, regular spacing act as a filter that only let the particles with high energy pass the boundary. The velocity of each particle has to be large enough so that the particles reach and cross the boundary. The consequence is a lower density than expected and a truncated distribution. Please, use rather the random init in your case. For the other issues, we have to work on it indeed. |
Thanks for your answer and sending the link! I think your explanation on this page make sense! I'm now running the simulations with
Thanks again for looking into these issues. I really like Smilei and if I can use |
Dear @Tissot11 Good questions and I don't really know in fact. This injection is really non intuitive for me. |
I was wondering if you have any updates on the Particle Injectors issues? I also found that if I use |
Dear @Tissot11 , Concerning the crash situation can you provide a namelist. I will try to investigate soon. For the moment no more improvement or correction for the injection. For the freezing, I think the 2 are incompatible. You can not inject a frozen species. However I have never tried and I should add an error message to prevent this. |
Description
I attach here some results on using the ParticleInjector block in 1D simulations. In these simulations, I define a drifting plasma and ParticleInjector systematically at both boundaries. I always choose remove boundary conditions for particles. The plasma is drifting in +x direction. The only peculiarity is that for xmax boundary, instead of injecting plasma in -x direction, I'm injecting it +x direction which maybe desired for maintaining the momentum flux if one injects these particles in the simulation box from the left side. I discussed some of these issues in #283 but I thought to present simplified results here and I hope that it can help in diagnosing the problem.
Case 1:
Initilize plasma and injection at the left boundary.
PI_3.py.txt
In this picture and below, I plot the plasma density using the Probe diagnostic. One sees that boundary condition remove is working fine on the right but the injection is located around x=0. One would have expected presence of some plasma in the upper part of figure at later times?
Case 2:
Injection at the left boundary and intilize plasma closer to the right boundary.
PI_4.py.txt
In this case there should not have been any reflection of particles from the right boundary due to remove boundary conditions. Also the spike at x=0 seen in Case 1 disappears now.
Case 3:
Injection from the right boundary in +x direction and plasma is in whole simulation box
PI_2.py.txt
In this the boundary condition remove doesn't seem to work on either sides. It seems as if it is overridden by the particle injection which is also assuming injection in -x direction from the right boundary though it is defined in +x direction. I had turned off external magnetic fields in this case compared to other cases, but it didn't have much influence on the issue present here.
Case 4.
Injection from thr right boundary in +x direction and plasma is closer to the right boundary.
PI_5.py.txt
This is similar to Case 2 above but the ParticleInjector is at xmax. Strangely, I can not run this simulation and always see segmentation fault suggesting problems in VectorPatch.
stderr.8870077.txt
It would be great if you can have a look at these results.
Parameters
Smilei version ?
Latest fetch from Github v4.4
Computing resources
g++ --version
)g++ (GCC) 6.2.0
mpic++ --version
,mpic++ -show
)Openmpi 2.0.1
h5cc --version
)1.8.21
python --version
)3.5.9
The text was updated successfully, but these errors were encountered: