Skip to content

Commit

Permalink
SingleParticle Test: Little Gyro Spin
Browse files Browse the repository at this point in the history
Modifies the single particle test to make a little spin
in 2 periods during 100 steps with relativistic momentum.
At the same time, the particle is accelerated non-relativistically
by about 0.005 beta in orthogonal direction with an E-Field.

Can be used to validate pushers, current, charge, radiation or
photon creation. Does only need a single GPU and creates just around
~1GB output which is compressed about 37 MB.

Currently no tools added alongside, since I am waiting for a
small bug in yt to be fixed (and also for our new CI node).

So long,
[here](https://gist.github.com/ax3l/9b49780a1bbedbe054f7d98654644e71/128a383a55ee62e342028b0744d72b3e40b60c8e)
is an example script that does not look nice yet:
```python
import opmd_viewer
import numpy as np
%matplotlib notebook
import matplotlib.pyplot as plt

ts3 = opmd_viewer.OpenPMDTimeSeries("singleParticle-004/simOutput/h5/")

pos_x = []
pos_y = []
pos_z = []
mom_z = []
t = []

for t_it in ts3.iterations:
    tmp = ts3.get_particle(["x", "y", "z", "uz"], "e", iteration=t_it)
    pos_x.append(tmp[0][0])
    pos_y.append(tmp[1][0])
    pos_z.append(tmp[2][0])
    mom_z.append(tmp[3][0])
    t.append(ts3.current_t)

plt.figure()
plt.plot(pos_x, pos_y, "x", label="pos_xy")
plt.legend()
plt.show()

plt.figure()
plt.plot(pos_z, label="z")
plt.legend()
plt.show()

plt.figure()
plt.plot(mom_z, label="mom_z")
plt.show()

plt.figure()
plt.plot(t, label="t")
plt.show()
```

There are other tests that I like more when we add a RT test
analysis, e.g. a drift in an inhomogenous B field.
  • Loading branch information
ax3l committed Jan 24, 2017
1 parent 9d49fff commit c24de4c
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ namespace laserProfile = laserNone;
namespace fieldSolver = fieldSolverNone;

/*! enable (1) or disable (0) current calculation */
#define ENABLE_CURRENT 0
#define ENABLE_CURRENT 1

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2016 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
* Copyright 2013-2017 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt,
* Richard Pausch
*
* This file is part of PIConGPU.
Expand All @@ -19,41 +19,42 @@
* If not, see <http://www.gnu.org/licenses/>.
*/


#pragma once

#include "particles/gasProfiles/profiles.def"
#include "particles/densityProfiles/profiles.def"
/* preprocessor struct generator */
#include "preprocessor/struct.hpp"


namespace picongpu
{
namespace SI
{
/** The maximum density in particles per m^3 in the gas distribution
* unit: ELEMENTS/m^3
/** Base density in particles per m^3 in the density profiles.
*
* This is often taken as reference maximum density in normalized profiles.
* Individual particle species can define a `densityRatio` flag relative
* to this value.
*
* unit: ELEMENTS/m^3
*
* One particle per cell with weighting 1.0:
* One particle per cell with weighting 1.0:
*/
constexpr float_64 GAS_DENSITY_SI =
constexpr float_64 BASE_DENSITY_SI =
1.0 /
( CELL_WIDTH_SI * CELL_HEIGHT_SI * CELL_DEPTH_SI );

}

//##########################################################################
//############## special gas profiles ######################################
//##########################################################################

namespace gasProfiles
namespace densityProfiles
{

struct FreeFormulaFunctor
{

/**
* This formula uses SI quantities only
* The profile will be multiplied by GAS_DENSITY.
* The profile will be multiplied by BASE_DENSITY_SI.
*
* @param position_SI total offset including all slides [in meter]
* @param cellSize_SI cell sizes [in meter]
Expand All @@ -67,8 +68,11 @@ namespace gasProfiles
{
const PMacc::math::UInt64< simDim > cell_id( position_SI / cellSize_SI.shrink< simDim >() );

// add particle in cell in first y plane at [128, 0, 128 ]
const PMacc::math::UInt64< DIM3 > cell_start( 128u, 0u, 128u );
// add particle in cell in at [ 32 5 16 ]
// X=32: middle of X plane (gyro-motion in X-Y)
// Y=5: do not start fully at border, e.g., if someone wants to increase E, and so mass over time
// Z=16: middle of box in Z, move slowly in positive Z as E-field drift
const PMacc::math::UInt64< DIM3 > cell_start( 32u, 5u, 16u );

bool isStartCell = true;
for( uint64_t d = 0; d < simDim; ++d )
Expand All @@ -82,9 +86,7 @@ namespace gasProfiles
}
};

/* definition of gas free formula */
/* definition of free formula profile */
using FreeFormula = FreeFormulaImpl< FreeFormulaFunctor >;

} // namespace gasProfiles

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2014-2016 Axel Huebl, Alexander Debus
* Copyright 2014-2017 Axel Huebl, Alexander Debus
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -29,7 +29,7 @@ namespace picongpu
{
public:
/* Add this additional field for pushing particles */
static constexpr bool InfluenceParticlePusher = false;
static constexpr bool InfluenceParticlePusher = true;

/* We use this to calculate your SI input back to our unit system */
PMACC_ALIGN(
Expand All @@ -54,8 +54,8 @@ namespace picongpu
/* specify your E-Field in V/m and convert to PIConGPU units */
return float3_X(
0.0,
-1.0e13 / m_unitField[1],
0.0
0.0,
-10.0e6 / m_unitField[1]
);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright 2013-2017 Axel Huebl, Rene Widera, Felix Schmitt,
* Benjamin Worpitz, Richard Pausch
* Benjamin Worpitz, Richard Pausch
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -36,20 +36,32 @@
namespace picongpu
{
/** FieldTmp output (calculated at runtime) *******************************
*
* Those operations derive scalar field quantities from particle species
* at runtime. Each value is mapped per cell. Some operations are identical
* up to a constant, so avoid writing those twice to save storage.
*
* you can choose any of these particle to grid projections:
* - CreateDensityOperation: particle position + shape on the grid
* - CreateChargeDensityOperation: density * charge
* - CreateMidCurrentDensityComponentOperation:
* density * charge * velocity_component
* - CreateCounterOperation: counts point like particles per cell (debug)
* - CreateEnergyDensityOperation: particle energy density with respect
* to shape
* - CreateEnergyOperation: particle energy with respect to shape
* note: for species that do not change their charge state, this is
* the same as the density times a constant for the charge
* - CreateEnergyOperation: sum of kinetic particle energy per cell with
* respect to shape (deprecated)
* - CreateEnergyDensityOperation: average kinetic particle energy per
* cell times the particle density
* note: this is the same as the sum of kinetic particle energy
* divided by a constant for the cell volume
* - CreateMomentumComponentOperation: ratio between a selected momentum
* component and the absolute
* momentum with respect to shape
* - CreateLarmorPowerOperation: radiated larmor power (needs ENABLE_RADIATION)
* - CreateLarmorPowerOperation: radiated larmor power
* (needs ENABLE_RADIATION)
*
* for debugging:
* - CreateMidCurrentDensityComponentOperation:
* density * charge * velocity_component
* - CreateCounterOperation: counts point like particles per cell
*/
using namespace particleToGrid;

Expand All @@ -59,20 +71,13 @@ namespace picongpu
CreateChargeDensityOperation< bmpl::_1 >
>::type;

/* ParticleCounter section */
using Counter_Seq = bmpl::transform<
VectorAllSpecies,
CreateCounterOperation< bmpl::_1 >
>::type;


/** FieldTmpSolvers groups all solvers that create data for FieldTmp ******
*
* FieldTmpSolvers is used in @see FieldTmp to calculate the exchange size
*/
using FieldTmpSolvers = MakeSeq_t<
ChargeDensity_Seq,
Counter_Seq
ChargeDensity_Seq
>;


Expand All @@ -81,8 +86,6 @@ namespace picongpu
/** Possible native fields: FieldE, FieldB, FieldJ
*/
using NativeFileOutputFields = MakeSeq_t<
FieldE,
FieldB,
FieldJ
>;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* Copyright 2013-2017 Axel Huebl, Rene Widera, Benjamin Worpitz
*
* 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 SI
{
/** Period of a gyro-motion in s for an electron with beta=0.5 in B=50T
* unit: seconds */
constexpr float_64 T_GYRO_SI = 0.825e-12;

/** Duration of one timestep
* unit: seconds */
constexpr float_64 DELTA_T_SI = T_GYRO_SI / 50.;

/** equals X
* unit: meter */
constexpr float_64 CELL_WIDTH_SI = 8.6e-6;
/** equals Y
* unit: meter */
constexpr float_64 CELL_HEIGHT_SI = CELL_WIDTH_SI;
/** equals Z
* unit: meter */
constexpr float_64 CELL_DEPTH_SI = CELL_WIDTH_SI;

/** Note on units in reduced dimensions
*
* In 2D3V simulations, the CELL_DEPTH_SI (Z) cell length
* is still used for normalization of densities, etc.
*
* A 2D3V simulation in a cartesian PIC simulation such as
* ours only changes the degrees of freedom in motion for
* (macro) particles and all (field) information in z
* travels instantaneous, making the 2D3V simulation
* behave like the interaction of infinite "wire particles"
* in fields with perfect symmetry in Z.
*/

} //namespace SI

//! Defines the size of the absorbing zone (in cells)
const uint32_t ABSORBER_CELLS[3][2] = {
{32, 32}, /*x direction [negative,positive]*/
{32, 32}, /*y direction [negative,positive]*/
{32, 32} /*z direction [negative,positive]*/
}; //unit: number of cells

//! Define the strength of the absorber for any direction
const float_X ABSORBER_STRENGTH[3][2] = {
{1.0e-3, 1.0e-3}, /*x direction [negative,positive]*/
{1.0e-3, 1.0e-3}, /*y direction [negative,positive]*/
{1.0e-3, 1.0e-3} /*z direction [negative,positive]*/
}; //unit: none

constexpr uint32_t ABSORBER_FADE_IN_STEPS = 16;

/** When to move the co-moving window.
* An initial pseudo particle, flying with the speed of light,
* is fired at the begin of the simulation.
* When it reaches slide_point % of the absolute(*) simulation area,
* the co-moving window starts to move with the speed of light.
*
* (*) Note: beware, that there is one "hidden" row of gpus at the y-front,
* when you use the co-moving window
* 0.75 means only 75% of simulation area is used for real simulation
*/
constexpr float_64 slide_point = 0.90;

}



Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ namespace manipulators
3,
DriftParam_direction,
/* unit vector for direction of drift: x, y, z */
0.0,
1.0,
0.0,
0.0
);
struct DriftParam
Expand Down Expand Up @@ -93,7 +93,7 @@ namespace startPosition
const InCellOffset_t inCellOffset;
};

/* definition of quiet particle start*/
/* definition of one specific position for particle start */
using OnePosition = OnePositionImpl< OnePositionParameter >;

} // namespace startPosition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2016 Rene Widera, Axel Huebl
* Copyright 2015-2017 Rene Widera, Axel Huebl
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -30,13 +30,13 @@ namespace particles
/* Available species functors
* in src/picongpu/include/particles/InitFunctors.hpp
*
* - CreateGas<T_GasFunctor, T_PositionFunctor, T_SpeciesType>
* Create particle distribution based on a gas profile and an in-cell
* - CreateDensity<T_DensityFunctor, T_PositionFunctor, T_SpeciesType>
* Create particle distribution based on a density profile and an in-cell
* positioning.
* Fills a particle species (`fillAllGaps()` is called).
* @tparam T_GasFunctor unary lambda functor with gas description,
* \see gasConfig.param
* \example gasProfiles::Homogenous,
* @tparam T_DensityFunctor unary lambda functor with density description,
* \see densityConfig.param
* \example densityProfiles::Homogenous,
* @tparam T_PositionFunctor unary lambda functor with position description,
* \see particlesConfig.param
* \example startPosition::Quiet
Expand Down Expand Up @@ -83,8 +83,8 @@ namespace particles
* the functors are called in order (from first to last functor)
*/
using InitPipeline = mpl::vector<
CreateGas<
gasProfiles::FreeFormula,
CreateDensity<
densityProfiles::FreeFormula,
startPosition::OnePosition,
PIC_Electrons
>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@

TBG_wallTime="1:00:00"

TBG_gpu_x=2
TBG_gpu_y=2
TBG_gpu_z=2
TBG_gpu_x=1
TBG_gpu_y=1
TBG_gpu_z=1

TBG_gridSize="-g 256 256 256"
TBG_steps="-s 2000"
TBG_gridSize="-g 64 64 32"
TBG_steps="-s 100"

TBG_periodic="--periodic 1 0 1"
TBG_periodic="--periodic 1 1 1"

#################################
## Section: Optional Variables ##
#################################

TBG_plugins="--e_position.period 1 \
--hdf5.period 1 \
# write position to stdout (messy):
# --e_position.period 1

TBG_plugins="--hdf5.period 1 \
--e_macroParticlesCount.period 100"


Expand Down

0 comments on commit c24de4c

Please sign in to comment.