Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 2, 2025
1 parent f402bea commit 3d03da4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
26 changes: 13 additions & 13 deletions src/envelope/spacecharge/Elliptic_Integral.H
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace impactx::envelope::spacecharge
{

/** Function to return the Carlson elliptic integral denoted
* by RD(x,y,z). This is a slight modification of
* the C++ function written by John Burkardt (GNU LGPL license):
Expand All @@ -34,12 +34,12 @@ namespace impactx::envelope::spacecharge
* Computing Elliptic Integrals by Duplication,
* Numerische Mathematik,
* Volume 33, 1979, pages 1-16.
*
*
* Bille Carlson, Elaine Notis,
* Algorithm 577, Algorithms for Incomplete Elliptic Integrals,
* ACM Transactions on Mathematical Software,
* Volume 7, Number 3, pages 398-403, September 1981.
*
*
* @param[in] x first argument
* @param[in] y second argument
* @param[in] z third argument
Expand All @@ -48,7 +48,7 @@ namespace impactx::envelope::spacecharge
*/
amrex::ParticleReal
Elliptic_RD (
amrex::ParticleReal x,
amrex::ParticleReal x,
amrex::ParticleReal y,
amrex::ParticleReal z,
amrex::ParticleReal errtol
Expand Down Expand Up @@ -92,13 +92,13 @@ namespace impactx::envelope::spacecharge
// IN THE FOLLOWING TABLE IT IS ASSUMED THAT ERRTOL WILL
// NEVER BE CHOSEN SMALLER THAN 1.D-5.
//
if (
x < 0.0 ||
y < 0.0 ||
x + y < lolim ||
z < lolim ||
uplim < x ||
uplim < y ||
if (
x < 0.0 ||
y < 0.0 ||
x + y < lolim ||
z < lolim ||
uplim < x ||
uplim < y ||
uplim < z )
{
amrex::Print() << "\n";
Expand All @@ -124,7 +124,7 @@ namespace impactx::envelope::spacecharge
xndev = ( mu - xn ) / mu;
yndev = ( mu - yn ) / mu;
zndev = ( mu - zn ) / mu;
epslon = std::max ( std::abs ( xndev ),
epslon = std::max ( std::abs ( xndev ),
std::max ( std::abs ( yndev ), std::abs ( zndev ) ) );

if ( epslon < errtol )
Expand Down Expand Up @@ -156,7 +156,7 @@ namespace impactx::envelope::spacecharge
}

}

} // namespace impactx::envelope::spacecharge

#endif // ELLIPTIC_INTEGRAL_H
16 changes: 8 additions & 8 deletions src/envelope/spacecharge/EnvelopeSpaceChargePush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ namespace impactx::envelope::spacecharge
)
{
using namespace amrex::literals;

// skip calculations for trivial case
if (bunch_charge == 0_prt) { return; }

// initialize the linear transport map
Map6x6 R = Map6x6::Identity();

Expand All @@ -93,33 +93,33 @@ namespace impactx::envelope::spacecharge
amrex::ParticleReal const pt_ref = refpart.pt;
amrex::ParticleReal const betgam2 = std::pow(pt_ref, 2) - 1_prt;
amrex::ParticleReal const betgam = std::sqrt(betgam2);

// evaluate the 3D space charge intensity parameter from bunch charge
amrex::ParticleReal const rcN = charge * bunch_charge / (4_prt * pi * ep0 * mass * std::pow(c,2));
amrex::ParticleReal const coeff = ds * rcN / betgam2 * (1_prt/(5_prt * std::sqrt(5_prt)));

// set parameters for elliptic integrals
amrex::ParticleReal const errtol = 1.0e-3;
amrex::ParticleReal const x = cm(1,1);
amrex::ParticleReal const y = cm(3,3);
amrex::ParticleReal const z = betgam * cm(5,5);

// evaluate the off-identity elements of the linear transfer map
R(2,1) = coeff * Elliptic_RD(y,z,x,errtol);
R(2,1) = coeff * Elliptic_RD(y,z,x,errtol);
R(4,3) = coeff * Elliptic_RD(z,x,y,errtol);
R(6,5) = coeff * Elliptic_RD(x,y,z,errtol);

// update the beam covariance matrix
cm = R * cm * R.transpose();

// test of elliptic integral evaluation only
// test of elliptic integral evaluation only
//amrex::ParticleReal const x = 1.0;
//amrex::ParticleReal const y = 5.0;
//amrex::ParticleReal const z = 0.02;
//amrex::ParticleReal const errtol = 1.0e-3;
//amrex::ParticleReal rd = Elliptic_RD(x,y,z,errtol);
//amrex::Print() << "RD( " << x << "," << y << "," << z << " ) = " << rd << "\n";

}


Expand Down

0 comments on commit 3d03da4

Please sign in to comment.