-
Notifications
You must be signed in to change notification settings - Fork 120
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
External field #283
Comments
You see a ramp between the first 2 points of the grid. This is the limit of your resolution. |
Thanks for the quick reply! Yes, I use a resolution of dx=0.1. But I would have thought that B should be constant at the boundary also. Actually it occurs in the middle of the simulation too where I define different value of the same field. I can make the resolution smaller but I can't go really small otherwise computation will take longer. What is the best way to deal with this? Should a define xvacuum=-dx so that the field starts at a constant value at the left boundary and also in in the middle?This ramping generates an additional component of the electric field causing unphysical results. |
If you want a constant field even past the boundary, you should set xvacuum to a large negative value, and let the plateau be much longer than the box. In the middle of the box, there is nothing you can do. It is impossible to have shorter changes then the resolution. |
Ok. I could get away from the ramp on the left side by defining a python function profile. Is there any way to smoothen the fluctuation electric field that might arise due to this ramp in magnetic field in the middle of the simulation box? |
There are some filters available, but beware it might create unrealistic fields. |
Ok. I'll check and compare the results. Friedman filter is only available in 2D? I follow the strategy of Plotnikov et al. (2017). |
I have checked with filters and it made things even worse with unphysical results. I have another question related to the particle injector. I initialized the injector based on the discussions in #271, and I attach the namelist. I define plasma species (electrons and ions) in the simulation box and I'm also injecting these electrons and ions from the left boundary for the continuous flow. The number density is fixed at 1.0, but I see it is not 1.0 (see the figures attached) at the left boundary and shows large fluctuations. Why is this the case? I have played around with different strategies and used trapezoidal fuction with xvacuum to be large negative number. But with the particle injector block on, it always shows unusual behaviour (Ex is also not zero). Am I not understanding how the particle injector block is meant to be used. Please let me know. I'm running the version of Smilei, I fetched from GitHub since the official tarball releases (4.4 and 4.5) I couldn't compile. __ |
I am not very familiar with the injector, but I recall that particles are taken from a velocity distribution that may contain negative velocities. Those are discarded. This means there is a fluctuation due to the randomness of this sampling. |
Thanks for the reply. Your explanation makes sense. The puzzling aspect was that I am initialising a supersonic flow, so i was expecting a lower number of particles with negative velocity. Anyway, is there any way to smooth the initial conditions in Smilei? I know about the current and field filtering but they work for the whole simulation duration. I could be interested in smoothening the initial conditions for the simulation. Do you think if this can be accomplished by using the restart feature of Smilei? |
I am not sure how you did your diagnostics here, and I am not sure what is the difference you want to highlight. In general, Field diagnostics obtain the density of particles using a projector like the one that is used to project the currents on the grid (usual PIC stuff). The particleBinning are very different, because they only compute a sum of particle weights in some user-defined binning. In the future, please use a different issue for each question you have. In this issue you have asked many unrelated things and it is difficult to follow. |
Sorry about these too many things. Some of these things are related and I'm not sure if one is not causing problems with others. I wanted to check is the profiles functions used to initialise plasma, fields and also use Particle Injector block. To summarize, I see few points that I don't understand.
ExternalField( Number density for electrons and ions each number_density = trapezoidal(3.911, xvacuum=-2dx,xplateau=40.0Lsim,xslope1=0.0,xslope2=0.0), I also tried number_density = trapezoidal(3.911, xvacuum=-2dx,xplateau=40.0Lsim,xslope1=0.0,xslope2=100.0), Please see the figures, below. In my case Lsim=102.4 and dx=0.02. On the right hand boundary, I see fields and density going to zero and I can not control it. For the density I used the Probe diagnostic as it's much faster than Fields. I had used Lsim for defining the corner for the Probe diagnostic to calculate the densities in the figure.
So I tried saving density and fields with Fields and Probe diagnostics and also used ParticleBinning for the density. I had used time averaging to avoid the fluctuation caused by the Particle Injector block. This is what I wrote in the last post. The ParticleBinning diagnostic gives correct value of particle density (1 in my case) but the Field diagnostics does not give correct value of density (~0.10) if I use time_average= 10 for both diagnostics for whole simulation box. To summarise, I want to know the reasons for the fields going to zero at time t=0 on the right boundary despite profile functions saying otherwise. And problem with the densities on both left and right hand boundaries. I also want to know if I save em fields using Fields and Probe diagnostics then I should get the same results or not. |
Also does a constant external field is constant in time too? |
|
|
|
Dear @Tissot11, I have run your namelist to test the injection. I don't have the problem at the boundary. Is it something that happens at a given iteration ? For instance, I have plotted the density from the particle binning diagnostics and the charge from the field diagnostics at timestep 1600: Note that I agree with @mccoys explanation concerning fluctuations. Increasing the number of particle per cell at injection may improve the situation. |
First the namelist Bz profiles Densities. First Probe and then ParticleBinning |
Probably I had attached a wrong namelist before highlight the problem with time_average=10 with both ParticleBinning and Fields diagnostics. But now this issue has been settled by @mccoys this morning. Please try my namelist that I have just sent and look at the results. |
In fact I have used the namelist you sent 12 days ago. I am only looking at the injection issue. I can see on my computer that the jump can be seen only in the rho diags as you mentioned not in the particle binning. It disappear around iteration 1000 but it may due to the particles coming back from the reflective wall. I think the cause is clearly the interpolation with the boundary behaviour. As soon as the physics is far from it I think it's ok. |
Dear @xxirii, I have ran at least 30-40 simulations in different setups employing the particle injector block in last two weeks. Sorry that I mixed up namelist before. I've not yet been able to analyze the simulations with a reflecting wall on the right. But please have a look at the namelist that I have just attached 10 minutes before and also have a look at my results. |
Your issue is probably related to the particle boundary conditions, not external fields. The external fields are constant at the beginning so there is no problem. You see a drop on the left side only after a while. The drop at the right side is only caused by the fact that the point |
Sorry, I'm not able to fully follow you. At t=0 there is a problem on right boundary for the external field even though I have defined xplateau=40*Lsim following your earlier suggestion. After t>500 one starts seeing decline of Bz at the left while it grows at the right boundary, which can't be explained physically. I had also tried using corners=Lsim-dx for the Probe. Though it did help at t=0 but it manifested in a large spike in magnetic field at the right boundary and zero plasma density at later times. After a while density spikes up at the left boundary which is clearly unphysical. I'm using remove boundary conditions for the particle and silver_muller for EM fields. I'll try to run a simulation without plasmas and Particle Injector block and apply an external field to see what happens. |
|
Now I looked it these results. Since I haven't put any external fields in this simulation, I only saw that at the left and right boundaries initialization problems. I attach my figures. One can see that at both boundaries the density is around half of what it should be. |
I answered above this question. It is due to the projection algorithm that assumes there is no particle after the boundary. You have half the value because it makes some sort of smoothing between the plasma and the vacuum outside of the box. |
I have done few more simulations where I didn't use Probe but only Fields to save density and fields and also choosing corners=Lsim-dx. I'll send you figures later after I sort these results out. How about the spike at the left boundary for ions after t=500? Is this not unphysical?
Physically, it seems a bit improbable. Because the field is supposed to be initialised at the left boundary and it is constant throughout the simulation at least at the left boundary. In some cases, I can clearly see that it the same effect that you have particle injections. The value initialzed at the left boundary is a bit lower or even zero and somehow because of the drifting plasma, it starts moving to the right. This causes this field to decay. There is no transportation of magnetic field happening that fast on this time scale. I attach some figures to show what I meant. In this particular simulation, when the Bz becomes stronger at the right boundary, it stops the particle injection on the right boundary after 2e5 iterations. So this is contrary to what you're saying. I attach the namelist and these results on the electron plasma density. My question would be that if all these projection algorithms can also assume that there is a plasma in ghost cells behind the left boundary. The number of these ghost cells can be increased to get rid of these fluctuations at the boundaries to initialise both particles and external fields with desired values? In other words what one should do to correctly initialise a constant external field and inject a constant flux of particles with a given density at the boundaries during the whole simulation time? |
Yeah, now it works! Is there some reason behind this particular 2*dx value? I had tried first very large value both for the density and external fields. I noticed some issues with the particle injector, so I choose just 2*dx. Do you have any other suggestions that I should take into account about regarding whatever I have asked till now? |
The default interpolator width (number of ghost cells) is 2. Concerning the suggestions you ask, I am not sure. Are you talking about the injector setup ? I am really not used to the injection of particles, so I think some others should answer when they return from vacation. |
Ok. Yeah, I have still few questions about the particle injector but I'll wait until someone replies. Thanks a lot for the help! I did too many runs recently and I have to now understand these better. |
Sorry again coming back to this external field question. For contact magnetic field it does work. But I wanted to create a jump in magnetic field in the middle of the simulation box. I used both trapezoidal and my own python functions to define this magnetic field Bz. I see that due to this jump there is a numerical instability (both in the middle and at the left boundary) that actually affects the magnetic field applied. Since I don't apply any jump in Bx, it can not show any effect there even for _2*dx_initilization in vacuum. I had hoped this numerical instability arising due to jump i leaves the simulation box after a while since I use silver-muller boundary conditions. This is all in vacuum. Do you have any suggestions on this? |
A jump of Bz in the x direction makes a curl of the magnetic field. It should create Ey field over time, and then a traveling wave. Do you expect the fields to remain constant ? |
Yes, your explanation is correct. I expect the Bz field to be constant at and closer to the boundaries. At the location of jump in the simulation box and elsewhere, it will change. I can create a profile for jump in the middle to mitigate this Ey but at the left boundary, I don't know what I should do. I was expecting this Ey to propagate away to the left due to silver-muller boundary condition. It may take a while though. |
I am not sure what is the problem at the left. Your picture shows it constant. |
The magnitude gets lower. Until x<=40 It should have been 0.035. Due to this instability Ey, Bz becomes much lower even at the left boundary in vacuum. This stair-like structure in the simulation box suggest the formation of two waves at the discontinuity at x=40. Both of them moves in opposite direction. If you run my namelist then you will see that either the wave going to the left due to the discontinuity at _x=40_doesn't respect causality. Or something else happens at the left boundary too and the magnitude of the magnetic field gets lower at the boundary. |
I guess the solution lies in defining a python function and not using built-in spatial other than constant for the external field? Can time or space resolutions help in suppressing this instability? |
|
I thought it was only needed for the constant function. So this 3*dx initialisation is needed if I use any built-in SMILEI functions for Bz field? For Bx it doesn't matter and even a 2*dx initialisation works because Bx doesn't have any jump. Am I correct in interpreting this? Would a 3*dx initialisation also be required if I define a Python function like below? def BzProfile(x): In the simulations I have done with plasma inlcuded in the simulation, I find the behaviour of the em pulse due to discontinuity in middle according to the expectation. However, in those simulations I see a strange behaviour at the left boundary which is not connected with this discontinuity in the middle. I was using the built-in trapezoidal function to define Bz. So if I try -3*dx initilzation then hopefully I might not see any problem at the left boundary? Also do I need to do the same -3*dx initialisation for defining the plasma density using the trapezoidal function especially for drifting plasma? |
|
Ok. Thanks for tips! Did you try Vacuum-Trial.txt or namelist_9.txt? In Vacuum_trail.txt I had used trapezoidal function without -3*dx. In namelist_9.txt I used polygonal function but fixing the x0 at -2*dx. |
I tried Vacuum_trial |
Ok. I had done another simulation where I had set xvacuum=-100. This caused also unphysical results. So I should only set xvacuum=-3*dx and not too large value. Sometimes, I also see issue with the left boundary even if I defined a Python function like _ However, it is inconsistent and seems to depend also on other parameters of the simulation box. Regarding the corners of Probe diagnostic, I had intuitively thought that Lsim should be the corner. But this isn't case as you mentioned. Should I alway set 0.99*Lsim for it to work? Apparently when I increased the resolution of the simulation, choosing corners=Lsim or 0.99*Lsim generate error saying the Probes has no points in the simulation box. Does the numbers of points have anything to do with it and should be smaller than number of points chosen for the simulation grid. |
|
|
If you have an issue with probes, please open a new issue with more details on your setup. |
I have opened the issue and attached the namelist and stdout file. |
Could you recall what was the question with the injector? I am a bit lost |
|
Yes, I have positive drift for the plasma and I agree that it's a complicated system but I am trying to reproduce results that have been published before using other codes. This is the reason that I suggested that there can be some problems. I have done some test with stationary and drifting plasmas (without particle injections) and external fields and things look reasonable. |
Hi @Tissot11, I have tested the last version of your namelist on my small computer until time t = 300. There is indeed something strange. I can observe as well a spike growing at the right boundary. Particle injection may not be adapted in your case using an external field near the boundaries. I am not sure injecting particles as we do is correct in this case. Behind the boundaries, the magnetic field do not exist and the plasma is thermalized. In principle, the physics should happen far from the boundaries. Do you have examples in the literature of people doing the same thing with an injector ? |
Thanks for the quick answer! I'm also a bit puzzled and I would like to understand the source of this problem. I attach some papers here. My setup is similar but now I'm trying to reproduce these exact results. Please have a look. |
I see, I have to look at the injection methods maybe similar to what was suggested in issue #271. This is a long work and I cannot focus on this for the moment. I will try at least to get more information about the methods when I can. |
I had tried your workaround that you suggested in #271. I understand that you may have other things on your desk. It would be nice to have an understanding of the issue. Why there is an accumulation of particles on the right and sometime on the left boundaries, and why it seems to affect the external field on the left boundary. |
I am closing this issue as #293 is more specific on the remaining problems. |
Description
I'm trying to initialise external magnetic field using trapezoidal profile. However, at the left boundary of the simulation, I see a ramp in magnetic field strength despite I have set xslope1 and xslope2 to be zero. On the right boundary I don't see any ramping but only on the right side. I attach a snapshot and
paste some lines of namelist below. I'm also injecting particles but the issue using the random initialisation as suggested #271.
Steps to reproduce the problem
If relevant, provide a step-by-step guide
Parameters
2.7.5
)The text was updated successfully, but these errors were encountered: