Skip to content

Commit

Permalink
Merge pull request #1018 from ax3l/topic-newMultiIonManipulators
Browse files Browse the repository at this point in the history
Particle Manipulators: Init Multi Ion Species
  • Loading branch information
PrometheusPi committed Dec 9, 2015
2 parents 6e597b4 + 57cb32a commit 499fc51
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/picongpu/include/particles/manipulators/AssignImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct AssignImpl
typedef AssignImpl type;
};

HINLINE AssignImpl(uint32_t currentStep)
HINLINE AssignImpl(uint32_t)
{
}

Expand Down
5 changes: 2 additions & 3 deletions src/picongpu/include/particles/manipulators/DriftImpl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Axel Huebl, Rene Widera
* Copyright 2013-2015 Axel Huebl, Rene Widera
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -40,9 +40,8 @@ struct DriftImpl : private T_ValueFunctor

typedef T_ValueFunctor ValueFunctor;

HINLINE DriftImpl(uint32_t currentStep)
HINLINE DriftImpl(uint32_t)
{

}

template<typename T_Particle1, typename T_Particle2>
Expand Down
5 changes: 2 additions & 3 deletions src/picongpu/include/particles/manipulators/FreeImpl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2015 Rene Widera
* Copyright 2013-2015 Rene Widera, Axel Huebl
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -43,9 +43,8 @@ struct FreeImpl
typedef FreeImpl<T_Functor> type;
};

HINLINE FreeImpl(uint32_t currentStep)
HINLINE FreeImpl(uint32_t)
{

}

template<typename T_Particle1, typename T_Particle2>
Expand Down
2 changes: 1 addition & 1 deletion src/picongpu/include/particles/manipulators/NoneImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct NoneImpl
typedef NoneImpl type;
};

HINLINE NoneImpl(uint32_t currentStep)
HINLINE NoneImpl(uint32_t)
{
}

Expand Down
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
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 src/picongpu/include/particles/manipulators/RatioWeightingImpl.def
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 src/picongpu/include/particles/manipulators/RatioWeightingImpl.hpp
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015 Marco Garten
* Copyright 2015 Marco Garten, Axel Huebl
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -39,9 +39,8 @@ struct SetAttributeImpl : private T_ValueFunctor

typedef T_ValueFunctor ValueFunctor;

HINLINE SetAttributeImpl(uint32_t currentStep)
HINLINE SetAttributeImpl(uint32_t)
{

}

template<typename T_Particle1, typename T_Particle2>
Expand Down
4 changes: 3 additions & 1 deletion src/picongpu/include/particles/manipulators/manipulators.def
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2014 Rene Widera
* Copyright 2014-2015 Rene Widera, Axel Huebl
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -32,3 +32,5 @@
#include "particles/manipulators/FreeImpl.def"
#include "particles/manipulators/SetAttributeImpl.def"
#include "particles/manipulators/RandomPositionImpl.def"
#include "particles/manipulators/RatioWeightingImpl.def"
#include "particles/manipulators/ProtonTimesWeightingImpl.def"
4 changes: 3 additions & 1 deletion src/picongpu/include/particles/manipulators/manipulators.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2014 Rene Widera
* Copyright 2014-2015 Rene Widera, Axel Huebl
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -31,3 +31,5 @@
#include "particles/manipulators/FreeImpl.hpp"
#include "particles/manipulators/SetAttributeImpl.hpp"
#include "particles/manipulators/RandomPositionImpl.hpp"
#include "particles/manipulators/RatioWeightingImpl.hpp"
#include "particles/manipulators/ProtonTimesWeightingImpl.hpp"

0 comments on commit 499fc51

Please sign in to comment.