Skip to content

Commit

Permalink
Close ComputationalRadiationPhysics#381 Meta Information in Phase Space
Browse files Browse the repository at this point in the history
Uses m_species * c to scale output for now.
(Previously it scaled by the electron mass.)

New Attributes:
  - exclusive offset of the global moving window
    if the spatial dimension is == y
  - [p_min;p_max] + unit
  - dr + unit (spatial dimension)
  - dt + unit (time step)
  • Loading branch information
ax3l committed May 9, 2014
1 parent b6f146b commit 5b24da6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 35 deletions.
49 changes: 40 additions & 9 deletions src/picongpu/include/plugins/PhaseSpace/DumpHBufferSplashP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ namespace picongpu
*/
template<typename T_Type, int T_bufDim>
void operator()( const PMacc::container::HostBuffer<T_Type, T_bufDim>& hBuffer,
const std::pair<uint32_t, uint32_t> axis_element,
const double unit,
const uint32_t currentStep,
MPI_Comm& mpiComm ) const
const std::pair<uint32_t, uint32_t> axis_element,
const std::pair<float_X, float_X> axis_p_range,
const float_64 pRange_unit,
const float_64 unit,
const uint32_t currentStep,
MPI_Comm& mpiComm ) const
{
using namespace splash;
typedef T_Type Type;
Expand Down Expand Up @@ -95,13 +97,19 @@ namespace picongpu

/* globalDomain of the phase space */
splash::Dimensions globalPhaseSpace_size( rSize, hBuffer.size().y(), 1 );
/* moving window meta information */

/* global moving window meta information */
splash::Dimensions globalPhaseSpace_offset( 0, 0, 0 );
int movingWindowOffset = 0;
int movingWindowSize = rSize;
if( axis_element.first == 1 ) /* spatial axis == y */
{
VirtualWindow window = MovingWindow::getInstance( ).getVirtualWindow( currentStep );
//Window window = MovingWindow::getInstance( ).getWindow( currentStep );
globalPhaseSpace_offset.set( window.slides * simBox.getLocalSize( ).y(),
0, 0 );
movingWindowOffset = window.globalDimensions.offset[axis_element.first];
movingWindowSize = window.globalDimensions.size[axis_element.first];
}

/* localDomain: offset of it in the globalDomain and size */
Expand Down Expand Up @@ -141,14 +149,37 @@ namespace picongpu
DomainCollector::GridType,
&(*hBuffer.origin()) );

ColTypeDouble ctDouble;
pdc.writeAttribute( currentStep, ctDouble, dataSetName.str().c_str(),
/** meta attributes for the data set: unit, range, moving window **/
typedef PICToSplash<float_X>::type SplashFloatXType;
typedef PICToSplash<float_64>::type SplashFloat64Type;
ColTypeInt ctInt;
SplashFloat64Type ctFloat64;
SplashFloatXType ctFloatX;

pdc.writeAttribute( currentStep, ctFloat64, dataSetName.str().c_str(),
"sim_unit", &unit );
pdc.writeAttribute( currentStep, ctFloat64, dataSetName.str().c_str(),
"p_unit", &pRange_unit );
pdc.writeAttribute( currentStep, ctFloatX, dataSetName.str().c_str(),
"p_min", &(axis_p_range.first) );
pdc.writeAttribute( currentStep, ctFloatX, dataSetName.str().c_str(),
"p_max", &(axis_p_range.second) );
pdc.writeAttribute( currentStep, ctInt, dataSetName.str().c_str(),
"movingWindowOffset", &movingWindowOffset );
pdc.writeAttribute( currentStep, ctInt, dataSetName.str().c_str(),
"movingWindowSize", &movingWindowSize );

pdc.writeAttribute( currentStep, ctFloatX, dataSetName.str().c_str(),
"dr", &(cellSize[axis_element.first]) );
pdc.writeAttribute( currentStep, ctFloat64, dataSetName.str().c_str(),
"dr_unit", &UNIT_LENGTH );
pdc.writeAttribute( currentStep, ctFloatX, dataSetName.str().c_str(),
"dt", &DELTA_T );
pdc.writeAttribute( currentStep, ctFloat64, dataSetName.str().c_str(),
"dr_unit", &UNIT_TIME );

/** close file ****************************************************/
#if (SPLASH_VERSION_MAJOR>1) || ((SPLASH_VERSION_MAJOR==1) && (SPLASH_VERSION_MINOR>=2))
pdc.finalize();
#endif
pdc.close();
}
};
Expand Down
17 changes: 14 additions & 3 deletions src/picongpu/include/plugins/PhaseSpace/PhaseSpace.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,23 @@ namespace picongpu
_2 = _1);

/* write to file */
const double UNIT_VOLUME = ( UNIT_LENGTH * UNIT_LENGTH * UNIT_LENGTH );
const double unit = UNIT_CHARGE / UNIT_VOLUME;
const float_64 UNIT_VOLUME = math::pow( UNIT_LENGTH, (int)simDim );
const float_64 unit = UNIT_CHARGE / UNIT_VOLUME;

/* (momentum) p range: unit is m_species * c
* During the kernels we calculate with a typical MAKRO momentum range
* to avoid over- / underflows. Now for the dump the meta information
* on the p-axis should be scaled to represent single/real particles.
* \see PhaseSpaceMulti::pluginLoad( ) */
float_64 pRange_unit = float_64( Species::FrameType::getMass(1.0) ) *
float_64( SPEED_OF_LIGHT );

DumpHBuffer dumpHBuffer;

if( this->commFileWriter != MPI_COMM_NULL )
dumpHBuffer( hReducedBuffer_noGuard, this->axis_element, unit, currentStep, this->commFileWriter );
dumpHBuffer( hReducedBuffer_noGuard, this->axis_element,
this->axis_p_range, pRange_unit,
unit, currentStep, this->commFileWriter );
}

template<class AssignmentFunction, class Species>
Expand Down
47 changes: 24 additions & 23 deletions src/picongpu/include/plugins/PhaseSpace/PhaseSpaceMulti.tpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/** Copyright 2013-2014 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/>.
* 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/>.
*/

#include "PhaseSpaceMulti.hpp"
Expand Down Expand Up @@ -48,9 +48,9 @@ namespace picongpu
((this->prefix + ".momentum").c_str(),
po::value<std::vector<std::string> > (&this->element_momentum)->multitoken(), "momentum component (px, py, pz)")
((this->prefix + ".min").c_str(),
po::value<std::vector<float_X> > (&this->momentum_range_min)->multitoken(), "min range momentum [m_e c]")
po::value<std::vector<float_X> > (&this->momentum_range_min)->multitoken(), "min range momentum [m_species c]")
((this->prefix + ".max").c_str(),
po::value<std::vector<float_X> > (&this->momentum_range_max)->multitoken(), "max range momentum [m_e c]");
po::value<std::vector<float_X> > (&this->momentum_range_max)->multitoken(), "max range momentum [m_species c]");
}

template<class AssignmentFunction, class Species>
Expand All @@ -64,18 +64,19 @@ namespace picongpu
this->children.reserve( this->numChildren );
for(uint32_t i = 0; i < this->numChildren; i++)
{
/* unit is m_e c - we use the typical weighting already since it
* scales linear in momentum and we avoid over- & under-flows
/* unit is m_species c - we use the typical weighting already since
* it scales linear in momentum and we avoid over- & under-flows
* during momentum-binning while staying at a
* "typical macro particle momentum scale"
*
* we correct that during the output of the pAxis range
* (linearly shrinking the single particle scale again)
*/
float_X unit_pRange = float_X( double(NUM_EL_PER_PARTICLE) *
double(M_EL) * double(SPEED_OF_LIGHT) );
std::pair<float_X, float_X> new_p_range( this->momentum_range_min.at(i) * unit_pRange,
this->momentum_range_max.at(i) * unit_pRange );
float_X pRangeMakro_unit = float_X( Species::FrameType::getMass(NUM_EL_PER_PARTICLE) *
SPEED_OF_LIGHT );
std::pair<float_X, float_X> new_p_range(
this->momentum_range_min.at(i) * pRangeMakro_unit,
this->momentum_range_max.at(i) * pRangeMakro_unit );
/* String to Enum conversion */
uint32_t el_space;
if( this->element_space.at(i) == "x" )
Expand Down

0 comments on commit 5b24da6

Please sign in to comment.