Skip to content

Commit 4d9f816

Browse files
committed
Update Green function formula
1 parent fa8e9a2 commit 4d9f816

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Source/ablastr/fields/PoissonSolver.H

+3-9
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,9 @@ amrex::Real IntegratedPotential( amrex::Real x, amrex::Real y, amrex::Real z ) {
5959
- 0.5 * z*z * std::atan( x*y/(z*r) )
6060
- 0.5 * y*y * std::atan( x*z/(y*r) )
6161
- 0.5 * x*x * std::atan( y*z/(x*r) )
62-
+ 0.5 * y*z*std::log( (1 + x/r)/(1 - x/r) )
63-
+ 0.5 * x*z*std::log( (1 + y/r)/(1 - y/r) );
64-
if (z >= 0) {
65-
G += x*y*std::log( z + r );
66-
} else {
67-
// When z is negative and much larger than x and y (in absolute value), floating point operation can cause issues
68-
// Thus, here we use z+r = (z+r)(r-z)/(r-z)
69-
G += x*y*std::log( (x*x + y*y)/(r-z) );
70-
}
62+
+ y*z*std::asinh( x/std::sqrt(y*y + z*z) )
63+
+ x*z*std::asinh( y/std::sqrt(x*x + z*z) )
64+
+ x*y*std::asinh( z/std::sqrt(x*x + y*y) );
7165
return G;
7266
}
7367

0 commit comments

Comments
 (0)