File: DiffuseElement.cpp

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (94 lines) | stat: -rw-r--r-- 2,881 bytes parent folder | download
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Resample/Element/DiffuseElement.cpp
//! @brief     Implements class DiffuseElement.
//!
//! @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 "Resample/Element/DiffuseElement.h"
#include "Base/Axis/Pixel.h"
#include "Base/Vector/GisasDirection.h"
#include "Base/Vector/WavevectorInfo.h"
#include "Resample/Flux/IFlux.h"
#include <numbers>

using std::numbers::pi;

DiffuseElement::DiffuseElement(double wavelength, double alpha_i, double phi_i,
                               const Pixel* const pixel, const SpinMatrix& polarizer,
                               const SpinMatrix& analyzer, bool isSpecular_,
                               const Fluxes* const fluxes_in, const Fluxes* const fluxes_out)
    : IElement({polarizer, analyzer})
    , m_wavelength(wavelength)
    , m_alpha_i(alpha_i)
    , m_phi_i(phi_i)
    , m_k_i(vecOfLambdaAlphaPhi(m_wavelength, -m_alpha_i, -m_phi_i))
    , m_mean_kf(pixel->getK(0.5, 0.5, m_wavelength))
    , m_pixel(pixel)
    , m_is_specular(isSpecular_)
    , m_fluxes_in(fluxes_in)
    , m_fluxes_out(fluxes_out)
{
}

void DiffuseElement::setFluxes(const Fluxes* fluxes_in, const Fluxes* fluxes_out)
{
    m_fluxes_in = fluxes_in;
    m_fluxes_out = fluxes_out;
}

const IFlux* DiffuseElement::fluxIn(size_t i_layer) const
{
    return (*m_fluxes_in)[i_layer];
}

const IFlux* DiffuseElement::fluxOut(size_t i_layer) const
{
    return (*m_fluxes_out)[i_layer];
}

DiffuseElement DiffuseElement::pointElement(double x, double y) const
{
    return {m_wavelength,  m_alpha_i,
            m_phi_i,       m_pixel->createZeroSizePixel(x, y), // TODO simplify
            polarizer(),   analyzer(),
            m_is_specular, m_fluxes_in,
            m_fluxes_out};
} //! Returns outgoing wavevector Kf for in-pixel coordinates x,y.
//! In-pixel coordinates take values from 0 to 1.
R3 DiffuseElement::getKf(double x, double y) const
{
    return m_pixel->getK(x, y, m_wavelength);
}

R3 DiffuseElement::meanQ() const
{
    return getKi() - meanKf();
}

double DiffuseElement::alpha(double x, double y) const
{
    return (pi / 2) - R3Util::theta(getKf(x, y));
}

WavevectorInfo DiffuseElement::wavevectorInfo() const
{
    return {getKi(), meanKf(), wavelength()};
}

double DiffuseElement::integrationFactor(double x, double y) const
{
    return m_pixel->integrationFactor(x, y);
}

double DiffuseElement::solidAngle() const
{
    return m_pixel->solidAngle();
}