24 const int min_points = 4;
30 setName(
"Interference2DLattice");
44 ret->setDecayFunction(*
m_decay);
66 throw std::runtime_error(
"InterferenceFunction2DLattice::lattice() -> Error. "
67 "No lattice defined.");
74 return area == 0.0 ? 0.0 : 1.0 / area;
91 throw std::runtime_error(
"InterferenceFunction2DLattice::evaluate"
92 " -> Error! No decay function defined.");
107 for (
int i = -
m_na - 1; i <
m_na + 2; ++i) {
108 for (
int j = -
m_nb - 1; j <
m_nb + 2; ++j) {
120 throw std::runtime_error(
"InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint"
121 " -> Error! No decay function defined.");
122 double gamma =
m_decay->gamma();
124 return m_decay->evaluate(qXY.first, qXY.second);
131 double q_X = qx * std::cos(gamma) + qy * std::sin(gamma);
132 double q_Y = -qx * std::sin(gamma) + qy * std::cos(gamma);
139 std::pair<double, double>
145 double alpha =
m_lattice->latticeAngle();
147 double qx_rot = qx * std::cos(xi) + qy * std::sin(xi);
148 double qy_rot = -qx * std::sin(xi) + qy * std::cos(xi);
151 int qa_int =
static_cast<int>(std::lround(a * qx_rot /
M_TWOPI));
152 int qb_int =
static_cast<int>(
153 std::lround(b * (qx_rot * std::cos(alpha) + qy_rot * std::sin(alpha)) /
M_TWOPI));
157 return {qx_frac, qy_frac};
164 throw std::runtime_error(
"InterferenceFunction2DLattice::initialize_rec_vectors() -> "
165 "Error. No lattice defined yet");
175 throw std::runtime_error(
"InterferenceFunction2DLattice::initialize_calc_factors"
176 " -> Error! No decay function defined.");
179 auto q_bounds =
m_decay->boundingReciprocalLatticeCoordinates(
182 m_na =
static_cast<int>(std::lround(q_bounds.first + 0.5));
183 m_nb =
static_cast<int>(std::lround(q_bounds.second + 0.5));
Defines classes RealIntegrator, ComplexIntegrator.
Defines class InterferenceFunction2DLattice.
Defines class RealParameter.
A two-dimensional Bravais lattice with no special symmetry.
T y() const
Returns y-component in cartesian coordinate system.
T x() const
Returns x-component in cartesian coordinate system.
Interface for two-dimensional decay function in reciprocal space.
virtual IFTDecayFunction2D * clone() const =0
Abstract base class of interference functions.
void registerChild(INode *node)
void setName(const std::string &name)
Interference function of a 2D lattice.
void initialize_calc_factors()
Initializes factors needed in each calculation.
std::vector< const INode * > getChildren() const override
Returns a vector of children.
Lattice2D::ReciprocalBases m_sbase
reciprocal lattice is stored without xi
void initialize_rec_vectors()
Initializes the x,y coordinates of the a*,b* reciprocal bases.
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...
double getParticleDensity() const override
Returns the particle density associated with this 2d lattice.
~InterferenceFunction2DLattice() override
bool m_integrate_xi
Integrate over the orientation xi.
bool integrationOverXi() const
InterferenceFunction2DLattice(const Lattice2D &lattice)
void setIntegrationOverXi(bool integrate_xi)
std::pair< double, double > rotateOrthonormal(double qx, double qy, double gamma) const
Returns reciprocal coordinates in the coordinate system rotated by the angle gamma.
std::unique_ptr< IFTDecayFunction2D > m_decay
InterferenceFunction2DLattice * clone() const override
Returns a clone of this ISampleNode object.
int m_nb
determines the number of reciprocal lattice points to use
double iff_without_dw(const kvector_t q) const override
Calculates the structure factor without Debye-Waller factor.
double interferenceAtOneRecLatticePoint(double qx, double qy) const
Returns interference from a single reciprocal lattice vector.
std::unique_ptr< Lattice2D > m_lattice
void setDecayFunction(const IFTDecayFunction2D &decay)
Sets two-dimensional decay function.
void onChange() override
Action to be taken in inherited class when a parameter has changed.
const Lattice2D & lattice() const
double interferenceForXi(double xi) const
A two-dimensional Bravais lattice.
ReciprocalBases reciprocalBases() const
virtual Lattice2D * clone() const =0
To integrate a real function of a real variable.
double integrate(const std::function< double(double)> &f, double lmin, double lmax)
double m_asy
x,y coordinates of a*
double m_bsy
x,y coordinates of b*