Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functions related to thermal neutron peak. Refs #6018.
- Loading branch information
Showing
10 changed files
with
683 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/ThermalNeutronBk2BkExpAlpha.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#ifndef MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPALPHA_H_ | ||
#define MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPALPHA_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/IFunction1D.h" | ||
#include "MantidAPI/ParamFunction.h" | ||
|
||
using namespace Mantid; | ||
using namespace Mantid::API; | ||
|
||
namespace Mantid | ||
{ | ||
namespace CurveFitting | ||
{ | ||
|
||
/** ThermalNeutronBk2BkExpAlpha : Function to calculate Alpha of Bk2Bk Exponential function from | ||
Thermal Neutron Function's Alph0, Alph1, Alph0t, Alph1t, Dtt1, and etc. | ||
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
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://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport ThermalNeutronBk2BkExpAlpha : virtual public IFunction1D, public ParamFunction | ||
{ | ||
public: | ||
ThermalNeutronBk2BkExpAlpha(); | ||
virtual ~ThermalNeutronBk2BkExpAlpha(); | ||
|
||
/// Override | ||
virtual void function1D(double* out, const double* xValues, const size_t nData) const; | ||
|
||
/// overwrite IFunction base class methods | ||
std::string name()const{return "ThermalNeutronBk2BkExpAlpha";} | ||
|
||
/// Overwrite IFunction | ||
virtual const std::string category() const { return "General";} | ||
|
||
protected: | ||
/// overwrite IFunction base class method, which declare function parameters | ||
virtual void init(); | ||
|
||
private: | ||
/// Derivative | ||
void functionDerivLocal(API::Jacobian* , const double* , const size_t ); | ||
|
||
/// Derivative to overwrite | ||
void functionDeriv(const API::FunctionDomain& domain, API::Jacobian& jacobian); | ||
|
||
/// Core function (inline) to calcualte TOF_h from d-spacing | ||
inline double corefunction(double dh, double width, double tcross, double alph0, | ||
double alph1, double alph0t, double alph1t) const; | ||
|
||
}; | ||
|
||
typedef boost::shared_ptr<ThermalNeutronBk2BkExpAlpha> ThermalNeutronBk2BkExpAlpha_sptr; | ||
|
||
|
||
} // namespace CurveFitting | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPALPHA_H_ */ |
77 changes: 77 additions & 0 deletions
77
Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/ThermalNeutronBk2BkExpBeta.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#ifndef MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPBETA_H_ | ||
#define MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPBETA_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/IFunction1D.h" | ||
#include "MantidAPI/ParamFunction.h" | ||
|
||
using namespace Mantid; | ||
using namespace Mantid::API; | ||
|
||
namespace Mantid | ||
{ | ||
namespace CurveFitting | ||
{ | ||
|
||
/** ThermalNeutronBk2BkExpBETA : Function to calculate Beta of Bk2Bk Exponential function from | ||
Thermal Neutron Function's beta0, Alph1, Alph0t, Alph1t, Dtt1, and etc. | ||
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
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://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport ThermalNeutronBk2BkExpBeta : virtual public IFunction1D, public ParamFunction | ||
{ | ||
public: | ||
ThermalNeutronBk2BkExpBeta(); | ||
virtual ~ThermalNeutronBk2BkExpBeta(); | ||
|
||
/// Override | ||
virtual void function1D(double* out, const double* xValues, const size_t nData) const; | ||
|
||
/// overwrite IFunction base class methods | ||
std::string name()const{return "ThermalNeutronBk2BkExpBeta";} | ||
|
||
/// Overwrite IFunction | ||
virtual const std::string category() const { return "General";} | ||
|
||
protected: | ||
/// overwrite IFunction base class method, which declare function parameters | ||
virtual void init(); | ||
|
||
private: | ||
/// Derivative | ||
void functionDerivLocal(API::Jacobian* , const double* , const size_t ); | ||
|
||
/// Derivative to overwrite | ||
void functionDeriv(const API::FunctionDomain& domain, API::Jacobian& jacobian); | ||
|
||
/// Core function (inline) to calcualte TOF_h from d-spacing | ||
inline double corefunction(double dh, double width, double tcross, double beta0, | ||
double beta1, double beta0t, double beta1t) const; | ||
|
||
}; | ||
|
||
typedef boost::shared_ptr<ThermalNeutronBk2BkExpBeta> ThermalNeutronBk2BkExpBeta_sptr; | ||
|
||
|
||
} // namespace CurveFitting | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPBETA_H_ */ |
76 changes: 76 additions & 0 deletions
76
Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/ThermalNeutronBk2BkExpSigma.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#ifndef MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPSIGMA_H_ | ||
#define MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPSIGMA_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/IFunction1D.h" | ||
#include "MantidAPI/ParamFunction.h" | ||
|
||
using namespace Mantid; | ||
using namespace Mantid::API; | ||
|
||
namespace Mantid | ||
{ | ||
namespace CurveFitting | ||
{ | ||
|
||
/** ThermalNeutronBk2BkExpSIGMA : Function to calculate Sigma of Bk2Bk Exponential function from | ||
Thermal Neutron Function's Sig0, Sig1, Sig2, Width and etc. | ||
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
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://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport ThermalNeutronBk2BkExpSigma : virtual public IFunction1D, public ParamFunction | ||
{ | ||
public: | ||
ThermalNeutronBk2BkExpSigma(); | ||
virtual ~ThermalNeutronBk2BkExpSigma(); | ||
|
||
/// Override | ||
virtual void function1D(double* out, const double* xValues, const size_t nData) const; | ||
|
||
/// overwrite IFunction base class methods | ||
std::string name()const{return "ThermalNeutronBk2BkExpSigma";} | ||
|
||
/// Overwrite IFunction | ||
virtual const std::string category() const { return "General";} | ||
|
||
protected: | ||
/// overwrite IFunction base class method, which declare function parameters | ||
virtual void init(); | ||
|
||
private: | ||
/// Derivative | ||
void functionDerivLocal(API::Jacobian* , const double* , const size_t ); | ||
|
||
/// Derivative to overwrite | ||
void functionDeriv(const API::FunctionDomain& domain, API::Jacobian& jacobian); | ||
|
||
/// Core function (inline) to calcualte TOF_h from d-spacing | ||
inline double corefunction(double dh, double sig0sq, double sig1sq, double sig2sq) const; | ||
|
||
}; | ||
|
||
typedef boost::shared_ptr<ThermalNeutronBk2BkExpSigma> ThermalNeutronBk2BkExpSigma_sptr; | ||
|
||
|
||
} // namespace CurveFitting | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPSIGMA_H_ */ |
89 changes: 89 additions & 0 deletions
89
Code/Mantid/Framework/CurveFitting/src/ThermalNeutronBk2BkExpAlpha.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include "MantidCurveFitting/ThermalNeutronBk2BkExpAlpha.h" | ||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/FunctionFactory.h" | ||
|
||
#include <gsl/gsl_sf_erf.h> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
using namespace Mantid; | ||
using namespace Mantid::CurveFitting; | ||
|
||
namespace Mantid | ||
{ | ||
namespace CurveFitting | ||
{ | ||
|
||
DECLARE_FUNCTION(ThermalNeutronBk2BkExpAlpha) | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Constructor | ||
*/ | ||
ThermalNeutronBk2BkExpAlpha::ThermalNeutronBk2BkExpAlpha() | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Destructor | ||
*/ | ||
ThermalNeutronBk2BkExpAlpha::~ThermalNeutronBk2BkExpAlpha() | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Defintion of parameter | ||
*/ | ||
void ThermalNeutronBk2BkExpAlpha::init() | ||
{ | ||
// Geometry related | ||
declareParameter("Width", 1.0); | ||
declareParameter("Tcross", 1.0); | ||
|
||
declareParameter("Alph0", 0.0); | ||
declareParameter("Alph1", 0.0); | ||
declareParameter("Alph0t", 0.0); | ||
declareParameter("Alph1t", 0.0); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Function 1D | ||
*/ | ||
void ThermalNeutronBk2BkExpAlpha::function1D(double *out, const double *xValues, const size_t nData) const | ||
{ | ||
double width = getParameter("Width"); | ||
double tcross = getParameter("Tcross"); | ||
double alph0 = getParameter("Alph0"); | ||
double alph1 = getParameter("Alph1"); | ||
double alph0t = getParameter("Alph0t"); | ||
double alph1t = getParameter("Alph1t"); | ||
|
||
for (size_t i = 0; i < nData; ++i) | ||
{ | ||
out[i] = corefunction(xValues[i], width, tcross, alph0, alph1, alph0t, alph1t); | ||
} | ||
|
||
return; | ||
} | ||
|
||
/** Derivative: use numerical derivative | ||
*/ | ||
void ThermalNeutronBk2BkExpAlpha::functionDeriv(const FunctionDomain &domain, Jacobian &jacobian) | ||
{ | ||
calNumericalDeriv(domain, jacobian); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Core function | ||
*/ | ||
double ThermalNeutronBk2BkExpAlpha::corefunction(double dh, double width, double tcross, double alph0, | ||
double alph1, double alph0t, double alph1t) const | ||
{ | ||
double n = 0.5*gsl_sf_erfc(width*(tcross-1.0/dh)); | ||
double alpha = 1.0/( n*(alph0+alph1*dh) + (1.0-n)*(alph0t-alph1t/dh) ); | ||
|
||
return alpha; | ||
} | ||
|
||
|
||
} // namespace CurveFitting | ||
} // namespace Mantid |
Oops, something went wrong.