21 double damping_length,
double domain_size_1,
24 , m_integrate_xi(false)
25 , m_damping_length(damping_length)
69 return area == 0.0 ? 0.0 : 1.0 / area;
98 double delta,
double& q_pa_1,
101 q_pa_1 = qx * std::cos(
gamma) + qy * std::sin(
gamma);
102 q_pa_2 = qx * std::cos(
gamma + delta) + qy * std::sin(
gamma + delta);
119 throw std::runtime_error(
"Interference2DParaCrystal::"
120 "interference1D() -> Error! Index of interference function "
121 "probability must be < 2");
123 throw std::runtime_error(
"Interference2DParaCrystal::"
124 "interference1D() -> Error! Probability distributions for "
125 "interference function not properly initialized");
128 int n =
static_cast<int>(std::abs(
m_domain_sizes[index] / length));
129 auto nd =
static_cast<double>(n);
130 complex_t fp =
FTPDF(qx, qy, xi, index);
132 return ((1.0 + fp) / (1.0 - fp)).real();
133 if (std::norm(1.0 - fp) < std::numeric_limits<double>::epsilon())
136 if (std::abs(1.0 - fp) * nd < 2e-4) {
137 complex_t intermediate =
138 (nd - 1.0) / 2.0 + (nd * nd - 1.0) * (fp - 1.0) / 6.0
139 + (nd * nd * nd - 2.0 * nd * nd - nd + 2.0) * (fp - 1.0) * (fp - 1.0) / 24.0;
140 return 1.0 + 2.0 * intermediate.real();
143 if (std::abs(fp) == 0.0
144 || std::log(std::abs(fp)) * nd < std::log(std::numeric_limits<double>::min()))
147 tmp = std::pow(fp, n);
148 complex_t intermediate = fp / (1.0 - fp) - fp * (1.0 - tmp) / nd / (1.0 - fp) / (1.0 - fp);
149 return 1.0 + 2.0 * intermediate.real();
157 double qa = qx * length * std::cos(xi) + qy * length * std::sin(xi);
158 complex_t phase = exp_I(qa);
162 double delta = pdf->
delta();
165 complex_t result = phase * amplitude;
188 throw std::runtime_error(
"Interference2DParaCrystal::lattice() -> Error. "
189 "No lattice defined.");
Defines classes RealIntegrator, ComplexIntegrator.
Defines class Interference2DParaCrystal.
Defines class RealLimits.
Abstract base class of interference functions.
Interface for two-dimensional distributions in Fourier space.
double delta() const
Angle in direct space between X- and Y-axis of distribution.
IProfile2D * clone() const override=0
virtual double standardizedFT2D(double qx, double qy) const =0
Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) i...
Interference function of a 2D paracrystal.
~Interference2DParaCrystal() override
double interferenceForXi(double xi, double qx, double qy) const
Returns interference function for fixed angle xi.
Interference2DParaCrystal * clone() const override
bool m_integrate_xi
Integrate over the orientation xi.
std::unique_ptr< Lattice2D > m_lattice
double iff_without_dw(R3 q) const override
Calculates the structure factor without Debye-Waller factor.
const Lattice2D & lattice() const
double interference1D(double qx, double qy, double xi, size_t index) const
Returns interference function for fixed xi in the dimension determined by the given index.
std::vector< const INode * > nodeChildren() const override
Returns all children.
void setDampingLength(double damping_length)
Sets the damping length.
double m_domain_sizes[2]
Coherence domain sizes.
complex_t FTPDF(double qx, double qy, double xi, size_t index) const
double particleDensity() const override
If defined by this interference function's parameters, returns the particle density (per area)....
void transformToPrincipalAxes(double qx, double qy, double gamma, double delta, double &q_pa_1, double &q_pa_2) const
void setProbabilityDistributions(const IProfile2D &pdf_1, const IProfile2D &pdf_2)
Sets the probability distributions (Fourier transformed) for the two lattice directions.
Interference2DParaCrystal(const Lattice2D &lattice, double damping_length, double domain_size_1, double domain_size_2)
std::unique_ptr< IProfile2D > m_pdf1
std::unique_ptr< IProfile2D > m_pdf2
void setDomainSizes(double size_1, double size_2)
Sets the sizes of coherence domains.
double m_damping_length
Damping length for removing delta function singularity at q=0.
void setIntegrationOverXi(bool integrate_xi)
Enables/disables averaging over the lattice rotation angle.
std::vector< double > domainSizes() const
A two-dimensional Bravais lattice.
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)
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.