26 const int min_points = 4;
28 std::pair<double, double> transformToRecLatticeCoordinates(
double qX,
double qY,
double a,
double b,
29 double alpha,
double gamma)
32 double qb = (b * qX * std::cos(alpha -
gamma) + b * qY * std::sin(alpha -
gamma)) /
M_TWOPI;
38 std::pair<double, double> boundingReciprocalLatticeCoordinates(
double qX,
double qY,
double a,
39 double b,
double alpha,
double gamma)
41 auto q_bounds_1 = transformToRecLatticeCoordinates(qX, qY, a, b, alpha,
gamma);
42 auto q_bounds_2 = transformToRecLatticeCoordinates(qX, -qY, a, b, alpha,
gamma);
43 double qa_max = std::max(std::abs(q_bounds_1.first), std::abs(q_bounds_2.first));
44 double qb_max = std::max(std::abs(q_bounds_1.second), std::abs(q_bounds_2.second));
45 return {qa_max, qb_max};
52 , m_integrate_xi(false)
56 throw std::runtime_error(
"Interference2DLattice::initialize_rec_vectors() -> "
57 "Error. No lattice defined yet");
72 result->setDecayFunction(*
m_decay);
82 throw std::runtime_error(
"Interference2DLattice::initialize_calc_factors"
83 " -> Error! No decay function defined.");
86 auto q_bounds = boundingReciprocalLatticeCoordinates(
89 m_na =
static_cast<int>(std::lround(q_bounds.first + 0.5));
90 m_nb =
static_cast<int>(std::lround(q_bounds.second + 0.5));
104 throw std::runtime_error(
"Interference2DLattice::lattice() -> Error. "
105 "No lattice defined.");
112 return area == 0.0 ? 0.0 : 1.0 / area;
123 throw std::runtime_error(
"Interference2DLattice::evaluate"
124 " -> Error! No decay function defined.");
138 for (
int i = -
m_na - 1; i <
m_na + 2; ++i) {
139 for (
int j = -
m_nb - 1; j <
m_nb + 2; ++j) {
151 throw std::runtime_error(
"Interference2DLattice::interferenceAtOneRecLatticePoint"
152 " -> Error! No decay function defined.");
155 return m_decay->decayFT2D(qXY.first, qXY.second);
162 double q_X = qx * std::cos(
gamma) + qy * std::sin(
gamma);
163 double q_Y = -qx * std::sin(
gamma) + qy * std::cos(
gamma);
170 std::pair<double, double>
175 double alpha =
m_lattice->latticeAngle();
177 double qx_rot = qx * std::cos(xi) + qy * std::sin(xi);
178 double qy_rot = -qx * std::sin(xi) + qy * std::cos(xi);
181 int qa_int =
static_cast<int>(std::lround(a * qx_rot /
M_TWOPI));
182 int qb_int =
static_cast<int>(
183 std::lround(b * (qx_rot * std::cos(alpha) + qy_rot * std::sin(alpha)) /
M_TWOPI));
187 return {qx_frac, qy_frac};
Defines classes RealIntegrator, ComplexIntegrator.
Defines class Interference2DLattice.
Defines interface class IProfile1D, and children thereof.
Defines interface class IProfile2D, and children thereof.
A two-dimensional Bravais lattice with no special symmetry.
Abstract base class of interference functions.
Interface for two-dimensional distributions in Fourier space.
IProfile2D * clone() const override=0
Interference function of a 2D lattice.
std::unique_ptr< Lattice2D > m_lattice
bool m_integrate_xi
Integrate over the orientation xi.
Interference2DLattice(const Lattice2D &lattice)
void setDecayFunction(const IProfile2D &decay)
Sets two-dimensional decay function.
std::pair< double, double > rotateOrthonormal(double qx, double qy, double gamma) const
Returns reciprocal coordinates in the coordinate system rotated by the angle gamma.
Interference2DLattice * clone() const override
bool integrationOverXi() const
const Lattice2D & lattice() const
std::vector< const INode * > nodeChildren() const override
Returns all children.
void setIntegrationOverXi(bool integrate_xi)
double iff_without_dw(R3 q) const override
Calculates the structure factor without Debye-Waller factor.
double interferenceForXi(double xi, double qx, double qy) const
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...
std::unique_ptr< IProfile2D > m_decay
int m_nb
determines the number of reciprocal lattice points to use
double interferenceAtOneRecLatticePoint(double qx, double qy) const
Returns interference from a single reciprocal lattice vector.
~Interference2DLattice() override
double particleDensity() const override
Returns the particle density associated with this 2d lattice.
A two-dimensional Bravais lattice.
ReciprocalBases reciprocalBases() const
Lattice2D * clone() const override=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*