-
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
instant field ionization transitions #5218
Merged
psychocoderHPC
merged 4 commits into
ComputationalRadiationPhysics:dev
from
BrianMarre:topic-instantFieldIonization
Dec 9, 2024
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
45 changes: 45 additions & 0 deletions
45
include/picongpu/particles/atomicPhysics/InstantTransitionRateLimit.hpp
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Copyright 2024 Brian Marre | ||
* | ||
* 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 | ||
|
||
// need unit system and normalization | ||
#include "picongpu/defines.hpp" | ||
#include "picongpu/particles/atomicPhysics/param.hpp" | ||
|
||
namespace picongpu::particles::atomicPhysics | ||
{ | ||
struct InstantTransitionRateLimit | ||
{ | ||
/** get maximum of total state loss rate for inclusion in the time dependent rate equation solver | ||
* | ||
* @tparam T_ReturnType type and precision to use in the result | ||
*/ | ||
template<typename T_ReturnType> | ||
static constexpr T_ReturnType get() | ||
{ | ||
using picongpu::atomicPhysics::RateSolverParam; | ||
|
||
// unit: unitless * unitless / unit_time = 1/unit_time | ||
return static_cast<T_ReturnType>( | ||
RateSolverParam::timeStepAlpha * float_X(RateSolverParam::maximumNumberSubStepsPerPICTimeStep)) | ||
/ picongpu::sim.pic.getDt<T_ReturnType>(); | ||
} | ||
}; | ||
} // namespace picongpu::particles::atomicPhysics |
This file contains 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
122 changes: 122 additions & 0 deletions
122
include/picongpu/particles/atomicPhysics/kernel/CheckForFieldEnergyOverSubscription.kernel
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* Copyright 2024 Brian Marre | ||
* | ||
* 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 "picongpu/defines.hpp" | ||
#include "picongpu/particles/atomicPhysics/ConvertEnum.hpp" | ||
#include "picongpu/particles/atomicPhysics/KernelIndexation.hpp" | ||
#include "picongpu/particles/atomicPhysics/kernel/CalculateRejectionProbability.hpp" | ||
#include "picongpu/particles/atomicPhysics/localHelperFields/RejectionProbabilityCache_Cell.hpp" | ||
|
||
#include <pmacc/lockstep/ForEach.hpp> | ||
|
||
#include <cstdint> | ||
|
||
namespace picongpu::particles::atomicPhysics::kernel | ||
{ | ||
/** check all cells for overSubscription | ||
* | ||
* checks each superCell cell for fieldEnergyUse > fieldEnergy, | ||
* if yes mark cell as oversubscribed and stores rejection probability in rejection probability cache | ||
* | ||
* @tparam T_numberAtomicPhysicsIonSpecies specialization template parameter used to prevent compilation of all | ||
* atomicPhysics kernels if no atomic physics species is present. | ||
*/ | ||
template<uint32_t T_numberAtomicPhysicsIonSpecies> | ||
struct CheckForFieldEnergyOverSubscriptionKernel | ||
{ | ||
using VectorIdx = DataSpace<picongpu::simDim>; | ||
/** call operator | ||
* | ||
* called by CheckForOverSubscription atomic physics sub-stage | ||
* | ||
* @param worker object containing the device and block information, passed by PMACC_KERNEL call | ||
* @param areMapping mapping of blockIndex to block superCell index | ||
* @param rngFactory factory for uniformly distributed random number generator | ||
* @param eFieldBox deviceDataBox giving access to eField values for all local superCells | ||
* @param fieldEnergyUseCacheBox deviceDataBox giving access to the field energy use cache for each local | ||
* superCell | ||
* @param sharedResourcesOverSubscribedBox deviceDataBox giving access to the local shared resources over | ||
* subscription switch for each local superCell | ||
* @param rejectionProbabilityCacheCellBox deviceDataBox giving access to localRejectionProbabilityCache for | ||
* all cells of all local superCells | ||
*/ | ||
template< | ||
typename T_Worker, | ||
typename T_AreaMapping, | ||
typename T_TimeRemainingBox, | ||
typename T_EFieldBox, | ||
typename T_FieldEnergyUseCacheBox, | ||
typename T_SharedRessourcesOverSubscribedBox, | ||
typename T_RejectionProbabilityCacheCellDataBox> | ||
HDINLINE void operator()( | ||
T_Worker const& worker, | ||
T_AreaMapping const areaMapping, | ||
T_TimeRemainingBox const timeRemainingBox, | ||
T_EFieldBox const eFieldBox, | ||
T_FieldEnergyUseCacheBox const fieldEnergyUseCacheBox, | ||
T_SharedRessourcesOverSubscribedBox sharedResourcesOverSubscribedBox, | ||
T_RejectionProbabilityCacheCellDataBox rejectionProbabilityCacheCellBox) const | ||
{ | ||
auto const superCellIdx = KernelIndexation::getSuperCellIndex(worker, areaMapping); | ||
auto const superCellFieldIdx | ||
= KernelIndexation::getSuperCellFieldIndexFromSuperCellIndex(areaMapping, superCellIdx); | ||
|
||
auto const timeRemaining = timeRemainingBox(superCellFieldIdx); | ||
if(timeRemaining <= 0._X) | ||
return; | ||
|
||
using FieldEnergyCache = typename T_FieldEnergyUseCacheBox::ValueType; | ||
particles::atomicPhysics::localHelperFields::RejectionProbabilityCache_Cell<FieldEnergyCache::numberCells>& | ||
rejectionProbabilityCacheCell | ||
= rejectionProbabilityCacheCellBox(superCellFieldIdx); | ||
|
||
FieldEnergyCache const& eFieldEnergyUseCache = fieldEnergyUseCacheBox(superCellFieldIdx); | ||
VectorIdx const superCellCellOffset = superCellIdx * picongpu::SuperCellSize::toRT(); | ||
bool sharedResourcesOverSubscribed = false; | ||
|
||
auto forEachCell = pmacc::lockstep::makeForEach<FieldEnergyCache::numberCells, T_Worker>(worker); | ||
forEachCell( | ||
[&worker, | ||
&superCellCellOffset, | ||
&eFieldBox, | ||
&eFieldEnergyUseCache, | ||
&rejectionProbabilityCacheCell, | ||
&sharedResourcesOverSubscribed](uint32_t const linearCellIndex) | ||
{ | ||
if(CalculateRejectionProbability::ofCell( | ||
linearCellIndex, | ||
superCellCellOffset, | ||
eFieldBox, | ||
eFieldEnergyUseCache, | ||
rejectionProbabilityCacheCell)) | ||
sharedResourcesOverSubscribed = true; | ||
}); | ||
|
||
uint32_t& flagField = sharedResourcesOverSubscribedBox(superCellFieldIdx); | ||
// write out flag setting to device memory | ||
alpaka::atomicOr( | ||
worker.getAcc(), | ||
&flagField, | ||
u32(sharedResourcesOverSubscribed), | ||
::alpaka::hierarchy::Threads{}); | ||
} | ||
}; | ||
} // namespace picongpu::particles::atomicPhysics::kernel |
Oops, something went wrong.
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.
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.
I wrote it already in an other PR. It looks very dangerous to use a reference here.
If it is a pmacc box please take the return value always by copy. There is only one case where a reference is ok and this is if you use native alpaka to get shared memory.
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.
Could be that this should be change in other code parts too.
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.
The use of a reference is correct and necessary here, since the dataBox will return a reference to global device memory and we don't want to store a copy of the superCell's rejection probability cache for every worker due to its significant size, ~ 512 * 32-bit.