-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1018 from ax3l/topic-newMultiIonManipulators
Particle Manipulators: Init Multi Ion Species
- Loading branch information
Showing
11 changed files
with
278 additions
and
13 deletions.
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