File: RoughnessMap.h

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 (72 lines) | stat: -rw-r--r-- 2,400 bytes parent folder | download | duplicates (2)
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
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Interface/RoughnessMap.h
//! @brief     Define RoughnessMap class.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2024
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_SAMPLE_MULTILAYER_ROUGHNESSMAP_H
#define BORNAGAIN_SAMPLE_MULTILAYER_ROUGHNESSMAP_H

#include "Base/Math/FourierTransform.h"
#include "Sample/Multilayer/Sample.h"
#include <random>

#ifdef BORNAGAIN_PYTHON
#include "Base/Py/ArrayWrapper.h" // Arrayf64Wrapper
#endif                            // BORNAGAIN_PYTHON

//! Generation of random rough surface with given both spectrum and height statistics.
//!
//! Algorithm by Pérez-Ràfols & Almqvist, Tribology International 131, 591-604 (2019)
//! https://doi.org/10.1016/j.triboint.2018.11.020

class RoughnessMap {
public:
    RoughnessMap(size_t x_points, size_t y_points, double Lx, double Ly, const Sample& sample,
                 int i_layer, int seed = -1);
    RoughnessMap() = delete;

    double2d_t generateMap();

#ifdef BORNAGAIN_PYTHON
    //! Returns data to construct a Python Numpy array.
    Arrayf64Wrapper generate();
#endif // BORNAGAIN_PYTHON

private:
    // create random uncorrelated map with given height statistics
    double2d_t mapFromHeights() const;

    // create random map with gives autocorrelation spectrum
    double2d_t mapFromSpectrum() const;

    double2d_t applySpectrumToHeights(const double2d_t& h_map, const double2d_t& s_map) const;
    double2d_t applyHeightsToSpectrum(const double2d_t& h_map, const double2d_t& s_map) const;

    // create random map with both spectrum and height distribution
    void createMap();

    int m_x_points = 0;
    int m_y_points = 0;
    double m_lx; //!< sample x size in nm
    double m_ly; //!< sample y size in nm

    const Sample& m_sample;

    int m_i_layer;
    double2d_t m_rough_map;

    mutable FourierTransform m_ft;
    std::random_device m_rd;
    mutable std::mt19937 m_gen;
};

#endif // BORNAGAIN_SAMPLE_MULTILAYER_ROUGHNESSMAP_H