-
Notifications
You must be signed in to change notification settings - Fork 122
/
DiffRotDiscreteCircle.cpp
78 lines (67 loc) · 2.93 KB
/
DiffRotDiscreteCircle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
// Mantid Coding standards <http://www.mantidproject.org/Coding_Standards>
// Main Module Header
#include "MantidCurveFitting/Functions/DiffRotDiscreteCircle.h"
// Mantid Headers from the same project
#include "MantidCurveFitting/Functions/ElasticDiffRotDiscreteCircle.h"
#include "MantidCurveFitting/Functions/InelasticDiffRotDiscreteCircle.h"
// Mantid headers from other projects
#include "MantidAPI/FunctionFactory.h"
#include "MantidAPI/IFunction.h"
#include "MantidAPI/ImmutableCompositeFunction.h"
// 3rd party library headers (N/A)
// standard library headers (N/A)
namespace {
Mantid::Kernel::Logger g_log("DiffRotDiscreteCircle");
}
namespace Mantid::CurveFitting::Functions {
DECLARE_FUNCTION(DiffRotDiscreteCircle)
/**
* @brief Propagate the attribute to its member functions.
* NOTE: we pass this->getAttribute(name) by reference, thus the same
* object is shared by the composite function and its members.
*/
void DiffRotDiscreteCircle::trickleDownAttribute(const std::string &name) {
for (size_t iFun = 0; iFun < nFunctions(); iFun++) {
API::IFunction_sptr fun = this->getFunction(iFun);
if (fun->hasAttribute(name))
fun->setAttribute(name, this->getAttribute(name));
}
}
/**
* @brief Overwrite attributes of member functions with the same name
*/
void DiffRotDiscreteCircle::declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue) {
API::ImmutableCompositeFunction::declareAttribute(name, defaultValue);
this->trickleDownAttribute(name);
}
/**
* @brief Overwrite attributes of member functions with the same name
*/
void DiffRotDiscreteCircle::setAttribute(const std::string &name, const Attribute &att) {
API::ImmutableCompositeFunction::setAttribute(name, att);
this->trickleDownAttribute(name);
}
/**
* @brief Initialize elastic and inelastic parts, aliases, attributes, and ties
*/
void DiffRotDiscreteCircle::init() {
m_elastic = std::dynamic_pointer_cast<ElasticDiffRotDiscreteCircle>(
API::FunctionFactory::Instance().createFunction("ElasticDiffRotDiscreteCircle"));
this->addFunction(m_elastic);
m_inelastic = std::dynamic_pointer_cast<InelasticDiffRotDiscreteCircle>(
API::FunctionFactory::Instance().createFunction("InelasticDiffRotDiscreteCircle"));
this->addFunction(m_inelastic);
this->setAttributeValue("NumDeriv", true);
this->declareAttribute("Q", API::IFunction::Attribute(0.5));
this->declareAttribute("N", API::IFunction::Attribute(3));
// Set the ties between Elastic and Inelastic parameters
this->addDefaultTies("f0.Height=f1.Intensity,f0.Radius=f1.Radius");
this->applyTies();
}
} // namespace Mantid::CurveFitting::Functions