BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
anonymous_namespace{SlicedFormFactorList.cpp} Namespace Reference

Functions

std::pair< size_t, size_t > SliceIndexSpan (const IParticle &particle, const std::vector< Slice > &slices, double z_ref)
 
size_t TopZToSliceIndex (double z, const std::vector< Slice > &slices)
 
size_t BottomZToSliceIndex (double z, const std::vector< Slice > &slices)
 
double SliceTopZ (size_t i, const std::vector< Slice > &slices)
 
ZLimits SlicesZLimits (const std::vector< Slice > &slices, size_t slice_index)
 
void ScaleRegions (std::vector< HomogeneousRegion > &regions, double factor)
 

Function Documentation

◆ SliceIndexSpan()

std::pair< size_t, size_t > anonymous_namespace{SlicedFormFactorList.cpp}::SliceIndexSpan ( const IParticle particle,
const std::vector< Slice > &  slices,
double  z_ref 
)

Definition at line 87 of file SlicedFormFactorList.cpp.

89 {
90  auto bottomTopZ = particle.bottomTopZ();
91  double zbottom = bottomTopZ.m_bottom;
92  double ztop = bottomTopZ.m_top;
93  double eps = (ztop - zbottom) * 1e-6; // allow for relatively small crossing due to numerical
94  // approximations (like rotation over 180 degrees)
95  double zmax = ztop + z_ref - eps;
96  double zmin = zbottom + z_ref + eps;
97  size_t top_index = TopZToSliceIndex(zmax, slices);
98  size_t bottom_index = BottomZToSliceIndex(zmin, slices);
99  if (top_index > bottom_index) // happens for zero size particles
100  top_index = bottom_index;
101  return {top_index, bottom_index};
102 }
virtual ParticleLimits bottomTopZ() const
Top and bottom z-coordinate.
Definition: IParticle.cpp:94
size_t TopZToSliceIndex(double z, const std::vector< Slice > &slices)
size_t BottomZToSliceIndex(double z, const std::vector< Slice > &slices)
double m_bottom
Definition: ZLimits.h:22

References IParticle::bottomTopZ(), BottomZToSliceIndex(), anonymous_namespace{PolyhedralComponents.cpp}::eps, ParticleLimits::m_bottom, and TopZToSliceIndex().

Referenced by SlicedFormFactorList::addParticle().

Here is the call graph for this function:

◆ TopZToSliceIndex()

size_t anonymous_namespace{SlicedFormFactorList.cpp}::TopZToSliceIndex ( double  z,
const std::vector< Slice > &  slices 
)

Definition at line 104 of file SlicedFormFactorList.cpp.

105 {
106  auto n_layers = slices.size();
107  if (n_layers < 2 || z > 0.0)
108  return 0;
109  double z_layer_bottom = 0.0;
110  size_t i_slice = 0;
111  while (i_slice + 1 < n_layers) {
112  ++i_slice;
113  z_layer_bottom -= slices[i_slice].thickness();
114  if (z > z_layer_bottom)
115  break;
116  }
117  return i_slice;
118 }

Referenced by SliceIndexSpan().

◆ BottomZToSliceIndex()

size_t anonymous_namespace{SlicedFormFactorList.cpp}::BottomZToSliceIndex ( double  z,
const std::vector< Slice > &  slices 
)

Definition at line 120 of file SlicedFormFactorList.cpp.

121 {
122  auto n_layers = slices.size();
123  if (n_layers < 2 || z >= 0.0)
124  return 0;
125  double z_layer_bottom = 0.0;
126  size_t i_slice = 0;
127  while (i_slice + 1 < n_layers) {
128  ++i_slice;
129  z_layer_bottom -= slices[i_slice].thickness();
130  if (z >= z_layer_bottom)
131  break;
132  }
133  return i_slice;
134 }

Referenced by SliceIndexSpan().

◆ SliceTopZ()

double anonymous_namespace{SlicedFormFactorList.cpp}::SliceTopZ ( size_t  i,
const std::vector< Slice > &  slices 
)

Definition at line 136 of file SlicedFormFactorList.cpp.

137 {
138  if (i == 0)
139  return 0.0;
140  double top_z = 0.0;
141  for (size_t j = 1; j < i; ++j)
142  top_z -= slices[j].thickness();
143  return top_z;
144 }

Referenced by SlicedFormFactorList::addParticle().

◆ SlicesZLimits()

ZLimits anonymous_namespace{SlicedFormFactorList.cpp}::SlicesZLimits ( const std::vector< Slice > &  slices,
size_t  slice_index 
)

Definition at line 146 of file SlicedFormFactorList.cpp.

147 {
148  size_t N = slices.size();
149  if (N < 2)
150  return ZLimits{};
151  if (slice_index == 0)
152  return ZLimits({false, 0}, {true, 0});
153  if (slice_index == N - 1)
154  return ZLimits({true, 0}, {false, 0});
155  double thickness = slices[slice_index].thickness();
156  return ZLimits(-thickness, 0.0);
157 }
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:41

Referenced by SlicedFormFactorList::addParticle().

◆ ScaleRegions()

void anonymous_namespace{SlicedFormFactorList.cpp}::ScaleRegions ( std::vector< HomogeneousRegion > &  regions,
double  factor 
)

Definition at line 159 of file SlicedFormFactorList.cpp.

160 {
161  for (auto& region : regions)
162  region.m_volume *= factor;
163 }

Referenced by SlicedFormFactorList::addParticle().