From bd6e5d76db74e8270a0a01dc7d278364da56859c Mon Sep 17 00:00:00 2001 From: Duc Le <duc.le@stfc.ac.uk> Date: Mon, 12 Sep 2016 00:08:39 +0100 Subject: [PATCH] Re #17457 - Removed formfactor algorithm commits. Fixed typo. --- Framework/Algorithms/CMakeLists.txt | 1 - .../MagFormFactorCorrection.h | 73 ----------- .../src/MagFormFactorCorrection.cpp | 117 ------------------ Framework/Kernel/src/MagneticIon.cpp | 2 +- 4 files changed, 1 insertion(+), 192 deletions(-) delete mode 100644 Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h delete mode 100644 Framework/Algorithms/src/MagFormFactorCorrection.cpp diff --git a/Framework/Algorithms/CMakeLists.txt b/Framework/Algorithms/CMakeLists.txt index 9136e1ba499..03ebe1d2ec3 100644 --- a/Framework/Algorithms/CMakeLists.txt +++ b/Framework/Algorithms/CMakeLists.txt @@ -153,7 +153,6 @@ set ( SRC_FILES src/InvertMask.cpp src/Logarithm.cpp src/LorentzCorrection.cpp - src/MagFormFactorCorrection.cpp src/MaskBins.cpp src/MaskBinsFromTable.cpp src/MaskDetectorsIf.cpp diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h deleted file mode 100644 index 5b5bd597688..00000000000 --- a/Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef MANTID_ALGORITHMS_SCALE_H_ -#define MANTID_ALGORITHMS_SCALE_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/Algorithm.h" - -namespace Mantid { -namespace Algorithms { -/** MagneticFormFactors scales the input workspace by the 1/F(Q) where F(Q) - is the magnetic form factor for the given magnetic ion. - - Properties: - <UL> - <LI> InputWorkspace - The name of the input workspace. </LI> - <LI> OutputWorkspace - The name of the output workspace. Can be the same as - the input one. </LI> - <LI> MagneticIon - The name of the magnetic ion (e.g. Fe2 for Fe2+) </LI> - </UL> - - @author Manh Duc Le, STFC - @date 08/09/2016 - - Copyright © 2010 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> - Code Documentation is available at: <http://doxygen.mantidproject.org> -*/ -class DLLExport MagFormFactorCorrection : public API::Algorithm { -public: - /// Algorithm's name - const std::string name() const override { return "MagFormFactorCorrection"; } - /// Summary of algorithms purpose - const std::string summary() const override { - return "MagFormFactorCorrection corrects a workspace for the magnetic form factor F(Q)" - "by dividing S(Q,w) by F(Q)."; - } - - /// Algorithm's version - int version() const override { return (1); } - /// Algorithm's category for identification - const std::string category() const override { - return "CorrectionFunctions"; - } - -private: - /// Initialisation code - void init() override; - /// Execution code - void exec() override; -}; - -} // namespace Algorithms -} // namespace Mantid - -#endif /*MANTID_ALGORITHMS_SCALE_H_*/ diff --git a/Framework/Algorithms/src/MagFormFactorCorrection.cpp b/Framework/Algorithms/src/MagFormFactorCorrection.cpp deleted file mode 100644 index 0f429cea73d..00000000000 --- a/Framework/Algorithms/src/MagFormFactorCorrection.cpp +++ /dev/null @@ -1,117 +0,0 @@ -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAlgorithms/MagFormFactorCorrection.h" -#include "MantidKernel/MagneticIon.h" -#include "MantidAPI/Axis.h" -#include "MantidAPI/AnalysisDataService.h" -#include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/WorkspaceFactory.h" - - -using namespace Mantid::PhysicalConstants; - -namespace Mantid { -namespace Algorithms { - -// Register the algorithm into the AlgorithmFactory -DECLARE_ALGORITHM(MagFormFactorCorrection) - -using namespace Kernel; -using namespace API; -using namespace PhysicalConstants; - -void MagFormFactorCorrection::init() { - declareProperty(make_unique<WorkspaceProperty<>>( - "InputWorkspace", "", Direction::Input), - "Workspace must have one axes with units of Q"); - declareProperty(make_unique<WorkspaceProperty<>>( - "OutputWorkspace", "", Direction::Output), - "Output workspace name."); - declareProperty( - "IonName", "", - "The name of the ion: an element symbol with a number indicating the valence, e.g. Fe2"); - declareProperty( - "FormFactorWorkspace", "", - "If specified the algorithm will create a 1D workspace with the form factor vs Q" - "with a name given by this field."); -} - -void MagFormFactorCorrection::exec() { - int64_t iax, numAxes, nQ, iQ; - bool hasQ = false; - std::string unitID; - Axis *QAxis; - std::vector<double> Qvals, FF; - double ff; - MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace"); - MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); - const std::string ionNameStr = getProperty("IonName"); - const std::string ffwsStr = getProperty("FormFactorWorkspace"); - const bool isHist = inputWS->isHistogramData(); - const int64_t numHists = inputWS->getNumberHistograms(); - const int64_t specSize = inputWS->blocksize(); - - // Checks that there is a |Q| axis. - numAxes = inputWS->axes(); - for (iax=0; iax<numAxes; iax++) { - QAxis = inputWS->getAxis(iax); - unitID = QAxis->unit()->unitID(); - if (unitID=="MomentumTransfer") { - hasQ = true; - // Gets the list of Q values - if (isHist || iax>0) { - nQ = QAxis->length() - 1; - for (iQ=0; iQ<nQ; iQ++) { - Qvals.push_back(0.5 * (QAxis->getValue(static_cast<size_t>(iQ)) + - QAxis->getValue(static_cast<size_t>(iQ+1)))); - } - } - else { - nQ = QAxis->length(); - for (iQ=0; iQ<nQ; iQ++) { - Qvals.push_back(QAxis->getValue(static_cast<size_t>(iQ))); - } - } - break; - } - } - if (!hasQ) { - throw std::runtime_error("Expected a MatrixWorkspace with a " - "MomentumTransfer axis. Cannot apply form factor " - "without knowing Q."); - } - - // Parses the ion name and get handle to MagneticIon object - const MagneticIon ion = getMagneticIon(ionNameStr); - // Gets the vector of form factor values - FF.reserve(nQ); - for (iQ=0; iQ<nQ; iQ++) { - FF.push_back(ion.analyticalFormFactor(Qvals[iQ]*Qvals[iQ])); - } - if (!ffwsStr.empty()) { - MatrixWorkspace_sptr ffws = API::WorkspaceFactory::Instance().create( - "Workspace2D", 1, Qvals.size(), FF.size()); - ffws->mutableX(0).assign(Qvals.begin(), Qvals.end()); - ffws->mutableY(0).assign(FF.begin(), FF.end()); - API::AnalysisDataServiceImpl &data_store = API::AnalysisDataService::Instance(); - data_store.addOrReplace(ffwsStr, ffws); - } - - // Does the actual scaling. - outputWS = inputWS->clone(); - for (int64_t i=0; i<numHists; i++) { - auto &Y = outputWS->dataY(i); - auto &E = outputWS->dataY(i); - for (int64_t j=0; j<specSize; j++) { - ff = (iax==0) ? FF[j] : FF[i]; - Y[j] /= ff; - E[j] /= ff; - } - } - - setProperty("OutputWorkspace", outputWS); -} - -} // namespace Algorithms -} // namespace Mantid diff --git a/Framework/Kernel/src/MagneticIon.cpp b/Framework/Kernel/src/MagneticIon.cpp index 20e54ae9eec..131f95633a0 100644 --- a/Framework/Kernel/src/MagneticIon.cpp +++ b/Framework/Kernel/src/MagneticIon.cpp @@ -603,7 +603,7 @@ constexpr double j_Am7[4][8] = { /// Values of 5d ions from Kobayashi et al., Acta. Cryst. A67, 473480 (2011) /// Needs an extra two parameters, and no <j6> (d-electrons, l=2) /// Last parameter is total deviation of the analytical formular from free ion calculations. -/// For some valences, there are multiple possible configurations (e.g. for neutron tungsten +/// For some valences, there are multiple possible configurations (e.g. for neutral tungsten /// we could have: 6s0 5d6, 6s1 5d5 or 6s2 5d4. The one used is noted in a comment. /// The configuration chosen is that obtained by filling the s-shell first. constexpr double j_Hf2[3][10] = { -- GitLab