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

Description

Interference function of a 3D lattice.

Definition at line 26 of file Interference3DLattice.h.

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

Public Member Functions

 Interference3DLattice (const Lattice3D &lattice)
 
 ~Interference3DLattice () 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...
 
Interference3DLatticeclone () const override
 
double DWfactor (R3 q) const
 structureFactors the Debye-Waller factor for a given wavevector transfer More...
 
const Lattice3Dlattice () const
 
std::vector< const INode * > nodeChildren () const override
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
virtual std::vector< ParaMetaparDefs () const
 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 setPeakShape (const IPeakShape &peak_shape)
 
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...
 
virtual double structureFactor (R3 q, double outer_iff=1.0) const
 The interference function for a given wavevector transfer. More...
 
bool supportsMultilayer () const override
 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...
 

Private Attributes

Lattice3D m_lattice
 
std::unique_ptr< IPeakShapem_peak_shape
 
double m_rec_radius
 radius in reciprocal space defining the nearest q vectors to use More...
 

Constructor & Destructor Documentation

◆ Interference3DLattice()

Interference3DLattice::Interference3DLattice ( const Lattice3D lattice)

Definition at line 21 of file Interference3DLattice.cpp.

22  : IInterference(0)
24  , m_peak_shape(nullptr)
25  , m_rec_radius(0.0)
26 {
27  R3 a1 = m_lattice.basisVectorA();
28  R3 a2 = m_lattice.basisVectorB();
29  R3 a3 = m_lattice.basisVectorC();
30 
31  m_rec_radius = std::max(M_PI / a1.mag(), M_PI / a2.mag());
32  m_rec_radius = std::max(m_rec_radius, M_PI / a3.mag());
33 }
#define M_PI
Definition: Constants.h:44
IInterference(const std::vector< double > &PValues)
double m_rec_radius
radius in reciprocal space defining the nearest q vectors to use
const Lattice3D & lattice() const
std::unique_ptr< IPeakShape > m_peak_shape
R3 basisVectorB() const
Returns basis vector b.
Definition: Lattice3D.h:46
R3 basisVectorC() const
Returns basis vector c.
Definition: Lattice3D.h:49
R3 basisVectorA() const
Returns basis vector a.
Definition: Lattice3D.h:43

References Lattice3D::basisVectorA(), Lattice3D::basisVectorB(), Lattice3D::basisVectorC(), m_lattice, M_PI, and m_rec_radius.

Referenced by clone().

Here is the call graph for this function:

◆ ~Interference3DLattice()

Interference3DLattice::~Interference3DLattice ( )
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 Interference3DLattice::className ( ) const
inlinefinalvirtual

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

Implements INode.

Definition at line 32 of file Interference3DLattice.h.

32 { return "Interference3DLattice"; }

◆ clone()

Interference3DLattice * Interference3DLattice::clone ( ) const
overridevirtual

Implements IInterference.

Definition at line 37 of file Interference3DLattice.cpp.

38 {
39  auto* result = new Interference3DLattice(m_lattice);
40  result->setPositionVariance(m_position_var);
41  if (m_peak_shape)
42  result->setPeakShape(*m_peak_shape);
43  return result;
44 }
double m_position_var
Definition: IInterference.h:53
Interference3DLattice(const Lattice3D &lattice)

References Interference3DLattice(), m_lattice, m_peak_shape, and IInterference::m_position_var.

Here is the call graph for this function:

◆ 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 Interference2DSuperLattice::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()

double Interference3DLattice::iff_without_dw ( R3  q) const
overrideprivatevirtual

Calculates the structure factor without Debye-Waller factor.

Implements IInterference.

Definition at line 61 of file Interference3DLattice.cpp.

62 {
64  R3 center = q;
65  double radius = 2.1 * m_rec_radius;
66  // double inner_radius = 0.0;
67  // if (m_peak_shape->angularDisorder()) {
68  // center = R3(0.0, 0.0, 0.0);
69  // inner_radius = std::max(0.0, q.mag() - radius);
70  // radius += q.mag();
71  // }
72  const auto rec_vectors = m_lattice.reciprocalLatticeVectorsWithinRadius(center, radius);
73  // std::cout << "IWD: q=" << q << ", r=" << radius << ", ir=" << inner_radius <<
74  // ", disordered=" << m_peak_shape->angularDisorder() << " => nVec=" << rec_vectors.size()
75  // << std::endl;
76 
77  double result = 0.0;
78  for (const auto& q_rec : rec_vectors)
79  // if (!(q_rec.mag() < inner_radius)) {
80  // result += m_peak_shape->evaluate(q, q_rec);
81  result += exp(-(q - q_rec).mag2() / 2 / pow(.06, 2));
82  // std::cout << " INCR: qr=" << q_rec << " => " << result << std::endl;
83  // }
84  return result;
85 }
std::vector< R3 > reciprocalLatticeVectorsWithinRadius(R3 q, double dq) const
Returns a list of reciprocal lattice vectors within distance dq of a vector q.
Definition: Lattice3D.cpp:75

References ASSERT, m_lattice, m_peak_shape, m_rec_radius, and Lattice3D::reciprocalLatticeVectorsWithinRadius().

Here is the call graph for this function:

◆ lattice()

const Lattice3D & Interference3DLattice::lattice ( ) const

Definition at line 51 of file Interference3DLattice.cpp.

52 {
53  return m_lattice;
54 }

References m_lattice.

◆ nodeChildren()

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

Returns all children.

Reimplemented from INode.

Definition at line 56 of file Interference3DLattice.cpp.

57 {
58  return {};
59 }

◆ 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()

virtual std::vector<ParaMeta> INode::parDefs ( ) const
inlinevirtualinherited

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

Reimplemented in ConstantBackground, GaussSphere, FuzzySphere, RotationEuler, RotationZ, RotationY, RotationX, Crystal, Layer, HexagonalLattice2D, SquareLattice2D, BasicLattice2D, LayerRoughness, TruncatedSpheroid, TruncatedSphere, TruncatedCube, Spheroid, Sphere, SawtoothRippleLorentz, SawtoothRippleGauss, SawtoothRippleBox, Pyramid6, Pyramid4, Pyramid3, Pyramid2, Prism6, Prism3, PlatonicTetrahedron, PlatonicOctahedron, LongBoxLorentz, LongBoxGauss, Icosahedron, HorizontalCylinder, HollowSphere, HemiEllipsoid, EllipsoidalCylinder, Dodecahedron, Cylinder, CosineRippleLorentz, CosineRippleGauss, CosineRippleBox, Cone, CantellatedCube, Box, Bipyramid4, BarLorentz, BarGauss, Profile2DVoigt, Profile2DCone, Profile2DGate, Profile2DGauss, Profile2DCauchy, Profile1DVoigt, Profile1DCosine, Profile1DTriangle, Profile1DGate, Profile1DGauss, Profile1DCauchy, MisesGaussPeakShape, MisesFisherGaussPeakShape, LorentzFisherPeakShape, GaussFisherPeakShape, IsotropicLorentzPeakShape, IsotropicGaussPeakShape, ParticleLayout, InterferenceTwin, InterferenceRadialParaCrystal, InterferenceHardDisk, Interference2DSuperLattice, Interference2DParaCrystal, Interference1DLattice, DistributionTrapezoid, DistributionCosine, DistributionLogNormal, DistributionGaussian, DistributionLorentz, DistributionGate, ResolutionFunction2DGaussian, PolFilter, FootprintSquare, and FootprintGauss.

Definition at line 51 of file INode.h.

51 { return {}; }

Referenced by INode::checkNodeArgs(), and IFormFactor::pythonConstructor().

◆ 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.

◆ setPeakShape()

void Interference3DLattice::setPeakShape ( const IPeakShape peak_shape)

Definition at line 46 of file Interference3DLattice.cpp.

47 {
48  m_peak_shape.reset(peak_shape.clone());
49 }
IPeakShape * clone() const override=0

References IPeakShape::clone(), and m_peak_shape.

Here is the call graph for this function:

◆ 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().

◆ structureFactor()

double IInterference::structureFactor ( R3  q,
double  outer_iff = 1.0 
) const
virtualinherited

The interference function for a given wavevector transfer.

Reimplemented in Interference2DSuperLattice.

Definition at line 35 of file IInterference.cpp.

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

References IInterference::iff_no_inner().

Here is the call graph for this function:

◆ supportsMultilayer()

bool Interference3DLattice::supportsMultilayer ( ) const
inlineoverridevirtual

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

Reimplemented from IInterference.

Definition at line 38 of file Interference3DLattice.h.

38 { return false; }

◆ 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_lattice

Lattice3D Interference3DLattice::m_lattice
private

Definition at line 45 of file Interference3DLattice.h.

Referenced by Interference3DLattice(), clone(), iff_without_dw(), and lattice().

◆ m_P

◆ m_peak_shape

std::unique_ptr<IPeakShape> Interference3DLattice::m_peak_shape
private

Definition at line 46 of file Interference3DLattice.h.

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

◆ m_position_var

◆ m_rec_radius

double Interference3DLattice::m_rec_radius
private

radius in reciprocal space defining the nearest q vectors to use

Definition at line 47 of file Interference3DLattice.h.

Referenced by Interference3DLattice(), and iff_without_dw().


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