diff --git a/src/picongpu/include/simulationControl/MySimulation.hpp b/src/picongpu/include/simulationControl/MySimulation.hpp index a138697e6d..bbcf3328a6 100644 --- a/src/picongpu/include/simulationControl/MySimulation.hpp +++ b/src/picongpu/include/simulationControl/MySimulation.hpp @@ -248,6 +248,8 @@ class MySimulation : public SimulationHelper #endif __delete(laser); + __delete(pushBGField); + __delete(currentBGField); } virtual uint32_t init() @@ -259,6 +261,7 @@ class MySimulation : public SimulationHelper fieldJ = new FieldJ(*cellDescription); fieldTmp = new FieldTmp(*cellDescription); pushBGField = new cellwiseOperation::CellwiseOperation < CORE + BORDER + GUARD > (*cellDescription); + currentBGField = new cellwiseOperation::CellwiseOperation < CORE + BORDER + GUARD > (*cellDescription); //std::cout<<"Grid x="<getUnit()), + currentStep, fieldBackgroundJ::activated); + #if (ENABLE_IONS == 1) __setTransactionEvent(eRecvIons + eIons); #if (ENABLE_CURRENT ==1) @@ -482,6 +489,7 @@ class MySimulation : public SimulationHelper // field solver fieldSolver::FieldSolver* myFieldSolver; cellwiseOperation::CellwiseOperation< CORE + BORDER + GUARD >* pushBGField; + cellwiseOperation::CellwiseOperation< CORE + BORDER + GUARD >* currentBGField; // particles #if (ENABLE_IONS == 1) diff --git a/src/picongpu/include/simulation_defines/param/fieldBackground.param b/src/picongpu/include/simulation_defines/param/fieldBackground.param index ef6293ed2f..be08d84a91 100644 --- a/src/picongpu/include/simulation_defines/param/fieldBackground.param +++ b/src/picongpu/include/simulation_defines/param/fieldBackground.param @@ -89,4 +89,36 @@ namespace picongpu } }; + class fieldBackgroundJ + { + public: + /* Add this additional field? */ + static const bool activated = false; + + /* We use this to calculate your SI input back to our unit system */ + const float3_64 unitField; + HDINLINE fieldBackgroundJ( const float3_64 unitField_ ) : unitField(unitField_) + {} + + /** Specify your background field J(r,t) here + * + * \param cellIdx The total cell id counted from the start at t=0 + * \param currentStep The current time step */ + HDINLINE float3_X + operator()( const DataSpace& cellIdx, + const uint32_t currentStep ) const + { + /* example: periodicity of 20 microns (=2.0e-5 m) */ + const float_64 period_SI(20.0e-6); + /* calculate cells -> SI -> m to microns*/ + const float_64 y_SI = cellIdx.y() * SI::CELL_HEIGHT_SI * 1.0e6; + /* note: you can also transform the time step to seconds by + * multiplying with DELTA_T_SI */ + + /* specify your J-Field in T and convert to PIConGPU units */ + const float_X sinArg = precisionCast( y_SI / period_SI * 2.0 * PI ); + return float3_X(0.0, math::cos( sinArg ) / unitField[1], 0.0); + } + }; + } // namespace picongpu