BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayerFuncs.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Computation/MultiLayerFuncs.cpp
6 //! @brief Global functions related to MultiLayers.
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 
19 
20 std::vector<complex_t> MaterialProfile(const MultiLayer& multilayer, int n_points, double z_min,
21  double z_max)
22 {
23  SimulationOptions options;
24  options.setUseAvgMaterials(true);
25  ProcessedSample sample(multilayer, options);
26  ProfileHelper helper(sample);
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> DefaultMaterialProfileLimits(const MultiLayer& multilayer)
32 {
33  SimulationOptions options;
34  options.setUseAvgMaterials(true);
35  ProcessedSample sample(multilayer, options);
36  ProfileHelper helper(sample);
37  return helper.defaultLimits();
38 }
39 
40 std::vector<double> GenerateZValues(int n_points, double z_min, double z_max)
41 {
42  std::vector<double> result;
43  if (n_points < 1)
44  return result;
45  double step = n_points > 1 ? (z_max - z_min) / (n_points - 1) : 0.0;
46  for (int i = 0; i < n_points; ++i) {
47  result.push_back(z_min + i * step);
48  }
49  return result;
50 }
std::pair< double, double > DefaultMaterialProfileLimits(const MultiLayer &multilayer)
Get default z limits for generating a material profile.
std::vector< double > GenerateZValues(int n_points, double z_min, double z_max)
Generate z values (equidistant) for use in MaterialProfile.
Global functions related to MultiLayers.
Defines class ProcessedSample.
Defines class ProfileHelper.
Defines class SimulationOptions.
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:42
Data structure that contains all the necessary data for scattering calculations.
Object that can generate the material profile of a sample as a function of depth.
Definition: ProfileHelper.h:32
std::pair< double, double > defaultLimits() const
std::vector< complex_t > calculateProfile(const std::vector< double > &z_values) const
Collect the different options for simulation.
void setUseAvgMaterials(bool use_avg_materials)
std::vector< complex_t > MaterialProfile(const MultiLayer &multilayer, int n_points, double z_min, double z_max)