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

Description

The default position builder is used when no specific implementation exist for generating the positions based on the interference function.

It always generates a single point at the origin

Definition at line 44 of file IPositionBuilder.h.

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

Public Member Functions

 DefaultPositionBuilder ()
 
 ~DefaultPositionBuilder () 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
 

Constructor & Destructor Documentation

◆ DefaultPositionBuilder()

DefaultPositionBuilder::DefaultPositionBuilder ( )
default

◆ ~DefaultPositionBuilder()

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

Implements IPositionBuilder.

Definition at line 51 of file IPositionBuilder.cpp.

52 {
53  std::vector<double> origin = {0.0, 0.0};
54  return {origin};
55 }

◆ positionVariance()

double DefaultPositionBuilder::positionVariance ( ) const
overrideprivatevirtual

Implements IPositionBuilder.

Definition at line 57 of file IPositionBuilder.cpp.

58 {
59  return 0.0;
60 }

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