BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleLayoutComputation.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Core/Computation/ParticleLayoutComputation.cpp
6 //! @brief Implements class ParticleLayoutComputation.
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 
21 
22 namespace {
23 
24 std::unique_ptr<IInterferenceFunctionStrategy>
25 processedInterferenceFunction(const ProcessedLayout& layout, const SimulationOptions& sim_params,
26  bool polarized)
27 {
28  const IInterferenceFunction* iff = layout.interferenceFunction();
29  if (iff && layout.numberOfSlices() > 1 && !iff->supportsMultilayer())
30  throw std::runtime_error("LayoutStrategyBuilder::checkInterferenceFunction: "
31  "interference function does not support multiple layers");
32 
33  auto radial_para = dynamic_cast<const InterferenceFunctionRadialParaCrystal*>(iff);
34 
35  const std::vector<FormFactorCoherentSum>& weighted_formfactors = layout.formFactorList();
36 
37  if (radial_para && radial_para->kappa() > 0.0) {
38  double kappa = radial_para->kappa();
39  return std::make_unique<SSCApproximationStrategy>(weighted_formfactors, radial_para,
40  sim_params, polarized, kappa);
41  }
42  return std::make_unique<DecouplingApproximationStrategy>(weighted_formfactors, iff, sim_params,
43  polarized);
44 }
45 
46 } // namespace
47 
49  const SimulationOptions& options,
50  bool polarized)
51  : m_layout(layout)
52  , m_region_map(layout.regionMap())
53  , m_interference_function_strategy(processedInterferenceFunction(layout, options, polarized))
54 {
55 }
56 
58 
60 {
62 }
63 
65  std::map<size_t, std::vector<HomogeneousRegion>>& region_map) const
66 {
67  for (auto& entry : m_region_map) {
68  size_t i = entry.first;
69  auto& regions = entry.second;
70  region_map[i].insert(region_map[i].begin(), regions.begin(), regions.end());
71  }
72 }
Defines class DecouplingApproximationStrategy.
Defines class InterferenceFunctionRadialParaCrystal.
Defines class ParticleLayoutComputation.
Defines class ProcessedLayout.
Defines class SSCApproximationStrategy.
Defines class SimulationElement.
Abstract base class of interference functions.
virtual bool supportsMultilayer() const
Indicates if this interference function can be used with a multilayer (DWBA mode)
Interference function of radial paracrystal.
ParticleLayoutComputation(const ProcessedLayout &layout, const SimulationOptions &options, bool polarized)
const ProcessedLayout & m_layout
const std::map< size_t, std::vector< HomogeneousRegion > > m_region_map
std::unique_ptr< const IInterferenceFunctionStrategy > m_interference_function_strategy
void compute(SimulationElement &elem) const
void mergeRegionMap(std::map< size_t, std::vector< HomogeneousRegion >> &region_map) const
Merges its region map into the given one (notice non-const reference parameter)
Data structure that contains preprocessed data for a single layout.
size_t numberOfSlices() const
const std::vector< FormFactorCoherentSum > & formFactorList() const
const IInterferenceFunction * interferenceFunction() const
double surfaceDensity() const
Data stucture containing both input and output of a single detector cell.
void addIntensity(double intensity)
Collect the different options for simulation.
matrixFFVector_t polarized(const SimulationElement &sim_element, const std::vector< FormFactorCoherentSum > &ff_wrappers)