-
Notifications
You must be signed in to change notification settings - Fork 230
[WIP] Integrate picsar_qed in ablastr #5677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
lucafedeli88
wants to merge
17
commits into
BLAST-WarpX:development
from
lucafedeli88:integrate_picsar_qed_in_warpx
Closed
[WIP] Integrate picsar_qed in ablastr #5677
lucafedeli88
wants to merge
17
commits into
BLAST-WarpX:development
from
lucafedeli88:integrate_picsar_qed_in_warpx
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for more information, see https://pre-commit.ci
EZoni
pushed a commit
that referenced
this pull request
Feb 28, 2025
Pure functions like `linear_interp`, `bilinear_interp`, and `trilinear_interp` are very general. Therefore, we can consider to move them to `ablastr::math`. Besides, I will need some of these functions to move `picsar_qed` inside `ablastr` (#5677)
…csar_qed_in_warpx
…88/WarpX into integrate_picsar_qed_in_warpx
lucafedeli88
added a commit
that referenced
this pull request
Nov 5, 2025
…n using single/double precision (#5828) With this PR the constants in ablastr are first defined using variable templates and then specialized for `amrex::Real`, e.g., for mathematical constants: ```C++ /** Mathematical constants */ namespace math { //! ratio of a circle's circumference to its diameter (variable template) template<typename T> constexpr auto pi_v = static_cast<T>(3.14159265358979323846); //! https://tauday.com/tau-manifesto (variable template) template<typename T> constexpr auto tau_v = static_cast<T>(2.0 * pi_v<double>); //! ratio of a circle's circumference to its diameter constexpr auto pi = pi_v<amrex::Real>; //! https://tauday.com/tau-manifesto constexpr auto tau = tau_v<amrex::Real>; } // namespace math ``` This is done with the intent of allowing the use of `double` precision constants even if the code is compiled in single precision (or vice versa if you really want it !), e.g. : ```C++ const auto a = 2_rt * math::pi; // a is an amrex::Real const auto b = 2 * math::pi_v<double>; // b is a double ! const auto c = 2 * math::pi_v<float>; // c is a float ! ``` I will need this feature to import the QED module from PICSAR into WarpX. I've started migrating the code in #5677 ,but the PR is becoming too big, so I decided to split it into smaller chunks. The new feature is now used in the template function `Algorithms::KineticEnergy` . This function is conceived to be able to force double precision in some cases regardless of how WarpX has been compiled. Therefore, using `c` in double precision in these cases is coherent with its goal. Note that I've changed the variables from `static constexpr` to `constexpr` because, to my understanding, `static` does not make any difference in this context. ## Previous discussions With this PR the constants in ablastr are first defined using variable templates and then specialized for `amrex::Real`, e.g., for mathematical constants: ```C++ namespace math { namespace variable_templates { template<typename T> constexpr auto pi = static_cast<T>(3.14159265358979323846); template<typename T> constexpr auto tau = static_cast<T>(2.0 * pi<double>); } constexpr auto pi = variable_templates::pi<amrex::Real>; constexpr auto tau = variable_templates::tau<amrex::Real>; } // namespace math ``` This is done with the intent of allowing the use of `double` precision constants even if the code is compiled in single precision (or vice versa if you really want it !), e.g. : ```C++ using namespace ablastr; namespace math_vt = math::variable_templates; const auto a = 2_rt * math::pi; // a is an amrex::Real const auto b = 2 * math_vt::pi<double>; // b is a double ! ``` I will need this feature to import the QED module from PICSAR into WarpX. I've started migrating the code in #5677 ,but the PR is becoming too big, so I decided to split it into smaller chunks. The new feature is now used in the template function `Algorithms::KineticEnergy` . This function is conceived to be able to force double precision in some cases regardless of how WarpX has been compiled. Therefore, using `c` in double precision in these cases is coherent with its goal. In case you don't like the long namespace name `variable_template`, an alternative would be to call it `vt`. Note that I've changed the variables from `static constexpr` to `constexpr` because, to my understanding, `static` does not make any difference in this context. ### Updates - Following @dpgrote 's suggestion, I've changed `variable_templates` to `const_templates` - Following @aeriforme 's suggestion, I've added `c2`, `invc` and `inv_c2` constants, and I have tested them by modifying a couple of source files. - Following @WeiqunZhang 's suggestion, I am now using `_v` suffix to indicate variable templates, as done in C++20 https://en.cppreference.com/w/cpp/numeric/constants.html
Member
Author
|
We will do this step-by-step. See #6427 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[TO DO]