BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
IPositionBuilder Class Referenceabstract

Description

Definition at line 27 of file IPositionBuilder.h.

Inheritance diagram for IPositionBuilder:
[legend]

Public Member Functions

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

Private Member Functions

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

Constructor & Destructor Documentation

◆ ~IPositionBuilder()

IPositionBuilder::~IPositionBuilder ( )
virtualdefault

Member Function Documentation

◆ generatePositions()

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

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 generatePositionsImpl(), and positionVariance().

Here is the call graph for this function:

◆ generatePositionsImpl()

virtual std::vector<std::vector<double> > IPositionBuilder::generatePositionsImpl ( double  layer_size,
double  density = 0.0 
) const
privatepure virtual

◆ positionVariance()


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