BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
MultiLayerFuncs.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Resample/Swig/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  return result;
29 }
30 
31 std::vector<complex_t> swigAPI::materialProfileSLD(const MultiLayer& sample, int n_points,
32  double z_min, double z_max)
33 {
34  SimulationOptions options;
35  options.setUseAvgMaterials(true);
36  const reSample resample = reSample::make(sample, options);
37  ProfileHelper helper(resample.averageSlices());
38  std::vector<double> z_values = generateZValues(n_points, z_min, z_max);
39  return helper.calculateProfile(z_values);
40 }
41 
42 std::pair<double, double> swigAPI::defaultMaterialProfileLimits(const MultiLayer& sample)
43 {
44  SimulationOptions options;
45  options.setUseAvgMaterials(true);
46  const reSample resample = reSample::make(sample, options);
47  ProfileHelper helper(resample.averageSlices());
48  return helper.defaultLimits();
49 }
Global functions related to MultiLayers.
Defines class ProfileHelper.
Defines class reSample.
Defines class SimulationOptions.
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:43
Object that can generate the material profile of a sample as a function of depth.
Definition: ProfileHelper.h:34
std::pair< double, double > defaultLimits() const
std::vector< complex_t > calculateProfile(const std::vector< double > &z_values) const
Collect the different options for simulation.SimulationOptions.
void setUseAvgMaterials(bool use_avg_materials)
Data structure that contains all the necessary data for scattering calculations.
Definition: ReSample.h:41
static reSample make(const MultiLayer &sample, const SimulationOptions &options, bool forcePolarized=false)
Factory method that wraps the private constructor.
Definition: ReSample.cpp:309
const SliceStack & averageSlices() const
Definition: ReSample.cpp:341
std::pair< double, double > defaultMaterialProfileLimits(const MultiLayer &sample)
Get default z limits for generating a material profile.
std::vector< complex_t > materialProfileSLD(const MultiLayer &sample, int n_points, double z_min, double z_max)
Calculate average material profile for given sample.
std::vector< double > generateZValues(int n_points, double z_min, double z_max)