Skip to content

Commit

Permalink
Implement peak profile for neutron TOF. Refs #5306.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Jul 23, 2012
1 parent 65f9626 commit 6489992
Show file tree
Hide file tree
Showing 4 changed files with 839 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/CurveFitting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ set ( SRC_FILES
src/SteepestDescentMinimizer.cpp
src/StretchExp.cpp
src/StretchExpMuon.cpp
src/ThermalNeutronBk2BkExpConvPV.cpp
src/UserFunction.cpp
src/UserFunction1D.cpp
src/UserFunctionMD.cpp
Expand Down Expand Up @@ -146,6 +147,7 @@ set ( INC_FILES
inc/MantidCurveFitting/SteepestDescentMinimizer.h
inc/MantidCurveFitting/StretchExp.h
inc/MantidCurveFitting/StretchExpMuon.h
inc/MantidCurveFitting/ThermalNeutronBk2BkExpConvPV.h
inc/MantidCurveFitting/UserFunction.h
inc/MantidCurveFitting/UserFunction1D.h
inc/MantidCurveFitting/UserFunctionMD.h
Expand Down Expand Up @@ -208,6 +210,7 @@ set ( TEST_FILES
test/StaticKuboToyabeTest.h
test/StretchExpMuonTest.h
test/StretchExpTest.h
test/ThermalNeutronBk2BkExpConvPVTest.h
test/UserFunction1DTest.h
test/UserFunctionTest.h
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#ifndef MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPCONVPV_H_
#define MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPCONVPV_H_

#include "MantidKernel/System.h"
#include "MantidAPI/IPeakFunction.h"
#include "MantidAPI/IFunctionMW.h"
#include "MantidKernel/Logger.h"
#include <complex>

namespace Mantid
{
namespace CurveFitting
{

/** ThermalNeutronBk2BkExpConvPV :
Back-to-back exponential convoluted with pseudo Voigt for thermal neutron and epithermal neutron TOF
It will involve the calculation from peak's miller indices
Copyright &copy; 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 ThermalNeutronBk2BkExpConvPV : virtual public API::IPeakFunction, virtual public API::IFunctionMW
{
public:
ThermalNeutronBk2BkExpConvPV();
virtual ~ThermalNeutronBk2BkExpConvPV();

/// overwrite IPeakFunction base class methods
virtual double centre()const;
virtual double height()const;
virtual double fwhm()const;

virtual void setHeight(const double h);

/// overwrite IFunction base class methods
std::string name()const{return "Bk2BkExpConvPV";}
virtual const std::string category() const { return "Peak";}

/// Set up the range of peak calculation for higher efficiency

/// Reset FWHM such that FWHM will be recalculated
void resetFWHM();

/// Set Miller Indicies
void setMillerIndex(int h, int k, int l);

protected:

virtual void functionLocal(double* out, const double* xValues, const size_t nData)const;
virtual void functionDerivLocal(API::Jacobian* out, const double* xValues, const size_t nData);
virtual void functionDeriv(const API::FunctionDomain& domain, API::Jacobian& jacobian);

/// overwrite IFunction base class method, which declare function parameters
virtual void init();

private:

/// Static reference to the logger class
static Kernel::Logger& g_log;

/// Integral for gamma
std::complex<double> E1(std::complex<double> z) const;

/// Calcualte H and Eta
void calHandEta(double sigma2, double gamma, double& H, double& eta) const;

/// Calcualte d-spacing value from Miller Indices for cubic
double calCubicDSpace(double a, int h, int k, int l) const;

/// Calculate peak center
double calPeakCenter() const;

/// Calculate peak profile I(TOF) = Omega(TOF)
double calOmega(double x, double eta, double N, double alpha, double beta, double H,
double sigma2, double invert_sqrt2sigma) const;

/*
* Set 2 functions to be hidden from client
*/
virtual void setCentre(const double c);
virtual void setFwhm(const double w);

int mH;
int mK;
int mL;

bool mHKLSet;

};


} // namespace CurveFitting
} // namespace Mantid

#endif /* MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPCONVPV_H_ */

0 comments on commit 6489992

Please sign in to comment.