BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DepthProbeComputationTerm Class Reference
Collaboration diagram for DepthProbeComputationTerm:

Public Member Functions

 DepthProbeComputationTerm (const ProcessedSample *p_sample)
 
 ~DepthProbeComputationTerm ()
 
void setProgressHandler (ProgressHandler *p_progress)
 
void compute (DepthProbeElement &elem) const
 

Private Attributes

const ProcessedSamplemp_sample
 
std::unique_ptr< DelayedProgressCountermP_progress_counter
 

Detailed Description

Definition at line 25 of file DepthProbeComputationTerm.h.

Constructor & Destructor Documentation

◆ DepthProbeComputationTerm()

DepthProbeComputationTerm::DepthProbeComputationTerm ( const ProcessedSample p_sample)

Definition at line 23 of file DepthProbeComputationTerm.cpp.

24  : mp_sample{p_sample}
25 {
26 }
const ProcessedSample * mp_sample

◆ ~DepthProbeComputationTerm()

DepthProbeComputationTerm::~DepthProbeComputationTerm ( )
default

Member Function Documentation

◆ setProgressHandler()

void DepthProbeComputationTerm::setProgressHandler ( ProgressHandler p_progress)

Definition at line 30 of file DepthProbeComputationTerm.cpp.

31 {
32  mP_progress_counter = std::make_unique<DelayedProgressCounter>(p_progress, 100);
33 }
std::unique_ptr< DelayedProgressCounter > mP_progress_counter

References mP_progress_counter.

Referenced by DepthProbeComputation::runProtected().

◆ compute()

void DepthProbeComputationTerm::compute ( DepthProbeElement elem) const

Definition at line 35 of file DepthProbeComputationTerm.cpp.

36 {
37  if (elem.isCalculated()) {
38  const IAxis& z_positions = *elem.getZPositions();
39  const size_t n_z = z_positions.size();
40  const size_t n_layers = mp_sample->numberOfSlices();
41  size_t start_z_ind = n_z;
42  std::valarray<double> intensities(0.0, n_z);
43 
44  double z_layer_bottom(0.0);
45  double z_layer_top(0.0);
46  for (size_t i_layer = 0; i_layer < n_layers && start_z_ind != 0; ++i_layer) {
47  z_layer_bottom = mp_sample->sliceBottomZ(i_layer);
48  z_layer_top = mp_sample->sliceTopZ(i_layer);
49 
50  // get R & T coefficients for current layer
51  const auto p_coefficients = mp_sample->fresnelMap()->getInCoefficients(elem, i_layer);
52  const complex_t R = p_coefficients->getScalarR();
53  const complex_t T = p_coefficients->getScalarT();
54  const complex_t kz_out = p_coefficients->getScalarKz();
55  const complex_t kz_in = -kz_out;
56 
57  // Compute intensity for z's of the layer
58  size_t ip1_z = start_z_ind;
59  for (; ip1_z > 0; --ip1_z) {
60  const size_t i_z = ip1_z - 1;
61  if (i_layer + 1 != n_layers && z_positions[i_z] <= z_layer_bottom)
62  break;
63  const double local_position = z_positions[i_z] - z_layer_top;
64  intensities[i_z] = std::norm(R * exp_I(kz_out * local_position)
65  + T * exp_I(kz_in * local_position));
66  }
67  start_z_ind = ip1_z;
68  }
69  elem.setIntensities(std::move(intensities));
70  }
71  if (mP_progress_counter) {
72  mP_progress_counter->stepProgress();
73  }
74 }
std::complex< double > complex_t
Definition: Complex.h:20
complex_t exp_I(complex_t z)
Returns exp(I*z), where I is the imaginary unit.
Definition: Complex.h:30
void setIntensities(T &&intensities)
const IAxis * getZPositions() const
bool isCalculated() const
Interface for one-dimensional axes.
Definition: IAxis.h:25
virtual size_t size() const =0
retrieve the number of bins
std::unique_ptr< const ILayerRTCoefficients > getInCoefficients(const T &sim_element, size_t layer_index) const
Retrieves the amplitude coefficients for an incoming wavevector.
Definition: IFresnelMap.h:41
double sliceTopZ(size_t i) const
double sliceBottomZ(size_t i) const
const IFresnelMap * fresnelMap() const
size_t numberOfSlices() const

References exp_I(), ProcessedSample::fresnelMap(), IFresnelMap::getInCoefficients(), DepthProbeElement::getZPositions(), DepthProbeElement::isCalculated(), mP_progress_counter, mp_sample, ProcessedSample::numberOfSlices(), DepthProbeElement::setIntensities(), IAxis::size(), ProcessedSample::sliceBottomZ(), and ProcessedSample::sliceTopZ().

Referenced by DepthProbeComputation::runProtected().

Here is the call graph for this function:

Member Data Documentation

◆ mp_sample

const ProcessedSample* DepthProbeComputationTerm::mp_sample
private

Definition at line 36 of file DepthProbeComputationTerm.h.

Referenced by compute().

◆ mP_progress_counter

std::unique_ptr<DelayedProgressCounter> DepthProbeComputationTerm::mP_progress_counter
private

Definition at line 37 of file DepthProbeComputationTerm.h.

Referenced by compute(), and setProgressHandler().


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