24 #include "../../job/FitObject.h" 25 #include "../../util/NumericalIntegration.h" 26 #include "../../dof/DegreeOfFreedom.h" 72 double evaluate(
double r,
double& deriv);
81 void writeTabulated(std::ostream& out,
double rmin,
double rmax,
double dr);
121 double centralDerivative(
double r,
double h,
double& abserr_trunc,
double& abserr_round);
319 if(&dof != &_nodes.back().coeff) {
329 void imposeBoundaryConditions();
333 virtual std::vector<DegreeOfFreedom*>
DOFToExport()
override {
return std::vector<DegreeOfFreedom*>(); }
345 std::vector<PolyNode> _nodes;
360 :
FunctionBase(id, job,
"spline"), _isPrepared(false) {}
378 void prepareSpline();
382 virtual std::vector<DegreeOfFreedom*>
DOFToExport()
override {
return std::vector<DegreeOfFreedom*>(); }
390 bool operator<(
const SplineNode& other)
const {
return x < other.x; }
397 std::vector<SplineNode> _nodes;
412 :
FunctionBase(id, job,
"functionInverseArgument"), _innerFunction(func) {}
415 const std::shared_ptr<FunctionBase>&
innerFunction()
const {
return _innerFunction; }
420 return _innerFunction->evaluate(1.0 - r);
424 double h = _innerFunction->evaluate(1.0 - r, deriv);
430 std::shared_ptr<FunctionBase> _innerFunction;
450 for(
const auto& f : _functions)
458 for(
const auto& f : _functions) {
460 s += f->evaluate(r, d);
468 std::vector<std::shared_ptr<FunctionBase>> _functions;
513 return _function1->evaluate(r) * _function2->evaluate(r);
519 p1 = _function1->evaluate(r, d1);
520 p2 = _function2->evaluate(r, d2);
521 deriv = p1 * d2 + p2 * d1;
527 std::shared_ptr<FunctionBase> _function1;
528 std::shared_ptr<FunctionBase> _function2;
virtual void parse(XML::Element functionElement) override
Parses function parameters from the given XML element.
Definition: Functions.cpp:86
FunctionSum(const FPString &id, FitJob *job)
Constructor.
Definition: Functions.h:441
Function is one at origin, .
Definition: Functions.h:45
double evaluateInternal(double r, double &deriv) override
Definition: Functions.h:423
FunctionProduct(const FPString &id, FitJob *job)
Constructor.
Definition: Functions.h:505
Definition: Functions.h:500
void setCutoff(double cutoff)
Definition: Functions.h:63
void setScreeningFunction(const std::shared_ptr< FunctionBase > &func)
Definition: Functions.h:105
double evaluateInternal(double r, double &deriv) override
Definition: Functions.h:516
FunctionBase(const FPString &id, FitJob *job, const FPString &tag=FPString())
Constructor.
Definition: Functions.h:51
double centralDerivative(double r, double h, double &abserr_trunc, double &abserr_round)
Definition: Functions.cpp:325
void setNormalizationMode(NormalizationMode mode)
Specifies the normalization mode to be used for this function.
Definition: Functions.h:87
virtual void dofValueChanged(DegreeOfFreedom &dof) override
This callback function is called by the DOFs of this function each time when their values changes...
Definition: Functions.h:317
double evaluateInternal(double r) override
Definition: Functions.h:448
double _prefactor
The constant prefactor used to normalize the function.
Definition: Functions.h:156
const std::shared_ptr< FunctionBase > & screeningFunction() const
Returns the screening function applied to this function, or NULL.
Definition: Functions.h:101
void computePrefactor()
Definition: Functions.cpp:234
void registerSubObject(FitObject *subobject, bool deleteOnShutdown=false)
Registers a sub-object.
Definition: FitObject.cpp:57
Definition: Functions.h:474
std::shared_ptr< FunctionBase > _screeningFunction
Optional screening function.
Definition: Functions.h:162
const std::vector< DegreeOfFreedom * > & DOF() const
Returns a list of degrees of freedom of this object.
Definition: FitObject.h:86
const FPString & tag() const
Returns the assigned tag string.
Definition: FitObject.h:144
bool hasCutoff() const
Returns whether this function has a cutoff.
Definition: Functions.h:55
FunctionInverseArgument(const FPString &id, FitJob *job, const std::shared_ptr< FunctionBase > &func)
Constructor.
Definition: Functions.h:411
NormalizationMode normalizationMode() const
Returns the normalization mode set for this function.
Definition: Functions.h:84
static std::shared_ptr< FunctionBase > createAndParse(XML::Element functionElement, const FPString &id, FitJob *job)
Parses an XML element and creates a function object out of it.
Definition: Functions.cpp:40
virtual void dofValueChanged(DegreeOfFreedom &dof)
This callback function is called by the DOFs of this fit object each time when their values changes...
Definition: FitObject.h:95
FunctionSpline(const FPString &id, FitJob *job)
Constructor.
Definition: Functions.h:359
Definition: Functions.h:169
NormalizationMode _normalizationMode
Controls the type of normalization applied to the function.
Definition: Functions.h:159
virtual std::vector< DegreeOfFreedom * > DOFToExport() override
Definition: Functions.h:333
virtual std::vector< DegreeOfFreedom * > DOFToExport()
Definition: Functions.h:148
double evaluate(double r)
Evaluates the function at the given r and multiplies the value with the proper normalization factor...
Definition: Functions.cpp:186
Definition: Functions.h:406
virtual std::vector< DegreeOfFreedom * > DOFToExport() override
Definition: Functions.h:382
double cutoff() const
Definition: Functions.h:59
Definition: Functions.h:354
This file collects the definition of classes that define various simple crystal structures.
Definition: Atomicrex.h:67
A simple scalar degree of freedom that consists of a single value.
Definition: DegreeOfFreedom.h:169
virtual double evaluateInternal(double r) override=0
Definition: Functions.h:301
virtual void dofValueChanged(DegreeOfFreedom &dof) override
Definition: Functions.h:95
Definition: Functions.h:184
void verifyDerivative()
Definition: Functions.cpp:267
std::string FPString
The default string type used throughout the code:
Definition: Atomicrex.h:70
Do not perform any normalization; use unmodified function.
Definition: Functions.h:41
Definition: Functions.h:231
Definition: XMLUtilities.h:226
Definition: Functions.h:279
Definition: XMLUtilities.h:69
double _cutoff
The function cutoff.
Definition: Functions.h:153
Definition: FitObject.h:42
Definition: Functions.h:436
void checkDerivativeNumerically(double r)
Definition: Functions.cpp:280
FitJob * job() const
Returns a pointer to the job to which this object belongs.
Definition: FitObject.h:150
double evaluateInternal(double r, double &deriv) override
Definition: Functions.h:455
Spherical integral over [0,cutoff] is unity, .
Definition: Functions.h:43
virtual double integrateSpherical(double a, double b)
Definition: NumericalIntegration.h:52
Base class for all degrees of freedom a potential or a structure may have.
Definition: DegreeOfFreedom.h:46
Base class for all one-dimensional functions that can be fitted.
Definition: Functions.h:35
Definition: Functions.h:207
double prefactor() const
Returns the constant prefactor the function is multiplied with.
Definition: Functions.h:66
Definition: Functions.h:257
const std::shared_ptr< FunctionBase > & innerFunction() const
Returns the inner function.
Definition: Functions.h:415
void writeTabulated(std::ostream &out, double rmin, double rmax, double dr)
Write tabulated function to stream for visualization with Gnuplot.
Definition: Functions.cpp:166
NormalizationMode
Definition: Functions.h:39
virtual XML::OElement generateXMLDefinition(const FPString &elementName)
Produces an XML representation of the function's current parameters and DOFs.
Definition: Functions.cpp:133
virtual void dofValueChanged(DegreeOfFreedom &dof) override
This callback function is called by the DOFs of this function each time their value changes...
Definition: Functions.h:369
double evaluateInternal(double r) override
Definition: Functions.h:419
Definition: NumericalIntegration.h:31
double evaluateInternal(double r) override
Definition: Functions.h:512