Mantid
Loading...
Searching...
No Matches
PawleyFunction.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
14#include "MantidCurveFitting/DllConfig.h"
15#include "MantidKernel/System.h"
16
19
20namespace Mantid {
21namespace CurveFitting {
22namespace Functions {
23
34class MANTID_CURVEFITTING_DLL PawleyParameterFunction : virtual public API::IFunction,
35 virtual public API::ParamFunction {
36public:
38
40 std::string name() const override { return "PawleyParameterFunction"; }
41
42 void setAttribute(const std::string &attName, const Attribute &attValue) override;
43
44 Geometry::PointGroup::LatticeSystem getLatticeSystem() const;
45 Geometry::UnitCell getUnitCellFromParameters() const;
46 void setParametersFromUnitCell(const Geometry::UnitCell &cell);
47
49 std::string getProfileFunctionName() const { return getAttribute("ProfileFunction").asString(); }
50
52 std::string getProfileFunctionCenterParameterName() const { return m_profileFunctionCenterParameterName; }
53
54 void function(const API::FunctionDomain &domain, API::FunctionValues &values) const override;
55 void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override;
56
57protected:
58 void init() override;
59
60 void setProfileFunction(const std::string &profileFunction);
61 void setLatticeSystem(const std::string &latticeSystem);
62
63 void createLatticeSystemParameters(Geometry::PointGroup::LatticeSystem latticeSystem);
64
65 void addLengthConstraint(const std::string &parameterName);
66 void addAngleConstraint(const std::string &parameterName);
67
68 void setCenterParameterNameFromFunction(const API::IPeakFunction_sptr &profileFunction);
69
72};
73
74using PawleyParameterFunction_sptr = std::shared_ptr<PawleyParameterFunction>;
75
91class MANTID_CURVEFITTING_DLL PawleyFunction : public API::IPawleyFunction {
92public:
94
96 std::string name() const override { return "PawleyFunction"; }
97
98 void setMatrixWorkspace(std::shared_ptr<const API::MatrixWorkspace> workspace, size_t wi, double startX,
99 double endX) override;
100
101 void setLatticeSystem(const std::string &latticeSystem) override;
102 void setProfileFunction(const std::string &profileFunction) override;
103 void setUnitCell(const std::string &unitCellString) override;
104
105 void function(const API::FunctionDomain &domain, API::FunctionValues &values) const override;
106
108 void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override {
109 calNumericalDeriv(domain, jacobian);
110 }
111
112 void setPeaks(const std::vector<Kernel::V3D> &hkls, double fwhm, double height) override;
113 void clearPeaks() override;
114
115 void addPeak(const Kernel::V3D &hkl, double fwhm, double height) override;
116 size_t getPeakCount() const override;
117 API::IPeakFunction_sptr getPeakFunction(size_t i) const override;
118 Kernel::V3D getPeakHKL(size_t i) const override;
119
120 PawleyParameterFunction_sptr getPawleyParameterFunction() const;
121
122protected:
123 void setPeakPositions(const std::string &centreName, double zeroShift, const Geometry::UnitCell &cell) const;
124
125 size_t calculateFunctionValues(const API::IPeakFunction_sptr &peak, const API::FunctionDomain1D &domain,
126 API::FunctionValues &localValues) const;
127
128 double getTransformedCenter(double d) const;
129
130 void init() override;
131 void beforeDecoratedFunctionSet(const API::IFunction_sptr &fn) override;
132
136
137 std::vector<Kernel::V3D> m_hkls;
138
141
143};
144
145using PawleyFunction_sptr = std::shared_ptr<PawleyFunction>;
146
147} // namespace Functions
148} // namespace CurveFitting
149} // namespace Mantid
double height
Definition: GetAllEi.cpp:155
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
Represent a domain for functions of one real argument.
Base class that represents the domain of a function.
A class to store values calculated by a function.
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
Implements the part of IFunction interface dealing with parameters.
Definition: ParamFunction.h:33
The Pawley approach to obtain lattice parameters from a powder diffractogram works by placing peak pr...
PawleyParameterFunction_sptr m_pawleyParameterFunction
API::CompositeFunction_sptr m_compositeFunction
std::string name() const override
Returns the name of the function.
API::CompositeFunction_sptr m_peakProfileComposite
void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override
Derivates are calculated numerically.
This function is used internally by PawleyFunction to hold the unit cell parameters as well as the Ze...
std::string getProfileFunctionCenterParameterName() const
Returns the name of the stored function's center parameter.
Geometry::PointGroup::LatticeSystem m_latticeSystem
std::string name() const override
Returns the function name.
std::string getProfileFunctionName() const
Returns the stored profile function name.
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
Class for 3D vectors.
Definition: V3D.h:34
std::shared_ptr< IPeakFunction > IPeakFunction_sptr
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
std::shared_ptr< CompositeFunction > CompositeFunction_sptr
shared pointer to the composite function base class
std::shared_ptr< PawleyFunction > PawleyFunction_sptr
std::shared_ptr< PawleyParameterFunction > PawleyParameterFunction_sptr
std::shared_ptr< Unit > Unit_sptr
Shared pointer to the Unit base class.
Definition: Unit.h:229
Helper class which provides the Collimation Length for SANS instruments.