Matching Staggered Field with Charge on the Grid #685
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
I'm not familiar with the code that reads fields from file (so another developer might add to this), but I would expect that you do need to take into account of the fact that fields are staggered in space using the standard Yee grid. Your observations about the changes you see from shifting the field seems to back that up. Ghostcell values will be set by EPOCH, so there's no need for you to do anything about those. |
Beta Was this translation helpful? Give feedback.
-
Good use of a bump! I've made some progress but I forgot to update this. I was going through the source-code to fix issue 597, where I learned this error was only related to using maths parser expressions in the fields block, and it shouldn't affect fields set from files. You are to write your fields files assuming that everything is evaluated at the same point in time, If loading from a file, you are to give the code the values of the fields at their evaluation points (including grid-stagger). I'll include an example here. Suppose we have 6 cells, from 0 to 6 microns, in a 1D simulation. The
With outflow-boundaries, any fields on the simulation edge will be assumed 0. This includes the To test how the fields are loaded relative to particles, let us create a set of fields which are anti-symmetric about a point at 3 microns. This means that a particle positioned exactly at 3 microns will feel no acceleration from To write the binary files, I used this MATLAB script: % Simulation parameters
nx = 6;
% Setup anti-symmetric fields with stagger
ex_vals = 1.0e10 * [-1, -1, 0, 1, 1, 0];
ey_vals = 1.0e10 * [-1, -1, -1, 1, 1, 1];
% Write field files
ex_file = fopen('ex.bin','w');
ey_file = fopen('ey.bin','w');
for i = 1:nx
fwrite(ex_file,ex_vals(i),'double');
fwrite(ey_file,ey_vals(i),'double');
end
fclose(ex_file);
fclose(ey_file);
% Write files to load a particle at the zero-field point at 3um
x_file = fopen('x.bin', 'w');
w_file = fopen('w.bin', 'w');
fwrite(x_file,3.0e-6,'double');
fwrite(w_file,1,'double');
fclose(x_file);
fclose(w_file); And I used this input deck, where I've given the absolute path to the data files on my system:
When running this, I find that in the Hope this helps, |
Beta Was this translation helpful? Give feedback.
Hi Ryan,
I'd advise caution in that approach. You may be able to set up your system so it has a perfect initial charge distribution, but the steps are still evaluated using cell-discretised EM fields and current densities. In my experience, noise in the current densities (and hence the fields) are unavoidable in PIC codes. I think your safest bet would be to reduce the cell-size in your current set-up.
If your bunch has width 30 microns in a simulation with a 3 micron cell size, that's only 10 cells across. The particle-shape overflow would be an extra cell on each side, so a 20% modification to your intended shape.
If your simulations are quite expensive in 2D, it might be worth testing …