Fix computeBunchMoments bugs, BunchTwissAnalysis refactor, bump to C++17#132
Fix computeBunchMoments bugs, BunchTwissAnalysis refactor, bump to C++17#132woodtp wants to merge 7 commits into
computeBunchMoments bugs, BunchTwissAnalysis refactor, bump to C++17#132Conversation
- tabs -> 2 spaces per style guide - foreach loop for the extension modules - clean up cpp_args - migrate c++ standard specification to project() - global project argument for `-DUSE_MPI` - Removed `-fPIC`. Meson handles this for us. - set default buildtype to 'release' in project() - can be overridden with `meson setup ... -Dbuildtype=debug` - Add `-march=native` global project argument, conditionally. - Since we don't distribute binaries and expect users to compile pyo3 for themselves, I don't see a reason not to include this flag as it can only help performance. At worst, it does nothing.
…unchTwissAnalysis::analyzeBunch. Bump to c++17. The moment calculation bugs are corrected, and an additional `normalization` flag is added to computeBunchMoments to prevent normalization of x-y moments by sqrt(beta) or sqrt(beta*emitt) unless explicitly requested. The class has been reworked to expedite calculation of moments up to 2nd order, which is the most common usecase. Previously, calling computeBunchMoments would scale as O(N^2) due to a double loop over the Bunch. Now, the double loop is triggered only if moment orders >=3 are requested. Bumping the c++ std version allows us to more easily compose specialized implementations of the moments calculation based on whether the dispersion correction is enabled or the 'macrosize' bunch attribute is defined. When these two conditions are `false`, the compiler will be able to optimize-out the extra instructions within in the Bunch loop(s) that these scenarios require.
| int order = 2; | ||
| int normalize = 0; | ||
| int emitnormterm = 0; | ||
| int dispterm = 0; | ||
| if (!PyArg_ParseTuple( | ||
| args, | ||
| "O|ippp:computeBunchMoments", | ||
| &pyBunch, | ||
| &order, | ||
| &normalize, | ||
| &emitnormterm, | ||
| &dispterm | ||
| )) { |
There was a problem hiding this comment.
Note that these lines are the only true changes to wrap_bunch_twiss_analysis.cc. Everything else is just formatting via clang-format.
|
CI checks for every build except Converting to draft. |
|
Quote: “I've also unified computeBunchMoments and analyzeBunch and marked the analyzeBunch method with [[deprecated]]. The choice is sort-of arbitrary, but I think we should favor computeBunchMoments as the entry point, because the name is more descriptive.” I asked Google: Answer: So, I am not sure that computeBunchMoments is the same as analyzeBunch. I seems to me that analyzeBunch is more appropriate name. |
|
@shishlo The function |
|
And |
Fixes #121.
Based on #122.
The moment calculation bugs are corrected, and an additional$\sqrt{\beta_{x,y}}$ or $\sqrt{\beta_{x,y}\varepsilon_{x,y}}$ unless explicitly requested.
normalizeflag is added tocomputeBunchMomentsto prevent normalization of x-y moments by powers of eitherThe class has been reworked to expedite calculation of moments up to 2nd order, which is the most common use case. Previously, calling$O(N^2)$ due to a double loop over the$\geq3$ are requested. Maybe there's a clever way to get around doing the loop twice, but my impression is that these terms are not needed very often anyway.
computeBunchMomentswould scale asBunch. Now, the double loop is triggered only if moment orders
I've also unified
computeBunchMomentsandanalyzeBunchand marked theanalyzeBunchmethod with[[deprecated]]. The choice is sort-of arbitrary, but I think we should favorcomputeBunchMomentsas the entry point, because the name is more descriptive. Previously, both methods calculated moments; the difference was thatanalyzeBunchwas calculating up to 2nd order moments, whilecomputeBunchMomentsitself calledanalyzeBunchbefore calculating x-y moments up to the requestedorder.analyzeBunchwill still work until removed, but will now emit a warning message (only at first invocation) thatcomputeBunchMomentsshould be used instead before forwarding arguments to computeBunchMoments.Bumping the c++ standard allows us to more easily compose specialized implementations of the moments calculation based on whether the dispersion correction is enabled or the
macrosizebunch attribute isdefined. When these two conditions are
false, the compiler should be able to optimize-out the extra instructions within the Bunch loop(s) that these scenarios require.Questions
getBunchMoment(i, j)and notgetCorrelation(i, j).