-
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
Particle Manipulators: Init Multi Ion Species #1018
Merged
PrometheusPi
merged 2 commits into
ComputationalRadiationPhysics:dev
from
ax3l:topic-newMultiIonManipulators
Dec 9, 2015
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
52 changes: 52 additions & 0 deletions
52
src/picongpu/include/particles/manipulators/ProtonTimesWeightingImpl.def
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,52 @@ | ||
/** | ||
* Copyright 2015 Axel Huebl | ||
* | ||
* 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 | ||
|
||
namespace picongpu | ||
{ | ||
namespace particles | ||
{ | ||
namespace manipulators | ||
{ | ||
|
||
/* Re-scale the weighting of a cloned species by numberOfProtons | ||
* | ||
* When cloning species from each other, the new | ||
* species "inherits" the macro-particle weighting | ||
* of the first one. | ||
* This functor can be used to manipulate the weighting | ||
* of the new species' macro particles to be a multiplied by | ||
* the number of protons on the initial species. | ||
* | ||
* As an example, this comes useful when initializing a quasi-neutral, | ||
* pre-ionized plasma of ions and electrons. Electrons can be created | ||
* from ions via cloning and increasing their weight to avoid simulating | ||
* multiple macro electrons per macro ion (with Z>1). | ||
* | ||
* note: needs the atomicNumbers flag on the initial species, | ||
* used by the GetAtomicNumbers trait. | ||
*/ | ||
struct ProtonTimesWeightingImpl; | ||
|
||
} //namespace manipulators | ||
} //namespace particles | ||
} //namespace picongpu |
78 changes: 78 additions & 0 deletions
78
src/picongpu/include/particles/manipulators/ProtonTimesWeightingImpl.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,78 @@ | ||
/** | ||
* Copyright 2015 Axel Huebl | ||
* | ||
* 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 "particles/manipulators/ProtonTimesWeightingImpl.def" | ||
#include "particles/traits/GetAtomicNumbers.hpp" | ||
|
||
#include "simulation_defines.hpp" | ||
|
||
namespace picongpu | ||
{ | ||
namespace particles | ||
{ | ||
namespace manipulators | ||
{ | ||
|
||
struct ProtonTimesWeightingImpl | ||
{ | ||
|
||
template<typename T_SpeciesType> | ||
struct apply | ||
{ | ||
typedef ProtonTimesWeightingImpl type; | ||
}; | ||
|
||
HINLINE ProtonTimesWeightingImpl(uint32_t) | ||
{ | ||
} | ||
|
||
/* Increase weighting of particleDest by proton number of SrcParticle | ||
* | ||
* The frame's `atomicNumber` `numberOfProtons`of `T_SrcParticle` | ||
* is used to increase the weighting of particleDest. | ||
* Useful to increase the weighting of macro electrons when cloned from an | ||
* ion with Z>1. Otherwise one would need Z macro electrons (each with the | ||
* same weighting as the initial ion) to keep the charge of a pre-ionized | ||
* atom neutral. | ||
* | ||
* \tparam T_DestParticle type of the particle species with weighting to manipulate | ||
* \tparam T_SrcParticle type of the particle species with proton number Z | ||
* | ||
* \see picongpu::particles::ManipulateCloneSpecies , picongpu::kernelCloneParticles | ||
*/ | ||
template<typename T_DestParticle, typename T_SrcParticle> | ||
DINLINE void operator()(const DataSpace<simDim>&, | ||
T_DestParticle& particleDest, T_SrcParticle&, | ||
const bool isDestParticle, const bool isSrcParticle) | ||
{ | ||
if (isDestParticle && isSrcParticle) | ||
{ | ||
const float_X protonNumber = traits::GetAtomicNumbers<T_SrcParticle>::type::numberOfProtons; | ||
particleDest[weighting_] *= protonNumber; | ||
} | ||
} | ||
}; | ||
|
||
} //namespace manipulators | ||
} //namespace particles | ||
} //namespace picongpu |
47 changes: 47 additions & 0 deletions
47
src/picongpu/include/particles/manipulators/RatioWeightingImpl.def
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,47 @@ | ||
/** | ||
* Copyright 2015 Axel Huebl | ||
* | ||
* 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 | ||
|
||
namespace picongpu | ||
{ | ||
namespace particles | ||
{ | ||
namespace manipulators | ||
{ | ||
|
||
/* Re-scale the weighting of a cloned species by densityRatio | ||
* | ||
* When cloning species from each other, the new | ||
* species "inherits" the macro-particle weighting | ||
* of the first one. | ||
* This functor can be used to manipulate the weighting | ||
* of the new species' macro particles to satisfy the | ||
* input densityRatio of it. | ||
* | ||
* note: needs the densityRatio flag on both species, | ||
* used by the GetDensityRatio trait. | ||
*/ | ||
struct RatioWeighting; | ||
|
||
} //namespace manipulators | ||
} //namespace particles | ||
} //namespace picongpu |
87 changes: 87 additions & 0 deletions
87
src/picongpu/include/particles/manipulators/RatioWeightingImpl.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,87 @@ | ||
/** | ||
* Copyright 2015 Axel Huebl | ||
* | ||
* 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 "particles/manipulators/RatioWeightingImpl.def" | ||
#include "particles/traits/GetDensityRatio.hpp" | ||
|
||
#include "simulation_defines.hpp" | ||
|
||
namespace picongpu | ||
{ | ||
namespace particles | ||
{ | ||
namespace manipulators | ||
{ | ||
|
||
struct RatioWeightingImpl | ||
{ | ||
|
||
template<typename T_SpeciesType> | ||
struct apply | ||
{ | ||
typedef RatioWeightingImpl type; | ||
}; | ||
|
||
HINLINE RatioWeightingImpl(uint32_t) | ||
{ | ||
} | ||
|
||
/* Adjust the weighting of particleDes by densityRatio of own & Src particle | ||
* | ||
* While cloning a particle (particleDes) from another (T_SrcParticle), one | ||
* can afterward directly normalize the weighting back to the intended density: | ||
* - divide weighting with the `T_SrcParticle`'s densityRatio | ||
* (to get macro particle weighting according to reference GAS_DENSITY * profile | ||
* at this specific point in space & time) | ||
* - multiply weighting with own densityRatio (to get this species' | ||
* densityRatio * GAS_DENSITY * profile) | ||
* | ||
* This is useful when the profile and number of macro particles for both species | ||
* shall be the same and the initialization of another profile via `CreateGas` | ||
* would be expensive (or one wants to keep the exact same position while cloning). | ||
* | ||
* \tparam T_DesParticle type of the particle species with weighting to manipulate | ||
* \tparam T_SrcParticle type of the particle species one cloned from | ||
* | ||
* \see picongpu::particles::ManipulateCloneSpecies , picongpu::kernelCloneParticles | ||
*/ | ||
template<typename T_DesParticle, typename T_SrcParticle> | ||
DINLINE void operator()(const DataSpace<simDim>&, | ||
T_DesParticle& particleDes, T_SrcParticle&, | ||
const bool isDesParticle, const bool isSrcParticle) | ||
{ | ||
if (isDesParticle && isSrcParticle) | ||
{ | ||
const float_X densityRatioDes = | ||
traits::GetDensityRatio<T_DesParticle>::type::getDefaultValue(); | ||
const float_X densityRatioSrc = | ||
traits::GetDensityRatio<T_SrcParticle>::type::getDefaultValue(); | ||
|
||
particleDes[weighting_] *= densityRatioDes / densityRatioSrc; | ||
} | ||
} | ||
}; | ||
|
||
} //namespace manipulators | ||
} //namespace particles | ||
} //namespace picongpu |
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
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
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.
Here, you are speaking about a general
species
but this manipulator is only useful for electrons. Could you specifyspecies
by sayingelectron species
here (as in the description of the pull request) in order to clarify 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.
Yes, I will describe it as an example use case that this is useful for electrons.