Skip to content

Commit

Permalink
Particle Manipulators: Init Multi-Ion Species
Browse files Browse the repository at this point in the history
This commit adds new manipulators that can be used during the
species init-pipeline.

- `RatioWeightingImpl`: Useful to clone one ion species from an other
                        ion species by still satisfying the densityRatio
                        of the new created species.

- `ProtonTimesWeightingImpl`: Useful to clone electron species from
                              an ion species for pre-ionized plasmas.
                              The weighting of the electrons is simply
                              multiplied by the proton number of the
                              initial ion species.
  • Loading branch information
ax3l committed Aug 6, 2015
1 parent df8e8de commit 2db958b
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 2 deletions.
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 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.
*
* 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,65 @@
/**
* 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 currentStep)
{

}

template<typename T_Particle1, typename T_Particle2>
DINLINE void operator()(const DataSpace<simDim>&,
T_Particle1& particleSpecies1, T_Particle2&,
const bool isParticle1, const bool isParticle2)
{
if (isParticle1 && isParticle2)
{
const float_X protonNumber = traits::GetAtomicNumbers<T_Particle2>::type::numberOfProtons;
particleSpecies1[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
69 changes: 69 additions & 0 deletions src/picongpu/include/particles/manipulators/RatioWeightingImpl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* 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 currentStep)
{

}

template<typename T_Particle1, typename T_Particle2>
DINLINE void operator()(const DataSpace<simDim>&,
T_Particle1& particleSpecies1, T_Particle2&,
const bool isParticle1, const bool isParticle2)
{
if (isParticle1 && isParticle2)
{
const float_X densityRatioDes =
traits::GetDensityRatio<T_Particle1>::type::getDefaultValue();
const float_X densityRatioSrc =
traits::GetDensityRatio<T_Particle2>::type::getDefaultValue();

particleSpecies1[weighting_] *= densityRatioDes / densityRatioSrc;
}
}
};

} //namespace manipulators
} //namespace particles
} //namespace picongpu
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 2db958b

Please sign in to comment.