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

Description

Definition at line 66 of file IPositionBuilder.h.

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

Public Member Functions

 Lattice1DPositionBuilder (const Interference1DLattice *p_iff)
 
 ~Lattice1DPositionBuilder () 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< Interference1DLattice > m_iff
 

Constructor & Destructor Documentation

◆ Lattice1DPositionBuilder()

Lattice1DPositionBuilder::Lattice1DPositionBuilder ( const Interference1DLattice *  p_iff)

Definition at line 97 of file IPositionBuilder.cpp.

98  : m_iff(p_iff->clone())
99 {
100 }
std::unique_ptr< Interference1DLattice > m_iff

◆ ~Lattice1DPositionBuilder()

Lattice1DPositionBuilder::~Lattice1DPositionBuilder ( )
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 > > Lattice1DPositionBuilder::generatePositionsImpl ( double  layer_size,
double  density = 0.0 
) const
overrideprivatevirtual

Implements IPositionBuilder.

Definition at line 104 of file IPositionBuilder.cpp.

106 {
107  const double length = m_iff->length();
108  const double xi = m_iff->xi();
109 
110  // Take the maximum possible integer multiple of the lattice vector required
111  // for populating particles correctly within the 3D model's boundaries
112  unsigned n1 =
113  length == 0.0 ? 2 : static_cast<unsigned>(2.0 * layer_size * std::sqrt(2.0) / length);
114 
115  return Generate2DLatticePoints(length, 0.0, 0.0, xi, n1, 1u);
116 }

References m_iff.

◆ positionVariance()

double Lattice1DPositionBuilder::positionVariance ( ) const
overrideprivatevirtual

Implements IPositionBuilder.

Definition at line 118 of file IPositionBuilder.cpp.

119 {
120  return m_iff->positionVariance();
121 }

References m_iff.

Member Data Documentation

◆ m_iff

std::unique_ptr<Interference1DLattice> Lattice1DPositionBuilder::m_iff
private

Definition at line 75 of file IPositionBuilder.h.

Referenced by generatePositionsImpl(), and positionVariance().


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