Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/dependencies/pyAMReX.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ set(ImpactX_pyamrex_src ""

# Git fetcher
option(ImpactX_pyamrex_internal "Download & build pyAMReX" ON)
set(ImpactX_pyamrex_repo "https://github.com/AMReX-Codes/pyamrex.git"
set(ImpactX_pyamrex_repo "https://github.com/ax3l/pyamrex.git"
CACHE STRING
"Repository URI to pull and build pyamrex from if(ImpactX_pyamrex_internal)")
set(ImpactX_pyamrex_branch "de24942c76ebc61ffaa184204c2491aebc357a07"
set(ImpactX_pyamrex_branch "topic-polymorphic-pc"
CACHE STRING
"Repository branch for ImpactX_pyamrex_repo if(ImpactX_pyamrex_internal)")

Expand Down
4 changes: 2 additions & 2 deletions src/elements/diagnostics/BeamMonitor.H
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace detail
{
class ImpactXParticleCounter {
public:
using ParticleContainer = typename ImpactXParticleContainer::ContainerLike<amrex::PinnedArenaAllocator>;
using ParticleContainer = typename ImpactXParticleContainer::ContainerLike<amrex::PolymorphicArenaAllocator>;
using ParticleIter = typename ParticleContainer::ParIterType;

ImpactXParticleCounter (ParticleContainer & pc);
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace detail
{
static constexpr auto type = "BeamMonitor";
using PType = typename ImpactXParticleContainer::ParticleType;
using PinnedContainer = typename ImpactXParticleContainer::ContainerLike<amrex::PinnedArenaAllocator>;
using PinnedContainer = typename ImpactXParticleContainer::ContainerLike<amrex::PolymorphicArenaAllocator>;

/** This element writes the particle beam out to openPMD data.
*
Expand Down
3 changes: 2 additions & 1 deletion src/elements/diagnostics/BeamMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ namespace detail {
std::vector<std::string> int_soa_names = pc.GetIntSoANames();

// pinned memory copy
PinnedContainer pinned_pc = pc.make_alike<amrex::PinnedArenaAllocator>();
PinnedContainer pinned_pc = pc.make_alike<amrex::PolymorphicArenaAllocator>();
pinned_pc.SetArena(amrex::The_Pinned_Arena());
pinned_pc.copyParticles(pc, true); // no filtering

// TODO: filtering
Expand Down
8 changes: 4 additions & 4 deletions src/envelope/spacecharge/EnvelopeSpaceChargePush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace impactx::envelope::spacecharge

// physical constants and reference quantities
using ablastr::constant::SI::c;
using ablastr::constant::SI::ep0;
using ablastr::constant::SI::epsilon_0;
using ablastr::constant::math::pi;
amrex::ParticleReal const mass = refpart.mass;
amrex::ParticleReal const charge = refpart.charge;
Expand All @@ -51,7 +51,7 @@ namespace impactx::envelope::spacecharge
amrex::ParticleReal const betgam3 = powi<3>(betgam);

// evaluate the beam space charge perveance from current
amrex::ParticleReal const IA = 4_prt * pi * ep0 * mass * powi<3>(c) / charge;
amrex::ParticleReal const IA = 4_prt * pi * epsilon_0 * mass * powi<3>(c) / charge;
amrex::ParticleReal const Kpv = std::abs(current / IA) * 2_prt / betgam3;

// evaluate the linear transfer map
Expand Down Expand Up @@ -89,15 +89,15 @@ namespace impactx::envelope::spacecharge

// physical constants and reference quantities
using ablastr::constant::SI::c;
using ablastr::constant::SI::ep0;
using ablastr::constant::SI::epsilon_0;
using ablastr::constant::math::pi;
amrex::ParticleReal const mass = refpart.mass;
amrex::ParticleReal const charge = refpart.charge;
amrex::ParticleReal const pt_ref = refpart.pt;
amrex::ParticleReal const betgam2 = powi<2>(pt_ref) - 1_prt;

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

// set parameters for elliptic integrals
Expand Down
8 changes: 4 additions & 4 deletions src/initialization/InitDistribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ namespace impactx
amrex::ParticleReal massE; // MeV/c^2
if (particle_type == "electron") {
qe = -1.0;
massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_invc2;
massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_inv_c2;
} else if (particle_type == "positron") {
qe = 1.0;
massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_invc2;
massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_inv_c2;
} else if (particle_type == "proton") {
qe = 1.0;
massE = ablastr::constant::SI::m_p / ablastr::constant::SI::MeV_invc2;
massE = ablastr::constant::SI::m_p / ablastr::constant::SI::MeV_inv_c2;
} else if (particle_type == "Hminus") {
qe = -1.0;
massE = 939.294308; // value used in TraceWin
Expand All @@ -66,7 +66,7 @@ namespace impactx
ablastr::warn_manager::WarnPriority::low
);
qe = -1.0;
massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_invc2;
massE = ablastr::constant::SI::m_e / ablastr::constant::SI::MeV_inv_c2;
}

// configure a new reference particle
Expand Down
10 changes: 5 additions & 5 deletions src/particles/ImpactXParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ namespace impactx
* `static` in AMReX, to `dynamic` in ImpactX.
*/
class ParIterSoA
: public amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs>
: public amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>
{
public:
using amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs>::ParIterSoA;
using amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>::ParIterSoA;

ParIterSoA (ContainerType& pc, int level);

Expand All @@ -112,10 +112,10 @@ namespace impactx
* `static` in AMReX, to `dynamic` in ImpactX.
*/
class ParConstIterSoA
: public amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs>
: public amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>
{
public:
using amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs>::ParConstIterSoA;
using amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>::ParConstIterSoA;

ParConstIterSoA (ContainerType& pc, int level);

Expand All @@ -129,7 +129,7 @@ namespace impactx
* This class stores particles, distributed over MPI ranks.
*/
class ImpactXParticleContainer
: public amrex::ParticleContainerPureSoA<RealSoA::nattribs, IntSoA::nattribs>
: public amrex::ParticleContainerPureSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>
{
public:
//! amrex iterator for particle boxes
Expand Down
11 changes: 6 additions & 5 deletions src/particles/ImpactXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,25 @@ namespace
namespace impactx
{
ParIterSoA::ParIterSoA (ContainerType& pc, int level)
: amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs>(pc, level,
: amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>(pc, level,
amrex::MFItInfo().SetDynamic(do_omp_dynamic())) {}

ParIterSoA::ParIterSoA (ContainerType& pc, int level, amrex::MFItInfo& info)
: amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs>(pc, level,
: amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>(pc, level,
info.SetDynamic(do_omp_dynamic())) {}

ParConstIterSoA::ParConstIterSoA (ContainerType& pc, int level)
: amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs>(pc, level,
: amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>(pc, level,
amrex::MFItInfo().SetDynamic(do_omp_dynamic())) {}

ParConstIterSoA::ParConstIterSoA (ContainerType& pc, int level, amrex::MFItInfo& info)
: amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs>(pc, level,
: amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>(pc, level,
info.SetDynamic(do_omp_dynamic())) {}

ImpactXParticleContainer::ImpactXParticleContainer (initialization::AmrCoreData* amr_core)
: amrex::ParticleContainerPureSoA<RealSoA::nattribs, IntSoA::nattribs>(amr_core->GetParGDB())
: amrex::ParticleContainerPureSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>(amr_core->GetParGDB())
{
SetArena(amrex::The_Arena());
SetParticleSize();
SetSoACompileTimeNames(
{RealSoA::names_s.begin(), RealSoA::names_s.end()},
Expand Down
4 changes: 2 additions & 2 deletions src/particles/ReferenceParticle.H
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace impactx
{
using namespace amrex::literals;

constexpr amrex::ParticleReal inv_MeV_invc2 = 1.0_prt / ablastr::constant::SI::MeV_invc2;
constexpr amrex::ParticleReal inv_MeV_invc2 = 1.0_prt / ablastr::constant::SI::MeV_inv_c2;
return amrex::ParticleReal(mass * inv_MeV_invc2);
}

Expand All @@ -145,7 +145,7 @@ namespace impactx
AMREX_ASSERT_WITH_MESSAGE(massE != 0.0_prt,
"set_mass_MeV: Mass cannot be zero!");

mass = massE * ablastr::constant::SI::MeV_invc2;
mass = massE * ablastr::constant::SI::MeV_inv_c2;

// re-scale pt and pz
if (pt != 0.0_prt)
Expand Down
4 changes: 2 additions & 2 deletions src/particles/distribution/Thermal.H
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ namespace distribution
m_bg = bg;

// Get reference particle rest energy (eV) and charge (q_e)
amrex::ParticleReal Erest = refpart.mass_MeV()*1.0e6;
amrex::ParticleReal Erest = refpart.mass_MeV() * 1.0e6_prt;
amrex::ParticleReal q_e = refpart.charge_qe();

// Set space charge intensity
m_Cintensity = q_e*bunch_charge/(powi<2>(bg)*Erest*ablastr::constant::SI::ep0);
m_Cintensity = q_e*bunch_charge/(powi<2>(bg)*Erest*ablastr::constant::SI::epsilon_0_v<amrex::ParticleReal>);

// Set minimum and maximum radius
amrex::ParticleReal r_scale = matched_scale_radius();
Expand Down
2 changes: 1 addition & 1 deletion src/particles/spacecharge/PoissonSolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace impactx::particles::spacecharge
// fix side effect on rho from previous call
for (int lev=0; lev<=finest_level; lev++) {
using namespace ablastr::constant::SI;
rho[lev].mult(-1._rt * ep0);
rho[lev].mult(-1._rt * epsilon_0);
}

// We may need to copy phi from phi_2d
Expand Down
2 changes: 1 addition & 1 deletion src/particles/wakefields/WakeConvolution.H
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace impactx::particles::wakefields
using namespace amrex::literals;
using amrex::Math::powi;

amrex::Real const rc = powi<2>(ablastr::constant::SI::q_e) / (4_rt * amrex::Real(M_PI) * ablastr::constant::SI::ep0 * ablastr::constant::SI::m_e * powi<2>(ablastr::constant::SI::c));
amrex::Real const rc = powi<2>(ablastr::constant::SI::q_e) / (4_rt * amrex::Real(M_PI) * ablastr::constant::SI::epsilon_0 * ablastr::constant::SI::m_e * powi<2>(ablastr::constant::SI::c));
amrex::Real const kappa = (2_rt * rc * ablastr::constant::SI::m_e * powi<2>(ablastr::constant::SI::c)) / std::pow(3_rt, 1_rt/3_rt) / std::pow(R, 2_rt/3_rt);

return -3_rt/2_rt * kappa / bin_size * (unit_step(s + bin_size / 2_rt) * std::pow(std::abs(s + bin_size / 2_rt), 2_rt/3_rt) - unit_step(s - bin_size / 2_rt) * std::pow(std::abs(s - bin_size / 2_rt), 2_rt/3_rt));
Expand Down
6 changes: 3 additions & 3 deletions src/python/ImpactXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void init_impactxparticlecontainer(py::module& m)

py::class_<
ParIterSoA,
amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs>
amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>
> py_pariter_soa(m, "ImpactXParIter");
py_pariter_soa
.def(py::init<ParIterSoA::ContainerType&, int>(),
Expand All @@ -42,7 +42,7 @@ void init_impactxparticlecontainer(py::module& m)

py::class_<
ParConstIterSoA,
amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs>
amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>
> py_parconstiter_soa(m, "ImpactXParConstIter");
py_parconstiter_soa
.def(py::init<ParConstIterSoA::ContainerType&, int>(),
Expand All @@ -53,7 +53,7 @@ void init_impactxparticlecontainer(py::module& m)

py::class_<
ImpactXParticleContainer,
amrex::ParticleContainerPureSoA<RealSoA::nattribs, IntSoA::nattribs>
amrex::ParticleContainerPureSoA<RealSoA::nattribs, IntSoA::nattribs, amrex::PolymorphicArenaAllocator>
>(m, "ImpactXParticleContainer")
//.def(py::init<>())

Expand Down
Loading