BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
materialprofile.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/quicksimeditor/materialprofile.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
18 #include <Sample/Slice/Slice.h>
19 
20 namespace gui2 {
21 
22 std::vector<complex_t> MaterialProfile::CalculateProfile(const multislice_t& multilayer,
23  int n_points, double z_min, double z_max)
24 {
25  auto baSlices = Utils::createBornAgainSlices(multilayer);
26  ProfileHelper helper(baSlices);
27  std::vector<double> z_values = GenerateZValues(n_points, z_min, z_max);
28  return helper.calculateProfile(z_values);
29 }
30 
31 std::pair<double, double>
33 {
34  auto baSlices = Utils::createBornAgainSlices(multilayer);
35  ProfileHelper helper(baSlices);
36  return helper.defaultLimits();
37 }
38 
39 std::vector<double> MaterialProfile::GenerateZValues(int n_points, double z_min, double z_max)
40 {
41  std::vector<double> result;
42  if (n_points < 1)
43  return result;
44  double step = n_points > 1 ? (z_max - z_min) / (n_points - 1) : 0.0;
45  for (int i = 0; i < n_points; ++i) {
46  result.push_back(z_min + i * step);
47  }
48  return result;
49 }
50 
51 } // namespace gui2
Defines class Slice.
std::pair< double, double > defaultLimits() const
std::vector< complex_t > calculateProfile(const std::vector< double > &z_values) const
Defines class CLASS?
DAREFLCORE_EXPORT std::pair< double, double > DefaultMaterialProfileLimits(const multislice_t &multilayer)
Get default z limits for generating a material profile.
DAREFLCORE_EXPORT std::vector< complex_t > CalculateProfile(const multislice_t &multilayer, int n_points, double z_min, double z_max)
Calculate average material profile for given multilayer.
DAREFLCORE_EXPORT std::vector< double > GenerateZValues(int n_points, double z_min, double z_max)
Generate z values (equidistant) for use in MaterialProfile.
DAREFLCORE_EXPORT std::vector< Slice > createBornAgainSlices(const multislice_t &multislice)
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
std::vector< SliceData > multislice_t
Defines class CLASS?
Defines class CLASS?