Search code examples
c++solverpoisson

C++ | Particle In Cell simulation for plasma physics - Poisson equation solver over a standard grid


I am constructing my own set of processes for the task that is ahead of me, however I am currently stuck at the 3D Poisson equation to solve potentials and magnetic fields generated by moving charged particles.

In short, Particle In Cell consists of 4 core processes:

  1. Integration of movement particles (from Lorentz equation),
  2. distribution of charge densities to the nodes of the grid (and current densities for magnetic fields),
  3. solving of Poisson equation to compute potentials and electric/magnetic fields at the nodes of grid,
  4. distribution of electric/magnetic fields to particles.

And the cycle repeats. I am able to do the steps (1), (2) and (4), but not the Poisson part. I am integrating particles by Boris scheme, grid is simply constructed as cell[i][j][k], with dimensions of K x L x M and the distribution process is a little bit tricky, but not very hard after all.

However, to my big surprise, I cannot find any suitable library that will solve 3D Poisson equation via Finite Differences Method (FDM). I am starting to think that I will have to write my own solver, but solving partial differential equations is a science on itself and I was told to not try this solution, since the results may be unstable if I don't do it properly. FFT may be also a solution, but I need something that will work even if boundary conditions are not periodic.

My question is:

Do you know of any suitable library for C++, that will take the right hand side of Poisson equation and compute the resulting potentials? Computation has to be done via FDM. Also, right hand side of Poisson equation actually means the whole grid of K x L x M points, which is integrated over a finite differences - edges of the grid.

Is it hard to write my own solver for Poisson equation? What algorithm do you recommend?

Do you know of any other solutions? Free software, well-written paper or documentation, thesis paper, anything.

Thank you in advance, this is currently a very serious problem for me since I cannot continue in my work.


Solution

  • You can try some library like libmesh or deal ii. They are made formthis kind of problems...