BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Interference2DSuperLattice Class Reference

Description

Interference function of a 2D superlattice with a configurable interference function for each lattice site.

Definition at line 25 of file Interference2DSuperLattice.h.

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

Public Member Functions

 Interference2DSuperLattice (const Lattice2D &lattice, unsigned size_1, unsigned size_2)
 
 Interference2DSuperLattice (double length_1, double length_2, double alpha, double xi, unsigned size_1, unsigned size_2)
 Constructor of two-dimensional interference function. More...
 
 ~Interference2DSuperLattice () override
 
void checkNodeArgs () const
 Raises exception if a parameter value is invalid. More...
 
std::string className () const final
 Returns the class name, to be hard-coded in each leaf class that inherits from INode. More...
 
Interference2DSuperLatticeclone () const override
 
unsigned domainSize1 () const
 
unsigned domainSize2 () const
 
double DWfactor (R3 q) const
 structureFactors the Debye-Waller factor for a given wavevector transfer More...
 
bool integrationOverXi () const
 
const Lattice2Dlattice () const
 
std::vector< const INode * > nodeChildren () const override
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
std::vector< ParaMetaparDefs () const final
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
virtual double particleDensity () const
 If defined by this interference function's parameters, returns the particle density (per area). Otherwise, returns zero or a user-defined value. More...
 
double positionVariance () const
 Returns the position variance. More...
 
void setIntegrationOverXi (bool integrate_xi)
 
void setPositionVariance (double var)
 Sets the variance of the position for the calculation of the DW factor It is defined as the variance in each relevant dimension. More...
 
void setSubstructureIFF (const IInterference &sub_iff)
 
double structureFactor (R3 q, double outer_iff=1.0) const override
 The interference function for a given wavevector transfer. More...
 
const IInterferencesubstructureIFF () const
 
virtual bool supportsMultilayer () const
 Indicates if this interference function can be used with a sample (DWBA mode) More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 

Protected Member Functions

double iff_no_inner (R3 q, double outer_iff) const
 Calculates the structure factor in the absence of extra inner structure. More...
 

Protected Attributes

std::vector< double > m_P
 
double m_position_var
 

Private Member Functions

double iff_without_dw (R3 q) const override
 Calculates the structure factor without Debye-Waller factor. More...
 
double iff_without_dw (R3 q, double xi) const
 
double interferenceForXi (double xi, double qx, double qy, double outer_iff) const
 

Private Attributes

bool m_integrate_xi
 Integrate over the orientation xi. More...
 
std::unique_ptr< Lattice2Dm_lattice
 
unsigned m_size_1
 
unsigned m_size_2
 Size of the finite lattice in lattice units. More...
 
std::unique_ptr< IInterferencem_substructure
 IFF of substructure. More...
 

Constructor & Destructor Documentation

◆ Interference2DSuperLattice() [1/2]

Interference2DSuperLattice::Interference2DSuperLattice ( const Lattice2D lattice,
unsigned  size_1,
unsigned  size_2 
)

Definition at line 24 of file Interference2DSuperLattice.cpp.

26  : IInterference(0)
27  , m_integrate_xi(false)
28  , m_substructure(nullptr)
29  , m_size_1(size_1)
30  , m_size_2(size_2)
31 {
32  m_lattice.reset(lattice.clone());
34 }
IInterference(const std::vector< double > &PValues)
void setSubstructureIFF(const IInterference &sub_iff)
std::unique_ptr< IInterference > m_substructure
IFF of substructure.
unsigned m_size_2
Size of the finite lattice in lattice units.
bool m_integrate_xi
Integrate over the orientation xi.
std::unique_ptr< Lattice2D > m_lattice
Default interference function (i.e. absence of any interference).
Lattice2D * clone() const override=0

References Lattice2D::clone(), lattice(), m_lattice, and setSubstructureIFF().

Referenced by clone().

Here is the call graph for this function:

◆ Interference2DSuperLattice() [2/2]

Interference2DSuperLattice::Interference2DSuperLattice ( double  length_1,
double  length_2,
double  alpha,
double  xi,
unsigned  size_1,
unsigned  size_2 
)

Constructor of two-dimensional interference function.

Parameters
length_1length of first lattice vector in nanometers
length_2length of second lattice vector in nanometers
alphaangle between lattice vectors in radians
xirotation of lattice with respect to x-axis (beam direction) in radians
size_1correlation length in direction 1
size_2correlation length in direction 2

Definition at line 43 of file Interference2DSuperLattice.cpp.

46  : Interference2DSuperLattice(BasicLattice2D(length_1, length_2, alpha, xi), size_1, size_2)
47 {
48 }
A two-dimensional Bravais lattice with no special symmetry.
Definition: Lattice2D.h:51
Interference2DSuperLattice(const Lattice2D &lattice, unsigned size_1, unsigned size_2)

◆ ~Interference2DSuperLattice()

Interference2DSuperLattice::~Interference2DSuperLattice ( )
overridedefault

Member Function Documentation

◆ checkNodeArgs()

void INode::checkNodeArgs ( ) const
inherited

Raises exception if a parameter value is invalid.

Definition at line 27 of file INode.cpp.

28 {
29  size_t nP = m_P.size();
30  if (parDefs().size() != nP) {
31  std::cerr << "BUG in class " << className() << std::endl;
32  std::cerr << "#m_P = " << nP << std::endl;
33  std::cerr << "#PDf = " << parDefs().size() << std::endl;
34  for (const ParaMeta& pm : parDefs())
35  std::cerr << " PDf: " << pm.name << std::endl;
36  ASSERT(0);
37  }
38  ASSERT(parDefs().size() == nP);
39  for (size_t i = 0; i < nP; ++i) {
40  const ParaMeta pm = parDefs()[i];
41 
43  if (pm.vMin == -INF) {
44  ASSERT(pm.vMax == +INF);
45  // nothing to do
46  } else if (pm.vMax == +INF) {
47  ASSERT(pm.vMin == 0);
48  limits = RealLimits::nonnegative();
49  } else {
50  limits = RealLimits::limited(pm.vMin, pm.vMax);
51  }
52  limits.check(pm.name, m_P[i]);
53  }
54 }
#define ASSERT(condition)
Definition: Assert.h:45
const double INF
Definition: INode.h:26
virtual std::vector< ParaMeta > parDefs() const
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: INode.h:51
std::vector< double > m_P
Definition: INode.h:63
virtual std::string className() const =0
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Limits for a real fit parameter.
Definition: RealLimits.h:24
static RealLimits limitless()
Creates an object without bounds (default)
Definition: RealLimits.cpp:139
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
Definition: RealLimits.cpp:170
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
Definition: RealLimits.cpp:124
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Definition: RealLimits.cpp:134
Metadata of one model parameter.
Definition: INode.h:29
double vMin
Definition: INode.h:33
double vMax
Definition: INode.h:34
std::string name
Definition: INode.h:30

References ASSERT, RealLimits::check(), INode::className(), INF, RealLimits::limited(), RealLimits::limitless(), INode::m_P, ParaMeta::name, RealLimits::nonnegative(), INode::parDefs(), ParaMeta::vMax, and ParaMeta::vMin.

Referenced by BarGauss::BarGauss(), BarLorentz::BarLorentz(), Bipyramid4::Bipyramid4(), Box::Box(), CantellatedCube::CantellatedCube(), Cone::Cone(), ConstantBackground::ConstantBackground(), CosineRippleBox::CosineRippleBox(), CosineRippleGauss::CosineRippleGauss(), CosineRippleLorentz::CosineRippleLorentz(), Cylinder::Cylinder(), DistributionCosine::DistributionCosine(), DistributionGate::DistributionGate(), DistributionGaussian::DistributionGaussian(), DistributionLogNormal::DistributionLogNormal(), DistributionLorentz::DistributionLorentz(), DistributionTrapezoid::DistributionTrapezoid(), Dodecahedron::Dodecahedron(), EllipsoidalCylinder::EllipsoidalCylinder(), FootprintGauss::FootprintGauss(), FootprintSquare::FootprintSquare(), FuzzySphere::FuzzySphere(), GaussSphere::GaussSphere(), HemiEllipsoid::HemiEllipsoid(), HollowSphere::HollowSphere(), HorizontalCylinder::HorizontalCylinder(), Icosahedron::Icosahedron(), LongBoxGauss::LongBoxGauss(), LongBoxLorentz::LongBoxLorentz(), PlatonicOctahedron::PlatonicOctahedron(), PlatonicTetrahedron::PlatonicTetrahedron(), Prism3::Prism3(), Prism6::Prism6(), Profile1DCauchy::Profile1DCauchy(), Profile1DCosine::Profile1DCosine(), Profile1DGate::Profile1DGate(), Profile1DGauss::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), Profile2DVoigt::Profile2DVoigt(), Pyramid2::Pyramid2(), Pyramid3::Pyramid3(), Pyramid4::Pyramid4(), Pyramid6::Pyramid6(), RotationEuler::RotationEuler(), RotationX::RotationX(), RotationY::RotationY(), RotationZ::RotationZ(), SawtoothRippleBox::SawtoothRippleBox(), SawtoothRippleGauss::SawtoothRippleGauss(), SawtoothRippleLorentz::SawtoothRippleLorentz(), Sphere::Sphere(), Spheroid::Spheroid(), TruncatedCube::TruncatedCube(), TruncatedSphere::TruncatedSphere(), and TruncatedSpheroid::TruncatedSpheroid().

Here is the call graph for this function:

◆ className()

std::string Interference2DSuperLattice::className ( ) const
inlinefinalvirtual

Returns the class name, to be hard-coded in each leaf class that inherits from INode.

Implements INode.

Definition at line 33 of file Interference2DSuperLattice.h.

33 { return "Interference2DSuperLattice"; }

◆ clone()

Interference2DSuperLattice * Interference2DSuperLattice::clone ( ) const
overridevirtual

Implements IInterference.

Definition at line 52 of file Interference2DSuperLattice.cpp.

53 {
55  result->setPositionVariance(m_position_var);
56  result->setSubstructureIFF(*m_substructure);
57  result->setIntegrationOverXi(integrationOverXi());
58  return result;
59 }
double m_position_var
Definition: IInterference.h:53

References Interference2DSuperLattice(), integrationOverXi(), m_lattice, IInterference::m_position_var, m_size_1, m_size_2, and m_substructure.

Here is the call graph for this function:

◆ domainSize1()

unsigned Interference2DSuperLattice::domainSize1 ( ) const
inline

Definition at line 46 of file Interference2DSuperLattice.h.

46 { return m_size_1; }

References m_size_1.

◆ domainSize2()

unsigned Interference2DSuperLattice::domainSize2 ( ) const
inline

Definition at line 47 of file Interference2DSuperLattice.h.

47 { return m_size_2; }

References m_size_2.

◆ DWfactor()

double IInterference::DWfactor ( R3  q) const
inherited

structureFactors the Debye-Waller factor for a given wavevector transfer

Definition at line 48 of file IInterference.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 }
virtual bool supportsMultilayer() const
Indicates if this interference function can be used with a sample (DWBA mode)
Definition: IInterference.h:47

References IInterference::m_position_var, and IInterference::supportsMultilayer().

Referenced by IInterference::iff_no_inner(), and interferenceForXi().

Here is the call graph for this function:

◆ iff_no_inner()

double IInterference::iff_no_inner ( R3  q,
double  outer_iff 
) const
protectedinherited

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

Definition at line 56 of file IInterference.cpp.

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

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

Referenced by IInterference::structureFactor().

Here is the call graph for this function:

◆ iff_without_dw() [1/2]

double Interference2DSuperLattice::iff_without_dw ( R3  q) const
overrideprivatevirtual

Calculates the structure factor without Debye-Waller factor.

Implements IInterference.

Definition at line 100 of file Interference2DSuperLattice.cpp.

101 {
102  ASSERT(0);
103 }

References ASSERT.

Referenced by interferenceForXi().

◆ iff_without_dw() [2/2]

double Interference2DSuperLattice::iff_without_dw ( R3  q,
double  xi 
) const
private

Definition at line 105 of file Interference2DSuperLattice.cpp.

106 {
107  using Math::Laue;
108 
109  const double a = m_lattice->length1();
110  const double b = m_lattice->length2();
111  const double xialpha = xi + m_lattice->latticeAngle();
112 
113  const double qadiv2 = (q.x() * a * std::cos(xi) + q.y() * a * std::sin(xi)) / 2.0;
114  const double qbdiv2 = (q.x() * b * std::cos(xialpha) + q.y() * b * std::sin(xialpha)) / 2.0;
115  const double ampl = Laue(qadiv2, m_size_1) * Laue(qbdiv2, m_size_2);
116  return ampl * ampl / (m_size_1 * m_size_2);
117 }
double Laue(double x, size_t N)
Real Laue function: .
Definition: Functions.cpp:77

References Math::Laue(), m_lattice, m_size_1, and m_size_2.

Here is the call graph for this function:

◆ integrationOverXi()

bool Interference2DSuperLattice::integrationOverXi ( ) const
inline

Definition at line 50 of file Interference2DSuperLattice.h.

50 { return m_integrate_xi; }

References m_integrate_xi.

Referenced by clone().

◆ interferenceForXi()

double Interference2DSuperLattice::interferenceForXi ( double  xi,
double  qx,
double  qy,
double  outer_iff 
) const
private

Definition at line 119 of file Interference2DSuperLattice.cpp.

121 {
122  const R3 q = R3(qx, qy, 0.0);
123  const double sub_iff = DWfactor(q) * (iff_without_dw(q, xi) * outer_iff - 1.0) + 1.0;
124  const double delta_xi = xi - m_lattice->rotationAngle();
125  return m_substructure->structureFactor(q.rotatedZ(-delta_xi), sub_iff);
126 }
double iff_without_dw(R3 q) const override
Calculates the structure factor without Debye-Waller factor.

References IInterference::DWfactor(), iff_without_dw(), m_lattice, and m_substructure.

Referenced by structureFactor().

Here is the call graph for this function:

◆ lattice()

const Lattice2D & Interference2DSuperLattice::lattice ( ) const

Definition at line 87 of file Interference2DSuperLattice.cpp.

88 {
89  if (!m_lattice)
90  throw std::runtime_error("InterferenceFinite2DLattice::lattice() -> Error. "
91  "No lattice defined.");
92  return *m_lattice;
93 }

References m_lattice.

Referenced by Interference2DSuperLattice().

◆ nodeChildren()

std::vector< const INode * > Interference2DSuperLattice::nodeChildren ( ) const
overridevirtual

Returns all children.

Reimplemented from INode.

Definition at line 95 of file Interference2DSuperLattice.cpp.

96 {
97  return std::vector<const INode*>() << m_lattice << m_substructure;
98 }

References m_lattice, and m_substructure.

◆ nodeOffspring()

std::vector< const INode * > INode::nodeOffspring ( ) const
inherited

Returns all descendants.

Definition at line 61 of file INode.cpp.

62 {
63  std::vector<const INode*> result;
64  result.push_back(this);
65  for (const auto* child : nodeChildren()) {
66  for (const auto* p : child->nodeOffspring())
67  result.push_back(p);
68  }
69  return result;
70 }
virtual std::vector< const INode * > nodeChildren() const
Returns all children.
Definition: INode.cpp:56

References INode::nodeChildren().

Here is the call graph for this function:

◆ parDefs()

std::vector<ParaMeta> Interference2DSuperLattice::parDefs ( ) const
inlinefinalvirtual

Returns the parameter definitions, to be hard-coded in each leaf class.

Reimplemented from INode.

Definition at line 34 of file Interference2DSuperLattice.h.

35  {
36  return {{"Length1", "nm", "lattice constant 1", 0, +INF, 0},
37  {"Length2", "nm", "lattice constant 2", 0, +INF, 0},
38  {"Alpha", "rad", "angle between lattice vectors 1 and 2", -INF, +INF, 0},
39  {"Xi", "rad", "angle between x axis and lattice vector 1", -INF, +INF, 0}};
40  }

References INF.

◆ particleDensity()

virtual double IInterference::particleDensity ( ) const
inlinevirtualinherited

If defined by this interference function's parameters, returns the particle density (per area). Otherwise, returns zero or a user-defined value.

Reimplemented in InterferenceHardDisk, InterferenceFinite2DLattice, Interference2DParaCrystal, and Interference2DLattice.

Definition at line 44 of file IInterference.h.

44 { return 0.0; }

◆ positionVariance()

double IInterference::positionVariance ( ) const
inlineinherited

Returns the position variance.

Definition at line 40 of file IInterference.h.

40 { return m_position_var; }

References IInterference::m_position_var.

◆ setIntegrationOverXi()

void Interference2DSuperLattice::setIntegrationOverXi ( bool  integrate_xi)

Definition at line 81 of file Interference2DSuperLattice.cpp.

82 {
83  m_integrate_xi = integrate_xi;
84  m_lattice->setRotationEnabled(!m_integrate_xi); // deregister Xi in the case of integration
85 }

References m_integrate_xi, and m_lattice.

◆ setPositionVariance()

void IInterference::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 IInterference.cpp.

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

References IInterference::m_position_var.

Referenced by ExemplarySamples::createFiniteSquareLattice2D(), and ExemplarySamples::createSuperLattice().

◆ setSubstructureIFF()

void Interference2DSuperLattice::setSubstructureIFF ( const IInterference sub_iff)

Definition at line 61 of file Interference2DSuperLattice.cpp.

62 {
63  m_substructure.reset(sub_iff.clone());
64 }
IInterference * clone() const override=0

References IInterference::clone(), and m_substructure.

Referenced by Interference2DSuperLattice(), and ExemplarySamples::createSuperLattice().

Here is the call graph for this function:

◆ structureFactor()

double Interference2DSuperLattice::structureFactor ( R3  q,
double  outer_iff = 1.0 
) const
overridevirtual

The interference function for a given wavevector transfer.

Reimplemented from IInterference.

Definition at line 71 of file Interference2DSuperLattice.cpp.

72 {
73  if (!m_integrate_xi)
74  return interferenceForXi(m_lattice->rotationAngle(), q.x(), q.y(), outer_iff);
75  return RealIntegrator().integrate(
76  [&](double xi) -> double { return interferenceForXi(xi, q.x(), q.y(), outer_iff); },
77  0.0, M_TWOPI)
78  / M_TWOPI;
79 }
#define M_TWOPI
Definition: Constants.h:54
double interferenceForXi(double xi, double qx, double qy, double outer_iff) const
To integrate a real function of a real variable.
Definition: IntegratorGK.h:28
double integrate(const std::function< double(double)> &f, double lmin, double lmax)

References RealIntegrator::integrate(), interferenceForXi(), m_integrate_xi, m_lattice, and M_TWOPI.

Here is the call graph for this function:

◆ substructureIFF()

const IInterference & Interference2DSuperLattice::substructureIFF ( ) const

Definition at line 66 of file Interference2DSuperLattice.cpp.

67 {
68  return *m_substructure;
69 }

References m_substructure.

◆ supportsMultilayer()

virtual bool IInterference::supportsMultilayer ( ) const
inlinevirtualinherited

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

Reimplemented in InterferenceFinite3DLattice, and Interference3DLattice.

Definition at line 47 of file IInterference.h.

47 { return true; }

Referenced by IInterference::DWfactor().

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

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

Definition at line 32 of file ICloneable.h.

Member Data Documentation

◆ m_integrate_xi

bool Interference2DSuperLattice::m_integrate_xi
private

Integrate over the orientation xi.

Definition at line 62 of file Interference2DSuperLattice.h.

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

◆ m_lattice

std::unique_ptr<Lattice2D> Interference2DSuperLattice::m_lattice
private

◆ m_P

◆ m_position_var

◆ m_size_1

unsigned Interference2DSuperLattice::m_size_1
private

Definition at line 65 of file Interference2DSuperLattice.h.

Referenced by clone(), domainSize1(), and iff_without_dw().

◆ m_size_2

unsigned Interference2DSuperLattice::m_size_2
private

Size of the finite lattice in lattice units.

Definition at line 65 of file Interference2DSuperLattice.h.

Referenced by clone(), domainSize2(), and iff_without_dw().

◆ m_substructure

std::unique_ptr<IInterference> Interference2DSuperLattice::m_substructure
private

IFF of substructure.

Definition at line 64 of file Interference2DSuperLattice.h.

Referenced by clone(), interferenceForXi(), nodeChildren(), setSubstructureIFF(), and substructureIFF().


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