BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
InterferenceFunction2DLattice Class Reference
Inheritance diagram for InterferenceFunction2DLattice:
Collaboration diagram for InterferenceFunction2DLattice:

Public Member Functions

 InterferenceFunction2DLattice (double length_1, double length_2, double alpha, double xi)
 
 InterferenceFunction2DLattice (const Lattice2D &lattice)
 
 ~InterferenceFunction2DLattice () final
 
InterferenceFunction2DLatticeclone () const override final
 
void accept (INodeVisitor *visitor) const override final
 
void setDecayFunction (const IFTDecayFunction2D &decay)
 
void setIntegrationOverXi (bool integrate_xi)
 
bool integrationOverXi () const
 
const Lattice2Dlattice () const
 
double getParticleDensity () const override final
 
std::vector< const INode * > getChildren () const override final
 
void onChange () override final
 
virtual double evaluate (const kvector_t q, double outer_iff=1.0) const
 
void setPositionVariance (double var)
 
double positionVariance () const
 
virtual bool supportsMultilayer () const
 
double DWfactor (kvector_t q) const
 
virtual const Materialmaterial () const
 
std::vector< const Material * > containedMaterials () const
 
virtual void transferToCPP ()
 
virtual std::string treeToString () const
 
void registerChild (INode *node)
 
virtual void setParent (const INode *newParent)
 
const INodeparent () const
 
INodeparent ()
 
int copyNumber (const INode *node) const
 
std::string displayName () const
 
ParameterPoolcreateParameterTree () const
 
ParameterPoolparameterPool () const
 
std::string parametersToString () const
 
RealParameterregisterParameter (const std::string &name, double *parpointer)
 
void registerVector (const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
 
void setParameterValue (const std::string &name, double value)
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
RealParameterparameter (const std::string &name) const
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
void setName (const std::string &name)
 
const std::string & getName () const
 

Static Public Member Functions

static InterferenceFunction2DLatticecreateSquare (double lattice_length, double xi)
 
static InterferenceFunction2DLatticecreateHexagonal (double lattice_length, double xi)
 
static std::string XComponentName (const std::string &base_name)
 
static std::string YComponentName (const std::string &base_name)
 
static std::string ZComponentName (const std::string &base_name)
 

Protected Member Functions

double iff_no_inner (const kvector_t q, double outer_iff) const
 

Protected Attributes

double m_position_var
 
const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

double iff_without_dw (const kvector_t q) const override final
 
void setLattice (const Lattice2D &lattice)
 
double interferenceForXi (double xi) const
 
double interferenceAtOneRecLatticePoint (double qx, double qy) const
 
std::pair< double, double > rotateOrthonormal (double qx, double qy, double gamma) const
 
std::pair< double, double > calculateReciprocalVectorFraction (double qx, double qy, double xi) const
 
void initialize_rec_vectors ()
 
void initialize_calc_factors ()
 

Private Attributes

bool m_integrate_xi
 
std::unique_ptr< IFTDecayFunction2Dm_decay
 
std::unique_ptr< Lattice2Dm_lattice
 
Lattice2D::ReciprocalBases m_sbase
 
int m_na
 
int m_nb
 
double m_qx
 
double m_qy
 
const INodem_parent {nullptr}
 
std::string m_name
 
std::unique_ptr< ParameterPoolm_pool
 

Detailed Description

Interference function of a 2D lattice.

Definition at line 26 of file InterferenceFunction2DLattice.h.

Constructor & Destructor Documentation

◆ InterferenceFunction2DLattice() [1/2]

InterferenceFunction2DLattice::InterferenceFunction2DLattice ( double  length_1,
double  length_2,
double  alpha,
double  xi 
)

Constructor of two-dimensional interference function.

Parameters
length_1length of the first basis vector in nanometers
length_2length of the second basis vector in nanometers
alphaangle between the basis vectors in radians
xirotation of the lattice with respect to the x-axis (beam direction) in radians

Definition at line 41 of file InterferenceFunction2DLattice.cpp.

43  : InterferenceFunction2DLattice(BasicLattice(length_1, length_2, alpha, xi))
44 {
45 }
InterferenceFunction2DLattice(double length_1, double length_2, double alpha, double xi)
Constructor of two-dimensional interference function.

Referenced by clone(), createHexagonal(), and createSquare().

◆ InterferenceFunction2DLattice() [2/2]

InterferenceFunction2DLattice::InterferenceFunction2DLattice ( const Lattice2D lattice)

Definition at line 29 of file InterferenceFunction2DLattice.cpp.

31 {
32  setName("Interference2DLattice");
34 }
IInterferenceFunction(const NodeMeta &meta, const std::vector< double > &PValues)
void setName(const std::string &name)
bool m_integrate_xi
Integrate over the orientation xi.
void setLattice(const Lattice2D &lattice)

References lattice(), setLattice(), and IParameterized::setName().

Here is the call graph for this function:

◆ ~InterferenceFunction2DLattice()

InterferenceFunction2DLattice::~InterferenceFunction2DLattice ( )
finaldefault

Member Function Documentation

◆ clone()

InterferenceFunction2DLattice * InterferenceFunction2DLattice::clone ( ) const
finaloverridevirtual

Returns a clone of this ISample object.

Implements IInterferenceFunction.

Definition at line 49 of file InterferenceFunction2DLattice.cpp.

50 {
51  auto* ret = new InterferenceFunction2DLattice(*m_lattice);
52  ret->setPositionVariance(m_position_var);
53  ret->setIntegrationOverXi(integrationOverXi());
54  if (m_decay)
55  ret->setDecayFunction(*m_decay);
56  return ret;
57 }
std::unique_ptr< IFTDecayFunction2D > m_decay
std::unique_ptr< Lattice2D > m_lattice

References integrationOverXi(), InterferenceFunction2DLattice(), m_decay, m_lattice, and IInterferenceFunction::m_position_var.

Here is the call graph for this function:

◆ accept()

void InterferenceFunction2DLattice::accept ( INodeVisitor visitor) const
inlinefinaloverridevirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 35 of file InterferenceFunction2DLattice.h.

35 { visitor->visit(this); }
virtual void visit(const BasicLattice *)
Definition: INodeVisitor.h:154

◆ createSquare()

InterferenceFunction2DLattice * InterferenceFunction2DLattice::createSquare ( double  lattice_length,
double  xi 
)
static

Creates square lattice.

Parameters
lattice_lengthlength of the first and second basis vectors in nanometers
xirotation of the lattice with respect to the x-axis in radians

Definition at line 62 of file InterferenceFunction2DLattice.cpp.

64 {
65  return new InterferenceFunction2DLattice(SquareLattice(lattice_length, xi));
66 }

References InterferenceFunction2DLattice().

Referenced by BoxesSquareLatticeBuilder::buildSample(), SquareLatticeBuilder::buildSample(), and RotatedSquareLatticeBuilder::buildSample().

Here is the call graph for this function:

◆ createHexagonal()

InterferenceFunction2DLattice * InterferenceFunction2DLattice::createHexagonal ( double  lattice_length,
double  xi 
)
static

Creates hexagonal lattice.

Parameters
lattice_lengthlength of the first and second basis vectors in nanometers
xirotation of the lattice with respect to the x-axis in radians

Definition at line 71 of file InterferenceFunction2DLattice.cpp.

73 {
74  return new InterferenceFunction2DLattice(HexagonalLattice(lattice_length, xi));
75 }

References InterferenceFunction2DLattice().

Referenced by ParticleCompositionBuilder::buildSample().

Here is the call graph for this function:

◆ setDecayFunction()

void InterferenceFunction2DLattice::setDecayFunction ( const IFTDecayFunction2D decay)

Sets two-dimensional decay function.

Parameters
decaytwo-dimensional decay function in reciprocal space

Definition at line 79 of file InterferenceFunction2DLattice.cpp.

80 {
81  m_decay.reset(decay.clone());
82  registerChild(m_decay.get());
84 }
virtual IFTDecayFunction2D * clone() const =0
void registerChild(INode *node)
Definition: INode.cpp:58
void initialize_calc_factors()
Initializes factors needed in each calculation.

References IFTDecayFunction2D::clone(), initialize_calc_factors(), m_decay, and INode::registerChild().

Referenced by CenteredSquareLatticeBuilder::buildSample().

Here is the call graph for this function:

◆ setIntegrationOverXi()

void InterferenceFunction2DLattice::setIntegrationOverXi ( bool  integrate_xi)

Definition at line 86 of file InterferenceFunction2DLattice.cpp.

87 {
88  m_integrate_xi = integrate_xi;
89  m_lattice->setRotationEnabled(!m_integrate_xi); // deregister Xi in the case of integration
90 }

References m_integrate_xi, and m_lattice.

◆ integrationOverXi()

bool InterferenceFunction2DLattice::integrationOverXi ( ) const
inline

Definition at line 43 of file InterferenceFunction2DLattice.h.

43 { return m_integrate_xi; }

References m_integrate_xi.

Referenced by clone().

◆ lattice()

const Lattice2D & InterferenceFunction2DLattice::lattice ( ) const

Definition at line 92 of file InterferenceFunction2DLattice.cpp.

93 {
94  if (!m_lattice)
95  throw std::runtime_error("InterferenceFunction2DLattice::lattice() -> Error. "
96  "No lattice defined.");
97  return *m_lattice;
98 }

References m_lattice.

Referenced by InterferenceFunction2DLattice(), and setLattice().

◆ getParticleDensity()

double InterferenceFunction2DLattice::getParticleDensity ( ) const
finaloverridevirtual

Returns the particle density associated with this 2d lattice.

Reimplemented from IInterferenceFunction.

Definition at line 100 of file InterferenceFunction2DLattice.cpp.

101 {
102  double area = m_lattice->unitCellArea();
103  return area == 0.0 ? 0.0 : 1.0 / area;
104 }

References m_lattice.

Referenced by interferenceForXi().

◆ getChildren()

std::vector< const INode * > InterferenceFunction2DLattice::getChildren ( ) const
finaloverridevirtual

Returns a vector of children (const).

Reimplemented from INode.

Definition at line 106 of file InterferenceFunction2DLattice.cpp.

107 {
108  return std::vector<const INode*>() << m_decay << m_lattice;
109 }

References m_decay, and m_lattice.

◆ onChange()

void InterferenceFunction2DLattice::onChange ( )
finaloverridevirtual

Action to be taken in inherited class when a parameter has changed.

Reimplemented from IParameterized.

Definition at line 111 of file InterferenceFunction2DLattice.cpp.

112 {
115 }
void initialize_rec_vectors()
Initializes the x,y coordinates of the a*,b* reciprocal bases.

References initialize_calc_factors(), and initialize_rec_vectors().

Here is the call graph for this function:

◆ iff_without_dw()

double InterferenceFunction2DLattice::iff_without_dw ( const kvector_t  q) const
finaloverrideprivatevirtual

Calculates the structure factor without Debye-Waller factor.

Implements IInterferenceFunction.

Definition at line 117 of file InterferenceFunction2DLattice.cpp.

118 {
119  if (!m_decay)
120  throw Exceptions::NullPointerException("InterferenceFunction2DLattice::evaluate"
121  " -> Error! No decay function defined.");
122  m_qx = q.x();
123  m_qy = q.y();
124  if (!m_integrate_xi)
125  return interferenceForXi(m_lattice->rotationAngle());
126  return RealIntegrator().integrate([&](double xi) -> double { return interferenceForXi(xi); },
127  0.0, M_TWOPI)
128  / M_TWOPI;
129 }
#define M_TWOPI
Definition: MathConstants.h:49
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
To integrate a real function of a real variable.
Definition: Integrator.h:24
double integrate(const std::function< double(double)> &f, double lmin, double lmax)
Definition: Integrator.cpp:27

References RealIntegrator::integrate(), interferenceForXi(), m_decay, m_integrate_xi, m_lattice, m_qx, m_qy, M_TWOPI, BasicVector3D< T >::x(), and BasicVector3D< T >::y().

Here is the call graph for this function:

◆ setLattice()

void InterferenceFunction2DLattice::setLattice ( const Lattice2D lattice)
private

Definition at line 131 of file InterferenceFunction2DLattice.cpp.

132 {
133  m_lattice.reset(lattice.clone());
134  registerChild(m_lattice.get());
136 }
virtual Lattice2D * clone() const =0

References Lattice2D::clone(), initialize_rec_vectors(), lattice(), m_lattice, and INode::registerChild().

Referenced by InterferenceFunction2DLattice().

Here is the call graph for this function:

◆ interferenceForXi()

double InterferenceFunction2DLattice::interferenceForXi ( double  xi) const
private

Definition at line 138 of file InterferenceFunction2DLattice.cpp.

139 {
140  double result = 0.0;
141  auto q_frac = calculateReciprocalVectorFraction(m_qx, m_qy, xi);
142 
143  for (int i = -m_na - 1; i < m_na + 2; ++i) {
144  for (int j = -m_nb - 1; j < m_nb + 2; ++j) {
145  double qx = q_frac.first + i * m_sbase.m_asx + j * m_sbase.m_bsx;
146  double qy = q_frac.second + i * m_sbase.m_asy + j * m_sbase.m_bsy;
147  result += interferenceAtOneRecLatticePoint(qx, qy);
148  }
149  }
150  return getParticleDensity() * result;
151 }
Lattice2D::ReciprocalBases m_sbase
reciprocal lattice is stored without xi
std::pair< double, double > calculateReciprocalVectorFraction(double qx, double qy, double xi) const
Returns qx,qy coordinates of q - qint, where qint is a reciprocal lattice vector bounding the recipro...
int m_nb
determines the number of reciprocal lattice points to use
double getParticleDensity() const override final
Returns the particle density associated with this 2d lattice.
double interferenceAtOneRecLatticePoint(double qx, double qy) const
Returns interference from a single reciprocal lattice vector.
double m_asy
x,y coordinates of a*
Definition: Lattice2D.h:30
double m_bsy
x,y coordinates of b*
Definition: Lattice2D.h:31

References calculateReciprocalVectorFraction(), getParticleDensity(), interferenceAtOneRecLatticePoint(), Lattice2D::ReciprocalBases::m_asx, Lattice2D::ReciprocalBases::m_asy, Lattice2D::ReciprocalBases::m_bsx, Lattice2D::ReciprocalBases::m_bsy, m_na, m_nb, m_qx, m_qy, and m_sbase.

Referenced by iff_without_dw().

Here is the call graph for this function:

◆ interferenceAtOneRecLatticePoint()

double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint ( double  qx,
double  qy 
) const
private

Returns interference from a single reciprocal lattice vector.

Definition at line 153 of file InterferenceFunction2DLattice.cpp.

154 {
155  if (!m_decay)
157  "InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint"
158  " -> Error! No decay function defined.");
159  double gamma = m_decay->gamma();
160  auto qXY = rotateOrthonormal(qx, qy, gamma);
161  return m_decay->evaluate(qXY.first, qXY.second);
162 }
std::pair< double, double > rotateOrthonormal(double qx, double qy, double gamma) const
Returns reciprocal coordinates in the coordinate system rotated by the angle gamma.

References m_decay, and rotateOrthonormal().

Referenced by interferenceForXi().

Here is the call graph for this function:

◆ rotateOrthonormal()

std::pair< double, double > InterferenceFunction2DLattice::rotateOrthonormal ( double  qx,
double  qy,
double  gamma 
) const
private

Returns reciprocal coordinates in the coordinate system rotated by the angle gamma.

Definition at line 165 of file InterferenceFunction2DLattice.cpp.

167 {
168  double q_X = qx * std::cos(gamma) + qy * std::sin(gamma);
169  double q_Y = -qx * std::sin(gamma) + qy * std::cos(gamma);
170  return {q_X, q_Y};
171 }

Referenced by interferenceAtOneRecLatticePoint().

◆ calculateReciprocalVectorFraction()

std::pair< double, double > InterferenceFunction2DLattice::calculateReciprocalVectorFraction ( double  qx,
double  qy,
double  xi 
) const
private

Returns qx,qy coordinates of q - qint, where qint is a reciprocal lattice vector bounding the reciprocal unit cell to which q belongs.

Definition at line 177 of file InterferenceFunction2DLattice.cpp.

179 {
180  double a = m_lattice->length1();
181  double b = m_lattice->length2();
182  double alpha = m_lattice->latticeAngle();
183  // first rotate the input to the system of m_sbase:
184  double qx_rot = qx * std::cos(xi) + qy * std::sin(xi);
185  double qy_rot = -qx * std::sin(xi) + qy * std::cos(xi);
186 
187  // find the reciprocal lattice coordinates of (qx_rot, qy_rot):
188  int qa_int = static_cast<int>(std::lround(a * qx_rot / M_TWOPI));
189  int qb_int = static_cast<int>(
190  std::lround(b * (qx_rot * std::cos(alpha) + qy_rot * std::sin(alpha)) / M_TWOPI));
191  // take the fractional part only (in m_sbase coordinates)
192  double qx_frac = qx_rot - qa_int * m_sbase.m_asx - qb_int * m_sbase.m_bsx;
193  double qy_frac = qy_rot - qa_int * m_sbase.m_asy - qb_int * m_sbase.m_bsy;
194  return {qx_frac, qy_frac};
195 }

References Lattice2D::ReciprocalBases::m_asx, Lattice2D::ReciprocalBases::m_asy, Lattice2D::ReciprocalBases::m_bsx, Lattice2D::ReciprocalBases::m_bsy, m_lattice, m_sbase, and M_TWOPI.

Referenced by interferenceForXi().

◆ initialize_rec_vectors()

void InterferenceFunction2DLattice::initialize_rec_vectors ( )
private

Initializes the x,y coordinates of the a*,b* reciprocal bases.

Definition at line 198 of file InterferenceFunction2DLattice.cpp.

199 {
200  if (!m_lattice)
201  throw std::runtime_error("InterferenceFunction2DLattice::initialize_rec_vectors() -> "
202  "Error. No lattice defined yet");
203 
204  BasicLattice base_lattice(m_lattice->length1(), m_lattice->length2(), m_lattice->latticeAngle(),
205  0.);
206  m_sbase = base_lattice.reciprocalBases();
207 }

References m_lattice, m_sbase, and Lattice2D::reciprocalBases().

Referenced by onChange(), and setLattice().

Here is the call graph for this function:

◆ initialize_calc_factors()

void InterferenceFunction2DLattice::initialize_calc_factors ( )
private

Initializes factors needed in each calculation.

Definition at line 209 of file InterferenceFunction2DLattice.cpp.

210 {
211  if (!m_decay)
213  "InterferenceFunction2DLattice::initialize_calc_factors"
214  " -> Error! No decay function defined.");
215 
216  // number of reciprocal lattice points to use
217  auto q_bounds = m_decay->boundingReciprocalLatticeCoordinates(
218  nmax / m_decay->decayLengthX(), nmax / m_decay->decayLengthY(), m_lattice->length1(),
219  m_lattice->length2(), m_lattice->latticeAngle());
220  m_na = static_cast<int>(std::lround(q_bounds.first + 0.5));
221  m_nb = static_cast<int>(std::lround(q_bounds.second + 0.5));
222  m_na = std::max(m_na, min_points);
223  m_nb = std::max(m_nb, min_points);
224 }

References m_decay, m_lattice, m_na, m_nb, anonymous_namespace{InterferenceFunction2DLattice.cpp}::min_points, and anonymous_namespace{InterferenceFunction2DLattice.cpp}::nmax.

Referenced by onChange(), and setDecayFunction().

◆ evaluate()

double IInterferenceFunction::evaluate ( const kvector_t  q,
double  outer_iff = 1.0 
) const
virtualinherited

Evaluates the interference function for a given wavevector transfer.

Reimplemented in InterferenceFunction2DSuperLattice.

Definition at line 35 of file IInterferenceFunction.cpp.

36 {
37  return iff_no_inner(q, outer_iff);
38 }
double iff_no_inner(const kvector_t q, double outer_iff) const
Calculates the structure factor in the absence of extra inner structure.

References IInterferenceFunction::iff_no_inner().

Here is the call graph for this function:

◆ setPositionVariance()

void IInterferenceFunction::setPositionVariance ( double  var)
inherited

Sets the variance of the position for the calculation of the DW factor It is defined as the variance in each relevant dimension.

Definition at line 40 of file IInterferenceFunction.cpp.

41 {
42  if (var < 0.0)
43  throw std::runtime_error("IInterferenceFunction::setPositionVariance: "
44  "variance should be positive.");
45  m_position_var = var;
46 }

References IInterferenceFunction::m_position_var.

Referenced by FiniteSquareLatticeBuilder::buildSample(), and SuperLatticeBuilder::buildSample().

◆ positionVariance()

double IInterferenceFunction::positionVariance ( ) const
inlineinherited

Returns the position variance.

Definition at line 39 of file IInterferenceFunction.h.

39 { return m_position_var; }

References IInterferenceFunction::m_position_var.

Referenced by SampleToPython::defineInterferenceFunctions().

◆ supportsMultilayer()

virtual bool IInterferenceFunction::supportsMultilayer ( ) const
inlinevirtualinherited

Indicates if this interference function can be used with a multilayer (DWBA mode)

Reimplemented in InterferenceFunctionFinite3DLattice, and InterferenceFunction3DLattice.

Definition at line 46 of file IInterferenceFunction.h.

46 { return true; }

Referenced by LayoutStrategyBuilder::createStrategy(), and IInterferenceFunction::DWfactor().

◆ DWfactor()

double IInterferenceFunction::DWfactor ( kvector_t  q) const
inherited

Evaluates the Debye-Waller factor for a given wavevector transfer.

Definition at line 48 of file IInterferenceFunction.cpp.

49 {
50  // remove z component for two dimensional interference functions:
51  if (supportsMultilayer())
52  q.setZ(0.0);
53  return std::exp(-q.mag2() * m_position_var);
54 }
double mag2() const
Returns magnitude squared of the vector.
void setZ(const T &a)
Sets z-component in cartesian coordinate system.
Definition: BasicVector3D.h:75
virtual bool supportsMultilayer() const
Indicates if this interference function can be used with a multilayer (DWBA mode)

References IInterferenceFunction::m_position_var, BasicVector3D< T >::mag2(), BasicVector3D< T >::setZ(), and IInterferenceFunction::supportsMultilayer().

Referenced by IInterferenceFunction::iff_no_inner().

Here is the call graph for this function:

◆ iff_no_inner()

double IInterferenceFunction::iff_no_inner ( const kvector_t  q,
double  outer_iff 
) const
protectedinherited

Calculates the structure factor in the absence of extra inner structure.

Definition at line 56 of file IInterferenceFunction.cpp.

57 {
58  return DWfactor(q) * (iff_without_dw(q) * outer_iff - 1.0) + 1.0;
59 }
double DWfactor(kvector_t q) const
Evaluates the Debye-Waller factor for a given wavevector transfer.
virtual double iff_without_dw(const kvector_t q) const =0
Calculates the structure factor without Debye-Waller factor.

References IInterferenceFunction::DWfactor(), and IInterferenceFunction::iff_without_dw().

Referenced by IInterferenceFunction::evaluate(), and InterferenceFunction2DSuperLattice::interferenceForXi().

Here is the call graph for this function:

◆ material()

◆ containedMaterials()

std::vector< const Material * > ISample::containedMaterials ( ) const
inherited

Returns set of unique materials contained in this ISample.

Definition at line 23 of file ISample.cpp.

24 {
25  std::vector<const Material*> result;
26  if (const Material* p_material = material())
27  result.push_back(p_material);
28  for (auto child : getChildren()) {
29  if (const ISample* sample = dynamic_cast<const ISample*>(child)) {
30  for (const Material* p_material : sample->containedMaterials())
31  result.push_back(p_material);
32  }
33  }
34  return result;
35 }
virtual std::vector< const INode * > getChildren() const
Returns a vector of children (const).
Definition: INode.cpp:64
Pure virtual base class for sample components and properties related to scattering.
Definition: ISample.h:28
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISample.h:37
A wrapper for underlying material implementation.
Definition: Material.h:29

References INode::getChildren(), and ISample::material().

Referenced by MultiLayerUtils::ContainsCompatibleMaterials(), anonymous_namespace{ProcessedSample.cpp}::ContainsMagneticMaterial(), and SampleToPython::initLabels().

Here is the call graph for this function:

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

Used for Python overriding of clone (see swig/tweaks.py)

Definition at line 34 of file ICloneable.h.

◆ treeToString()

std::string INode::treeToString ( ) const
virtualinherited

Returns multiline string representing tree structure below the node.

Definition at line 53 of file INode.cpp.

54 {
55  return NodeUtils::nodeToString(*this);
56 }
std::string nodeToString(const INode &node)
Returns multiline string representing tree structure starting from given node.
Definition: NodeUtils.cpp:67

References NodeUtils::nodeToString().

Here is the call graph for this function:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 58 of file INode.cpp.

59 {
60  ASSERT(node);
61  node->setParent(this);
62 }
#define ASSERT(condition)
Definition: Assert.h:26
virtual void setParent(const INode *newParent)
Definition: INode.cpp:69

References ASSERT, and INode::setParent().

Referenced by ParticleLayout::addAndRegisterAbstractParticle(), ParticleCoreShell::addAndRegisterCore(), MultiLayer::addAndRegisterInterface(), MultiLayer::addAndRegisterLayer(), ParticleCoreShell::addAndRegisterShell(), Layer::addLayout(), ParticleComposition::addParticlePointer(), Beam::Beam(), Crystal::Crystal(), IDetector::IDetector(), Simulation::initialize(), MesoCrystal::initialize(), Instrument::Instrument(), Beam::operator=(), Instrument::operator=(), Particle::Particle(), ParticleDistribution::ParticleDistribution(), IParticle::rotate(), ParticleLayout::setAndRegisterInterferenceFunction(), Simulation::setBackground(), InterferenceFunction1DLattice::setDecayFunction(), setDecayFunction(), Instrument::setDetector(), IDetector::setDetectorResolution(), Beam::setFootprintFactor(), Particle::setFormFactor(), InterferenceFunctionFinite3DLattice::setLattice(), setLattice(), InterferenceFunction2DParaCrystal::setLattice(), InterferenceFunction2DSuperLattice::setLattice(), InterferenceFunctionFinite2DLattice::setLattice(), InterferenceFunctionRadialParaCrystal::setProbabilityDistribution(), InterferenceFunction2DParaCrystal::setProbabilityDistributions(), ConvolutionDetectorResolution::setResolutionFunction(), IParticle::setRotation(), LayerInterface::setRoughness(), and InterferenceFunction2DSuperLattice::setSubstructureIFF().

Here is the call graph for this function:

◆ setParent()

void INode::setParent ( const INode newParent)
virtualinherited

Reimplemented in SampleProvider.

Definition at line 69 of file INode.cpp.

70 {
71  m_parent = newParent;
72 }
const INode * m_parent
Definition: INode.h:81

References INode::m_parent.

Referenced by INode::registerChild(), SampleProvider::setBuilder(), and SampleProvider::setParent().

◆ parent() [1/2]

const INode * INode::parent ( ) const
inherited

◆ parent() [2/2]

INode * INode::parent ( )
inherited

Definition at line 79 of file INode.cpp.

80 {
81  return const_cast<INode*>(m_parent);
82 }
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49

References INode::m_parent.

◆ copyNumber()

int INode::copyNumber ( const INode node) const
inherited

Returns copyNumber of child, which takes into account existence of children with same name.

Definition at line 84 of file INode.cpp.

85 {
86  if (node->parent() != this)
87  return -1;
88 
89  int result(-1), count(0);
90  for (auto child : getChildren()) {
91 
92  if (child == nullptr)
93  throw std::runtime_error("INode::copyNumber() -> Error. Nullptr as child.");
94 
95  if (child == node)
96  result = count;
97 
98  if (child->getName() == node->getName())
99  ++count;
100  }
101 
102  return count > 1 ? result : -1;
103 }
const INode * parent() const
Definition: INode.cpp:74
const std::string & getName() const

References INode::getChildren(), IParameterized::getName(), and INode::parent().

Referenced by INode::displayName().

Here is the call graph for this function:

◆ displayName()

std::string INode::displayName ( ) const
inherited

Returns display name, composed from the name of node and it's copy number.

Definition at line 105 of file INode.cpp.

106 {
107  std::string result = getName();
108  if (m_parent) {
109  int index = m_parent->copyNumber(this);
110  if (index >= 0)
111  result = result + std::to_string(index);
112  }
113  return result;
114 }
int copyNumber(const INode *node) const
Returns copyNumber of child, which takes into account existence of children with same name.
Definition: INode.cpp:84

References INode::copyNumber(), IParameterized::getName(), and INode::m_parent.

Referenced by NodeUtils::nodePath(), and anonymous_namespace{NodeUtils.cpp}::nodeString().

Here is the call graph for this function:

◆ createParameterTree()

ParameterPool * INode::createParameterTree ( ) const
virtualinherited

Creates new parameter pool, with all local parameters and those of its children.

Reimplemented from IParameterized.

Definition at line 116 of file INode.cpp.

117 {
118  std::unique_ptr<ParameterPool> result(new ParameterPool);
119 
121  it.first();
122  while (!it.isDone()) {
123  const INode* child = it.getCurrent();
124  const std::string path = NodeUtils::nodePath(*child, this->parent()) + "/";
125  child->parameterPool()->copyToExternalPool(path, result.get());
126  it.next();
127  }
128 
129  return result.release();
130 }
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.
Iterator through INode tree of objects.
Definition: NodeIterator.h:90
Container with parameters for IParameterized object.
Definition: ParameterPool.h:30
void copyToExternalPool(const std::string &prefix, ParameterPool *other_pool) const
Copies parameters of given pool to other pool, prepeding prefix to the parameter names.
std::string nodePath(const INode &node, const INode *root=nullptr)
Returns path composed of node's displayName, with respect to root node.
Definition: NodeUtils.cpp:82

References ParameterPool::copyToExternalPool(), NodeIterator< Strategy >::first(), NodeIterator< Strategy >::getCurrent(), NodeIterator< Strategy >::isDone(), NodeIterator< Strategy >::next(), NodeUtils::nodePath(), IParameterized::parameterPool(), and INode::parent().

Referenced by ParticleDistribution::generateParticles(), Simulation::runSimulation(), DepthProbeSimulation::validateParametrization(), OffSpecSimulation::validateParametrization(), and SpecularSimulation::validateParametrization().

Here is the call graph for this function:

◆ parameterPool()

ParameterPool* IParameterized::parameterPool ( ) const
inlineinherited

Returns pointer to the parameter pool.

Definition at line 38 of file IParameterized.h.

38 { return m_pool.get(); } // has non-const usages!
std::unique_ptr< ParameterPool > m_pool
parameter pool (kind of pointer-to-implementation)

References IParameterized::m_pool.

Referenced by pyfmt2::argumentList(), SampleBuilderNode::borrow_builder_parameters(), INode::createParameterTree(), INode::INode(), IParameterized::IParameterized(), anonymous_namespace{NodeUtils.cpp}::poolToString(), SampleBuilderNode::reset(), and IDistribution1D::setUnits().

◆ parametersToString()

std::string IParameterized::parametersToString ( ) const
inherited

Returns multiline string representing available parameters.

Definition at line 40 of file IParameterized.cpp.

41 {
42  std::ostringstream result;
43  std::unique_ptr<ParameterPool> P_pool(createParameterTree());
44  result << *P_pool << "\n";
45  return result.str();
46 }
virtual ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.

References IParameterized::createParameterTree().

Here is the call graph for this function:

◆ registerParameter()

RealParameter & IParameterized::registerParameter ( const std::string &  name,
double *  parpointer 
)
inherited

Definition at line 48 of file IParameterized.cpp.

49 {
50  return m_pool->addParameter(
51  new RealParameter(name, data, getName(), [&]() -> void { onChange(); }));
52 }
virtual void onChange()
Action to be taken in inherited class when a parameter has changed.
Wraps a parameter of type double.
Definition: RealParameter.h:32

References IParameterized::getName(), IParameterized::m_pool, and IParameterized::onChange().

Referenced by BasicLattice::BasicLattice(), Beam::Beam(), CylindersInBABuilder::CylindersInBABuilder(), DetectionProperties::DetectionProperties(), HexagonalLattice::HexagonalLattice(), IInterferenceFunction::IInterferenceFunction(), INode::INode(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), Lattice2D::Lattice2D(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), ParticleDistribution::ParticleDistribution(), PlainMultiLayerBySLDBuilder::PlainMultiLayerBySLDBuilder(), IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), Layer::registerThickness(), IParameterized::registerVector(), ParticleLayout::registerWeight(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), ResonatorBuilder::ResonatorBuilder(), Lattice2D::setRotationEnabled(), SquareLattice::SquareLattice(), and TriangularRippleBuilder::TriangularRippleBuilder().

Here is the call graph for this function:

◆ registerVector()

void IParameterized::registerVector ( const std::string &  base_name,
kvector_t p_vec,
const std::string &  units = "nm" 
)
inherited

Definition at line 54 of file IParameterized.cpp.

56 {
57  registerParameter(XComponentName(base_name), &((*p_vec)[0])).setUnit(units);
58  registerParameter(YComponentName(base_name), &((*p_vec)[1])).setUnit(units);
59  registerParameter(ZComponentName(base_name), &((*p_vec)[2])).setUnit(units);
60 }
RealParameter & registerParameter(const std::string &name, double *parpointer)
static std::string XComponentName(const std::string &base_name)
static std::string YComponentName(const std::string &base_name)
static std::string ZComponentName(const std::string &base_name)
RealParameter & setUnit(const std::string &name)

References IParameterized::registerParameter(), RealParameter::setUnit(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by Beam::Beam(), DetectionProperties::DetectionProperties(), InterferenceFunctionTwin::InterferenceFunctionTwin(), MultiLayer::MultiLayer(), Lattice::registerBasisVectors(), and IParticle::registerPosition().

Here is the call graph for this function:

◆ setParameterValue()

void IParameterized::setParameterValue ( const std::string &  name,
double  value 
)
inherited

Definition at line 62 of file IParameterized.cpp.

63 {
64  if (name.find('*') == std::string::npos && name.find('/') == std::string::npos) {
65  m_pool->setParameterValue(name, value);
66  } else {
67  std::unique_ptr<ParameterPool> P_pool{createParameterTree()};
68  if (name.find('*') != std::string::npos)
69  P_pool->setMatchedParametersValue(name, value);
70  else
71  P_pool->setParameterValue(name, value);
72  }
73 }
int setMatchedParametersValue(const std::string &wildcards, double value)
Sets value of the nonzero parameters that match pattern ('*' allowed), or throws.

References IParameterized::createParameterTree(), IParameterized::m_pool, and ParameterPool::setMatchedParametersValue().

Referenced by AsymRippleBuilder::buildSample(), and IParameterized::setVectorValue().

Here is the call graph for this function:

◆ setVectorValue()

void IParameterized::setVectorValue ( const std::string &  base_name,
kvector_t  value 
)
inherited

Definition at line 75 of file IParameterized.cpp.

76 {
77  setParameterValue(XComponentName(base_name), value.x());
78  setParameterValue(YComponentName(base_name), value.y());
79  setParameterValue(ZComponentName(base_name), value.z());
80 }
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
void setParameterValue(const std::string &name, double value)

References IParameterized::setParameterValue(), BasicVector3D< T >::x(), IParameterized::XComponentName(), BasicVector3D< T >::y(), IParameterized::YComponentName(), BasicVector3D< T >::z(), and IParameterized::ZComponentName().

Here is the call graph for this function:

◆ parameter()

RealParameter * IParameterized::parameter ( const std::string &  name) const
inherited

◆ removeParameter()

void IParameterized::removeParameter ( const std::string &  name)
inherited

◆ removeVector()

void IParameterized::removeVector ( const std::string &  base_name)
inherited

Definition at line 93 of file IParameterized.cpp.

94 {
95  removeParameter(XComponentName(base_name));
96  removeParameter(YComponentName(base_name));
97  removeParameter(ZComponentName(base_name));
98 }
void removeParameter(const std::string &name)

References IParameterized::removeParameter(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by IParticle::registerPosition().

Here is the call graph for this function:

◆ XComponentName()

std::string IParameterized::XComponentName ( const std::string &  base_name)
staticinherited

◆ YComponentName()

std::string IParameterized::YComponentName ( const std::string &  base_name)
staticinherited

Definition at line 105 of file IParameterized.cpp.

106 {
107  return base_name + "Y";
108 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ ZComponentName()

std::string IParameterized::ZComponentName ( const std::string &  base_name)
staticinherited

Definition at line 110 of file IParameterized.cpp.

111 {
112  return base_name + "Z";
113 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ setName()

void IParameterized::setName ( const std::string &  name)
inlineinherited

Definition at line 68 of file IParameterized.h.

68 { m_name = name; }
std::string m_name

References IParameterized::m_name.

Referenced by BasicLattice::BasicLattice(), Beam::Beam(), Layer::clone(), ConvolutionDetectorResolution::ConvolutionDetectorResolution(), LayersWithAbsorptionBuilder::createSampleByIndex(), Basic2DParaCrystalBuilder::createSampleByIndex(), ParticleInVacuumBuilder::createSampleByIndex(), SimpleMagneticRotationBuilder::createSampleByIndex(), Crystal::Crystal(), DetectionProperties::DetectionProperties(), DistributionHandler::DistributionHandler(), FormFactorBAPol::FormFactorBAPol(), FormFactorCoreShell::FormFactorCoreShell(), FormFactorCrystal::FormFactorCrystal(), FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(), FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(), FormFactorDecoratorRotation::FormFactorDecoratorRotation(), FormFactorDWBA::FormFactorDWBA(), FormFactorDWBAPol::FormFactorDWBAPol(), FormFactorWeighted::FormFactorWeighted(), HexagonalLattice::HexagonalLattice(), IDetector::IDetector(), DepthProbeSimulation::initialize(), GISASSimulation::initialize(), OffSpecSimulation::initialize(), SpecularSimulation::initialize(), SpecularDetector1D::initialize(), MesoCrystal::initialize(), Particle::initialize(), ParticleComposition::initialize(), INode::INode(), Instrument::Instrument(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(), InterferenceFunction3DLattice::InterferenceFunction3DLattice(), InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(), InterferenceFunctionFinite3DLattice::InterferenceFunctionFinite3DLattice(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionNone::InterferenceFunctionNone(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), ISampleBuilder::ISampleBuilder(), IsGISAXSDetector::IsGISAXSDetector(), Lattice::Lattice(), Layer::Layer(), LayerInterface::LayerInterface(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), Beam::operator=(), SampleBuilderNode::operator=(), ParticleCoreShell::ParticleCoreShell(), ParticleDistribution::ParticleDistribution(), ParticleLayout::ParticleLayout(), RectangularDetector::RectangularDetector(), SampleBuilderNode::reset(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), SampleBuilderNode::SampleBuilderNode(), SampleBuilderNode::setSBN(), SphericalDetector::SphericalDetector(), and SquareLattice::SquareLattice().

◆ getName()

Member Data Documentation

◆ m_integrate_xi

bool InterferenceFunction2DLattice::m_integrate_xi
private

Integrate over the orientation xi.

Definition at line 77 of file InterferenceFunction2DLattice.h.

Referenced by iff_without_dw(), integrationOverXi(), and setIntegrationOverXi().

◆ m_decay

std::unique_ptr<IFTDecayFunction2D> InterferenceFunction2DLattice::m_decay
private

◆ m_lattice

◆ m_sbase

Lattice2D::ReciprocalBases InterferenceFunction2DLattice::m_sbase
private

reciprocal lattice is stored without xi

Definition at line 80 of file InterferenceFunction2DLattice.h.

Referenced by calculateReciprocalVectorFraction(), initialize_rec_vectors(), and interferenceForXi().

◆ m_na

int InterferenceFunction2DLattice::m_na
private

Definition at line 81 of file InterferenceFunction2DLattice.h.

Referenced by initialize_calc_factors(), and interferenceForXi().

◆ m_nb

int InterferenceFunction2DLattice::m_nb
private

determines the number of reciprocal lattice points to use

Definition at line 81 of file InterferenceFunction2DLattice.h.

Referenced by initialize_calc_factors(), and interferenceForXi().

◆ m_qx

double InterferenceFunction2DLattice::m_qx
mutableprivate

Definition at line 82 of file InterferenceFunction2DLattice.h.

Referenced by iff_without_dw(), and interferenceForXi().

◆ m_qy

double InterferenceFunction2DLattice::m_qy
mutableprivate

Definition at line 83 of file InterferenceFunction2DLattice.h.

Referenced by iff_without_dw(), and interferenceForXi().

◆ m_position_var

◆ m_parent

const INode* INode::m_parent {nullptr}
privateinherited

Definition at line 81 of file INode.h.

Referenced by INode::displayName(), INode::parent(), and INode::setParent().

◆ m_NP

const size_t INode::m_NP
protectedinherited

Definition at line 86 of file INode.h.

Referenced by INode::INode().

◆ m_P

std::vector<double> INode::m_P
protectedinherited

Definition at line 87 of file INode.h.

Referenced by INode::INode(), and IFootprintFactor::setWidthRatio().

◆ m_name

std::string IParameterized::m_name
privateinherited

Definition at line 72 of file IParameterized.h.

Referenced by IParameterized::getName(), and IParameterized::setName().

◆ m_pool

std::unique_ptr<ParameterPool> IParameterized::m_pool
privateinherited

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