Skip to content

Commit 9d79ce3

Browse files
committed
Skip FFT when not needed for PDF calculation.
Termination ripples do not appear in the PDF simulated at a very large Qmax. Skip Fourier Transformation as it makes no difference.
1 parent ac35a0c commit 9d79ce3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/diffpy/srreal/PDFCalculator.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,27 @@ QuantityType PDFCalculator::getF() const
130130

131131
QuantityType PDFCalculator::getExtendedPDF() const
132132
{
133-
// we need a full range PDF to apply termination ripples correctly
134133
QuantityType rgrid_ext = this->getExtendedRgrid();
134+
// Skip FFT when qmax is not specified and qmin does not exclude the
135+
// the F(Q=Qstep) point (excluding F(0) == 0 makes no difference to G).
136+
const bool skipfft =
137+
!eps_lt(this->getQmax(), M_PI / this->getRstep()) &&
138+
!(1 < pdfutils_qminSteps(this));
139+
if (skipfft)
140+
{
141+
QuantityType rdfpr = this->getExtendedRDFperR();
142+
QuantityType rdfprb = this->applyBaseline(rgrid_ext, rdfpr);
143+
QuantityType pdf = this->applyEnvelopes(rgrid_ext, rdfprb);
144+
return pdf;
145+
}
146+
// FFT required here
147+
// we need a full range PDF to apply termination ripples correctly
135148
QuantityType f_ext = this->getExtendedF();
136-
QuantityType pdf0 = fftftog(f_ext, this->getQstep());
149+
QuantityType pdf1 = fftftog(f_ext, this->getQstep());
137150
// cut away the FFT padded points
138-
assert(this->extendedRmaxSteps() <= int(pdf0.size()));
139-
QuantityType pdf1(pdf0.begin() + this->extendedRminSteps(),
140-
pdf0.begin() + this->extendedRmaxSteps());
151+
assert(this->extendedRmaxSteps() <= int(pdf1.size()));
152+
pdf1.erase(pdf1.begin() + this->extendedRmaxSteps(), pdf1.end());
153+
pdf1.erase(pdf1.begin(), pdf1.begin() + this->extendedRminSteps());
141154
QuantityType pdf2 = this->applyEnvelopes(rgrid_ext, pdf1);
142155
return pdf2;
143156
}

0 commit comments

Comments
 (0)