File: Slice.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 (84 lines) | stat: -rw-r--r-- 2,370 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
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Resample/Slice/Slice.cpp
//! @brief     Implements class Slice.
//!
//! @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/Slice/Slice.h"
#include "Base/Spin/SpinMatrix.h"
#include "Resample/Slice/SliceStack.h"
#include "Sample/Interface/Roughness.h"
#include "Sample/Material/MaterialUtil.h"
#include <numbers>
#include <utility>

using std::numbers::pi;

Slice::Slice(const ZLimits& zRange, const Material& material, const R3& B_field,
             const Roughness* const roughness, double rms)
    : m_z_range(zRange)
    , m_material(material)
    , m_B_field(B_field)
    , m_top_roughness(roughness)
    , m_top_rms(rms)
{
}

Slice::~Slice() = default;

double Slice::low() const
{
    return m_z_range.low();
}

double Slice::hig() const
{
    return m_z_range.hig();
}

double Slice::higOr0() const
{
    return m_z_range.higOr0();
}

double Slice::thicknessOr0() const
{
    return m_z_range.thicknessOr0();
}

complex_t Slice::scalarReducedPotential(R3 k, double n_ref) const
{
    complex_t n = m_material.refractiveIndex((2 * pi) / k.mag());
    return MaterialUtil::ScalarReducedPotential(n, k, n_ref);
}

// ISSUE #394 currently unused
SpinMatrix Slice::polarizedReducedPotential(R3 k, double n_ref) const
{
    complex_t n = m_material.refractiveIndex((2 * pi) / k.mag());
    return MaterialUtil::PolarizedReducedPotential(n, m_B_field, k, n_ref);
}

void Slice::initBField(R3 h_field, double h_z)
{
    // Temporary forbid z-magnetization in all layers (see issue #654)
    if (m_material.magnetization().z() != 0)
        throw std::runtime_error("Processing z-magnetization of layers is not implemented.");

    static constexpr double Magnetic_Permeability = 4e-7 * pi;
    m_B_field = Magnetic_Permeability * (h_field + m_material.magnetization());
    m_B_field.setZ(Magnetic_Permeability * h_z);
}

void Slice::invertBField()
{
    m_B_field = -m_B_field;
}