-
Notifications
You must be signed in to change notification settings - Fork 217
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
refactor AU units #5133
refactor AU units #5133
Conversation
6f9b7a8
to
d1feb42
Compare
d1feb42
to
b52224a
Compare
Still in the process of the reviewing the PR, but there is one thing I am already really unhappy with. This in my eyes the wrong approach and leads to combining orthogonal sets of functions elements into one class and a large number of conversion methods. The root problem seems to be that the PR tries to press both code internal units and AtomicUnits into one class, although AtomicUnits are logically independent of the code internal units and should therefore be represented as a separate class with it's own conversion functions, instead of mashing them into one general set of conversion functions from SI to whatever. My suggestion would be to define for internalPicUnits and atomicUnits each a class holding only the 4 base quantities and their SI-values.
And for atomicUnits:
and then based on these define for each an daughter class that defines all the derived units in their respective unit systems, e.g. internalPicUnitEField, ... . In addition it would be nice to define unit prefixes in one central location to provide generic conversion methods to avoid the magic prefix conversion numbers. |
I agree with you that the current approach is not very nice. It is fully orientated on the current approach. I opened the issue #5135 for the unit system, but to be fair nobody was interested in this topic until now and without contribution from others I do not see that this will be solved in the next years. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found No bugs, seems to be function wise correct.
include/picongpu/particles/atomicPhysics/initElectrons/Inelastic2BodyCollisionFromCoMoving.hpp
Outdated
Show resolved
Hide resolved
include/picongpu/particles/atomicPhysics/kernel/DecelerateElectrons.kernel
Outdated
Show resolved
Hide resolved
include/picongpu/particles/atomicPhysics/rateCalculation/BoundFreeFieldTransitionRates.hpp
Outdated
Show resolved
Hide resolved
include/picongpu/particles/atomicPhysics/rateCalculation/BoundFreeFieldTransitionRates.hpp
Outdated
Show resolved
Hide resolved
include/picongpu/particles/atomicPhysics/ionizationPotentialDepression/StewartPyattIPD.hpp
Outdated
Show resolved
Hide resolved
share/picongpu/tests/CollisionsBeamRelaxation/include/picongpu/param/particle.param
Outdated
Show resolved
Hide resolved
share/picongpu/tests/CollisionsBeamRelaxation/include/picongpu/param/particle.param
Outdated
Show resolved
Hide resolved
share/picongpu/tests/CollisionsThermalisation/include/picongpu/param/particle.param
Outdated
Show resolved
Hide resolved
share/picongpu/tests/CollisionsThermalisation/include/picongpu/param/particle.param
Outdated
Show resolved
Hide resolved
share/picongpu/tests/compileAtomicPhysics/include/picongpu/param/ionizer.param
Outdated
Show resolved
Hide resolved
- add conversion au units -> si - add conversion au unis -> pic ci: picongpu
nvcc is not possible to pull static constexpr member into the device code, therefore acessing a function is required.
- add `automicUnit` - rename `ev` to `eV`
8637777
to
5c99c7c
Compare
constexpr float_X eV = static_cast<float_X>(sim.si.conv().joule2eV( | ||
picongpu::sim.unit.mass() * pmacc::math::cPow(picongpu::sim.unit.length(), 2u))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a bug, it should read
constexpr float_X eV = static_cast<float_X>(sim.si.conv().joule2eV(
picongpu::sim.unit.mass() * pmacc::math::cPow(picongpu::sim.unit.length(), 2u) / pmacc::math::cPow(picongpu::sim.unit.time(), 2u)));
or even shorter
constexpr float_X eV = static_cast<float_X>(sim.si.conv().joule2eV( | |
picongpu::sim.unit.mass() * pmacc::math::cPow(picongpu::sim.unit.length(), 2u))); | |
constexpr float_X eV = static_cast<float_X>(picongpu::sim.si.conv().joule2eV(picongpu::sim.unit.energy())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it maybe sim.pic.get_eV();
because I assume you would like to have a picongpu eV?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is even better!
include/picongpu/particles/atomicPhysics/kernel/DecelerateElectrons.kernel
Outdated
Show resolved
Hide resolved
include/picongpu/particles/atomicPhysics/rateCalculation/BoundBoundTransitionRates.hpp
Outdated
Show resolved
Hide resolved
include/picongpu/particles/atomicPhysics/rateCalculation/CollisionalRate.hpp
Outdated
Show resolved
Hide resolved
* @{ | ||
*/ | ||
template<typename T_Type = float_X> | ||
constexpr T_Type eV2Joule(T_Type eV = 1.0) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constexpr T_Type eV2Joule(T_Type eV = 1.0) const | |
constexpr T_Type eV2picEnergy(T_Type eV = 1.0) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but be careful when using automated search and replace since eV2Joule also exists in the SI namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also needs to be renamed in the other functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offline discussed. Other functions are named equally. I am open that someone refactor it in a sperate PR because this is out of the scope of this PR.
const float_64 minEnergy_keV = sim.pic.conv().eV2Joule(minEnergy_SI * 1.0e-3); | ||
const float_64 maxEnergy_keV = sim.pic.conv().eV2Joule(maxEnergy_SI * 1.0e-3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bug
const float_64 minEnergy_keV = sim.pic.conv().eV2Joule(minEnergy_SI * 1.0e-3); | |
const float_64 maxEnergy_keV = sim.pic.conv().eV2Joule(maxEnergy_SI * 1.0e-3); | |
const float_64 minEnergy_keV = 1.0e-3 * sim.pic.conv().joule2eV(minEnergy_SI); | |
const float_64 maxEnergy_keV = 1.0e-3 * sim.pic.conv().joule2eV(maxEnergy_SI); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it to sim.si.conv()
const float_64 minEnergy_SI = this->minEnergy * sim.si.conv().eV2Joule(1.0e3); | ||
const float_64 maxEnergy_SI = this->maxEnergy * sim.si.conv().eV2Joule(1.0e3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bug
const float_64 minEnergy_SI = this->minEnergy * sim.si.conv().eV2Joule(1.0e3); | |
const float_64 maxEnergy_SI = this->maxEnergy * sim.si.conv().eV2Joule(1.0e3); | |
const float_64 minEnergy_SI = this->minEnergy * sim.unit.energy(); | |
const float_64 maxEnergy_SI = this->maxEnergy * sim.unit.energy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it conversion to keV, I will add this to the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to
/* convert keV to joule */
const float_64 minEnergy_SI = sim.si.conv().eV2Joule(this->minEnergy * 1.0e3);
const float_64 maxEnergy_SI = sim.si.conv().eV2Joule(this->maxEnergy * 1.0e3);
/* convert into PIConGPU units */
this->minEnergy = minEnergy_SI / sim.unit.energy();
this->maxEnergy = maxEnergy_SI / sim.unit.energy();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the FLYonPIC rate calculation unit test fails.
For reference, check by doing the following
pic-create $PIC_EXAMPLES/../tests/compileAtomicPhysics ./testUnitSystem
git clone [email protected]:ComputationalRadiationPhysics/TestUnitSystemAtomicData.git
cd ./testUnitSystem
cp ../TestUnitSystemAtomicData/* ./
pic-build
./bin/picongpu -g 1 1 1 -d 1 1 1 -s 1 --periodic 1 1 1
In ComputationalRadiationPhysics#5131 we changed rydberg energy from eV to joule but missed to apply the conversion in the code.
fix is applied |
The PR ComputationalRadiationPhysics#5133 and ComputationalRadiationPhysics#5142 got merged together with ComputationalRadiationPhysics#4826. Removed files and renamings for the unit systems collide therefore.
The PR ComputationalRadiationPhysics#5133 and ComputationalRadiationPhysics#5142 got merged together with ComputationalRadiationPhysics#4826. Removed files and renamings for the unit systems collide therefore.
Please review very carefully!!!!!!
Review
Please check the first commit only. The second commit is changing the access
.conv.*
to.conv().*
. This is required because nvcc is not able to pull the constexpr members correctly into the device code.