BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Compute::SpecularScalar Namespace Reference

Description

Methods to compute scalar propagation directions and fluxes as function of slice.

Functions

Fluxes fluxes (const SliceStack &slices, const R3 &k)
 Computes refraction angles and transmission/reflection coefficients for given coherent wave propagation in a sample. More...
 
complex_t topLayerR (const SliceStack &slices, const std::vector< complex_t > &kz)
 Computes the Fresnel R coefficient for the top layer only. Introduced in order to speed up pure reflectivity computations. More...
 

Function Documentation

◆ fluxes()

Fluxes Compute::SpecularScalar::fluxes ( const SliceStack slices,
const R3 &  k 
)

Computes refraction angles and transmission/reflection coefficients for given coherent wave propagation in a sample.

Definition at line 122 of file ComputeFluxScalar.cpp.

123 {
124  const bool top_exit = k.z() <= 0; // true if source or detector pixel are at z>=0
125  std::vector<complex_t> kz = Compute::Kz::computeReducedKz(slices, k);
126  ASSERT(slices.size() == kz.size());
127 
128  const std::vector<Spinor> TR = computeTR(slices, kz, slices.roughnessModel(), top_exit);
129 
130  Fluxes result;
131  for (size_t i = 0; i < kz.size(); ++i)
132  result.emplace_back(std::make_unique<const ScalarFlux>(kz[i], TR[i]));
133  return result;
134 }
#define ASSERT(condition)
Definition: Assert.h:45
std::vector< std::unique_ptr< const IFlux > > Fluxes
RoughnessModel roughnessModel() const
Definition: SliceStack.h:57
std::vector< complex_t > computeReducedKz(const SliceStack &slices, R3 k)
Computes kz values from known k vector and slices with the following assumptions:

References ASSERT, Compute::Kz::computeReducedKz(), and SliceStack::roughnessModel().

Referenced by reSample::fluxesIn(), and reSample::fluxesOut().

Here is the call graph for this function:

◆ topLayerR()

complex_t Compute::SpecularScalar::topLayerR ( const SliceStack slices,
const std::vector< complex_t > &  kz 
)

Computes the Fresnel R coefficient for the top layer only. Introduced in order to speed up pure reflectivity computations.

Definition at line 136 of file ComputeFluxScalar.cpp.

138 {
139  const RoughnessModel& r_model = slices.roughnessModel();
140 
141  ASSERT(slices.size() == kz.size());
142  const size_t N = slices.size();
143  if (N == 1)
144  return 0.; // only one layer present, there's nothing left to calculate
145  if (kz[0] == 0.)
146  return -1.;
147 
148  complex_t R_i1 = 0.;
149 
150  for (size_t i = N - 1; i > 0; i--) {
151  double sigma = 0.0;
152  if (const auto* const roughness = slices.bottomRoughness(i - 1))
153  sigma = roughness->sigma();
154 
155  const auto [mp, mm] = transition(kz[i - 1], kz[i], sigma, r_model);
156 
157  const complex_t delta = exp_I(kz[i - 1] * slices[i - 1].thicknessOr0());
158 
159  R_i1 = pow(delta, 2) * (mm + mp * R_i1) / (mp + mm * R_i1);
160  }
161 
162  return R_i1;
163 }
const LayerRoughness * bottomRoughness(size_t i_slice) const
Definition: SliceStack.cpp:75
#define N
Definition: mixmax.h:31

References ASSERT, SliceStack::bottomRoughness(), N, and SliceStack::roughnessModel().

Referenced by SpecularComputation::runProtected().

Here is the call graph for this function: