BornAgain  1.19.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 reflection and scattering
4 //
5 //! @file Sample/Processed/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<double> swigAPI::generateZValues(int n_points, double z_min, double z_max)
21 {
22  std::vector<double> result;
23  if (n_points < 1)
24  return result;
25  double step = n_points > 1 ? (z_max - z_min) / (n_points - 1) : 0.0;
26  for (int i = 0; i < n_points; ++i) {
27  result.push_back(z_min + i * step);
28  }
29  return result;
30 }
31 
32 std::vector<complex_t> swigAPI::materialProfileSLD(const MultiLayer& multilayer, int n_points,
33  double z_min, double z_max)
34 {
35  SimulationOptions options;
36  options.setUseAvgMaterials(true);
37  ProcessedSample sample(multilayer, options);
38  ProfileHelper helper(sample);
39  std::vector<double> z_values = generateZValues(n_points, z_min, z_max);
40  return helper.calculateProfile(z_values);
41 }
42 
43 std::pair<double, double> swigAPI::defaultMaterialProfileLimits(const MultiLayer& multilayer)
44 {
45  SimulationOptions options;
46  options.setUseAvgMaterials(true);
47  ProcessedSample sample(multilayer, options);
48  ProfileHelper helper(sample);
49  return helper.defaultLimits();
50 }
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:41
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:36
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 > materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)
Calculate average material profile for given multilayer.
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)