Skip to content

Commit

Permalink
Correct perveance calculation. Hard-coded current for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
cemitch99 committed Feb 14, 2025
1 parent 1878ab0 commit 7c39662
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/particles/spacecharge/EnvelopeSpaceChargePush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <AMReX_REAL.H> // for Real
#include <AMReX_SmallMatrix.H>
#include <AMReX_ParmParse.H>
#include <AMReX_Print.H>

#include <cmath>

Expand All @@ -22,7 +23,7 @@ namespace impactx::spacecharge
envelope_space_charge2D_push (
[[maybe_unused]] RefPart const & refpart,
Map6x6 & cm,
[[maybe_unused]] amrex::ParticleReal current,
amrex::ParticleReal current,
amrex::ParticleReal ds
)
{
Expand All @@ -31,11 +32,6 @@ namespace impactx::spacecharge
// initialize the linear transport map
Map6x6 R = Map6x6::Identity();

// added temporarily for benchmark testing
amrex::ParmParse pp_dist("dist");
amrex::ParticleReal beam_current = 0.0; // Beam current (A)
pp_dist.query("current", beam_current);

// physical constants and reference quantities
amrex::ParticleReal const c = ablastr::constant::SI::c;
amrex::ParticleReal const ep0 = ablastr::constant::SI::ep0;
Expand All @@ -44,10 +40,12 @@ namespace impactx::spacecharge
amrex::ParticleReal const charge = refpart.charge;
amrex::ParticleReal const pt_ref = refpart.pt;
amrex::ParticleReal const betgam2 = std::pow(pt_ref, 2) - 1.0_prt;
amrex::ParticleReal const betgam = std::sqrt(betgam2);
amrex::ParticleReal const betgam3 = std::pow(betgam,3);

// evaluate the beam space charge perveance from current
amrex::ParticleReal const IA = 4.0_prt*pi*ep0*mass*pow(c,3)/charge;
amrex::ParticleReal const Kpv = (beam_current/IA) * 2.0_prt/betgam2;
amrex::ParticleReal const Kpv = std::abs(current/IA) * 2.0_prt/betgam3;

// evaluate the linear transfer map
amrex::ParticleReal const sigma2 = cm(1,1)*cm(3,3)-cm(1,3)*cm(1,3);
Expand Down
2 changes: 1 addition & 1 deletion src/tracking/envelope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace impactx
if (space_charge)
{
// push Covariance Matrix in 2D space charge fields
amrex::ParticleReal current=0.0; //TODO: This must be set.
amrex::ParticleReal current=0.5; //TODO: This must be set.
spacecharge::envelope_space_charge2D_push(ref,cm,current,slice_ds);
}

Expand Down

0 comments on commit 7c39662

Please sign in to comment.