diff --git a/src/external/BMWtools/BMWIntegrator.cpp b/src/external/BMWtools/BMWIntegrator.cpp index dfbc63b20..24e9c5445 100644 --- a/src/external/BMWtools/BMWIntegrator.cpp +++ b/src/external/BMWtools/BMWIntegrator.cpp @@ -26,6 +26,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/** + * @file BMWIntegrator.cpp + * @brief Implementation of various numerical integration classes for superconductivity calculations. + * + * This file implements integration methods for calculating superfluid density within the semi-classical + * model for various superconducting order parameter symmetries using the Cuba library (Cuhre, Divonne, Suave algorithms). + * + * @author Bastian M. Wojek + */ + #include "BMWIntegrator.h" #include "cuba.h" @@ -42,10 +52,10 @@ std::vector TPointPWaveGapIntegralCuhre::fPar; //----------------------------------------------------------------------------- /** - *

Integrate the function using the Cuhre interface + * @brief Integrate the function using the Cuhre interface. * - *

return: - * - value of the integral + * @param tag Selects which integrand to use: 0 for aa==bb component, otherwise cc component + * @return Value of the integral */ double TPointPWaveGapIntegralCuhre::IntegrateFunc(int tag) { @@ -79,20 +89,20 @@ double TPointPWaveGapIntegralCuhre::IntegrateFunc(int tag) //----------------------------------------------------------------------------- /** - *

Calculate the function value for the use with Cuhre---actual implementation of the function - * for p-wave point, aa==bb component + * @brief Calculate the function value for the use with Cuhre---actual implementation of the function + * for p-wave point, aa==bb component. * - *

return: - * - 0 + * @param ndim Number of dimensions of the integral (2 here) + * @param x Point where the function should be evaluated: x = {E, z} + * @param ncomp Number of components of the integrand (1 here) + * @param f Function value (output) + * @param userdata Additional user parameters (required by the interface, NULL here) + * @return 0 on success * - * \param ndim number of dimensions of the integral (2 here) - * \param x point where the function should be evaluated - * \param ncomp number of components of the integrand (1 here) - * \param f function value - * \param userdata additional user parameters (required by the interface, NULL here) + * @note fPar = {twokBT, Delta(T), Ec, zc} */ int TPointPWaveGapIntegralCuhre::Integrand_aa(const int *ndim, const double x[], - const int *ncomp, double f[], void *userdata) // x = {E, z}, fPar = {twokBT, Delta(T), Ec, zc} + const int *ncomp, double f[], void *userdata) { double z = x[1]*fPar[3]; double deltasq(pow(sqrt(1.0-z*z)*fPar[1],2.0)); @@ -102,20 +112,20 @@ int TPointPWaveGapIntegralCuhre::Integrand_aa(const int *ndim, const double x[], //----------------------------------------------------------------------------- /** - *

Calculate the function value for the use with Cuhre---actual implementation of the function - * for p-wave point, cc component + * @brief Calculate the function value for the use with Cuhre---actual implementation of the function + * for p-wave point, cc component. * - *

return: - * - 0 + * @param ndim Number of dimensions of the integral (2 here) + * @param x Point where the function should be evaluated: x = {E, z} + * @param ncomp Number of components of the integrand (1 here) + * @param f Function value (output) + * @param userdata Additional user parameters (required by the interface, NULL here) + * @return 0 on success * - * \param ndim number of dimensions of the integral (2 here) - * \param x point where the function should be evaluated - * \param ncomp number of components of the integrand (1 here) - * \param f function value - * \param userdata additional user parameters (required by the interface, NULL here) + * @note fPar = {twokBT, Delta(T), Ec, zc} */ int TPointPWaveGapIntegralCuhre::Integrand_cc(const int *ndim, const double x[], - const int *ncomp, double f[], void *userdata) // x = {E, z}, fPar = {twokBT, Delta(T), Ec, zc} + const int *ncomp, double f[], void *userdata) { double z = x[1]*fPar[3]; double deltasq(pow(sqrt(1.0-z*z)*fPar[1],2.0)); @@ -125,14 +135,14 @@ int TPointPWaveGapIntegralCuhre::Integrand_cc(const int *ndim, const double x[], //----------------------------------------------------------------------------- -std::vector TLinePWaveGapIntegralCuhre::fPar; +std::vector TLinePWaveGapIntegralCuhre::fPar; ///< Static parameter vector for line p-wave integrand //----------------------------------------------------------------------------- /** - *

Integrate the function using the Cuhre interface + * @brief Integrate the function using the Cuhre interface for line p-wave symmetry. * - *

return: - * - value of the integral + * @param tag Selects which integrand to use: 0 for aa==bb component, otherwise cc component + * @return Value of the integral */ double TLinePWaveGapIntegralCuhre::IntegrateFunc(int tag) { @@ -212,14 +222,13 @@ int TLinePWaveGapIntegralCuhre::Integrand_cc(const int *ndim, const double x[], //----------------------------------------------------------------------------- -std::vector TDWaveGapIntegralCuhre::fPar; +std::vector TDWaveGapIntegralCuhre::fPar; ///< Static parameter vector for d-wave integrand //----------------------------------------------------------------------------- /** - *

Integrate the function using the Cuhre interface + * @brief Integrate the function using the Cuhre interface for d-wave symmetry. * - *

return: - * - value of the integral + * @return Value of the integral */ double TDWaveGapIntegralCuhre::IntegrateFunc() { @@ -247,19 +256,20 @@ double TDWaveGapIntegralCuhre::IntegrateFunc() //----------------------------------------------------------------------------- /** - *

Calculate the function value for the use with Cuhre---actual implementation of the function + * @brief Calculate the function value for the use with Cuhre---actual implementation of the function + * for d-wave symmetry. * - *

return: - * - 0 + * @param ndim Number of dimensions of the integral (2 here) + * @param x Point where the function should be evaluated: x = {E, phi} + * @param ncomp Number of components of the integrand (1 here) + * @param f Function value (output) + * @param userdata Additional user parameters (required by the interface, NULL here) + * @return 0 on success * - * \param ndim number of dimensions of the integral (2 here) - * \param x point where the function should be evaluated - * \param ncomp number of components of the integrand (1 here) - * \param f function value - * \param userdata additional user parameters (required by the interface, NULL here) + * @note fPar = {twokBT, Delta(T), Ec, phic} */ int TDWaveGapIntegralCuhre::Integrand(const int *ndim, const double x[], - const int *ncomp, double f[], void *userdata) // x = {E, phi}, fPar = {twokBT, Delta(T), Ec, phic} + const int *ncomp, double f[], void *userdata) { double deltasq(TMath::Power(fPar[1]*TMath::Cos(2.0*x[1]*fPar[3]),2.0)); f[0] = 1.0/TMath::Power(TMath::CosH(TMath::Sqrt(x[0]*x[0]*fPar[2]*fPar[2]+deltasq)/fPar[0]),2.0); diff --git a/src/external/BMWtools/BMWIntegrator.h b/src/external/BMWtools/BMWIntegrator.h index c0a4f4fbf..d4fed5716 100644 --- a/src/external/BMWtools/BMWIntegrator.h +++ b/src/external/BMWtools/BMWIntegrator.h @@ -26,6 +26,17 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/** + * @file BMWIntegrator.h + * @brief Header file containing various numerical integration classes for superconductivity calculations. + * + * This file provides integration classes based on GNU Scientific Library (GSL) and the Cuba library + * for calculating superfluid density within the semi-classical model for various superconducting + * order parameter symmetries (s-wave, p-wave, d-wave, etc.) assuming cylindrical Fermi surfaces. + * + * @author Bastian M. Wojek + */ + #ifndef _BMWIntegrator_H_ #define _BMWIntegrator_H_ @@ -39,11 +50,15 @@ //----------------------------------------------------------------------------- /** - *

Alternative base class for 1D integrations using the GNU Scientific Library integrator. - * The difference to the other class is that here the integration parameters have to be supplied directly to the IntegrateFunc method. - * Therefore, integrals with different parameters can be calculated in parallel (at least I hope so). - * The function which should be integrated has to be implemented in a derived class. - * Note: The purpose of this is to offer an easy-to-use interface---not the most efficient integration routine. + * @class T2Integrator + * @brief Alternative base class for 1D integrations using the GNU Scientific Library integrator. + * + * The difference to the other class is that here the integration parameters have to be supplied + * directly to the IntegrateFunc method. Therefore, integrals with different parameters can be + * calculated in parallel (at least I hope so). The function which should be integrated has to be + * implemented in a derived class. + * + * @note The purpose of this is to offer an easy-to-use interface---not the most efficient integration routine. */ class T2Integrator { public: @@ -97,17 +112,20 @@ inline double T2Integrator::IntegrateFunc(double x1, double x2, const std::vecto //----------------------------------------------------------------------------- /** - *

Base class for 1D integrations using the GNU Scientific Library integrator. - * The function which should be integrated has to be implemented in a derived class. - * Note: The purpose of this is to offer an easy-to-use interface---not the most efficient integration routine. + * @class TIntegrator + * @brief Base class for 1D integrations using the GNU Scientific Library integrator. + * + * The function which should be integrated has to be implemented in a derived class. + * + * @note The purpose of this is to offer an easy-to-use interface---not the most efficient integration routine. */ class TIntegrator { public: TIntegrator(); virtual ~TIntegrator(); - void SetParameters(const std::vector &par) const { fPar=par; } - virtual double FuncAtX(double) const = 0; - double IntegrateFunc(double, double); + void SetParameters(const std::vector &par) const { fPar=par; } ///< Set integration parameters + virtual double FuncAtX(double) const = 0; ///< Calculate integrand at point x (pure virtual) + double IntegrateFunc(double, double); ///< Perform the integration protected: mutable std::vector fPar; ///< parameters of the integrand @@ -170,24 +188,28 @@ inline double TIntegrator::IntegrateFunc(double x1, double x2) //----------------------------------------------------------------------------- /** - *

Base class for multidimensional Monte-Carlo integrations using the GNU Scientific Library integrator. - * The function which should be integrated has to be implemented in a derived class. - * Note: The purpose of this is to offer an easy-to-use interface---not the most efficient integration routine. + * @class TMCIntegrator + * @brief Base class for multidimensional Monte-Carlo integrations using the GNU Scientific Library integrator. + * + * The function which should be integrated has to be implemented in a derived class. + * Uses the MISER algorithm of Press and Farrar. + * + * @note The purpose of this is to offer an easy-to-use interface---not the most efficient integration routine. */ class TMCIntegrator { public: TMCIntegrator(); virtual ~TMCIntegrator(); - void SetParameters(const std::vector &par) const { fPar=par; } - virtual double FuncAtX(double *) const = 0; - double IntegrateFunc(size_t, double *, double *); + void SetParameters(const std::vector &par) const { fPar=par; } ///< Set integration parameters + virtual double FuncAtX(double *) const = 0; ///< Calculate integrand at point x (pure virtual) + double IntegrateFunc(size_t, double *, double *); ///< Perform the multidimensional integration protected: mutable std::vector fPar; ///< parameters of the integrand private: static double FuncAtXgsl(double *, size_t, void *); - std::unique_ptr fMCIntegrator; ///< pointer to the GSL integrator + std::unique_ptr fMCIntegrator; ///< pointer to the GSL Monte-Carlo integrator mutable double (*fFunc)(double *, size_t, void *); ///< pointer to the integrand function }; @@ -245,208 +267,238 @@ inline double TMCIntegrator::IntegrateFunc(size_t dim, double *x1, double *x2) //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and a point p symmetry of the superconducting order parameter. - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TPointPWaveGapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a point p symmetry + * of the superconducting order parameter. + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TPointPWaveGapIntegralCuhre { public: - TPointPWaveGapIntegralCuhre() : fNDim(2) {} - ~TPointPWaveGapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand_aa(const int*, const double[], const int*, double[], void*); - static int Integrand_cc(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(int tag); + TPointPWaveGapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TPointPWaveGapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand_aa(const int*, const double[], const int*, double[], void*); ///< Integrand for aa==bb component + static int Integrand_cc(const int*, const double[], const int*, double[], void*); ///< Integrand for cc component + double IntegrateFunc(int tag); ///< Perform the integration (tag=0 for aa, tag!=0 for cc) protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), Ec, zc) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and a line p symmetry of the superconducting order parameter. - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TLinePWaveGapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a line p symmetry + * of the superconducting order parameter. + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TLinePWaveGapIntegralCuhre { public: - TLinePWaveGapIntegralCuhre() : fNDim(2) {} - ~TLinePWaveGapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand_aa(const int*, const double[], const int*, double[], void*); - static int Integrand_cc(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(int tag); + TLinePWaveGapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TLinePWaveGapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand_aa(const int*, const double[], const int*, double[], void*); ///< Integrand for aa==bb component + static int Integrand_cc(const int*, const double[], const int*, double[], void*); ///< Integrand for cc component + double IntegrateFunc(int tag); ///< Perform the integration (tag=0 for aa, tag!=0 for cc) protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), Ec, zc) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and a d_{x^2-y^2} symmetry of the superconducting order parameter. - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TDWaveGapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a d_{x^2-y^2} symmetry + * of the superconducting order parameter. + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TDWaveGapIntegralCuhre { public: - TDWaveGapIntegralCuhre() : fNDim(2) {} - ~TDWaveGapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TDWaveGapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TDWaveGapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), Ec, phic) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density along the a-axis - * within the semi-classical model assuming a cylindrical Fermi surface and a mixed d_{x^2-y^2} + s symmetry of the - * superconducting order parameter (effectively: d_{x^2-y^2} with shifted nodes and a-b-anisotropy). - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TCosSqDWaveGapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density along the a-axis + * within the semi-classical model assuming a cylindrical Fermi surface and a mixed d_{x^2-y^2} + s symmetry + * of the superconducting order parameter (effectively: d_{x^2-y^2} with shifted nodes and a-b-anisotropy). + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TCosSqDWaveGapIntegralCuhre { public: - TCosSqDWaveGapIntegralCuhre() : fNDim(2) {} - ~TCosSqDWaveGapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TCosSqDWaveGapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TCosSqDWaveGapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, DeltaD(T), Ec, phic, DeltaS(T)) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density along the b-axis - * within the semi-classical model assuming a cylindrical Fermi surface and a mixed d_{x^2-y^2} + s symmetry of the - * superconducting order parameter (effectively: d_{x^2-y^2} with shifted nodes and a-b-anisotropy). - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TSinSqDWaveGapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density along the b-axis + * within the semi-classical model assuming a cylindrical Fermi surface and a mixed d_{x^2-y^2} + s symmetry + * of the superconducting order parameter (effectively: d_{x^2-y^2} with shifted nodes and a-b-anisotropy). + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TSinSqDWaveGapIntegralCuhre { public: - TSinSqDWaveGapIntegralCuhre() : fNDim(2) {} - ~TSinSqDWaveGapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TSinSqDWaveGapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TSinSqDWaveGapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, DeltaD(T), Ec, phic, DeltaS(T)) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and an "anisotropic s-wave" symmetry of the superconducting order parameter. - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TAnSWaveGapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and an "anisotropic s-wave" + * symmetry of the superconducting order parameter. + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TAnSWaveGapIntegralCuhre { public: - TAnSWaveGapIntegralCuhre() : fNDim(2) {} - ~TAnSWaveGapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TAnSWaveGapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TAnSWaveGapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), a, Ec, phic) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and an "anisotropic s-wave" symmetry of the superconducting order parameter. - * The integration uses the Divonne algorithm of the Cuba library. + * @class TAnSWaveGapIntegralDivonne + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and an "anisotropic s-wave" + * symmetry of the superconducting order parameter. + * + * The integration uses the Divonne algorithm of the Cuba library. */ class TAnSWaveGapIntegralDivonne { public: - TAnSWaveGapIntegralDivonne() : fNDim(2) {} - ~TAnSWaveGapIntegralDivonne() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TAnSWaveGapIntegralDivonne() : fNDim(2) {} ///< Constructor + ~TAnSWaveGapIntegralDivonne() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), a, Ec, phic) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and an "anisotropic s-wave" symmetry of the superconducting order parameter. - * The integration uses the Suave algorithm of the Cuba library. + * @class TAnSWaveGapIntegralSuave + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and an "anisotropic s-wave" + * symmetry of the superconducting order parameter. + * + * The integration uses the Suave algorithm of the Cuba library. */ class TAnSWaveGapIntegralSuave { public: - TAnSWaveGapIntegralSuave() : fNDim(2) {} - ~TAnSWaveGapIntegralSuave() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TAnSWaveGapIntegralSuave() : fNDim(2) {} ///< Constructor + ~TAnSWaveGapIntegralSuave() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), a, Ec, phic) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and an "non-monotonic d-wave" symmetry of the superconducting order parameter. - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TNonMonDWave1GapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a "non-monotonic d-wave" + * symmetry of the superconducting order parameter. + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TNonMonDWave1GapIntegralCuhre { public: - TNonMonDWave1GapIntegralCuhre() : fNDim(2) {} - ~TNonMonDWave1GapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TNonMonDWave1GapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TNonMonDWave1GapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), a, Ec, phic) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Two-dimensional integrator class for the efficient calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and an "non-monotonic d-wave" symmetry of the superconducting order parameter. - * The integration uses the Cuhre algorithm of the Cuba library. + * @class TNonMonDWave2GapIntegralCuhre + * @brief Two-dimensional integrator class for the efficient calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a "non-monotonic d-wave" + * symmetry of the superconducting order parameter. + * + * The integration uses the Cuhre algorithm of the Cuba library. */ class TNonMonDWave2GapIntegralCuhre { public: - TNonMonDWave2GapIntegralCuhre() : fNDim(2) {} - ~TNonMonDWave2GapIntegralCuhre() { fPar.clear(); } - void SetParameters(const std::vector &par) { fPar=par; } - static int Integrand(const int*, const double[], const int*, double[], void*); - double IntegrateFunc(); + TNonMonDWave2GapIntegralCuhre() : fNDim(2) {} ///< Constructor + ~TNonMonDWave2GapIntegralCuhre() { fPar.clear(); } ///< Destructor + void SetParameters(const std::vector &par) { fPar=par; } ///< Set integration parameters + static int Integrand(const int*, const double[], const int*, double[], void*); ///< Integrand function + double IntegrateFunc(); ///< Perform the integration protected: - static std::vector fPar; ///< parameters of the integrand - unsigned int fNDim; ///< dimension of the integral + static std::vector fPar; ///< parameters of the integrand (twokBT, Delta(T), a, Ec, phic) + unsigned int fNDim; ///< dimension of the integral (2) }; //----------------------------------------------------------------------------- /** - *

Test class for the 2D MC integration - * Integral: x*y dx dy + * @class T2DTest + * @brief Test class for the 2D Monte-Carlo integration. + * + * Integral: x*y dx dy */ class T2DTest : public TMCIntegrator { public: - T2DTest() {} - ~T2DTest() {} - double FuncAtX(double *) const; + T2DTest() {} ///< Constructor + ~T2DTest() {} ///< Destructor + double FuncAtX(double *) const; ///< Calculate integrand x*y at point x }; //----------------------------------------------------------------------------- @@ -465,28 +517,34 @@ inline double T2DTest::FuncAtX(double *x) const //----------------------------------------------------------------------------- /** - *

Class for the 2D Monte-Carlo integration for the calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and a point p symmetry of the superconducting order parameter. - * The integration uses the GSL integration routines. + * @class TPointPWaveGapIntegral + * @brief Class for the 2D Monte-Carlo integration for the calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a point p symmetry + * of the superconducting order parameter. + * + * The integration uses the GSL integration routines. */ class TPointPWaveGapIntegral : public TMCIntegrator { public: - TPointPWaveGapIntegral() {} - ~TPointPWaveGapIntegral() {} - double FuncAtX(double *) const; + TPointPWaveGapIntegral() {} ///< Constructor + ~TPointPWaveGapIntegral() {} ///< Destructor + double FuncAtX(double *) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- /** - *

Class for the 2D Monte-Carlo integration for the calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and a line p symmetry of the superconducting order parameter. - * The integration uses the GSL integration routines. + * @class TLinePWaveGapIntegral + * @brief Class for the 2D Monte-Carlo integration for the calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a line p symmetry + * of the superconducting order parameter. + * + * The integration uses the GSL integration routines. */ class TLinePWaveGapIntegral : public TMCIntegrator { public: - TLinePWaveGapIntegral() {} - ~TLinePWaveGapIntegral() {} - double FuncAtX(double *) const; + TLinePWaveGapIntegral() {} ///< Constructor + ~TLinePWaveGapIntegral() {} ///< Destructor + double FuncAtX(double *) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- @@ -523,15 +581,18 @@ inline double TLinePWaveGapIntegral::FuncAtX(double *x) const // x = {E, theta}, //----------------------------------------------------------------------------- /** - *

Class for the 2D Monte-Carlo integration for the calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and a d_{x^2-y^2} symmetry of the superconducting order parameter. - * The integration uses the GSL integration routines. + * @class TDWaveGapIntegral + * @brief Class for the 2D Monte-Carlo integration for the calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and a d_{x^2-y^2} symmetry + * of the superconducting order parameter. + * + * The integration uses the GSL integration routines. */ class TDWaveGapIntegral : public TMCIntegrator { public: - TDWaveGapIntegral() {} - ~TDWaveGapIntegral() {} - double FuncAtX(double *) const; + TDWaveGapIntegral() {} ///< Constructor + ~TDWaveGapIntegral() {} ///< Destructor + double FuncAtX(double *) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- @@ -552,15 +613,18 @@ inline double TDWaveGapIntegral::FuncAtX(double *x) const // x = {E, phi}, fPar //----------------------------------------------------------------------------- /** - *

Class for the 2D Monte-Carlo integration for the calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and an "anisotropic s-wave" symmetry of the superconducting order parameter. - * The integration uses the GSL integration routines. + * @class TAnSWaveGapIntegral + * @brief Class for the 2D Monte-Carlo integration for the calculation of the superfluid density + * within the semi-classical model assuming a cylindrical Fermi surface and an "anisotropic s-wave" + * symmetry of the superconducting order parameter. + * + * The integration uses the GSL integration routines. */ class TAnSWaveGapIntegral : public TMCIntegrator { public: - TAnSWaveGapIntegral() {} - ~TAnSWaveGapIntegral() {} - double FuncAtX(double *) const; + TAnSWaveGapIntegral() {} ///< Constructor + ~TAnSWaveGapIntegral() {} ///< Destructor + double FuncAtX(double *) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- @@ -581,16 +645,18 @@ inline double TAnSWaveGapIntegral::FuncAtX(double *x) const // x = {E, phi}, fPa //----------------------------------------------------------------------------- /** - *

Class for the 1D integration of j0(a*x)*exp(-b*x) - * The integration uses the GSL integration routines. + * @class TIntBesselJ0Exp + * @brief Class for the 1D integration of j0(a*x)*exp(-b*x). + * + * The integration uses the GSL integration routines. */ class TIntBesselJ0Exp : public T2Integrator { public: - TIntBesselJ0Exp() {} - ~TIntBesselJ0Exp() {} + TIntBesselJ0Exp() {} ///< Constructor + ~TIntBesselJ0Exp() {} ///< Destructor private: - double FuncAtX(double, const std::vector&) const; + double FuncAtX(double, const std::vector&) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- @@ -616,16 +682,18 @@ inline double TIntBesselJ0Exp::FuncAtX(double x, const std::vector &par) //----------------------------------------------------------------------------- /** - *

Class for the 1D integration of sin(a*x)*exp(-b*x*x) - * The integration uses the GSL integration routines. + * @class TIntSinGss + * @brief Class for the 1D integration of sin(a*x)*exp(-b*x*x). + * + * The integration uses the GSL integration routines. */ class TIntSinGss : public T2Integrator { public: - TIntSinGss() {} - ~TIntSinGss() {} + TIntSinGss() {} ///< Constructor + ~TIntSinGss() {} ///< Destructor private: - double FuncAtX(double, const std::vector&) const; + double FuncAtX(double, const std::vector&) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- @@ -644,18 +712,20 @@ inline double TIntSinGss::FuncAtX(double x, const std::vector &par) cons //----------------------------------------------------------------------------- /** - *

Class for the 1D integration of the "DeRenzi Spin Glass Interpolation Integrand" - * See Eq. (5) of R. De Renzi and S. Fanesi, Physica B 289-290, 209-212 (2000). - * doi:10.1016/S0921-4526(00)00368-9 - * The integration uses the GSL integration routines. + * @class TIntSGInterpolation + * @brief Class for the 1D integration of the "DeRenzi Spin Glass Interpolation Integrand". + * + * See Eq. (5) of R. De Renzi and S. Fanesi, Physica B 289-290, 209-212 (2000). + * doi:10.1016/S0921-4526(00)00368-9 + * The integration uses the GSL integration routines. */ class TIntSGInterpolation : public T2Integrator { public: - TIntSGInterpolation() {} - ~TIntSGInterpolation() {} + TIntSGInterpolation() {} ///< Constructor + ~TIntSGInterpolation() {} ///< Destructor private: - double FuncAtX(double, const std::vector&) const; + double FuncAtX(double, const std::vector&) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- @@ -677,15 +747,17 @@ inline double TIntSGInterpolation::FuncAtX(double x, const std::vector & //----------------------------------------------------------------------------- /** - *

Class for the 1D integration for the calculation of the superfluid density within the semi-classical model - * assuming a cylindrical Fermi surface and an isotropic s-wave symmetry of the superconducting order parameter. - * The integration uses the GSL integration routines. + * @class TGapIntegral + * @brief Class for the 1D integration for the calculation of the superfluid density within the semi-classical model + * assuming a cylindrical Fermi surface and an isotropic s-wave symmetry of the superconducting order parameter. + * + * The integration uses the GSL integration routines. */ class TGapIntegral : public TIntegrator { public: - TGapIntegral() {} - ~TGapIntegral() {} - double FuncAtX(double) const; // variable: E + TGapIntegral() {} ///< Constructor + ~TGapIntegral() {} ///< Destructor + double FuncAtX(double) const; ///< Calculate integrand at energy E }; //----------------------------------------------------------------------------- @@ -704,16 +776,18 @@ inline double TGapIntegral::FuncAtX(double e) const //----------------------------------------------------------------------------- /** - *

Class for the 1D integration for the calculation of the uniaxial static Gauss-Kubo-Toyabe function - * The integration uses the GSL integration routines. + * @class TFirstUniaxialGssKTIntegral + * @brief Class for the 1D integration for the calculation of the uniaxial static Gauss-Kubo-Toyabe function. + * + * The integration uses the GSL integration routines. */ class TFirstUniaxialGssKTIntegral : public T2Integrator { public: - TFirstUniaxialGssKTIntegral() {} - virtual ~TFirstUniaxialGssKTIntegral() {} + TFirstUniaxialGssKTIntegral() {} ///< Constructor + virtual ~TFirstUniaxialGssKTIntegral() {} ///< Destructor private: - virtual double FuncAtX(double, const std::vector&) const; // variable: x + virtual double FuncAtX(double, const std::vector&) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- @@ -736,16 +810,18 @@ inline double TFirstUniaxialGssKTIntegral::FuncAtX(double x, const std::vectorClass for the 1D integration for the calculation of the uniaxial static Gauss-Kubo-Toyabe function - * The integration uses the GSL integration routines. + * @class TSecondUniaxialGssKTIntegral + * @brief Class for the 1D integration for the calculation of the uniaxial static Gauss-Kubo-Toyabe function. + * + * The integration uses the GSL integration routines. */ class TSecondUniaxialGssKTIntegral : public T2Integrator { public: - TSecondUniaxialGssKTIntegral() {} - virtual ~TSecondUniaxialGssKTIntegral() {} + TSecondUniaxialGssKTIntegral() {} ///< Constructor + virtual ~TSecondUniaxialGssKTIntegral() {} ///< Destructor private: - virtual double FuncAtX(double, const std::vector&) const; // variable: x + virtual double FuncAtX(double, const std::vector&) const; ///< Calculate integrand at point x }; //----------------------------------------------------------------------------- diff --git a/src/external/BMWtools/BMWStartupHandler.cpp b/src/external/BMWtools/BMWStartupHandler.cpp index 8fd2e2875..f7206fc44 100644 --- a/src/external/BMWtools/BMWStartupHandler.cpp +++ b/src/external/BMWtools/BMWStartupHandler.cpp @@ -30,6 +30,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/** + * @file BMWStartupHandler.cpp + * @brief Implementation of the XML startup file handler for BMW tools. + * + * This file implements the BMWStartupHandler class which parses the BMW_startup.xml + * configuration file using SAX2 XML parsing. + * + * @author Bastian M. Wojek (based on PStartupHandler.cpp by Andreas Suter) + */ + #include #include @@ -39,22 +49,22 @@ ClassImpQ(BMWStartupHandler) -//-------------------------------------------------------------------------- -// Constructor //-------------------------------------------------------------------------- /** - *

Constructor. Check if the BMW_startup.xml file is found in the local directory + * @brief Constructor. Initializes all member variables to default values. + * + * The actual configuration will be loaded when the XML file is parsed. */ BMWStartupHandler::BMWStartupHandler() : fDebug(false), fLEM(false), fVortex(false), fLF(false), fDataPath(""), fDeltat(0.), fDeltaB(0.), fWisdomFile(""), fWisdomFileFloat(""), fNSteps(0), fGridSteps(0), fDeltatLF(0.), fNStepsLF(0) { } -//-------------------------------------------------------------------------- -// Destructor //-------------------------------------------------------------------------- /** - *

Destructor + * @brief Destructor. Cleans up allocated resources. + * + * Clears all internal vectors and maps. */ BMWStartupHandler::~BMWStartupHandler() { @@ -64,22 +74,23 @@ BMWStartupHandler::~BMWStartupHandler() fEnergies.clear(); } -//-------------------------------------------------------------------------- -// OnStartDocument //-------------------------------------------------------------------------- /** - *

Called on start of the XML file reading. Initializes all necessary variables. + * @brief Called on start of the XML file reading. Initializes all necessary variables. + * + * This method is automatically invoked by the SAX2 parser when parsing begins. */ void BMWStartupHandler::OnStartDocument() { fKey = eEmpty; } -//-------------------------------------------------------------------------- -// OnEndDocument //-------------------------------------------------------------------------- /** - *

Called on end of XML file reading. + * @brief Called on end of XML file reading. + * + * This method is automatically invoked by the SAX2 parser when parsing completes. + * It triggers validation and default value assignment. */ void BMWStartupHandler::OnEndDocument() { @@ -87,15 +98,13 @@ void BMWStartupHandler::OnEndDocument() CheckLists(); } -//-------------------------------------------------------------------------- -// OnStartElement //-------------------------------------------------------------------------- /** - *

Called when a XML start element is found. Filters out the needed elements - * and sets a proper key. + * @brief Called when an XML start element is found. Filters out the needed elements + * and sets a proper key. * - * \param str XML element name - * \param attributes not used + * @param str XML element name + * @param attributes XML attributes (not used) */ void BMWStartupHandler::OnStartElement(const char *str, const TList *attributes) { @@ -132,27 +141,23 @@ void BMWStartupHandler::OnStartElement(const char *str, const TList *attributes) } } -//-------------------------------------------------------------------------- -// OnEndElement //-------------------------------------------------------------------------- /** - *

Called when a XML end element is found. Resets the handler key. + * @brief Called when an XML end element is found. Resets the handler key. * - * \param str not used + * @param str XML element name (not used) */ void BMWStartupHandler::OnEndElement(const char *str) { fKey = eEmpty; } -//-------------------------------------------------------------------------- -// OnCharacters //-------------------------------------------------------------------------- /** - *

Content of a given XML element. Filters out the data and feeds them to - * the internal variables. + * @brief Content of a given XML element. Filters out the data and feeds them to + * the internal variables. * - * \param str XML element string + * @param str XML element content string */ void BMWStartupHandler::OnCharacters(const char *str) { @@ -221,26 +226,22 @@ void BMWStartupHandler::OnCharacters(const char *str) } } -//-------------------------------------------------------------------------- -// OnComment //-------------------------------------------------------------------------- /** - *

Called when a XML comment is found. Not used. + * @brief Called when an XML comment is found. Not used. * - * \param str not used. + * @param str Comment string (not used) */ void BMWStartupHandler::OnComment(const char *str) { // nothing to be done for now } -//-------------------------------------------------------------------------- -// OnWarning //-------------------------------------------------------------------------- /** - *

Called when the XML parser emits a warning. + * @brief Called when the XML parser emits a warning. * - * \param str warning string + * @param str Warning string */ void BMWStartupHandler::OnWarning(const char *str) { @@ -248,13 +249,11 @@ void BMWStartupHandler::OnWarning(const char *str) std::cerr << std::endl; } -//-------------------------------------------------------------------------- -// OnError //-------------------------------------------------------------------------- /** - *

Called when the XML parser emits an error. + * @brief Called when the XML parser emits an error. * - * \param str error string + * @param str Error string */ void BMWStartupHandler::OnError(const char *str) { @@ -262,13 +261,11 @@ void BMWStartupHandler::OnError(const char *str) std::cerr << std::endl; } -//-------------------------------------------------------------------------- -// OnFatalError //-------------------------------------------------------------------------- /** - *

Called when the XML parser emits a fatal error. + * @brief Called when the XML parser emits a fatal error. * - * \param str fatal error string + * @param str Fatal error string */ void BMWStartupHandler::OnFatalError(const char *str) { @@ -276,26 +273,25 @@ void BMWStartupHandler::OnFatalError(const char *str) std::cerr << std::endl; } -//-------------------------------------------------------------------------- -// OnCdataBlock //-------------------------------------------------------------------------- /** - *

Not used. + * @brief Called when an XML CDATA block is encountered. Not used. * - * \param str not used - * \param len not used + * @param str CDATA content (not used) + * @param len Length of CDATA (not used) */ void BMWStartupHandler::OnCdataBlock(const char *str, int len) { // nothing to be done for now } -//-------------------------------------------------------------------------- -// CheckList //-------------------------------------------------------------------------- /** - *

Check if the default lists are present and if not, feed them with some default settings + * @brief Check if the default lists are present and if not, feed them with some default settings. * + * This method validates all configuration parameters and assigns sensible defaults for any + * parameters that were not specified in the XML file. It handles different modes (LF, LEM, Vortex) + * and ensures that all required parameters are properly initialized. */ void BMWStartupHandler::CheckLists() { diff --git a/src/external/BMWtools/BMWStartupHandler.h b/src/external/BMWtools/BMWStartupHandler.h index 8daf3b760..ba9fa8069 100644 --- a/src/external/BMWtools/BMWStartupHandler.h +++ b/src/external/BMWtools/BMWStartupHandler.h @@ -30,6 +30,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/** + * @file BMWStartupHandler.h + * @brief Header file for the XML startup file handler for BMW tools. + * + * This file contains the BMWStartupHandler class which parses the BMW_startup.xml + * configuration file and provides default settings for the BMWtools plugin libraries. + * + * @author Bastian M. Wojek (based on PStartupHandler.h by Andreas Suter) + */ + #ifndef _BMWSTARTUPHANDLER_H_ #define _BMWSTARTUPHANDLER_H_ @@ -40,32 +50,36 @@ #include /** - *

Handles the XML musrfit startup file (BMW_startup.xml) where default settings for some plugin libraries are stored: - * - TRIM.SP data file path and energies - * - time and field resolutions for Fourier transforms - * - paths to FFTW3 wisdom files (double and float) - * - number of steps for one-dimensional theory functions (where needed) - * - number of steps for two-dimensional grids when calculating spatial field distributions in vortex lattices - * - time resolutions and lengths of Laplace transforms used in the calculation of LF-relaxation functions - * - flag for debugging the information contained in the startup file + * @class BMWStartupHandler + * @brief Handles the XML musrfit startup file (BMW_startup.xml) where default settings for plugin libraries are stored. + * + * This class is a SAX2-based XML parser handler that reads and processes the BMW_startup.xml configuration file. + * The configuration file contains default settings for: + * - TRIM.SP data file path and energies (for low-energy muon implantation profiles) + * - Time and field resolutions for Fourier transforms + * - Paths to FFTW3 wisdom files (double and float precision) + * - Number of steps for one-dimensional theory functions (where needed) + * - Number of steps for two-dimensional grids when calculating spatial field distributions in vortex lattices + * - Time resolutions and lengths of Laplace transforms used in the calculation of LF-relaxation functions + * - Debug flag for verbose output of the information contained in the startup file */ class BMWStartupHandler : public TQObject { public: BMWStartupHandler(); virtual ~BMWStartupHandler(); - virtual void OnStartDocument(); // SLOT - virtual void OnEndDocument(); // SLOT - virtual void OnStartElement(const char*, const TList*); // SLOT - virtual void OnEndElement(const char*); // SLOT - virtual void OnCharacters(const char*); // SLOT - virtual void OnComment(const char*); // SLOT - virtual void OnWarning(const char*); // SLOT - virtual void OnError(const char*); // SLOT - virtual void OnFatalError(const char*); // SLOT - virtual void OnCdataBlock(const char*, int); // SLOT + virtual void OnStartDocument(); ///< Called when XML parsing begins + virtual void OnEndDocument(); ///< Called when XML parsing ends + virtual void OnStartElement(const char*, const TList*); ///< Called when an XML element starts + virtual void OnEndElement(const char*); ///< Called when an XML element ends + virtual void OnCharacters(const char*); ///< Called when XML character data is encountered + virtual void OnComment(const char*); ///< Called when an XML comment is encountered + virtual void OnWarning(const char*); ///< Called when the XML parser emits a warning + virtual void OnError(const char*); ///< Called when the XML parser emits an error + virtual void OnFatalError(const char*); ///< Called when the XML parser emits a fatal error + virtual void OnCdataBlock(const char*, int); ///< Called when an XML CDATA block is encountered - virtual void CheckLists(); + virtual void CheckLists(); ///< Validates and sets default values for configuration parameters virtual const std::string GetDataPath() const { return fDataPath; } ///< returns the path to TRIM.SP files virtual std::map GetEnergies() const { return fEnergies; } ///< returns energies and file labels of available TRIM.SP files @@ -80,28 +94,31 @@ class BMWStartupHandler : public TQObject { virtual const bool GetDebug() const { return fDebug; } ///< true = debug the xml-entries private: + /** + * @brief Enumeration of XML element keywords used for parsing. + */ enum EKeyWords {eEmpty, eComment, eDebug, eLEM, eVortex, eLF, eDataPath, eEnergyLabel, \ eEnergy, eEnergyList, eDeltat, eDeltaB, eWisdomFile, eWisdomFileFloat, \ eNSteps, eGridSteps, eDeltatLF, eNStepsLF}; - EKeyWords fKey; ///< xml filter key + EKeyWords fKey; ///< Current XML element being parsed - bool fDebug; ///< debug flag - bool fLEM; ///< low-energy muSR flag - bool fVortex; ///< vortex-lattice flag - bool fLF; ///< longitudinal-field flag - std::string fDataPath; ///< path to TRIM.SP files - std::vector fEnergyLabelList; ///< file labels of the TRIM.SP files - std::vector fEnergyList; ///< muon implantation energies of the TRIM.SP files - std::map fEnergies; ///< muon implantation energies and file labels of the TRIM.SP files - double fDeltat; ///< time resolution of P(t) when using Fourier transforms - double fDeltaB; ///< field resolution of p(B) when using Fourier transforms - std::string fWisdomFile; ///< FFTW3 double-wisdom file - std::string fWisdomFileFloat; ///< FFTW3 float-wisdom file - unsigned int fNSteps; ///< number of steps in one-dimensional theory functions - unsigned int fGridSteps; ///< number of steps in each direction when calculating two-dimensional spatial field distributions - double fDeltatLF; ///< time resolution of P(t) when using Laplace transforms for the calculation of LF-relaxation functions - unsigned int fNStepsLF; ///< length of the Laplace transforms for the calculation of LF-relaxation functions + bool fDebug; ///< Debug flag for verbose output + bool fLEM; ///< Low-energy muSR mode flag + bool fVortex; ///< Vortex lattice calculations flag + bool fLF; ///< Longitudinal field mode flag + std::string fDataPath; ///< Path to TRIM.SP data files directory + std::vector fEnergyLabelList; ///< File name labels of the TRIM.SP files + std::vector fEnergyList; ///< Muon implantation energies in keV of the TRIM.SP files + std::map fEnergies; ///< Map of muon implantation energies (keV) to file labels + double fDeltat; ///< Time resolution in microseconds for P(t) when using Fourier transforms + double fDeltaB; ///< Field resolution in Gauss for p(B) when using Fourier transforms + std::string fWisdomFile; ///< Path to FFTW3 double-precision wisdom file + std::string fWisdomFileFloat; ///< Path to FFTW3 single-precision wisdom file + unsigned int fNSteps; ///< Number of steps in one-dimensional theory functions + unsigned int fGridSteps; ///< Number of grid points in each direction for 2D spatial field distributions + double fDeltatLF; ///< Time resolution in microseconds for P(t) in LF Laplace transforms + unsigned int fNStepsLF; ///< Length of the Laplace transforms for LF relaxation functions ClassDef(BMWStartupHandler, 1) }; diff --git a/src/external/BMWtools/TTrimSPDataHandler.cpp b/src/external/BMWtools/TTrimSPDataHandler.cpp index d14fbed8e..13cbf1e13 100644 --- a/src/external/BMWtools/TTrimSPDataHandler.cpp +++ b/src/external/BMWtools/TTrimSPDataHandler.cpp @@ -26,6 +26,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/** + * @file TTrimSPDataHandler.cpp + * @brief Implementation of the TRIM.SP muon implantation profile data handler. + * + * This file implements the TTrimSPData class which reads, stores, and manipulates + * low-energy muon implantation profiles calculated by the TRIM.SP Monte Carlo code. + * + * @author Bastian M. Wojek + */ + #include "TTrimSPDataHandler.h" #include #include @@ -36,9 +46,18 @@ #include //-------------------- -// Constructor of the TrimSPData class -- reading all available trim.SP-rge-files with a given name into std::vectors -//-------------------- - +/** + * @brief Constructor of the TTrimSPData class. Reads all available TRIM.SP .rge files. + * + * Reads muon implantation profiles from TRIM.SP .rge files for the specified energies. + * The files are expected to be in the format output by TRIM.SP, with depth in Angstroms + * and muon density n(z) as columns after the "PARTICLES" keyword. + * + * @param path Directory path containing the TRIM.SP .rge files + * @param energies Map of muon energies (keV) to file name labels + * @param debug Enable debug output (default: false) + * @param highRes Use high-resolution (1 Angstrom) grid if non-zero (default: 0) + */ TTrimSPData::TTrimSPData(const std::string &path, std::map &energies, bool debug, unsigned int highRes) { // sort the energies in ascending order - this might be useful for later applications (energy-interpolations etc.) @@ -114,11 +133,18 @@ TTrimSPData::TTrimSPData(const std::string &path, std::map fEnergyIter = fEnergy.end(); } -// Method checking if an implantation profile is available for a given energy -// The behavior is the similar to the find-algorithm but more robust (tiny deviations in the energies are allowed). -// If the given energy is found the methods sets the internal energy iterator to the element of the energy vector. -// If it is not found the energy iterator will point to the end() of the energy vector. - +//-------------------- +/** + * @brief Find an implantation profile for a given energy. + * + * This method checks if an implantation profile is available for the specified energy. + * The behavior is similar to std::find but more robust - tiny deviations in the energies + * are allowed (tolerance of 0.05 keV). If the given energy is found, the method sets the + * internal energy iterator to the corresponding element. If not found, the iterator will + * point to end(). + * + * @param e Muon energy in keV + */ void TTrimSPData::FindEnergy(double e) const { for (fEnergyIter = fEnergy.begin(); fEnergyIter != fEnergy.end(); ++fEnergyIter) { if (fabs(*fEnergyIter - e) < 0.05) @@ -152,9 +178,15 @@ void TTrimSPData::UseHighResolution(double e) { } //--------------------- -// Method returning z-vector calculated by trim.SP for given energy[keV] -//--------------------- - +/** + * @brief Get the depth vector calculated by TRIM.SP for a given energy. + * + * Returns the vector of depth points (in Angstroms) at which n(z) was calculated + * by TRIM.SP for the specified energy. + * + * @param e Muon energy in keV + * @return Vector of depth points in Angstroms. If energy not found, returns first available profile. + */ std::vector TTrimSPData::DataZ(double e) const { FindEnergy(e); @@ -169,10 +201,15 @@ std::vector TTrimSPData::DataZ(double e) const { } //--------------------- -// Method returning actual n(z)-vector calculated by trim.SP and -// potentially altered by the WeightLayers- or the Normalize-method for given energy[keV] -//--------------------- - +/** + * @brief Get the actual n(z) vector for a given energy. + * + * Returns the current n(z) implantation profile which may have been modified by + * WeightLayers or Normalize methods. + * + * @param e Muon energy in keV + * @return Vector of n(z) values. If energy not found, returns first available profile. + */ std::vector TTrimSPData::DataNZ(double e) const { FindEnergy(e); @@ -188,9 +225,15 @@ std::vector TTrimSPData::DataNZ(double e) const { } //--------------------- -// Method returning original n(z)-vector calculated by trim.SP for given energy[keV] -//--------------------- - +/** + * @brief Get the original (unmodified) n(z) vector for a given energy. + * + * Returns the original n(z) implantation profile as read from the .rge file, + * unaffected by any weighting or normalization operations. + * + * @param e Muon energy in keV + * @return Vector of original n(z) values. If energy not found, returns first available profile. + */ std::vector TTrimSPData::OrigDataNZ(double e) const { FindEnergy(e); @@ -220,10 +263,16 @@ double TTrimSPData::DataDZ(double e) const { } //--------------------- -// Method returning fraction of muons implanted in the specified layer for a given energy[keV] -// Parameters: Energy[keV], LayerNumber[1], Interfaces[nm] -//--------------------- - +/** + * @brief Calculate the fraction of muons implanted in a specified layer. + * + * Calculates the fraction of muons stopping in a given layer defined by interface positions. + * + * @param e Muon energy in keV + * @param layno Layer number (starting from 1) + * @param interface Vector of layer interface positions in nm + * @return Fraction of muons in the specified layer (0.0 to 1.0). Returns 0.0 on error. + */ double TTrimSPData::LayerFraction(double e, unsigned int layno, const std::vector& interface) const { if (layno < 1 && layno > (interface.size()+1)) { @@ -267,13 +316,20 @@ double TTrimSPData::LayerFraction(double e, unsigned int layno, const std::vecto } //--------------------- -// Method putting different weight to different layers of your thin film -// Parameters: Implantation Energy[keV], Interfaces[nm], Weights [0.0 <= w[i] <= 1.0] -// Example: 25.0, (50, 100), (1.0, 0.33, 1.0) -// at 25keV consider 3 layers, where the first ends after 50nm, the second after 100nm (these are NOT the layer thicknesses!!) -// the first and last layers get the full n(z), where only one third of the muons in the second layer will be taken into account -//--------------------- - +/** + * @brief Apply different weights to different layers of a thin film sample. + * + * This method allows selective weighting of muon contributions from different layers, + * useful for multi-layer samples where only certain layers are of interest. + * + * @param e Implantation energy in keV + * @param interface Vector of layer interface positions in nm (cumulative depths, NOT layer thicknesses) + * @param weight Vector of weights (0.0 to 1.0) for each layer + * + * @note Example: WeightLayers(25.0, {50, 100}, {1.0, 0.33, 1.0}) + * At 25 keV, consider 3 layers where the first ends at 50 nm and the second at 100 nm. + * The first and last layers get full weight (1.0), while the second layer gets 0.33. + */ void TTrimSPData::WeightLayers(double e, const std::vector& interface, const std::vector& weight) const { if (weight.size()-interface.size()-1) { @@ -342,9 +398,16 @@ void TTrimSPData::WeightLayers(double e, const std::vector& interface, c } //--------------------- -// Method returning n(z) for given z[nm] and energy[keV] -//--------------------- - +/** + * @brief Get interpolated n(z) value at a specific depth and energy. + * + * Returns the muon density at a given depth using linear interpolation between + * the discrete grid points from TRIM.SP. + * + * @param zz Depth in nanometers + * @param e Muon energy in keV + * @return Interpolated n(z) value. Returns 0.0 if z < 0 or beyond profile range. + */ double TTrimSPData::GetNofZ(double zz, double e) const { std::vector z, nz; @@ -382,9 +445,14 @@ double TTrimSPData::GetNofZ(double zz, double e) const { } //--------------------- -// Method normalizing the n(z)-vector calculated by trim.SP for a given energy[keV] -//--------------------- - +/** + * @brief Normalize the n(z) profile to unity integral. + * + * Normalizes the implantation profile so that the integral over all depths equals 1. + * This is useful for converting absolute particle counts to probability densities. + * + * @param e Muon energy in keV + */ void TTrimSPData::Normalize(double e) const { FindEnergy(e); @@ -408,9 +476,12 @@ void TTrimSPData::Normalize(double e) const { } //--------------------- -// Method telling you if the n(z)-vector calculated by trim.SP for a given energy [keV] has been normalized -//--------------------- - +/** + * @brief Check if the n(z) profile for a given energy has been normalized. + * + * @param e Muon energy in keV + * @return true if the profile is normalized, false otherwise + */ bool TTrimSPData::IsNormalized(double e) const { FindEnergy(e); @@ -424,9 +495,15 @@ bool TTrimSPData::IsNormalized(double e) const { } //--------------------- -// Calculate the mean range in (nm) for a given energy e -//--------------------- - +/** + * @brief Calculate the mean implantation depth for a given energy. + * + * Computes the first moment of the implantation profile, giving the average + * stopping depth of muons. + * + * @param e Muon energy in keV + * @return Mean implantation depth in nanometers. Returns -1.0 on error. + */ double TTrimSPData::MeanRange(double e) const { FindEnergy(e); @@ -447,9 +524,14 @@ double TTrimSPData::MeanRange(double e) const { } //--------------------- -// Find the peak range in (nm) for a given energy e -//--------------------- - +/** + * @brief Find the peak position of the implantation profile. + * + * Locates the depth at which the implantation profile has its maximum value. + * + * @param e Muon energy in keV + * @return Peak position in nanometers. Returns -1.0 on error. + */ double TTrimSPData::PeakRange(double e) const { FindEnergy(e); @@ -473,10 +555,17 @@ double TTrimSPData::PeakRange(double e) const { } //--------------------- -// Convolve the n(z)-vector calculated by trim.SP for a given energy e [keV] with a gaussian exp(-z^2/(2*w^2)) -// No normalization is done! -//--------------------- - +/** + * @brief Convolve the implantation profile with a Gaussian. + * + * Convolves the n(z) profile with a Gaussian exp(-z²/(2w²)) to account for + * additional broadening effects (e.g., straggling, surface roughness). + * + * @param w Gaussian width parameter in nanometers + * @param e Muon energy in keV + * + * @note No normalization is performed after convolution. + */ void TTrimSPData::ConvolveGss(double w, double e) const { if (!w) return; diff --git a/src/external/BMWtools/TTrimSPDataHandler.h b/src/external/BMWtools/TTrimSPDataHandler.h index ed2a03cf1..7f46b0086 100644 --- a/src/external/BMWtools/TTrimSPDataHandler.h +++ b/src/external/BMWtools/TTrimSPDataHandler.h @@ -26,6 +26,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +/** + * @file TTrimSPDataHandler.h + * @brief Header file for handling TRIM.SP muon implantation profile data. + * + * This file contains the TTrimSPData class which reads, stores, and manipulates + * low-energy muon implantation profiles calculated by the TRIM.SP Monte Carlo code. + * + * @author Bastian M. Wojek + */ + #ifndef _TTrimSPDataHandler_H_ #define _TTrimSPDataHandler_H_ @@ -34,7 +44,20 @@ #include /** - *

Class used to handle a set of low energy muon implantation profiles + * @class TTrimSPData + * @brief Class used to handle a set of low-energy muon implantation profiles. + * + * This class reads and manages muon implantation depth profiles calculated by the TRIM.SP + * Monte Carlo code. It provides methods to access, manipulate, and analyze the implantation + * profiles for different muon energies. The profiles describe the depth distribution n(z) + * of implanted muons in a material. + * + * Key features: + * - Read multiple TRIM.SP .rge files for different muon energies + * - Interpolation of implantation profiles + * - Layer weighting for multi-layer samples + * - Normalization and convolution operations + * - Calculation of mean and peak implantation depths */ class TTrimSPData { @@ -49,34 +72,34 @@ public: fEnergy.clear(); fDZ.clear(); fIsNormalized.clear(); - } + } ///< Destructor - std::vector Energy() const {return fEnergy;} - std::vector DataZ(double) const; - std::vector DataNZ(double) const; - std::vector OrigDataNZ(double) const; - double DataDZ(double) const; - void UseHighResolution(double); - void SetOriginal() {fOrigDataNZ = fDataNZ;} - void WeightLayers(double, const std::vector&, const std::vector&) const; - double LayerFraction(double, unsigned int, const std::vector&) const; - double GetNofZ(double, double) const; - void Normalize(double) const; - bool IsNormalized(double) const; - void ConvolveGss(double, double) const; - double MeanRange(double) const; - double PeakRange(double) const; + std::vector Energy() const {return fEnergy;} ///< Get vector of available muon energies in keV + std::vector DataZ(double) const; ///< Get depth points (in Angstrom) for a given energy (keV) + std::vector DataNZ(double) const; ///< Get implantation profile n(z) for a given energy (keV) + std::vector OrigDataNZ(double) const; ///< Get original (unmodified) implantation profile for a given energy + double DataDZ(double) const; ///< Get spatial resolution (Angstrom) for a given energy + void UseHighResolution(double); ///< Switch to high-resolution (1 Angstrom) grid for given energy + void SetOriginal() {fOrigDataNZ = fDataNZ;} ///< Store current profiles as new originals + void WeightLayers(double, const std::vector&, const std::vector&) const; ///< Apply layer-dependent weights to profile + double LayerFraction(double, unsigned int, const std::vector&) const; ///< Calculate fraction of muons in specified layer + double GetNofZ(double, double) const; ///< Get interpolated n(z) value at depth z (nm) for given energy (keV) + void Normalize(double) const; ///< Normalize implantation profile to unity integral + bool IsNormalized(double) const; ///< Check if profile for given energy is normalized + void ConvolveGss(double, double) const; ///< Convolve profile with Gaussian of width w (nm) + double MeanRange(double) const; ///< Calculate mean implantation depth (nm) for given energy + double PeakRange(double) const; ///< Find peak position (nm) of implantation profile for given energy private: - void FindEnergy(double) const; + void FindEnergy(double) const; ///< Internal method to locate energy in vector - std::vector fEnergy; ///< vector holding all available muon energies - std::vector fDZ; ///< vector holding the spatial resolution of the TRIM.SP output for all energies - std::vector< std::vector > fDataZ; ///< discrete points in real space for which n(z) has been calculated for all energies - mutable std::vector< std::vector > fDataNZ; ///< n(z) for all energies - std::vector< std::vector > fOrigDataNZ; ///< original (unmodified) implantation profiles for all energies as read in from rge-files - mutable std::vector fIsNormalized; ///< tag indicating if the implantation profiles are normalized (for each energy separately) - mutable std::vector::const_iterator fEnergyIter; ///< iterator traversing the vector of available energies + std::vector fEnergy; ///< Vector holding all available muon energies in keV + std::vector fDZ; ///< Vector holding the spatial resolution (Angstrom) of the TRIM.SP output for all energies + std::vector< std::vector > fDataZ; ///< Discrete depth points in Angstrom for which n(z) has been calculated for all energies + mutable std::vector< std::vector > fDataNZ; ///< Muon density n(z) for all energies (may be modified by weighting/normalization) + std::vector< std::vector > fOrigDataNZ; ///< Original (unmodified) implantation profiles for all energies as read from .rge files + mutable std::vector fIsNormalized; ///< Flag indicating if the implantation profiles are normalized (for each energy separately) + mutable std::vector::const_iterator fEnergyIter; ///< Iterator for traversing the vector of available energies }; #endif // _TTrimSPDataHandler_H_