diff --git a/Framework/Algorithms/src/PDFFourierTransform.cpp b/Framework/Algorithms/src/PDFFourierTransform.cpp index 38aca68442fe87b5fe17e61462dcbabd3e439276..9f5c9f5b45d1bc805eafa28604d8d3639903330c 100644 --- a/Framework/Algorithms/src/PDFFourierTransform.cpp +++ b/Framework/Algorithms/src/PDFFourierTransform.cpp @@ -166,12 +166,11 @@ void PDFFourierTransform::exec() { // nothing to do } else if (inputXunit == "dSpacing") { // convert the x-units to Q/MomentumTransfer + const double PI_2(2. * M_PI); + std::for_each(inputQ.begin(), inputQ.end(), + [&PI_2](double &Q) { Q /= PI_2; }); std::transform(inputDQ.begin(), inputDQ.end(), inputQ.begin(), inputDQ.begin(), std::divides<double>()); - const double PI_2(2. * M_PI); - std::transform(inputQ.begin(), inputQ.end(), inputQ.begin(), - std::bind1st(std::divides<double>(), PI_2)); - // reverse all of the arrays std::reverse(inputQ.begin(), inputQ.end()); std::reverse(inputDQ.begin(), inputDQ.end()); @@ -209,8 +208,7 @@ void PDFFourierTransform::exec() { if (soqType == S_OF_Q) { g_log.information() << "Subtracting one from all values\n"; // there is no error propagation for subtracting one - std::transform(inputFOfQ.begin(), inputFOfQ.end(), inputFOfQ.begin(), - std::bind2nd(std::minus<double>(), 1.)); + std::for_each(inputFOfQ.begin(), inputFOfQ.end(), [](double &F) { F--; }); soqType = S_OF_Q_MINUS_ONE; } if (soqType == S_OF_Q_MINUS_ONE) { @@ -316,8 +314,7 @@ void PDFFourierTransform::exec() { sinus *= sin(q * rdelta) / (q * rdelta); } fs += sinus * inputFOfQ[q_index]; - error += - q * q * (sinus * inputDfOfQ[q_index]) * (sinus * inputDfOfQ[q_index]); + error += (sinus * inputDfOfQ[q_index]) * (sinus * inputDfOfQ[q_index]); // g_log.debug() << "q[" << i << "] = " << q << " dq = " << deltaq << " // S(q) =" << s; // g_log.debug() << " d(gr) = " << temp << " gr = " << gr << std::endl; @@ -325,7 +322,7 @@ void PDFFourierTransform::exec() { // put the information into the output outputY[r_index] = fs * 2 / M_PI; - outputE[r_index] = error * 2 / M_PI; // TODO: Wrong! + outputE[r_index] = sqrt(error) * 2 / M_PI; } // convert to the correct form of PDF @@ -348,7 +345,7 @@ void PDFFourierTransform::exec() { } else if (pdfType == LITTLE_G_OF_R) { const double factor = 1. / (4. * M_PI * rho0); for (size_t i = 0; i < outputY.size(); ++i) { - // error propogation - assuming uncertainty in r = 0 + // error propagation - assuming uncertainty in r = 0 outputE[i] = outputE[i] / outputR[i]; // transform the data outputY[i] = 1. + factor * outputY[i] / outputR[i]; @@ -356,7 +353,7 @@ void PDFFourierTransform::exec() { } else if (pdfType == RDF_OF_R) { const double factor = 4. * M_PI * rho0; for (size_t i = 0; i < outputY.size(); ++i) { - // error propogation - assuming uncertainty in r = 0 + // error propagation - assuming uncertainty in r = 0 outputE[i] = outputE[i] * outputR[i]; // transform the data outputY[i] = outputR[i] * outputY[i] + factor * outputR[i] * outputR[i]; diff --git a/docs/source/algorithms/PDFFourierTransform-v1.rst b/docs/source/algorithms/PDFFourierTransform-v1.rst index 797e1b5adf0be8a915a6217164c80d5e2b2e634a..09c89f6d141eb5d6d5ac3c5672f121e024d7b615 100644 --- a/docs/source/algorithms/PDFFourierTransform-v1.rst +++ b/docs/source/algorithms/PDFFourierTransform-v1.rst @@ -17,11 +17,19 @@ spectral density :math:`S(Q)`, :math:`S(Q)-1`, or :math:`Q[S(Q)-1]` The input Workspace spectrum should be in the Q-space (\ **MomentumTransfer**\ ) `units <http://www.mantidproject.org/Units>`_ . (d-spacing is not supported any more. Contact development team to fix that and enable **dSpacing** again) +References +---------- + +#. B. H. Toby and T. Egami, *Accuracy of Pair Distribution Functions Analysis Appliced to Crystalline and Non-Crystalline Materials*, Acta Cryst. (1992) A**48**, 336-346 + `doi: 10.1107/S0108767391011327 <http://dx.doi.org/10.1107/S0108767391011327>`_ +#. B.H. Toby and S. Billinge, *Determination of Standard uncertainities in fits to pair distribution functions* Acta Cryst. (2004) A**60**, 315-317] + `doi: 10.1107/S0108767304011754 <http://dx.doi.org/10.1107/S0108767304011754>`_ + .. The algorithm itself is able to identify the unit. -- not any more. TODO: should be investigated why this has been disabled -Output Options: -############### +Output Options +-------------- **G(r)** ''''''''' diff --git a/docs/source/release/v3.7.0/diffraction.rst b/docs/source/release/v3.7.0/diffraction.rst index 13c88b239285bf35d3d6a5010744e7298f689d19..b61be76095d46a0ed702bfe1fdeb98ace72989b6 100644 --- a/docs/source/release/v3.7.0/diffraction.rst +++ b/docs/source/release/v3.7.0/diffraction.rst @@ -47,6 +47,10 @@ Graphical user interface: now view the plot in `dSpacing` instead `ToF`, which enables you to rerun the fitting process after selecting peaks from the interface. +Powder Diffraction +------------------ + +- :ref:`PDFFourierTransform <algm-PDFFourierTransform>` has been corrected in its calculation of errors. Imaging -------