BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RadialParacrystalPositionBuilder Class Reference

Description

Definition at line 114 of file IPositionBuilder.h.

Inheritance diagram for RadialParacrystalPositionBuilder:
[legend]
Collaboration diagram for RadialParacrystalPositionBuilder:
[legend]

Public Member Functions

 RadialParacrystalPositionBuilder (const InterferenceRadialParaCrystal *p_iff)
 
 ~RadialParacrystalPositionBuilder () override
 
std::vector< std::vector< double > > generatePositions (double layer_size, double density=0.0) const
 

Private Member Functions

std::vector< std::vector< double > > generatePositionsImpl (double layer_size, double density=0.0) const override
 
double positionVariance () const override
 

Private Attributes

std::unique_ptr< InterferenceRadialParaCrystal > m_iff
 

Constructor & Destructor Documentation

◆ RadialParacrystalPositionBuilder()

RadialParacrystalPositionBuilder::RadialParacrystalPositionBuilder ( const InterferenceRadialParaCrystal *  p_iff)

Definition at line 213 of file IPositionBuilder.cpp.

215  : m_iff(p_iff->clone())
216 {
217 }
std::unique_ptr< InterferenceRadialParaCrystal > m_iff

◆ ~RadialParacrystalPositionBuilder()

RadialParacrystalPositionBuilder::~RadialParacrystalPositionBuilder ( )
overridedefault

Member Function Documentation

◆ generatePositions()

std::vector< std::vector< double > > IPositionBuilder::generatePositions ( double  layer_size,
double  density = 0.0 
) const
inherited

Definition at line 29 of file IPositionBuilder.cpp.

31 {
32  std::vector<std::vector<double>> positions = generatePositionsImpl(layer_size, density);
33  double pos_var = positionVariance();
34  if (pos_var > 0.0) {
35  // random generator and distribution
36  std::random_device rd; // Will be used to obtain a seed for the random number engine
37  std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd()
38  std::normal_distribution<double> dis(0.0, std::sqrt(pos_var));
39  for (auto& position : positions) {
40  for (auto& coordinate : position)
41  coordinate += dis(gen);
42  }
43  }
44  return positions;
45 }
virtual std::vector< std::vector< double > > generatePositionsImpl(double layer_size, double density=0.0) const =0
virtual double positionVariance() const =0

References IPositionBuilder::generatePositionsImpl(), and IPositionBuilder::positionVariance().

Here is the call graph for this function:

◆ generatePositionsImpl()

std::vector< std::vector< double > > RadialParacrystalPositionBuilder::generatePositionsImpl ( double  layer_size,
double  density = 0.0 
) const
overrideprivatevirtual

Implements IPositionBuilder.

Definition at line 222 of file IPositionBuilder.cpp.

223 {
224  std::vector<std::vector<double>> lattice_positions;
225 
226  double distance = m_iff->peakDistance();
227 
228  // Estimate the limit n of the integer multiple i of the peakDistance required
229  // for populating particles correctly within the 3D model's boundaries
230  int n = distance <= 0.0 ? 1 : static_cast<int>(layer_size * std::sqrt(2.0) / distance);
231 
232  lattice_positions.resize(2 * n + 1);
233  for (auto& it : lattice_positions)
234  it.resize(2);
235 
236  lattice_positions[0][0] = 0.0; // x coordinate of reference particle - at the origin
237  lattice_positions[0][1] = 0.0; // y coordinate of reference particle - at the origin
238 
239  for (int i = 1; i <= n; ++i) {
240  // positions of particles located along +x (store at odd index)
241  unsigned i_left = static_cast<unsigned>(std::max(0, 2 * i - 3));
242 
243  double offset = m_iff->randomSample();
244  lattice_positions[2 * i - 1][0] = lattice_positions[i_left][0] + distance + offset;
245  lattice_positions[2 * i - 1][1] = 0.0;
246 
247  // positions of particles located along -x (store at even index)
248  offset = m_iff->randomSample();
249  lattice_positions[2 * i][0] = lattice_positions[2 * (i - 1)][0] - distance + offset;
250  lattice_positions[2 * i][1] = 0.0;
251  }
252  return lattice_positions;
253 }

References m_iff.

◆ positionVariance()

double RadialParacrystalPositionBuilder::positionVariance ( ) const
overrideprivatevirtual

Implements IPositionBuilder.

Definition at line 255 of file IPositionBuilder.cpp.

256 {
257  return m_iff->positionVariance();
258 }

References m_iff.

Member Data Documentation

◆ m_iff

std::unique_ptr<InterferenceRadialParaCrystal> RadialParacrystalPositionBuilder::m_iff
private

Definition at line 123 of file IPositionBuilder.h.

Referenced by generatePositionsImpl(), and positionVariance().


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