Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/picongpu/include/particles/gasProfiles/FreeFormulaImpl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015 Rene Widera
* Copyright 2015 Rene Widera, Richard Pausch
*
* This file is part of PIConGPU.
*
Expand Down Expand Up @@ -51,9 +51,15 @@ struct FreeFormulaImpl : public T_ParamClass
*/
HDINLINE float_X operator()(const DataSpace<simDim>& totalCellOffset)
{
const float_64 unit_length = UNIT_LENGTH;
DataSpace<simDim> position_SI = totalCellOffset;
cellSize_t cellSize_SI = cellSize;
for(unsigned int i = 0; i<simDim ; i++)
{
cellSize_SI *= UNIT_LENGTH;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cellSize_t is of type float_X and does not guarantee to hold a SI-scaled value.

position_SI[i] *= cellSize_SI[i];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each component of position_SI is, as the DataSpace components, of type int which will not behave well when scaled to meters.

}

float_X density = ParamClass::operator()( totalCellOffset, unit_length );
float_X density = ParamClass::operator()(position_SI, cellSize_SI);

return density;
}
Expand Down
21 changes: 13 additions & 8 deletions src/picongpu/include/simulation_defines/param/gasConfig.param
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013-2014 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
* Copyright 2013-2015 Axel Huebl, Heiko Burau, Rene Widera, Felix Schmitt
* Richard Pausch
*
* This file is part of PIConGPU.
Expand Down Expand Up @@ -242,29 +242,34 @@ struct FreeFormulaFunctor
{

/**
* This formula should use SI quantities only!
* This formula uses SI quantities only
* The profile will be multiplied by GAS_DENSITY.
*
* @param totalCellOffset total offset including all slides [in cells]
* @param unitLength PIConGPU unit length
* @param position_SI total offset including all slides [in meter]
* @param cellSize_SI cell sizes [in meter]
*
* @return float_X density
* @return float_X density [normalized to 1.0]
*/
HDINLINE float_X operator()(const DataSpace<simDim>& totalCellOffset, const float_64 unitLength)
template<class cellSizeType>
HDINLINE float_X operator()(const DataSpace<simDim>& position_SI, const cellSizeType& cellSize_SI)
{
const float_64 y = float_64(totalCellOffset.y()) * unitLength * 1000.0; // m -> mm
const float_64 y = float_64(position_SI.y()) * 1000.0; // m -> mm
//const unsigned int y_cell_id = position_SI.y() / cellSize_SI[1];

/* triangle function example
* for a density profile from 0 to 400 microns */
float_64 s = 1.0 - 5.0 * math::abs(y - 0.2);

/* give it an empty/filled shape for every second cell */
//s *= float_64( (y_cell_id % 2) == 0 );

/* all parts of the function MUST be > 0 */
s *= float_64(s >= 0.0);
return s;
}
};

/* definition of gas sphere with flanks*/
/* definition of gas free formula */
typedef FreeFormulaImpl<FreeFormulaFunctor> FreeFormula;

}//namespace gasProfiles
Expand Down