1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Device/Beam/FootprintGauss.cpp
//! @brief Implements class FootprintGauss.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Device/Beam/FootprintGauss.h"
#include "Base/Math/Functions.h"
#include "Base/Util/Assert.h"
#include <numbers>
using std::numbers::pi;
FootprintGauss::FootprintGauss(const std::vector<double> P)
: IFootprint(P)
{
validateOrThrow();
}
FootprintGauss::FootprintGauss(double width_ratio)
: FootprintGauss(std::vector<double>{width_ratio})
{
}
FootprintGauss* FootprintGauss::clone() const
{
return new FootprintGauss(m_width_ratio);
}
double FootprintGauss::calculate(double alpha) const
{
ASSERT(m_validated);
if (alpha < 0.0 || alpha > (pi / 2))
return 0.0;
if (widthRatio() == 0.0)
return 1.0;
const double arg = std::sin(alpha) * sqrt(0.5) / widthRatio();
return Math::erf(arg);
}
|