diff --git a/cmake/dependencies/ABLASTR.cmake b/cmake/dependencies/ABLASTR.cmake index 4bc9b4e8e..87ffab855 100644 --- a/cmake/dependencies/ABLASTR.cmake +++ b/cmake/dependencies/ABLASTR.cmake @@ -162,7 +162,7 @@ set(ImpactX_openpmd_src "" set(ImpactX_ablastr_repo "https://github.com/ECP-WarpX/WarpX.git" CACHE STRING "Repository URI to pull and build ABLASTR from if(ImpactX_ablastr_internal)") -set(ImpactX_ablastr_branch "25.01" +set(ImpactX_ablastr_branch "958a39463c9e3fea0bbe1da0306104ccf9a2164c" CACHE STRING "Repository branch for ImpactX_ablastr_repo if(ImpactX_ablastr_internal)") @@ -170,7 +170,7 @@ set(ImpactX_ablastr_branch "25.01" set(ImpactX_amrex_repo "https://github.com/AMReX-Codes/amrex.git" CACHE STRING "Repository URI to pull and build AMReX from if(ImpactX_amrex_internal)") -set(ImpactX_amrex_branch "f6d3d70cadfc03036f5fdc4f89b7fcb225792716" +set(ImpactX_amrex_branch "" CACHE STRING "Repository branch for ImpactX_amrex_repo if(ImpactX_amrex_internal)") diff --git a/cmake/dependencies/pyAMReX.cmake b/cmake/dependencies/pyAMReX.cmake index 7632c88b9..8ab600e0b 100644 --- a/cmake/dependencies/pyAMReX.cmake +++ b/cmake/dependencies/pyAMReX.cmake @@ -74,7 +74,7 @@ option(ImpactX_pyamrex_internal "Download & build pyAMReX" ON) set(ImpactX_pyamrex_repo "https://github.com/AMReX-Codes/pyamrex.git" CACHE STRING "Repository URI to pull and build pyamrex from if(ImpactX_pyamrex_internal)") -set(ImpactX_pyamrex_branch "25.01" +set(ImpactX_pyamrex_branch "458c9ae7ab3cd4ca4e4e9736e82c60f9a7e7606c" CACHE STRING "Repository branch for ImpactX_pyamrex_repo if(ImpactX_pyamrex_internal)") diff --git a/examples/requirements.txt b/examples/requirements.txt index 7dd56f27b..006ad04b6 100644 --- a/examples/requirements.txt +++ b/examples/requirements.txt @@ -1,7 +1,9 @@ -r ../requirements.txt +# Work-Around for https://github.com/nkarast/PyNAFF/pull/10 +# pynaff +git+https://github.com/ax3l/PyNAFF.git@fix-complex-warning matplotlib numpy openpmd-api pandas -pynaff scipy diff --git a/requirements.txt b/requirements.txt index bcedcb6a3..e3e67247b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -numpy~=1.15 +numpy>=1.15 quantiphy~=2.19 diff --git a/src/particles/CollectLost.cpp b/src/particles/CollectLost.cpp index c25e8db1b..d0553002a 100644 --- a/src/particles/CollectLost.cpp +++ b/src/particles/CollectLost.cpp @@ -58,7 +58,7 @@ namespace impactx ImpactXParticleContainer& dest = *source.GetLostParticleContainer(); // Check destination has the same attributes as source + "s_lost" - for (auto & name : source.RealSoA_names()) + for (auto & name : source.GetRealSoANames()) { if (!dest.HasRealComp(name)) { amrex::Print() << "adding " << name << std::endl; @@ -67,7 +67,7 @@ namespace impactx AMREX_ALWAYS_ASSERT_WITH_MESSAGE(source.GetRealCompIndex(name) == dest.GetRealCompIndex(name), "Source and destination Real attributes misaligned!"); } - for (auto & name : source.intSoA_names()) + for (auto & name : source.GetIntSoANames()) { if (!dest.HasIntComp(name)) { dest.AddIntComp(name); @@ -81,9 +81,9 @@ namespace impactx bool comm = true; dest.AddRealComp("s_lost", comm); } - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(source.RealSoA_names().size() + 1 == dest.RealSoA_names().size(), + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(source.GetRealSoANames().size() + 1 == dest.GetRealSoANames().size(), "Source and destination have different Real attributes!"); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(source.intSoA_names().size() == dest.intSoA_names().size(), + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(source.GetIntSoANames().size() == dest.GetIntSoANames().size(), "Source and destination have different Int attributes!"); const int s_runtime_index = dest.GetRealCompIndex("s_lost") - dest.NArrayReal; diff --git a/src/particles/ImpactXParticleContainer.H b/src/particles/ImpactXParticleContainer.H index 1fc4efd70..27fdebc10 100644 --- a/src/particles/ImpactXParticleContainer.H +++ b/src/particles/ImpactXParticleContainer.H @@ -143,52 +143,6 @@ namespace impactx //! Destruct a particle container virtual ~ImpactXParticleContainer() = default; - /** Check if a container has a ParticleReal component - * - * @param name component name to check - * @return true if found, else false - */ - bool HasRealComp (std::string const & name); - - /** Check if a container has an Integer component - * - * @param name component name to check - * @return true if found, else false - */ - bool HasIntComp (std::string const & name); - - /** Get the ParticleReal SoA index of a component - * - * This throws a runtime exception if the component does not exist. - * - * @param name component name to query index for - * @return zero-based index - */ - int GetRealCompIndex (std::string const & name); - - /** Get the Integer SoA index of a component - * - * This throws a runtime exception if the component does not exist. - * - * @param name component name to query index for - * @return zero-based index - */ - int GetIntCompIndex (std::string const & name); - - /** Add a ParticleReal component - * - * @param name a unique name of the component, not colliding with RealSoA - * @param communicate participate in MPI communication when particles move - */ - void AddRealComp (std::string const & name, bool communicate=true); - - /** Add an Integer component - * - * @param name a unique name of the component, not colliding with IntSoA - * @param communicate participate in MPI communication when particles move - */ - void AddIntComp (std::string const & name, bool communicate=true); - /** Add new particles to the container for fixed s. * * Note: This can only be used *after* the initialization (grids) have @@ -309,14 +263,6 @@ namespace impactx DepositCharge (std::unordered_map & rho, amrex::Vector const & ref_ratio); - /** Get the name of each ParticleReal SoA component */ - std::vector - RealSoA_names () const; - - /** Get the name of each int SoA component */ - std::vector - intSoA_names () const; - /** Get the current coordinate system of particles in this container */ CoordSystem GetCoordSystem () const; @@ -342,12 +288,6 @@ namespace impactx //! the current coordinate system of particles in this container CoordSystem m_coordsystem = CoordSystem::s; - //! ParticleReal component names - std::vector m_real_soa_names; - - //! Int component names - std::vector m_int_soa_names; - }; // ImpactXParticleContainer } // namespace impactx diff --git a/src/particles/ImpactXParticleContainer.cpp b/src/particles/ImpactXParticleContainer.cpp index 4be795c81..7b9dc3c1a 100644 --- a/src/particles/ImpactXParticleContainer.cpp +++ b/src/particles/ImpactXParticleContainer.cpp @@ -59,62 +59,10 @@ namespace impactx : amrex::ParticleContainerPureSoA(amr_core->GetParGDB()) { SetParticleSize(); - - // name compile-time attributes - m_real_soa_names.resize(RealSoA::names_s.size()); - m_int_soa_names.resize(IntSoA::names_s.size()); - std::copy(RealSoA::names_s.begin(), RealSoA::names_s.end(), m_real_soa_names.begin()); - std::copy(IntSoA::names_s.begin(), IntSoA::names_s.end(), m_int_soa_names.begin()); - } - - bool ImpactXParticleContainer::HasRealComp (std::string const & name) - { - return std::find(m_real_soa_names.begin(), m_real_soa_names.end(), name) != std::end(m_real_soa_names); - } - - bool ImpactXParticleContainer::HasIntComp (std::string const & name) - { - return std::find(m_int_soa_names.begin(), m_int_soa_names.end(), name) != std::end(m_int_soa_names); - } - - int ImpactXParticleContainer::GetRealCompIndex (std::string const & name) - { - const auto it = std::find(m_real_soa_names.begin(), m_real_soa_names.end(), name); - - if (it == m_real_soa_names.end()) - throw std::runtime_error("GetRealCompIndex: Component " + name + " does not exist!"); - else - return std::distance(m_real_soa_names.begin(), it); - } - - int ImpactXParticleContainer::GetIntCompIndex (std::string const & name) - { - const auto it = std::find(m_int_soa_names.begin(), m_int_soa_names.end(), name); - - if (it == m_int_soa_names.end()) - throw std::runtime_error("GetIntCompIndex: Component " + name + " does not exist!"); - else - return std::distance(m_int_soa_names.begin(), it); - } - - void - ImpactXParticleContainer::AddRealComp (std::string const & name, bool communicate) - { - if (std::find(m_real_soa_names.begin(), m_real_soa_names.end(), name) != std::end(m_real_soa_names)) - throw std::runtime_error("AddRealComp: Component " + name + " already exists!"); - - m_real_soa_names.push_back(name); - amrex::ParticleContainerPureSoA::AddRealComp(communicate); - } - - void - ImpactXParticleContainer::AddIntComp (std::string const & name, bool communicate) - { - if (std::find(m_int_soa_names.begin(), m_int_soa_names.end(), name) != std::end(m_int_soa_names)) - throw std::runtime_error("AddIntComp: Component " + name + " already exists!"); - - m_int_soa_names.push_back(name); - amrex::ParticleContainerPureSoA::AddIntComp(communicate); + SetSoACompileTimeNames( + {RealSoA::names_s.begin(), RealSoA::names_s.end()}, + {IntSoA::names_s.begin(), IntSoA::names_s.end()} + ); } void @@ -300,18 +248,6 @@ namespace impactx >(*this); } - std::vector - ImpactXParticleContainer::RealSoA_names () const - { - return m_real_soa_names; - } - - std::vector - ImpactXParticleContainer::intSoA_names () const - { - return m_int_soa_names; - } - CoordSystem ImpactXParticleContainer::GetCoordSystem () const { diff --git a/src/particles/elements/diagnostics/openPMD.cpp b/src/particles/elements/diagnostics/openPMD.cpp index 16ff6c81c..b1323fd4b 100644 --- a/src/particles/elements/diagnostics/openPMD.cpp +++ b/src/particles/elements/diagnostics/openPMD.cpp @@ -336,8 +336,8 @@ namespace detail m_rbc = diagnostics::reduced_beam_characteristics(pc); // component names - std::vector real_soa_names = pc.RealSoA_names(); - std::vector int_soa_names = pc.intSoA_names(); + std::vector real_soa_names = pc.GetRealSoANames(); + std::vector int_soa_names = pc.GetIntSoANames(); // pinned memory copy PinnedContainer pinned_pc = pc.make_alike(); diff --git a/src/python/ImpactXParticleContainer.cpp b/src/python/ImpactXParticleContainer.cpp index fabd3c3f5..fc56a63ef 100644 --- a/src/python/ImpactXParticleContainer.cpp +++ b/src/python/ImpactXParticleContainer.cpp @@ -130,11 +130,6 @@ void init_impactxparticlecontainer(py::module& m) "Charge deposition" ) */ - - .def_property_readonly("RealSoA_names", &ImpactXParticleContainer::RealSoA_names, - "Get the name of each ParticleReal SoA component") - .def_property_readonly("intSoA_names", &ImpactXParticleContainer::intSoA_names, - "Get the name of each int SoA component") ; py_pariter_soa.def("pc", &ParIterSoA::pc); diff --git a/src/python/impactx/__init__.py b/src/python/impactx/__init__.py index 34cac419a..78cc31bd9 100644 --- a/src/python/impactx/__init__.py +++ b/src/python/impactx/__init__.py @@ -19,7 +19,6 @@ # import core bindings to C++ from . import impactx_pybind as cxx from .distribution_input_helpers import twiss # noqa -from .extensions.ImpactXParIter import register_ImpactXParIter_extension from .extensions.ImpactXParticleContainer import ( register_ImpactXParticleContainer_extension, ) @@ -43,5 +42,4 @@ RefPart.load_file = read_beam # noqa # Pure Python extensions to ImpactX types -register_ImpactXParIter_extension(cxx) register_ImpactXParticleContainer_extension(cxx.ImpactXParticleContainer) diff --git a/src/python/impactx/extensions/ImpactXParIter.py b/src/python/impactx/extensions/ImpactXParIter.py deleted file mode 100644 index 40d12c045..000000000 --- a/src/python/impactx/extensions/ImpactXParIter.py +++ /dev/null @@ -1,81 +0,0 @@ -""" -This file is part of ImpactX - -Copyright 2023 ImpactX contributors -Authors: Axel Huebl -License: BSD-3-Clause-LBNL -""" - - -def soa_real_comps(pti, num_comps): - """ - Name the ImpactX ParticleReal components in SoA. - - Parameters - ---------- - pti : ImpactXParIter or ImpactXParConstIter - used to query particle container component names - num_comps : int - number of components to generate names for. - - Returns - ------- - A list of length num_comps with values. - """ - names = pti.pc().RealSoA_names - - if len(names) != num_comps: - raise RuntimeError( - "num_comps ({num_comps}) is not equal to length of RealSoA_names ({len(names)})" - ) - - return names - - -def soa_int_comps(pti, num_comps): - """ - Name the ImpactX int components in SoA. - - Parameters - ---------- - pti : ImpactXParIter or ImpactXParConstIter - used to query particle container component names - num_comps : int - number of components to generate names for. - - Returns - ------- - A list of length num_comps with values. - """ - names = pti.pc().intSoA_names - - if len(names) != num_comps: - raise RuntimeError( - f"num_comps ({num_comps}) is not equal to length of intSoA_names ({len(names)})" - ) - - return names - - -def soa(self): - """Get the StructOfArrays on the current tile - - Parameters - ---------- - self : ImpactXParIter or ImpactXParConstIter - used to query particle container component names - """ - soa = super(type(self), self).soa() - - # overwrite name providers - soa.soa_real_comps = lambda num_comps: soa_real_comps(self, num_comps) - soa.soa_int_comps = lambda num_comps: soa_int_comps(self, num_comps) - - return soa - - -def register_ImpactXParIter_extension(impactx_pybind): - """ImpactXParIter helper methods""" - - impactx_pybind.ImpactXParIter.soa = soa - impactx_pybind.ImpactXParConstIter.soa = soa diff --git a/src/python/impactx/extensions/ImpactXParIter.pyi b/src/python/impactx/extensions/ImpactXParIter.pyi deleted file mode 100644 index 5757d68dd..000000000 --- a/src/python/impactx/extensions/ImpactXParIter.pyi +++ /dev/null @@ -1,69 +0,0 @@ -""" - -This file is part of ImpactX - -Copyright 2023 ImpactX contributors -Authors: Axel Huebl -License: BSD-3-Clause-LBNL -""" - -from __future__ import annotations - -__all__ = [ - "register_ImpactXParIter_extension", - "soa", - "soa_int_comps", - "soa_real_comps", -] - -def register_ImpactXParIter_extension(impactx_pybind): - """ - ImpactXParIter helper methods - """ - -def soa(self): - """ - Get the StructOfArrays on the current tile - - Parameters - ---------- - self : ImpactXParIter or ImpactXParConstIter - used to query particle container component names - - """ - -def soa_int_comps(pti, num_comps): - """ - - Name the ImpactX int components in SoA. - - Parameters - ---------- - pti : ImpactXParIter or ImpactXParConstIter - used to query particle container component names - num_comps : int - number of components to generate names for. - - Returns - ------- - A list of length num_comps with values. - - """ - -def soa_real_comps(pti, num_comps): - """ - - Name the ImpactX ParticleReal components in SoA. - - Parameters - ---------- - pti : ImpactXParIter or ImpactXParConstIter - used to query particle container component names - num_comps : int - number of components to generate names for. - - Returns - ------- - A list of length num_comps with values. - - """ diff --git a/src/python/impactx/extensions/__init__.pyi b/src/python/impactx/extensions/__init__.pyi index 0aa5be122..d8e64ee91 100644 --- a/src/python/impactx/extensions/__init__.pyi +++ b/src/python/impactx/extensions/__init__.pyi @@ -1,5 +1,5 @@ from __future__ import annotations -from . import ImpactXParIter, ImpactXParticleContainer +from . import ImpactXParticleContainer -__all__ = ["ImpactXParIter", "ImpactXParticleContainer"] +__all__ = ["ImpactXParticleContainer"] diff --git a/src/python/impactx/impactx_pybind/__init__.pyi b/src/python/impactx/impactx_pybind/__init__.pyi index acadebb03..8ecf3f8e8 100644 --- a/src/python/impactx/impactx_pybind/__init__.pyi +++ b/src/python/impactx/impactx_pybind/__init__.pyi @@ -521,7 +521,7 @@ class ImpactXParticleContainer( Set reference particle attributes. """ @property - def RealSoA_names(self) -> list[str]: + def GetRealSoANames(self) -> list[str]: """ Get the name of each ParticleReal SoA component """ @@ -531,7 +531,7 @@ class ImpactXParticleContainer( Get the current coordinate system of particles in this container """ @property - def intSoA_names(self) -> list[str]: + def GetIntSoANames(self) -> list[str]: """ Get the name of each int SoA component """