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

Public Member Functions

 ProfileHelper (const std::vector< Slice > &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

Definition at line 26 of file profilehelper.h.

Constructor & Destructor Documentation

◆ ProfileHelper()

ProfileHelper::ProfileHelper ( const std::vector< Slice > &  sample)

Definition at line 25 of file profilehelper.cpp.

26 {
27  auto N = sample.size();
28  m_materialdata.reserve(N);
29  if (N > 1) {
30  m_zlimits.reserve(N - 1);
31  m_sigmas.reserve(N - 1);
32  }
33  double bottom_z{0};
34  for (size_t i = 0; i < N; ++i) {
35  m_materialdata.push_back(sample[i].material().materialData());
36  bottom_z -= sample[i].thickness();
37  if (i + 1 < N) {
38  m_zlimits.push_back(bottom_z);
39  auto sigma = 0.;
40  if (auto roughness = sample[i + 1].topRoughness())
41  sigma = roughness->getSigma();
42 
43  m_sigmas.push_back(sigma);
44  }
45  }
46 }
std::vector< double > m_sigmas
Definition: profilehelper.h:37
std::vector< double > m_zlimits
Definition: profilehelper.h:36
std::vector< complex_t > m_materialdata
Definition: profilehelper.h:35

References m_materialdata, m_sigmas, and m_zlimits.

◆ ~ProfileHelper()

ProfileHelper::~ProfileHelper ( )
default

Member Function Documentation

◆ calculateProfile()

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

Definition at line 52 of file profilehelper.cpp.

53 {
54  complex_t top_value = m_materialdata.size() ? m_materialdata[0] : 0.0;
55  std::vector<complex_t> result(z_values.size(), top_value);
56  for (size_t i = 0; i < m_zlimits.size(); ++i) {
57  auto sld_diff = m_materialdata[i + 1] - m_materialdata[i];
58  for (size_t j = 0; j < z_values.size(); ++j) {
59  auto arg = (z_values[j] - m_zlimits[i]);
60  auto t = Transition(arg, m_sigmas[i]);
61  result[j] += sld_diff * t;
62  }
63  }
64  return result;
65 }
std::complex< double > complex_t
Definition: Complex.h:20

Referenced by gui2::MaterialProfile::CalculateProfile().

◆ defaultLimits()

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

Definition at line 67 of file profilehelper.cpp.

68 {
69  if (m_zlimits.size() < 1)
70  return {0.0, 0.0};
71  double interface_span = m_zlimits.front() - m_zlimits.back();
72  double default_margin = interface_span > 0.0 ? interface_span / 20.0 : 10.0;
73  double top_margin = m_sigmas.front() > 0.0 ? 5.0 * m_sigmas.front() : default_margin;
74  double bottom_margin = m_sigmas.back() > 0.0 ? 5.0 * m_sigmas.back() : default_margin;
75  double z_min = m_zlimits.back() - bottom_margin;
76  double z_max = m_zlimits.front() + top_margin;
77  return {z_min, z_max};
78 }

Referenced by gui2::MaterialProfile::DefaultMaterialProfileLimits().

Member Data Documentation

◆ m_materialdata

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

Definition at line 35 of file profilehelper.h.

Referenced by ProfileHelper().

◆ m_sigmas

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

Definition at line 37 of file profilehelper.h.

Referenced by ProfileHelper().

◆ m_zlimits

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

Definition at line 36 of file profilehelper.h.

Referenced by ProfileHelper().


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