Skip to content

Commit

Permalink
Add BG FieldJ Config and RunOneStep implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Mar 3, 2014
1 parent 278ba6a commit 7b22f37
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/picongpu/include/simulationControl/MySimulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ class MySimulation : public SimulationHelper<simDim>

#endif
__delete(laser);
__delete(pushBGField);
__delete(currentBGField);
}

virtual uint32_t init()
Expand All @@ -259,6 +261,7 @@ class MySimulation : public SimulationHelper<simDim>
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="<<layout.getDataSpace().x()<<" y="<<layout.getDataSpace().y()<<std::endl;

Expand Down Expand Up @@ -377,6 +380,10 @@ class MySimulation : public SimulationHelper<simDim>

fieldJ->clear();

/** add "external" background current */
(*currentBGField)(fieldJ, nvfct::Add(), fieldBackgroundJ(fieldJ->getUnit()),
currentStep, fieldBackgroundJ::activated);

#if (ENABLE_IONS == 1)
__setTransactionEvent(eRecvIons + eIons);
#if (ENABLE_CURRENT ==1)
Expand Down Expand Up @@ -482,6 +489,7 @@ class MySimulation : public SimulationHelper<simDim>
// field solver
fieldSolver::FieldSolver* myFieldSolver;
cellwiseOperation::CellwiseOperation< CORE + BORDER + GUARD >* pushBGField;
cellwiseOperation::CellwiseOperation< CORE + BORDER + GUARD >* currentBGField;

// particles
#if (ENABLE_IONS == 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<simDim>& 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<float_X>( y_SI / period_SI * 2.0 * PI );
return float3_X(0.0, math::cos( sinArg ) / unitField[1], 0.0);
}
};

} // namespace picongpu

0 comments on commit 7b22f37

Please sign in to comment.