BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
GISASSpecularContribution.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sim/Contrib/GISASSpecularContribution.cpp
6 //! @brief Implements class GISASSpecularContribution.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Util/Assert.h"
19 
21 {
22  if (!ele.isSpecular())
23  return;
24 
25  const auto* flux = dynamic_cast<const ScalarFlux*>(ele.fluxIn(0));
26  ASSERT(flux);
27  complex_t R = flux->getScalarR();
28 
29  double sin_alpha_i = std::abs(std::sin(ele.alphaI()));
30  if (sin_alpha_i == 0.0) {
31  ele.setIntensity(0);
32  return;
33  }
34  const double solid_angle = ele.solidAngle();
35  if (solid_angle <= 0.0)
36  return;
37  const double intensity = std::norm(R) * sin_alpha_i / solid_angle;
38  ele.setIntensity(intensity);
39 }
Defines the macro ASSERT.
#define ASSERT(condition)
Definition: Assert.h:45
Defines class DiffuseElement.
Defines class GISASSpecularContribution.
Defines class ScalarFlux.
Data stucture containing both input and output of a single detector cell.
double alphaI() const
double solidAngle() const
const IFlux * fluxIn(size_t i_layer) const
bool isSpecular() const
Tells if simulation element corresponds to a specular peak.
void setIntensity(double intensity)
void compute(DiffuseElement &ele) const
Specular reflection and transmission coefficients in a layer in case of scalar interactions between t...
Definition: ScalarFlux.h:29
constexpr Double_t R()
Definition: TMath.h:213