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

Description

A two-dimensional Bravais lattice with no special symmetry.

Definition at line 51 of file Lattice2D.h.

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

Public Member Functions

 BasicLattice2D (double length1, double length2, double angle, double xi)
 
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...
 
BasicLattice2Dclone () const override
 
double latticeAngle () const override
 
double length1 () const override
 
double length2 () const override
 
virtual std::vector< const INode * > nodeChildren () const
 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...
 
ReciprocalBases reciprocalBases () const
 
double rotationAngle () const
 
void setRotationEnabled (bool enabled)
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
double unitCellArea () const override
 

Protected Attributes

std::vector< double > m_P
 
double m_xi
 

Private Attributes

double m_angle
 
double m_length1
 
double m_length2
 

Constructor & Destructor Documentation

◆ BasicLattice2D()

BasicLattice2D::BasicLattice2D ( double  length1,
double  length2,
double  angle,
double  xi 
)

Definition at line 56 of file Lattice2D.cpp.

57  : Lattice2D(xi)
60  , m_angle(angle)
61 {
62  if (m_length1 <= 0.0 || m_length2 <= 0.0)
63  throw std::runtime_error(
64  "BasicLattice2D::BasicLattice2D() -> Error. Lattice length can't be "
65  "negative or zero.");
66  RealLimits::positive().check("LatticeLength1", m_length1);
67  RealLimits::positive().check("LatticeLength2", m_length2);
68 }
double m_length1
Definition: Lattice2D.h:70
double length1() const override
Definition: Lattice2D.h:64
double m_length2
Definition: Lattice2D.h:70
double m_angle
Definition: Lattice2D.h:71
double length2() const override
Definition: Lattice2D.h:65
Lattice2D(const std::vector< double > &PValues)
Definition: Lattice2D.cpp:24
static RealLimits positive()
Creates an object which can have only positive values (>0., zero is not included)
Definition: RealLimits.cpp:119
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

References RealLimits::check(), m_length1, m_length2, and RealLimits::positive().

Referenced by clone().

Here is the call graph for this function:

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

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

Implements INode.

Definition at line 56 of file Lattice2D.h.

56 { return "BasicLattice2D"; }

◆ clone()

BasicLattice2D * BasicLattice2D::clone ( ) const
overridevirtual

Implements Lattice2D.

Definition at line 70 of file Lattice2D.cpp.

71 {
73 }
BasicLattice2D(double length1, double length2, double angle, double xi)
Definition: Lattice2D.cpp:56
double m_xi
Definition: Lattice2D.h:46

References BasicLattice2D(), m_angle, m_length1, m_length2, and Lattice2D::m_xi.

Here is the call graph for this function:

◆ latticeAngle()

double BasicLattice2D::latticeAngle ( ) const
inlineoverridevirtual

Implements Lattice2D.

Definition at line 66 of file Lattice2D.h.

66 { return m_angle; }

References m_angle.

◆ length1()

double BasicLattice2D::length1 ( ) const
inlineoverridevirtual

Implements Lattice2D.

Definition at line 64 of file Lattice2D.h.

64 { return m_length1; }

References m_length1.

◆ length2()

double BasicLattice2D::length2 ( ) const
inlineoverridevirtual

Implements Lattice2D.

Definition at line 65 of file Lattice2D.h.

65 { return m_length2; }

References m_length2.

◆ nodeChildren()

◆ 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> BasicLattice2D::parDefs ( ) const
inlinefinalvirtual

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

Reimplemented from INode.

Definition at line 57 of file Lattice2D.h.

58  {
59  return {{"Length1", "nm", "lattice constant 1", 0, +INF, 0},
60  {"Length2", "nm", "lattice constant 2", 0, +INF, 0},
61  {"Alpha", "rad", "angle between lattice vectors 1 and 2", -INF, +INF, 0}};
62  }

References INF.

◆ reciprocalBases()

Lattice2D::ReciprocalBases Lattice2D::reciprocalBases ( ) const
inherited

Definition at line 34 of file Lattice2D.cpp.

35 {
36  const double sinalpha = std::sin(latticeAngle());
37  const double ainv = M_TWOPI / length1() / sinalpha;
38  const double binv = M_TWOPI / length2() / sinalpha;
39  const double xi = rotationAngle();
40  const double xialpha = xi + latticeAngle();
41 
42  return {+ainv * std::sin(xialpha), -ainv * std::cos(xialpha), -binv * std::sin(xi),
43  +binv * std::cos(xi)};
44 }
#define M_TWOPI
Definition: Constants.h:54
double rotationAngle() const
Definition: Lattice2D.h:39
virtual double latticeAngle() const =0
virtual double length2() const =0
virtual double length1() const =0

References Lattice2D::latticeAngle(), Lattice2D::length1(), Lattice2D::length2(), M_TWOPI, and Lattice2D::rotationAngle().

Referenced by Interference2DLattice::Interference2DLattice().

Here is the call graph for this function:

◆ rotationAngle()

double Lattice2D::rotationAngle ( ) const
inlineinherited

Definition at line 39 of file Lattice2D.h.

39 { return m_xi; }

References Lattice2D::m_xi.

Referenced by Lattice2D::reciprocalBases().

◆ setRotationEnabled()

void Lattice2D::setRotationEnabled ( bool  enabled)
inherited

Definition at line 46 of file Lattice2D.cpp.

47 {
48  // #bapool enabling/disabling was done by register/unregister m_xi. Any equivalent
49  // implementation necessary?
50 }

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

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

Definition at line 32 of file ICloneable.h.

◆ unitCellArea()

double BasicLattice2D::unitCellArea ( ) const
overridevirtual

Implements Lattice2D.

Definition at line 75 of file Lattice2D.cpp.

76 {
77  return std::abs(m_length1 * m_length2 * std::sin(m_angle));
78 }

References m_angle, m_length1, and m_length2.

Member Data Documentation

◆ m_angle

double BasicLattice2D::m_angle
private

Definition at line 71 of file Lattice2D.h.

Referenced by clone(), latticeAngle(), and unitCellArea().

◆ m_length1

double BasicLattice2D::m_length1
private

Definition at line 70 of file Lattice2D.h.

Referenced by BasicLattice2D(), clone(), length1(), and unitCellArea().

◆ m_length2

double BasicLattice2D::m_length2
private

Definition at line 70 of file Lattice2D.h.

Referenced by BasicLattice2D(), clone(), length2(), and unitCellArea().

◆ m_P

◆ m_xi

double Lattice2D::m_xi
protectedinherited

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