-
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
Remove attribute chargeState, add boundElectrons #706
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,7 @@ struct Unit<globalCellIdx<T_Type> > | |
}; | ||
|
||
template<> | ||
struct Unit<chargeState > | ||
struct Unit<boundElectrons> | ||
{ | ||
static std::vector<double> get() | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question as with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is defined here: @psychocoderHPC , your verdict? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please see this issue #707 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 thx! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @n01r please add a comment above the trait There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that should be done for all of them in one PR. That would be far more effective than doing each one separately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fine with me 👍 |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
#include "simulation_defines.hpp" | ||
#include "traits/frame/GetCharge.hpp" | ||
#include "traits/HasIdentifier.hpp" | ||
#include "particles/traits/GetAtomicNumbers.hpp" | ||
|
||
namespace picongpu | ||
{ | ||
|
@@ -35,49 +36,70 @@ namespace detail | |
|
||
/** Calculate the real charge of a particle | ||
* | ||
* use attribute `chargeState` to calculate the charge | ||
* use attribute `boundElectrons` and the proton number from | ||
* flag `atomicNumbers` to calculate the charge | ||
* | ||
* \tparam T_HasBoundElectrons boolean that describes if species allows multiple charge states | ||
* due to bound electrons | ||
*/ | ||
template<bool T_HasChargeState> | ||
struct LoadChargeState | ||
template<bool T_HasBoundElectrons> | ||
struct LoadBoundElectrons | ||
{ | ||
|
||
/** Functor implementation | ||
* | ||
* \tparam T_Particle particle type | ||
* \param singlyChargedResult charge resulting from multiplying a single | ||
* electron charge (positive OR negative) by the macro particle weighting | ||
* \param particle particle reference | ||
*/ | ||
template<typename T_Particle> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls add a doxygen string for the params here, I am already confused what "partialResult" means :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the right step then would be to also rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... and to document what it means in the Doxygen flag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's why I said: also |
||
HDINLINE float_X operator()(const float_X partialResult, const T_Particle& particle) | ||
HDINLINE float_X operator()(const float_X singlyChargedResult, const T_Particle& particle) | ||
{ | ||
return partialResult * particle[chargeState_]; | ||
const float_X protonNumber = GetAtomicNumbers<T_Particle>::type::numberOfProtons; | ||
|
||
return singlyChargedResult * (protonNumber - particle[boundElectrons_]); | ||
} | ||
}; | ||
|
||
/** Calculate the real charge of a particle | ||
* | ||
* This is the fallback implementation if no `chargeState` is available for a particle | ||
* This is the fallback implementation if no `boundElectrons` are available for a particle | ||
* | ||
* \tparam T_HasBoundElectrons boolean that describes if species allows multiple charge states | ||
* due to bound electrons | ||
*/ | ||
template<> | ||
struct LoadChargeState<false> | ||
struct LoadBoundElectrons<false> | ||
{ | ||
|
||
/** Functor implementation | ||
* | ||
* \tparam T_Particle particle type | ||
* \param singlyChargedResult charge resulting from multiplying a single | ||
* electron charge (positive OR negative) by the macro particle weighting | ||
* \param particle particle reference | ||
*/ | ||
template<typename T_Particle> | ||
HDINLINE float_X operator()(const float_X partialResult, const T_Particle& particle) | ||
HDINLINE float_X operator()(const float_X singlyChargedResult, const T_Particle& particle) | ||
{ | ||
return partialResult; | ||
return singlyChargedResult; | ||
} | ||
}; | ||
} // namespace detail | ||
|
||
/** get the charge of a makro particle | ||
/** get the charge of a macro particle | ||
* | ||
* This function trait take care to the `chargeState` attribute if it is set | ||
* This function trait considers the `boundElectrons` attribute if it is set | ||
* | ||
* @param weighting weighting of the particle | ||
* @param particle a reference to a particle | ||
* @return charge of the makro particle | ||
* @return charge of the macro particle | ||
*/ | ||
template<typename T_Particle> | ||
HDINLINE float_X getCharge(const float_X weighting, const T_Particle& particle) | ||
{ | ||
typedef T_Particle ParticleType; | ||
typedef typename PMacc::traits::HasIdentifier<ParticleType, chargeState>::type hasChargeState; | ||
return detail::LoadChargeState<hasChargeState::value >()( | ||
typedef typename PMacc::traits::HasIdentifier<ParticleType, boundElectrons>::type hasBoundElectrons; | ||
return detail::LoadBoundElectrons<hasBoundElectrons::value >()( | ||
frame::getCharge<typename ParticleType::FrameType > () * weighting, | ||
particle); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* Copyright 2014-2015 Marco Garten, Rene Widera | ||
* | ||
* This file is part of PIConGPU. | ||
* | ||
* PIConGPU is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* PIConGPU is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with PIConGPU. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "simulation_defines.hpp" | ||
#include "traits/HasIdentifier.hpp" | ||
#include "algorithms/TypeCast.hpp" | ||
#include "particles/traits/GetAtomicNumbers.hpp" | ||
|
||
namespace picongpu | ||
{ | ||
namespace traits | ||
{ | ||
namespace attribute | ||
{ | ||
namespace detail | ||
{ | ||
|
||
/** Calculate the charge state of an atom / ion | ||
* | ||
* use attribute `boundElectrons` to calculate the charge state | ||
*/ | ||
template<bool T_HasBoundElectrons> | ||
struct LoadChargeState | ||
{ | ||
/** Functor implementation | ||
* | ||
* \return chargeState = number of electrons in neutral atom - number of currently bound electrons | ||
*/ | ||
template<typename T_Particle> | ||
HDINLINE float_X operator()(const T_Particle& particle) | ||
{ | ||
const float_X protonNumber = GetAtomicNumbers<T_Particle>::type::numberOfProtons; | ||
return protonNumber - particle[boundElectrons_]; | ||
} | ||
}; | ||
|
||
/** Calculate charge state of an atom / ion | ||
* | ||
* This is the fallback implementation to throw an error if no `boundElectrons` | ||
* are available for a species. | ||
*/ | ||
template<> | ||
struct LoadChargeState<false> | ||
{ | ||
|
||
template<typename T_Particle> | ||
HDINLINE void operator()(const T_Particle& particle) | ||
{ | ||
PMACC_CASSERT_MSG(This_species_has_only_one_charge_state,1==2); | ||
} | ||
}; | ||
} // namespace detail | ||
|
||
/** get the charge state of a macro particle | ||
* | ||
* This function trait considers the `boundElectrons` attribute if it is set. | ||
* Charge states do not add up and also the various particles in a macro particle | ||
* do NOT have different charge states where one would average over them. | ||
* | ||
* @param particle a reference to a particle | ||
* @return charge of the macro particle | ||
*/ | ||
template<typename T_Particle> | ||
HDINLINE float_X getChargeState(const T_Particle& particle) | ||
{ | ||
typedef T_Particle ParticleType; | ||
typedef typename PMacc::traits::HasIdentifier<ParticleType, boundElectrons>::type hasBoundElectrons; | ||
return detail::LoadChargeState<hasBoundElectrons::value >()(particle); | ||
} | ||
|
||
}// namespace attribute | ||
}// namespace traits | ||
}// namespace picongpu |
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, pls :)
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.
waiting for @psychocoderHPC 's #640