From 6b416e9f0f0ee290841c1774fd13ef1e6e6fca3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Thu, 4 Jun 2015 14:46:20 +0200 Subject: [PATCH] two ions and electron species preview example --- examples/LaserWakefield/cmakeFlags | 11 +- .../simulation_defines/param/gasConfig.param | 45 ++++---- .../param/particleConfig.param | 32 +++--- .../param/physicalConstants.param | 85 ++++++++++++++ .../simulation_defines/param/species.param | 14 +-- .../param/speciesDefinition.param | 62 +++++++---- .../param/speciesInitialization.param | 21 ++-- .../unitless/physicalConstants.unitless | 104 ++++++++++++++++++ .../unitless/speciesDefinition.unitless | 91 +++++++++++++++ examples/LaserWakefield/submit/0016gpus.cfg | 8 +- .../particles/manipulators/RandomPosImpl.def | 36 ++++++ .../particles/manipulators/RandomPosImpl.hpp | 94 ++++++++++++++++ .../particles/manipulators/manipulators.def | 1 + .../particles/manipulators/manipulators.hpp | 1 + 14 files changed, 513 insertions(+), 92 deletions(-) create mode 100644 examples/LaserWakefield/include/simulation_defines/param/physicalConstants.param create mode 100644 examples/LaserWakefield/include/simulation_defines/unitless/physicalConstants.unitless create mode 100644 examples/LaserWakefield/include/simulation_defines/unitless/speciesDefinition.unitless create mode 100644 src/picongpu/include/particles/manipulators/RandomPosImpl.def create mode 100644 src/picongpu/include/particles/manipulators/RandomPosImpl.hpp diff --git a/examples/LaserWakefield/cmakeFlags b/examples/LaserWakefield/cmakeFlags index c2432855ec..06cbd73094 100755 --- a/examples/LaserWakefield/cmakeFlags +++ b/examples/LaserWakefield/cmakeFlags @@ -30,16 +30,7 @@ # - increase by 1, no gaps flags[0]="-DCUDA_ARCH=sm_20" -flags[1]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_FIELDSOLVER=fieldSolverLehe;-DPARAM_PARTICLEPUSHER=Vay" -flags[2]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC" -flags[3]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=VillaBune;-DPARAM_PARTICLESHAPE=CIC" -flags[4]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit" -flags[5]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0" -flags[6]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_DIMENSION=DIM2" -flags[7]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_CURRENTSOLVER=Esirkepov;-DPARAM_PARTICLESHAPE=CIC;-DPARAM_DIMENSION=DIM2" -flags[8]="-DCUDA_ARCH=sm_20 -DPARAM_OVERWRITES:LIST=-DPARAM_PRECISION=precision64Bit;-DPARAM_DIMENSION=DIM2" -flags[9]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DENABLE_CURRENT=0;-DPARAM_DIMENSION=DIM2" -flags[10]="-DCUDA_ARCH=sm_35 -DPARAM_OVERWRITES:LIST=-DPARAM_IONS=1;-DPARAM_IONIZATION=1" + ################################################################################ # execution diff --git a/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param b/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param index 1c0fa7bb2c..c18dac60b5 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param +++ b/examples/LaserWakefield/include/simulation_defines/param/gasConfig.param @@ -43,39 +43,46 @@ const double GAS_DENSITY_SI = 1.e25; //########################################################################## namespace gasProfiles { -struct GaussianParameter -{ - /** Gas Formular: - const float_X exponent = fabs((y - GAS_CENTER) / GAS_SIGMA); - const float_X density = __expf(GAS_FACTOR*__powf(exponent, GAS_POWER)); - takes GAS_CENTER_LEFT for y < GAS_CENTER_LEFT, - GAS_CENTER_RIGHT for y > GAS_CENTER_RIGHT, - and exponent = float_X(0.0) for GAS_CENTER_LEFT < y < GAS_CENTER_RIGHT */ - static const float_X GAS_FACTOR = -1.0; - static const float_X GAS_POWER = 4.0; +/** Middle of the constant sphere + * unit: meter */ +CONST_VECTOR(float_64, simDim, SphereFlanksParam_center, 8.0e3, 8.0e3, 8.0e3); +struct SphereFlanksParam +{ /** height of vacuum area on top border * this vacuum is really important because of the laser initialization, * which is done in the first cell of the simulation * unit: cells */ - static const uint32_t VACUUM_CELLS_Y = 50; + static const uint32_t vacuum_y_cells = 50; struct SI { - /** The central position of the gas distribution + /** Radius of the constant sphere * unit: meter */ - static const float_64 GAS_CENTER_LEFT = 8.0e-5; - static const float_64 GAS_CENTER_RIGHT = 10.0e-5; - /** the distance from GAS_CENTER until the gas density decreases to its 1/e-th part + static const float_64 r = 1.0e3; + + /** Inner radius if you want to build a shell/ring * unit: meter */ - static const float_64 GAS_SIGMA_LEFT = 8.0e-5; - static const float_64 GAS_SIGMA_RIGHT = 8.0e-5; + static const float_64 ri = 0.0; + + /** Middle of the constant sphere + * unit: meter */ + const SphereFlanksParam_center_t center; + + /** Parameters for the exponential slope + * For radius > GAS_R_SI: + * let radius' = radius - r + * \rho = exp[ - radius' * exponent ] + * unit: 1/m + */ + static const float_64 exponent = 1.0e-3; + }; }; -/* definition of GasGaussian*/ -typedef GaussianImpl Gaussian; +/* definition of gas sphere with flanks*/ +typedef SphereFlanksImpl SphereFlanks; }//namespace gasProfiles diff --git a/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param b/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param index 64d5338cac..4d529c7043 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param +++ b/examples/LaserWakefield/include/simulation_defines/param/particleConfig.param @@ -41,7 +41,24 @@ namespace particles * unit: none */ const float_X MIN_WEIGHTING = 10.0; -const uint32_t TYPICAL_PARTICLES_PER_CELL = 2; +const uint32_t TYPICAL_PARTICLES_PER_CELL = 10; + +namespace manipulators +{ + struct SixTimesWeightingFunctor + { + template + DINLINE void operator()(T_Particle& particle) + { + particle[weighting_]*=float_X(6.0); + } + }; + + /* definition of SetDrift start*/ + typedef FreeImpl SixTimesWeighting; + + +} //namespace manipulators namespace startPosition { @@ -55,22 +72,11 @@ struct RandomParameter /* definition of random particle start*/ typedef RandomImpl Random; -struct QuietParameter -{ - /** Count of particles per cell per direction at initial state - * unit: none */ - typedef typename mCT::shrinkTo, simDim>::type numParticlesPerDimension; -}; - -/* definition of random particle start*/ -typedef QuietImpl Quiet; - - } //namespace startPosition namespace manipulators { - + struct BoundElectronsWhenNeutral { /* space for attribute initial parameters */ diff --git a/examples/LaserWakefield/include/simulation_defines/param/physicalConstants.param b/examples/LaserWakefield/include/simulation_defines/param/physicalConstants.param new file mode 100644 index 0000000000..e92f6b3862 --- /dev/null +++ b/examples/LaserWakefield/include/simulation_defines/param/physicalConstants.param @@ -0,0 +1,85 @@ +/** + * Copyright 2013 Axel Huebl, Heiko Burau, Rene Widera + * + * 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 . + */ + + + +#pragma once + +namespace picongpu +{ + const float_64 PI = 3.141592653589793238462643383279502884197169399; + + /** Threshold used for calculations that want to separate between + * high-precision formulas for relativistic and non-relativistic + * use-cases, e.g. energy-binning algorithms. */ + const float_X GAMMA_THRESH = float_X(1.005); + + namespace SI + { + /** unit: m / s */ + const float_64 SPEED_OF_LIGHT_SI = 2.99792458e8; + + /** unit: N / A^2 */ + const float_64 MUE0_SI = PI * 4.e-7; + /** unit: C / (V m) */ + const float_64 EPS0_SI = 1.0 / MUE0_SI / SPEED_OF_LIGHT_SI + / SPEED_OF_LIGHT_SI; + + // Electron properties + /** unit: kg */ + const float_64 ELECTRON_MASS_SI = 9.109382e-31; + /** unit: C */ + const float_64 ELECTRON_CHARGE_SI = -1.602176e-19; + + // Ion / Proton / Positron properties + /** unit: kg */ + const float_64 ION_MASS_SI = 1.6726217e-27; + + const float_64 ION_MASS_C_SI = 1.660538921-27; + } + + // converts + // + // UNIT_A to UNIT_B + // + // CONVENTION: WE DO NOT CONVERT FROM ANY STRANGE UNIT TO UNITLESS UNITS DIRECTLY! + // convert steps: INPUT -> float_64_convert to SI -> float_64_convert to unitless + // -> cast to float + // WE DO NOT define "UNIT_ENERGY_keV" or something similar! Never! + // Stay SI, stay free ;-) + // + // example: + // // some particle physicist beloved input: + // const float_64 An_Arbitrary_Energy_Input_keV = 30.0; // unit: keV + // + // // first convert to SI (because SI stays our standard Unit System!) + // const float_64 An_Arbitrary_Energy_Input_SI = An_Arbitrary_Energy_Input_keV * UNITCONV_keV_to_Joule // unit: Joule + // + // // now the "real" convert to our internal unitless system + // const float_X An_Arbitrary_Energy_Input = float_X(An_Arbitrary_Energy_Input_SI / UNIT_ENERGY) // unit: none + // + // As a convention, we DO NOT use the short track: + // const float_64 An_Arbitrary_Energy_Input_keV = 30.0; // unit: keV + // const float_X An_Arbitrary_Energy_Input = float_X(An_Arbitrary_Energy_Input_SI * UNITCONV_keV_to_Joule / UNIT_ENERGY) // unit: none + // + const float_64 UNITCONV_keV_to_Joule = 1.60217646e-16; + const float_64 UNITCONV_Joule_to_keV = (1.0 / UNITCONV_keV_to_Joule); + +} diff --git a/examples/LaserWakefield/include/simulation_defines/param/species.param b/examples/LaserWakefield/include/simulation_defines/param/species.param index ac21cd45aa..425f332a1b 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/species.param +++ b/examples/LaserWakefield/include/simulation_defines/param/species.param @@ -34,17 +34,7 @@ /*enable (1) or disable (0) electrons*/ #define ENABLE_ELECTRONS 1 /*enable (1) or disable (0) ions*/ -#ifndef PARAM_IONS -#define PARAM_IONS 0 -#endif - -#define ENABLE_IONS PARAM_IONS - -/*enable (1) or disable (0) ionization*/ -#ifndef PARAM_IONIZATION -#define PARAM_IONIZATION 0 -#endif - +#define ENABLE_IONS 1 namespace picongpu { @@ -76,7 +66,7 @@ typedef FieldToParticleInterpolation UsedParticleCurrentSolver; diff --git a/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param b/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param index cc1f121284..f570976982 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param +++ b/examples/LaserWakefield/include/simulation_defines/param/speciesDefinition.param @@ -75,8 +75,7 @@ typedef typename MakeSeq< DefaultParticleAttributes, AttributMomentum_mt1, -AttributRadiationFlag, -boundElectrons +AttributRadiationFlag >::type AttributeSeqIons; /*########################### end particle attributes ########################*/ @@ -95,13 +94,22 @@ typedef bmpl::vector< /* define species: electrons */ typedef Particles, + bmpl::string<'e','H'>, SuperCellSize, AttributeSeqElectrons, ParticleFlagsElectrons, typename MakeSeq >::type > > PIC_Electrons; +/* define species: electrons */ +typedef Particles, + SuperCellSize, + AttributeSeqElectrons, + ParticleFlagsElectrons, + typename MakeSeq >::type > +> PIC_ElectronsC; + /*--------------------------- ions -------------------------------------------*/ /*! Specify (chemical) element @@ -120,41 +128,51 @@ typedef Particles > - */ - -typedef particles::shapes::CIC IonShape; typedef bmpl::vector< particlePusher, shape, interpolation, current, - #if(PARAM_IONIZATION == 1) - ionizer >, - #endif atomicNumbers > ParticleFlagsIons; /* define species: ions */ typedef Particles, + bmpl::string<'i','H'>, SuperCellSize, AttributeSeqIons, ParticleFlagsIons, typename MakeSeq >::type > > PIC_Ions; +//##### carbon + +struct Carbon +{ + static const float_X numberOfProtons = 6.0; + static const float_X numberOfNeutrons = 6.0; +}; +typedef bmpl::vector< + particlePusher, + shape, + interpolation, + current, + atomicNumbers +> ParticleFlagsIonsC; + +/* define species: ions */ +typedef Particles, + SuperCellSize, + AttributeSeqIons, + ParticleFlagsIonsC, + typename MakeSeq >::type > +> PIC_IonsC; + + /*########################### end species ####################################*/ @@ -175,7 +193,9 @@ PIC_Ions typedef typename MakeSeq< Species1, -Species2 +Species2, +PIC_IonsC, +PIC_ElectronsC >::type VectorAllSpecies; diff --git a/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param b/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param index 4721e858e7..ff977e4c19 100644 --- a/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param +++ b/examples/LaserWakefield/include/simulation_defines/param/speciesInitialization.param @@ -32,19 +32,14 @@ namespace picongpu * the functors are called in order (from first to last functor) */ typedef mpl::vector< -#if (PARAM_IONIZATION == 0) - - particles::CreateGas - #if (ENABLE_IONS == 1) - ,particles::CloneSpecies - #endif - -#else - - particles::CreateGas, - particles::Manipulate - -#endif + particles::CreateGas, + particles::CloneSpecies, + particles::CloneSpecies, + particles::CloneSpecies, + particles::Manipulate,PIC_Ions>, + particles::CloneSpecies, + particles::CloneSpecies, + particles::Manipulate > InitPipeline; } //namespace picongpu diff --git a/examples/LaserWakefield/include/simulation_defines/unitless/physicalConstants.unitless b/examples/LaserWakefield/include/simulation_defines/unitless/physicalConstants.unitless new file mode 100644 index 0000000000..c4aa464acc --- /dev/null +++ b/examples/LaserWakefield/include/simulation_defines/unitless/physicalConstants.unitless @@ -0,0 +1,104 @@ +/** + * Copyright 2013-2014 Axel Huebl, Rene Widera + * + * 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 . + */ + + +#pragma once + +namespace picongpu +{ + /** Unit of Speed */ + const float_64 UNIT_SPEED = SI::SPEED_OF_LIGHT_SI; + /** Unit of time */ + const float_64 UNIT_TIME = SI::DELTA_T_SI; + /** Unit of length */ + const float_64 UNIT_LENGTH = UNIT_TIME*UNIT_SPEED; + +#if(SIMDIM==DIM3) + namespace SI + { + /** density normed to dimension of the simulation*/ + const float_64 GAS_DENSITY_NORMED= SI::GAS_DENSITY_SI; + } //namespace SI + + namespace particles + { + /** Number of particles per makro particle (= macro particle weighting) + * unit: none */ + const float_X TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE = float_64(SI::GAS_DENSITY_NORMED*SI::CELL_WIDTH_SI*SI::CELL_HEIGHT_SI *SI::CELL_DEPTH_SI ) + / float_64(particles::TYPICAL_PARTICLES_PER_CELL); + } + +#elif(SIMDIM==DIM2) + namespace SI + { + /** density normed to dimension of the simulation + * + * http://www.tf.uni-kiel.de/matwis/amat/mw1_ge/kap_6/basics/m6_2_1.html + */ + const float_64 GAS_DENSITY_NORMED= SI::GAS_DENSITY_SI*UNIT_LENGTH; + } //namespace SI + namespace particles + { + /** Number of particles per makro particle (= macro particle weighting) + * unit: none */ + const float_X TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE = float_64(SI::GAS_DENSITY_NORMED*SI::CELL_WIDTH_SI*SI::CELL_HEIGHT_SI ) + / float_64(particles::TYPICAL_PARTICLES_PER_CELL); + } +#endif + + + /** Unit of mass */ + const double UNIT_MASS = SI::ELECTRON_MASS_SI * double(particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE); + /** Unit of charge */ + const double UNIT_CHARGE = -1.0 * SI::ELECTRON_CHARGE_SI * double(particles::TYPICAL_NUM_PARTICLES_PER_MACROPARTICLE); + /** Unit of energy */ + const double UNIT_ENERGY = (UNIT_MASS * UNIT_LENGTH * UNIT_LENGTH / (UNIT_TIME * UNIT_TIME)); + /** Unit of EField: V/m */ + const double UNIT_EFIELD = 1.0 / (UNIT_TIME * UNIT_TIME / UNIT_MASS / UNIT_LENGTH * UNIT_CHARGE); + //** Unit of BField: Tesla [T] = Vs/m^2 */ + const double UNIT_BFIELD = (UNIT_MASS / (UNIT_TIME * UNIT_CHARGE)); + + + + + const float_X SPEED_OF_LIGHT = float_X(SI::SPEED_OF_LIGHT_SI / UNIT_SPEED); + + //! Charge of electron + const float_X Q_EL = (float) (SI::ELECTRON_CHARGE_SI / UNIT_CHARGE); + //! Mass of electron + const float_X M_EL = (float) (SI::ELECTRON_MASS_SI / UNIT_MASS); + + //! Mass of ion + const float_X M_ION = (float) (SI::ION_MASS_SI / UNIT_MASS); + + //! Mass of ion carbon + const float_X M_IONC = (float) (SI::ION_MASS_C_SI / UNIT_MASS); + + + //! magnetic constant must be double 3.92907e-39 + const float_X MUE0 = (float) (SI::MUE0_SI / UNIT_LENGTH / UNIT_MASS * UNIT_CHARGE * UNIT_CHARGE); + + //! electric constant must be double 2.54513e+38 + const float_X EPS0 = (float) (1. / MUE0 / SPEED_OF_LIGHT / SPEED_OF_LIGHT); + + // = 1/c^2 + const float_X MUE0_EPS0 = float_X(1. / SPEED_OF_LIGHT / SPEED_OF_LIGHT); + +} //namespace picongpu diff --git a/examples/LaserWakefield/include/simulation_defines/unitless/speciesDefinition.unitless b/examples/LaserWakefield/include/simulation_defines/unitless/speciesDefinition.unitless new file mode 100644 index 0000000000..2e06f37c54 --- /dev/null +++ b/examples/LaserWakefield/include/simulation_defines/unitless/speciesDefinition.unitless @@ -0,0 +1,91 @@ +/** + * Copyright 2014 Rene Widera + * + * 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 . + */ + + +#pragma once + +#include "traits/frame/GetCharge.hpp" +#include "traits/frame/GetMass.hpp" +#include "traits/attribute/GetCharge.hpp" +#include "traits/attribute/GetChargeState.hpp" +#include "traits/attribute/GetMass.hpp" +#include "fields/currentDeposition/Solver.hpp" +#include "particles/Particles.tpp" +#include "particles/ionization/byField/ionizers.hpp" + +namespace picongpu +{ +namespace traits +{ +namespace frame +{ + +template<> +HDINLINE float_X getMass() +{ + return M_ION; + /** \todo take account for mass loss of ions when electrons leave them during ionization */ +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL; +}; + +template<> +HDINLINE float_X getMass() +{ + return M_EL; +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL*float_X(-1.0); +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL*float_X(-6.0); +}; + +template<> +HDINLINE float_X getMass() +{ + return M_IONC; +}; + +template<> +HDINLINE float_X getCharge() +{ + return Q_EL; +}; + +template<> +HDINLINE float_X getMass() +{ + return M_EL; +}; + +} //namespace frame +} //namespace traits +} //namespace picongpu diff --git a/examples/LaserWakefield/submit/0016gpus.cfg b/examples/LaserWakefield/submit/0016gpus.cfg index 5b3ba2f3e8..acf7166916 100644 --- a/examples/LaserWakefield/submit/0016gpus.cfg +++ b/examples/LaserWakefield/submit/0016gpus.cfg @@ -37,7 +37,7 @@ TBG_gpu_x=2 TBG_gpu_y=4 TBG_gpu_z=2 -TBG_gridSize="-g 192 1024 192" +TBG_gridSize="-g 256 1024 256" TBG_steps="-s 4000" # leave TBG_movingWindow empty to disable moving window @@ -49,12 +49,12 @@ TBG_movingWindow="-m" ################################# # create preview images (png) -TBG_pngYZ="--e_png.period 10 --e_png.axis yz --e_png.slicePoint 0.5 --e_png.folder pngElectronsYZ" -TBG_pngYX="--e_png.period 10 --e_png.axis yx --e_png.slicePoint 0.5 --e_png.folder pngElectronsYX" +TBG_pngYZ="--eH_png.period 10 --eH_png.axis yz --eH_png.slicePoint 0.5 --eH_png.folder pngElectronsYZ" +TBG_pngYX="--eH_png.period 10 --eH_png.axis yx --eH_png.slicePoint 0.5 --eH_png.folder pngElectronsYX" TBG_plugins="!TBG_pngYX \ !TBG_pngYZ \ - --e_macroParticlesCount.period 100" + --eH_macroParticlesCount.period 100" ################################# diff --git a/src/picongpu/include/particles/manipulators/RandomPosImpl.def b/src/picongpu/include/particles/manipulators/RandomPosImpl.def new file mode 100644 index 0000000000..fb149b1fa3 --- /dev/null +++ b/src/picongpu/include/particles/manipulators/RandomPosImpl.def @@ -0,0 +1,36 @@ +/** + * Copyright 2014 Rene Widera + * + * 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 . + */ + + +#pragma once + +namespace picongpu +{ +namespace particles +{ +namespace manipulators +{ + +template< typename T_SpeciesType = bmpl::_1> +struct RandomPosImpl; + +} //namespace manipulators +} //namespace particles +} //namespace picongpu diff --git a/src/picongpu/include/particles/manipulators/RandomPosImpl.hpp b/src/picongpu/include/particles/manipulators/RandomPosImpl.hpp new file mode 100644 index 0000000000..3c311e21d5 --- /dev/null +++ b/src/picongpu/include/particles/manipulators/RandomPosImpl.hpp @@ -0,0 +1,94 @@ +/** + * Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera + * + * 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 . + */ + + +#pragma once + +#include "simulation_defines.hpp" +#include "nvidia/rng/RNG.hpp" +#include "nvidia/rng/methods/Xor.hpp" +#include "nvidia/rng/distributions/Uniform_float.hpp" +#include "mpi/SeedPerRank.hpp" + +namespace picongpu +{ +namespace particles +{ +namespace manipulators +{ + +namespace nvrng = nvidia::rng; +namespace rngMethods = nvidia::rng::methods; +namespace rngDistributions = nvidia::rng::distributions; + +template< typename T_SpeciesType> +struct RandomPosImpl +{ + typedef T_SpeciesType SpeciesType; + typedef typename MakeIdentifier::type SpeciesName; + + HINLINE RandomPosImpl(uint32_t currentStep) : isInitialized(false) + { + typedef typename SpeciesType::FrameType FrameType; + + GlobalSeed globalSeed; + mpi::SeedPerRank seedPerRank; + seed = seedPerRank(globalSeed(), FrameType::CommunicationTag); + seed ^= POSITION_SEED; + + const SubGrid& subGrid = Environment::get().SubGrid(); + localCells = subGrid.getLocalDomain().size; + } + + template + DINLINE void operator()(const DataSpace& localCellIdx, T_Particle& particle, const bool isParticle) + { + typedef typename T_Particle::FrameType FrameType; + + if (!isInitialized) + { + const uint32_t cellIdx = DataSpaceOperations::map( + localCells, + localCellIdx); + rng = nvrng::create(rngMethods::Xor(seed, cellIdx), rngDistributions::Uniform_float()); + isInitialized = true; + } + if (isParticle) + { + floatD_X tmpPos; + + for (uint32_t d = 0; d < simDim; ++d) + tmpPos[d] = rng(); + + particle[position_] = tmpPos; + } + } + +private: + typedef PMacc::nvidia::rng::RNG RngType; + RngType rng; + bool isInitialized; + uint32_t seed; + DataSpace localCells; +}; + +} //namespace manipulators +} //namespace particles +} //namespace picongpu diff --git a/src/picongpu/include/particles/manipulators/manipulators.def b/src/picongpu/include/particles/manipulators/manipulators.def index 38f063512a..2d5fdd3e97 100644 --- a/src/picongpu/include/particles/manipulators/manipulators.def +++ b/src/picongpu/include/particles/manipulators/manipulators.def @@ -29,3 +29,4 @@ #include "particles/manipulators/CreateParticlesFromParticleImpl.def" #include "particles/manipulators/FreeImpl.def" #include "particles/manipulators/SetAttributeImpl.def" +#include "particles/manipulators/RandomPosImpl.def" diff --git a/src/picongpu/include/particles/manipulators/manipulators.hpp b/src/picongpu/include/particles/manipulators/manipulators.hpp index 9b9d58ee3e..ae7e7093b7 100644 --- a/src/picongpu/include/particles/manipulators/manipulators.hpp +++ b/src/picongpu/include/particles/manipulators/manipulators.hpp @@ -27,4 +27,5 @@ #include "particles/manipulators/IfRelativeGlobalPositionImpl.hpp" #include "particles/manipulators/CreateParticlesFromParticleImpl.hpp" #include "particles/manipulators/FreeImpl.hpp" +#include "particles/manipulators/RandomPosImpl.hpp" #include "particles/manipulators/SetAttributeImpl.hpp"