BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ProfileHelper Class Reference

Object that can generate the material profile of a sample as a function of depth. More...

Public Member Functions

 ProfileHelper (const ProcessedSample &sample)
 
 ~ProfileHelper ()
 
std::vector< complex_tcalculateProfile (const std::vector< double > &z_values) const
 
std::pair< double, double > defaultLimits () const
 

Private Attributes

std::vector< complex_tm_materialdata
 
std::vector< double > m_sigmas
 
std::vector< double > m_zlimits
 

Detailed Description

Object that can generate the material profile of a sample as a function of depth.

The generated profile contains the complex SLD for SLD materials and the parameters delta and beta for refractive index materials

Definition at line 36 of file ProfileHelper.h.

Constructor & Destructor Documentation

◆ ProfileHelper()

ProfileHelper::ProfileHelper ( const ProcessedSample sample)

Definition at line 33 of file ProfileHelper.cpp.

34 {
35  auto N = sample.numberOfSlices();
36  m_materialdata.reserve(N);
37  if (N > 1) {
38  m_zlimits.reserve(N - 1);
39  m_sigmas.reserve(N - 1);
40  }
41  auto& slices = sample.averageSlices();
42  for (size_t i = 0; i < N; ++i) {
43  m_materialdata.push_back(slices[i].material().materialData());
44  if (i + 1 < N) {
45  m_zlimits.push_back(sample.sliceBottomZ(i));
46  if (const auto* roughness = sample.bottomRoughness(i)) {
47  m_sigmas.push_back(roughness->getSigma());
48  } else {
49  m_sigmas.push_back(0.0);
50  }
51  }
52  }
53 }
double sliceBottomZ(size_t i) const
size_t numberOfSlices() const
const std::vector< Slice > & averageSlices() const
const LayerRoughness * bottomRoughness(size_t i) const
std::vector< complex_t > m_materialdata
Definition: ProfileHelper.h:45
std::vector< double > m_sigmas
Definition: ProfileHelper.h:47
std::vector< double > m_zlimits
Definition: ProfileHelper.h:46

References ProcessedSample::averageSlices(), ProcessedSample::bottomRoughness(), m_materialdata, m_sigmas, m_zlimits, ProcessedSample::numberOfSlices(), and ProcessedSample::sliceBottomZ().

Here is the call graph for this function:

◆ ~ProfileHelper()

ProfileHelper::~ProfileHelper ( )
default

Member Function Documentation

◆ calculateProfile()

std::vector< complex_t > ProfileHelper::calculateProfile ( const std::vector< double > &  z_values) const

Definition at line 60 of file ProfileHelper.cpp.

61 {
62  complex_t top_value = m_materialdata.size() ? m_materialdata[0] : 0.0;
63  std::vector<complex_t> result(z_values.size(), top_value);
64  for (size_t i = 0; i < m_zlimits.size(); ++i) {
65  auto sld_diff = m_materialdata[i + 1] - m_materialdata[i];
66  for (size_t j = 0; j < z_values.size(); ++j) {
67  auto arg = (z_values[j] - m_zlimits[i]);
68  auto t = Transition(arg, m_sigmas[i]);
69  result[j] += sld_diff * t;
70  }
71  }
72  return result;
73 }
std::complex< double > complex_t
Definition: Complex.h:20

References m_materialdata, m_sigmas, and m_zlimits.

Referenced by swigAPI::materialProfileSLD().

◆ defaultLimits()

std::pair< double, double > ProfileHelper::defaultLimits ( ) const

Definition at line 75 of file ProfileHelper.cpp.

76 {
77  if (m_zlimits.size() < 1)
78  return {0.0, 0.0};
79  double interface_span = m_zlimits.front() - m_zlimits.back();
80  double default_margin = interface_span > 0.0 ? interface_span / 20.0 : 10.0;
81  double top_margin = m_sigmas.front() > 0.0 ? 5.0 * m_sigmas.front() : default_margin;
82  double bottom_margin = m_sigmas.back() > 0.0 ? 5.0 * m_sigmas.back() : default_margin;
83  double z_min = m_zlimits.back() - bottom_margin;
84  double z_max = m_zlimits.front() + top_margin;
85  return {z_min, z_max};
86 }

References m_sigmas, and m_zlimits.

Referenced by swigAPI::defaultMaterialProfileLimits().

Member Data Documentation

◆ m_materialdata

std::vector<complex_t> ProfileHelper::m_materialdata
private

Definition at line 45 of file ProfileHelper.h.

Referenced by ProfileHelper(), and calculateProfile().

◆ m_sigmas

std::vector<double> ProfileHelper::m_sigmas
private

Definition at line 47 of file ProfileHelper.h.

Referenced by ProfileHelper(), calculateProfile(), and defaultLimits().

◆ m_zlimits

std::vector<double> ProfileHelper::m_zlimits
private

Definition at line 46 of file ProfileHelper.h.

Referenced by ProfileHelper(), calculateProfile(), and defaultLimits().


The documentation for this class was generated from the following files: