Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More window functions #320

Merged
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ This is the 5th release candidate, a *pre-beta* version.

**.param file changes:**
- Added selection of optional window functions in `radiationConfig.param`
[#286](https://github.com/ComputationalRadiationPhysics/picongpu/pull/286/files#diff-1)
[#286](https://github.com/ComputationalRadiationPhysics/picongpu/pull/286/files#diff-1)
- Added more window functions in `radiationConfig.param`
[#320](https://github.com/ComputationalRadiationPhysics/picongpu/pull/320/files#diff-1)
- removed double `#define __COHERENTINCOHERENTWEIGHTING__ 1` in some example radiationConfig.param
[#323](https://github.com/ComputationalRadiationPhysics/picongpu/pull/323/files)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,15 @@ namespace picongpu
/* Choose different window function in order to get better ringing reduction
* radWindowFunctionRectangle
* radWindowFunctionTriangle
* radWindowFunctionHamming
* radWindowFunctionTriplett
* radWindowFunctionGauss
*/
namespace radWindowFunctionRectangle { }
namespace radWindowFunctionTriangle { }
namespace radWindowFunctionHamming { }
namespace radWindowFunctionTriplett { }
namespace radWindowFunctionGauss { }

namespace radWindowFunction = radWindowFunctionTriangle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,15 @@ namespace picongpu
/* Choose different window function in order to get better ringing reduction
* radWindowFunctionRectangle
* radWindowFunctionTriangle
* radWindowFunctionHamming
* radWindowFunctionTriplett
* radWindowFunctionGauss
*/
namespace radWindowFunctionRectangle { }
namespace radWindowFunctionTriangle { }
namespace radWindowFunctionHamming { }
namespace radWindowFunctionTriplett { }
namespace radWindowFunctionGauss { }

namespace radWindowFunction = radWindowFunctionTriangle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,15 @@ namespace picongpu
/* Choose different window function in order to get better ringing reduction
* radWindowFunctionRectangle
* radWindowFunctionTriangle
* radWindowFunctionHamming
* radWindowFunctionTriplett
* radWindowFunctionGauss
*/
namespace radWindowFunctionRectangle { }
namespace radWindowFunctionTriangle { }
namespace radWindowFunctionHamming { }
namespace radWindowFunctionTriplett { }
namespace radWindowFunctionGauss { }

namespace radWindowFunction = radWindowFunctionTriangle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,15 @@ namespace picongpu
/* Choose different window function in order to get better ringing reduction
* radWindowFunctionRectangle
* radWindowFunctionTriangle
* radWindowFunctionHamming
* radWindowFunctionTriplett
* radWindowFunctionGauss
*/
namespace radWindowFunctionRectangle { }
namespace radWindowFunctionTriangle { }
namespace radWindowFunctionHamming { }
namespace radWindowFunctionTriplett { }
namespace radWindowFunctionGauss { }

namespace radWindowFunction = radWindowFunctionTriangle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,15 @@ namespace picongpu
/* Choose different window function in order to get better ringing reduction
* radWindowFunctionRectangle
* radWindowFunctionTriangle
* radWindowFunctionHamming
* radWindowFunctionTriplett
* radWindowFunctionGauss
*/
namespace radWindowFunctionRectangle { }
namespace radWindowFunctionTriangle { }
namespace radWindowFunctionHamming { }
namespace radWindowFunctionTriplett { }
namespace radWindowFunctionGauss { }

namespace radWindowFunction = radWindowFunctionTriangle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,15 @@ namespace picongpu
/* Choose different window function in order to get better ringing reduction
* radWindowFunctionRectangle
* radWindowFunctionTriangle
* radWindowFunctionHamming
* radWindowFunctionTriplett
* radWindowFunctionGauss
*/
namespace radWindowFunctionRectangle { }
namespace radWindowFunctionTriangle { }
namespace radWindowFunctionHamming { }
namespace radWindowFunctionTriplett { }
namespace radWindowFunctionGauss { }

namespace radWindowFunction = radWindowFunctionTriangle;

Expand Down
122 changes: 108 additions & 14 deletions src/picongpu/include/plugins/radiation/windowFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#pragma once

#include<cmath>

namespace picongpu
{

Expand All @@ -44,17 +46,17 @@ namespace picongpu
**/
HDINLINE float_X operator()(const float_X position_x, const float_X L_x) const
{
/* an optimized formula is implemented
*
* transform position to make box symetric:
* x_prime = position_x - 1/2 * L_x
*
* then: f(x_position) = f(x_prime)
* f(x_prime) = { 1.0 : -L_x/2 <= x_prime <= +L_x/2
* { 0.0 : in any other case
*/
const float_X x_prime = position_x - L_x*float_X(0.5);
return float_X(math::abs(x_prime) <= float_X(0.5) * L_x);
/* an optimized formula is implemented
*
* transform position to make box symetric:
* x_prime = position_x - 1/2 * L_x
*
* then: f(x_position) = f(x_prime)
* f(x_prime) = { 1.0 : -L_x/2 <= x_prime <= +L_x/2
* { 0.0 : in any other case
*/
const float_X x_prime = position_x - L_x*float_X(0.5);
return float_X(math::abs(x_prime) <= float_X(0.5) * L_x);
}
};
} /* namespace radWindowFunctionRectangle */
Expand All @@ -81,14 +83,106 @@ namespace picongpu
**/
HDINLINE float_X operator()(const float_X position_x, const float_X L_x) const
{
float_X x = position_x - float_X(0.5)*L_x;
return float_X(math::abs(x) <= float_X(0.5)*L_x * (float_X(1.0)-
float_X(2.0)/L_x * math::abs(x) ));
float_X x = position_x - float_X(0.5)*L_x;
return float_X(math::abs(x) <= float_X(0.5)*L_x)
* (float_X(1.0) - float_X(2.0)/L_x * math::abs(x) );
}
};
} /* namespace radWindowFunctionTriangle */



namespace radWindowFunctionHamming
{
struct radWindowFunction
{
/** 1D Window function according to the Hamming window:
*
* x = position_x - L_x/2
* a = parameter of the Hamming window (ideal: 0.08)
* f(x) = {a+(1-a)*cos^2(pi*x/L_x) : (-L_x/2 <= x <= +L_x/2 )
* {0.0 : in any other case
*
* @param position_x = 1D position
* @param L_x = length of the simulated area
* assuming that the simulation ranges
* from 0 to L_x in the choosen dimension
* @returns weighting factor to reduce ringing effects due to
* sharp spacial boundaries
**/
HDINLINE float_X operator()(const float_X position_x, const float_X L_x) const
{
const float_X x = position_x - L_x*float_X(0.5);
const float_X a = 0.08; /* ideal parameter: -43dB reduction */
const float_X cosinusValue = math::cos(M_PI*x/L_x);
return float_X(math::abs(x) <= float_X(0.5)*L_x)
* (a + (float_X(1.0)-a)*cosinusValue*cosinusValue);
}
};
} /* namespace radWindowFunctionHamming */



namespace radWindowFunctionTriplett
{
struct radWindowFunction
{
/** 1D Window function according to the Triplett window:
*
* x = position_x - L_x/2
* lambda = decay parameter of the Triplett window
* f(x) = {exp(-lambda*|x|)*cos^2(pi*x/L_x) : (-L_x/2 <= x <= +L_x/2 )
* {0.0 : in any other case
*
* @param position_x = 1D position
* @param L_x = length of the simulated area
* assuming that the simulation ranges
* from 0 to L_x in the choosen dimension
* @returns weighting factor to reduce ringing effects due to
* sharp spacial boundaries
**/
HDINLINE float_X operator()(const float_X position_x, const float_X L_x) const
{
const float_X x = position_x - L_x*float_X(0.5);
const float_X lambda = float_X(5.0)/L_x; /* larger is better, but too large means no data */
const float_X cosinusValue = math::cos(M_PI*x/L_x);
return float_X(math::abs(x) <= float_X(0.5)*L_x)
* (math::exp(float_X(-1.0)*lambda*math::abs(x))*cosinusValue*cosinusValue);
}
};
} /* namespace radWindowFunctionTriplett */



namespace radWindowFunctionGauss
{
struct radWindowFunction
{
/** 1D Window function according to the Gauss window:
*
* x = position_x - L_x/2
* sigma = standard deviation of the Gauss window
* f(x) = {exp(-0.5*x^2/sigma^2) : (-L_x/2 <= x <= +L_x/2 )
* {0.0 : in any other case
*
* @param position_x = 1D position
* @param L_x = length of the simulated area
* assuming that the simulation ranges
* from 0 to L_x in the choosen dimension
* @returns weighting factor to reduce ringing effects due to
* sharp spacial boundaries
**/
HDINLINE float_X operator()(const float_X position_x, const float_X L_x) const
{
const float_X x = position_x - L_x*float_X(0.5);
const float_X sigma = float_X(0.4)*L_x; /* smaller is better, but too small means no data */
const float_X relativePosition = x/sigma; /* optimization */
return float_X(math::abs(x) <= float_X(0.5)*L_x)
* (math::exp(float_X(-0.5)*relativePosition*relativePosition));
}
};
} /* namespace radWindowFunctionGauss */


} /* namespace picongpu */

Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@ namespace picongpu
/* Choose different window function in order to get better ringing reduction
* radWindowFunctionRectangle
* radWindowFunctionTriangle
* radWindowFunctionHamming
* radWindowFunctionTriplett
* radWindowFunctionGauss
*/
namespace radWindowFunctionRectangle { }
namespace radWindowFunctionTriangle { }
namespace radWindowFunctionHamming { }
namespace radWindowFunctionTriplett { }
namespace radWindowFunctionGauss { }

namespace radWindowFunction = radWindowFunctionTriangle;

Expand Down