-
Notifications
You must be signed in to change notification settings - Fork 200
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
[WIP] Implement Poisson solver based on integrated Green functions #4611
Conversation
} | ||
|
||
void | ||
computePhiIGF ( amrex::MultiFab const & rho, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the function body of large functions like this can be moved to cpp files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. That's a good point.
amrex::Real const y = j0*dy; | ||
amrex::Real const z = k0*dz; | ||
|
||
amrex::Real const G_value = 1./(4*MathConst::pi*PhysConst::ep0) * ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ep::0
should be removed here, so that we can use this function also in the magnetostatic solver (same as with the multi-grid solver)
+ 0.5 * x*z*std::log( (1 + y/r)/(1 - y/r) ); | ||
if (z >= 0) { | ||
G += x*y*std::log( z + r ); | ||
} else { | ||
// When z is negative and much larger than x and y (in absolute value), floating point operation can cause issues | ||
// Thus, here we use z+r = (z+r)(r-z)/(r-z) | ||
G += x*y*std::log( (x*x + y*y)/(r-z) ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we have automated tests, this whole block of code could probably be replaced by:
+ 0.5 * x*z*std::log( (1 + y/r)/(1 - y/r) ); | |
if (z >= 0) { | |
G += x*y*std::log( z + r ); | |
} else { | |
// When z is negative and much larger than x and y (in absolute value), floating point operation can cause issues | |
// Thus, here we use z+r = (z+r)(r-z)/(r-z) | |
G += x*y*std::log( (x*x + y*y)/(r-z) ); | |
} | |
+ 0.5 * x*z*std::log( (1 + y/r)/(1 - y/r) ) | |
+ 0.5 * x*y * std::sign(z) * std::log( (r+std::abs(z))*(r+std::abs(z))/(x*x + y*y) ); |
(from the symmetrized form of the Green function)
Superseded by #4648 |
This uses the method from:
https://journals.aps.org/prab/abstract/10.1103/PhysRevSTAB.9.044204
https://journals.aps.org/prab/pdf/10.1103/PhysRevSTAB.10.129901
Because this uses the same FFT infrastructure as PSATD, right now, the code needs to be compiled with:
-DWarpX_PSATD=ON
.Also: since the solver uses a global FFT, right now only one MPI rank participates in the FFT solve (but this MPI rank can still use a full GPU) ; this could be improved later by using heFFTe. The rest of the PIC operations (charge deposition, gather, etc.) are still performed by the different MPI ranks in parallel.
Comparison with Basseti-Erskine formula (see the test script in this PR):

TODO:
ParallelCopy
)grid_type = collocated
(this could be done with the regular Poisson solver instead of the relativistic one, so that we can outputphi
)This should follow the same logic as the Maxwell solver. In the PICMI interface, there is already a “method” parameter for the Poisson solver.
Abort if someone tries to use mesh refinement
Properly set guard cells of
phi
outside of the global domain (useful forgrid_type = collocated
)Save the FFT plans in a permanent object, so that we do not need to recompute them.Probably not needed. From the timers, it seems that the creation and destruction of FFT plan does not take any significant time.Clean-up ; move code to a different file, maybe
IntegratedGreenFunctionSolver.H
, inablastr
Handle dimensionality that are not 3D, abort if we are not in 3D
Address warning
By calling the function in
VectorPoissonSolver.H
(for the magnetostatic solver)ParallelCopy
error that appears inDEBUG
mode: