diff --git a/.gitignore b/.gitignore index f4139b4e2..937bf860c 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,15 @@ tagfile \#* .\#* latex/ + +# OS generated files # +###################### +.DS_Store + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf +indentationStandard/programs/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 10cb4ad5a..0e771fbe4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,16 +51,24 @@ SET(TARGET_SRC ./src/dft/vselfBinsManager.cc ./src/dft/energyCalculator.cc ./src/dft/densityCalculator.cc + ./src/dft/computeAuxProjectedDensityMatrixFromPSI.cc ./src/dft/densityFirstOrderResponseCalculator.cc ./src/dft/applyMultipoleDirichletBC.cc ./src/excManager/excDensityBaseClass.cpp ./src/excManager/excDensityLDAClass.cpp ./src/excManager/excWavefunctionBaseClass.cpp ./src/excManager/excDensityGGAClass.cpp + ./src/excManager/excDensityLLMGGAClass.cpp ./src/excManager/excManager.cpp ./src/excManager/excWavefunctionNoneClass.cpp + ./src/excManager/AuxDensityFE.cpp + ./src/excManager/AuxDensityMatrixSlater.cpp ./src/excManager/NNGGA.cc ./src/excManager/NNLDA.cc + ./src/excManager/NNLLMGGA.cpp + ./src/excManager/SlaterBasisData.cpp + ./src/excManager/SlaterBasisSet.cpp + ./src/excManager/SphericalHarmonicFunc.cpp ./src/poisson/poissonSolverProblem.cc ./src/helmholtz/kerkerSolverProblem.cc ./src/dftOperator/KohnShamHamiltonianOperator.cc @@ -111,6 +119,7 @@ SET(TARGET_SRC ./utils/MPIWriteOnFile.cpp ./utils/QuadDataCompositeWrite.cpp ./utils/PeriodicTable.cc + ./utils/FiniteDifference.cc ./src/dft/dftd.cc ./src/mdi/MDIEngine.cpp ./src/mdi/libraryMDI.cpp diff --git a/demo/ex1/parameterFile_a.prm b/demo/ex1/parameterFile_a.prm index aa9b9404c..56622d61f 100644 --- a/demo/ex1/parameterFile_a.prm +++ b/demo/ex1/parameterFile_a.prm @@ -17,7 +17,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/demo/ex1/parameterFile_b.prm b/demo/ex1/parameterFile_b.prm index e5a070ce7..c429ba838 100644 --- a/demo/ex1/parameterFile_b.prm +++ b/demo/ex1/parameterFile_b.prm @@ -18,7 +18,7 @@ subsection Boundary conditions end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/demo/ex2/parameterFile_a.prm b/demo/ex2/parameterFile_a.prm index 1495e4f6f..7e244fc23 100644 --- a/demo/ex2/parameterFile_a.prm +++ b/demo/ex2/parameterFile_a.prm @@ -41,7 +41,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/demo/ex2/parameterFile_b.prm b/demo/ex2/parameterFile_b.prm index d4055aedd..81e61f357 100644 --- a/demo/ex2/parameterFile_b.prm +++ b/demo/ex2/parameterFile_b.prm @@ -43,7 +43,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/demo/ex3/parameterFile.prm b/demo/ex3/parameterFile.prm index 49c97c659..6f29c8996 100644 --- a/demo/ex3/parameterFile.prm +++ b/demo/ex3/parameterFile.prm @@ -39,7 +39,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/doc/manual/manual.tex b/doc/manual/manual.tex index 73538303d..302ad2a58 100644 --- a/doc/manual/manual.tex +++ b/doc/manual/manual.tex @@ -136,7 +136,7 @@ \hfill{\Huge \fontfamily{\sfdefault}\selectfont User Manual \\ \raggedleft \huge \fontfamily{\sfdefault}\selectfont Version % keep the following line as is so that we can replace this using a script: -1.1.0-pre (dev) %VERSION-INFO% +1.2.0-pre (dev) %VERSION-INFO% \\\large(generated \today)\\ \vspace{1.5em} {\Large Sambit Das\,\\Vikram Gavini\,\\Phani Motamarri\\} diff --git a/doc/manual/parameters.tex b/doc/manual/parameters.tex index bd4f02624..ca3ba9bef 100644 --- a/doc/manual/parameters.tex +++ b/doc/manual/parameters.tex @@ -512,16 +512,16 @@ \subsection{Parameters in section \tt DFT functional parameters} \index[prmindex]{EXCHANGE CORRELATION TYPE} \index[prmindexfull]{DFT functional parameters!EXCHANGE CORRELATION TYPE} -{\it Value:} 1 +{\it Value:} GGA-PBE -{\it Default:} 1 +{\it Default:} GGA-PBE -{\it Description:} [Standard] Parameter specifying the type of exchange-correlation to be used: 1(LDA: Perdew Zunger Ceperley Alder correlation with Slater Exchange[PRB. 23, 5048 (1981)]), 2(LDA: Perdew-Wang 92 functional with Slater Exchange [PRB. 45, 13244 (1992)]), 3(LDA: Vosko, Wilk \& Nusair with Slater Exchange[Can. J. Phys. 58, 1200 (1980)]), 4(GGA: Perdew-Burke-Ernzerhof functional [PRL. 77, 3865 (1996)], 5(RPBE: B. Hammer, L. B. Hansen, and J. K. Nørskov, Phys. Rev. B 59, 7413 (1999)), 6(ML-XC NNLDA: LDA-PW + NN), 7(ML-XC NNGGA: GGA-PBE + NN). Caution: options 6-7 are experimental and only accessible to the DFT-FE developers currently. +{\it Description:} [Standard] Parameter specifying the type of exchange-correlation to be used: LDA-PZ (Perdew Zunger Ceperley Alder correlation with Slater Exchange[PRB. 23, 5048 (1981)]), LDA-PW (Perdew-Wang 92 functional with Slater Exchange [PRB. 45, 13244 (1992)]), LDA-VWN (Vosko, Wilk \& Nusair with Slater Exchange[Can. J. Phys. 58, 1200 (1980)]), GGA-PBE (Perdew-Burke-Ernzerhof functional [PRL. 77, 3865 (1996)]), GGA-RPBE (RPBE: B. Hammer, L. B. Hansen, and J. K. Nørskov, Phys. Rev. B 59, 7413 (1999)), MLXC-NNLDA (LDA-PW + NN-LDA), MLXC-NNGGA (GGA-PBE + NN-GGA), MLXC-NNLLMGGA (GGA-PBE + NN Laplacian level MGGA). Caution: MLXC options are experimental. -{\it Possible values:} An integer $n$ such that $1\leq n \leq 8$ +{\it Possible values:} Any one of LDA-PZ, LDA-PW, LDA-VWN, GGA-PBE, GGA-RPBE, MLXC-NNLDA, MLXC-NNGGA, and MLXC-NNLLMGGA \item {\it Parameter name:} {\tt MODEL XC INPUT FILE} \phantomsection\label{parameters:DFT functional parameters/MODEL XC INPUT FILE} \label{parameters:DFT_20functional_20parameters/MODEL_20XC_20INPUT_20FILE} @@ -535,8 +535,40 @@ \subsection{Parameters in section \tt DFT functional parameters} {\it Default:} -{\it Description:} [Developer] File that contains both the pytorch ML-XC NN model (.ptc file) and the tolerances. This is an experimental feature to test out any new XC functional developed using machine learning. +{\it Description:} [Developer] File that contains both the pytorch MLXC NN model (.ptc file) and the tolerances. This is an experimental feature to test out any new XC functional developed using machine learning. + +{\it Possible values:} Any string +\item {\it Parameter name:} {\tt AUX BASIS TYPE} +\phantomsection\label{parameters:DFT functional parameters/AUX BASIS TYPE} +\label{parameters:DFT_20functional_20parameters/AUX_20BASIS_20TYPE} + + +\index[prmindex]{AUX BASIS TYPE} +\index[prmindexfull]{DFT functional parameters!AUX BASIS TYPE} +{\it Value:} FE + + +{\it Default:} FE + + +{\it Description:} [Developer] Auxiliary basis for projecting the Kohn-Sham density or density matrix for XC evaluation. FE is the default option. + + +{\it Possible values:} Any one of FE, SLATER, and PW +\item {\it Parameter name:} {\tt AUX BASIS DATA} +\phantomsection\label{parameters:DFT functional parameters/AUX BASIS DATA} +\label{parameters:DFT_20functional_20parameters/AUX_20BASIS_20DATA} + + +\index[prmindex]{AUX BASIS DATA} +\index[prmindexfull]{DFT functional parameters!AUX BASIS DATA} +{\it Value:} + + +{\it Default:} + +{\it Description:} [Developer] File that contains additional information for the Auxiliary basis selected in AUX BASIS TYPE. {\it Possible values:} Any string \item {\it Parameter name:} {\tt NET CHARGE} diff --git a/doc/manual/rundftfe.tex b/doc/manual/rundftfe.tex index 15ac399ce..3adf40c83 100644 --- a/doc/manual/rundftfe.tex +++ b/doc/manual/rundftfe.tex @@ -105,14 +105,14 @@ \subsubsection{Example 1}\label{sec:example1} Set the required DFT functional input parameters for pseudopotential calculation \begin{verbatim} subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end \end{verbatim} where \begin{itemize} -\item The choice of ``4'' for \verb|EXCHANGE CORRELATION TYPE| corresponds to ``GGA: Perdew-Burke-Ernzerhof +\item The choice of ``GGA-PBE'' for \verb|EXCHANGE CORRELATION TYPE| corresponds to ``Perdew-Burke-Ernzerhof functional [PRL. 77, 3865 (1996)]'' functional. \item ``pseudo.inp'', given as input to \verb|PSEUDOPOTENTIAL FILE NAMES LIST| is an external file (any other file name can be used) in the same workspace, which contains the list of pseudopotential file names in \verb|UPF| format corresponding to the atom types involved in the calculations. The file is formatted as diff --git a/include/AuxDensityFE.h b/include/AuxDensityFE.h new file mode 100644 index 000000000..9b7181f49 --- /dev/null +++ b/include/AuxDensityFE.h @@ -0,0 +1,79 @@ +// +// Created by Sambit Das. +// + +#ifndef DFTFE_AUXDM_AUXDENSITYFE_H +#define DFTFE_AUXDM_AUXDENSITYFE_H + +#include +#include +#include + +namespace dftfe +{ + class AuxDensityFE : public AuxDensityMatrix + { + public: + // CAUTION: points have to be a contiguous subset of d_quadPointsSet + void + applyLocalOperations( + const std::vector &points, + std::unordered_map> + &densityData) override; + + void + evalOverlapMatrixStart(const std::vector &quadpts, + const std::vector &quadWt) override; + + void + evalOverlapMatrixEnd(const MPI_Comm &mpiComm) override; + + void + projectDensityMatrixStart( + std::unordered_map> &projectionInputs, + int iSpin) override; + + void + projectDensityMatrixEnd(const MPI_Comm &mpiComm) override; + + /** + * @brief Projects the quadrature density to aux basis (L2 projection). + * This is actually a copy call. All the local partition quadrature points + * must to be passed to this function in one go + * + * @param projectionInputs is a map from string to inputs needed + * for projection. + * projectionInputs["quadpts"], + * projectionInputs["quadWt"], + * projectionInputs["densityFunc"] + * projectionInputs["gradDensityFunc"] + * + * densityFunc The density Values at quad points + * densityFunc(spin_index, quad_index), + * quad_index is fastest. + * + * gradDensityFunc The density Values at quad points + * gradDensityFunc(spin_index, quad_index,dim_index), + * dim_index is fastest. + * + */ + void + projectDensityStart(std::unordered_map> + &projectionInputs) override; + + void + projectDensityEnd(const MPI_Comm &mpiComm) override; + + + private: + std::vector d_densityValsTotalAllQuads; + std::vector d_densityValsSpinUpAllQuads; + std::vector d_densityValsSpinDownAllQuads; + std::vector d_gradDensityValsSpinUpAllQuads; + std::vector d_gradDensityValsSpinDownAllQuads; + std::vector d_quadPointsAll; + std::vector d_quadWeightsAll; + }; +} // namespace dftfe + +#endif // DFTFE_AUXDM_AUXDENSITYFE_H diff --git a/include/AuxDensityMatrix.h b/include/AuxDensityMatrix.h new file mode 100644 index 000000000..9d6af2c2b --- /dev/null +++ b/include/AuxDensityMatrix.h @@ -0,0 +1,87 @@ +// +// Created by Arghadwip Paul. +// + +#ifndef DFTFE_AUXDM_AUXDENSITYMATRIX_H +#define DFTFE_AUXDM_AUXDENSITYMATRIX_H + +#include +#include +#include +#include +#include +#include + +namespace dftfe +{ + enum class DensityDescriptorDataAttributes + { + valuesTotal, + valuesSpinUp, + valuesSpinDown, + gradValuesSpinUp, + gradValuesSpinDown, + hessianSpinUp, + hessianSpinDown, + laplacianSpinUp, + laplacianSpinDown + }; + + class AuxDensityMatrix + { + public: + /** + * @brief compute local descriptors of the aux basis electron-density + * representation at the supplied set of points using + */ + virtual void + applyLocalOperations( + const std::vector &Points, + std::unordered_map> + &densityData) = 0; + + /** + * @brief Compute aux basis overlap matrix batchwise contribution from + * supplied set of quadrature points and their associated weights + */ + virtual void + evalOverlapMatrixStart(const std::vector &quadpts, + const std::vector &quadWt) = 0; + + /** + * @brief for MPI accumulation + */ + virtual void + evalOverlapMatrixEnd(const MPI_Comm &mpiComm) = 0; + + /** + * @brief Projects the KS density matrix to aux basis (L2 projection) batch wise + */ + virtual void + projectDensityMatrixStart( + std::unordered_map> &projectionInputs, + int iSpin) = 0; + + /** + * @brief for MPI accumulation + */ + virtual void + projectDensityMatrixEnd(const MPI_Comm &mpiComm) = 0; + + + /** + * @brief Projects the quadrature density to aux basis (L2 projection) batch wise + */ + virtual void + projectDensityStart(std::unordered_map> + &projectionInputs) = 0; + + /** + * @brief for MPI accumulation + */ + virtual void + projectDensityEnd(const MPI_Comm &mpiComm) = 0; + }; +} // namespace dftfe + +#endif // DFTFE_AUXDM_AUXDENSITYMATRIX_H diff --git a/include/AuxDensityMatrixSlater.h b/include/AuxDensityMatrixSlater.h new file mode 100644 index 000000000..ec0bad827 --- /dev/null +++ b/include/AuxDensityMatrixSlater.h @@ -0,0 +1,104 @@ +// +// Created by Arghadwip Paul. +// + +#ifndef DFTFE_AUXDM_AUXDENSITYMATRIXSLATER_H +#define DFTFE_AUXDM_AUXDENSITYMATRIXSLATER_H + +#ifdef DFTFE_WITH_TORCH + +# include "AuxDensityMatrix.h" +# include "SlaterBasisSet.h" +# include "SlaterBasisData.h" +# include +# include +# include +# include + + +namespace dftfe +{ + class AuxDensityMatrixSlater : public AuxDensityMatrix + { + private: + int d_nQuad; + int d_nSpin; + SlaterBasisSet d_sbs; + SlaterBasisData d_sbd; + + int d_nBasis; + int d_maxDerOrder; + + std::vector d_DM; + std::vector d_SMatrix; + std::vector d_SMatrixInv; + std::vector d_SWFC; + std::vector d_fValues; + + int d_nWFC; + int d_iSpin; + + + void + evalOverlapMatrixInv(); + std::vector & + getOverlapMatrixInv(); + + public: + void + applyLocalOperations( + const std::vector &Points, + std::unordered_map> + &densityData) override; + + void + reinitAuxDensityMatrix( + const std::vector>> + & atomCoords, + const std::string &auxBasisFile, + const int nSpin, + const int maxDerOrder); + + void + evalOverlapMatrixStart(const std::vector &quadpts, + const std::vector &quadWt) override; + + void + evalOverlapMatrixEnd(const MPI_Comm &mpiComm) override; + + // FIXME: to be extended for complex valued wavefunctions + /** + * + * @param projectionInputs is a map from string to inputs needed + * for projection. + * eg - projectionInputs["quadpts"], + * projectionInputs["quadWt"], + * projectionInputs["psiFunc"], + * projectionInputs["fValues"] + * + * psiFunc The SCF wave function or eigen function in FE Basis. + * psiFunc(quad_index, wfc_index), + * quad_index is fastest. + * fValues are the occupancies. + * + * @param iSpin indicates up (iSpin = 0) or down (iSpin = 0) spin. + * + */ + void + projectDensityMatrixStart( + std::unordered_map> &projectionInputs, + int iSpin) override; + + void + projectDensityMatrixEnd(const MPI_Comm &mpiComm) override; + + void + projectDensityStart(std::unordered_map> + &projectionInputs) override; + + void + projectDensityEnd(const MPI_Comm &mpiComm) override; + }; +} // namespace dftfe +#endif +#endif // DFTFE_AUXDM_AUXDENSITYMATRIXSLATER_H diff --git a/include/FiniteDifference.h b/include/FiniteDifference.h new file mode 100644 index 000000000..0e8451a7f --- /dev/null +++ b/include/FiniteDifference.h @@ -0,0 +1,59 @@ +#ifndef DFTFE_FiniteDifference_H +#define DFTFE_FiniteDifference_H + +#include + +namespace dftfe +{ + namespace utils + { + class FiniteDifference + { + public: + static std::vector + getStencilGridOneVariableCentral(const unsigned int totalStencilSize, + const double h); + + + + // stencil index is the fastest index in stencilDataAllQuadPoints + // memory for firstOrderDerivative is assumed to be allocated + static void + firstOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * firstOrderDerivative); + + static void + firstOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double * h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * firstOrderDerivative); + + + // stencil index is the fastest index in stencilDataAllQuadPoints + // memory for secondOrderDerivative is assumed to be allocated + static void + secondOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * secondOrderDerivative); + + static void + secondOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double * h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * secondOrderDerivative); + }; + } // namespace utils +} // namespace dftfe + +#endif // DFTFE_FiniteDifference_H diff --git a/include/KohnShamHamiltonianOperator.h b/include/KohnShamHamiltonianOperator.h index c05a6cf23..a8f44b1f3 100644 --- a/include/KohnShamHamiltonianOperator.h +++ b/include/KohnShamHamiltonianOperator.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace dftfe { @@ -85,23 +86,15 @@ namespace dftfe /** * @brief Computes effective potential involving exchange-correlation functionals - * @param rhoValues electron-density + * @param auxDensityMatrixRepresentation core plus valence electron-density * @param phiValues electrostatic potential arising both from electron-density and nuclear charge - * @param rhoCoreValues quadrature data of sum{Vext} minus sum{Vnu} */ void computeVEff( - const std::vector< - dftfe::utils::MemoryStorage> - &rhoValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradRhoValues, + std::shared_ptr auxDensityXCRepresentationPtr, const dftfe::utils::MemoryStorage - & phiValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - const unsigned int spinIndex = 0); + & phiValues, + const unsigned int spinIndex = 0); void computeVEffExternalPotCorr( @@ -110,23 +103,16 @@ namespace dftfe void computeVEffPrime( - const std::vector< - dftfe::utils::MemoryStorage> - &rhoValues, + std::shared_ptr auxDensityXCRepresentationPtr, const std::vector< dftfe::utils::MemoryStorage> &rhoPrimeValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradRhoValues, const std::vector< dftfe::utils::MemoryStorage> &gradRhoPrimeValues, const dftfe::utils::MemoryStorage - & phiPrimeValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - const unsigned int spinIndex); + & phiPrimeValues, + const unsigned int spinIndex); /** * @brief sets the data member to appropriate kPoint and spin Index diff --git a/include/NNLLMGGA.h b/include/NNLLMGGA.h new file mode 100644 index 000000000..65cae3c50 --- /dev/null +++ b/include/NNLLMGGA.h @@ -0,0 +1,43 @@ +#ifndef NNLLMGGA_H +#define NNLLMGGA_H +#ifdef DFTFE_WITH_TORCH +# include +# include +# include +namespace dftfe +{ + class NNLLMGGA + { + public: + NNLLMGGA(std::string modelFileName, + const bool isSpinPolarized = false, + const excDensityPositivityCheckTypes densityPositivityCheckType = + excDensityPositivityCheckTypes::MAKE_POSITIVE); + ~NNLLMGGA(); + + void + evaluateexc(const double * rho, + const double * sigma, + const double * laprho, + const unsigned int numPoints, + double * exc); + void + evaluatevxc(const double * rho, + const double * sigma, + const double * laprho, + const unsigned int numPoints, + double * exc, + double * dexc); + + private: + std::string d_modelFilename; + std::string d_ptcFilename; + torch::jit::script::Module * d_model; + const bool d_isSpinPolarized; + double d_rhoTol; + double d_sThreshold; + const excDensityPositivityCheckTypes d_densityPositivityCheckType; + }; +} // namespace dftfe +#endif +#endif // NNLLMGGA_H diff --git a/include/SlaterBasisData.h b/include/SlaterBasisData.h new file mode 100644 index 000000000..e21a0d420 --- /dev/null +++ b/include/SlaterBasisData.h @@ -0,0 +1,67 @@ +// +// Created by Arghadwip Paul on 2/15/24. +// + +#ifndef DFTFE_SLATER_SLATERBASISDATA_H +#define DFTFE_SLATER_SLATERBASISDATA_H + +#ifdef DFTFE_WITH_TORCH + +# include +# include +# include +# include "SlaterBasisSet.h" +# include "SphericalHarmonicFunc.h" + +namespace dftfe +{ + class SlaterBasisData + { + public: + // Public Member functions declarations + void + evalBasisData(const std::vector &quadpts, + const SlaterBasisSet & sbs, + int maxDerOrder); + + double + getBasisValues(const int index); + + std::vector + getBasisValuesAll(); + + double + getBasisGradValues(const int index); + + double + getBasisHessianValues(const int index); + + + private: + // Member variables + std::vector basisValues; + std::vector basisGradValues; + std::vector basisHessValues; + + void + evalBasisValues(const std::vector &quadpts, + const SlaterBasisSet & sbs); + + void + evalBasisGradValues(const std::vector &quadpts, + const SlaterBasisSet & sbs); + + void + evalBasisHessianValues(const std::vector &quadpts, + const SlaterBasisSet & sbs); + + torch::Tensor + evalSlaterFunc(const torch::Tensor & x_s, + const torch::Tensor & y_s, + const torch::Tensor & z_s, + const SlaterPrimitive *sp); + }; +} // namespace dftfe + +#endif +#endif // DFTFE_SLATER_SLATERBASISDATA_H diff --git a/include/SlaterBasisSet.h b/include/SlaterBasisSet.h new file mode 100644 index 000000000..b25345e1d --- /dev/null +++ b/include/SlaterBasisSet.h @@ -0,0 +1,67 @@ +// +// Created by Arghadwip Paul. +// + +#ifndef DFTFE_SLATER_SLATERBASISSET_H +#define DFTFE_SLATER_SLATERBASISSET_H + +#include +#include +#include +#include + +namespace dftfe +{ + struct SlaterPrimitive + { + int n; // principal quantum number + int l; // azimuthal (angular) quantum number + int m; // magnetic quantum number + double alpha; // exponent of the basis + }; + + struct SlaterBasisInfo + { + std::string symbol; // atom name + std::vector center; // atom center coordinates + const SlaterPrimitive *sp; // pointer to the Slater basis + }; + + class SlaterBasisSet + { + private: + // std::unordered_map d_atomToSlaterBasisName; + + std::unordered_map> + d_atomToSlaterPrimitivePtr; + + std::vector d_SlaterBasisInfo; + + std::unordered_map + readAtomToSlaterBasisName(const std::string &fileName); + + void + addSlaterPrimitivesFromBasisFile(const std::string &atomSymbol, + const std::string &basisName); + + public: + SlaterBasisSet(); // Constructor + ~SlaterBasisSet(); // Destructor + + + void + constructBasisSet( + const std::vector>> + & atomCoords, + const std::string &auxBasisFileName); + + + const std::vector & + getSlaterBasisInfo() const; + + int + getSlaterBasisSize() const; + }; +} // namespace dftfe + +#endif // DFTFE_SLATER_SLATERBASISSET_H diff --git a/include/SphericalHarmonicFunc.h b/include/SphericalHarmonicFunc.h new file mode 100644 index 000000000..9920a3225 --- /dev/null +++ b/include/SphericalHarmonicFunc.h @@ -0,0 +1,28 @@ +// +// Created by Arghadwip Paul. +// + +#ifndef DFTFE_SLATER_SPHERICALHARMONICFUNC_H +#define DFTFE_SLATER_SPHERICALHARMONICFUNC_H + +#ifdef DFTFE_WITH_TORCH + +# include + +namespace dftfe +{ + double + Dm(const int m); + double + Clm(const int l, const int absm); + torch::Tensor + Rn(const int n, const double alpha, const torch::Tensor &r); + torch::Tensor + Qm(const int m, const torch::Tensor &phi); + torch::Tensor + associatedLegendre(const int l, const int absm, const torch::Tensor &x); + +} // namespace dftfe + +#endif +#endif // DFTFE_SLATER_SPHERICALHARMONICFUNC_H diff --git a/include/computeAuxProjectedDensityMatrixFromPSI.h b/include/computeAuxProjectedDensityMatrixFromPSI.h new file mode 100644 index 000000000..57b12ca8d --- /dev/null +++ b/include/computeAuxProjectedDensityMatrixFromPSI.h @@ -0,0 +1,52 @@ +// --------------------------------------------------------------------- +// +// Copyright (c) 2017-2022 The Regents of the University of Michigan and DFT-FE +// authors. +// +// This file is part of the DFT-FE code. +// +// The DFT-FE code is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the DFT-FE distribution. +// +// --------------------------------------------------------------------- +// + +#ifndef computeAuxProjectedDensityMatrixFromPSI_H_ +#define computeAuxProjectedDensityMatrixFromPSI_H_ + +#include +#include +#include +#include + +namespace dftfe +{ + template + void + computeAuxProjectedDensityMatrixFromPSI( + const dftfe::utils::MemoryStorage &X, + const unsigned int totalNumWaveFunctions, + const std::vector> &eigenValues, + const double fermiEnergy, + const double fermiEnergyUp, + const double fermiEnergyDown, + std::shared_ptr< + dftfe::basis::FEBasisOperations> + &basisOperationsPtr, + std::shared_ptr> + & BLASWrapperPtr, + const unsigned int matrixFreeDofhandlerIndex, + const unsigned int quadratureIndex, + const std::vector &kPointWeights, + AuxDensityMatrix & auxDensityMatrixRepresentation, + const MPI_Comm & mpiCommParent, + const MPI_Comm & domainComm, + const MPI_Comm & interpoolcomm, + const MPI_Comm & interBandGroupComm, + const dftParameters & dftParams); +} // namespace dftfe +#endif diff --git a/include/dft.h b/include/dft.h index 0b2b75577..928a3a986 100644 --- a/include/dft.h +++ b/include/dft.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ #include #include +#include namespace dftfe { @@ -1023,6 +1025,29 @@ namespace dftfe applyPeriodicBCHigherOrderNodes(); + void + updateAuxDensityXCMatrix( + const std::vector< + dftfe::utils::MemoryStorage> + &densityQuadValues, + const std::vector< + dftfe::utils::MemoryStorage> + &gradDensityQuadValues, + const std::map> &rhoCore, + const std::map> &gradRhoCore, + const dftfe::utils::MemoryStorage + &eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + const dftfe::utils::MemoryStorage + &eigenVectorsFlattenedDevice, +#endif + const std::vector> &eigenValues, + const double fermiEnergy_, + const double fermiEnergyUp_, + const double fermiEnergyDown_, + std::shared_ptr auxDensityMatrixXCPtr); std::shared_ptr d_excManagerPtr; dispersionCorrection d_dispersionCorr; @@ -1454,6 +1479,9 @@ namespace dftfe d_densityTotalOutValuesLpspQuad, d_densityTotalInValuesLpspQuad, d_gradDensityTotalOutValuesLpspQuad, d_gradDensityTotalInValuesLpspQuad; + std::shared_ptr d_auxDensityMatrixXCInPtr; + std::shared_ptr d_auxDensityMatrixXCOutPtr; + // For multipole boundary conditions double d_monopole; std::vector d_dipole; diff --git a/include/dftParameters.h b/include/dftParameters.h index 9774a0dc8..0b3c7f403 100644 --- a/include/dftParameters.h +++ b/include/dftParameters.h @@ -36,8 +36,8 @@ namespace dftfe public: unsigned int finiteElementPolynomialOrder, finiteElementPolynomialOrderElectrostatics, n_refinement_steps, - numberEigenValues, xc_id, spinPolarized, nkx, nky, nkz, offsetFlagX, - offsetFlagY, offsetFlagZ; + numberEigenValues, spinPolarized, nkx, nky, nkz, offsetFlagX, offsetFlagY, + offsetFlagZ; unsigned int chebyshevOrder, numPass, numSCFIterations, maxLinearSolverIterations, mixingHistory, npool, numberWaveFunctionsForEstimate, numLevels, @@ -45,7 +45,10 @@ namespace dftfe bool poissonGPU; bool vselfGPU; + std::string XCType; std::string modelXCInputFile; + std::string auxBasisTypeXC; + std::string auxBasisDataXC; double radiusAtomBall, mixingParameter, spinMixingEnhancementFactor; bool adaptAndersonMixingParameter; diff --git a/include/energyCalculator.h b/include/energyCalculator.h index 5d104fa05..279a8a254 100644 --- a/include/energyCalculator.h +++ b/include/energyCalculator.h @@ -20,6 +20,7 @@ #include #include "dftParameters.h" #include +#include #ifndef energyCalculator_H_ # define energyCalculator_H_ @@ -124,16 +125,13 @@ namespace dftfe const std::vector< dftfe::utils::MemoryStorage> &densityOutValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradDensityInValues, const std::vector< dftfe::utils::MemoryStorage> &gradDensityOutValues, const dftfe::utils::MemoryStorage - & rhoOutValuesLpsp, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, + & rhoOutValuesLpsp, + std::shared_ptr auxDensityXCInRepresentationPtr, + std::shared_ptr auxDensityXCOutRepresentationPtr, const std::map> &smearedbValues, const std::map> & smearedbNonTrivialAtomIds, @@ -180,9 +178,9 @@ namespace dftfe &gradDensityInValues, const std::vector< dftfe::utils::MemoryStorage> - & gradDensityOutValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, + & gradDensityOutValues, + std::shared_ptr AuxDensityXCInRepresentationPtr, + std::shared_ptr AuxDensityXCOutRepresentationPtr, const std::map> &smearedbValues, const std::map> & smearedbNonTrivialAtomIds, @@ -206,46 +204,12 @@ namespace dftfe &densityInValues, const std::vector< dftfe::utils::MemoryStorage> - &densityOutValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradDensityInValues, - const std::vector< - dftfe::utils::MemoryStorage> - & gradDensityOutValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - double & exchangeEnergy, - double & correlationEnergy, - double &excCorrPotentialTimesRho); - - void - computeXCEnergyTerms( - const std::shared_ptr< - dftfe::basis::FEBasisOperations> - & basisOperationsPtr, - const unsigned int quadratureId, - const std::shared_ptr excManagerPtr, - const std::vector< - dftfe::utils::MemoryStorage> - &densityInValues, - const std::vector< - dftfe::utils::MemoryStorage> - &densityOutValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradDensityInValues, - const std::vector< - dftfe::utils::MemoryStorage> - & gradDensityOutValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - double & exchangeEnergy, - double & correlationEnergy, - double &excCorrPotentialTimesRho); - + & gradDensityOutValues, + std::shared_ptr AuxDensityXCInRepresentationPtr, + std::shared_ptr auxDensityXCOutRepresentationPtr, + double & exchangeEnergy, + double & correlationEnergy, + double & excCorrPotentialTimesRho); double computeEntropicEnergy(const std::vector> &eigenValues, diff --git a/include/eshelbyTensor.h b/include/eshelbyTensor.h index cb18c6856..fc6420390 100644 --- a/include/eshelbyTensor.h +++ b/include/eshelbyTensor.h @@ -92,7 +92,6 @@ namespace dftfe /// exchange-correlation part of the ELoc Eshelby tensor dealii::Tensor<2, 3, dealii::VectorizedArray> getELocXcEshelbyTensor( - const dealii::VectorizedArray & rho, const dealii::Tensor<1, 3, dealii::VectorizedArray> &gradRho, const dealii::VectorizedArray & exc, const dealii::Tensor<1, 3, dealii::VectorizedArray> diff --git a/include/eshelbyTensorSpinPolarized.h b/include/eshelbyTensorSpinPolarized.h index 75934bb4c..01d017db6 100644 --- a/include/eshelbyTensorSpinPolarized.h +++ b/include/eshelbyTensorSpinPolarized.h @@ -55,7 +55,6 @@ namespace dftfe /// exchange-correlation and psp part of the ELoc Eshelby tensor dealii::Tensor<2, 3, dealii::VectorizedArray> getELocXcEshelbyTensor( - const dealii::VectorizedArray & rho, const dealii::Tensor<1, 3, dealii::VectorizedArray> &gradRhoSpin0, const dealii::Tensor<1, 3, dealii::VectorizedArray> &gradRhoSpin1, const dealii::VectorizedArray & exc, diff --git a/include/excDensityBaseClass.h b/include/excDensityBaseClass.h index d0fcc3a8d..726238bf1 100644 --- a/include/excDensityBaseClass.h +++ b/include/excDensityBaseClass.h @@ -19,78 +19,67 @@ #ifndef DFTFE_EXCDENSITYBASECLASS_H #define DFTFE_EXCDENSITYBASECLASS_H -//#include -#include #include #include #include #include -//#include +#include "AuxDensityMatrix.h" namespace dftfe { enum class densityFamilyType { LDA, - GGA - }; - // enum class for identifying the relevant objects for exc manager class - enum class rhoDataAttributes - { - values, - sigmaGradValue + GGA, + LLMGGA, }; - enum class VeffOutputDataAttributes + enum class xcOutputDataAttributes { - derEnergyWithDensity, - derEnergyWithSigmaGradDensity + e, // energy density per unit volume + vSpinUp, + vSpinDown, + pdeDensitySpinUp, + pdeDensitySpinDown, + pdeSigma, + pdeLaplacianSpinUp, + pdeLaplacianSpinDown }; - enum class fxcOutputDataAttributes - { - der2EnergyWithDensity, - der2EnergyWithDensitySigma, - der2EnergyWithSigma - }; - - class excDensityBaseClass { public: - excDensityBaseClass(bool isSpinPolarized); + excDensityBaseClass(const densityFamilyType familyType, + const std::vector + &densityDescriptorAttributesList); + densityFamilyType + getDensityBasedFamilyType() const; - virtual void - computeDensityBasedEnergyDensity( - unsigned int sizeInput, - const std::map *> &rhoData, - std::vector &outputExchangeEnergyDensity, - std::vector &outputCorrEnergyDensity) const = 0; + const std::vector & + getDensityDescriptorAttributesList() const; + /** + * x and c denotes exchange and correlation respectively + */ virtual void - computeDensityBasedVxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDerExchangeEnergy, - std::map *> - &outputDerCorrEnergy) const = 0; + computeExcVxcFxc( + AuxDensityMatrix & auxDensityMatrix, + const std::vector &quadPoints, + const std::vector &quadWeights, + std::unordered_map> &xDataOut, + std::unordered_map> &cDataout) + const = 0; + protected: virtual void - computeDensityBasedFxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDer2ExchangeEnergy, - std::map *> - &outputDer2CorrEnergy) const = 0; + checkInputOutputDataAttributesConsistency( + const std::vector &outputDataAttributes) + const = 0; - densityFamilyType - getDensityBasedFamilyType() const; - protected: - densityFamilyType d_familyType; - bool d_isSpinPolarized; + const densityFamilyType d_familyType; + const std::vector + d_densityDescriptorAttributesList; }; } // namespace dftfe diff --git a/include/excDensityGGAClass.h b/include/excDensityGGAClass.h index a7e6f9f45..2fc8e0e4c 100644 --- a/include/excDensityGGAClass.h +++ b/include/excDensityGGAClass.h @@ -17,62 +17,44 @@ #ifndef DFTFE_EXCDENSITYGGACLASS_H #define DFTFE_EXCDENSITYGGACLASS_H -//#include +#include #include - namespace dftfe { class NNGGA; class excDensityGGAClass : public excDensityBaseClass { public: - excDensityGGAClass(xc_func_type *funcXPtr, - xc_func_type *funcCPtr, - bool isSpinPolarized, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor); + excDensityGGAClass(xc_func_type *funcXPtr, xc_func_type *funcCPtr); + excDensityGGAClass(xc_func_type *funcXPtr, xc_func_type *funcCPtr, - bool isSpinPolarized, - std::string modelXCInputFile, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor); + std::string modelXCInputFile); - ~excDensityGGAClass(); - void - computeDensityBasedEnergyDensity( - unsigned int sizeInput, - const std::map *> &rhoData, - std::vector &outputExchangeEnergyDensity, - std::vector &outputCorrEnergyDensity) const override; + ~excDensityGGAClass(); void - computeDensityBasedVxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDerExchangeEnergy, - std::map *> - &outputDerCorrEnergy) const override; + computeExcVxcFxc( + AuxDensityMatrix & auxDensityMatrix, + const std::vector &quadPoints, + const std::vector &quadWeights, + std::unordered_map> &xDataOut, + std::unordered_map> &cDataout) + const override; void - computeDensityBasedFxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDer2ExchangeEnergy, - std::map *> - &outputDer2CorrEnergy) const override; - + checkInputOutputDataAttributesConsistency( + const std::vector &outputDataAttributes) + const override; private: - NNGGA * d_NNGGAPtr; - xc_func_type *d_funcXPtr; - xc_func_type *d_funcCPtr; + NNGGA * d_NNGGAPtr; + xc_func_type * d_funcXPtr; + xc_func_type * d_funcCPtr; + std::vector d_spacingFDStencil; + unsigned int d_vxcDivergenceTermFDStencilSize; }; } // namespace dftfe #endif // DFTFE_EXCDENSITYGGACLASS_H diff --git a/include/excDensityLDAClass.h b/include/excDensityLDAClass.h index 7398bffe8..4dd9f6a37 100644 --- a/include/excDensityLDAClass.h +++ b/include/excDensityLDAClass.h @@ -19,7 +19,6 @@ #define DFTFE_EXCDENSIYLDACLASS_H #include -//#include #include namespace dftfe { @@ -27,47 +26,27 @@ namespace dftfe class excDensityLDAClass : public excDensityBaseClass { public: - excDensityLDAClass(xc_func_type *funcXPtr, - xc_func_type *funcCPtr, - bool isSpinPolarized, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor); + excDensityLDAClass(xc_func_type *funcXPtr, xc_func_type *funcCPtr); excDensityLDAClass(xc_func_type *funcXPtr, xc_func_type *funcCPtr, - bool isSpinPolarized, - std::string modelXCInputFile, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor); + std::string modelXCInputFile); ~excDensityLDAClass(); void - computeDensityBasedEnergyDensity( - unsigned int sizeInput, - const std::map *> &rhoData, - std::vector &outputExchangeEnergyDensity, - std::vector &outputCorrEnergyDensity) const override; - - void - computeDensityBasedVxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDerExchangeEnergy, - std::map *> - &outputDerCorrEnergy) const override; + computeExcVxcFxc( + AuxDensityMatrix & auxDensityMatrix, + const std::vector &quadPoints, + const std::vector &quadWeights, + std::unordered_map> &xDataOut, + std::unordered_map> &cDataout) + const override; void - computeDensityBasedFxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDer2ExchangeEnergy, - std::map *> - &outputDer2CorrEnergy) const override; + checkInputOutputDataAttributesConsistency( + const std::vector &outputDataAttributes) + const override; private: diff --git a/include/excDensityLLMGGAClass.h b/include/excDensityLLMGGAClass.h new file mode 100644 index 000000000..4a7049569 --- /dev/null +++ b/include/excDensityLLMGGAClass.h @@ -0,0 +1,47 @@ +// +// Created by Arghadwip Paul. +// + +#ifndef DFTFE_EXCDENSITYLLMGGACLASS_H +#define DFTFE_EXCDENSITYLLMGGACLASS_H + +#include +#include +namespace dftfe +{ + class NNLLMGGA; + class excDensityLLMGGAClass : public excDensityBaseClass + { + public: + excDensityLLMGGAClass(xc_func_type *funcXPtr, xc_func_type *funcCPtr); + + excDensityLLMGGAClass(xc_func_type *funcXPtr, + xc_func_type *funcCPtr, + std::string modelXCInputFile); + + ~excDensityLLMGGAClass(); + + void + computeExcVxcFxc( + AuxDensityMatrix & auxDensityMatrix, + const std::vector &quadPoints, + const std::vector &quadWeights, + std::unordered_map> &xDataOut, + std::unordered_map> &cDataout) + const override; + + void + checkInputOutputDataAttributesConsistency( + const std::vector &outputDataAttributes) + const override; + + + private: + NNLLMGGA * d_NNLLMGGAPtr; + xc_func_type * d_funcXPtr; + xc_func_type * d_funcCPtr; + std::vector d_spacingFDStencil; + unsigned int d_vxcDivergenceTermFDStencilSize; + }; +} // namespace dftfe +#endif // DFTFE_EXCDENSITYLLMGGACLASS_H diff --git a/include/excManager.h b/include/excManager.h index 61fb0ce9b..2824fb871 100644 --- a/include/excManager.h +++ b/include/excManager.h @@ -42,13 +42,9 @@ namespace dftfe void - init(unsigned int xc_id, - bool isSpinPolarized, - unsigned int exxFactor, - bool scaleExchange, - unsigned int scaleExchangeFactor, - bool computeCorrelation, - std::string modelXCInputFile); + init(std::string XCType, + bool isSpinPolarized, + std::string modelXCInputFile); densityFamilyType getDensityBasedFamilyType() const; diff --git a/include/linearAlgebraOperations.h b/include/linearAlgebraOperations.h index 9d13de6a2..028d6ee7c 100644 --- a/include/linearAlgebraOperations.h +++ b/include/linearAlgebraOperations.h @@ -432,6 +432,13 @@ namespace dftfe const unsigned int *lda, int * info); void + dpotri_(const char * uplo, + const unsigned int *n, + double * A, + const unsigned int *lda, + int * info); + + void zpotrf_(const char * uplo, const unsigned int * n, std::complex *a, diff --git a/setupDevelopPetsc.sh b/setupDevelopPetsc.sh index 8db5bf55a..2b5246fa4 100755 --- a/setupDevelopPetsc.sh +++ b/setupDevelopPetsc.sh @@ -32,6 +32,7 @@ ELPA_PATH="/home/vikramg/DFT-softwares-gcc/elpa/install2024" DCCL_PATH="" mdiPath="" torchDir="/scratch/vikramg_root/vikramg/dsambit/torch/libtorch/share/cmake/Torch" +DFTD4Path="/home/vikramg/DFT-softwares-gcc/dftd4/install3.6.0" #Toggle GPU compilation withGPU=OFF @@ -89,7 +90,7 @@ function cmake_configure() { -DXML_INCLUDE_DIR=$xmlIncludeDir\ -DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch -DTORCH_DIR=$torchDir\ -DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\ - -DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH"\ + -DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH;$DFTD4PATH"\ -DWITH_COMPLEX=$withComplex -DWITH_GPU=$withGPU -DGPU_LANG=$gpuLang -DGPU_VENDOR=$gpuVendor -DWITH_GPU_AWARE_MPI=$withGPUAwareMPI -DCMAKE_CUDA_FLAGS="$device_flags" -DCMAKE_CUDA_ARCHITECTURES="$device_architectures"\ -DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\ -DHIGHERQUAD_PSP=$withHigherQuadPSP $1 @@ -103,7 +104,7 @@ function cmake_configure() { -DXML_INCLUDE_DIR=$xmlIncludeDir\ -DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch -DTORCH_DIR=$torchDir\ -DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\ - -DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH"\ + -DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH;$DFTD4PATH"\ -DWITH_COMPLEX=$withComplex -DWITH_GPU=$withGPU -DGPU_LANG=$gpuLang -DGPU_VENDOR=$gpuVendor -DWITH_GPU_AWARE_MPI=$withGPUAwareMPI -DCMAKE_HIP_FLAGS="$device_flags" -DCMAKE_HIP_ARCHITECTURES="$device_architectures"\ -DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\ -DHIGHERQUAD_PSP=$withHigherQuadPSP $1 @@ -118,7 +119,7 @@ function cmake_configure() { -DXML_INCLUDE_DIR=$xmlIncludeDir\ -DWITH_MDI=$withMDI -DMDI_PATH=$mdiPath -DWITH_TORCH=$withTorch -DTORCH_DIR=$torchDir\ -DWITH_CUSTOMIZED_DEALII=$withCustomizedDealii\ - -DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH"\ + -DWITH_DCCL=$withDCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$DCCL_PATH;$DFTD4PATH"\ -DWITH_COMPLEX=$withComplex \ -DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile\ -DHIGHERQUAD_PSP=$withHigherQuadPSP $1 diff --git a/src/dft/computeAuxProjectedDensityMatrixFromPSI.cc b/src/dft/computeAuxProjectedDensityMatrixFromPSI.cc new file mode 100644 index 000000000..0e9dfe62c --- /dev/null +++ b/src/dft/computeAuxProjectedDensityMatrixFromPSI.cc @@ -0,0 +1,406 @@ +// --------------------------------------------------------------------- +// +// Copyright (c) 2017-2022 The Regents of the University of Michigan and DFT-FE +// authors. +// +// This file is part of the DFT-FE code. +// +// The DFT-FE code is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the DFT-FE distribution. +// +// --------------------------------------------------------------------- +// +// @author Sambit Das +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace dftfe +{ + template + void + computeAuxProjectedDensityMatrixFromPSI( + const dftfe::utils::MemoryStorage &X, + const unsigned int totalNumWaveFunctions, + const std::vector> &eigenValues, + const double fermiEnergy, + const double fermiEnergyUp, + const double fermiEnergyDown, + std::shared_ptr< + dftfe::basis::FEBasisOperations> + &basisOperationsPtr, + std::shared_ptr> + & BLASWrapperPtr, + const unsigned int matrixFreeDofhandlerIndex, + const unsigned int quadratureIndex, + const std::vector &kPointWeights, + AuxDensityMatrix & auxDensityMatrixRepresentation, + const MPI_Comm & mpiCommParent, + const MPI_Comm & domainComm, + const MPI_Comm & interpoolcomm, + const MPI_Comm & interBandGroupComm, + const dftParameters & dftParams) + { + int this_process; + MPI_Comm_rank(mpiCommParent, &this_process); +#if defined(DFTFE_WITH_DEVICE) + if (memorySpace == dftfe::utils::MemorySpace::DEVICE) + dftfe::utils::deviceSynchronize(); +#endif + MPI_Barrier(mpiCommParent); + double project_time = MPI_Wtime(); + const unsigned int numKPoints = kPointWeights.size(); + const unsigned int numLocalDofs = basisOperationsPtr->nOwnedDofs(); + const unsigned int totalLocallyOwnedCells = basisOperationsPtr->nCells(); + const unsigned int numNodesPerElement = basisOperationsPtr->nDofsPerCell(); + // band group parallelization data structures + const unsigned int numberBandGroups = + dealii::Utilities::MPI::n_mpi_processes(interBandGroupComm); + const unsigned int bandGroupTaskId = + dealii::Utilities::MPI::this_mpi_process(interBandGroupComm); + std::vector bandGroupLowHighPlusOneIndices; + dftUtils::createBandParallelizationIndices(interBandGroupComm, + totalNumWaveFunctions, + bandGroupLowHighPlusOneIndices); + + const unsigned int BVec = + std::min(dftParams.chebyWfcBlockSize, bandGroupLowHighPlusOneIndices[1]); + + const double spinPolarizedFactor = + (dftParams.spinPolarized == 1) ? 1.0 : 2.0; + const unsigned int numSpinComponents = + (dftParams.spinPolarized == 1) ? 2 : 1; + + const NumberType zero = 0; + + const unsigned int cellsBlockSize = + memorySpace == dftfe::utils::MemorySpace::DEVICE ? 50 : 1; + const unsigned int numCellBlocks = totalLocallyOwnedCells / cellsBlockSize; + const unsigned int remCellBlockSize = + totalLocallyOwnedCells - numCellBlocks * cellsBlockSize; + basisOperationsPtr->reinit(BVec, cellsBlockSize, quadratureIndex); + const unsigned int numQuadPoints = basisOperationsPtr->nQuadsPerCell(); + + dftfe::utils::MemoryStorage wfcQuadPointData; + dftfe::utils::MemoryStorage + wfcQuadPointDataHost; + + + wfcQuadPointData.resize(cellsBlockSize * numQuadPoints * BVec, zero); + wfcQuadPointDataHost.resize(cellsBlockSize * numQuadPoints * BVec, zero); + + dftfe::utils::MemoryStorage + partialOccupVecHost(BVec, 0.0); +#if defined(DFTFE_WITH_DEVICE) + dftfe::utils::MemoryStorage partialOccupVec( + partialOccupVecHost.size()); +#else + auto &partialOccupVec = partialOccupVecHost; +#endif + + dftfe::linearAlgebra::MultiVector + *flattenedArrayBlock; + + basisOperationsPtr->reinit(BVec, cellsBlockSize, quadratureIndex, false); + + dftfe::utils::MemoryStorage + allQuadPointsHost = basisOperationsPtr->quadPoints(); + + dftfe::utils::MemoryStorage + allQuadWeightsMemorySpace = basisOperationsPtr->JxW(); + + + dftfe::utils::MemoryStorage allQuadWeightsHost; + allQuadWeightsHost.copyFrom(allQuadWeightsMemorySpace); + + // + // compute S matrix of aux basis + // + for (int iblock = 0; iblock < (numCellBlocks + 1); iblock++) + { + const unsigned int currentCellsBlockSize = + (iblock == numCellBlocks) ? remCellBlockSize : cellsBlockSize; + if (currentCellsBlockSize > 0) + { + const unsigned int startingCellId = iblock * cellsBlockSize; + + std::vector quadPointsBatch(currentCellsBlockSize * + numQuadPoints * 3); + std::vector quadWeightsBatch(currentCellsBlockSize * + numQuadPoints); + for (unsigned int iQuad = 0; + iQuad < currentCellsBlockSize * numQuadPoints; + ++iQuad) + { + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsBatch[3 * iQuad + idim] = + allQuadPointsHost[startingCellId * numQuadPoints * 3 + + 3 * iQuad + idim]; + quadWeightsBatch[iQuad] = + allQuadWeightsHost[startingCellId * numQuadPoints + iQuad]; + } + + auxDensityMatrixRepresentation.evalOverlapMatrixStart( + quadPointsBatch, quadWeightsBatch); + } // non-trivial cell block check + } // cells block loop + + auxDensityMatrixRepresentation.evalOverlapMatrixEnd(domainComm); + + std::unordered_map> + densityMatrixProjectionInputs; + std::vector &wfcQuadPointDataBatchHost = + densityMatrixProjectionInputs["psiFunc"]; + std::vector &quadPointsBatch = + densityMatrixProjectionInputs["quadpts"]; + std::vector &quadWeightsBatch = + densityMatrixProjectionInputs["quadWt"]; + std::vector &fValuesBatch = + densityMatrixProjectionInputs["fValues"]; + + for (unsigned int kPoint = 0; kPoint < kPointWeights.size(); ++kPoint) + for (unsigned int spinIndex = 0; spinIndex < numSpinComponents; + ++spinIndex) + { + wfcQuadPointData.setValue(zero); + for (unsigned int jvec = 0; jvec < totalNumWaveFunctions; + jvec += BVec) + { + const unsigned int currentBlockSize = + std::min(BVec, totalNumWaveFunctions - jvec); + flattenedArrayBlock = + &(basisOperationsPtr->getMultiVector(currentBlockSize, 0)); + + if ((jvec + currentBlockSize) <= + bandGroupLowHighPlusOneIndices[2 * bandGroupTaskId + 1] && + (jvec + currentBlockSize) > + bandGroupLowHighPlusOneIndices[2 * bandGroupTaskId]) + { + if (dftParams.constraintMagnetization) + { + const double fermiEnergyConstraintMag = + spinIndex == 0 ? fermiEnergyUp : fermiEnergyDown; + for (unsigned int iEigenVec = 0; + iEigenVec < currentBlockSize; + ++iEigenVec) + { + if (eigenValues[kPoint] + [totalNumWaveFunctions * spinIndex + + jvec + iEigenVec] > + fermiEnergyConstraintMag) + *(partialOccupVecHost.begin() + iEigenVec) = 0; + else + *(partialOccupVecHost.begin() + iEigenVec) = + kPointWeights[kPoint] * spinPolarizedFactor; + } + } + else + { + for (unsigned int iEigenVec = 0; + iEigenVec < currentBlockSize; + ++iEigenVec) + { + *(partialOccupVecHost.begin() + iEigenVec) = + dftUtils::getPartialOccupancy( + eigenValues[kPoint] + [totalNumWaveFunctions * spinIndex + + jvec + iEigenVec], + fermiEnergy, + C_kb, + dftParams.TVal) * + kPointWeights[kPoint] * spinPolarizedFactor; + } + } +#if defined(DFTFE_WITH_DEVICE) + partialOccupVec.copyFrom(partialOccupVecHost); +#endif + partialOccupVecHost.copyTo(fValuesBatch); + if (memorySpace == dftfe::utils::MemorySpace::HOST) + for (unsigned int iNode = 0; iNode < numLocalDofs; ++iNode) + std::memcpy(flattenedArrayBlock->data() + + iNode * currentBlockSize, + X.data() + + numLocalDofs * totalNumWaveFunctions * + (numSpinComponents * kPoint + spinIndex) + + iNode * totalNumWaveFunctions + jvec, + currentBlockSize * sizeof(NumberType)); +#if defined(DFTFE_WITH_DEVICE) + else if (memorySpace == dftfe::utils::MemorySpace::DEVICE) + dftfe::utils::deviceKernelsGeneric:: + stridedCopyToBlockConstantStride( + currentBlockSize, + totalNumWaveFunctions, + numLocalDofs, + jvec, + X.data() + numLocalDofs * totalNumWaveFunctions * + (numSpinComponents * kPoint + spinIndex), + flattenedArrayBlock->data()); +#endif + + + basisOperationsPtr->reinit(currentBlockSize, + cellsBlockSize, + quadratureIndex, + false); + + + flattenedArrayBlock->updateGhostValues(); + basisOperationsPtr->distribute(*(flattenedArrayBlock)); + + for (int iblock = 0; iblock < (numCellBlocks + 1); iblock++) + { + const unsigned int currentCellsBlockSize = + (iblock == numCellBlocks) ? remCellBlockSize : + cellsBlockSize; + if (currentCellsBlockSize > 0) + { + const unsigned int startingCellId = + iblock * cellsBlockSize; + + + quadPointsBatch.resize(currentCellsBlockSize * + numQuadPoints * 3); + quadWeightsBatch.resize(currentCellsBlockSize * + numQuadPoints); + for (unsigned int iQuad = 0; + iQuad < currentCellsBlockSize * numQuadPoints; + ++iQuad) + { + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsBatch[3 * iQuad + idim] = + allQuadPointsHost[startingCellId * + numQuadPoints * 3 + + 3 * iQuad + idim]; + quadWeightsBatch[iQuad] = + allQuadWeightsHost[startingCellId * + numQuadPoints + + iQuad]; + } + + basisOperationsPtr->interpolateKernel( + *(flattenedArrayBlock), + wfcQuadPointData.data(), + NULL, + std::pair( + startingCellId, + startingCellId + currentCellsBlockSize)); + + + + wfcQuadPointData.copyTo(wfcQuadPointDataBatchHost); + + auxDensityMatrixRepresentation + .projectDensityMatrixStart( + densityMatrixProjectionInputs, spinIndex); + + } // non-trivial cell block check + } // cells block loop + } + } + } // spin loop + + + + int size; + MPI_Comm_size(interpoolcomm, &size); + if (size > 1) + { + auxDensityMatrixRepresentation.projectDensityMatrixEnd(interpoolcomm); + } + MPI_Comm_size(interBandGroupComm, &size); + if (size > 1) + { + auxDensityMatrixRepresentation.projectDensityMatrixEnd( + interBandGroupComm); + } + auxDensityMatrixRepresentation.projectDensityMatrixEnd(domainComm); + +#if defined(DFTFE_WITH_DEVICE) + if (memorySpace == dftfe::utils::MemorySpace::DEVICE) + dftfe::utils::deviceSynchronize(); +#endif + MPI_Barrier(mpiCommParent); + project_time = MPI_Wtime() - project_time; + + if (this_process == 0 && dftParams.verbosity >= 2) + if (memorySpace == dftfe::utils::MemorySpace::HOST) + std::cout << "Time for project on CPU: " << project_time << std::endl; + else if (memorySpace == dftfe::utils::MemorySpace::DEVICE) + std::cout << "Time for project on Device: " << project_time + << std::endl; + } + + +#ifndef USE_COMPLEX +# if defined(DFTFE_WITH_DEVICE) + template void + computeAuxProjectedDensityMatrixFromPSI( + const dftfe::utils::MemoryStorage &X, + const unsigned int totalNumWaveFunctions, + const std::vector> &eigenValues, + const double fermiEnergy, + const double fermiEnergyUp, + const double fermiEnergyDown, + std::shared_ptr< + dftfe::basis::FEBasisOperations> + &basisOperationsPtr, + std::shared_ptr< + dftfe::linearAlgebra::BLASWrapper> + & BLASWrapperPtr, + const unsigned int matrixFreeDofhandlerIndex, + const unsigned int quadratureIndex, + const std::vector &kPointWeights, + AuxDensityMatrix & auxDensityMatrixRepresentation, + const MPI_Comm & mpiCommParent, + const MPI_Comm & domainComm, + const MPI_Comm & interpoolcomm, + const MPI_Comm & interBandGroupComm, + const dftParameters & dftParams); +# endif + template void + computeAuxProjectedDensityMatrixFromPSI( + const dftfe::utils::MemoryStorage &X, + const unsigned int totalNumWaveFunctions, + const std::vector> &eigenValues, + const double fermiEnergy, + const double fermiEnergyUp, + const double fermiEnergyDown, + std::shared_ptr< + dftfe::basis::FEBasisOperations> + &basisOperationsPtr, + std::shared_ptr< + dftfe::linearAlgebra::BLASWrapper> + & BLASWrapperPtr, + const unsigned int matrixFreeDofhandlerIndex, + const unsigned int quadratureIndex, + const std::vector &kPointWeights, + AuxDensityMatrix & auxDensityMatrixRepresentation, + const MPI_Comm & mpiCommParent, + const MPI_Comm & domainComm, + const MPI_Comm & interpoolcomm, + const MPI_Comm & interBandGroupComm, + const dftParameters & dftParams); +#endif +} // namespace dftfe diff --git a/src/dft/computeOutputDensityDirectionalDerivative.cc b/src/dft/computeOutputDensityDirectionalDerivative.cc index 0203ff087..70ddcbb3c 100644 --- a/src/dft/computeOutputDensityDirectionalDerivative.cc +++ b/src/dft/computeOutputDensityDirectionalDerivative.cc @@ -246,17 +246,36 @@ namespace dftfe gradvSpin0Values[i] - gradvSpin1Values[i]; } } + else + { + rhoPrimeValues[1].clear(); + rhoPrimeValues[1].resize(rhoPrimeValues[0].size(), 0); + gradRhoPrimeValues[1].clear(); + gradRhoPrimeValues[1].resize(gradRhoPrimeValues[0].size(), 0); + } for (unsigned int s = 0; s < (1 + d_dftParamsPtr->spinPolarized); ++s) { computing_timer.enter_subsection("VEffPrime Computation"); - kohnShamDFTEigenOperator.computeVEffPrime(d_densityInQuadValues, + + updateAuxDensityXCMatrix(d_densityInQuadValues, + d_gradDensityInQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCInPtr); + + kohnShamDFTEigenOperator.computeVEffPrime(d_auxDensityMatrixXCInPtr, rhoPrimeValues, - d_gradDensityInQuadValues, gradRhoPrimeValues, electrostaticPotPrimeValues, - d_rhoCore, - d_gradRhoCore, s); computing_timer.leave_subsection("VEffPrime Computation"); diff --git a/src/dft/dft.cc b/src/dft/dft.cc index 2e57bea3e..6fcf32397 100644 --- a/src/dft/dft.cc +++ b/src/dft/dft.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -2753,14 +2754,28 @@ namespace dftfe d_numEigenValues : d_numEigenValuesRR))); + updateAuxDensityXCMatrix(d_densityInQuadValues, + d_gradDensityInQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCInPtr); + for (unsigned int s = 0; s < 2; ++s) { computing_timer.enter_subsection("VEff Computation"); - kohnShamDFTEigenOperator.computeVEff(d_densityInQuadValues, - d_gradDensityInQuadValues, + + + + kohnShamDFTEigenOperator.computeVEff(d_auxDensityMatrixXCInPtr, d_phiInQuadValues, - d_rhoCore, - d_gradRhoCore, s); computing_timer.leave_subsection("VEff Computation"); @@ -2906,12 +2921,7 @@ namespace dftfe computing_timer.enter_subsection( "VEff Computation"); kohnShamDFTEigenOperator.computeVEff( - d_densityInQuadValues, - d_gradDensityInQuadValues, - d_phiInQuadValues, - d_rhoCore, - d_gradRhoCore, - s); + d_auxDensityMatrixXCInPtr, d_phiInQuadValues, s); computing_timer.leave_subsection( "VEff Computation"); } @@ -3037,12 +3047,23 @@ namespace dftfe d_numEigenValues : d_numEigenValuesRR); + updateAuxDensityXCMatrix(d_densityInQuadValues, + d_gradDensityInQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCInPtr); + computing_timer.enter_subsection("VEff Computation"); - kohnShamDFTEigenOperator.computeVEff(d_densityInQuadValues, - d_gradDensityInQuadValues, - d_phiInQuadValues, - d_rhoCore, - d_gradRhoCore); + kohnShamDFTEigenOperator.computeVEff(d_auxDensityMatrixXCInPtr, + d_phiInQuadValues); computing_timer.leave_subsection("VEff Computation"); @@ -3411,6 +3432,20 @@ namespace dftfe d_phiOutQuadValues, dummy); computing_timer.leave_subsection("phiTot solve"); + + updateAuxDensityXCMatrix(d_densityOutQuadValues, + d_gradDensityOutQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCOutPtr); } if (d_dftParamsPtr->useEnergyResidualTolerance) { @@ -3431,8 +3466,8 @@ namespace dftfe d_densityOutQuadValues, d_gradDensityInQuadValues, d_gradDensityOutQuadValues, - d_rhoCore, - d_gradRhoCore, + d_auxDensityMatrixXCInPtr, + d_auxDensityMatrixXCOutPtr, d_bQuadValuesAllAtoms, d_bCellNonTrivialAtomIds, d_localVselfs, @@ -3470,11 +3505,10 @@ namespace dftfe d_phiTotRhoOut, d_densityInQuadValues, d_densityOutQuadValues, - d_gradDensityInQuadValues, d_gradDensityOutQuadValues, d_densityTotalOutValuesLpspQuad, - d_rhoCore, - d_gradRhoCore, + d_auxDensityMatrixXCInPtr, + d_auxDensityMatrixXCOutPtr, d_bQuadValuesAllAtoms, d_bCellNonTrivialAtomIds, d_localVselfs, @@ -3560,6 +3594,20 @@ namespace dftfe } } + updateAuxDensityXCMatrix(d_densityOutQuadValues, + d_gradDensityOutQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCOutPtr); + const unsigned int numberBandGroups = dealii::Utilities::MPI::n_mpi_processes(interBandGroupComm); @@ -3728,11 +3776,10 @@ namespace dftfe d_phiTotRhoOut, d_densityInQuadValues, d_densityOutQuadValues, - d_gradDensityInQuadValues, d_gradDensityOutQuadValues, d_densityTotalOutValuesLpspQuad, - d_rhoCore, - d_gradRhoCore, + d_auxDensityMatrixXCInPtr, + d_auxDensityMatrixXCOutPtr, d_bQuadValuesAllAtoms, d_bCellNonTrivialAtomIds, d_localVselfs, @@ -4869,6 +4916,266 @@ namespace dftfe } + template + void + dftClass::updateAuxDensityXCMatrix( + const std::vector< + dftfe::utils::MemoryStorage> + &densityQuadValues, + const std::vector< + dftfe::utils::MemoryStorage> + & gradDensityQuadValues, + const std::map> &rhoCore, + const std::map> &gradRhoCore, + const dftfe::utils::MemoryStorage + &eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + const dftfe::utils::MemoryStorage + &eigenVectorsFlattenedDevice, +#endif + const std::vector> &eigenValues_, + const double fermiEnergy_, + const double fermiEnergyUp_, + const double fermiEnergyDown_, + std::shared_ptr auxDensityMatrixXCPtr) + { + const bool isGGA = + d_excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA; + d_basisOperationsPtrHost->reinit(0, 0, d_densityQuadratureId); + const unsigned int totalLocallyOwnedCells = + d_basisOperationsPtrHost->nCells(); + const unsigned int nQuadsPerCell = + d_basisOperationsPtrHost->nQuadsPerCell(); + const unsigned int spinPolarizedFactor = 1 + d_dftParamsPtr->spinPolarized; + + if (d_dftParamsPtr->auxBasisTypeXC == "FE") + { + std::unordered_map> + densityProjectionInputs; + std::vector &densityValsForXC = + densityProjectionInputs["densityFunc"]; + densityValsForXC.resize(2 * totalLocallyOwnedCells * nQuadsPerCell, 0); + + if (spinPolarizedFactor == 1) + { + for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; + ++iCell) + { + const double *cellRhoValues = + densityQuadValues[0].data() + iCell * nQuadsPerCell; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + densityValsForXC[iCell * nQuadsPerCell + iQuad] = + cellRhoValues[iQuad] / 2.0; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + densityValsForXC[totalLocallyOwnedCells * nQuadsPerCell + + iCell * nQuadsPerCell + iQuad] = + cellRhoValues[iQuad] / 2.0; + } + } + else if (spinPolarizedFactor == 2) + { + for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; + ++iCell) + { + const double *cellRhoValues = + densityQuadValues[0].data() + iCell * nQuadsPerCell; + const double *cellMagValues = + densityQuadValues[1].data() + iCell * nQuadsPerCell; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + densityValsForXC[iCell * nQuadsPerCell + iQuad] = + cellRhoValues[iQuad] / 2.0 + cellMagValues[iQuad] / 2.0; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + densityValsForXC[totalLocallyOwnedCells * nQuadsPerCell + + iCell * nQuadsPerCell + iQuad] = + cellRhoValues[iQuad] / 2.0 - cellMagValues[iQuad] / 2.0; + } + } + + + + if (d_dftParamsPtr->nonLinearCoreCorrection) + { + for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; + ++iCell) + { + const std::vector &tempRhoCore = + rhoCore.find(d_basisOperationsPtrHost->cellID(iCell))->second; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + densityValsForXC[iCell * nQuadsPerCell + iQuad] += + tempRhoCore[iQuad] / 2.0; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + densityValsForXC[totalLocallyOwnedCells * nQuadsPerCell + + iCell * nQuadsPerCell + iQuad] += + tempRhoCore[iQuad] / 2.0; + } + } + if (isGGA) + { + std::vector &gradDensityValsForXC = + densityProjectionInputs["gradDensityFunc"]; + + gradDensityValsForXC.resize(2 * totalLocallyOwnedCells * + nQuadsPerCell * 3, + 0); + + + if (spinPolarizedFactor == 1) + { + for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; + ++iCell) + { + const double *cellGradRhoValues = + gradDensityQuadValues[0].data() + + iCell * nQuadsPerCell * 3; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + for (unsigned int idim = 0; idim < 3; ++idim) + gradDensityValsForXC[iCell * nQuadsPerCell * 3 + + iQuad * 3 + idim] = + cellGradRhoValues[3 * iQuad + idim] / 2.0; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + for (unsigned int idim = 0; idim < 3; ++idim) + gradDensityValsForXC[totalLocallyOwnedCells * + nQuadsPerCell * 3 + + iCell * nQuadsPerCell * 3 + + iQuad * 3 + idim] = + cellGradRhoValues[3 * iQuad + idim] / 2.0; + } + } + else if (spinPolarizedFactor == 2) + { + for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; + ++iCell) + { + const double *cellGradRhoValues = + gradDensityQuadValues[0].data() + + iCell * nQuadsPerCell * 3; + const double *cellGradMagValues = + gradDensityQuadValues[1].data() + + iCell * nQuadsPerCell * 3; + + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + for (unsigned int idim = 0; idim < 3; ++idim) + gradDensityValsForXC[iCell * nQuadsPerCell * 3 + + iQuad * 3 + idim] = + cellGradRhoValues[3 * iQuad + idim] / 2.0 + + cellGradMagValues[3 * iQuad + idim] / 2.0; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + for (unsigned int idim = 0; idim < 3; ++idim) + gradDensityValsForXC[totalLocallyOwnedCells * + nQuadsPerCell * 3 + + iCell * nQuadsPerCell * 3 + + iQuad * 3 + idim] = + cellGradRhoValues[3 * iQuad + idim] / 2.0 - + cellGradMagValues[3 * iQuad + idim] / 2.0; + } + } + + + if (d_dftParamsPtr->nonLinearCoreCorrection) + { + for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; + ++iCell) + { + const std::vector &tempGradRhoCore = + gradRhoCore.find(d_basisOperationsPtrHost->cellID(iCell)) + ->second; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + for (unsigned int idim = 0; idim < 3; ++idim) + gradDensityValsForXC[iCell * nQuadsPerCell * 3 + + iQuad * 3 + idim] += + tempGradRhoCore[3 * iQuad + idim] / 2.0; + + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) + for (unsigned int idim = 0; idim < 3; ++idim) + gradDensityValsForXC[totalLocallyOwnedCells * + nQuadsPerCell * 3 + + iCell * nQuadsPerCell * 3 + + iQuad * 3 + idim] += + tempGradRhoCore[3 * iQuad + idim] / 2.0; + } + } + } + + auto quadPoints = d_basisOperationsPtrHost->quadPoints(); + + auto quadWeights = d_basisOperationsPtrHost->JxW(); + std::vector &quadPointsStdVec = + densityProjectionInputs["quadpts"]; + quadPointsStdVec.resize(quadPoints.size()); + std::vector &quadWeightsStdVec = + densityProjectionInputs["quadWt"]; + quadWeightsStdVec.resize(quadWeights.size()); + for (unsigned int iQuad = 0; iQuad < quadWeightsStdVec.size(); ++iQuad) + { + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsStdVec[3 * iQuad + idim] = quadPoints[3 * iQuad + idim]; + quadWeightsStdVec[iQuad] = std::real(quadWeights[iQuad]); + } + + + auxDensityMatrixXCPtr->projectDensityStart(densityProjectionInputs); + + auxDensityMatrixXCPtr->projectDensityEnd(mpi_communicator); + } + else if (d_dftParamsPtr->auxBasisTypeXC == "SlaterAE") + { +#ifndef USE_COMPLEX +# ifdef DFTFE_WITH_DEVICE + if (d_dftParamsPtr->useDevice) + computeAuxProjectedDensityMatrixFromPSI(eigenVectorsFlattenedDevice, + d_numEigenValues, + eigenValues_, + fermiEnergy_, + fermiEnergyUp_, + fermiEnergyDown_, + d_basisOperationsPtrDevice, + d_BLASWrapperPtr, + d_densityDofHandlerIndex, + d_gllQuadratureId, + d_kPointWeights, + *auxDensityMatrixXCPtr, + d_mpiCommParent, + mpi_communicator, + interpoolcomm, + interBandGroupComm, + *d_dftParamsPtr); +# endif + if (!d_dftParamsPtr->useDevice) + computeAuxProjectedDensityMatrixFromPSI(eigenVectorsFlattenedHost, + d_numEigenValues, + eigenValues_, + fermiEnergy_, + fermiEnergyUp_, + fermiEnergyDown_, + d_basisOperationsPtrHost, + d_BLASWrapperPtrHost, + d_densityDofHandlerIndex, + d_gllQuadratureId, + d_kPointWeights, + *auxDensityMatrixXCPtr, + d_mpiCommParent, + mpi_communicator, + interpoolcomm, + interBandGroupComm, + *d_dftParamsPtr); +#endif + } + } #include "dft.inst.cc" } // namespace dftfe diff --git a/src/dft/dftd.cc b/src/dft/dftd.cc index 2e57ae079..7b6296556 100644 --- a/src/dft/dftd.cc +++ b/src/dft/dftd.cc @@ -75,35 +75,31 @@ namespace dftfe std::vector> parameterList; if (!customParameters) { - switch (d_dftParams.xc_id) + if (d_dftParams.XCType == "GGA-PBE") { - case 1: - case 2: - case 3: + if (d_dftParams.dc_dispersioncorrectiontype == 1) AssertThrow( - false, + d_dftParams.dc_d3dampingtype != 4, dealii::ExcMessage(std::string( - "DFTD3/4 have not been parametrized for this functional"))); - break; - case 4: - if (d_dftParams.dc_dispersioncorrectiontype == 1) - AssertThrow( - d_dftParams.dc_d3dampingtype != 4, - dealii::ExcMessage(std::string( - "The OP damping functions has not been parametrized for this functional"))); - functional = "pbe"; - break; - case 5: - if (d_dftParams.dc_dispersioncorrectiontype == 1) - AssertThrow( - d_dftParams.dc_d3dampingtype == 0 || - d_dftParams.dc_d3dampingtype == 1, - dealii::ExcMessage(std::string( - "The OP, BJM and ZEROM damping functions have not been parametrized for this functional"))); - functional = "rpbe"; - break; - default: - break; + "The OP damping functions has not been parametrized for this functional"))); + functional = "pbe"; + } + else if (d_dftParams.XCType == "GGA-RPBE") + { + if (d_dftParams.dc_dispersioncorrectiontype == 1) + AssertThrow( + d_dftParams.dc_d3dampingtype == 0 || + d_dftParams.dc_d3dampingtype == 1, + dealii::ExcMessage(std::string( + "The OP, BJM and ZEROM damping functions have not been parametrized for this functional"))); + functional = "rpbe"; + } + else + { + AssertThrow( + false, + dealii::ExcMessage(std::string( + "DFTD3/4 have not been parametrized for this functional"))); } } switch (d_dftParams.dc_dispersioncorrectiontype) diff --git a/src/dft/energyCalculator.cc b/src/dft/energyCalculator.cc index df13ae576..631b9946c 100644 --- a/src/dft/energyCalculator.cc +++ b/src/dft/energyCalculator.cc @@ -585,16 +585,13 @@ namespace dftfe const std::vector< dftfe::utils::MemoryStorage> &densityOutValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradDensityInValues, const std::vector< dftfe::utils::MemoryStorage> &gradDensityOutValues, const dftfe::utils::MemoryStorage - & rhoOutValuesLpsp, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, + & rhoOutValuesLpsp, + std::shared_ptr auxDensityXCInRepresentationPtr, + std::shared_ptr auxDensityXCOutRepresentationPtr, const std::map> &smearedbValues, const std::map> & smearedbNonTrivialAtomIds, @@ -652,32 +649,41 @@ namespace dftfe lpspQuadratureIDElectro, pseudoLocValues, rhoOutValuesLpsp); - if (d_dftParams.spinPolarized == 1) - computeXCEnergyTermsSpinPolarized(basisOperationsPtr, - densityQuadratureID, - excManagerPtr, - densityInValues, - densityOutValues, - gradDensityInValues, - gradDensityOutValues, - rhoCoreValues, - gradRhoCoreValues, - exchangeEnergy, - correlationEnergy, - excCorrPotentialTimesRho); - else - computeXCEnergyTerms(basisOperationsPtr, - densityQuadratureID, - excManagerPtr, - densityInValues, - densityOutValues, - gradDensityInValues, - gradDensityOutValues, - rhoCoreValues, - gradRhoCoreValues, - exchangeEnergy, - correlationEnergy, - excCorrPotentialTimesRho); + + std::vector< + dftfe::utils::MemoryStorage> + densityOutQuadValuesSpinPolarized = densityOutValues; + std::vector< + dftfe::utils::MemoryStorage> + gradDensityOutQuadValuesSpinPolarized; + + if (d_dftParams.spinPolarized == 0) + densityOutQuadValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + densityOutValues[0].size(), 0.0)); + + if (excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA) + { + gradDensityOutQuadValuesSpinPolarized = gradDensityOutValues; + + if (d_dftParams.spinPolarized == 0) + gradDensityOutQuadValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + gradDensityOutValues[0].size(), 0.0)); + } + + computeXCEnergyTermsSpinPolarized(basisOperationsPtr, + densityQuadratureID, + excManagerPtr, + densityOutQuadValuesSpinPolarized, + gradDensityOutQuadValuesSpinPolarized, + auxDensityXCInRepresentationPtr, + auxDensityXCOutRepresentationPtr, + exchangeEnergy, + correlationEnergy, + excCorrPotentialTimesRho); + const double potentialTimesRho = excCorrPotentialTimesRho + electrostaticPotentialTimesRho; @@ -749,7 +755,6 @@ namespace dftfe d_dftParams.verbosity, d_dftParams); } - return totalEnergy; } @@ -788,9 +793,9 @@ namespace dftfe &gradDensityInValues, const std::vector< dftfe::utils::MemoryStorage> - & gradDensityOutValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, + & gradDensityOutValues, + std::shared_ptr auxDensityXCInRepresentationPtr, + std::shared_ptr auxDensityXCOutRepresentationPtr, const std::map> &smearedbValues, const std::map> & smearedbNonTrivialAtomIds, @@ -822,61 +827,74 @@ namespace dftfe densityQuadratureIDElectro, phiTotRhoInValues, densityInValues[0])); - if (d_dftParams.spinPolarized == 1) - computeXCEnergyTermsSpinPolarized(basisOperationsPtr, - densityQuadratureID, - excManagerPtr, - densityInValues, - densityInValues, - gradDensityInValues, - gradDensityInValues, - rhoCoreValues, - gradRhoCoreValues, - exchangeEnergy, - correlationEnergy, - excCorrPotentialTimesRho); - else - computeXCEnergyTerms(basisOperationsPtr, - densityQuadratureID, - excManagerPtr, - densityInValues, - densityInValues, - gradDensityInValues, - gradDensityInValues, - rhoCoreValues, - gradRhoCoreValues, - exchangeEnergy, - correlationEnergy, - excCorrPotentialTimesRho); + + std::vector< + dftfe::utils::MemoryStorage> + densityInQuadValuesSpinPolarized = densityInValues; + std::vector< + dftfe::utils::MemoryStorage> + densityOutQuadValuesSpinPolarized = densityOutValues; + std::vector< + dftfe::utils::MemoryStorage> + gradDensityInQuadValuesSpinPolarized; + std::vector< + dftfe::utils::MemoryStorage> + gradDensityOutQuadValuesSpinPolarized; + + if (excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA) + { + gradDensityInQuadValuesSpinPolarized = gradDensityInValues; + gradDensityOutQuadValuesSpinPolarized = gradDensityOutValues; + } + + if (d_dftParams.spinPolarized == 0) + { + densityInQuadValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + densityInValues[0].size(), 0.0)); + densityOutQuadValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + densityOutValues[0].size(), 0.0)); + + if (excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + gradDensityInQuadValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + gradDensityInValues[0].size(), 0.0)); + gradDensityOutQuadValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + gradDensityOutValues[0].size(), 0.0)); + } + } + + computeXCEnergyTermsSpinPolarized(basisOperationsPtr, + densityQuadratureID, + excManagerPtr, + densityInQuadValuesSpinPolarized, + gradDensityInQuadValuesSpinPolarized, + auxDensityXCInRepresentationPtr, + auxDensityXCInRepresentationPtr, + exchangeEnergy, + correlationEnergy, + excCorrPotentialTimesRho); + + excCorrPotentialTimesRho *= -1.0; exchangeEnergy *= -1.0; correlationEnergy *= -1.0; - if (d_dftParams.spinPolarized == 1) - computeXCEnergyTermsSpinPolarized(basisOperationsPtr, - densityQuadratureID, - excManagerPtr, - densityInValues, - densityOutValues, - gradDensityInValues, - gradDensityOutValues, - rhoCoreValues, - gradRhoCoreValues, - exchangeEnergy, - correlationEnergy, - excCorrPotentialTimesRho); - else - computeXCEnergyTerms(basisOperationsPtr, - densityQuadratureID, - excManagerPtr, - densityInValues, - densityOutValues, - gradDensityInValues, - gradDensityOutValues, - rhoCoreValues, - gradRhoCoreValues, - exchangeEnergy, - correlationEnergy, - excCorrPotentialTimesRho); + computeXCEnergyTermsSpinPolarized(basisOperationsPtr, + densityQuadratureID, + excManagerPtr, + densityOutQuadValuesSpinPolarized, + gradDensityOutQuadValuesSpinPolarized, + auxDensityXCInRepresentationPtr, + auxDensityXCOutRepresentationPtr, + exchangeEnergy, + correlationEnergy, + excCorrPotentialTimesRho); const double potentialTimesRho = excCorrPotentialTimesRho + electrostaticPotentialTimesRho; const double nuclearElectrostaticEnergy = @@ -910,46 +928,60 @@ namespace dftfe & basisOperationsPtr, const unsigned int quadratureId, const std::shared_ptr excManagerPtr, - const std::vector< - dftfe::utils::MemoryStorage> - &densityInValues, const std::vector< dftfe::utils::MemoryStorage> &densityOutValues, const std::vector< dftfe::utils::MemoryStorage> - &gradDensityInValues, - const std::vector< - dftfe::utils::MemoryStorage> - & gradDensityOutValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - double & exchangeEnergy, - double & correlationEnergy, - double &excCorrPotentialTimesRho) + & gradDensityOutValues, + std::shared_ptr auxDensityXCInRepresentationPtr, + std::shared_ptr auxDensityXCOutRepresentationPtr, + double & exchangeEnergy, + double & correlationEnergy, + double & excCorrPotentialTimesRho) { basisOperationsPtr->reinit(0, 0, quadratureId, false); - const unsigned int nCells = basisOperationsPtr->nCells(); - const unsigned int nQuadsPerCell = basisOperationsPtr->nQuadsPerCell(); - std::vector densityValueInXC(2 * nQuadsPerCell, 0.0); - std::vector densityValueOutXC(2 * nQuadsPerCell, 0.0); - std::vector exchangeEnergyDensity(nQuadsPerCell, 0.0); - std::vector corrEnergyDensity(nQuadsPerCell, 0.0); - std::vector derExchEnergyWithInputDensity(2 * nQuadsPerCell, 0.0); - std::vector derCorrEnergyWithInputDensity(2 * nQuadsPerCell, 0.0); - std::vector derExchEnergyWithSigmaGradDenInput, - derCorrEnergyWithSigmaGradDenInput; - std::vector sigmaWithOutputGradDensity, sigmaWithInputGradDensity; - std::vector gradXCRhoInDotgradRhoOut; - std::vector> gradRhoIn, gradRhoOut; + const unsigned int nCells = basisOperationsPtr->nCells(); + const unsigned int nQuadsPerCell = basisOperationsPtr->nQuadsPerCell(); + + + std::unordered_map> + xDensityInDataOut; + std::unordered_map> + cDensityInDataOut; + + std::unordered_map> + xDensityOutDataOut; + std::unordered_map> + cDensityOutDataOut; + + std::vector &xEnergyDensityOut = + xDensityOutDataOut[xcOutputDataAttributes::e]; + std::vector &cEnergyDensityOut = + cDensityOutDataOut[xcOutputDataAttributes::e]; + + std::vector &pdexDensityInSpinUp = + xDensityInDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdexDensityInSpinDown = + xDensityInDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + std::vector &pdecDensityInSpinUp = + cDensityInDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdecDensityInSpinDown = + cDensityInDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + if (excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA) { - derExchEnergyWithSigmaGradDenInput.resize(3 * nQuadsPerCell); - derCorrEnergyWithSigmaGradDenInput.resize(3 * nQuadsPerCell); - sigmaWithOutputGradDensity.resize(3 * nQuadsPerCell); - sigmaWithInputGradDensity.resize(3 * nQuadsPerCell); - gradXCRhoInDotgradRhoOut.resize(3 * nQuadsPerCell); + xDensityInDataOut[xcOutputDataAttributes::pdeSigma] = + std::vector(); + cDensityInDataOut[xcOutputDataAttributes::pdeSigma] = + std::vector(); } + + auto quadPointsAll = basisOperationsPtr->quadPoints(); + + auto quadWeightsAll = basisOperationsPtr->JxW(); + + auto dot3 = [](const std::array &a, const std::array &b) { double sum = 0.0; @@ -959,392 +991,140 @@ namespace dftfe } return sum; }; - const std::vector dummy; + + for (unsigned int iCell = 0; iCell < nCells; ++iCell) { - auto cellId = basisOperationsPtr->cellID(iCell); - std::map *> rhoOutData; - std::map *> rhoInData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - const std::vector &tempRhoCore = - d_dftParams.nonLinearCoreCorrection ? - rhoCoreValues.find(cellId)->second : - dummy; - const std::vector &tempGradRhoCore = - (d_dftParams.nonLinearCoreCorrection && - excManagerPtr->getDensityBasedFamilyType() == - densityFamilyType::GGA) ? - gradRhoCoreValues.find(cellId)->second : - dummy; + std::vector quadPointsInCell(nQuadsPerCell * 3); + std::vector quadWeightsInCell(nQuadsPerCell); for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) { - densityValueInXC[2 * iQuad + 0] = - (densityInValues[0][iCell * nQuadsPerCell + iQuad] + - densityInValues[1][iCell * nQuadsPerCell + iQuad]) / - 2.0; - densityValueInXC[2 * iQuad + 1] = - (densityInValues[0][iCell * nQuadsPerCell + iQuad] - - densityInValues[1][iCell * nQuadsPerCell + iQuad]) / - 2.0; - densityValueOutXC[2 * iQuad + 0] = - (densityOutValues[0][iCell * nQuadsPerCell + iQuad] + - densityOutValues[1][iCell * nQuadsPerCell + iQuad]) / - 2.0; - densityValueOutXC[2 * iQuad + 1] = - (densityOutValues[0][iCell * nQuadsPerCell + iQuad] - - densityOutValues[1][iCell * nQuadsPerCell + iQuad]) / - 2.0; - if (d_dftParams.nonLinearCoreCorrection == true) - { - densityValueInXC[2 * iQuad + 0] += tempRhoCore[iQuad] / 2.0; - densityValueInXC[2 * iQuad + 1] += tempRhoCore[iQuad] / 2.0; - densityValueOutXC[2 * iQuad + 0] += tempRhoCore[iQuad] / 2.0; - densityValueOutXC[2 * iQuad + 1] += tempRhoCore[iQuad] / 2.0; - } + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsInCell[3 * iQuad + idim] = + quadPointsAll[iCell * nQuadsPerCell * 3 + 3 * iQuad + idim]; + quadWeightsInCell[iQuad] = + std::real(quadWeightsAll[iCell * nQuadsPerCell + iQuad]); } - rhoOutData[rhoDataAttributes::values] = &densityValueOutXC; - rhoInData[rhoDataAttributes::values] = &densityValueInXC; + excManagerPtr->getExcDensityObj()->computeExcVxcFxc( + *auxDensityXCInRepresentationPtr, + quadPointsInCell, + quadWeightsInCell, + xDensityInDataOut, + cDensityInDataOut); + + excManagerPtr->getExcDensityObj()->computeExcVxcFxc( + *auxDensityXCOutRepresentationPtr, + quadPointsInCell, + quadWeightsInCell, + xDensityOutDataOut, + cDensityOutDataOut); + + std::vector pdexDensityInSigma; + std::vector pdecDensityInSigma; + if (excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + pdexDensityInSigma = + xDensityInDataOut[xcOutputDataAttributes::pdeSigma]; + pdecDensityInSigma = + cDensityInDataOut[xcOutputDataAttributes::pdeSigma]; + } - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithInputDensity; + std::unordered_map> + densityXCInData; + std::vector &gradDensityXCInSpinUp = + densityXCInData[DensityDescriptorDataAttributes::gradValuesSpinUp]; + std::vector &gradDensityXCInSpinDown = + densityXCInData[DensityDescriptorDataAttributes::gradValuesSpinDown]; - outputDerCorrEnergy[VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithInputDensity; + if (excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + auxDensityXCInRepresentationPtr->applyLocalOperations( + quadPointsInCell, densityXCInData); + std::vector gradXCRhoInDotgradRhoOut; if (excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA) { - std::array gradXCRhoIn1, gradXCRhoIn2, gradXCRhoOut1, - gradXCRhoOut2, gradRhoOut1, gradRhoOut2; + gradXCRhoInDotgradRhoOut.resize(nQuadsPerCell * 3); + + std::array gradXCRhoIn1, gradXCRhoIn2, gradRhoOut1, + gradRhoOut2; for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) { for (unsigned int iDim = 0; iDim < 3; ++iDim) { gradXCRhoIn1[iDim] = - (gradDensityInValues[0][iCell * 3 * nQuadsPerCell + - 3 * iQuad + iDim] + - gradDensityInValues[1][iCell * 3 * nQuadsPerCell + - 3 * iQuad + iDim]) / - 2.0; + gradDensityXCInSpinUp[3 * iQuad + iDim]; gradXCRhoIn2[iDim] = - (gradDensityInValues[0][iCell * 3 * nQuadsPerCell + - 3 * iQuad + iDim] - - gradDensityInValues[1][iCell * 3 * nQuadsPerCell + - 3 * iQuad + iDim]) / - 2.0; - gradXCRhoOut1[iDim] = + gradDensityXCInSpinDown[3 * iQuad + iDim]; + gradRhoOut1[iDim] = (gradDensityOutValues[0][iCell * 3 * nQuadsPerCell + 3 * iQuad + iDim] + gradDensityOutValues[1][iCell * 3 * nQuadsPerCell + 3 * iQuad + iDim]) / 2.0; - gradXCRhoOut2[iDim] = + gradRhoOut2[iDim] = (gradDensityOutValues[0][iCell * 3 * nQuadsPerCell + 3 * iQuad + iDim] - gradDensityOutValues[1][iCell * 3 * nQuadsPerCell + 3 * iQuad + iDim]) / 2.0; } - gradRhoOut1 = gradXCRhoOut1; - gradRhoOut2 = gradXCRhoOut2; - if (d_dftParams.nonLinearCoreCorrection == true) - { - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - gradXCRhoIn1[iDim] += - tempGradRhoCore[3 * iQuad + iDim] / 2.0; - gradXCRhoIn2[iDim] += - tempGradRhoCore[3 * iQuad + iDim] / 2.0; - gradXCRhoOut1[iDim] += - tempGradRhoCore[3 * iQuad + iDim] / 2.0; - gradXCRhoOut2[iDim] += - tempGradRhoCore[3 * iQuad + iDim] / 2.0; - } - } - sigmaWithInputGradDensity[3 * iQuad + 0] = - dot3(gradXCRhoIn1, gradXCRhoIn1); - sigmaWithInputGradDensity[3 * iQuad + 1] = - dot3(gradXCRhoIn1, gradXCRhoIn2); - sigmaWithInputGradDensity[3 * iQuad + 2] = - dot3(gradXCRhoIn2, gradXCRhoIn2); - sigmaWithOutputGradDensity[3 * iQuad + 0] = - dot3(gradXCRhoOut1, gradXCRhoOut1); - sigmaWithOutputGradDensity[3 * iQuad + 1] = - dot3(gradXCRhoOut1, gradXCRhoOut2); - sigmaWithOutputGradDensity[3 * iQuad + 2] = - dot3(gradXCRhoOut2, gradXCRhoOut2); - gradXCRhoInDotgradRhoOut[3 * iQuad + 0] = + + gradXCRhoInDotgradRhoOut[iQuad * 3 + 0] = dot3(gradXCRhoIn1, gradRhoOut1); - gradXCRhoInDotgradRhoOut[3 * iQuad + 1] = + gradXCRhoInDotgradRhoOut[iQuad * 3 + 1] = (dot3(gradXCRhoIn1, gradRhoOut2) + dot3(gradXCRhoIn2, gradRhoOut1)) / 2.0; - gradXCRhoInDotgradRhoOut[3 * iQuad + 2] = + gradXCRhoInDotgradRhoOut[iQuad * 3 + 2] = dot3(gradXCRhoIn2, gradRhoOut2); } - rhoOutData[rhoDataAttributes::sigmaGradValue] = - &sigmaWithOutputGradDensity; - rhoInData[rhoDataAttributes::sigmaGradValue] = - &sigmaWithInputGradDensity; - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaGradDenInput; - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaGradDenInput; - } - excManagerPtr->getExcDensityObj()->computeDensityBasedEnergyDensity( - nQuadsPerCell, rhoOutData, exchangeEnergyDensity, corrEnergyDensity); - - excManagerPtr->getExcDensityObj()->computeDensityBasedVxc( - nQuadsPerCell, - rhoInData, - outputDerExchangeEnergy, - outputDerCorrEnergy); + } // GGA + for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) { - double Vxc = derExchEnergyWithInputDensity[2 * iQuad + 0] + - derCorrEnergyWithInputDensity[2 * iQuad + 0]; + double Vxc = + pdexDensityInSpinUp[iQuad] + pdecDensityInSpinUp[iQuad]; excCorrPotentialTimesRho += Vxc * ((densityOutValues[0][iCell * nQuadsPerCell + iQuad] + densityOutValues[1][iCell * nQuadsPerCell + iQuad]) / 2.0) * basisOperationsPtr->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; - Vxc = derExchEnergyWithInputDensity[2 * iQuad + 1] + - derCorrEnergyWithInputDensity[2 * iQuad + 1]; + + Vxc = pdexDensityInSpinDown[iQuad] + pdecDensityInSpinDown[iQuad]; excCorrPotentialTimesRho += Vxc * - ((densityInValues[0][iCell * nQuadsPerCell + iQuad] - - densityInValues[1][iCell * nQuadsPerCell + iQuad]) / + ((densityOutValues[0][iCell * nQuadsPerCell + iQuad] - + densityOutValues[1][iCell * nQuadsPerCell + iQuad]) / 2.0) * basisOperationsPtr->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; - exchangeEnergy += - (exchangeEnergyDensity[iQuad]) * - (densityValueOutXC[2 * iQuad] + - densityValueOutXC[2 * iQuad + 1]) * - basisOperationsPtr->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; - correlationEnergy += - (corrEnergyDensity[iQuad]) * - (densityValueOutXC[2 * iQuad] + - densityValueOutXC[2 * iQuad + 1]) * - basisOperationsPtr->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; - if (excManagerPtr->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - double VxcGrad = 0.0; - for (unsigned int iDim = 0; iDim < 3; ++iDim) - VxcGrad += - 2.0 * - (derExchEnergyWithSigmaGradDenInput[3 * iQuad + iDim] + - derCorrEnergyWithSigmaGradDenInput[3 * iQuad + iDim]) * - gradXCRhoInDotgradRhoOut[3 * iQuad + iDim]; - excCorrPotentialTimesRho += - VxcGrad * basisOperationsPtr - ->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; - } - } - } - } - - - void - energyCalculator::computeXCEnergyTerms( - const std::shared_ptr< - dftfe::basis::FEBasisOperations> - & basisOperationsPtr, - const unsigned int quadratureId, - const std::shared_ptr excManagerPtr, - const std::vector< - dftfe::utils::MemoryStorage> - &densityInValues, - const std::vector< - dftfe::utils::MemoryStorage> - &densityOutValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradDensityInValues, - const std::vector< - dftfe::utils::MemoryStorage> - & gradDensityOutValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - double & exchangeEnergy, - double & correlationEnergy, - double &excCorrPotentialTimesRho) - { - basisOperationsPtr->reinit(0, 0, quadratureId, false); - const unsigned int nCells = basisOperationsPtr->nCells(); - const unsigned int nQuadsPerCell = basisOperationsPtr->nQuadsPerCell(); - std::vector densityValueInXC(nQuadsPerCell, 0.0); - std::vector densityValueOutXC(nQuadsPerCell, 0.0); - std::vector exchangeEnergyDensity(nQuadsPerCell, 0.0); - std::vector corrEnergyDensity(nQuadsPerCell, 0.0); - std::vector derExchEnergyWithInputDensity(nQuadsPerCell, 0.0); - std::vector derCorrEnergyWithInputDensity(nQuadsPerCell, 0.0); - std::vector derExchEnergyWithSigmaGradDenInput, - derCorrEnergyWithSigmaGradDenInput; - std::vector sigmaWithOutputGradDensity, sigmaWithInputGradDensity; - std::vector gradXCRhoInDotgradRhoOut; - std::vector> gradRhoIn, gradRhoOut; - if (excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA) - { - derExchEnergyWithSigmaGradDenInput.resize(nQuadsPerCell); - derCorrEnergyWithSigmaGradDenInput.resize(nQuadsPerCell); - sigmaWithOutputGradDensity.resize(nQuadsPerCell); - sigmaWithInputGradDensity.resize(nQuadsPerCell); - gradXCRhoInDotgradRhoOut.resize(nQuadsPerCell); - } - auto dot3 = [](const std::array &a, - const std::array &b) { - double sum = 0.0; - for (unsigned int i = 0; i < 3; i++) - { - sum += a[i] * b[i]; - } - return sum; - }; - const std::vector dummy; - for (unsigned int iCell = 0; iCell < nCells; ++iCell) - { - auto cellId = basisOperationsPtr->cellID(iCell); - std::map *> rhoOutData; - std::map *> rhoInData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - const std::vector &tempRhoCore = - d_dftParams.nonLinearCoreCorrection ? - rhoCoreValues.find(cellId)->second : - dummy; - const std::vector &tempGradRhoCore = - (d_dftParams.nonLinearCoreCorrection && - excManagerPtr->getDensityBasedFamilyType() == - densityFamilyType::GGA) ? - gradRhoCoreValues.find(cellId)->second : - dummy; - if (d_dftParams.nonLinearCoreCorrection == true) - { - std::transform(densityInValues[0].data() + iCell * nQuadsPerCell, - densityInValues[0].data() + - (iCell + 1) * nQuadsPerCell, - tempRhoCore.data(), - densityValueInXC.data(), - std::plus<>{}); - std::transform(densityOutValues[0].data() + iCell * nQuadsPerCell, - densityOutValues[0].data() + - (iCell + 1) * nQuadsPerCell, - tempRhoCore.data(), - densityValueOutXC.data(), - std::plus<>{}); - } - else - { - std::memcpy(densityValueInXC.data(), - densityInValues[0].data() + iCell * nQuadsPerCell, - nQuadsPerCell * sizeof(double)); - std::memcpy(densityValueOutXC.data(), - densityOutValues[0].data() + iCell * nQuadsPerCell, - nQuadsPerCell * sizeof(double)); - } - rhoOutData[rhoDataAttributes::values] = &densityValueOutXC; - - rhoInData[rhoDataAttributes::values] = &densityValueInXC; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithInputDensity; - - outputDerCorrEnergy[VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithInputDensity; - - if (excManagerPtr->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - std::array gradXCRhoIn, gradXCRhoOut, gradRhoOut; - for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) - { - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - gradXCRhoIn[iDim] = - gradDensityInValues[0][iCell * 3 * nQuadsPerCell + - 3 * iQuad + iDim]; - gradXCRhoOut[iDim] = - gradDensityOutValues[0][iCell * 3 * nQuadsPerCell + - 3 * iQuad + iDim]; - } - gradRhoOut = gradXCRhoOut; - if (d_dftParams.nonLinearCoreCorrection == true) - { - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - gradXCRhoIn[iDim] += tempGradRhoCore[3 * iQuad + iDim]; - gradXCRhoOut[iDim] += tempGradRhoCore[3 * iQuad + iDim]; - } - } - sigmaWithInputGradDensity[iQuad] = - dot3(gradXCRhoIn, gradXCRhoIn); - sigmaWithOutputGradDensity[iQuad] = - dot3(gradXCRhoOut, gradXCRhoOut); - gradXCRhoInDotgradRhoOut[iQuad] = dot3(gradXCRhoIn, gradRhoOut); - } - rhoOutData[rhoDataAttributes::sigmaGradValue] = - &sigmaWithOutputGradDensity; - rhoInData[rhoDataAttributes::sigmaGradValue] = - &sigmaWithInputGradDensity; - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaGradDenInput; - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaGradDenInput; - } - excManagerPtr->getExcDensityObj()->computeDensityBasedEnergyDensity( - nQuadsPerCell, rhoOutData, exchangeEnergyDensity, corrEnergyDensity); - - excManagerPtr->getExcDensityObj()->computeDensityBasedVxc( - nQuadsPerCell, - rhoInData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - for (unsigned int iQuad = 0; iQuad < nQuadsPerCell; ++iQuad) - { - double Vxc = derExchEnergyWithInputDensity[iQuad] + - derCorrEnergyWithInputDensity[iQuad]; - excCorrPotentialTimesRho += - Vxc * (densityOutValues[0][iCell * nQuadsPerCell + iQuad]) * - basisOperationsPtr->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; exchangeEnergy += - (exchangeEnergyDensity[iQuad]) * (densityValueOutXC[iQuad]) * + (xEnergyDensityOut[iQuad]) * basisOperationsPtr->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; correlationEnergy += - (corrEnergyDensity[iQuad]) * (densityValueOutXC[iQuad]) * + (cEnergyDensityOut[iQuad]) * basisOperationsPtr->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; if (excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA) { - double VxcGrad = 2.0 * - (derExchEnergyWithSigmaGradDenInput[iQuad] + - derCorrEnergyWithSigmaGradDenInput[iQuad]) * - gradXCRhoInDotgradRhoOut[iQuad]; + double VxcGrad = 0.0; + for (unsigned int isigma = 0; isigma < 3; ++isigma) + VxcGrad += 2.0 * + (pdexDensityInSigma[iQuad * 3 + isigma] + + pdecDensityInSigma[iQuad * 3 + isigma]) * + gradXCRhoInDotgradRhoOut[iQuad * 3 + isigma]; excCorrPotentialTimesRho += VxcGrad * basisOperationsPtr ->JxWBasisData()[iCell * nQuadsPerCell + iQuad]; } } - } + } // cell loop } diff --git a/src/dft/initUnmovedTriangulation.cc b/src/dft/initUnmovedTriangulation.cc index ad8ecaf83..df578ca79 100644 --- a/src/dft/initUnmovedTriangulation.cc +++ b/src/dft/initUnmovedTriangulation.cc @@ -29,6 +29,8 @@ #include #include #include +#include +#include namespace dftfe { @@ -306,14 +308,48 @@ namespace dftfe dftUtils::printCurrentMemoryUsage(mpi_communicator, "Force initUnmoved"); - d_excManagerPtr->init(d_dftParamsPtr->xc_id, - (d_dftParamsPtr->spinPolarized == 1) ? true : false, - 0.0, // exx factor - false, // scale exchange - 1.0, // scale exchange factor - true, // computeCorrelation + d_excManagerPtr->init(d_dftParamsPtr->XCType, + true, d_dftParamsPtr->modelXCInputFile); + if (d_dftParamsPtr->auxBasisTypeXC == "FE") + { + d_auxDensityMatrixXCInPtr = std::make_shared(); + d_auxDensityMatrixXCOutPtr = std::make_shared(); + } + else if (d_dftParamsPtr->auxBasisTypeXC == "SlaterAE") + { +#ifdef DFTFE_WITH_TORCH + d_auxDensityMatrixXCInPtr = std::make_shared(); + // FIXME: extract atomCoords from "atomLocations" (this is a datamember + // of dftClass) of type std::vector> atomLocations + // with each row representing an atom and each column has the following + // data: atomic number, valence number, + // and x,y,z cartesian coordiantes with respect to origin at domain + // center + /* + d_auxDensityMatrixXCInPtr->reinitAuxDensityMatrix( + const std::vector>> + &atomCoords, + d_dftParamsPtr->auxBasisTypeXC, + 2, + 5); + */ + + d_auxDensityMatrixXCOutPtr = std::make_shared(); + // FIXME: with same comments as above + /* + d_auxDensityMatrixXCOutPtr->reinitAuxDensityMatrix( + const std::vector>> + &atomCoords, + d_dftParamsPtr->auxBasisTypeXC, + 2, + 5); + */ +#endif + } + + computing_timer.leave_subsection("unmoved setup"); } #include "dft.inst.cc" diff --git a/src/dft/solveNSCF.cc b/src/dft/solveNSCF.cc index ca42037ef..f09a19c9e 100644 --- a/src/dft/solveNSCF.cc +++ b/src/dft/solveNSCF.cc @@ -370,15 +370,30 @@ namespace dftfe std::vector>( d_kPointWeights.size(), std::vector(d_numEigenValues))); + updateAuxDensityXCMatrix(d_densityInQuadValues, + d_gradDensityInQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCInPtr); + + for (unsigned int s = 0; s < 2; ++s) { computing_timer.enter_subsection("VEff Computation"); - kohnShamDFTEigenOperator.computeVEff(d_densityInQuadValues, - d_gradDensityInQuadValues, + + + kohnShamDFTEigenOperator.computeVEff(d_auxDensityMatrixXCInPtr, d_phiInQuadValues, - d_rhoCore, - d_gradRhoCore, s); + computing_timer.leave_subsection("VEff Computation"); @@ -518,12 +533,8 @@ namespace dftfe { computing_timer.enter_subsection("VEff Computation"); kohnShamDFTEigenOperator.computeVEff( - d_densityInQuadValues, - d_gradDensityInQuadValues, - d_phiInQuadValues, - d_rhoCore, - d_gradRhoCore, - s); + d_auxDensityMatrixXCInPtr, d_phiInQuadValues, s); + computing_timer.leave_subsection("VEff Computation"); } for (unsigned int kPoint = 0; kPoint < d_kPointWeights.size(); @@ -649,13 +660,23 @@ namespace dftfe for (unsigned int kPoint = 0; kPoint < d_kPointWeights.size(); ++kPoint) residualNormWaveFunctionsAllkPoints[kPoint].resize(d_numEigenValues); + updateAuxDensityXCMatrix(d_densityInQuadValues, + d_gradDensityInQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCInPtr); computing_timer.enter_subsection("VEff Computation"); - kohnShamDFTEigenOperator.computeVEff(d_densityInQuadValues, - d_gradDensityInQuadValues, - d_phiInQuadValues, - d_rhoCore, - d_gradRhoCore); + kohnShamDFTEigenOperator.computeVEff(d_auxDensityMatrixXCInPtr, + d_phiInQuadValues); computing_timer.leave_subsection("VEff Computation"); for (unsigned int kPoint = 0; kPoint < d_kPointWeights.size(); ++kPoint) @@ -867,6 +888,20 @@ namespace dftfe computing_timer.leave_subsection("compute rho"); + updateAuxDensityXCMatrix(d_densityOutQuadValues, + d_gradDensityOutQuadValues, + d_rhoCore, + d_gradRhoCore, + d_eigenVectorsFlattenedHost, +#ifdef DFTFE_WITH_DEVICE + d_eigenVectorsFlattenedDevice, +#endif + eigenValues, + fermiEnergy, + fermiEnergyUp, + fermiEnergyDown, + d_auxDensityMatrixXCOutPtr); + // // compute integral rhoOut // @@ -1022,11 +1057,10 @@ namespace dftfe d_phiTotRhoOut, d_densityInQuadValues, d_densityOutQuadValues, - d_gradDensityInQuadValues, d_gradDensityOutQuadValues, d_densityTotalOutValuesLpspQuad, - d_rhoCore, - d_gradRhoCore, + d_auxDensityMatrixXCInPtr, + d_auxDensityMatrixXCOutPtr, d_bQuadValuesAllAtoms, d_bCellNonTrivialAtomIds, d_localVselfs, diff --git a/src/dftOperator/KohnShamHamiltonianOperator.cc b/src/dftOperator/KohnShamHamiltonianOperator.cc index 6dbde6271..9a4bd8f93 100644 --- a/src/dftOperator/KohnShamHamiltonianOperator.cc +++ b/src/dftOperator/KohnShamHamiltonianOperator.cc @@ -219,27 +219,17 @@ namespace dftfe template void KohnShamHamiltonianOperator::computeVEff( - const std::vector< - dftfe::utils::MemoryStorage> - &rhoValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradRhoValues, + std::shared_ptr auxDensityXCRepresentation, const dftfe::utils::MemoryStorage - & phiValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - const unsigned int spinIndex) + & phiValues, + const unsigned int spinIndex) { const bool isGGA = d_excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA; - const unsigned int spinPolarizedFactor = 1 + d_dftParamsPtr->spinPolarized; - const unsigned int spinPolarizedSigmaFactor = - d_dftParamsPtr->spinPolarized == 0 ? 1 : 3; d_basisOperationsPtrHost->reinit(0, 0, d_densityQuadratureID); const unsigned int totalLocallyOwnedCells = d_basisOperationsPtrHost->nCells(); - const unsigned int numberQuadraturePoints = + const unsigned int numberQuadraturePointsPerCell = d_basisOperationsPtrHost->nQuadsPerCell(); #if defined(DFTFE_WITH_DEVICE) dftfe::utils::MemoryStorage @@ -251,324 +241,171 @@ namespace dftfe auto &d_invJacderExcWithSigmaTimesGradRhoJxWHost = d_invJacderExcWithSigmaTimesGradRhoJxW; #endif - d_VeffJxWHost.resize(totalLocallyOwnedCells * numberQuadraturePoints, 0.0); + d_VeffJxWHost.resize(totalLocallyOwnedCells * numberQuadraturePointsPerCell, + 0.0); + d_invJacderExcWithSigmaTimesGradRhoJxWHost.clear(); d_invJacderExcWithSigmaTimesGradRhoJxWHost.resize( - isGGA ? totalLocallyOwnedCells * numberQuadraturePoints * 3 : 0, 0.0); - - // allocate storage for exchange potential - std::vector exchangePotentialVal(numberQuadraturePoints * - spinPolarizedFactor); - std::vector corrPotentialVal(numberQuadraturePoints * - spinPolarizedFactor); - std::vector densityValue(numberQuadraturePoints * - spinPolarizedFactor); - std::vector sigmaValue( - isGGA ? numberQuadraturePoints * spinPolarizedSigmaFactor : 0); - std::vector derExchEnergyWithSigmaVal( - isGGA ? numberQuadraturePoints * spinPolarizedSigmaFactor : 0); - std::vector derCorrEnergyWithSigmaVal( - isGGA ? numberQuadraturePoints * spinPolarizedSigmaFactor : 0); - std::vector gradDensityValue( - isGGA ? 3 * numberQuadraturePoints * spinPolarizedFactor : 0); - auto dot3 = [](const double *a, const double *b) { - double sum = 0.0; - for (unsigned int i = 0; i < 3; i++) - { - sum += a[i] * b[i]; - } - return sum; - }; + isGGA ? totalLocallyOwnedCells * numberQuadraturePointsPerCell * 3 : 0, + 0.0); + + + std::unordered_map> xDataOut; + std::unordered_map> cDataOut; + + + std::vector &pdexDensitySpinUp = + xDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdexDensitySpinDown = + xDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + std::vector &pdecDensitySpinUp = + cDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdecDensitySpinDown = + cDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + + if (isGGA) + { + xDataOut[xcOutputDataAttributes::pdeSigma] = std::vector(); + cDataOut[xcOutputDataAttributes::pdeSigma] = std::vector(); + } + + auto quadPointsAll = d_basisOperationsPtrHost->quadPoints(); + + auto quadWeightsAll = d_basisOperationsPtrHost->JxW(); for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; ++iCell) { - if (spinPolarizedFactor == 1) - std::memcpy(densityValue.data(), - rhoValues[0].data() + iCell * numberQuadraturePoints, - numberQuadraturePoints * sizeof(double)); - else if (spinPolarizedFactor == 2) + std::vector quadPointsInCell(numberQuadraturePointsPerCell * 3); + std::vector quadWeightsInCell(numberQuadraturePointsPerCell); + for (unsigned int iQuad = 0; iQuad < numberQuadraturePointsPerCell; + ++iQuad) { - const double *cellRhoValues = - rhoValues[0].data() + iCell * numberQuadraturePoints; - const double *cellMagValues = - rhoValues[1].data() + iCell * numberQuadraturePoints; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double rhoByTwo = cellRhoValues[iQuad] / 2.0; - const double magByTwo = cellMagValues[iQuad] / 2.0; - densityValue[2 * iQuad] = rhoByTwo + magByTwo; - densityValue[2 * iQuad + 1] = rhoByTwo - magByTwo; - } + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsInCell[3 * iQuad + idim] = + quadPointsAll[iCell * numberQuadraturePointsPerCell * 3 + + 3 * iQuad + idim]; + quadWeightsInCell[iQuad] = std::real( + quadWeightsAll[iCell * numberQuadraturePointsPerCell + iQuad]); } - if (isGGA) - if (spinPolarizedFactor == 1) - std::memcpy(gradDensityValue.data(), - gradRhoValues[0].data() + - iCell * numberQuadraturePoints * 3, - 3 * numberQuadraturePoints * sizeof(double)); - else if (spinPolarizedFactor == 2) - { - const double *cellGradRhoValues = - gradRhoValues[0].data() + 3 * iCell * numberQuadraturePoints; - const double *cellGradMagValues = - gradRhoValues[1].data() + 3 * iCell * numberQuadraturePoints; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - const double gradRhoByTwo = - cellGradRhoValues[3 * iQuad + iDim] / 2.0; - const double gradMagByTwo = - cellGradMagValues[3 * iQuad + iDim] / 2.0; - gradDensityValue[6 * iQuad + iDim] = - gradRhoByTwo + gradMagByTwo; - gradDensityValue[6 * iQuad + 3 + iDim] = - gradRhoByTwo - gradMagByTwo; - } - } - const double *tempPhi = - phiValues.data() + iCell * numberQuadraturePoints; + d_excManagerPtr->getExcDensityObj()->computeExcVxcFxc( + *auxDensityXCRepresentation, + quadPointsInCell, + quadWeightsInCell, + xDataOut, + cDataOut); - if (d_dftParamsPtr->nonLinearCoreCorrection) - if (spinPolarizedFactor == 1) - { - std::transform(densityValue.data(), - densityValue.data() + numberQuadraturePoints, - rhoCoreValues - .find(d_basisOperationsPtrHost->cellID(iCell)) - ->second.data(), - densityValue.data(), - std::plus<>{}); - if (isGGA) - std::transform(gradDensityValue.data(), - gradDensityValue.data() + - 3 * numberQuadraturePoints, - gradRhoCoreValues - .find(d_basisOperationsPtrHost->cellID(iCell)) - ->second.data(), - gradDensityValue.data(), - std::plus<>{}); - } - else if (spinPolarizedFactor == 2) - { - const std::vector &temp2 = - rhoCoreValues.find(d_basisOperationsPtrHost->cellID(iCell)) - ->second; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - densityValue[2 * iQuad] += temp2[iQuad] / 2.0; - densityValue[2 * iQuad + 1] += temp2[iQuad] / 2.0; - } - if (isGGA) - { - const std::vector &temp3 = - gradRhoCoreValues - .find(d_basisOperationsPtrHost->cellID(iCell)) - ->second; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - gradDensityValue[6 * iQuad + iDim] += - temp3[3 * iQuad + iDim] / 2.0; - gradDensityValue[6 * iQuad + iDim + 3] += - temp3[3 * iQuad + iDim] / 2.0; - } - } - } + const std::vector &pdexDensitySpinIndex = + spinIndex == 0 ? pdexDensitySpinUp : pdexDensitySpinDown; + const std::vector &pdecDensitySpinIndex = + spinIndex == 0 ? pdecDensitySpinUp : pdecDensitySpinDown; + + std::vector pdexSigma; + std::vector pdecSigma; if (isGGA) { - if (spinPolarizedFactor == 1) - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - sigmaValue[iQuad] = dot3(gradDensityValue.data() + 3 * iQuad, - gradDensityValue.data() + 3 * iQuad); - else if (spinPolarizedFactor == 2) - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - sigmaValue[3 * iQuad] = - dot3(gradDensityValue.data() + 6 * iQuad, - gradDensityValue.data() + 6 * iQuad); - sigmaValue[3 * iQuad + 1] = - dot3(gradDensityValue.data() + 6 * iQuad, - gradDensityValue.data() + 6 * iQuad + 3); - sigmaValue[3 * iQuad + 2] = - dot3(gradDensityValue.data() + 6 * iQuad + 3, - gradDensityValue.data() + 6 * iQuad + 3); - } + pdexSigma = xDataOut[xcOutputDataAttributes::pdeSigma]; + pdecSigma = cDataOut[xcOutputDataAttributes::pdeSigma]; } - std::map *> rhoData; - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; + std::unordered_map> + densityData; + std::vector &densitySpinUp = + densityData[DensityDescriptorDataAttributes::valuesSpinUp]; + std::vector &densitySpinDown = + densityData[DensityDescriptorDataAttributes::valuesSpinDown]; + std::vector &gradDensitySpinUp = + densityData[DensityDescriptorDataAttributes::gradValuesSpinUp]; + std::vector &gradDensitySpinDown = + densityData[DensityDescriptorDataAttributes::gradValuesSpinDown]; - rhoData[rhoDataAttributes::values] = &densityValue; + if (isGGA) + auxDensityXCRepresentation->applyLocalOperations(quadPointsInCell, + densityData); - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &exchangePotentialVal; + const std::vector &gradDensityXCSpinIndex = + spinIndex == 0 ? gradDensitySpinUp : gradDensitySpinDown; + const std::vector &gradDensityXCOtherSpinIndex = + spinIndex == 0 ? gradDensitySpinDown : gradDensitySpinUp; + + + const double *tempPhi = + phiValues.data() + iCell * numberQuadraturePointsPerCell; - outputDerCorrEnergy[VeffOutputDataAttributes::derEnergyWithDensity] = - &corrPotentialVal; - if (isGGA) - { - rhoData[rhoDataAttributes::sigmaGradValue] = &sigmaValue; - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaVal; - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaVal; - } - d_excManagerPtr->getExcDensityObj()->computeDensityBasedVxc( - numberQuadraturePoints, - rhoData, - outputDerExchangeEnergy, - outputDerCorrEnergy); auto cellJxWPtr = d_basisOperationsPtrHost->JxWBasisData().data() + - iCell * numberQuadraturePoints; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; ++iQuad) + iCell * numberQuadraturePointsPerCell; + for (unsigned int iQuad = 0; iQuad < numberQuadraturePointsPerCell; + ++iQuad) { - if (spinPolarizedFactor == 1) - d_VeffJxWHost[iCell * numberQuadraturePoints + iQuad] = - (tempPhi[iQuad] + exchangePotentialVal[iQuad] + - corrPotentialVal[iQuad]) * - cellJxWPtr[iQuad]; - else - d_VeffJxWHost[iCell * numberQuadraturePoints + iQuad] = - (tempPhi[iQuad] + exchangePotentialVal[2 * iQuad + spinIndex] + - corrPotentialVal[2 * iQuad + spinIndex]) * - cellJxWPtr[iQuad]; + d_VeffJxWHost[iCell * numberQuadraturePointsPerCell + iQuad] = + (tempPhi[iQuad] + pdexDensitySpinIndex[iQuad] + + pdecDensitySpinIndex[iQuad]) * + cellJxWPtr[iQuad]; } + if (isGGA) { - if (spinPolarizedFactor == 1) + if (d_basisOperationsPtrHost->cellsTypeFlag() != 2) { - if (d_basisOperationsPtrHost->cellsTypeFlag() != 2) + for (unsigned int iQuad = 0; + iQuad < numberQuadraturePointsPerCell; + ++iQuad) { - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double *inverseJacobiansQuadPtr = - d_basisOperationsPtrHost->inverseJacobiansBasisData() - .data() + - (d_basisOperationsPtrHost->cellsTypeFlag() == 0 ? - iCell * numberQuadraturePoints * 9 + iQuad * 9 : - iCell * 9); - const double *gradDensityQuadPtr = - gradDensityValue.data() + 3 * iQuad; - const double term = (derExchEnergyWithSigmaVal[iQuad] + - derCorrEnergyWithSigmaVal[iQuad]) * - cellJxWPtr[iQuad]; - for (unsigned jDim = 0; jDim < 3; ++jDim) - for (unsigned iDim = 0; iDim < 3; ++iDim) - d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] += - 2.0 * inverseJacobiansQuadPtr[3 * jDim + iDim] * - gradDensityQuadPtr[jDim] * term; - } - } - else if (d_basisOperationsPtrHost->cellsTypeFlag() == 2) - { - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double *inverseJacobiansQuadPtr = - d_basisOperationsPtrHost->inverseJacobiansBasisData() - .data() + - iCell * 3; - const double *gradDensityQuadPtr = - gradDensityValue.data() + 3 * iQuad; - const double term = (derExchEnergyWithSigmaVal[iQuad] + - derCorrEnergyWithSigmaVal[iQuad]) * - cellJxWPtr[iQuad]; - for (unsigned iDim = 0; iDim < 3; ++iDim) - d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] = 2.0 * inverseJacobiansQuadPtr[iDim] * - gradDensityQuadPtr[iDim] * term; - } + const double *inverseJacobiansQuadPtr = + d_basisOperationsPtrHost->inverseJacobiansBasisData() + .data() + + (d_basisOperationsPtrHost->cellsTypeFlag() == 0 ? + iCell * numberQuadraturePointsPerCell * 9 + iQuad * 9 : + iCell * 9); + const double *gradDensityQuadPtr = + gradDensityXCSpinIndex.data() + iQuad * 3; + const double *gradDensityOtherQuadPtr = + gradDensityXCOtherSpinIndex.data() + iQuad * 3; + const double term = (pdexSigma[iQuad * 3 + 2 * spinIndex] + + pdecSigma[iQuad * 3 + 2 * spinIndex]) * + cellJxWPtr[iQuad]; + const double termoff = + (pdexSigma[iQuad * 3 + 1] + pdecSigma[iQuad * 3 + 1]) * + cellJxWPtr[iQuad]; + for (unsigned jDim = 0; jDim < 3; ++jDim) + for (unsigned iDim = 0; iDim < 3; ++iDim) + d_invJacderExcWithSigmaTimesGradRhoJxWHost + [iCell * numberQuadraturePointsPerCell * 3 + + iQuad * 3 + iDim] += + inverseJacobiansQuadPtr[3 * jDim + iDim] * + (2.0 * gradDensityQuadPtr[jDim] * term + + gradDensityOtherQuadPtr[jDim] * termoff); } } - else if (spinPolarizedFactor == 2) + else if (d_basisOperationsPtrHost->cellsTypeFlag() == 2) { - if (d_basisOperationsPtrHost->cellsTypeFlag() != 2) - { - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double *inverseJacobiansQuadPtr = - d_basisOperationsPtrHost->inverseJacobiansBasisData() - .data() + - (d_basisOperationsPtrHost->cellsTypeFlag() == 0 ? - iCell * numberQuadraturePoints * 9 + iQuad * 9 : - iCell * 9); - const double *gradDensityQuadPtr = - gradDensityValue.data() + 6 * iQuad + 3 * spinIndex; - const double *gradDensityOtherQuadPtr = - gradDensityValue.data() + 6 * iQuad + - 3 * (1 - spinIndex); - const double term = - (derExchEnergyWithSigmaVal[3 * iQuad + - 2 * spinIndex] + - derCorrEnergyWithSigmaVal[3 * iQuad + - 2 * spinIndex]) * - cellJxWPtr[iQuad]; - const double termoff = - (derExchEnergyWithSigmaVal[3 * iQuad + 1] + - derCorrEnergyWithSigmaVal[3 * iQuad + 1]) * - cellJxWPtr[iQuad]; - for (unsigned jDim = 0; jDim < 3; ++jDim) - for (unsigned iDim = 0; iDim < 3; ++iDim) - d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] += - inverseJacobiansQuadPtr[3 * jDim + iDim] * - (2.0 * gradDensityQuadPtr[jDim] * term + - gradDensityOtherQuadPtr[jDim] * termoff); - } - } - else if (d_basisOperationsPtrHost->cellsTypeFlag() == 2) + for (unsigned int iQuad = 0; + iQuad < numberQuadraturePointsPerCell; + ++iQuad) { - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double *inverseJacobiansQuadPtr = - d_basisOperationsPtrHost->inverseJacobiansBasisData() - .data() + - iCell * 3; - const double *gradDensityQuadPtr = - gradDensityValue.data() + 6 * iQuad + 3 * spinIndex; - const double *gradDensityOtherQuadPtr = - gradDensityValue.data() + 6 * iQuad + - 3 * (1 - spinIndex); - const double term = - (derExchEnergyWithSigmaVal[3 * iQuad + - 2 * spinIndex] + - derCorrEnergyWithSigmaVal[3 * iQuad + - 2 * spinIndex]) * - cellJxWPtr[iQuad]; - const double termoff = - (derExchEnergyWithSigmaVal[3 * iQuad + 1] + - derCorrEnergyWithSigmaVal[3 * iQuad + 1]) * - cellJxWPtr[iQuad]; - for (unsigned iDim = 0; iDim < 3; ++iDim) - d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] = inverseJacobiansQuadPtr[iDim] * - (2.0 * gradDensityQuadPtr[iDim] * term + - gradDensityOtherQuadPtr[iDim] * termoff); - } + const double *inverseJacobiansQuadPtr = + d_basisOperationsPtrHost->inverseJacobiansBasisData() + .data() + + iCell * 3; + const double *gradDensityQuadPtr = + gradDensityXCSpinIndex.data() + iQuad * 3; + const double *gradDensityOtherQuadPtr = + gradDensityXCOtherSpinIndex.data() + iQuad * 3; + const double term = (pdexSigma[iQuad * 3 + 2 * spinIndex] + + pdecSigma[iQuad * 3 + 2 * spinIndex]) * + cellJxWPtr[iQuad]; + const double termoff = + (pdexSigma[iQuad * 3 + 1] + pdecSigma[iQuad * 3 + 1]) * + cellJxWPtr[iQuad]; + for (unsigned iDim = 0; iDim < 3; ++iDim) + d_invJacderExcWithSigmaTimesGradRhoJxWHost + [iCell * numberQuadraturePointsPerCell * 3 + iQuad * 3 + + iDim] = inverseJacobiansQuadPtr[iDim] * + (2.0 * gradDensityQuadPtr[iDim] * term + + gradDensityOtherQuadPtr[iDim] * termoff); } } - } - } + } // GGA + } // cell loop #if defined(DFTFE_WITH_DEVICE) d_VeffJxW.resize(d_VeffJxWHost.size()); d_VeffJxW.copyFrom(d_VeffJxWHost); diff --git a/src/dftOperator/veffPrimeForLRDM.cc b/src/dftOperator/veffPrimeForLRDM.cc index 94e8d41c2..a77ea00e2 100644 --- a/src/dftOperator/veffPrimeForLRDM.cc +++ b/src/dftOperator/veffPrimeForLRDM.cc @@ -17,37 +17,29 @@ // @author Sambit Das, Nikhil Kodali // #include - +#include namespace dftfe { template void KohnShamHamiltonianOperator::computeVEffPrime( - const std::vector< - dftfe::utils::MemoryStorage> - &rhoValues, + std::shared_ptr auxDensityXCRepresentationPtr, const std::vector< dftfe::utils::MemoryStorage> &rhoPrimeValues, - const std::vector< - dftfe::utils::MemoryStorage> - &gradRhoValues, const std::vector< dftfe::utils::MemoryStorage> &gradRhoPrimeValues, const dftfe::utils::MemoryStorage - & phiPrimeValues, - const std::map> &rhoCoreValues, - const std::map> &gradRhoCoreValues, - const unsigned int spinIndex) + & phiPrimeValues, + const unsigned int spinIndex) { const bool isGGA = d_excManagerPtr->getDensityBasedFamilyType() == densityFamilyType::GGA; - const unsigned int spinPolarizedFactor = 1 + d_dftParamsPtr->spinPolarized; d_basisOperationsPtrHost->reinit(0, 0, d_densityQuadratureID); const unsigned int totalLocallyOwnedCells = d_basisOperationsPtrHost->nCells(); - const unsigned int numberQuadraturePoints = + const unsigned int numberQuadraturePointsPerCell = d_basisOperationsPtrHost->nQuadsPerCell(); #if defined(DFTFE_WITH_DEVICE) dftfe::utils::MemoryStorage @@ -59,549 +51,314 @@ namespace dftfe auto &d_invJacderExcWithSigmaTimesGradRhoJxWHost = d_invJacderExcWithSigmaTimesGradRhoJxW; #endif - d_VeffJxWHost.resize(totalLocallyOwnedCells * numberQuadraturePoints, 0.0); + d_VeffJxWHost.resize(totalLocallyOwnedCells * numberQuadraturePointsPerCell, + 0.0); + d_invJacderExcWithSigmaTimesGradRhoJxWHost.clear(); d_invJacderExcWithSigmaTimesGradRhoJxWHost.resize( - isGGA ? totalLocallyOwnedCells * numberQuadraturePoints * 3 : 0, 0.0); - auto dot3 = [](const double *a, const double *b) { - double sum = 0.0; - for (unsigned int i = 0; i < 3; i++) + isGGA ? totalLocallyOwnedCells * numberQuadraturePointsPerCell * 3 : 0, + 0.0); + + std::unordered_map> xDataOut; + std::unordered_map> cDataOut; + + + std::vector &pdexDensitySpinUp = + xDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdexDensitySpinDown = + xDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + std::vector &pdecDensitySpinUp = + cDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdecDensitySpinDown = + cDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + + if (isGGA) + { + xDataOut[xcOutputDataAttributes::pdeSigma] = std::vector(); + cDataOut[xcOutputDataAttributes::pdeSigma] = std::vector(); + } + + auto quadPointsAll = d_basisOperationsPtrHost->quadPoints(); + + auto quadWeightsAll = d_basisOperationsPtrHost->JxW(); + + std::vector quadPointsStdVecAll; + quadPointsStdVecAll.resize(quadPointsAll.size()); + std::vector quadWeightsStdVecAll; + quadWeightsStdVecAll.resize(quadWeightsAll.size()); + for (unsigned int iQuad = 0; iQuad < quadWeightsStdVecAll.size(); ++iQuad) + { + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsStdVecAll[3 * iQuad + idim] = + quadPointsAll[3 * iQuad + idim]; + quadWeightsStdVecAll[iQuad] = std::real(quadWeightsAll[iQuad]); + } + + const double lambda = 1e-2; + for (unsigned int iCellQuad = 0; + iCellQuad < totalLocallyOwnedCells * numberQuadraturePointsPerCell; + ++iCellQuad) + d_VeffJxWHost[iCellQuad] = + phiPrimeValues[iCellQuad] * + d_basisOperationsPtrHost->JxWBasisData()[iCellQuad]; + std::transform(phiPrimeValues.begin(), + phiPrimeValues.end(), + d_basisOperationsPtrHost->JxWBasisData().begin(), + d_VeffJxWHost.begin(), + std::multiplies<>{}); + + auto computeXCPerturbedDensity = [&](double densityPerturbCoeff, + double veffCoeff) { + std::unordered_map> + densityDataAll; + std::vector &densitySpinUpAll = + densityDataAll[DensityDescriptorDataAttributes::valuesSpinUp]; + std::vector &densitySpinDownAll = + densityDataAll[DensityDescriptorDataAttributes::valuesSpinDown]; + if (isGGA) { - sum += a[i] * b[i]; + densityDataAll[DensityDescriptorDataAttributes::gradValuesSpinUp] = + std::vector(); + densityDataAll[DensityDescriptorDataAttributes::gradValuesSpinDown] = + std::vector(); } - return sum; - }; - if (spinPolarizedFactor == 1) - { - std::vector densityValue(numberQuadraturePoints); - std::vector gradDensityValue( - isGGA ? 3 * numberQuadraturePoints : 0); - std::vector densityPrimeValue(numberQuadraturePoints); - std::vector gradDensityPrimeValue( - isGGA ? 3 * numberQuadraturePoints : 0); - - std::vector sigmaValue(isGGA ? numberQuadraturePoints : 0); - std::vector derExchEnergyWithSigmaVal( - isGGA ? numberQuadraturePoints : 0); - std::vector derCorrEnergyWithSigmaVal( - isGGA ? numberQuadraturePoints : 0); - std::vector der2ExchEnergyWithSigmaVal( - isGGA ? numberQuadraturePoints : 0); - std::vector der2CorrEnergyWithSigmaVal( - isGGA ? numberQuadraturePoints : 0); - std::vector der2ExchEnergyWithDensitySigmaVal( - isGGA ? numberQuadraturePoints : 0); - std::vector der2CorrEnergyWithDensitySigmaVal( - isGGA ? numberQuadraturePoints : 0); - std::vector derExchEnergyWithDensityVal( - isGGA ? numberQuadraturePoints : 0); - std::vector derCorrEnergyWithDensityVal( - isGGA ? numberQuadraturePoints : 0); - std::vector der2ExchEnergyWithDensityVal( - numberQuadraturePoints); - std::vector der2CorrEnergyWithDensityVal( - numberQuadraturePoints); - - // - // loop over cell block - // - for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; ++iCell) - { - std::memcpy(densityValue.data(), - rhoValues[0].data() + iCell * numberQuadraturePoints, - numberQuadraturePoints * sizeof(double)); - if (isGGA) - std::memcpy(gradDensityValue.data(), - gradRhoValues[0].data() + - iCell * numberQuadraturePoints * 3, - 3 * numberQuadraturePoints * sizeof(double)); - - std::memcpy(densityPrimeValue.data(), - rhoPrimeValues[0].data() + - iCell * numberQuadraturePoints, - numberQuadraturePoints * sizeof(double)); - if (isGGA) - std::memcpy(gradDensityPrimeValue.data(), - gradRhoPrimeValues[0].data() + - iCell * numberQuadraturePoints * 3, - 3 * numberQuadraturePoints * sizeof(double)); - - if (d_dftParamsPtr->nonLinearCoreCorrection) - { - std::transform(densityValue.data(), - densityValue.data() + numberQuadraturePoints, - rhoCoreValues - .find(d_basisOperationsPtrHost->cellID(iCell)) - ->second.data(), - densityValue.data(), - std::plus<>{}); - if (isGGA) - std::transform( - gradDensityValue.data(), - gradDensityValue.data() + 3 * numberQuadraturePoints, - gradRhoCoreValues - .find(d_basisOperationsPtrHost->cellID(iCell)) - ->second.data(), - gradDensityValue.data(), - std::plus<>{}); - } - - if (isGGA) - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - sigmaValue[iQuad] = dot3(gradDensityValue.data() + 3 * iQuad, - gradDensityValue.data() + 3 * iQuad); - - std::map *> rhoData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - std::map *> - outputDer2ExchangeEnergy; - std::map *> - outputDer2CorrEnergy; - - - rhoData[rhoDataAttributes::values] = &densityValue; - if (isGGA) - rhoData[rhoDataAttributes::sigmaGradValue] = &sigmaValue; - - if (isGGA) - { - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithDensityVal; - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaVal; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithDensityVal; - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaVal; - } - outputDer2ExchangeEnergy - [fxcOutputDataAttributes::der2EnergyWithDensity] = - &der2ExchEnergyWithDensityVal; - if (isGGA) - { - outputDer2ExchangeEnergy - [fxcOutputDataAttributes::der2EnergyWithDensitySigma] = - &der2ExchEnergyWithDensitySigmaVal; - outputDer2ExchangeEnergy - [fxcOutputDataAttributes::der2EnergyWithSigma] = - &der2ExchEnergyWithSigmaVal; - } - outputDer2CorrEnergy - [fxcOutputDataAttributes::der2EnergyWithDensity] = - &der2CorrEnergyWithDensityVal; - if (isGGA) - { - outputDer2CorrEnergy - [fxcOutputDataAttributes::der2EnergyWithDensitySigma] = - &der2CorrEnergyWithDensitySigmaVal; - outputDer2CorrEnergy - [fxcOutputDataAttributes::der2EnergyWithSigma] = - &der2CorrEnergyWithSigmaVal; - } - - if (isGGA) - d_excManagerPtr->getExcDensityObj()->computeDensityBasedVxc( - numberQuadraturePoints, - rhoData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - d_excManagerPtr->getExcDensityObj()->computeDensityBasedFxc( - numberQuadraturePoints, - rhoData, - outputDer2ExchangeEnergy, - outputDer2CorrEnergy); - - - auto cellJxWPtr = d_basisOperationsPtrHost->JxWBasisData().data() + - iCell * numberQuadraturePoints; - - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - double sigmaDensityMixedDerTerm = 0.0; - if (isGGA) - { - const double gradRhoDotGradRhoPrime = - dot3(gradDensityValue.data() + 3 * iQuad, - gradDensityPrimeValue.data() + 3 * iQuad); - - // 2.0*del2{exc}/del{sigma}{rho}*\dot{gradrho^{\prime},gradrho} - sigmaDensityMixedDerTerm = - 2.0 * - (der2ExchEnergyWithDensitySigmaVal[iQuad] + - der2CorrEnergyWithDensitySigmaVal[iQuad]) * - gradRhoDotGradRhoPrime; - } - - d_VeffJxWHost[numberQuadraturePoints * iCell + iQuad] = - (phiPrimeValues[iCell * numberQuadraturePoints + iQuad] + - (der2ExchEnergyWithDensityVal[iQuad] + - der2CorrEnergyWithDensityVal[iQuad]) * - densityPrimeValue[iQuad] + - sigmaDensityMixedDerTerm) * - cellJxWPtr[iQuad]; - } - - - if (isGGA) - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) + auxDensityXCRepresentationPtr->applyLocalOperations(quadPointsStdVecAll, + densityDataAll); + + std::vector gradDensitySpinUpAll; + std::vector gradDensitySpinDownAll; + + if (isGGA) + { + gradDensitySpinUpAll = + densityDataAll[DensityDescriptorDataAttributes::gradValuesSpinUp]; + gradDensitySpinDownAll = + densityDataAll[DensityDescriptorDataAttributes::gradValuesSpinDown]; + } + + std::unordered_map> + perturbedDensityProjectionInputs; + + std::vector &perturbedDensityValsForXC = + perturbedDensityProjectionInputs["densityFunc"]; + perturbedDensityProjectionInputs["quadpts"] = quadPointsStdVecAll; + perturbedDensityProjectionInputs["quadWt"] = quadWeightsStdVecAll; + + perturbedDensityValsForXC.resize(2 * totalLocallyOwnedCells * + numberQuadraturePointsPerCell, + 0); + + const double *rhoTotalPrimeValues = rhoPrimeValues[0].data(); + const double *rhoMagzPrimeValues = rhoPrimeValues[1].data(); + for (unsigned int iQuad = 0; + iQuad < totalLocallyOwnedCells * numberQuadraturePointsPerCell; + ++iQuad) + perturbedDensityValsForXC[iQuad] = + densitySpinUpAll[iQuad] + + densityPerturbCoeff * + (rhoTotalPrimeValues[iQuad] + rhoMagzPrimeValues[iQuad]) / 2.0; + + for (unsigned int iQuad = 0; + iQuad < totalLocallyOwnedCells * numberQuadraturePointsPerCell; + ++iQuad) + perturbedDensityValsForXC[totalLocallyOwnedCells * + numberQuadraturePointsPerCell + + iQuad] = + densitySpinDownAll[iQuad] + + densityPerturbCoeff * + (rhoTotalPrimeValues[iQuad] - rhoMagzPrimeValues[iQuad]) / 2.0; + + if (isGGA) + { + std::vector &perturbedGradDensityValsForXC = + perturbedDensityProjectionInputs["gradDensityFunc"]; + + perturbedGradDensityValsForXC.resize( + 2 * totalLocallyOwnedCells * numberQuadraturePointsPerCell * 3, 0); + + const double *gradRhoTotalPrimeValues = gradRhoPrimeValues[0].data(); + const double *gradRhoMagzPrimeValues = gradRhoPrimeValues[1].data(); + for (unsigned int i = 0; + i < totalLocallyOwnedCells * numberQuadraturePointsPerCell * 3; + ++i) + for (unsigned int idim = 0; idim < 3; ++idim) + perturbedGradDensityValsForXC[i] = + gradDensitySpinUpAll[i] + + densityPerturbCoeff * + (gradRhoTotalPrimeValues[i] + gradRhoMagzPrimeValues[i]) / + 2.0; + + for (unsigned int i = 0; + i < totalLocallyOwnedCells * numberQuadraturePointsPerCell * 3; + ++i) + for (unsigned int idim = 0; idim < 3; ++idim) + perturbedGradDensityValsForXC[totalLocallyOwnedCells * + numberQuadraturePointsPerCell * + 3 + + i] = + gradDensitySpinDownAll[i] + + densityPerturbCoeff * + (gradRhoTotalPrimeValues[i] - gradRhoMagzPrimeValues[i]) / + 2.0; + } + + + std::shared_ptr auxDensityXCPerturbedRepresentationPtr = + std::make_shared(); + auxDensityXCPerturbedRepresentationPtr->projectDensityStart( + perturbedDensityProjectionInputs); + + auxDensityXCPerturbedRepresentationPtr->projectDensityEnd( + d_mpiCommDomain); + + // + // loop over cell block + // + for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; ++iCell) + { + std::vector quadPointsInCell(numberQuadraturePointsPerCell * + 3); + std::vector quadWeightsInCell(numberQuadraturePointsPerCell); + for (unsigned int iQuad = 0; iQuad < numberQuadraturePointsPerCell; + ++iQuad) + { + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsInCell[3 * iQuad + idim] = + quadPointsAll[iCell * numberQuadraturePointsPerCell * 3 + + 3 * iQuad + idim]; + quadWeightsInCell[iQuad] = std::real( + quadWeightsAll[iCell * numberQuadraturePointsPerCell + iQuad]); + } + + + + d_excManagerPtr->getExcDensityObj()->computeExcVxcFxc( + *auxDensityXCPerturbedRepresentationPtr, + quadPointsInCell, + quadWeightsInCell, + xDataOut, + cDataOut); + + const std::vector &pdexDensitySpinIndex = + spinIndex == 0 ? pdexDensitySpinUp : pdexDensitySpinDown; + const std::vector &pdecDensitySpinIndex = + spinIndex == 0 ? pdecDensitySpinUp : pdecDensitySpinDown; + + std::vector pdexSigma; + std::vector pdecSigma; + if (isGGA) + { + pdexSigma = xDataOut[xcOutputDataAttributes::pdeSigma]; + pdecSigma = cDataOut[xcOutputDataAttributes::pdeSigma]; + } + + std::unordered_map> + densityData; + std::vector &gradDensitySpinUp = + densityData[DensityDescriptorDataAttributes::gradValuesSpinUp]; + std::vector &gradDensitySpinDown = + densityData[DensityDescriptorDataAttributes::gradValuesSpinDown]; + + if (isGGA) + auxDensityXCPerturbedRepresentationPtr->applyLocalOperations( + quadPointsInCell, densityData); + + const std::vector &gradDensityXCSpinIndex = + spinIndex == 0 ? gradDensitySpinUp : gradDensitySpinDown; + const std::vector &gradDensityXCOtherSpinIndex = + spinIndex == 0 ? gradDensitySpinDown : gradDensitySpinUp; + + + + auto cellJxWPtr = d_basisOperationsPtrHost->JxWBasisData().data() + + iCell * numberQuadraturePointsPerCell; + + + for (unsigned int iQuad = 0; iQuad < numberQuadraturePointsPerCell; + ++iQuad) + { + d_VeffJxWHost[iCell * numberQuadraturePointsPerCell + iQuad] += + veffCoeff * + (pdexDensitySpinIndex[iQuad] + pdecDensitySpinIndex[iQuad]) * + cellJxWPtr[iQuad]; + } + + if (isGGA) + { + if (d_basisOperationsPtrHost->cellsTypeFlag() != 2) { - const double jxw = cellJxWPtr[iQuad]; - const double gradRhoDotGradRhoPrime = - dot3(gradDensityValue.data() + 3 * iQuad, - gradDensityPrimeValue.data() + 3 * iQuad); - - std::vector term(3, 0.0); - term[0] = derExchEnergyWithSigmaVal[iQuad] + - derCorrEnergyWithSigmaVal[iQuad]; - term[1] = der2ExchEnergyWithSigmaVal[iQuad] + - der2CorrEnergyWithSigmaVal[iQuad]; - term[2] = der2ExchEnergyWithDensitySigmaVal[iQuad] + - der2CorrEnergyWithDensitySigmaVal[iQuad]; - - std::vector tempvec(3, 0.0); - for (unsigned int iDim = 0; iDim < 3; ++iDim) - tempvec[iDim] = - (term[0] * gradDensityPrimeValue[3 * iQuad + iDim] + - 2.0 * term[1] * gradRhoDotGradRhoPrime * - gradDensityValue[3 * iQuad + iDim] + - term[2] * densityPrimeValue[iQuad] * - gradDensityValue[3 * iQuad + iDim]) * - jxw; - if (d_basisOperationsPtrHost->cellsTypeFlag() != 2) + for (unsigned int iQuad = 0; + iQuad < numberQuadraturePointsPerCell; + ++iQuad) { const double *inverseJacobiansQuadPtr = d_basisOperationsPtrHost->inverseJacobiansBasisData() .data() + (d_basisOperationsPtrHost->cellsTypeFlag() == 0 ? - iCell * numberQuadraturePoints * 9 + iQuad * 9 : + iCell * numberQuadraturePointsPerCell * 9 + + iQuad * 9 : iCell * 9); + const double *gradDensityQuadPtr = + gradDensityXCSpinIndex.data() + iQuad * 3; + const double *gradDensityOtherQuadPtr = + gradDensityXCOtherSpinIndex.data() + iQuad * 3; + const double term = + (pdexSigma[iQuad * 3 + 2 * spinIndex] + + pdecSigma[iQuad * 3 + 2 * spinIndex]) * + cellJxWPtr[iQuad]; + const double termoff = + (pdexSigma[iQuad * 3 + 1] + pdecSigma[iQuad * 3 + 1]) * + cellJxWPtr[iQuad]; for (unsigned jDim = 0; jDim < 3; ++jDim) for (unsigned iDim = 0; iDim < 3; ++iDim) d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] += inverseJacobiansQuadPtr[3 * jDim + iDim] * - tempvec[jDim]; + [iCell * numberQuadraturePointsPerCell * 3 + + iQuad * 3 + iDim] += + veffCoeff * + inverseJacobiansQuadPtr[3 * jDim + iDim] * + (2.0 * gradDensityQuadPtr[jDim] * term + + gradDensityOtherQuadPtr[jDim] * termoff); } - else if (d_basisOperationsPtrHost->cellsTypeFlag() == 2) + } + else if (d_basisOperationsPtrHost->cellsTypeFlag() == 2) + { + for (unsigned int iQuad = 0; + iQuad < numberQuadraturePointsPerCell; + ++iQuad) { const double *inverseJacobiansQuadPtr = d_basisOperationsPtrHost->inverseJacobiansBasisData() .data() + iCell * 3; + const double *gradDensityQuadPtr = + gradDensityXCSpinIndex.data() + iQuad * 3; + const double *gradDensityOtherQuadPtr = + gradDensityXCOtherSpinIndex.data() + iQuad * 3; + const double term = + (pdexSigma[iQuad * 3 + 2 * spinIndex] + + pdecSigma[iQuad * 3 + 2 * spinIndex]) * + cellJxWPtr[iQuad]; + const double termoff = + (pdexSigma[iQuad * 3 + 1] + pdecSigma[iQuad * 3 + 1]) * + cellJxWPtr[iQuad]; for (unsigned iDim = 0; iDim < 3; ++iDim) d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] = - inverseJacobiansQuadPtr[iDim] * tempvec[iDim]; + [iCell * numberQuadraturePointsPerCell * 3 + + iQuad * 3 + iDim] += + veffCoeff * inverseJacobiansQuadPtr[iDim] * + (2.0 * gradDensityQuadPtr[iDim] * term + + gradDensityOtherQuadPtr[iDim] * termoff); } } - } // cell loop - } - else - { - std::vector densityValue(2 * numberQuadraturePoints); - std::vector gradDensityValue( - isGGA ? 6 * numberQuadraturePoints : 0); - std::vector densityPrimeValue(2 * numberQuadraturePoints); - std::vector gradDensityPrimeValue( - isGGA ? 6 * numberQuadraturePoints : 0); - - std::vector derExchEnergyWithDensityVal(2 * - numberQuadraturePoints); - std::vector derCorrEnergyWithDensityVal(2 * - numberQuadraturePoints); - std::vector derExchEnergyWithSigma( - isGGA ? 3 * numberQuadraturePoints : 0); - std::vector derCorrEnergyWithSigma( - isGGA ? 3 * numberQuadraturePoints : 0); - std::vector sigmaValue(isGGA ? 3 * numberQuadraturePoints : 0); - - const double lambda = 1e-2; - for (unsigned int iCellQuad = 0; - iCellQuad < totalLocallyOwnedCells * numberQuadraturePoints; - ++iCellQuad) - d_VeffJxWHost[iCellQuad] = - phiPrimeValues[iCellQuad] * - d_basisOperationsPtrHost->JxWBasisData()[iCellQuad]; - std::transform(phiPrimeValues.begin(), - phiPrimeValues.end(), - d_basisOperationsPtrHost->JxWBasisData().begin(), - d_VeffJxWHost.begin(), - std::multiplies<>{}); - - auto computeXCPerturbedDensity = [&](double densityPerturbCoeff, - double veffCoeff) { - // - // loop over cell block - // - for (unsigned int iCell = 0; iCell < totalLocallyOwnedCells; ++iCell) - { - const double *cellRhoValues = - rhoValues[0].data() + iCell * numberQuadraturePoints; - const double *cellMagValues = - rhoValues[1].data() + iCell * numberQuadraturePoints; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double rhoByTwo = cellRhoValues[iQuad] / 2.0; - const double magByTwo = cellMagValues[iQuad] / 2.0; - densityValue[2 * iQuad] = rhoByTwo + magByTwo; - densityValue[2 * iQuad + 1] = rhoByTwo - magByTwo; - } - if (isGGA) - { - const double *cellGradRhoValues = - gradRhoValues[0].data() + - 3 * iCell * numberQuadraturePoints; - const double *cellGradMagValues = - gradRhoValues[1].data() + - 3 * iCell * numberQuadraturePoints; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - const double gradRhoByTwo = - cellGradRhoValues[3 * iQuad + iDim] / 2.0; - const double gradMagByTwo = - cellGradMagValues[3 * iQuad + iDim] / 2.0; - gradDensityValue[6 * iQuad + iDim] = - gradRhoByTwo + gradMagByTwo; - gradDensityValue[6 * iQuad + 3 + iDim] = - gradRhoByTwo - gradMagByTwo; - } - } - - - if (d_dftParamsPtr->nonLinearCoreCorrection) - { - const std::vector &temp2 = - rhoCoreValues.find(d_basisOperationsPtrHost->cellID(iCell)) - ->second; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - densityValue[2 * iQuad] += temp2[iQuad] / 2.0; - densityValue[2 * iQuad + 1] += temp2[iQuad] / 2.0; - } - if (isGGA) - { - const std::vector &temp3 = - gradRhoCoreValues - .find(d_basisOperationsPtrHost->cellID(iCell)) - ->second; - for (unsigned int iQuad = 0; - iQuad < numberQuadraturePoints; - ++iQuad) - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - gradDensityValue[6 * iQuad + iDim] += - temp3[3 * iQuad + iDim] / 2.0; - gradDensityValue[6 * iQuad + iDim + 3] += - temp3[3 * iQuad + iDim] / 2.0; - } - } - } - + } // GGA + } // cell loop + }; + computeXCPerturbedDensity(2.0 * lambda, -1.0 / 12.0 / lambda); + computeXCPerturbedDensity(lambda, 2.0 / 3.0 / lambda); + computeXCPerturbedDensity(-2.0 * lambda, 1.0 / 12.0 / lambda); + computeXCPerturbedDensity(-lambda, -2.0 / 3.0 / lambda); - const double *cellRhoPrimeValues = - rhoPrimeValues[0].data() + iCell * numberQuadraturePoints; - const double *cellMagPrimeValues = - rhoPrimeValues[1].data() + iCell * numberQuadraturePoints; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double rhoByTwo = cellRhoPrimeValues[iQuad] / 2.0; - const double magByTwo = cellMagPrimeValues[iQuad] / 2.0; - densityPrimeValue[2 * iQuad] = rhoByTwo + magByTwo; - densityPrimeValue[2 * iQuad + 1] = rhoByTwo - magByTwo; - } - if (isGGA) - { - const double *cellGradRhoPrimeValues = - gradRhoPrimeValues[0].data() + - 3 * iCell * numberQuadraturePoints; - const double *cellGradMagPrimeValues = - gradRhoPrimeValues[1].data() + - 3 * iCell * numberQuadraturePoints; - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - for (unsigned int iDim = 0; iDim < 3; ++iDim) - { - const double gradRhoByTwo = - cellGradRhoPrimeValues[3 * iQuad + iDim] / 2.0; - const double gradMagByTwo = - cellGradMagPrimeValues[3 * iQuad + iDim] / 2.0; - gradDensityPrimeValue[6 * iQuad + iDim] = - gradRhoByTwo + gradMagByTwo; - gradDensityPrimeValue[6 * iQuad + 3 + iDim] = - gradRhoByTwo - gradMagByTwo; - } - } - std::transform(densityValue.begin(), - densityValue.end(), - densityPrimeValue.begin(), - densityValue.begin(), - [&densityPerturbCoeff](auto &a, auto &b) { - return a + densityPerturbCoeff * b; - }); - if (isGGA) - std::transform(gradDensityValue.begin(), - gradDensityValue.end(), - gradDensityPrimeValue.begin(), - gradDensityValue.begin(), - [&densityPerturbCoeff](auto &a, auto &b) { - return a + densityPerturbCoeff * b; - }); - - if (isGGA) - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - sigmaValue[3 * iQuad] = - dot3(gradDensityValue.data() + 6 * iQuad, - gradDensityValue.data() + 6 * iQuad); - sigmaValue[3 * iQuad + 1] = - dot3(gradDensityValue.data() + 6 * iQuad, - gradDensityValue.data() + 6 * iQuad + 3); - sigmaValue[3 * iQuad + 2] = - dot3(gradDensityValue.data() + 6 * iQuad + 3, - gradDensityValue.data() + 6 * iQuad + 3); - } - - std::map *> rhoData; - - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - - rhoData[rhoDataAttributes::values] = &densityValue; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithDensityVal; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithDensityVal; - if (isGGA) - { - rhoData[rhoDataAttributes::sigmaGradValue] = &sigmaValue; - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigma; - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigma; - } - d_excManagerPtr->getExcDensityObj()->computeDensityBasedVxc( - numberQuadraturePoints, - rhoData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - auto cellJxWPtr = - d_basisOperationsPtrHost->JxWBasisData().data() + - iCell * numberQuadraturePoints; - - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - d_VeffJxWHost[numberQuadraturePoints * iCell + iQuad] += - veffCoeff * - (derExchEnergyWithDensityVal[2 * iQuad + spinIndex] + - derCorrEnergyWithDensityVal[2 * iQuad + spinIndex]) * - cellJxWPtr[iQuad]; - } - if (isGGA) - if (d_basisOperationsPtrHost->cellsTypeFlag() != 2) - { - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double *inverseJacobiansQuadPtr = - d_basisOperationsPtrHost->inverseJacobiansBasisData() - .data() + - (d_basisOperationsPtrHost->cellsTypeFlag() == 0 ? - iCell * numberQuadraturePoints * 9 + iQuad * 9 : - iCell * 9); - const double *gradDensityQuadPtr = - gradDensityValue.data() + 6 * iQuad + 3 * spinIndex; - const double *gradDensityOtherQuadPtr = - gradDensityValue.data() + 6 * iQuad + - 3 * (1 - spinIndex); - const double term = - (derExchEnergyWithSigma[3 * iQuad + 2 * spinIndex] + - derCorrEnergyWithSigma[3 * iQuad + 2 * spinIndex]) * - cellJxWPtr[iQuad]; - const double termoff = - (derExchEnergyWithSigma[3 * iQuad + 1] + - derCorrEnergyWithSigma[3 * iQuad + 1]) * - cellJxWPtr[iQuad]; - for (unsigned jDim = 0; jDim < 3; ++jDim) - for (unsigned iDim = 0; iDim < 3; ++iDim) - d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] += - inverseJacobiansQuadPtr[3 * jDim + iDim] * - (2.0 * gradDensityQuadPtr[jDim] * term + - gradDensityOtherQuadPtr[jDim] * termoff) * - veffCoeff; - } - } - else if (d_basisOperationsPtrHost->cellsTypeFlag() == 2) - { - for (unsigned int iQuad = 0; iQuad < numberQuadraturePoints; - ++iQuad) - { - const double *inverseJacobiansQuadPtr = - d_basisOperationsPtrHost->inverseJacobiansBasisData() - .data() + - iCell * 3; - const double *gradDensityQuadPtr = - gradDensityValue.data() + 6 * iQuad + 3 * spinIndex; - const double *gradDensityOtherQuadPtr = - gradDensityValue.data() + 6 * iQuad + - 3 * (1 - spinIndex); - const double term = - (derExchEnergyWithSigma[3 * iQuad + 2 * spinIndex] + - derCorrEnergyWithSigma[3 * iQuad + 2 * spinIndex]) * - cellJxWPtr[iQuad]; - const double termoff = - (derExchEnergyWithSigma[3 * iQuad + 1] + - derCorrEnergyWithSigma[3 * iQuad + 1]) * - cellJxWPtr[iQuad]; - for (unsigned iDim = 0; iDim < 3; ++iDim) - d_invJacderExcWithSigmaTimesGradRhoJxWHost - [iCell * numberQuadraturePoints * 3 + iQuad * 3 + - iDim] += - veffCoeff * inverseJacobiansQuadPtr[iDim] * - (2.0 * gradDensityQuadPtr[iDim] * term + - gradDensityOtherQuadPtr[iDim] * termoff); - } - } - } // cell loop - }; - computeXCPerturbedDensity(2.0 * lambda, -1.0 / 12.0 / lambda); - computeXCPerturbedDensity(lambda, 2.0 / 3.0 / lambda); - computeXCPerturbedDensity(-2.0 * lambda, 1.0 / 12.0 / lambda); - computeXCPerturbedDensity(-lambda, -2.0 / 3.0 / lambda); - } #if defined(DFTFE_WITH_DEVICE) diff --git a/src/excManager/AuxDensityFE.cpp b/src/excManager/AuxDensityFE.cpp new file mode 100644 index 000000000..4f5a63677 --- /dev/null +++ b/src/excManager/AuxDensityFE.cpp @@ -0,0 +1,195 @@ +// +// Created by Sambit Das. +// + +#include "AuxDensityFE.h" +#include +#include + +namespace dftfe +{ + namespace + { + void + fillDensityAttributeData( + std::vector & attributeData, + const std::vector & values, + const std::pair &indexRange) + { + unsigned int startIndex = indexRange.first; + unsigned int endIndex = indexRange.second; + + attributeData.resize(endIndex - startIndex); + if (startIndex > endIndex || endIndex > values.size()) + { + std::cout << "CHECK1: " << startIndex << std::endl; + std::cout << "CHECK1: " << endIndex << std::endl; + throw std::invalid_argument("Invalid index range for densityData"); + } + + for (unsigned int i = startIndex; i < endIndex; ++i) + { + attributeData[i - startIndex] = values[i]; + } + } + } // namespace + + + void + AuxDensityFE::applyLocalOperations( + const std::vector &points, + std::unordered_map> + &densityData) + { + std::pair indexRangeVal; + std::pair indexRangeGrad; + + unsigned int minIndex = 0; + for (unsigned int i = 0; i < d_quadWeightsAll.size(); i++) + { + if ((std::abs(points[0] - d_quadPointsAll[3 * i + 0]) + + std::abs(points[1] - d_quadPointsAll[3 * i + 1]) + + std::abs(points[2] - d_quadPointsAll[3 * i + 2])) < 1e-6) + { + minIndex = i; + break; + } + } + + + indexRangeVal.first = minIndex; + indexRangeVal.second = minIndex + points.size() / 3; + + indexRangeGrad.first = minIndex * 3; + indexRangeGrad.second = minIndex * 3 + points.size(); + + if (densityData.find(DensityDescriptorDataAttributes::valuesTotal) != + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes::valuesTotal], + d_densityValsTotalAllQuads, + indexRangeVal); + } + + if (densityData.find(DensityDescriptorDataAttributes::valuesSpinUp) != + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes::valuesSpinUp], + d_densityValsSpinUpAllQuads, + indexRangeVal); + } + + if (densityData.find(DensityDescriptorDataAttributes::valuesSpinDown) != + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes::valuesSpinDown], + d_densityValsSpinDownAllQuads, + indexRangeVal); + } + + if (densityData.find(DensityDescriptorDataAttributes::gradValuesSpinUp) != + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes::gradValuesSpinUp], + d_gradDensityValsSpinUpAllQuads, + indexRangeGrad); + } + + if (densityData.find(DensityDescriptorDataAttributes::gradValuesSpinDown) != + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes::gradValuesSpinDown], + d_gradDensityValsSpinDownAllQuads, + indexRangeGrad); + } + } + + + void + AuxDensityFE::evalOverlapMatrixStart(const std::vector &quadpts, + const std::vector &quadWt) + { + std::string errMsg = "Not implemented"; + dftfe::utils::throwException(false, errMsg); + } + + void + AuxDensityFE::evalOverlapMatrixEnd(const MPI_Comm &mpiComm) + { + std::string errMsg = "Not implemented"; + dftfe::utils::throwException(false, errMsg); + } + + + void + AuxDensityFE::projectDensityMatrixStart( + std::unordered_map> &projectionInputs, + int iSpin) + + { + std::string errMsg = "Not implemented"; + dftfe::utils::throwException(false, errMsg); + } + + void + AuxDensityFE::projectDensityMatrixEnd(const MPI_Comm &mpiComm) + { + std::string errMsg = "Not implemented"; + dftfe::utils::throwException(false, errMsg); + } + + + + void + AuxDensityFE::projectDensityStart( + std::unordered_map> &projectionInputs) + { + d_quadPointsAll = projectionInputs["quadpts"]; + d_quadWeightsAll = projectionInputs["quadWt"]; + const std::vector &densityVals = + projectionInputs.find("densityFunc")->second; + const unsigned int nQ = d_quadWeightsAll.size(); + d_densityValsTotalAllQuads.resize(nQ, 0); + d_densityValsSpinUpAllQuads.resize(nQ, 0); + d_densityValsSpinDownAllQuads.resize(nQ, 0); + for (unsigned int iquad = 0; iquad < nQ; iquad++) + d_densityValsSpinUpAllQuads[iquad] = densityVals[iquad]; + + for (unsigned int iquad = 0; iquad < nQ; iquad++) + d_densityValsSpinDownAllQuads[iquad] = densityVals[nQ + iquad]; + + for (unsigned int iquad = 0; iquad < nQ; iquad++) + d_densityValsTotalAllQuads[iquad] = d_densityValsSpinUpAllQuads[iquad] + + d_densityValsSpinDownAllQuads[iquad]; + + if (projectionInputs.find("gradDensityFunc") != projectionInputs.end()) + { + const std::vector &gradDensityVals = + projectionInputs["gradDensityFunc"]; + d_gradDensityValsSpinUpAllQuads.resize(nQ * 3, 0); + d_gradDensityValsSpinDownAllQuads.resize(nQ * 3, 0); + + for (unsigned int iquad = 0; iquad < nQ; iquad++) + for (unsigned int idim = 0; idim < 3; idim++) + d_gradDensityValsSpinUpAllQuads[3 * iquad + idim] = + gradDensityVals[3 * iquad + idim]; + + for (unsigned int iquad = 0; iquad < nQ; iquad++) + for (unsigned idim = 0; idim < 3; idim++) + d_gradDensityValsSpinDownAllQuads[3 * iquad + idim] = + gradDensityVals[3 * nQ + 3 * iquad + idim]; + } + } + + + void + AuxDensityFE::projectDensityEnd(const MPI_Comm &mpiComm) + {} + + +} // namespace dftfe diff --git a/src/excManager/AuxDensityMatrixSlater.cpp b/src/excManager/AuxDensityMatrixSlater.cpp new file mode 100644 index 000000000..da71e38d1 --- /dev/null +++ b/src/excManager/AuxDensityMatrixSlater.cpp @@ -0,0 +1,523 @@ +// +// Created by Arghadwip Paul. +// +#ifdef DFTFE_WITH_TORCH +# include "AuxDensityMatrixSlater.h" +# include +# include +# include + +namespace dftfe +{ + void + AuxDensityMatrixSlater::reinitAuxDensityMatrix( + const std::vector>> &atomCoords, + const std::string &auxBasisFile, + const int nSpin, + const int maxDerOrder) + { + d_sbs.constructBasisSet(atomCoords, auxBasisFile); + d_nBasis = d_sbs.getSlaterBasisSize(); + d_nSpin = nSpin; + d_maxDerOrder = maxDerOrder; + d_DM.assign(d_nSpin * d_nBasis * d_nBasis, 0.0); + } + + void + AuxDensityMatrixSlater::evalOverlapMatrixStart( + const std::vector &quadpts, + const std::vector &quadWt) + { + d_sbd.evalBasisData(quadpts, d_sbs, d_maxDerOrder); + d_SMatrix = std::vector(d_nBasis * d_nBasis, 0.0); + + for (int i = 0; i < d_nBasis; ++i) + { + for (int j = i; j < d_nBasis; ++j) + { + double sum = 0.0; + for (int iQuad = 0; iQuad < quadWt.size(); iQuad++) + { + sum += d_sbd.getBasisValues(iQuad * d_nBasis + i) * + d_sbd.getBasisValues(iQuad * d_nBasis + j) * + quadWt[iQuad]; + } + d_SMatrix[i * d_nBasis + j] = sum; + if (i != j) + { + d_SMatrix[j * d_nBasis + i] = sum; + } + } + } + } + + void + AuxDensityMatrixSlater::evalOverlapMatrixEnd(const MPI_Comm &mpiComm) + { + // MPI All Reduce + MPI_Allreduce(d_SMatrix.data(), + d_SMatrix.data(), + d_SMatrix.size(), + MPI_DOUBLE, + MPI_SUM, + mpiComm); + evalOverlapMatrixInv(); + } + + void + AuxDensityMatrixSlater::evalOverlapMatrixInv() + { + d_SMatrixInv = d_SMatrix; + // Invert using Cholesky + int info; + // Compute the Cholesky factorization of SMatrix + dftfe::dpotrf_("L", + reinterpret_cast(&d_nBasis), + d_SMatrixInv.data(), + reinterpret_cast(&d_nBasis), + &info); + + if (info != 0) + { + throw std::runtime_error("Error in dpotrf." + "Cholesky Factorization failed." + " Matrix may not be positive definite."); + } + + // Compute the inverse of SMatrix using the Cholesky factorization + dftfe::dpotri_("L", + reinterpret_cast(&d_nBasis), + d_SMatrixInv.data(), + reinterpret_cast(&d_nBasis), + &info); + if (info != 0) + { + throw std::runtime_error("Error in dpotri." + "Inversion using Cholesky Factors failed." + "Matrix may not be positive definite."); + } + + // Copy the upper triangular part to the lower triangular part + for (int i = 0; i < d_nBasis; ++i) + { + for (int j = i + 1; j < d_nBasis; ++j) + { + d_SMatrixInv[j * d_nBasis + i] = d_SMatrixInv[i * d_nBasis + j]; + } + } + + // Multiply SMatrix and SMatrixInv using dgemm_ + double alpha = 1.0; + double beta = 0.0; + std::vector CMatrix(d_nBasis * d_nBasis, 0.0); + dftfe::dgemm_("N", + "N", + reinterpret_cast(&d_nBasis), + reinterpret_cast(&d_nBasis), + reinterpret_cast(&d_nBasis), + &alpha, + d_SMatrix.data(), + reinterpret_cast(&d_nBasis), + d_SMatrixInv.data(), + reinterpret_cast(&d_nBasis), + &beta, + CMatrix.data(), + reinterpret_cast(&d_nBasis)); + + + + double frobenius_norm = 0.0; + for (int i = 0; i < d_nBasis; ++i) + { + for (int j = 0; j < d_nBasis; j++) + { + if (i == j) + { + frobenius_norm += (CMatrix[i * d_nBasis + j] - 1.0) * + (CMatrix[i * d_nBasis + j] - 1.0); + } + else + { + frobenius_norm += + CMatrix[i * d_nBasis + j] * CMatrix[i * d_nBasis + j]; + } + } + } + frobenius_norm = std::sqrt(frobenius_norm); + if (frobenius_norm > 1E-8) + { + std::cout << "frobenius norm of inversion : " << frobenius_norm + << std::endl; + throw std::runtime_error("SMatrix Inversion" + "using Cholesky Factors failed" + "to pass check!"); + } + } + + std::vector & + AuxDensityMatrixSlater::getOverlapMatrixInv() + { + return d_SMatrixInv; + } + + void + AuxDensityMatrixSlater::projectDensityMatrixStart( + std::unordered_map> &projectionInputs, + int iSpin) + { + // eval matrix d_SWFC + + d_iSpin = iSpin; + auto &psiFunc = projectionInputs["psiFunc"]; + auto &quadWt = projectionInputs["quadWt"]; + d_fValues = projectionInputs["fValues"]; + std::vector SlaterBasisValWeighted = d_sbd.getBasisValuesAll(); + + d_nQuad = quadWt.size(); + d_nWFC = psiFunc.size() / d_nQuad; + d_SWFC = std::vector(d_nBasis * d_nWFC, 0.0); + + + for (int i = 0; i < d_nQuad; ++i) + { + for (int j = 0; j < d_nBasis; ++j) + { + SlaterBasisValWeighted[i * d_nBasis + j] *= quadWt[i]; + } + } + + double alpha = 1.0; + double beta = 0.0; + dftfe::dgemm_("N", + "T", + reinterpret_cast(&d_nBasis), + reinterpret_cast(&d_nWFC), + reinterpret_cast(&d_nQuad), + &alpha, + SlaterBasisValWeighted.data(), + reinterpret_cast(&d_nBasis), + psiFunc.data(), + reinterpret_cast(&d_nWFC), + &beta, + d_SWFC.data(), + reinterpret_cast(&d_nBasis)); + } + + void + AuxDensityMatrixSlater::projectDensityMatrixEnd(const MPI_Comm &mpiComm) + { + // MPI All Reduce d_SWFC + MPI_Allreduce(d_SWFC.data(), + d_SWFC.data(), + d_SWFC.size(), + MPI_DOUBLE, + MPI_SUM, + mpiComm); + + auto SlaterOverlapInv = this->getOverlapMatrixInv(); + // Multiply S^(-1) * = BB + std::vector BB(d_nBasis * d_nWFC, 0.0); + double alpha = 1.0; + double beta = 0.0; + dftfe::dgemm_("N", + "N", + reinterpret_cast(&d_nBasis), + reinterpret_cast(&d_nWFC), + reinterpret_cast(&d_nBasis), + &alpha, + SlaterOverlapInv.data(), + reinterpret_cast(&d_nBasis), + d_SWFC.data(), + reinterpret_cast(&d_nBasis), + &beta, + BB.data(), + reinterpret_cast(&d_nBasis)); + + // BF = BB * F^(1/2) + std::vector BF = BB; + for (int i = 0; i < d_nWFC; i++) + { + for (int j = 0; j < d_nBasis; j++) + { + BF[i * d_nBasis + j] *= std::sqrt(d_fValues[i]); + } + } + + // D = BF * BF^T + dftfe::dgemm_("N", + "T", + reinterpret_cast(&d_nBasis), + reinterpret_cast(&d_nBasis), + reinterpret_cast(&d_nWFC), + &alpha, + BF.data(), + reinterpret_cast(&d_nBasis), + BF.data(), + reinterpret_cast(&d_nBasis), + &beta, + d_DM.data() + d_iSpin * d_nBasis * d_nBasis, + reinterpret_cast(&d_nBasis)); + } + + + namespace + { + void + fillDensityAttributeData(std::vector & attributeData, + const std::vector & values, + const std::pair &indexRange) + { + size_t startIndex = indexRange.first; + size_t endIndex = indexRange.second; + + if (startIndex > endIndex || endIndex >= attributeData.size() || + endIndex >= values.size()) + { + throw std::invalid_argument("Invalid index range for densityData"); + } + + for (size_t i = startIndex; i <= endIndex; ++i) + { + attributeData[i] = values[i]; + } + } + } // namespace + + void + AuxDensityMatrixSlater::applyLocalOperations( + const std::vector &Points, + std::unordered_map> + &densityData) + { + int DMSpinOffset = d_nBasis * d_nBasis; + std::pair indexRange; + + for (int iQuad = 0; iQuad < Points.size(); iQuad++) + { + std::vector rhoUp(1, 0.0); + std::vector rhoDown(1, 0.0); + std::vector rhoTotal(1, 0.0); + std::vector gradrhoUp(3, 0.0); + std::vector gradrhoDown(3, 0.0); + std::vector HessianrhoUp(9, 0.0); + std::vector HessianrhoDown(9, 0.0); + std::vector LaplacianrhoUp(1, 0.0); + std::vector LaplacianrhoDown(1, 0.0); + + for (int i = 0; i < d_nBasis; i++) + { + for (int j = 0; j < d_nBasis; j++) + { + for (int iSpin = 0; iSpin < d_nSpin; iSpin++) + { + if (iSpin == 0) + { + rhoUp[0] += d_DM[i * d_nBasis + j] * + d_sbd.getBasisValues(iQuad * d_nBasis + i) * + d_sbd.getBasisValues(iQuad * d_nBasis + j); + + for (int derIndex = 0; derIndex < 3; derIndex++) + { + gradrhoUp[derIndex] += + d_DM[i * d_nBasis + j] * + (d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * i + derIndex) * + d_sbd.getBasisValues(iQuad * d_nBasis + j) + + d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * j + derIndex) * + d_sbd.getBasisValues(iQuad * d_nBasis + i)); + } + + for (int derIndex1 = 0; derIndex1 < 3; derIndex1++) + { + for (int derIndex2 = 0; derIndex2 < 3; derIndex2++) + { + HessianrhoUp[derIndex1 * 3 + derIndex2] += + d_DM[i * d_nBasis + j] * + (d_sbd.getBasisHessianValues( + iQuad * d_nBasis + 9 * i + 3 * derIndex1 + + derIndex2) * + d_sbd.getBasisValues(iQuad * d_nBasis + + j) + + d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * i + derIndex1) * + d_sbd.getBasisGradValues( + iQuad * d_nBasis + 3 * j + derIndex2) + + d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * i + derIndex2) * + d_sbd.getBasisGradValues( + iQuad * d_nBasis + 3 * j + derIndex1) + + d_sbd.getBasisValues(iQuad * d_nBasis + i) * + d_sbd.getBasisHessianValues( + iQuad * d_nBasis + 9 * j + + 3 * derIndex1 + derIndex2)); + } + } + } + + if (iSpin == 1) + { + rhoDown[0] += + d_DM[DMSpinOffset + i * d_nBasis + j] * + d_sbd.getBasisValues(iQuad * d_nBasis + i) * + d_sbd.getBasisValues(iQuad * d_nBasis + j); + + for (int derIndex = 0; derIndex < 3; derIndex++) + { + gradrhoDown[derIndex] += + d_DM[DMSpinOffset + i * d_nBasis + j] * + (d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * i + derIndex) * + d_sbd.getBasisValues(iQuad * d_nBasis + j) + + d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * j + derIndex) * + d_sbd.getBasisValues(iQuad * d_nBasis + i)); + } + + for (int derIndex1 = 0; derIndex1 < 3; derIndex1++) + { + for (int derIndex2 = 0; derIndex2 < 3; derIndex2++) + { + HessianrhoDown[derIndex1 * 3 + derIndex2] += + d_DM[DMSpinOffset + i * d_nBasis + j] * + (d_sbd.getBasisHessianValues( + iQuad * d_nBasis + 9 * i + 3 * derIndex1 + + derIndex2) * + d_sbd.getBasisValues(iQuad * d_nBasis + + j) + + d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * i + derIndex1) * + d_sbd.getBasisGradValues( + iQuad * d_nBasis + 3 * j + derIndex2) + + d_sbd.getBasisGradValues(iQuad * d_nBasis + + 3 * i + derIndex2) * + d_sbd.getBasisGradValues( + iQuad * d_nBasis + 3 * j + derIndex1) + + d_sbd.getBasisValues(iQuad * d_nBasis + i) * + d_sbd.getBasisHessianValues( + iQuad * d_nBasis + 9 * j + + 3 * derIndex1 + derIndex2)); + } + } + } + } + } + } + + rhoTotal[0] = rhoUp[0] + rhoDown[0]; + LaplacianrhoUp[0] = HessianrhoUp[0] + HessianrhoUp[4] + HessianrhoUp[8]; + LaplacianrhoDown[0] = + HessianrhoDown[0] + HessianrhoDown[4] + HessianrhoDown[8]; + + + indexRange = std::make_pair(iQuad, iQuad); + if (densityData.find(DensityDescriptorDataAttributes::valuesTotal) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes::valuesTotal], + rhoTotal, + indexRange); + } + + if (densityData.find(DensityDescriptorDataAttributes::valuesSpinUp) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::valuesSpinUp], + rhoUp, + indexRange); + } + + if (densityData.find(DensityDescriptorDataAttributes::valuesSpinDown) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::valuesSpinDown], + rhoDown, + indexRange); + } + + indexRange = std::make_pair(iQuad * 3, iQuad * 3 + 2); + + if (densityData.find( + DensityDescriptorDataAttributes::gradValuesSpinUp) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::gradValuesSpinUp], + gradrhoUp, + indexRange); + } + + if (densityData.find( + DensityDescriptorDataAttributes::gradValuesSpinDown) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::gradValuesSpinDown], + gradrhoDown, + indexRange); + } + + indexRange = std::make_pair(iQuad * 9, iQuad * 9 + 8); + if (densityData.find(DensityDescriptorDataAttributes::hessianSpinUp) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::hessianSpinUp], + HessianrhoUp, + indexRange); + } + + // Check for hessianSpinDown attribute + if (densityData.find( + DensityDescriptorDataAttributes::hessianSpinDown) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::hessianSpinDown], + HessianrhoDown, + indexRange); + } + + + indexRange = std::make_pair(iQuad, iQuad); + if (densityData.find( + DensityDescriptorDataAttributes::laplacianSpinUp) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::laplacianSpinUp], + LaplacianrhoUp, + indexRange); + } + + if (densityData.find( + DensityDescriptorDataAttributes::laplacianSpinDown) == + densityData.end()) + { + fillDensityAttributeData( + densityData[DensityDescriptorDataAttributes ::laplacianSpinDown], + LaplacianrhoDown, + indexRange); + } + } + } + + void + AuxDensityMatrixSlater::projectDensityStart( + std::unordered_map> &projectionInputs) + { + // projectDensity implementation + std::cout << "Error : No implementation yet" << std::endl; + } + + void + AuxDensityMatrixSlater::projectDensityEnd(const MPI_Comm &mpiComm) + { + // projectDensity implementation + std::cout << "Error : No implementation yet" << std::endl; + } +} // namespace dftfe +#endif diff --git a/src/excManager/NNLLMGGA.cpp b/src/excManager/NNLLMGGA.cpp new file mode 100644 index 000000000..5be1fc691 --- /dev/null +++ b/src/excManager/NNLLMGGA.cpp @@ -0,0 +1,408 @@ +#ifdef DFTFE_WITH_TORCH +# include +# include +# include +# include +# include +# include +# include +# include + +# define GGA_CS 0.1616204596739955 +namespace dftfe +{ + namespace + { + struct CastToFloat + { + float + operator()(double value) const + { + return static_cast(value); + } + }; + + struct CastToDouble + { + double + operator()(float value) const + { + return static_cast(value); + } + }; + + template + inline void + interleave(IN1 it1, + IN1 end1, + IN2 it2, + IN2 end2, + IN3 it3, + IN3 end3, + unsigned int nbatch1, + unsigned int nbatch2, + unsigned int nbatch3, + OUT out) + { + // interleave until at least one container is done + while (it1 != end1 && it2 != end2 && it3 != end3) + { + // insert from container 1 + unsigned int ibatch1 = 0; + while (ibatch1 < nbatch1 && it1 != end1) + { + *out = *it1; + out++; + it1++; + ibatch1++; + } + + // insert from container 2 + unsigned int ibatch2 = 0; + while (ibatch2 < nbatch2 && it2 != end2) + { + *out = *it2; + out++; + it2++; + ibatch2++; + } + + // insert from container 3 + unsigned int ibatch3 = 0; + while (ibatch3 < nbatch3 && it3 != end3) + { + *out = *it3; + out++; + it3++; + ibatch3++; + } + } + + if (it1 != end1) // check and finish container 1 + { + std::copy(it1, end1, out); + } + if (it2 != end2) // check and finish container 2 + { + std::copy(it2, end2, out); + } + if (it3 != end3) // check and finish container 3 + { + std::copy(it3, end3, out); + } + } + + std::string + trim(const std::string &str, const std::string &whitespace = " \t") + { + std::size_t strBegin = str.find_first_not_of(whitespace); + if (strBegin == std::string::npos) + return ""; // no content + std::size_t strEnd = str.find_last_not_of(whitespace); + std::size_t strRange = strEnd - strBegin + 1; + return str.substr(strBegin, strRange); + } + + std::map + getKeyValuePairs(const std::string filename, const std::string delimiter) + { + std::map returnValue; + std::ifstream readFile; + std::string readLine; + readFile.open(filename.c_str()); + utils::throwException(readFile.is_open(), + "Unable to open file " + + filename); + while (std::getline(readFile, readLine)) + { + auto pos = readLine.find_last_of(delimiter); + if (pos != std::string::npos) + { + std::string key = trim(readLine.substr(0, pos)); + std::string value = trim(readLine.substr(pos + 1)); + returnValue[key] = value; + } + } + + readFile.close(); + return returnValue; + } + + + void + excSpinPolarized( + const double * rho, + const double * sigma, + const double * laprho, + const unsigned int numPoints, + double * exc, + torch::jit::script::Module * model, + const excDensityPositivityCheckTypes densityPositivityCheckType, + const double rhoTol, + const double sThreshold) + { + std::vector rhoModified(2 * numPoints, 0.0); + if (densityPositivityCheckType == + excDensityPositivityCheckTypes::EXCEPTION_POSITIVE) + for (unsigned int i = 0; i < 2 * numPoints; ++i) + { + std::string errMsg = + "Negative electron-density encountered during xc evaluations"; + dftfe::utils::throwException(rho[i] > 0, errMsg); + } + else if (densityPositivityCheckType == + excDensityPositivityCheckTypes::MAKE_POSITIVE) + for (unsigned int i = 0; i < 2 * numPoints; ++i) + { + rhoModified[i] = + std::max(rho[i], 0.0); // rhoTol will be added subsequently + } + else + for (unsigned int i = 0; i < 2 * numPoints; ++i) + { + rhoModified[i] = rho[i]; + } + + std::vector modGradRhoTotal(numPoints, 0.0); + for (unsigned int i = 0; i < numPoints; ++i) + modGradRhoTotal[i] = + std::sqrt(sigma[3 * i] + 2.0 * sigma[3 * i + 1] + sigma[3 * i + 2]); + + for (unsigned int i = 0; i < numPoints; ++i) + { + const double rhoTotal = rhoModified[2 * i] + rhoModified[2 * i + 1]; + const double rho4By3 = std::pow(rhoTotal, 4.0 / 3.0); + const double s = GGA_CS * modGradRhoTotal[i] / rho4By3; + if (s < sThreshold) + { + modGradRhoTotal[i] = sThreshold * rho4By3 / GGA_CS; + } + } + + std::vector lapRhoTotal(numPoints, 0.0); + for (unsigned int i = 0; i < numPoints; ++i) + { + lapRhoTotal[i] = laprho[2 * i] + laprho[2 * i + 1]; + } + + + std::vector rhoFloat(4 * numPoints); + interleave(&rhoModified[0], + &rhoModified[0] + 2 * numPoints, + &(modGradRhoTotal[0]), + &(modGradRhoTotal[0]) + numPoints, + &(lapRhoTotal[0]), + &(lapRhoTotal[0]) + numPoints, + 2, + 1, + 1, + &rhoFloat[0]); + + auto options = + torch::TensorOptions().dtype(torch::kFloat32).requires_grad(true); + torch::Tensor rhoTensor = + torch::from_blob(&rhoFloat[0], {numPoints, 4}, options).clone(); + rhoTensor += rhoTol; + std::vector input(0); + input.push_back(rhoTensor); + auto excTensor = model->forward(input).toTensor(); + for (unsigned int i = 0; i < numPoints; ++i) + exc[i] = static_cast(excTensor[i][0].item()) / + (rhoModified[2 * i] + rhoModified[2 * i + 1] + 2 * rhoTol); + } + + void + dexcSpinPolarized( + const double * rho, + const double * sigma, + const double * laprho, + const unsigned int numPoints, + double * exc, + double * dexc, + torch::jit::script::Module * model, + const excDensityPositivityCheckTypes densityPositivityCheckType, + const double rhoTol, + const double sThreshold) + { + std::vector rhoModified(2 * numPoints, 0.0); + if (densityPositivityCheckType == + excDensityPositivityCheckTypes::EXCEPTION_POSITIVE) + for (unsigned int i = 0; i < 2 * numPoints; ++i) + { + std::string errMsg = + "Negative electron-density encountered during xc evaluations"; + dftfe::utils::throwException(rho[i] > 0, errMsg); + } + else if (densityPositivityCheckType == + excDensityPositivityCheckTypes::MAKE_POSITIVE) + for (unsigned int i = 0; i < 2 * numPoints; ++i) + { + rhoModified[i] = + std::max(rho[i], 0.0); // rhoTol will be added subsequently + } + else + for (unsigned int i = 0; i < 2 * numPoints; ++i) + { + rhoModified[i] = rho[i]; + } + + std::vector modGradRhoTotal(numPoints, 0.0); + for (unsigned int i = 0; i < numPoints; ++i) + modGradRhoTotal[i] = + std::sqrt(sigma[3 * i] + 2.0 * sigma[3 * i + 1] + sigma[3 * i + 2]); + + for (unsigned int i = 0; i < numPoints; ++i) + { + const double rhoTotal = rhoModified[2 * i] + rhoModified[2 * i + 1]; + const double rho4By3 = std::pow(rhoTotal, 4.0 / 3.0); + const double s = GGA_CS * modGradRhoTotal[i] / rho4By3; + if (s < sThreshold) + { + modGradRhoTotal[i] = sThreshold * rho4By3 / GGA_CS; + } + } + + std::vector lapRhoTotal(numPoints, 0.0); + for (unsigned int i = 0; i < numPoints; ++i) + { + lapRhoTotal[i] = laprho[2 * i] + laprho[2 * i + 1]; + } + + std::vector rhoFloat(4 * numPoints); + interleave(&rhoModified[0], + &rhoModified[0] + 2 * numPoints, + &(modGradRhoTotal[0]), + &(modGradRhoTotal[0]) + numPoints, + &(lapRhoTotal[0]), + &(lapRhoTotal[0]) + numPoints, + 2, + 1, + 1, + &rhoFloat[0]); + + auto options = + torch::TensorOptions().dtype(torch::kFloat32).requires_grad(true); + torch::Tensor rhoTensor = + torch::from_blob(&rhoFloat[0], {numPoints, 3}, options).clone(); + rhoTensor += rhoTol; + std::vector input(0); + input.push_back(rhoTensor); + auto excTensor = model->forward(input).toTensor(); + auto grad_output = torch::ones_like(excTensor); + auto vxcTensor = torch::autograd::grad({excTensor}, + {rhoTensor}, + /*grad_outputs=*/{grad_output}, + /*create_graph=*/true)[0]; + for (unsigned int i = 0; i < numPoints; ++i) + { + exc[i] = static_cast(excTensor[i][0].item()) / + (rhoModified[2 * i] + rhoModified[2 * i + 1] + 2 * rhoTol); + dexc[7 * i + 0] = static_cast(vxcTensor[i][0].item()); + dexc[7 * i + 1] = static_cast(vxcTensor[i][1].item()); + dexc[7 * i + 2] = static_cast(vxcTensor[i][2].item()) / + (2.0 * (modGradRhoTotal[i] + rhoTol)); + dexc[7 * i + 3] = static_cast(vxcTensor[i][2].item()) / + (modGradRhoTotal[i] + rhoTol); + dexc[7 * i + 4] = static_cast(vxcTensor[i][2].item()) / + (2.0 * (modGradRhoTotal[i] + rhoTol)); + + dexc[7 * i + 5] = static_cast(vxcTensor[i][3].item()); + dexc[7 * i + 6] = static_cast(vxcTensor[i][3].item()); + } + } + + + } // namespace + + NNLLMGGA::NNLLMGGA( + std::string modelFileName, + const bool isSpinPolarized /*=false*/, + const excDensityPositivityCheckTypes densityPositivityCheckType) + : d_modelFileName(modelFileName) + , d_isSpinPolarized(isSpinPolarized) + , d_densityPositivityCheckType(densityPositivityCheckType) + { + std::map modelKeyValues = + getKeyValuePairs(d_modelFilename, "="); + + std::vector keysToFind = {"PTC_FILE", + "RHO_TOL", + "S_THRESHOLD"}; + + // check if all required keys are found + for (unsigned int i = 0; i < keysToFind.size(); ++i) + { + bool found = false; + for (auto it = modelKeyValues.begin(); it != modelKeyValues.end(); ++it) + { + if (keysToFind[i] == it->first) + found = true; + } + utils::throwException(found, + "Unable to find the key " + keysToFind[i] + + " in file " + d_modelFilename); + } + + d_ptcFilename = modelKeyValues["PTC_FILE"]; + d_rhoTol = std::stod(modelKeyValues["RHO_TOL"]); + d_sThreshold = std::stod(modelKeyValues["S_THRESHOLD"]); + + + d_model = new torch::jit::script::Module; + *d_model = torch::jit::load(d_modelFileName); + // Explicitly load model onto CPU, you can use kGPU if you are on Linux + // and have libtorch version with CUDA support (and a GPU) + d_model->to(torch::kCPU); + } + + NNLLMGGA::~NNLLMGGA() + { + delete d_model; + } + + void + NNLLMGGA::evaluateexc(const double * rho, + const double * sigma, + const double * laprho, + const unsigned int numPoints, + double * exc) + { + if (!d_isSpinPolarized) + throw std::runtime_error("Spin unpolarized NN is yet to be implemented."); + else + excSpinPolarized(rho, + sigma, + laprho, + numPoints, + exc, + d_model, + d_densityPositivityCheckType, + d_rhoTol, + d_sThreshold); + } + + void + NNLLMGGA::evaluatevxc(const double * rho, + const double * sigma, + const double * laprho, + const unsigned int numPoints, + double * exc, + double * dexc) + { + if (!d_isSpinPolarized) + throw std::runtime_error("Spin unpolarized NN is yet to be implemented."); + else + dexcSpinPolarized(rho, + sigma, + laprho, + numPoints, + exc, + dexc, + d_model, + d_densityPositivityCheckType, + d_rhoTol, + d_sThreshold); + } + +} // namespace dftfe +#endif diff --git a/src/excManager/SlaterBasisData.cpp b/src/excManager/SlaterBasisData.cpp new file mode 100644 index 000000000..d8671f30b --- /dev/null +++ b/src/excManager/SlaterBasisData.cpp @@ -0,0 +1,320 @@ +// +// Created by Arghadwip Paul. +// +#ifdef DFTFE_WITH_TORCH +# include +# include +# include +# include "SlaterBasisData.h" + +namespace dftfe +{ + void + SlaterBasisData::evalBasisData(const std::vector &quadpts, + const SlaterBasisSet & sbs, + int maxDerOrder) + { + int nQuad = quadpts.size() / 3; + int nBasis = sbs.getSlaterBasisSize(); + + switch (maxDerOrder) + { + case 0: + basisValues = std::vector(nQuad * nBasis, 0.0); + this->evalBasisValues(quadpts, sbs); + break; + + case 1: + basisValues = std::vector(nQuad * nBasis, 0.0); + basisGradValues = std::vector(nQuad * nBasis * 3, 0.0); + this->evalBasisGradValues(quadpts, sbs); + break; + + case 2: + basisValues = std::vector(nQuad * nBasis, 0.0); + basisGradValues = std::vector(nQuad * nBasis * 3, 0.0); + basisHessValues = std::vector(nQuad * nBasis * 9, 0.0); + this->evalBasisHessianValues(quadpts, sbs); + break; + + default: + throw std::runtime_error("\n\n maxDerOrder should be 0, 1 or 2 \n\n"); + } + } + + + // getBasisValues implementation + void + SlaterBasisData::evalBasisValues(const std::vector &quadpts, + const SlaterBasisSet & sbs) + { + int nBasis = sbs.getSlaterBasisSize(); + auto quadpts_t = torch::tensor(quadpts, torch::dtype(torch::kDouble)); + const std::vector &basisInfo = sbs.getSlaterBasisInfo(); + + // Slice the tensor to create x_t, y_t, z_t + auto x_t = quadpts_t + .index({torch::indexing::Slice(torch::indexing::None, + torch::indexing::None, + 3)}) + .clone(); + auto y_t = + quadpts_t.index({torch::indexing::Slice(1, torch::indexing::None, 3)}) + .clone(); + auto z_t = + quadpts_t.index({torch::indexing::Slice(2, torch::indexing::None, 3)}) + .clone(); + + int basis_ctr = 0; + for (const auto &info : basisInfo) + { + auto center = info.center; + auto slaterPrimitive = info.sp; + + auto x_shifted = x_t - center[0]; + auto y_shifted = y_t - center[1]; + auto z_shifted = z_t - center[2]; + + auto SV = this->evalSlaterFunc(x_shifted, + y_shifted, + z_shifted, + slaterPrimitive); + int nQuad_t = SV.size(0); + for (int i = 0; i < nQuad_t; ++i) + { + int vecIndex = basis_ctr + i * nBasis; + basisValues[vecIndex] = SV[i].item(); + } + basis_ctr += 1; + } + } + + // getBasisGradValues implementation + void + SlaterBasisData::evalBasisGradValues(const std::vector &quadpts, + const SlaterBasisSet & sbs) + { + int nBasis = sbs.getSlaterBasisSize(); + auto quadpts_t = torch::tensor(quadpts, torch::dtype(torch::kDouble)); + const std::vector &basisInfo = sbs.getSlaterBasisInfo(); + // Slice the tensor to create x_t, y_t, z_t + auto x_t = quadpts_t + .index({torch::indexing::Slice(torch::indexing::None, + torch::indexing::None, + 3)}) + .clone() + .set_requires_grad(true); + auto y_t = + quadpts_t.index({torch::indexing::Slice(1, torch::indexing::None, 3)}) + .clone() + .set_requires_grad(true); + auto z_t = + quadpts_t.index({torch::indexing::Slice(2, torch::indexing::None, 3)}) + .clone() + .set_requires_grad(true); + + int basis_ctr = 0; + for (const auto &info : basisInfo) + { + auto center = info.center; + auto slaterPrimitive = info.sp; + + auto x_shifted = x_t - center[0]; + auto y_shifted = y_t - center[1]; + auto z_shifted = z_t - center[2]; + + auto SV = this->evalSlaterFunc(x_shifted, + y_shifted, + z_shifted, + slaterPrimitive); + int nQuad_t = SV.size(0); + SV.backward(torch::ones_like(SV)); + for (int i = 0; i < nQuad_t; ++i) + { + int vecIndex_1 = basis_ctr + i * nBasis; + int vecIndex_2 = (basis_ctr + i * nBasis) * 3; + basisValues[vecIndex_1] = SV[i].item(); + basisGradValues[vecIndex_2] = x_t.grad()[i].item(); + basisGradValues[vecIndex_2 + 1] = y_t.grad()[i].item(); + basisGradValues[vecIndex_2 + 2] = z_t.grad()[i].item(); + } + x_t.grad().zero_(); + y_t.grad().zero_(); + z_t.grad().zero_(); + + basis_ctr += 1; + } + } + + // getBasisHessianValues implementation + void + SlaterBasisData::evalBasisHessianValues(const std::vector &quadpts, + const SlaterBasisSet & sbs) + { + int nBasis = sbs.getSlaterBasisSize(); + auto quadpts_t = torch::tensor(quadpts, torch::dtype(torch::kDouble)); + const std::vector &basisInfo = sbs.getSlaterBasisInfo(); + + // Slice the tensor to create x_t, y_t, z_t + auto x_t = quadpts_t + .index({torch::indexing::Slice(torch::indexing::None, + torch::indexing::None, + 3)}) + .clone() + .set_requires_grad(true); + auto y_t = + quadpts_t.index({torch::indexing::Slice(1, torch::indexing::None, 3)}) + .clone() + .set_requires_grad(true); + + auto z_t = + quadpts_t.index({torch::indexing::Slice(2, torch::indexing::None, 3)}) + .clone() + .set_requires_grad(true); + + int basis_ctr = 0; + for (const auto &info : basisInfo) + { + auto center = info.center; + auto slaterPrimitive = info.sp; + + auto x_shifted = x_t - center[0]; + auto y_shifted = y_t - center[1]; + auto z_shifted = z_t - center[2]; + + auto SF = this->evalSlaterFunc(x_shifted, + y_shifted, + z_shifted, + slaterPrimitive); + auto SF_prime = + torch::autograd::grad({SF}, + {x_t, y_t, z_t}, + /*grad_outputs=*/{torch::ones_like(SF)}, + /*retain_graph=*/c10::optional(true), + /*create_graph=*/true, + /*allow_unused=*/false); + + auto SFx_xyz = torch::autograd::grad({SF_prime[0]}, + {x_t, y_t, z_t}, + {torch::ones_like(SF_prime[0])}, + c10::optional(true), + false, + false); + + auto SFy_xyz = torch::autograd::grad({SF_prime[1]}, + {x_t, y_t, z_t}, + {torch::ones_like(SF_prime[1])}, + c10::optional(true), + false, + false); + + auto SFz_xyz = torch::autograd::grad({SF_prime[2]}, + {x_t, y_t, z_t}, + {torch::ones_like(SF_prime[2])}, + c10::optional(false), + false, + false); + + + int nQuad_t = SF.size(0); + for (int i = 0; i < nQuad_t; ++i) + { + int vecIndex_der0 = basis_ctr + i * nBasis; + int vecIndex_der1 = (basis_ctr + i * nBasis) * 3; + int vecIndex_der2 = (basis_ctr + i * nBasis) * 9; + + basisValues[vecIndex_der0] = SF[i].item(); + + basisGradValues[vecIndex_der1] = SF_prime[0][i].item(); + basisGradValues[vecIndex_der1 + 1] = SF_prime[1][i].item(); + basisGradValues[vecIndex_der1 + 2] = SF_prime[2][i].item(); + + basisHessValues[vecIndex_der2] = SFx_xyz[0][i].item(); + basisHessValues[vecIndex_der2 + 1] = SFx_xyz[1][i].item(); + basisHessValues[vecIndex_der2 + 2] = SFx_xyz[2][i].item(); + basisHessValues[vecIndex_der2 + 3] = SFy_xyz[0][i].item(); + basisHessValues[vecIndex_der2 + 4] = SFy_xyz[1][i].item(); + basisHessValues[vecIndex_der2 + 5] = SFy_xyz[2][i].item(); + basisHessValues[vecIndex_der2 + 6] = SFz_xyz[0][i].item(); + basisHessValues[vecIndex_der2 + 7] = SFz_xyz[1][i].item(); + basisHessValues[vecIndex_der2 + 8] = SFz_xyz[2][i].item(); + } + basis_ctr += 1; + } + } + + // evaluate Slater Function + torch::Tensor + SlaterBasisData::evalSlaterFunc(const torch::Tensor & x_s, + const torch::Tensor & y_s, + const torch::Tensor & z_s, + const SlaterPrimitive *sp) + { + int n = sp->n; + int l = sp->l; + int m = sp->m; + double alpha = sp->alpha; + + double t1 = std::pow(2.0 * alpha, n + 0.5); + double t2 = std::sqrt(std::tgamma(2 * n + 1)); + double nrm = t1 / t2; + + auto r = torch::sqrt(x_s * x_s + y_s * y_s + z_s * z_s); + auto theta = torch::acos(z_s / r); + auto phi = torch::atan2(y_s, x_s); + + int absm = abs(m); + auto cosTheta = torch::cos(theta); + auto C = Clm(l, absm) * Dm(m); + auto R = Rn(n, alpha, r); + auto P = associatedLegendre(l, absm, cosTheta); + auto Q = Qm(m, phi); + + auto SF = nrm * C * R * P * Q; + + return SF; + } + + double + SlaterBasisData::getBasisValues(const int index) + { + if (index < 0 || index >= basisValues.size()) + { + throw std::out_of_range( + "Index is outside the range of the basisValues vector."); + } + + return basisValues[index]; + } + + double + SlaterBasisData::getBasisGradValues(const int index) + { + if (index < 0 || index >= basisGradValues.size()) + { + throw std::out_of_range( + "Index is outside the range of the basisValues vector."); + } + + return basisGradValues[index]; + } + + double + SlaterBasisData::getBasisHessianValues(const int index) + { + if (index < 0 || index >= basisHessValues.size()) + { + throw std::out_of_range( + "Index is outside the range of the basisValues vector."); + } + + return basisHessValues[index]; + } + + std::vector + SlaterBasisData::getBasisValuesAll() + { + return basisValues; + } +} // namespace dftfe +#endif diff --git a/src/excManager/SlaterBasisSet.cpp b/src/excManager/SlaterBasisSet.cpp new file mode 100644 index 000000000..0f67fd666 --- /dev/null +++ b/src/excManager/SlaterBasisSet.cpp @@ -0,0 +1,213 @@ +// +// Created by Arghadwip Paul. +// + +#include +#include +#include +#include +#include + +#include "SlaterBasisSet.h" + +namespace dftfe +{ + SlaterBasisSet::SlaterBasisSet() + { + // empty constructor + } + + SlaterBasisSet::~SlaterBasisSet() + { + // deallocate SlaterPrimitive pointers stored in the map + for (auto &pair : d_atomToSlaterPrimitivePtr) + { + std::vector &primitives = pair.second; + for (SlaterPrimitive *sp : primitives) + { + if (sp != nullptr) + { + delete sp; + } + } + primitives.clear(); + } + } + + + void + SlaterBasisSet::constructBasisSet( + const std::vector>> &atomCoords, + const std::string &auxBasisFileName) + { + const auto atomToSlaterBasisName = + readAtomToSlaterBasisName(auxBasisFileName); + + for (const auto &pair : atomToSlaterBasisName) + { + const std::string &atomSymbol = pair.first; + const std::string &basisName = pair.second; + + this->addSlaterPrimitivesFromBasisFile(atomSymbol, basisName); + } + + + for (const auto &pair : atomCoords) + { + const std::string & atomSymbol = pair.first; + const std::vector &atomCenter = pair.second; + + for (const SlaterPrimitive *sp : d_atomToSlaterPrimitivePtr[atomSymbol]) + { + SlaterBasisInfo info = {atomSymbol, atomCenter, sp}; + d_SlaterBasisInfo.push_back(info); + } + } + } + + const std::vector & + SlaterBasisSet::getSlaterBasisInfo() const + { + return d_SlaterBasisInfo; + } + + int + SlaterBasisSet::getSlaterBasisSize() const + { + return static_cast(d_SlaterBasisInfo.size()); + } + + void + SlaterBasisSet::addSlaterPrimitivesFromBasisFile( + const std::string &atomSymbol, + const std::string &basisName) + { + /* + * Written in a format that ignores the first line + */ + std::ifstream file("../Data/" + basisName); + if (file.is_open()) + { + std::string line; + std::unordered_map lStringToIntMap = { + {"S", 0}, {"P", 1}, {"D", 2}, {"F", 3}, {"G", 4}, {"H", 5}}; + // First line - Ignore + std::getline(file, line); + std::istringstream iss(line); + if (iss.fail()) + { + throw std::runtime_error("Error reading line in file: " + + basisName); + } + std::string atomType, extra; + iss >> atomType; + if (iss >> extra) + { + throw std::runtime_error("Error: More than one entry in line 1 in" + + basisName); + } + // Second Line Onwards + while (std::getline(file, line)) + { + std::istringstream iss(line); + if (iss.fail()) + { + throw std::runtime_error("Error reading line in file: " + + basisName); + } + + std::string nlString; + double alpha; + iss >> nlString >> alpha; + if (iss >> extra) + { + throw std::runtime_error( + "Error: More than two entries in a line in" + basisName); + } + + char lChar = nlString.back(); + + int n = std::stoi(nlString.substr(0, nlString.size() - 1)); + int l; + try + { + l = lStringToIntMap.at(std::string(1, lChar)); + } + catch (const std::out_of_range &e) + { + throw std::runtime_error( + std::string( + "Character doesn't exist in the lStringToIntMap in " + "SlaterBasisSet.cpp: ") + + std::string(1, lChar)); + } + std::vector mList; + if (l == 1) + { + mList = {1, -1, 0}; // Special case for p orbitals + } + else + { + for (int m = -l; m <= l; ++m) + { + mList.push_back(m); + } + } + for (int m : mList) + { + SlaterPrimitive *sp = new SlaterPrimitive{n, l, m, alpha}; + d_atomToSlaterPrimitivePtr[atomSymbol].push_back(sp); + } + } + } + else + { + throw std::runtime_error("Unable to open file: " + basisName); + } + } + + + std::unordered_map + SlaterBasisSet::readAtomToSlaterBasisName(const std::string &fileName) + { + std::unordered_map atomToSlaterBasisName; + std::ifstream file(fileName); + if (file.is_open()) + { + std::string line; + int lineNumber = 0; + while (std::getline(file, line)) + { + lineNumber++; + std::istringstream iss(line); + std::string atomSymbol; + std::string slaterBasisName; + + if (iss >> atomSymbol >> slaterBasisName) + { + std::string extra; + if (iss >> extra) + { + throw std::runtime_error( + "Error: More than two entries in line " + + std::to_string(lineNumber) + "in" + fileName); + } + atomToSlaterBasisName[atomSymbol] = slaterBasisName; + } + else + { + throw std::runtime_error("Error: Invalid format in line " + + std::to_string(lineNumber) + "in" + + fileName); + } + } + file.close(); + } + else + { + std::cout << "Unable to open the file." + fileName << std::endl; + } + return atomToSlaterBasisName; + } + +} // namespace dftfe diff --git a/src/excManager/SphericalHarmonicFunc.cpp b/src/excManager/SphericalHarmonicFunc.cpp new file mode 100644 index 000000000..1cdde21f5 --- /dev/null +++ b/src/excManager/SphericalHarmonicFunc.cpp @@ -0,0 +1,103 @@ +// +// Created by Arghadwip Paul. +// + +#ifdef DFTFE_WITH_TORCH + +# include +# include +# include +# include +# include "SphericalHarmonicFunc.h" + +namespace dftfe +{ + double + Dm(const int m) + { + if (m == 0) + return 1.0 / sqrt(2 * M_PI); + else + return 1.0 / sqrt(M_PI); + } + + double + Clm(const int l, const int absm) + { + assert(absm <= l); + double a = (2.0 * l + 1.0) * tgamma(l - absm + 1); + double b = 2.0 * tgamma(l + absm + 1); + return sqrt(a / b); + } + + torch::Tensor + Rn(const int n, const double alpha, const torch::Tensor &r) + { + if (n == 1) + return torch::exp(-alpha * r); // torch + else + return (torch::pow(r, n - 1) * torch::exp(-alpha * r)); // torch + } + + torch::Tensor + Qm(const int m, const torch::Tensor &phi) + { + if (m > 0) + { + return torch::cos(m * phi); // torch + } + else if (m == 0) + { + return torch::ones_like(phi); // torch + } + else + { + return torch::sin(abs(m) * phi); // torch + } + } + + torch::Tensor + associatedLegendre(const int l, const int absm, const torch::Tensor &x) + { + assert(absm >= 0 && absm <= l); + + // Check if any value is outside the [-1, 1] range + if ((x < -1.0).any().item() || (x > 1.0).any().item()) + { + throw std::runtime_error( + "The argument to associated legendre must be in [-1,1]"); + } + + auto cxM = torch::ones_like(x); + auto somx2 = torch::sqrt(1.0 - x * x); + + double fact = 1.0; + for (int i = 0; i < absm; ++i) + { + cxM = -cxM * fact * somx2; + fact += 2.0; + } + + auto cx = cxM; + + if (absm != l) + { + auto cxMPlus1 = x * (2 * absm + 1) * cxM; + cx = cxMPlus1; + + auto cxPrev = cxMPlus1; + auto cxPrevPrev = cxM; + + for (int i = absm + 2; i <= l; ++i) + { + cx = ((2 * i - 1) * x * cxPrev + (-i - absm + 1) * cxPrevPrev) / + (i - absm); + cxPrevPrev = cxPrev; + cxPrev = cx; + } + } + + return (pow(-1.0, absm) * cx); + } +} // namespace dftfe +#endif diff --git a/src/excManager/excDensityBaseClass.cpp b/src/excManager/excDensityBaseClass.cpp index 614fa8325..2f2f15e94 100644 --- a/src/excManager/excDensityBaseClass.cpp +++ b/src/excManager/excDensityBaseClass.cpp @@ -14,15 +14,18 @@ // // --------------------------------------------------------------------- // -// @author Vishal Subramanian // #include namespace dftfe { - excDensityBaseClass::excDensityBaseClass(bool isSpinPolarized) - : d_isSpinPolarized(isSpinPolarized) + excDensityBaseClass::excDensityBaseClass( + const densityFamilyType familyType, + const std::vector + &densityDescriptorAttributesList) + : d_densityDescriptorAttributesList(densityDescriptorAttributesList) + , d_familyType(familyType) {} @@ -32,4 +35,9 @@ namespace dftfe return d_familyType; } + const std::vector & + excDensityBaseClass::getDensityDescriptorAttributesList() const + { + return d_densityDescriptorAttributesList; + } } // namespace dftfe diff --git a/src/excManager/excDensityGGAClass.cpp b/src/excManager/excDensityGGAClass.cpp index 5676fff2c..13c1e9b05 100644 --- a/src/excManager/excDensityGGAClass.cpp +++ b/src/excManager/excDensityGGAClass.cpp @@ -14,41 +14,45 @@ // // --------------------------------------------------------------------- // -// @author Vishal Subramanian +// @author Vishal Subramanian, Sambit Das // -#include -#include +#include "excDensityGGAClass.h" +#include "NNGGA.h" +#include "Exceptions.h" +#include namespace dftfe { excDensityGGAClass::excDensityGGAClass(xc_func_type *funcXPtr, - xc_func_type *funcCPtr, - bool isSpinPolarized, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor) - : excDensityBaseClass(isSpinPolarized) + xc_func_type *funcCPtr) + : excDensityBaseClass( + densityFamilyType::GGA, + std::vector{ + DensityDescriptorDataAttributes::valuesSpinUp, + DensityDescriptorDataAttributes::valuesSpinDown, + DensityDescriptorDataAttributes::gradValuesSpinUp, + DensityDescriptorDataAttributes::gradValuesSpinDown}) { - d_familyType = densityFamilyType::GGA; - d_funcXPtr = funcXPtr; - d_funcCPtr = funcCPtr; - d_NNGGAPtr = nullptr; + d_funcXPtr = funcXPtr; + d_funcCPtr = funcCPtr; + d_NNGGAPtr = nullptr; } excDensityGGAClass::excDensityGGAClass(xc_func_type *funcXPtr, xc_func_type *funcCPtr, - bool isSpinPolarized, - std::string modelXCInputFile, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor) - : excDensityBaseClass(isSpinPolarized) + std::string modelXCInputFile) + : excDensityBaseClass( + densityFamilyType::GGA, + std::vector{ + DensityDescriptorDataAttributes::valuesSpinUp, + DensityDescriptorDataAttributes::valuesSpinDown, + DensityDescriptorDataAttributes::gradValuesSpinUp, + DensityDescriptorDataAttributes::gradValuesSpinDown}) { - d_familyType = densityFamilyType::GGA; - d_funcXPtr = funcXPtr; - d_funcCPtr = funcCPtr; + d_funcXPtr = funcXPtr; + d_funcCPtr = funcCPtr; #ifdef DFTFE_WITH_TORCH d_NNGGAPtr = new NNGGA(modelXCInputFile, true); #endif @@ -61,236 +65,205 @@ namespace dftfe } void - excDensityGGAClass::computeDensityBasedEnergyDensity( - unsigned int sizeInput, - const std::map *> &rhoData, - std::vector &outputExchangeEnergyDensity, - std::vector &outputCorrEnergyDensity) const + excDensityGGAClass::checkInputOutputDataAttributesConsistency( + const std::vector &outputDataAttributes) const { - auto rhoValues = rhoData.find(rhoDataAttributes::values)->second; - auto rhoSigmaGradValues = - rhoData.find(rhoDataAttributes::sigmaGradValue)->second; - + const std::vector allowedOutputDataAttributes = { + xcOutputDataAttributes::e, + xcOutputDataAttributes::pdeDensitySpinUp, + xcOutputDataAttributes::pdeDensitySpinDown, + xcOutputDataAttributes::pdeSigma}; - // This * is not neccessary, unnessary referencing and de-referencing - xc_gga_exc(d_funcXPtr, - sizeInput, - &(*rhoValues)[0], - &(*rhoSigmaGradValues)[0], - &outputExchangeEnergyDensity[0]); - xc_gga_exc(d_funcCPtr, - sizeInput, - &(*rhoValues)[0], - &(*rhoSigmaGradValues)[0], - &outputCorrEnergyDensity[0]); - -#ifdef DFTFE_WITH_TORCH - if (d_NNGGAPtr != nullptr) + for (size_t i = 0; i < outputDataAttributes.size(); i++) { - std::vector rhoValuesForNN(2 * sizeInput, 0); - std::vector sigmaValuesForNN(3 * sizeInput, 0); - if (d_isSpinPolarized) + bool isFound = false; + for (size_t j = 0; j < allowedOutputDataAttributes.size(); j++) { - for (unsigned int i = 0; i < 2 * sizeInput; i++) - rhoValuesForNN[i] = (*rhoValues)[i]; - - for (unsigned int i = 0; i < 3 * sizeInput; i++) - sigmaValuesForNN[i] = (*rhoSigmaGradValues)[i]; + if (outputDataAttributes[i] == allowedOutputDataAttributes[j]) + isFound = true; } - else - { - for (unsigned int i = 0; i < sizeInput; i++) - { - rhoValuesForNN[2 * i] = 0.5 * (*rhoValues)[i]; - rhoValuesForNN[2 * i + 1] = 0.5 * (*rhoValues)[i]; - } - for (unsigned int i = 0; i < sizeInput; i++) - { - sigmaValuesForNN[3 * i] = (*rhoSigmaGradValues)[i] / 4.0; - sigmaValuesForNN[3 * i + 1] = (*rhoSigmaGradValues)[i] / 4.0; - sigmaValuesForNN[3 * i + 2] = (*rhoSigmaGradValues)[i] / 4.0; - } - } - std::vector excValuesFromNN(sizeInput, 0); - d_NNGGAPtr->evaluateexc(&(rhoValuesForNN[0]), - &(sigmaValuesForNN[0]), - sizeInput, - &excValuesFromNN[0]); - for (unsigned int i = 0; i < sizeInput; i++) - outputExchangeEnergyDensity[i] += excValuesFromNN[i]; + std::string errMsg = + "xcOutputDataAttributes do not matched allowed choices for the family type."; + dftfe::utils::throwException(isFound, errMsg); } -#endif } void - excDensityGGAClass::computeDensityBasedVxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDerExchangeEnergy, - std::map *> - &outputDerCorrEnergy) const + excDensityGGAClass::computeExcVxcFxc( + AuxDensityMatrix & auxDensityMatrix, + const std::vector &quadPoints, + const std::vector &quadWeights, + std::unordered_map> &xDataOut, + std::unordered_map> &cDataOut) + const { - auto rhoValues = rhoData.find(rhoDataAttributes::values)->second; - auto rhoSigmaGradValues = - rhoData.find(rhoDataAttributes::sigmaGradValue)->second; + std::vector outputDataAttributes; + for (const auto &element : xDataOut) + outputDataAttributes.push_back(element.first); + + checkInputOutputDataAttributesConsistency(outputDataAttributes); + + + std::unordered_map> + densityDescriptorData; + + for (size_t i = 0; i < d_densityDescriptorAttributesList.size(); i++) + { + if (d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::valuesSpinUp || + d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::valuesSpinDown) + densityDescriptorData[d_densityDescriptorAttributesList[i]] = + std::vector(quadWeights.size(), 0); + else if (d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::gradValuesSpinUp || + d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::gradValuesSpinDown) + densityDescriptorData[d_densityDescriptorAttributesList[i]] = + std::vector(3 * quadWeights.size(), 0); + } - auto derExchangeEnergyWithDensity = - outputDerExchangeEnergy - .find(VeffOutputDataAttributes::derEnergyWithDensity) + auxDensityMatrix.applyLocalOperations(quadPoints, densityDescriptorData); + + + auto &densityValuesSpinUp = + densityDescriptorData.find(DensityDescriptorDataAttributes::valuesSpinUp) ->second; - auto derExchangeEnergyWithSigmaGradDensity = - outputDerExchangeEnergy - .find(VeffOutputDataAttributes::derEnergyWithSigmaGradDensity) + auto &densityValuesSpinDown = + densityDescriptorData + .find(DensityDescriptorDataAttributes::valuesSpinDown) ->second; - - auto derCorrEnergyWithDensity = - outputDerCorrEnergy.find(VeffOutputDataAttributes::derEnergyWithDensity) + auto &gradValuesSpinUp = + densityDescriptorData + .find(DensityDescriptorDataAttributes::gradValuesSpinUp) ->second; - - auto derCorrEnergyWithSigmaGradDensity = - outputDerCorrEnergy - .find(VeffOutputDataAttributes::derEnergyWithSigmaGradDensity) + auto &gradValuesSpinDown = + densityDescriptorData + .find(DensityDescriptorDataAttributes::gradValuesSpinDown) ->second; - xc_gga_vxc(d_funcXPtr, - sizeInput, - &(*rhoValues)[0], - &(*rhoSigmaGradValues)[0], - &(*derExchangeEnergyWithDensity)[0], - &(*derExchangeEnergyWithSigmaGradDensity)[0]); - xc_gga_vxc(d_funcCPtr, - sizeInput, - &(*rhoValues)[0], - &(*rhoSigmaGradValues)[0], - &(*derCorrEnergyWithDensity)[0], - &(*derCorrEnergyWithSigmaGradDensity)[0]); -#ifdef DFTFE_WITH_TORCH - if (d_NNGGAPtr != nullptr) + std::vector densityValues(2 * quadWeights.size(), 0); + std::vector sigmaValues(3 * quadWeights.size(), 0); + + std::vector exValues(quadWeights.size(), 0); + std::vector ecValues(quadWeights.size(), 0); + std::vector pdexDensityValuesNonNN(2 * quadWeights.size(), 0); + std::vector pdecDensityValuesNonNN(2 * quadWeights.size(), 0); + std::vector pdexDensitySpinUpValues(quadWeights.size(), 0); + std::vector pdexDensitySpinDownValues(quadWeights.size(), 0); + std::vector pdecDensitySpinUpValues(quadWeights.size(), 0); + std::vector pdecDensitySpinDownValues(quadWeights.size(), 0); + std::vector pdexSigmaValues(3 * quadWeights.size(), 0); + std::vector pdecSigmaValues(3 * quadWeights.size(), 0); + + for (size_t i = 0; i < quadWeights.size(); i++) { - std::vector rhoValuesForNN(2 * sizeInput, 0); - std::vector sigmaValuesForNN(3 * sizeInput, 0); - if (d_isSpinPolarized) + densityValues[2 * i + 0] = densityValuesSpinUp[i]; + densityValues[2 * i + 1] = densityValuesSpinDown[i]; + for (size_t j = 0; j < 3; j++) { - for (unsigned int i = 0; i < 2 * sizeInput; i++) - rhoValuesForNN[i] = (*rhoValues)[i]; - - for (unsigned int i = 0; i < 3 * sizeInput; i++) - sigmaValuesForNN[i] = (*rhoSigmaGradValues)[i]; + sigmaValues[3 * i + 0] += + gradValuesSpinUp[3 * i + j] * gradValuesSpinUp[3 * i + j]; + sigmaValues[3 * i + 1] += + gradValuesSpinUp[3 * i + j] * gradValuesSpinDown[3 * i + j]; + sigmaValues[3 * i + 2] += + gradValuesSpinDown[3 * i + j] * gradValuesSpinDown[3 * i + j]; } - else - { - for (unsigned int i = 0; i < sizeInput; i++) - { - rhoValuesForNN[2 * i] = 0.5 * (*rhoValues)[i]; - rhoValuesForNN[2 * i + 1] = 0.5 * (*rhoValues)[i]; - } + } - for (unsigned int i = 0; i < sizeInput; i++) - { - sigmaValuesForNN[3 * i] = (*rhoSigmaGradValues)[i] / 4.0; - sigmaValuesForNN[3 * i + 1] = (*rhoSigmaGradValues)[i] / 4.0; - sigmaValuesForNN[3 * i + 2] = (*rhoSigmaGradValues)[i] / 4.0; - } - } + xc_gga_exc_vxc(d_funcXPtr, + quadWeights.size(), + &densityValues[0], + &sigmaValues[0], + &exValues[0], + &pdexDensityValuesNonNN[0], + &pdexSigmaValues[0]); + xc_gga_exc_vxc(d_funcCPtr, + quadWeights.size(), + &densityValues[0], + &sigmaValues[0], + &ecValues[0], + &pdecDensityValuesNonNN[0], + &pdecSigmaValues[0]); + + for (size_t i = 0; i < quadWeights.size(); i++) + { + exValues[i] = + exValues[i] * (densityValues[2 * i + 0] + densityValues[2 * i + 1]); + ecValues[i] = + ecValues[i] * (densityValues[2 * i + 0] + densityValues[2 * i + 1]); + pdexDensitySpinUpValues[i] = pdexDensityValuesNonNN[2 * i + 0]; + pdexDensitySpinDownValues[i] = pdexDensityValuesNonNN[2 * i + 1]; + pdecDensitySpinUpValues[i] = pdecDensityValuesNonNN[2 * i + 0]; + pdecDensitySpinDownValues[i] = pdecDensityValuesNonNN[2 * i + 1]; + } - std::vector excValuesFromNN(sizeInput, 0); - std::vector vxcValuesFromNN(5 * sizeInput, 0); - d_NNGGAPtr->evaluatevxc(&(rhoValuesForNN[0]), - &(sigmaValuesForNN[0]), - sizeInput, +#ifdef DFTFE_WITH_TORCH + if (d_NNGGAPtr != nullptr) + { + std::vector excValuesFromNN(quadWeights.size(), 0); + const size_t numDescriptors = d_densityDescriptorAttributesList.size(); + std::vector pdexcDescriptorValuesFromNN(numDescriptors * + quadWeights.size(), + 0); + d_NNGGAPtr->evaluatevxc(&(densityValues[0]), + &sigmaValues[0], + quadWeights.size(), &excValuesFromNN[0], - &vxcValuesFromNN[0]); - if (d_isSpinPolarized) - { - for (unsigned int i = 0; i < sizeInput; i++) - { - (*derExchangeEnergyWithDensity)[2 * i] += - vxcValuesFromNN[5 * i]; - (*derExchangeEnergyWithDensity)[2 * i + 1] += - vxcValuesFromNN[5 * i + 1]; - (*derExchangeEnergyWithSigmaGradDensity)[3 * i] += - vxcValuesFromNN[5 * i + 2]; - (*derExchangeEnergyWithSigmaGradDensity)[3 * i + 1] += - vxcValuesFromNN[5 * i + 3]; - (*derExchangeEnergyWithSigmaGradDensity)[3 * i + 2] += - vxcValuesFromNN[5 * i + 4]; - } - } - else + &pdexcDescriptorValuesFromNN[0]); + for (size_t i = 0; i < quadWeights.size(); i++) { - for (unsigned int i = 0; i < sizeInput; i++) - { - (*derExchangeEnergyWithDensity)[i] += vxcValuesFromNN[5 * i]; - (*derExchangeEnergyWithSigmaGradDensity)[i] += - vxcValuesFromNN[5 * i + 2]; - } + exValues[i] += excValuesFromNN[i]; + pdexDensitySpinUpValues[i] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 0]; + pdexDensitySpinDownValues[i] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 1]; + pdexSigmaValues[3 * i + 0] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 2]; + pdexSigmaValues[3 * i + 1] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 3]; + pdexSigmaValues[3 * i + 2] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 4]; } } #endif - } - - - void - excDensityGGAClass::computeDensityBasedFxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDer2ExchangeEnergy, - std::map *> - &outputDer2CorrEnergy) const - { - auto rhoValues = rhoData.find(rhoDataAttributes::values)->second; - auto rhoSigmaGradValues = - rhoData.find(rhoDataAttributes::sigmaGradValue)->second; - - - auto der2ExchangeEnergyWithDensity = - outputDer2ExchangeEnergy - .find(fxcOutputDataAttributes::der2EnergyWithDensity) - ->second; - auto der2ExchangeEnergyWithDensitySigma = - outputDer2ExchangeEnergy - .find(fxcOutputDataAttributes::der2EnergyWithDensitySigma) - ->second; - - auto der2ExchangeEnergyWithSigmaGradDensity = - outputDer2ExchangeEnergy - .find(fxcOutputDataAttributes::der2EnergyWithSigma) - ->second; - auto der2CorrEnergyWithDensity = - outputDer2CorrEnergy.find(fxcOutputDataAttributes::der2EnergyWithDensity) - ->second; - auto der2CorrEnergyWithDensitySigma = - outputDer2CorrEnergy - .find(fxcOutputDataAttributes::der2EnergyWithDensitySigma) - ->second; - - auto der2CorrEnergyWithSigmaGradDensity = - outputDer2CorrEnergy.find(fxcOutputDataAttributes::der2EnergyWithSigma) - ->second; + for (size_t i = 0; i < outputDataAttributes.size(); i++) + { + if (outputDataAttributes[i] == xcOutputDataAttributes::e) + { + xDataOut.find(outputDataAttributes[i])->second = exValues; + cDataOut.find(outputDataAttributes[i])->second = ecValues; + } + else if (outputDataAttributes[i] == + xcOutputDataAttributes::pdeDensitySpinUp) + { + xDataOut.find(outputDataAttributes[i])->second = + pdexDensitySpinUpValues; + cDataOut.find(outputDataAttributes[i])->second = + pdecDensitySpinUpValues; + } + else if (outputDataAttributes[i] == + xcOutputDataAttributes::pdeDensitySpinDown) + { + xDataOut.find(outputDataAttributes[i])->second = + pdexDensitySpinDownValues; - xc_gga_fxc(d_funcXPtr, - sizeInput, - &(*rhoValues)[0], - &(*rhoSigmaGradValues)[0], - &(*der2ExchangeEnergyWithDensity)[0], - &(*der2ExchangeEnergyWithDensitySigma)[0], - &(*der2ExchangeEnergyWithSigmaGradDensity)[0]); + cDataOut.find(outputDataAttributes[i])->second = + pdecDensitySpinDownValues; + } + else if (outputDataAttributes[i] == xcOutputDataAttributes::pdeSigma) + { + xDataOut.find(outputDataAttributes[i])->second = pdexSigmaValues; - xc_gga_fxc(d_funcCPtr, - sizeInput, - &(*rhoValues)[0], - &(*rhoSigmaGradValues)[0], - &(*der2CorrEnergyWithDensity)[0], - &(*der2CorrEnergyWithDensitySigma)[0], - &(*der2CorrEnergyWithSigmaGradDensity)[0]); + cDataOut.find(outputDataAttributes[i])->second = pdecSigmaValues; + } + } } } // namespace dftfe diff --git a/src/excManager/excDensityLDAClass.cpp b/src/excManager/excDensityLDAClass.cpp index 834134e41..ba150719f 100644 --- a/src/excManager/excDensityLDAClass.cpp +++ b/src/excManager/excDensityLDAClass.cpp @@ -14,25 +14,25 @@ // // --------------------------------------------------------------------- // -// @author Vishal Subramanian +// @author Vishal Subramanian, Sambit Das // #include #include +#include +#include namespace dftfe { excDensityLDAClass::excDensityLDAClass(xc_func_type *funcXPtr, - xc_func_type *funcCPtr, - bool isSpinPolarized, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor) - : excDensityBaseClass(isSpinPolarized) + xc_func_type *funcCPtr) + : excDensityBaseClass(densityFamilyType::LDA, + std::vector{ + DensityDescriptorDataAttributes::valuesSpinUp, + DensityDescriptorDataAttributes::valuesSpinDown}) { - d_familyType = densityFamilyType::LDA; - d_funcXPtr = funcXPtr; - d_funcCPtr = funcCPtr; + d_funcXPtr = funcXPtr; + d_funcCPtr = funcCPtr; #ifdef DFTFE_WITH_TORCH d_NNLDAPtr = nullptr; #endif @@ -40,16 +40,14 @@ namespace dftfe excDensityLDAClass::excDensityLDAClass(xc_func_type *funcXPtr, xc_func_type *funcCPtr, - bool isSpinPolarized, - std::string modelXCInputFile, - bool scaleExchange, - bool computeCorrelation, - double scaleExchangeFactor) - : excDensityBaseClass(isSpinPolarized) + std::string modelXCInputFile) + : excDensityBaseClass(densityFamilyType::LDA, + std::vector{ + DensityDescriptorDataAttributes::valuesSpinUp, + DensityDescriptorDataAttributes::valuesSpinDown}) { - d_familyType = densityFamilyType::LDA; - d_funcXPtr = funcXPtr; - d_funcCPtr = funcCPtr; + d_funcXPtr = funcXPtr; + d_funcCPtr = funcCPtr; #ifdef DFTFE_WITH_TORCH d_NNLDAPtr = new NNLDA(modelXCInputFile, true); #endif @@ -62,155 +60,158 @@ namespace dftfe } void - excDensityLDAClass::computeDensityBasedEnergyDensity( - unsigned int sizeInput, - const std::map *> &rhoData, - std::vector &outputExchangeEnergyDensity, - std::vector &outputCorrEnergyDensity) const + excDensityLDAClass::checkInputOutputDataAttributesConsistency( + const std::vector &outputDataAttributes) const { - auto rhoValues = rhoData.find(rhoDataAttributes::values)->second; - - xc_lda_exc(d_funcXPtr, - sizeInput, - &(*rhoValues)[0], - &outputExchangeEnergyDensity[0]); - xc_lda_exc(d_funcCPtr, - sizeInput, - &(*rhoValues)[0], - &outputCorrEnergyDensity[0]); + const std::vector allowedOutputDataAttributes = { + xcOutputDataAttributes::e, + xcOutputDataAttributes::pdeDensitySpinUp, + xcOutputDataAttributes::pdeDensitySpinDown}; -#ifdef DFTFE_WITH_TORCH - if (d_NNLDAPtr != nullptr) + for (unsigned int i = 0; i < outputDataAttributes.size(); i++) { - std::vector rhoValuesForNN(2 * sizeInput, 0); - if (d_isSpinPolarized) + bool isFound = false; + for (unsigned int j = 0; j < allowedOutputDataAttributes.size(); j++) { - for (unsigned int i = 0; i < 2 * sizeInput; i++) - { - rhoValuesForNN[i] = (*rhoValues)[i]; - } - } - else - { - for (unsigned int i = 0; i < sizeInput; i++) - { - rhoValuesForNN[2 * i] = 0.5 * (*rhoValues)[i]; - rhoValuesForNN[2 * i + 1] = 0.5 * (*rhoValues)[i]; - } + if (outputDataAttributes[i] == allowedOutputDataAttributes[j]) + isFound = true; } - std::vector excValuesFromNN(sizeInput, 0); - d_NNLDAPtr->evaluateexc(&(rhoValuesForNN[0]), - sizeInput, - &excValuesFromNN[0]); - for (unsigned int i = 0; i < sizeInput; i++) - outputExchangeEnergyDensity[i] += excValuesFromNN[i]; + + std::string errMsg = + "xcOutputDataAttributes do not matched allowed choices for the family type."; + dftfe::utils::throwException(isFound, errMsg); } -#endif } void - excDensityLDAClass::computeDensityBasedVxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDerExchangeEnergy, - std::map *> - &outputDerCorrEnergy) const + excDensityLDAClass::computeExcVxcFxc( + AuxDensityMatrix & auxDensityMatrix, + const std::vector &quadPoints, + const std::vector &quadWeights, + std::unordered_map> &xDataOut, + std::unordered_map> &cDataOut) + const { - auto rhoValues = rhoData.find(rhoDataAttributes::values)->second; + std::vector outputDataAttributes; + for (const auto &element : xDataOut) + outputDataAttributes.push_back(element.first); - auto exchangePotentialVal = - outputDerExchangeEnergy - .find(VeffOutputDataAttributes::derEnergyWithDensity) - ->second; + checkInputOutputDataAttributesConsistency(outputDataAttributes); + + + std::unordered_map> + densityDescriptorData; + + for (unsigned int i = 0; i < d_densityDescriptorAttributesList.size(); i++) + { + densityDescriptorData[d_densityDescriptorAttributesList[i]] = + std::vector(quadWeights.size(), 0); + } + + auxDensityMatrix.applyLocalOperations(quadPoints, densityDescriptorData); - auto corrPotentialVal = - outputDerCorrEnergy.find(VeffOutputDataAttributes::derEnergyWithDensity) + + auto &densityValuesSpinUp = + densityDescriptorData.find(DensityDescriptorDataAttributes::valuesSpinUp) + ->second; + auto &densityValuesSpinDown = + densityDescriptorData + .find(DensityDescriptorDataAttributes::valuesSpinDown) ->second; - xc_lda_vxc(d_funcXPtr, - sizeInput, - &(*rhoValues)[0], - &(*exchangePotentialVal)[0]); - xc_lda_vxc(d_funcCPtr, - sizeInput, - &(*rhoValues)[0], - &(*corrPotentialVal)[0]); + + + std::vector densityValues(2 * quadWeights.size(), 0); + + std::vector exValues(quadWeights.size(), 0); + std::vector ecValues(quadWeights.size(), 0); + std::vector pdexDensityValuesNonNN(2 * quadWeights.size(), 0); + std::vector pdecDensityValuesNonNN(2 * quadWeights.size(), 0); + std::vector pdexDensitySpinUpValues(quadWeights.size(), 0); + std::vector pdexDensitySpinDownValues(quadWeights.size(), 0); + std::vector pdecDensitySpinUpValues(quadWeights.size(), 0); + std::vector pdecDensitySpinDownValues(quadWeights.size(), 0); + + for (unsigned int i = 0; i < quadWeights.size(); i++) + { + densityValues[2 * i + 0] = densityValuesSpinUp[i]; + densityValues[2 * i + 1] = densityValuesSpinDown[i]; + } + + xc_lda_exc_vxc(d_funcXPtr, + quadWeights.size(), + &densityValues[0], + &exValues[0], + &pdexDensityValuesNonNN[0]); + xc_lda_exc_vxc(d_funcCPtr, + quadWeights.size(), + &densityValues[0], + &ecValues[0], + &pdecDensityValuesNonNN[0]); + + for (unsigned int i = 0; i < quadWeights.size(); i++) + { + exValues[i] = + exValues[i] * (densityValues[2 * i + 0] + densityValues[2 * i + 1]); + ecValues[i] = + ecValues[i] * (densityValues[2 * i + 0] + densityValues[2 * i + 1]); + pdexDensitySpinUpValues[i] = pdexDensityValuesNonNN[2 * i + 0]; + pdexDensitySpinDownValues[i] = pdexDensityValuesNonNN[2 * i + 1]; + pdecDensitySpinUpValues[i] = pdecDensityValuesNonNN[2 * i + 0]; + pdecDensitySpinDownValues[i] = pdecDensityValuesNonNN[2 * i + 1]; + } #ifdef DFTFE_WITH_TORCH if (d_NNLDAPtr != nullptr) { - std::vector rhoValuesForNN(2 * sizeInput, 0); - if (d_isSpinPolarized) - { - for (unsigned int i = 0; i < 2 * sizeInput; i++) - { - rhoValuesForNN[i] = (*rhoValues)[i]; - } - } - else - { - for (unsigned int i = 0; i < sizeInput; i++) - { - rhoValuesForNN[2 * i] = 0.5 * (*rhoValues)[i]; - rhoValuesForNN[2 * i + 1] = 0.5 * (*rhoValues)[i]; - } - } - - std::vector excValuesFromNN(2 * sizeInput, 0); - std::vector vxcValuesFromNN(2 * sizeInput, 0); - d_NNLDAPtr->evaluatevxc(&(rhoValuesForNN[0]), - sizeInput, + std::vector excValuesFromNN(quadWeights.size(), 0); + const unsigned int numDescriptors = + d_densityDescriptorAttributesList.size(); + std::vector pdexcDescriptorValuesFromNN(numDescriptors * + quadWeights.size(), + 0); + d_NNLDAPtr->evaluatevxc(&(densityValues[0]), + quadWeights.size(), &excValuesFromNN[0], - &vxcValuesFromNN[0]); - if (d_isSpinPolarized) - { - for (unsigned int i = 0; i < 2 * sizeInput; i++) - (*exchangePotentialVal)[i] += vxcValuesFromNN[i]; - } - else + &pdexcDescriptorValuesFromNN[0]); + for (unsigned int i = 0; i < quadWeights.size(); i++) { - for (unsigned int i = 0; i < sizeInput; i++) - (*exchangePotentialVal)[i] += vxcValuesFromNN[2 * i]; + exValues[i] += excValuesFromNN[i]; + pdexDensitySpinUpValues[i] += + pdexcDescriptorFromNN[numDescriptors * i + 0]; + pdexDensitySpinDownValues[i] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 1]; } } #endif - } - - void - excDensityLDAClass::computeDensityBasedFxc( - unsigned int sizeInput, - const std::map *> &rhoData, - std::map *> - &outputDer2ExchangeEnergy, - std::map *> - &outputDer2CorrEnergy) const - { - auto rhoValues = rhoData.find(rhoDataAttributes::values)->second; - - auto der2ExchangeEnergyWithDensity = - outputDer2ExchangeEnergy - .find(fxcOutputDataAttributes::der2EnergyWithDensity) - ->second; - - auto der2CorrEnergyWithDensity = - outputDer2CorrEnergy.find(fxcOutputDataAttributes::der2EnergyWithDensity) - ->second; + for (unsigned int i = 0; i < outputDataAttributes.size(); i++) + { + if (outputDataAttributes[i] == xcOutputDataAttributes::e) + { + xDataOut.find(outputDataAttributes[i])->second = exValues; + cDataOut.find(outputDataAttributes[i])->second = ecValues; + } + else if (outputDataAttributes[i] == + xcOutputDataAttributes::pdeDensitySpinUp) + { + xDataOut.find(outputDataAttributes[i])->second = + pdexDensitySpinUpValues; - xc_lda_fxc(d_funcXPtr, - sizeInput, - &(*rhoValues)[0], - &(*der2ExchangeEnergyWithDensity)[0]); + cDataOut.find(outputDataAttributes[i])->second = + pdecDensitySpinUpValues; + } + else if (outputDataAttributes[i] == + xcOutputDataAttributes::pdeDensitySpinDown) + { + xDataOut.find(outputDataAttributes[i])->second = + pdexDensitySpinDownValues; - xc_lda_fxc(d_funcCPtr, - sizeInput, - &(*rhoValues)[0], - &(*der2CorrEnergyWithDensity)[0]); + cDataOut.find(outputDataAttributes[i])->second = + pdecDensitySpinDownValues; + } + } } - - - } // namespace dftfe diff --git a/src/excManager/excDensityLLMGGAClass.cpp b/src/excManager/excDensityLLMGGAClass.cpp new file mode 100644 index 000000000..102e1261c --- /dev/null +++ b/src/excManager/excDensityLLMGGAClass.cpp @@ -0,0 +1,587 @@ +#include +#include +#include +#include +#include "Exceptions.h" +#include "FiniteDifference.h" + +namespace dftfe +{ + excDensityLLMGGAClass::excDensityLLMGGAClass(xc_func_type *funcXPtr, + xc_func_type *funcCPtr) + : excDensityBaseClass(densityFamilyType::LLMGGA, + std::vector{ + DensityDescriptorDataAttributes::valuesSpinUp, + DensityDescriptorDataAttributes::valuesSpinDown, + DensityDescriptorDataAttributes::gradValuesSpinUp, + DensityDescriptorDataAttributes::gradValuesSpinDown, + DensityDescriptorDataAttributes::laplacianSpinUp, + DensityDescriptorDataAttributes::laplacianSpinDown}) + { + d_funcXPtr = funcXPtr; + d_funcCPtr = funcCPtr; + d_NNLLMGGAPtr = nullptr; + } + + excDensityLLMGGAClass::excDensityLLMGGAClass(xc_func_type *funcXPtr, + xc_func_type *funcCPtr, + std::string modelXCInputFile) + : excDensityBaseClass(densityFamilyType::LLMGGA, + std::vector{ + DensityDescriptorDataAttributes::valuesSpinUp, + DensityDescriptorDataAttributes::valuesSpinDown, + DensityDescriptorDataAttributes::gradValuesSpinUp, + DensityDescriptorDataAttributes::gradValuesSpinDown, + DensityDescriptorDataAttributes::laplacianSpinUp, + DensityDescriptorDataAttributes::laplacianSpinDown}) + { + d_funcXPtr = funcXPtr; + d_funcCPtr = funcCPtr; +#ifdef DFTFE_WITH_TORCH + d_NNLLMGGAPtr = new NNLLMGGA(modelXCInputFile, true); +#endif + } + + excDensityLLMGGAClass::~excDensityLLMGGAClass() + { + if (d_NNLLMGGAPtr != nullptr) + delete d_NNLLMGGAPtr; + } + + void + excDensityLLMGGAClass::checkInputOutputDataAttributesConsistency( + const std::vector &outputDataAttributes) const + { + const std::vector allowedOutputDataAttributes = { + xcOutputDataAttributes::e, + xcOutputDataAttributes::vSpinUp, + xcOutputDataAttributes::vSpinDown, + xcOutputDataAttributes::pdeDensitySpinUp, + xcOutputDataAttributes::pdeDensitySpinDown, + xcOutputDataAttributes::pdeSigma, + xcOutputDataAttributes::pdeLaplacianSpinUp, + xcOutputDataAttributes::pdeLaplacianSpinDown}; + + for (size_t i = 0; i < outputDataAttributes.size(); i++) + { + bool isFound = false; + for (size_t j = 0; j < allowedOutputDataAttributes.size(); j++) + { + if (outputDataAttributes[i] == allowedOutputDataAttributes[j]) + isFound = true; + } + + std::string errMsg = + "xcOutputDataAttributes do not matched allowed choices for the family type."; + dftfe::utils::throwException(isFound, errMsg); + } + } + + void + excDensityLLMGGAClass::computeExcVxcFxc( + AuxDensityMatrix & auxDensityMatrix, + const std::vector &quadPoints, + const std::vector &quadWeights, + std::unordered_map> &xDataOut, + std::unordered_map> &cDataOut) + const + { + std::vector outputDataAttributes; + for (const auto &element : xDataOut) + outputDataAttributes.push_back(element.first); + + checkInputOutputDataAttributesConsistency(outputDataAttributes); + + std::unordered_map> + densityDescriptorData; + + // d_densityDescriptorAttributesList not defined + for (size_t i = 0; i < d_densityDescriptorAttributesList.size(); i++) + { + if (d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::valuesSpinUp || + d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::valuesSpinDown) + densityDescriptorData[d_densityDescriptorAttributesList[i]] = + std::vector(quadWeights.size(), 0); + else if (d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::gradValuesSpinUp || + d_densityDescriptorAttributesList[i] == + DensityDescriptorDataAttributes::gradValuesSpinDown) + densityDescriptorData[d_densityDescriptorAttributesList[i]] = + std::vector(3 * quadWeights.size(), 0); + } + + bool isVxcBeingComputed = false; + if (std::find(outputDataAttributes.begin(), + outputDataAttributes.end(), + xcOutputDataAttributes::vSpinUp) != + outputDataAttributes.end() || + std::find(outputDataAttributes.begin(), + outputDataAttributes.end(), + xcOutputDataAttributes::vSpinDown) != + outputDataAttributes.end()) + isVxcBeingComputed = true; + + auxDensityMatrix.applyLocalOperations(quadPoints, densityDescriptorData); + + auto &densityValuesSpinUp = + densityDescriptorData.find(DensityDescriptorDataAttributes::valuesSpinUp) + ->second; + auto &densityValuesSpinDown = + densityDescriptorData + .find(DensityDescriptorDataAttributes::valuesSpinDown) + ->second; + auto &gradValuesSpinUp = + densityDescriptorData + .find(DensityDescriptorDataAttributes::gradValuesSpinUp) + ->second; + auto &gradValuesSpinDown = + densityDescriptorData + .find(DensityDescriptorDataAttributes::gradValuesSpinDown) + ->second; + auto &laplacianValuesSpinUp = + densityDescriptorData + .find(DensityDescriptorDataAttributes::laplacianSpinUp) + ->second; + auto &laplacianValuesSpinDown = + densityDescriptorData + .find(DensityDescriptorDataAttributes::laplacianSpinDown) + ->second; + + + std::vector densityValues(2 * quadWeights.size(), 0); + std::vector sigmaValues(3 * quadWeights.size(), 0); + std::vector laplacianValues(2 * quadWeights.size(), 0); + + std::vector exValues(quadWeights.size(), 0); + std::vector ecValues(quadWeights.size(), 0); + std::vector pdexDensityValuesNonNN(2 * quadWeights.size(), 0); + std::vector pdecDensityValuesNonNN(2 * quadWeights.size(), 0); + std::vector pdexDensitySpinUpValues(quadWeights.size(), 0); + std::vector pdexDensitySpinDownValues(quadWeights.size(), 0); + std::vector pdecDensitySpinUpValues(quadWeights.size(), 0); + std::vector pdecDensitySpinDownValues(quadWeights.size(), 0); + std::vector pdexSigmaValues(3 * quadWeights.size(), 0); + std::vector pdecSigmaValues(3 * quadWeights.size(), 0); + + + for (size_t i = 0; i < quadWeights.size(); i++) + { + densityValues[2 * i + 0] = densityValuesSpinUp[i]; + densityValues[2 * i + 1] = densityValuesSpinDown[i]; + + for (size_t j = 0; j < 3; j++) + { + sigmaValues[3 * i + 0] += + gradValuesSpinUp[3 * i + j] * gradValuesSpinUp[3 * i + j]; + sigmaValues[3 * i + 1] += + gradValuesSpinUp[3 * i + j] * gradValuesSpinDown[3 * i + j]; + sigmaValues[3 * i + 2] += + gradValuesSpinDown[3 * i + j] * gradValuesSpinDown[3 * i + j]; + } + + laplacianValues[2 * i + 0] = laplacianValuesSpinUp[i]; + laplacianValues[2 * i + 1] = laplacianValuesSpinDown[i]; + } + + xc_gga_exc_vxc(d_funcXPtr, + quadWeights.size(), + &densityValues[0], + &sigmaValues[0], + &exValues[0], + &pdexDensityValuesNonNN[0], + &pdexSigmaValues[0]); + xc_gga_exc_vxc(d_funcCPtr, + quadWeights.size(), + &densityValues[0], + &sigmaValues[0], + &ecValues[0], + &pdecDensityValuesNonNN[0], + &pdecSigmaValues[0]); + + for (size_t i = 0; i < quadWeights.size(); i++) + { + exValues[i] = + exValues[i] * (densityValues[2 * i + 0] + densityValues[2 * i + 1]); + ecValues[i] = + ecValues[i] * (densityValues[2 * i + 0] + densityValues[2 * i + 1]); + pdexDensitySpinUpValues[i] = pdexDensityValuesNonNN[2 * i + 0]; + pdexDensitySpinDownValues[i] = pdexDensityValuesNonNN[2 * i + 1]; + pdecDensitySpinUpValues[i] = pdecDensityValuesNonNN[2 * i + 0]; + pdecDensitySpinDownValues[i] = pdecDensityValuesNonNN[2 * i + 1]; + } + + +#ifdef DFTFE_WITH_TORCH + if (d_NNLLMGGAPtr != nullptr) + { + std::vector excValuesFromNN(quadWeights.size(), 0); + const size_t numDescriptors = d_densityDescriptorAttributesList.size(); + std::vector pdexcDescriptorValuesFromNN(numDescriptors * + quadWeights.size(), + 0); + + d_NNLLMGGAPtr->evaluatevxc(&(densityValues[0]), + &sigmaValues[0], + &laplacianValues[0], + quadWeights.size(), + &excValuesFromNN[0], + &pdexcDescriptorValuesFromNN[0]); + + for (size_t i = 0; i < quadWeights.size(); i++) + { + exValues[i] += excValuesFromNN[i]; + pdexDensitySpinUpValues[i] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 0]; + pdexDensitySpinDownValues[i] += + pdexcDescriptorValuesFromNN[numDescriptors * i + 1]; + } + } +#endif + + std::vector vxValuesSpinUp(quadWeights.size(), 0); + std::vector vcValuesSpinUp(quadWeights.size(), 0); + std::vector vxValuesSpinDown(quadWeights.size(), 0); + std::vector vcValuesSpinDown(quadWeights.size(), 0); + + if (isVxcBeingComputed) + { + std::vector pdexGradDensityidimSpinUpStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector pdecGradDensityidimSpinUpStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector> divergenceTermsPdexGradDensitySpinUp( + 3, std::vector(quadWeights.size(), 0)); + std::vector> divergenceTermsPdecGradDensitySpinUp( + 3, std::vector(quadWeights.size(), 0)); + std::vector pdexLapDensityidimSpinUpStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector pdecLapDensityidimSpinUpStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector> laplacianTermsPdexLapDensitySpinUp( + 3, std::vector(quadWeights.size(), 0)); + std::vector> laplacianTermsPdecLapDensitySpinUp( + 3, std::vector(quadWeights.size(), 0)); + + std::vector pdexGradDensityidimSpinDownStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector pdecGradDensityidimSpinDownStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector> divergenceTermsPdexGradDensitySpinDown( + 3, std::vector(quadWeights.size(), 0)); + std::vector> divergenceTermsPdecGradDensitySpinDown( + 3, std::vector(quadWeights.size(), 0)); + std::vector pdexLapDensityidimSpinDownStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector pdecLapDensityidimSpinDownStencil( + quadWeights.size() * d_vxcDivergenceTermFDStencilSize, 0.0); + std::vector> laplacianTermsPdexLapDensitySpinDown( + 3, std::vector(quadWeights.size(), 0)); + std::vector> laplacianTermsPdecLapDensitySpinDown( + 3, std::vector(quadWeights.size(), 0)); + + + std::unordered_map> + densityDescriptorDataForFD; + + std::vector densityValuesFD(2 * quadWeights.size(), 0); + std::vector sigmaValuesFD(3 * quadWeights.size(), 0); + std::vector laplacianValuesFD(2 * quadWeights.size(), 0); + + std::vector exValuesFD(quadWeights.size(), 0); + std::vector ecValuesFD(quadWeights.size(), 0); + std::vector pdexDensityValuesNonNNFD(2 * quadWeights.size(), + 0); // not used + std::vector pdecDensityValuesNonNNFD(2 * quadWeights.size(), + 0); // not used + std::vector pdexSigmaValuesFD(3 * quadWeights.size(), 0); + std::vector pdecSigmaValuesFD(3 * quadWeights.size(), 0); + std::vector pdexLaplacianValuesFD(2 * quadWeights.size(), 0); + std::vector pdecLaplacianValuesFD(2 * quadWeights.size(), + 0); // not used + + std::vector d_spacingFDStencil(quadWeights.size(), 1e-4); + + for (size_t idim = 0; idim < 3; idim++) + { + for (size_t istencil = 0; + istencil < d_vxcDivergenceTermFDStencilSize; + istencil++) + { + std::vector quadShiftedFD = quadPoints; + for (size_t igrid = 0; igrid < quadWeights.size(); igrid++) + { + // create FD grid + quadShiftedFD[3 * igrid + idim] = + quadPoints[3 * igrid + idim] + + (-std::floor(d_vxcDivergenceTermFDStencilSize / 2) * + d_spacingFDStencil[igrid] + + igrid * d_spacingFDStencil[igrid]); + } + + auxDensityMatrix.applyLocalOperations( + quadShiftedFD, densityDescriptorDataForFD); + + auto &densityValuesSpinUpFD = + densityDescriptorDataForFD + .find(DensityDescriptorDataAttributes::valuesSpinUp) + ->second; + auto &densityValuesSpinDownFD = + densityDescriptorDataForFD + .find(DensityDescriptorDataAttributes::valuesSpinDown) + ->second; + auto &gradValuesSpinUpFD = + densityDescriptorDataForFD + .find(DensityDescriptorDataAttributes::gradValuesSpinUp) + ->second; + auto &gradValuesSpinDownFD = + densityDescriptorDataForFD + .find(DensityDescriptorDataAttributes::gradValuesSpinDown) + ->second; + auto &laplacianValuesSpinUpFD = + densityDescriptorDataForFD + .find(DensityDescriptorDataAttributes::laplacianSpinUp) + ->second; + auto &laplacianValuesSpinDownFD = + densityDescriptorDataForFD + .find(DensityDescriptorDataAttributes::laplacianSpinDown) + ->second; + + for (size_t i = 0; i < quadWeights.size(); i++) + { + densityValuesFD[2 * i + 0] = densityValuesSpinUpFD[i]; + densityValuesFD[2 * i + 1] = densityValuesSpinDownFD[i]; + + sigmaValuesFD[3 * i + 0] = 0; + sigmaValuesFD[3 * i + 1] = 0; + sigmaValuesFD[3 * i + 2] = 0; + + for (size_t j = 0; j < 3; j++) + { + sigmaValuesFD[3 * i + 0] += + gradValuesSpinUpFD[3 * i + j] * + gradValuesSpinUpFD[3 * i + j]; + sigmaValuesFD[3 * i + 1] += + gradValuesSpinUpFD[3 * i + j] * + gradValuesSpinDownFD[3 * i + j]; + sigmaValuesFD[3 * i + 2] += + gradValuesSpinDownFD[3 * i + j] * + gradValuesSpinDownFD[3 * i + j]; + } + + laplacianValuesFD[2 * i + 0] = laplacianValuesSpinUp[i]; + laplacianValuesFD[2 * i + 1] = laplacianValuesSpinDown[i]; + } + + xc_gga_exc_vxc(d_funcXPtr, + quadWeights.size(), + &densityValuesFD[0], + &sigmaValuesFD[0], + &exValuesFD[0], + &pdexDensityValuesNonNNFD[0], + &pdexSigmaValuesFD[0]); + xc_gga_exc_vxc(d_funcCPtr, + quadWeights.size(), + &densityValuesFD[0], + &sigmaValuesFD[0], + &ecValuesFD[0], + &pdecDensityValuesNonNNFD[0], + &pdecSigmaValuesFD[0]); + +#ifdef DFTFE_WITH_TORCH + if (d_NNLLMGGAPtr != nullptr) + { + std::vector excValuesFromNNFD(quadWeights.size(), + 0); + const size_t numDescriptors = + d_densityDescriptorAttributesList.size(); + std::vector pdexcDescriptorValuesFromNNFD( + numDescriptors * quadWeights.size(), 0); + + + d_NNLLMGGAPtr->evaluatevxc( + &(densityValuesFD[0]), + &sigmaValuesFD[0], + &laplacianValuesFD[0], + quadWeights.size(), + &excValuesFromNNFD[0], + &pdexcDescriptorValuesFromNNFD[0]); + + for (size_t i = 0; i < quadWeights.size(); i++) + { + pdexSigmaValuesFD[3 * i + 0] += + pdexcDescriptorValuesFromNNFD[numDescriptors * i + 2]; + pdexSigmaValuesFD[3 * i + 1] += + pdexcDescriptorValuesFromNNFD[numDescriptors * i + 3]; + pdexSigmaValuesFD[3 * i + 2] += + pdexcDescriptorValuesFromNNFD[numDescriptors * i + 4]; + pdexLaplacianValuesFD[2 * i + 0] += + pdexcDescriptorValuesFromNNFD[numDescriptors * i + 5]; + pdexLaplacianValuesFD[2 * i + 1] += + pdexcDescriptorValuesFromNNFD[numDescriptors * i + 6]; + } + } +#endif + + for (size_t igrid = 0; igrid < quadWeights.size(); igrid++) + { + pdexGradDensityidimSpinUpStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + gradValuesSpinUpFD[3 * igrid + idim] * + (2.0 * pdexSigmaValuesFD[3 * igrid] + + pdexSigmaValuesFD[3 * igrid + 1]) + + gradValuesSpinDownFD[3 * igrid + idim] * + (2.0 * pdexSigmaValuesFD[3 * igrid + 2] + + pdexSigmaValuesFD[3 * igrid + 1]); + + pdecGradDensityidimSpinUpStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + gradValuesSpinUpFD[3 * igrid + idim] * + (2.0 * pdecSigmaValuesFD[3 * igrid] + + pdecSigmaValuesFD[3 * igrid + 1]) + + gradValuesSpinDownFD[3 * igrid + idim] * + (2.0 * pdecSigmaValuesFD[3 * igrid + 2] + + pdecSigmaValuesFD[3 * igrid + 1]); + + pdexLapDensityidimSpinUpStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + pdexLaplacianValuesFD[2 * igrid]; + + pdecLapDensityidimSpinUpStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + pdecLaplacianValuesFD[2 * igrid]; + + pdexGradDensityidimSpinDownStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + gradValuesSpinUpFD[3 * igrid + idim] * + (2.0 * pdexSigmaValuesFD[3 * igrid] + + pdexSigmaValuesFD[3 * igrid + 1]) + + gradValuesSpinDownFD[3 * igrid + idim] * + (2.0 * pdexSigmaValuesFD[3 * igrid + 2] + + pdexSigmaValuesFD[3 * igrid + 1]); + + pdecGradDensityidimSpinDownStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + gradValuesSpinUpFD[3 * igrid + idim] * + (2.0 * pdecSigmaValuesFD[3 * igrid] + + pdecSigmaValuesFD[3 * igrid + 1]) + + gradValuesSpinDownFD[3 * igrid + idim] * + (2.0 * pdecSigmaValuesFD[3 * igrid + 2] + + pdecSigmaValuesFD[3 * igrid + 1]); + + pdexLapDensityidimSpinDownStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + pdexLaplacianValuesFD[2 * igrid + 1]; + + pdecLapDensityidimSpinDownStencil + [igrid * d_vxcDivergenceTermFDStencilSize + istencil] = + pdecLaplacianValuesFD[2 * igrid + 1]; + } + } // stencil grid filling loop + + utils::FiniteDifference::firstOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdexGradDensityidimSpinUpStencil[0]), + &(divergenceTermsPdexGradDensitySpinUp[idim][0])); + + utils::FiniteDifference::firstOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdecGradDensityidimSpinUpStencil[0]), + &(divergenceTermsPdecGradDensitySpinUp[idim][0])); + + utils::FiniteDifference::firstOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdexGradDensityidimSpinDownStencil[0]), + &(divergenceTermsPdexGradDensitySpinDown[idim][0])); + + utils::FiniteDifference::firstOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdecGradDensityidimSpinDownStencil[0]), + &(divergenceTermsPdecGradDensitySpinDown[idim][0])); + + + utils::FiniteDifference::secondOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdexLapDensityidimSpinUpStencil[0]), + &(laplacianTermsPdexLapDensitySpinUp[idim][0])); + + /* + utils::FiniteDifference::secondOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdecLapDensityidimSpinUpStencil[0]), + &(laplacianTermsPdecLapDensitySpinUp[idim][0])); + */ + + utils::FiniteDifference::secondOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdexLapDensityidimSpinDownStencil[0]), + &(laplacianTermsPdexLapDensitySpinDown[idim][0])); + + /* + utils::FiniteDifference::secondOrderDerivativeOneVariableCentral( + d_vxcDivergenceTermFDStencilSize, + &(d_spacingFDStencil[0]), + quadWeights.size(), + &(pdecLapDensityidimSpinDownStencil[0]), + &(laplacianTermsPdecLapDensitySpinDown[idim][0])); + */ + + } // dim loop + + for (size_t igrid = 0; igrid < quadWeights.size(); igrid++) + { + vxValuesSpinUp[igrid] = + pdexDensitySpinUpValues[igrid] - + (divergenceTermsPdexGradDensitySpinUp[0][igrid] + + divergenceTermsPdexGradDensitySpinUp[1][igrid] + + divergenceTermsPdexGradDensitySpinUp[2][igrid]) + + (laplacianTermsPdexLapDensitySpinUp[0][igrid] + + laplacianTermsPdexLapDensitySpinUp[1][igrid] + + laplacianTermsPdexLapDensitySpinUp[2][igrid]); + + vcValuesSpinUp[igrid] = + pdecDensitySpinUpValues[igrid] - + (divergenceTermsPdecGradDensitySpinUp[0][igrid] + + divergenceTermsPdecGradDensitySpinUp[1][igrid] + + divergenceTermsPdecGradDensitySpinUp[2][igrid]) + + (laplacianTermsPdecLapDensitySpinUp[0][igrid] + + laplacianTermsPdecLapDensitySpinUp[1][igrid] + + laplacianTermsPdecLapDensitySpinUp[2][igrid]); + + + vxValuesSpinDown[igrid] = + pdexDensitySpinDownValues[igrid] - + (divergenceTermsPdexGradDensitySpinDown[0][igrid] + + divergenceTermsPdexGradDensitySpinDown[1][igrid] + + divergenceTermsPdexGradDensitySpinDown[2][igrid]) + + (laplacianTermsPdexLapDensitySpinDown[0][igrid] + + laplacianTermsPdexLapDensitySpinDown[1][igrid] + + laplacianTermsPdexLapDensitySpinDown[2][igrid]); + + vcValuesSpinDown[igrid] = + pdecDensitySpinDownValues[igrid] - + (divergenceTermsPdecGradDensitySpinDown[0][igrid] + + divergenceTermsPdecGradDensitySpinDown[1][igrid] + + divergenceTermsPdecGradDensitySpinDown[2][igrid]) + + (laplacianTermsPdecLapDensitySpinDown[0][igrid] + + laplacianTermsPdecLapDensitySpinDown[1][igrid] + + laplacianTermsPdecLapDensitySpinDown[2][igrid]); + } + } // VxcCompute check + } +} // namespace dftfe diff --git a/src/excManager/excManager.cpp b/src/excManager/excManager.cpp index 05ae32f9a..e69f2d548 100644 --- a/src/excManager/excManager.cpp +++ b/src/excManager/excManager.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace dftfe { @@ -67,13 +68,9 @@ namespace dftfe void - excManager::init(unsigned int xc_id, - bool isSpinPolarized, - unsigned int exxFactor, - bool scaleExchange, - unsigned int scaleExchangeFactor, - bool computeCorrelation, - std::string modelXCInputFile) + excManager::init(std::string XCType, + bool isSpinPolarized, + std::string modelXCInputFile) { clear(); @@ -82,135 +79,89 @@ namespace dftfe int exceptParamX = -1, exceptParamC = -1; - int isSpinPolarizedXC; - if (isSpinPolarized) + + + if (XCType == "LDA-PZ") { - isSpinPolarizedXC = XC_POLARIZED; + exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_LDA_C_PZ, XC_POLARIZED); + d_excDensityObjPtr = new excDensityLDAClass(d_funcXPtr, d_funcCPtr); + + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); } - else + else if (XCType == "LDA-PW") { - isSpinPolarizedXC = XC_UNPOLARIZED; + exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_LDA_C_PW, XC_POLARIZED); + d_excDensityObjPtr = new excDensityLDAClass(d_funcXPtr, d_funcCPtr); + + + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); } + else if (XCType == "LDA-VWN") + { + exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_LDA_C_VWN, XC_POLARIZED); + d_excDensityObjPtr = new excDensityLDAClass(d_funcXPtr, d_funcCPtr); + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); + } + else if (XCType == "GGA-PBE") + { + exceptParamX = xc_func_init(d_funcXPtr, XC_GGA_X_PBE, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_GGA_C_PBE, XC_POLARIZED); + d_excDensityObjPtr = new excDensityGGAClass(d_funcXPtr, d_funcCPtr); - switch (xc_id) + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); + } + else if (XCType == "GGA-RPBE") { - case 1: - exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, isSpinPolarizedXC); - exceptParamC = - xc_func_init(d_funcCPtr, XC_LDA_C_PZ, isSpinPolarizedXC); - d_excDensityObjPtr = new excDensityLDAClass(d_funcXPtr, - d_funcCPtr, - isSpinPolarized, - scaleExchange, - computeCorrelation, - scaleExchangeFactor); - - d_excWavefunctionObjPtr = - new excWavefunctionNoneClass(isSpinPolarized); - break; - case 2: - exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, isSpinPolarizedXC); - exceptParamC = - xc_func_init(d_funcCPtr, XC_LDA_C_PW, isSpinPolarizedXC); - d_excDensityObjPtr = new excDensityLDAClass(d_funcXPtr, - d_funcCPtr, - isSpinPolarized, - scaleExchange, - computeCorrelation, - scaleExchangeFactor); - - d_excWavefunctionObjPtr = - new excWavefunctionNoneClass(isSpinPolarized); - break; - case 3: - exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, isSpinPolarizedXC); - exceptParamC = - xc_func_init(d_funcCPtr, XC_LDA_C_VWN, isSpinPolarizedXC); - d_excDensityObjPtr = new excDensityLDAClass(d_funcXPtr, - d_funcCPtr, - isSpinPolarized, - scaleExchange, - computeCorrelation, - scaleExchangeFactor); - d_excWavefunctionObjPtr = - new excWavefunctionNoneClass(isSpinPolarized); - break; - case 4: - exceptParamX = - xc_func_init(d_funcXPtr, XC_GGA_X_PBE, isSpinPolarizedXC); - exceptParamC = - xc_func_init(d_funcCPtr, XC_GGA_C_PBE, isSpinPolarizedXC); - d_excDensityObjPtr = new excDensityGGAClass(d_funcXPtr, - d_funcCPtr, - isSpinPolarized, - scaleExchange, - computeCorrelation, - scaleExchangeFactor); - - d_excWavefunctionObjPtr = - new excWavefunctionNoneClass(isSpinPolarized); - break; - case 5: - exceptParamX = - xc_func_init(d_funcXPtr, XC_GGA_X_RPBE, isSpinPolarizedXC); - exceptParamC = - xc_func_init(d_funcCPtr, XC_GGA_C_PBE, isSpinPolarizedXC); - d_excDensityObjPtr = new excDensityGGAClass(d_funcXPtr, - d_funcCPtr, - isSpinPolarized, - scaleExchange, - computeCorrelation, - scaleExchangeFactor); - - d_excWavefunctionObjPtr = - new excWavefunctionNoneClass(isSpinPolarized); - break; - case 6: - exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, isSpinPolarizedXC); - exceptParamC = - xc_func_init(d_funcCPtr, XC_LDA_C_PW, isSpinPolarizedXC); - d_excDensityObjPtr = new excDensityLDAClass(d_funcXPtr, - d_funcCPtr, - isSpinPolarized, - modelXCInputFile, - scaleExchange, - computeCorrelation, - scaleExchangeFactor); - - d_excWavefunctionObjPtr = - new excWavefunctionNoneClass(isSpinPolarized); - break; - case 7: - exceptParamX = - xc_func_init(d_funcXPtr, XC_GGA_X_PBE, isSpinPolarizedXC); - exceptParamC = - xc_func_init(d_funcCPtr, XC_GGA_C_PBE, isSpinPolarizedXC); - d_excDensityObjPtr = new excDensityGGAClass(d_funcXPtr, - d_funcCPtr, - isSpinPolarized, - modelXCInputFile, - scaleExchange, - computeCorrelation, - scaleExchangeFactor); - - d_excWavefunctionObjPtr = - new excWavefunctionNoneClass(isSpinPolarized); - break; - default: - std::cout << "Error in xc code \n"; - break; - - if (exceptParamX != 0 || exceptParamC != 0) - { - std::cout << "-------------------------------------" << std::endl; - std::cout << "Exchange or Correlation Functional not found" - << std::endl; - std::cout << "-------------------------------------" << std::endl; - exit(-1); - } + exceptParamX = xc_func_init(d_funcXPtr, XC_GGA_X_RPBE, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_GGA_C_PBE, XC_POLARIZED); + d_excDensityObjPtr = new excDensityGGAClass(d_funcXPtr, d_funcCPtr); + + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); } - } + else if (XCType == "MLXC-NNLDA") + { + exceptParamX = xc_func_init(d_funcXPtr, XC_LDA_X, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_LDA_C_PW, XC_POLARIZED); + d_excDensityObjPtr = + new excDensityLDAClass(d_funcXPtr, d_funcCPtr, modelXCInputFile); + + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); + } + else if (XCType == "MLXC-NNGGA") + { + exceptParamX = xc_func_init(d_funcXPtr, XC_GGA_X_PBE, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_GGA_C_PBE, XC_POLARIZED); + d_excDensityObjPtr = + new excDensityGGAClass(d_funcXPtr, d_funcCPtr, modelXCInputFile); + + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); + } + else if (XCType == "MLXC-NNLLMGGA") + { + exceptParamX = xc_func_init(d_funcXPtr, XC_GGA_X_PBE, XC_POLARIZED); + exceptParamC = xc_func_init(d_funcCPtr, XC_GGA_C_PBE, XC_POLARIZED); + d_excDensityObjPtr = + new excDensityLLMGGAClass(d_funcXPtr, d_funcCPtr, modelXCInputFile); + + d_excWavefunctionObjPtr = new excWavefunctionNoneClass(isSpinPolarized); + } + else + { + std::cout << "Error in xc code \n"; + if (exceptParamX != 0 || exceptParamC != 0) + { + std::cout << "-------------------------------------" << std::endl; + std::cout << "Exchange or Correlation Functional not found" + << std::endl; + std::cout << "-------------------------------------" << std::endl; + exit(-1); + } + } + } // namespace dftfe densityFamilyType excManager::getDensityBasedFamilyType() const diff --git a/src/force/configurationalForceCompute/configurationalForceEEshelbyFPSPFnlLinFE.cc b/src/force/configurationalForceCompute/configurationalForceEEshelbyFPSPFnlLinFE.cc index f8dfeb106..382c896ba 100644 --- a/src/force/configurationalForceCompute/configurationalForceEEshelbyFPSPFnlLinFE.cc +++ b/src/force/configurationalForceCompute/configurationalForceEEshelbyFPSPFnlLinFE.cc @@ -509,983 +509,389 @@ namespace dftfe numMacroCells, kptGroupLowHighPlusOneIndices); - std::vector rhoTotalCellQuadValues(numQuadPoints, 0); - std::vector rhoSpinPolarizedCellQuadValues(numQuadPoints * 2, - 0); - std::vector gradRhoTotalCellQuadValues(numQuadPoints * 3, 0); - - std::vector gradRhoSpinPolarizedCellQuadValues(numQuadPoints * - 6, - 0); - if (d_dftParams.spinPolarized == 1) + dftPtr->d_basisOperationsPtrHost->reinit(0, + 0, + dftPtr->d_densityQuadratureId, + false); + std::vector< + dftfe::utils::MemoryStorage> + gradDensityOutValuesSpinPolarized; + + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) { - dealii::AlignedVector> - rhoXCQuadsVect(numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - phiTotRhoOutQuads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoSpin0QuadsVect(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoSpin1QuadsVect(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - hessianRhoSpin0Quads(numQuadPoints, zeroTensor4); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - hessianRhoSpin1Quads(numQuadPoints, zeroTensor4); - dealii::AlignedVector> excQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - vxcRhoOutSpin0Quads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - vxcRhoOutSpin1Quads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - derExchCorrEnergyWithGradRhoOutSpin0Quads(numQuadPoints, - zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - derExchCorrEnergyWithGradRhoOutSpin1Quads(numQuadPoints, - zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoCoreQuads(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - hessianRhoCoreQuads(numQuadPoints, zeroTensor4); - std::map> - forceContributionNonlinearCoreCorrectionGammaAtoms; + gradDensityOutValuesSpinPolarized = gradRhoOutValues; - for (unsigned int cell = 0; cell < matrixFreeData.n_cell_batches(); - ++cell) - { - if (cell < - kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId + 1] && - cell >= kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId]) - { - forceEval.reinit(cell); + if (d_dftParams.spinPolarized == 0) + gradDensityOutValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + gradRhoOutValues[0].size(), 0.0)); + } - std::fill(rhoXCQuadsVect.begin(), - rhoXCQuadsVect.end(), - dealii::make_vectorized_array(0.0)); - std::fill(phiTotRhoOutQuads.begin(), - phiTotRhoOutQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(gradRhoSpin0QuadsVect.begin(), - gradRhoSpin0QuadsVect.end(), - zeroTensor3); - std::fill(gradRhoSpin1QuadsVect.begin(), - gradRhoSpin1QuadsVect.end(), - zeroTensor3); - std::fill(hessianRhoSpin0Quads.begin(), - hessianRhoSpin0Quads.end(), - zeroTensor4); - std::fill(hessianRhoSpin1Quads.begin(), - hessianRhoSpin1Quads.end(), - zeroTensor4); - std::fill(excQuads.begin(), - excQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(vxcRhoOutSpin0Quads.begin(), - vxcRhoOutSpin0Quads.end(), + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + gradRhoSpin0QuadsVect(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + gradRhoSpin1QuadsVect(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<2, 3, dealii::VectorizedArray>> + hessianRhoSpin0Quads(numQuadPoints, zeroTensor4); + dealii::AlignedVector< + dealii::Tensor<2, 3, dealii::VectorizedArray>> + hessianRhoSpin1Quads(numQuadPoints, zeroTensor4); + dealii::AlignedVector> excQuads( + numQuadPoints, dealii::make_vectorized_array(0.0)); + dealii::AlignedVector> + vxcRhoOutSpin0Quads(numQuadPoints, dealii::make_vectorized_array(0.0)); - std::fill(vxcRhoOutSpin1Quads.begin(), - vxcRhoOutSpin1Quads.end(), + dealii::AlignedVector> + vxcRhoOutSpin1Quads(numQuadPoints, dealii::make_vectorized_array(0.0)); - std::fill(derExchCorrEnergyWithGradRhoOutSpin0Quads.begin(), - derExchCorrEnergyWithGradRhoOutSpin0Quads.end(), - zeroTensor3); - std::fill(derExchCorrEnergyWithGradRhoOutSpin1Quads.begin(), - derExchCorrEnergyWithGradRhoOutSpin1Quads.end(), - zeroTensor3); - std::fill(gradRhoCoreQuads.begin(), - gradRhoCoreQuads.end(), - zeroTensor3); - std::fill(hessianRhoCoreQuads.begin(), - hessianRhoCoreQuads.end(), - zeroTensor4); - - const unsigned int numSubCells = - matrixFreeData.n_active_entries_per_cell_batch(cell); - // For LDA - std::vector exchValRhoOut(numQuadPoints); - std::vector corrValRhoOut(numQuadPoints); - std::vector exchPotValRhoOut(2 * numQuadPoints); - std::vector corrPotValRhoOut(2 * numQuadPoints); - std::vector rhoOutQuadsXC(2 * numQuadPoints); - - // - // For GGA - std::vector sigmaValRhoOut(3 * numQuadPoints); - std::vector derExchEnergyWithDensityValRhoOut( - 2 * numQuadPoints), - derCorrEnergyWithDensityValRhoOut(2 * numQuadPoints), - derExchEnergyWithSigmaRhoOut(3 * numQuadPoints), - derCorrEnergyWithSigmaRhoOut(3 * numQuadPoints); - std::vector> - gradRhoOutQuadsXCSpin0(numQuadPoints); - std::vector> - gradRhoOutQuadsXCSpin1(numQuadPoints); - - // - for (unsigned int iSubCell = 0; iSubCell < numSubCells; - ++iSubCell) - { - subCellPtr = - matrixFreeData.get_cell_iterator(cell, iSubCell); - dealii::CellId subCellId = subCellPtr->id(); - - // const std::vector &temp = - // rhoOutValues.find(subCellId)->second; - // const std::vector &temp1 = - // (*dftPtr->rhoOutValuesSpinPolarized) - // .find(subCellId) - // ->second; + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + derExchCorrEnergyWithGradRhoOutSpin0Quads(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + derExchCorrEnergyWithGradRhoOutSpin1Quads(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + gradRhoCoreQuads(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<2, 3, dealii::VectorizedArray>> + hessianRhoCoreQuads(numQuadPoints, zeroTensor4); + std::map> + forceContributionNonlinearCoreCorrectionGammaAtoms; + + std::unordered_map> + xDensityOutDataOut; + std::unordered_map> + cDensityOutDataOut; + + std::vector &xEnergyDensityOut = + xDensityOutDataOut[xcOutputDataAttributes::e]; + std::vector &cEnergyDensityOut = + cDensityOutDataOut[xcOutputDataAttributes::e]; + + std::vector &pdexDensityOutSpinUp = + xDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdexDensityOutSpinDown = + xDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + std::vector &pdecDensityOutSpinUp = + cDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdecDensityOutSpinDown = + cDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + xDensityOutDataOut[xcOutputDataAttributes::pdeSigma] = + std::vector(); + cDensityOutDataOut[xcOutputDataAttributes::pdeSigma] = + std::vector(); + } - const unsigned int subCellIndex = - dftPtr->d_basisOperationsPtrHost->cellIndex( - subCellId); - const auto &rhoTotalOutValues = rhoOutValues[0]; - const auto &rhoMagOutValues = rhoOutValues[1]; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoTotalCellQuadValues[q] = - rhoTotalOutValues[subCellIndex * numQuadPoints + - q]; - rhoSpinPolarizedCellQuadValues[2 * q + 0] = - (rhoTotalOutValues[subCellIndex * numQuadPoints + - q] + - rhoMagOutValues[subCellIndex * numQuadPoints + - q]) / - 2.0; - rhoSpinPolarizedCellQuadValues[2 * q + 1] = - (rhoTotalOutValues[subCellIndex * numQuadPoints + - q] - - rhoMagOutValues[subCellIndex * numQuadPoints + - q]) / - 2.0; - } - rhoOutQuadsXC = rhoSpinPolarizedCellQuadValues; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoXCQuadsVect[q][iSubCell] = - rhoTotalCellQuadValues[q]; - } + auto quadPointsAll = dftPtr->d_basisOperationsPtrHost->quadPoints(); - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp2 = - rhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoOutQuadsXC[2 * q + 0] += temp2[q] / 2.0; - rhoOutQuadsXC[2 * q + 1] += temp2[q] / 2.0; - rhoXCQuadsVect[q][iSubCell] += temp2[q]; - } - } + auto quadWeightsAll = dftPtr->d_basisOperationsPtrHost->JxW(); - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - // const std::vector &temp3 = - // (*dftPtr->gradRhoOutValuesSpinPolarized) - // .find(subCellId) - // ->second; - - const auto &gradRhoTotalOutValues = - gradRhoOutValues[0]; - const auto &gradRhoMagOutValues = - gradRhoOutValues[1]; - - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoSpinPolarizedCellQuadValues[6 * q + - idim] = - (gradRhoTotalOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim] + - gradRhoMagOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim]) / - 2.0; - gradRhoSpinPolarizedCellQuadValues[6 * q + 3 + - idim] = - (gradRhoTotalOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim] - - gradRhoMagOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim]) / - 2.0; - } - - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoOutQuadsXCSpin0[q][idim] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - idim]; - gradRhoOutQuadsXCSpin1[q][idim] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - 3 + - idim]; - gradRhoSpin0QuadsVect[q][idim][iSubCell] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - idim]; - gradRhoSpin1QuadsVect[q][idim][iSubCell] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - 3 + - idim]; - } - - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp4 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoOutQuadsXCSpin0[q][idim] += - temp4[3 * q + idim] / 2.0; - gradRhoOutQuadsXCSpin1[q][idim] += - temp4[3 * q + idim] / 2.0; - } - } - } + for (unsigned int cell = 0; cell < matrixFreeData.n_cell_batches(); + ++cell) + { + if (cell < kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId + 1] && + cell >= kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId]) + { + forceEval.reinit(cell); - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - sigmaValRhoOut[3 * q + 0] = - scalar_product(gradRhoOutQuadsXCSpin0[q], - gradRhoOutQuadsXCSpin0[q]); - sigmaValRhoOut[3 * q + 1] = - scalar_product(gradRhoOutQuadsXCSpin0[q], - gradRhoOutQuadsXCSpin1[q]); - sigmaValRhoOut[3 * q + 2] = - scalar_product(gradRhoOutQuadsXCSpin1[q], - gradRhoOutQuadsXCSpin1[q]); - } + std::fill(gradRhoSpin0QuadsVect.begin(), + gradRhoSpin0QuadsVect.end(), + zeroTensor3); + std::fill(gradRhoSpin1QuadsVect.begin(), + gradRhoSpin1QuadsVect.end(), + zeroTensor3); + std::fill(hessianRhoSpin0Quads.begin(), + hessianRhoSpin0Quads.end(), + zeroTensor4); + std::fill(hessianRhoSpin1Quads.begin(), + hessianRhoSpin1Quads.end(), + zeroTensor4); + std::fill(excQuads.begin(), + excQuads.end(), + dealii::make_vectorized_array(0.0)); + std::fill(vxcRhoOutSpin0Quads.begin(), + vxcRhoOutSpin0Quads.end(), + dealii::make_vectorized_array(0.0)); + std::fill(vxcRhoOutSpin1Quads.begin(), + vxcRhoOutSpin1Quads.end(), + dealii::make_vectorized_array(0.0)); + std::fill(derExchCorrEnergyWithGradRhoOutSpin0Quads.begin(), + derExchCorrEnergyWithGradRhoOutSpin0Quads.end(), + zeroTensor3); + std::fill(derExchCorrEnergyWithGradRhoOutSpin1Quads.begin(), + derExchCorrEnergyWithGradRhoOutSpin1Quads.end(), + zeroTensor3); + std::fill(gradRhoCoreQuads.begin(), + gradRhoCoreQuads.end(), + zeroTensor3); + std::fill(hessianRhoCoreQuads.begin(), + hessianRhoCoreQuads.end(), + zeroTensor4); - std::map *> - rhoOutData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; - rhoOutData[rhoDataAttributes::sigmaGradValue] = - &sigmaValRhoOut; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithDensityValRhoOut; - outputDerExchangeEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaRhoOut; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithDensityValRhoOut; - outputDerCorrEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaRhoOut; - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutSpin0Quads[q][iSubCell] = - derExchEnergyWithDensityValRhoOut[2 * q] + - derCorrEnergyWithDensityValRhoOut[2 * q]; - vxcRhoOutSpin1Quads[q][iSubCell] = - derExchEnergyWithDensityValRhoOut[2 * q + 1] + - derCorrEnergyWithDensityValRhoOut[2 * q + 1]; - for (unsigned int idim = 0; idim < 3; idim++) - { - derExchCorrEnergyWithGradRhoOutSpin0Quads - [q][idim][iSubCell] = - 2.0 * - (derExchEnergyWithSigmaRhoOut[3 * q + - 0] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 0]) * - gradRhoOutQuadsXCSpin0[q][idim]; - derExchCorrEnergyWithGradRhoOutSpin0Quads - [q][idim][iSubCell] += - (derExchEnergyWithSigmaRhoOut[3 * q + 1] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 1]) * - gradRhoOutQuadsXCSpin1[q][idim]; - - derExchCorrEnergyWithGradRhoOutSpin1Quads - [q][idim][iSubCell] += - 2.0 * - (derExchEnergyWithSigmaRhoOut[3 * q + 2] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 2]) * - gradRhoOutQuadsXCSpin1[q][idim]; - derExchCorrEnergyWithGradRhoOutSpin1Quads - [q][idim][iSubCell] += - (derExchEnergyWithSigmaRhoOut[3 * q + 1] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 1]) * - gradRhoOutQuadsXCSpin0[q][idim]; - } - } - } - else if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::LDA) - { - std::map *> - rhoOutData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; - - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &exchPotValRhoOut; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &corrPotValRhoOut; - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutSpin0Quads[q][iSubCell] = - exchPotValRhoOut[2 * q] + - corrPotValRhoOut[2 * q]; - vxcRhoOutSpin1Quads[q][iSubCell] = - exchPotValRhoOut[2 * q + 1] + - corrPotValRhoOut[2 * q + 1]; - } - } + const unsigned int numSubCells = + matrixFreeData.n_active_entries_per_cell_batch(cell); - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - if (d_dftParams.nonLinearCoreCorrection == true) - { - const std::vector &temp1 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - gradRhoCoreQuads[q][idim][iSubCell] = - temp1[3 * q + idim] / 2.0; - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - const std::vector &temp2 = - hessianRhoCoreValues.find(subCellId) - ->second; - for (unsigned int q = 0; q < numQuadPoints; - ++q) - for (unsigned int idim = 0; idim < 3; - ++idim) - for (unsigned int jdim = 0; jdim < 3; - ++jdim) - hessianRhoCoreQuads - [q][idim][jdim][iSubCell] = - temp2[9 * q + 3 * idim + jdim] / - 2.0; - } - } - } + // + for (unsigned int iSubCell = 0; iSubCell < numSubCells; + ++iSubCell) + { + subCellPtr = + matrixFreeData.get_cell_iterator(cell, iSubCell); + dealii::CellId subCellId = subCellPtr->id(); - } // subcell loop - if (d_dftParams.nonLinearCoreCorrection) - { - FNonlinearCoreCorrectionGammaAtomsElementalContributionSpinPolarized( - forceContributionNonlinearCoreCorrectionGammaAtoms, - forceEval, - matrixFreeData, - cell, - vxcRhoOutSpin0Quads, - vxcRhoOutSpin1Quads, - derExchCorrEnergyWithGradRhoOutSpin0Quads, - derExchCorrEnergyWithGradRhoOutSpin1Quads, - gradRhoCoreAtoms, - hessianRhoCoreAtoms, - dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA); - } + const unsigned int subCellIndex = + dftPtr->d_basisOperationsPtrHost->cellIndex(subCellId); - for (unsigned int q = 0; q < numQuadPoints; ++q) + std::vector quadPointsInCell(numQuadPoints * 3); + std::vector quadWeightsInCell(numQuadPoints); + for (unsigned int iQuad = 0; iQuad < numQuadPoints; ++iQuad) { - const dealii::VectorizedArray phiTot_q = - phiTotRhoOutQuads[q]; - - dealii::Tensor<2, 3, dealii::VectorizedArray> - E = eshelbyTensorSP::getELocXcEshelbyTensor( - rhoXCQuadsVect[q], - gradRhoSpin0QuadsVect[q], - gradRhoSpin1QuadsVect[q], - excQuads[q], - derExchCorrEnergyWithGradRhoOutSpin0Quads[q], - derExchCorrEnergyWithGradRhoOutSpin1Quads[q]); - - dealii::Tensor<1, 3, dealii::VectorizedArray> - F = zeroTensor3; - - if (d_dftParams.nonLinearCoreCorrection) - F += eshelbyTensorSP::getFNonlinearCoreCorrection( - vxcRhoOutSpin0Quads[q], - vxcRhoOutSpin1Quads[q], - derExchCorrEnergyWithGradRhoOutSpin0Quads[q], - derExchCorrEnergyWithGradRhoOutSpin1Quads[q], - gradRhoCoreQuads[q], - hessianRhoCoreQuads[q], - dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA); - - forceEval.submit_value(F, q); - forceEval.submit_gradient(E, q); - } // quad point loop - - forceEval.integrate(true, true); - forceEval.distribute_local_to_global( - d_configForceVectorLinFE); // also takes care of - // constraints - } // kpt paral - } // cell loop - - if (d_dftParams.nonLinearCoreCorrection) - { - if (d_dftParams.floatingNuclearCharges) - accumulateForceContributionGammaAtomsFloating( - forceContributionNonlinearCoreCorrectionGammaAtoms, - d_forceAtomsFloating); - else - distributeForceContributionFPSPLocalGammaAtoms( - forceContributionNonlinearCoreCorrectionGammaAtoms, - d_atomsForceDofs, - d_constraintsNoneForce, - d_configForceVectorLinFE); - } - } - else - { - dealii::AlignedVector> rhoQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> rhoXCQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - phiTotRhoOutQuads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - derVxcWithRhoTimesRhoDiffQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsInCell[iQuad * 3 + idim] = + quadPointsAll[subCellIndex * numQuadPoints * 3 + + iQuad * 3 + idim]; + quadWeightsInCell[iQuad] = std::real( + quadWeightsAll[subCellIndex * numQuadPoints + iQuad]); + } - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoQuads(numQuadPoints, zeroTensor3); - // dealii::AlignedVector - // > > gradRhoAtomsQuads(numQuadPoints,zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - hessianRhoQuads(numQuadPoints, zeroTensor4); - // dealii::AlignedVector - // > > hessianRhoAtomsQuads(numQuadPoints,zeroTensor4); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoCoreQuads(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - hessianRhoCoreQuads(numQuadPoints, zeroTensor4); - dealii::AlignedVector> excQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - vxcRhoOutQuads(numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - derExchCorrEnergyWithGradRhoOutQuads(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - derVxcWithGradRhoQuads(numQuadPoints, zeroTensor3); - dealii::AlignedVector> - derVxcWithRhoQuads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - der2ExcWithGradRhoQuads(numQuadPoints, zeroTensor4); - std::map> - forceContributionGradRhoNonlinearCoreCorrectionGammaAtoms; - std::map> - forceContributionHessianRhoNonlinearCoreCorrectionGammaAtoms; - for (unsigned int cell = 0; cell < matrixFreeData.n_cell_batches(); - ++cell) - { - if (cell < - kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId + 1] && - cell >= kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId]) - { - forceEval.reinit(cell); + dftPtr->d_excManagerPtr->getExcDensityObj() + ->computeExcVxcFxc(*(dftPtr->d_auxDensityMatrixXCOutPtr), + quadPointsInCell, + quadWeightsInCell, + xDensityOutDataOut, + cDensityOutDataOut); - std::fill(rhoQuads.begin(), - rhoQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(rhoXCQuads.begin(), - rhoXCQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(phiTotRhoOutQuads.begin(), - phiTotRhoOutQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(derVxcWithRhoTimesRhoDiffQuads.begin(), - derVxcWithRhoTimesRhoDiffQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(gradRhoQuads.begin(), - gradRhoQuads.end(), - zeroTensor3); - // std::fill(gradRhoAtomsQuads.begin(),gradRhoAtomsQuads.end(),zeroTensor3); - std::fill(hessianRhoQuads.begin(), - hessianRhoQuads.end(), - zeroTensor4); - // std::fill(hessianRhoAtomsQuads.begin(),hessianRhoAtomsQuads.end(),zeroTensor4); - std::fill(gradRhoCoreQuads.begin(), - gradRhoCoreQuads.end(), - zeroTensor3); - std::fill(hessianRhoCoreQuads.begin(), - hessianRhoCoreQuads.end(), - zeroTensor4); - std::fill(excQuads.begin(), - excQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(vxcRhoOutQuads.begin(), - vxcRhoOutQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(derExchCorrEnergyWithGradRhoOutQuads.begin(), - derExchCorrEnergyWithGradRhoOutQuads.end(), - zeroTensor3); - std::fill(derVxcWithGradRhoQuads.begin(), - derVxcWithGradRhoQuads.end(), - zeroTensor3); - std::fill(derVxcWithRhoQuads.begin(), - derVxcWithRhoQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(der2ExcWithGradRhoQuads.begin(), - der2ExcWithGradRhoQuads.end(), - zeroTensor4); - - const unsigned int numSubCells = - matrixFreeData.n_active_entries_per_cell_batch(cell); - // For LDA - std::vector exchValRhoOut(numQuadPoints); - std::vector corrValRhoOut(numQuadPoints); - std::vector exchPotValRhoOut(numQuadPoints); - std::vector corrPotValRhoOut(numQuadPoints); - std::vector rhoOutQuadsXC(numQuadPoints); - - // - // For GGA - std::vector sigmaValRhoOut(numQuadPoints); - std::vector derExchEnergyWithDensityValRhoOut( - numQuadPoints), - derCorrEnergyWithDensityValRhoOut(numQuadPoints), - derExchEnergyWithSigmaRhoOut(numQuadPoints), - derCorrEnergyWithSigmaRhoOut(numQuadPoints); - std::vector> gradRhoOutQuadsXC( - numQuadPoints); - std::vector derVxWithSigmaRhoOut(numQuadPoints); - std::vector derVcWithSigmaRhoOut(numQuadPoints); - std::vector der2ExWithSigmaRhoOut(numQuadPoints); - std::vector der2EcWithSigmaRhoOut(numQuadPoints); - std::vector derVxWithRhoOut(numQuadPoints); - std::vector derVcWithRhoOut(numQuadPoints); - - // - for (unsigned int iSubCell = 0; iSubCell < numSubCells; - ++iSubCell) + std::vector pdexDensityOutSigma; + std::vector pdecDensityOutSigma; + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) { - subCellPtr = - matrixFreeData.get_cell_iterator(cell, iSubCell); - dealii::CellId subCellId = subCellPtr->id(); - - // const std::vector &temp1 = - // rhoOutValues.find(subCellId)->second; - - const unsigned int subCellIndex = - dftPtr->d_basisOperationsPtrHost->cellIndex( - subCellId); - const auto &rhoTotalOutValues = rhoOutValues[0]; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoTotalCellQuadValues[q] = - rhoTotalOutValues[subCellIndex * numQuadPoints + - q]; - } - - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoOutQuadsXC[q] = rhoTotalCellQuadValues[q]; - rhoQuads[q][iSubCell] = rhoTotalCellQuadValues[q]; - rhoXCQuads[q][iSubCell] = rhoTotalCellQuadValues[q]; - } - - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp2 = - rhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoOutQuadsXC[q] += temp2[q]; - rhoXCQuads[q][iSubCell] += temp2[q]; - } - } - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - // const std::vector &temp3 = - // gradRhoOutValues.find(subCellId)->second; - const auto &gradRhoTotalOutValuesTemp = - gradRhoOutValues[0]; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - gradRhoTotalCellQuadValues[3 * q + idim] = - gradRhoTotalOutValuesTemp[subCellIndex * - numQuadPoints * - 3 + - q * 3 + idim]; - - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoOutQuadsXC[q][idim] = - gradRhoTotalCellQuadValues[3 * q + idim]; - gradRhoQuads[q][idim][iSubCell] = - gradRhoTotalCellQuadValues[3 * q + idim]; - } - - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp4 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - gradRhoOutQuadsXC[q][0] += temp4[3 * q + 0]; - gradRhoOutQuadsXC[q][1] += temp4[3 * q + 1]; - gradRhoOutQuadsXC[q][2] += temp4[3 * q + 2]; - } - } - } - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - for (unsigned int q = 0; q < numQuadPoints; ++q) - sigmaValRhoOut[q] = - gradRhoOutQuadsXC[q].norm_square(); - - std::map *> - rhoOutData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; - rhoOutData[rhoDataAttributes::sigmaGradValue] = - &sigmaValRhoOut; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithDensityValRhoOut; - outputDerExchangeEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaRhoOut; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithDensityValRhoOut; - outputDerCorrEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaRhoOut; - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - - - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutQuads[q][iSubCell] = - derExchEnergyWithDensityValRhoOut[q] + - derCorrEnergyWithDensityValRhoOut[q]; - - for (unsigned int idim = 0; idim < 3; idim++) - { - derExchCorrEnergyWithGradRhoOutQuads - [q][idim][iSubCell] = - 2.0 * - (derExchEnergyWithSigmaRhoOut[q] + - derCorrEnergyWithSigmaRhoOut[q]) * - gradRhoOutQuadsXC[q][idim]; - } - } - } - else if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::LDA) - { - std::map *> - rhoOutData; + pdexDensityOutSigma = + xDensityOutDataOut[xcOutputDataAttributes::pdeSigma]; + pdecDensityOutSigma = + cDensityOutDataOut[xcOutputDataAttributes::pdeSigma]; + } - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; + std::unordered_map> + densityXCOutData; + std::vector gradDensityXCOutSpinUp; + std::vector gradDensityXCOutSpinDown; - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &exchPotValRhoOut; + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + densityXCOutData + [DensityDescriptorDataAttributes::gradValuesSpinUp] = + std::vector(); + densityXCOutData[DensityDescriptorDataAttributes:: + gradValuesSpinDown] = + std::vector(); + } - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &corrPotValRhoOut; + dftPtr->d_auxDensityMatrixXCOutPtr->applyLocalOperations( + quadPointsInCell, densityXCOutData); - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + gradDensityXCOutSpinUp = densityXCOutData + [DensityDescriptorDataAttributes::gradValuesSpinUp]; + gradDensityXCOutSpinDown = densityXCOutData + [DensityDescriptorDataAttributes::gradValuesSpinDown]; + } - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + // const std::vector &temp3 = + // (*dftPtr->gradRhoOutValuesSpinPolarized) + // .find(subCellId) + // ->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutQuads[q][iSubCell] = - exchPotValRhoOut[q] + corrPotValRhoOut[q]; - } - } + const auto &gradRhoTotalOutValues = + gradDensityOutValuesSpinPolarized[0]; + const auto &gradRhoMagOutValues = + gradDensityOutValuesSpinPolarized[1]; for (unsigned int q = 0; q < numQuadPoints; ++q) - { - if (d_dftParams.nonLinearCoreCorrection == true) - { - const std::vector &temp1 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - gradRhoCoreQuads[q][idim][iSubCell] = - temp1[3 * q + idim]; - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - const std::vector &temp2 = - hessianRhoCoreValues.find(subCellId) - ->second; - for (unsigned int q = 0; q < numQuadPoints; - ++q) - for (unsigned int idim = 0; idim < 3; - ++idim) - for (unsigned int jdim = 0; jdim < 3; - ++jdim) - hessianRhoCoreQuads - [q][idim][jdim][iSubCell] = - temp2[9 * q + 3 * idim + jdim]; - } - } - } - } // subcell loop - - if (d_dftParams.nonLinearCoreCorrection) - { - FNonlinearCoreCorrectionGammaAtomsElementalContribution( - forceContributionGradRhoNonlinearCoreCorrectionGammaAtoms, - forceEval, - matrixFreeData, - cell, - vxcRhoOutQuads, - gradRhoCoreAtoms); - - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - FNonlinearCoreCorrectionGammaAtomsElementalContribution( - forceContributionHessianRhoNonlinearCoreCorrectionGammaAtoms, - forceEval, - matrixFreeData, - cell, - derExchCorrEnergyWithGradRhoOutQuads, - hessianRhoCoreAtoms); + for (unsigned int idim = 0; idim < 3; idim++) + { + gradRhoSpin0QuadsVect[q][idim][iSubCell] = + (gradRhoTotalOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim] + + gradRhoMagOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim]) / + 2.0; + gradRhoSpin1QuadsVect[q][idim][iSubCell] = + (gradRhoTotalOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim] - + gradRhoMagOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim]) / + 2.0; + } } for (unsigned int q = 0; q < numQuadPoints; ++q) { - const dealii::VectorizedArray phiTot_q = - phiTotRhoOutQuads[q]; - - dealii::Tensor<2, 3, dealii::VectorizedArray> - E = eshelbyTensor::getELocXcEshelbyTensor( - rhoXCQuads[q], - gradRhoQuads[q], - excQuads[q], - derExchCorrEnergyWithGradRhoOutQuads[q]); - - - dealii::Tensor<1, 3, dealii::VectorizedArray> - F = zeroTensor3; - + excQuads[q][iSubCell] = + xEnergyDensityOut[q] + cEnergyDensityOut[q]; + vxcRhoOutSpin0Quads[q][iSubCell] = + pdexDensityOutSpinUp[q] + pdecDensityOutSpinUp[q]; + vxcRhoOutSpin1Quads[q][iSubCell] = + pdexDensityOutSpinDown[q] + pdecDensityOutSpinDown[q]; + } - if (d_dftParams.nonLinearCoreCorrection) + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + for (unsigned int q = 0; q < numQuadPoints; ++q) { - F += eshelbyTensor::getFNonlinearCoreCorrection( - vxcRhoOutQuads[q], gradRhoCoreQuads[q]); - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - F += eshelbyTensor::getFNonlinearCoreCorrection( - derExchCorrEnergyWithGradRhoOutQuads[q], - hessianRhoCoreQuads[q]); + for (unsigned int idim = 0; idim < 3; idim++) + { + derExchCorrEnergyWithGradRhoOutSpin0Quads + [q][idim][iSubCell] = + 2.0 * + (pdexDensityOutSigma[3 * q + 0] + + pdecDensityOutSigma[3 * q + 0]) * + gradDensityXCOutSpinUp[3 * q + idim]; + derExchCorrEnergyWithGradRhoOutSpin0Quads + [q][idim][iSubCell] += + (pdexDensityOutSigma[3 * q + 1] + + pdecDensityOutSigma[3 * q + 1]) * + gradDensityXCOutSpinDown[3 * q + idim]; + + derExchCorrEnergyWithGradRhoOutSpin1Quads + [q][idim][iSubCell] += + 2.0 * + (pdexDensityOutSigma[3 * q + 2] + + pdecDensityOutSigma[3 * q + 2]) * + gradDensityXCOutSpinDown[3 * q + idim]; + derExchCorrEnergyWithGradRhoOutSpin1Quads + [q][idim][iSubCell] += + (pdexDensityOutSigma[3 * q + 1] + + pdecDensityOutSigma[3 * q + 1]) * + gradDensityXCOutSpinUp[3 * q + idim]; + } } + } - forceEval.submit_value(F, q); - forceEval.submit_gradient(E, q); - } // quad point loop - - - forceEval.integrate(true, true); - forceEval.distribute_local_to_global( - d_configForceVectorLinFE); // also takes care of - // constraints - } // kpt paral - } // cell loop + if (d_dftParams.nonLinearCoreCorrection == true) + for (unsigned int q = 0; q < numQuadPoints; ++q) + { + const std::vector &temp1 = + gradRhoCoreValues.find(subCellId)->second; + for (unsigned int q = 0; q < numQuadPoints; ++q) + for (unsigned int idim = 0; idim < 3; idim++) + gradRhoCoreQuads[q][idim][iSubCell] = + temp1[3 * q + idim] / 2.0; - if (d_dftParams.nonLinearCoreCorrection) - { - if (d_dftParams.floatingNuclearCharges) + if (dftPtr->d_excManagerPtr + ->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + const std::vector &temp2 = + hessianRhoCoreValues.find(subCellId)->second; + for (unsigned int q = 0; q < numQuadPoints; ++q) + for (unsigned int idim = 0; idim < 3; ++idim) + for (unsigned int jdim = 0; jdim < 3; ++jdim) + hessianRhoCoreQuads + [q][idim][jdim][iSubCell] = + temp2[9 * q + 3 * idim + jdim] / 2.0; + } + } + + } // subcell loop + + if (d_dftParams.nonLinearCoreCorrection) { - accumulateForceContributionGammaAtomsFloating( - forceContributionGradRhoNonlinearCoreCorrectionGammaAtoms, - d_forceAtomsFloating); - - if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == - densityFamilyType::GGA) - accumulateForceContributionGammaAtomsFloating( - forceContributionHessianRhoNonlinearCoreCorrectionGammaAtoms, - d_forceAtomsFloating); + FNonlinearCoreCorrectionGammaAtomsElementalContributionSpinPolarized( + forceContributionNonlinearCoreCorrectionGammaAtoms, + forceEval, + matrixFreeData, + cell, + vxcRhoOutSpin0Quads, + vxcRhoOutSpin1Quads, + derExchCorrEnergyWithGradRhoOutSpin0Quads, + derExchCorrEnergyWithGradRhoOutSpin1Quads, + gradRhoCoreAtoms, + hessianRhoCoreAtoms, + dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA); } - else + + for (unsigned int q = 0; q < numQuadPoints; ++q) { - distributeForceContributionFPSPLocalGammaAtoms( - forceContributionGradRhoNonlinearCoreCorrectionGammaAtoms, - d_atomsForceDofs, - d_constraintsNoneForce, - d_configForceVectorLinFE); + dealii::Tensor<2, 3, dealii::VectorizedArray> E = + eshelbyTensorSP::getELocXcEshelbyTensor( + gradRhoSpin0QuadsVect[q], + gradRhoSpin1QuadsVect[q], + excQuads[q], + derExchCorrEnergyWithGradRhoOutSpin0Quads[q], + derExchCorrEnergyWithGradRhoOutSpin1Quads[q]); - if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == - densityFamilyType::GGA) - distributeForceContributionFPSPLocalGammaAtoms( - forceContributionHessianRhoNonlinearCoreCorrectionGammaAtoms, - d_atomsForceDofs, - d_constraintsNoneForce, - d_configForceVectorLinFE); - } - } + dealii::Tensor<1, 3, dealii::VectorizedArray> F = + zeroTensor3; + + if (d_dftParams.nonLinearCoreCorrection) + F += eshelbyTensorSP::getFNonlinearCoreCorrection( + vxcRhoOutSpin0Quads[q], + vxcRhoOutSpin1Quads[q], + derExchCorrEnergyWithGradRhoOutSpin0Quads[q], + derExchCorrEnergyWithGradRhoOutSpin1Quads[q], + gradRhoCoreQuads[q], + hessianRhoCoreQuads[q], + dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA); + + forceEval.submit_value(F, q); + forceEval.submit_gradient(E, q); + } // quad point loop + + forceEval.integrate(true, true); + forceEval.distribute_local_to_global( + d_configForceVectorLinFE); // also takes care of + // constraints + } // kpt paral + } // cell loop + + if (d_dftParams.nonLinearCoreCorrection) + { + if (d_dftParams.floatingNuclearCharges) + accumulateForceContributionGammaAtomsFloating( + forceContributionNonlinearCoreCorrectionGammaAtoms, + d_forceAtomsFloating); + else + distributeForceContributionFPSPLocalGammaAtoms( + forceContributionNonlinearCoreCorrectionGammaAtoms, + d_atomsForceDofs, + d_constraintsNoneForce, + d_configForceVectorLinFE); } + ////Add electrostatic configurational force contribution//////////////// computeConfigurationalForceEEshelbyEElectroPhiTot( matrixFreeDataElectro, diff --git a/src/force/configurationalStressCompute/computeStressEEshelbyEPSPEnlEk.cc b/src/force/configurationalStressCompute/computeStressEEshelbyEPSPEnlEk.cc index fc191c0ca..9d342091c 100644 --- a/src/force/configurationalStressCompute/computeStressEEshelbyEPSPEnlEk.cc +++ b/src/force/configurationalStressCompute/computeStressEEshelbyEPSPEnlEk.cc @@ -450,825 +450,348 @@ namespace dftfe numMacroCells, kptGroupLowHighPlusOneIndices); - std::vector rhoTotalCellQuadValues(numQuadPoints, 0); - std::vector rhoSpinPolarizedCellQuadValues(numQuadPoints * 2, - 0); - std::vector gradRhoTotalCellQuadValues(numQuadPoints * 3, 0); - std::vector gradRhoSpinPolarizedCellQuadValues(numQuadPoints * - 6, - 0); - - - if (d_dftParams.spinPolarized == 1) + dftPtr->d_basisOperationsPtrHost->reinit(0, + 0, + dftPtr->d_densityQuadratureId); + std::vector< + dftfe::utils::MemoryStorage> + gradDensityOutValuesSpinPolarized; + + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) { - dealii::AlignedVector> - rhoXCQuadsVect(numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoSpin0QuadsVect(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoSpin1QuadsVect(numQuadPoints, zeroTensor3); - dealii::AlignedVector> excQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - vxcRhoOutSpin0Quads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - vxcRhoOutSpin1Quads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - derExchCorrEnergyWithGradRhoOutSpin0Quads(numQuadPoints, - zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - derExchCorrEnergyWithGradRhoOutSpin1Quads(numQuadPoints, - zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoCoreQuads(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - hessianRhoCoreQuads(numQuadPoints, zeroTensor4); + gradDensityOutValuesSpinPolarized = gradRhoOutValues; - for (unsigned int cell = 0; cell < matrixFreeData.n_cell_batches(); - ++cell) - { - if (cell < - kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId + 1] && - cell >= kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId]) - { - forceEval.reinit(cell); + if (d_dftParams.spinPolarized == 0) + gradDensityOutValuesSpinPolarized.push_back( + dftfe::utils::MemoryStorage( + gradRhoOutValues[0].size(), 0.0)); + } - std::fill(rhoXCQuadsVect.begin(), - rhoXCQuadsVect.end(), - dealii::make_vectorized_array(0.0)); - std::fill(gradRhoSpin0QuadsVect.begin(), - gradRhoSpin0QuadsVect.end(), - zeroTensor3); - std::fill(gradRhoSpin1QuadsVect.begin(), - gradRhoSpin1QuadsVect.end(), - zeroTensor3); - std::fill(excQuads.begin(), - excQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(vxcRhoOutSpin0Quads.begin(), - vxcRhoOutSpin0Quads.end(), + + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + gradRhoSpin0QuadsVect(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + gradRhoSpin1QuadsVect(numQuadPoints, zeroTensor3); + dealii::AlignedVector> excQuads( + numQuadPoints, dealii::make_vectorized_array(0.0)); + dealii::AlignedVector> + vxcRhoOutSpin0Quads(numQuadPoints, dealii::make_vectorized_array(0.0)); - std::fill(vxcRhoOutSpin1Quads.begin(), - vxcRhoOutSpin1Quads.end(), + dealii::AlignedVector> + vxcRhoOutSpin1Quads(numQuadPoints, dealii::make_vectorized_array(0.0)); - std::fill(derExchCorrEnergyWithGradRhoOutSpin0Quads.begin(), - derExchCorrEnergyWithGradRhoOutSpin0Quads.end(), - zeroTensor3); - std::fill(derExchCorrEnergyWithGradRhoOutSpin1Quads.begin(), - derExchCorrEnergyWithGradRhoOutSpin1Quads.end(), - zeroTensor3); - std::fill(gradRhoCoreQuads.begin(), - gradRhoCoreQuads.end(), - zeroTensor3); - std::fill(hessianRhoCoreQuads.begin(), - hessianRhoCoreQuads.end(), - zeroTensor4); - - const unsigned int numSubCells = - matrixFreeData.n_active_entries_per_cell_batch(cell); - // For LDA - std::vector exchValRhoOut(numQuadPoints); - std::vector corrValRhoOut(numQuadPoints); - std::vector exchPotValRhoOut(2 * numQuadPoints); - std::vector corrPotValRhoOut(2 * numQuadPoints); - std::vector rhoOutQuadsXC(2 * numQuadPoints); - - // - // For GGA - std::vector sigmaValRhoOut(3 * numQuadPoints); - std::vector derExchEnergyWithDensityValRhoOut( - 2 * numQuadPoints), - derCorrEnergyWithDensityValRhoOut(2 * numQuadPoints), - derExchEnergyWithSigmaRhoOut(3 * numQuadPoints), - derCorrEnergyWithSigmaRhoOut(3 * numQuadPoints); - std::vector> - gradRhoOutQuadsXCSpin0(numQuadPoints); - std::vector> - gradRhoOutQuadsXCSpin1(numQuadPoints); - - // - for (unsigned int iSubCell = 0; iSubCell < numSubCells; - ++iSubCell) - { - subCellPtr = - matrixFreeData.get_cell_iterator(cell, iSubCell); - dealii::CellId subCellId = subCellPtr->id(); - - // const std::vector &temp = - // (rhoOutValues).find(subCellId)->second; - // const std::vector &temp1 = - // (*dftPtr->rhoOutValuesSpinPolarized) - // .find(subCellId) - // ->second; + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + derExchCorrEnergyWithGradRhoOutSpin0Quads(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + derExchCorrEnergyWithGradRhoOutSpin1Quads(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<1, 3, dealii::VectorizedArray>> + gradRhoCoreQuads(numQuadPoints, zeroTensor3); + dealii::AlignedVector< + dealii::Tensor<2, 3, dealii::VectorizedArray>> + hessianRhoCoreQuads(numQuadPoints, zeroTensor4); + + std::unordered_map> + xDensityOutDataOut; + std::unordered_map> + cDensityOutDataOut; + + std::vector &xEnergyDensityOut = + xDensityOutDataOut[xcOutputDataAttributes::e]; + std::vector &cEnergyDensityOut = + cDensityOutDataOut[xcOutputDataAttributes::e]; + + std::vector &pdexDensityOutSpinUp = + xDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdexDensityOutSpinDown = + xDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + std::vector &pdecDensityOutSpinUp = + cDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinUp]; + std::vector &pdecDensityOutSpinDown = + cDensityOutDataOut[xcOutputDataAttributes::pdeDensitySpinDown]; + + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + xDensityOutDataOut[xcOutputDataAttributes::pdeSigma] = + std::vector(); + cDensityOutDataOut[xcOutputDataAttributes::pdeSigma] = + std::vector(); + } - const unsigned int subCellIndex = - dftPtr->d_basisOperationsPtrHost->cellIndex( - subCellId); - const auto &rhoTotalOutValues = rhoOutValues[0]; - const auto &rhoMagOutValues = rhoOutValues[1]; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoTotalCellQuadValues[q] = - rhoTotalOutValues[subCellIndex * numQuadPoints + - q]; - rhoSpinPolarizedCellQuadValues[2 * q + 0] = - (rhoTotalOutValues[subCellIndex * numQuadPoints + - q] + - rhoMagOutValues[subCellIndex * numQuadPoints + - q]) / - 2.0; - rhoSpinPolarizedCellQuadValues[2 * q + 1] = - (rhoTotalOutValues[subCellIndex * numQuadPoints + - q] - - rhoMagOutValues[subCellIndex * numQuadPoints + - q]) / - 2.0; - } - rhoOutQuadsXC = rhoSpinPolarizedCellQuadValues; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoXCQuadsVect[q][iSubCell] = - rhoTotalCellQuadValues[q]; - } + auto quadPointsAll = dftPtr->d_basisOperationsPtrHost->quadPoints(); - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp2 = - rhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoOutQuadsXC[2 * q + 0] += temp2[q] / 2.0; - rhoOutQuadsXC[2 * q + 1] += temp2[q] / 2.0; - rhoXCQuadsVect[q][iSubCell] += temp2[q]; - } - } + auto quadWeightsAll = dftPtr->d_basisOperationsPtrHost->JxW(); - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - // const std::vector &temp3 = - // (*dftPtr->gradRhoOutValuesSpinPolarized) - // .find(subCellId) - // ->second; - const auto &gradRhoTotalOutValues = - gradRhoOutValues[0]; - const auto &gradRhoMagOutValues = - gradRhoOutValues[1]; - - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoSpinPolarizedCellQuadValues[6 * q + - idim] = - (gradRhoTotalOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim] + - gradRhoMagOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim]) / - 2.0; - gradRhoSpinPolarizedCellQuadValues[6 * q + 3 + - idim] = - (gradRhoTotalOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim] - - gradRhoMagOutValues[subCellIndex * - numQuadPoints * 3 + - q * 3 + idim]) / - 2.0; - } - - - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoOutQuadsXCSpin0[q][idim] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - idim]; - gradRhoOutQuadsXCSpin1[q][idim] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - 3 + - idim]; - gradRhoSpin0QuadsVect[q][idim][iSubCell] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - idim]; - gradRhoSpin1QuadsVect[q][idim][iSubCell] = - gradRhoSpinPolarizedCellQuadValues[6 * q + - 3 + - idim]; - } - - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp4 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoOutQuadsXCSpin0[q][idim] += - temp4[3 * q + idim] / 2.0; - gradRhoOutQuadsXCSpin1[q][idim] += - temp4[3 * q + idim] / 2.0; - } - } - } + for (unsigned int cell = 0; cell < matrixFreeData.n_cell_batches(); + ++cell) + { + if (cell < kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId + 1] && + cell >= kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId]) + { + forceEval.reinit(cell); + + std::fill(gradRhoSpin0QuadsVect.begin(), + gradRhoSpin0QuadsVect.end(), + zeroTensor3); + std::fill(gradRhoSpin1QuadsVect.begin(), + gradRhoSpin1QuadsVect.end(), + zeroTensor3); + std::fill(excQuads.begin(), + excQuads.end(), + dealii::make_vectorized_array(0.0)); + std::fill(vxcRhoOutSpin0Quads.begin(), + vxcRhoOutSpin0Quads.end(), + dealii::make_vectorized_array(0.0)); + std::fill(vxcRhoOutSpin1Quads.begin(), + vxcRhoOutSpin1Quads.end(), + dealii::make_vectorized_array(0.0)); + std::fill(derExchCorrEnergyWithGradRhoOutSpin0Quads.begin(), + derExchCorrEnergyWithGradRhoOutSpin0Quads.end(), + zeroTensor3); + std::fill(derExchCorrEnergyWithGradRhoOutSpin1Quads.begin(), + derExchCorrEnergyWithGradRhoOutSpin1Quads.end(), + zeroTensor3); + std::fill(gradRhoCoreQuads.begin(), + gradRhoCoreQuads.end(), + zeroTensor3); + std::fill(hessianRhoCoreQuads.begin(), + hessianRhoCoreQuads.end(), + zeroTensor4); - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - sigmaValRhoOut[3 * q + 0] = - scalar_product(gradRhoOutQuadsXCSpin0[q], - gradRhoOutQuadsXCSpin0[q]); - sigmaValRhoOut[3 * q + 1] = - scalar_product(gradRhoOutQuadsXCSpin0[q], - gradRhoOutQuadsXCSpin1[q]); - sigmaValRhoOut[3 * q + 2] = - scalar_product(gradRhoOutQuadsXCSpin1[q], - gradRhoOutQuadsXCSpin1[q]); - } + const unsigned int numSubCells = + matrixFreeData.n_active_entries_per_cell_batch(cell); - std::map *> - rhoOutData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; - rhoOutData[rhoDataAttributes::sigmaGradValue] = - &sigmaValRhoOut; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithDensityValRhoOut; - outputDerExchangeEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaRhoOut; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithDensityValRhoOut; - outputDerCorrEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaRhoOut; - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutSpin0Quads[q][iSubCell] = - derExchEnergyWithDensityValRhoOut[2 * q] + - derCorrEnergyWithDensityValRhoOut[2 * q]; - vxcRhoOutSpin1Quads[q][iSubCell] = - derExchEnergyWithDensityValRhoOut[2 * q + 1] + - derCorrEnergyWithDensityValRhoOut[2 * q + 1]; - for (unsigned int idim = 0; idim < 3; idim++) - { - derExchCorrEnergyWithGradRhoOutSpin0Quads - [q][idim][iSubCell] = - 2.0 * - (derExchEnergyWithSigmaRhoOut[3 * q + - 0] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 0]) * - gradRhoOutQuadsXCSpin0[q][idim]; - derExchCorrEnergyWithGradRhoOutSpin0Quads - [q][idim][iSubCell] += - (derExchEnergyWithSigmaRhoOut[3 * q + 1] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 1]) * - gradRhoOutQuadsXCSpin1[q][idim]; - - derExchCorrEnergyWithGradRhoOutSpin1Quads - [q][idim][iSubCell] += - 2.0 * - (derExchEnergyWithSigmaRhoOut[3 * q + 2] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 2]) * - gradRhoOutQuadsXCSpin1[q][idim]; - derExchCorrEnergyWithGradRhoOutSpin1Quads - [q][idim][iSubCell] += - (derExchEnergyWithSigmaRhoOut[3 * q + 1] + - derCorrEnergyWithSigmaRhoOut[3 * q + - 1]) * - gradRhoOutQuadsXCSpin0[q][idim]; - } - } - } - else if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::LDA) - { - std::map *> - rhoOutData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &exchPotValRhoOut; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &corrPotValRhoOut; - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutSpin0Quads[q][iSubCell] = - exchPotValRhoOut[2 * q] + - corrPotValRhoOut[2 * q]; - vxcRhoOutSpin1Quads[q][iSubCell] = - exchPotValRhoOut[2 * q + 1] + - corrPotValRhoOut[2 * q + 1]; - } - } - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - if (d_dftParams.nonLinearCoreCorrection == true) - { - const std::vector &temp1 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - gradRhoCoreQuads[q][idim][iSubCell] = - temp1[3 * q + idim] / 2.0; - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - const std::vector &temp2 = - hessianRhoCoreValues.find(subCellId) - ->second; - for (unsigned int q = 0; q < numQuadPoints; - ++q) - for (unsigned int idim = 0; idim < 3; - ++idim) - for (unsigned int jdim = 0; jdim < 3; - ++jdim) - hessianRhoCoreQuads - [q][idim][jdim][iSubCell] = - temp2[9 * q + 3 * idim + jdim] / - 2.0; - } - } - } + // + for (unsigned int iSubCell = 0; iSubCell < numSubCells; + ++iSubCell) + { + subCellPtr = + matrixFreeData.get_cell_iterator(cell, iSubCell); + dealii::CellId subCellId = subCellPtr->id(); - } // subcell loop - dealii::Tensor<2, 3, dealii::VectorizedArray> - EQuadSum = zeroTensor4; - for (unsigned int q = 0; q < numQuadPoints; ++q) + const unsigned int subCellIndex = + dftPtr->d_basisOperationsPtrHost->cellIndex(subCellId); + + std::vector quadPointsInCell(numQuadPoints * 3); + std::vector quadWeightsInCell(numQuadPoints); + for (unsigned int iQuad = 0; iQuad < numQuadPoints; ++iQuad) { - dealii::Tensor<2, 3, dealii::VectorizedArray> - E = eshelbyTensorSP::getELocXcEshelbyTensor( - rhoXCQuadsVect[q], - gradRhoSpin0QuadsVect[q], - gradRhoSpin1QuadsVect[q], - excQuads[q], - derExchCorrEnergyWithGradRhoOutSpin0Quads[q], - derExchCorrEnergyWithGradRhoOutSpin1Quads[q]); - - EQuadSum += E * forceEval.JxW(q); - } // quad point loop - - if (isPseudopotential) + for (unsigned int idim = 0; idim < 3; ++idim) + quadPointsInCell[3 * iQuad + idim] = + quadPointsAll[subCellIndex * numQuadPoints * 3 + + 3 * iQuad + idim]; + quadWeightsInCell[iQuad] = std::real( + quadWeightsAll[subCellIndex * numQuadPoints + iQuad]); + } + + + dftPtr->d_excManagerPtr->getExcDensityObj() + ->computeExcVxcFxc(*(dftPtr->d_auxDensityMatrixXCOutPtr), + quadPointsInCell, + quadWeightsInCell, + xDensityOutDataOut, + cDensityOutDataOut); + + std::vector pdexDensityOutSigma; + std::vector pdecDensityOutSigma; + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) { - if (d_dftParams.nonLinearCoreCorrection) - addENonlinearCoreCorrectionStressContributionSpinPolarized( - forceEval, - matrixFreeData, - cell, - vxcRhoOutSpin0Quads, - vxcRhoOutSpin1Quads, - derExchCorrEnergyWithGradRhoOutSpin0Quads, - derExchCorrEnergyWithGradRhoOutSpin1Quads, - gradRhoCoreAtoms, - hessianRhoCoreAtoms, - dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA); + pdexDensityOutSigma = + xDensityOutDataOut[xcOutputDataAttributes::pdeSigma]; + pdecDensityOutSigma = + cDensityOutDataOut[xcOutputDataAttributes::pdeSigma]; } - for (unsigned int iSubCell = 0; iSubCell < numSubCells; - ++iSubCell) - for (unsigned int idim = 0; idim < 3; ++idim) - for (unsigned int jdim = 0; jdim < 3; ++jdim) - { - d_stress[idim][jdim] += - EQuadSum[idim][jdim][iSubCell]; - } - } // kpt paral - } // macrocell loop - } - else - { - dealii::AlignedVector> rhoQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> rhoXCQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - phiTotRhoOutQuads(numQuadPoints, - dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoQuads(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - gradRhoCoreQuads(numQuadPoints, zeroTensor3); - dealii::AlignedVector< - dealii::Tensor<2, 3, dealii::VectorizedArray>> - hessianRhoCoreQuads(numQuadPoints, zeroTensor4); - dealii::AlignedVector> excQuads( - numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector> - vxcRhoOutQuads(numQuadPoints, dealii::make_vectorized_array(0.0)); - dealii::AlignedVector< - dealii::Tensor<1, 3, dealii::VectorizedArray>> - derExchCorrEnergyWithGradRhoOutQuads(numQuadPoints, zeroTensor3); - for (unsigned int cell = 0; cell < matrixFreeData.n_cell_batches(); - ++cell) - { - if (cell < - kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId + 1] && - cell >= kptGroupLowHighPlusOneIndices[2 * kptGroupTaskId]) - { - forceEval.reinit(cell); + std::unordered_map> + densityXCOutData; + std::vector gradDensityXCOutSpinUp; + std::vector gradDensityXCOutSpinDown; - std::fill(rhoQuads.begin(), - rhoQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(rhoXCQuads.begin(), - rhoXCQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(phiTotRhoOutQuads.begin(), - phiTotRhoOutQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(gradRhoQuads.begin(), - gradRhoQuads.end(), - zeroTensor3); - std::fill(gradRhoCoreQuads.begin(), - gradRhoCoreQuads.end(), - zeroTensor3); - std::fill(hessianRhoCoreQuads.begin(), - hessianRhoCoreQuads.end(), - zeroTensor4); - std::fill(excQuads.begin(), - excQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(vxcRhoOutQuads.begin(), - vxcRhoOutQuads.end(), - dealii::make_vectorized_array(0.0)); - std::fill(derExchCorrEnergyWithGradRhoOutQuads.begin(), - derExchCorrEnergyWithGradRhoOutQuads.end(), - zeroTensor3); - - const unsigned int numSubCells = - matrixFreeData.n_active_entries_per_cell_batch(cell); - // For LDA - std::vector exchValRhoOut(numQuadPoints); - std::vector corrValRhoOut(numQuadPoints); - std::vector exchPotValRhoOut(numQuadPoints); - std::vector corrPotValRhoOut(numQuadPoints); - std::vector rhoOutQuadsXC(numQuadPoints); - - // - // For GGA - std::vector sigmaValRhoOut(numQuadPoints); - std::vector derExchEnergyWithDensityValRhoOut( - numQuadPoints), - derCorrEnergyWithDensityValRhoOut(numQuadPoints), - derExchEnergyWithSigmaRhoOut(numQuadPoints), - derCorrEnergyWithSigmaRhoOut(numQuadPoints); - std::vector> gradRhoOutQuadsXC( - numQuadPoints); - - // - for (unsigned int iSubCell = 0; iSubCell < numSubCells; - ++iSubCell) + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) { - subCellPtr = - matrixFreeData.get_cell_iterator(cell, iSubCell); - dealii::CellId subCellId = subCellPtr->id(); + densityXCOutData + [DensityDescriptorDataAttributes::gradValuesSpinUp] = + std::vector(); + densityXCOutData[DensityDescriptorDataAttributes:: + gradValuesSpinDown] = + std::vector(); + } - // const std::vector &temp1 = - // rhoOutValues.find(subCellId)->second; + dftPtr->d_auxDensityMatrixXCOutPtr->applyLocalOperations( + quadPointsInCell, densityXCOutData); - const unsigned int subCellIndex = - dftPtr->d_basisOperationsPtrHost->cellIndex( - subCellId); - const auto &rhoTotalOutValues = rhoOutValues[0]; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoTotalCellQuadValues[q] = - rhoTotalOutValues[subCellIndex * numQuadPoints + - q]; - } + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + gradDensityXCOutSpinUp = densityXCOutData + [DensityDescriptorDataAttributes::gradValuesSpinUp]; + gradDensityXCOutSpinDown = densityXCOutData + [DensityDescriptorDataAttributes::gradValuesSpinDown]; + } - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoOutQuadsXC[q] = rhoTotalCellQuadValues[q]; - rhoQuads[q][iSubCell] = rhoTotalCellQuadValues[q]; - rhoXCQuads[q][iSubCell] = rhoTotalCellQuadValues[q]; - } - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp2 = - rhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - rhoOutQuadsXC[q] += temp2[q]; - rhoXCQuads[q][iSubCell] += temp2[q]; - } - } + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + // const std::vector &temp3 = + // (*dftPtr->gradRhoOutValuesSpinPolarized) + // .find(subCellId) + // ->second; - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - // const std::vector &temp3 = - // gradRhoOutValues.find(subCellId)->second; - const auto &gradRhoTotalOutValuesTemp = - gradRhoOutValues[0]; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - gradRhoTotalCellQuadValues[3 * q + idim] = - gradRhoTotalOutValuesTemp[subCellIndex * - numQuadPoints * - 3 + - q * 3 + idim]; - - - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - { - gradRhoOutQuadsXC[q][idim] = - gradRhoTotalCellQuadValues[3 * q + idim]; - gradRhoQuads[q][idim][iSubCell] = - gradRhoTotalCellQuadValues[3 * q + idim]; - } - - if (d_dftParams.nonLinearCoreCorrection) - { - const std::vector &temp4 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - gradRhoOutQuadsXC[q][0] += temp4[3 * q + 0]; - gradRhoOutQuadsXC[q][1] += temp4[3 * q + 1]; - gradRhoOutQuadsXC[q][2] += temp4[3 * q + 2]; - } - } - } + const auto &gradRhoTotalOutValues = + gradDensityOutValuesSpinPolarized[0]; + const auto &gradRhoMagOutValues = + gradDensityOutValuesSpinPolarized[1]; - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - for (unsigned int q = 0; q < numQuadPoints; ++q) - sigmaValRhoOut[q] = - gradRhoOutQuadsXC[q].norm_square(); - - std::map *> - rhoOutData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; - rhoOutData[rhoDataAttributes::sigmaGradValue] = - &sigmaValRhoOut; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derExchEnergyWithDensityValRhoOut; - outputDerExchangeEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derExchEnergyWithSigmaRhoOut; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &derCorrEnergyWithDensityValRhoOut; - outputDerCorrEnergy - [VeffOutputDataAttributes:: - derEnergyWithSigmaGradDensity] = - &derCorrEnergyWithSigmaRhoOut; - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutQuads[q][iSubCell] = - derExchEnergyWithDensityValRhoOut[q] + - derCorrEnergyWithDensityValRhoOut[q]; - - for (unsigned int idim = 0; idim < 3; idim++) - { - derExchCorrEnergyWithGradRhoOutQuads - [q][idim][iSubCell] = - 2.0 * - (derExchEnergyWithSigmaRhoOut[q] + - derCorrEnergyWithSigmaRhoOut[q]) * - gradRhoOutQuadsXC[q][idim]; - } - } - } - else if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::LDA) - { - std::map *> - rhoOutData; - - std::map *> - outputDerExchangeEnergy; - std::map *> - outputDerCorrEnergy; - - rhoOutData[rhoDataAttributes::values] = - &rhoOutQuadsXC; - - outputDerExchangeEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &exchPotValRhoOut; - - outputDerCorrEnergy - [VeffOutputDataAttributes::derEnergyWithDensity] = - &corrPotValRhoOut; - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedEnergyDensity(numQuadPoints, - rhoOutData, - exchValRhoOut, - corrValRhoOut); - - dftPtr->d_excManagerPtr->getExcDensityObj() - ->computeDensityBasedVxc(numQuadPoints, - rhoOutData, - outputDerExchangeEnergy, - outputDerCorrEnergy); - - - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - excQuads[q][iSubCell] = - exchValRhoOut[q] + corrValRhoOut[q]; - vxcRhoOutQuads[q][iSubCell] = - exchPotValRhoOut[q] + corrPotValRhoOut[q]; - } - } + for (unsigned int q = 0; q < numQuadPoints; ++q) + for (unsigned int idim = 0; idim < 3; idim++) + { + gradRhoSpin0QuadsVect[q][idim][iSubCell] = + (gradRhoTotalOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim] + + gradRhoMagOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim]) / + 2.0; + gradRhoSpin1QuadsVect[q][idim][iSubCell] = + (gradRhoTotalOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim] - + gradRhoMagOutValues[subCellIndex * + numQuadPoints * 3 + + q * 3 + idim]) / + 2.0; + } + } + + + for (unsigned int q = 0; q < numQuadPoints; ++q) + { + excQuads[q][iSubCell] = + xEnergyDensityOut[q] + cEnergyDensityOut[q]; + vxcRhoOutSpin0Quads[q][iSubCell] = + pdexDensityOutSpinUp[q] + pdecDensityOutSpinUp[q]; + vxcRhoOutSpin1Quads[q][iSubCell] = + pdexDensityOutSpinDown[q] + pdecDensityOutSpinDown[q]; + } + if (dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { for (unsigned int q = 0; q < numQuadPoints; ++q) { - if (d_dftParams.nonLinearCoreCorrection == true) + for (unsigned int idim = 0; idim < 3; idim++) { - const std::vector &temp1 = - gradRhoCoreValues.find(subCellId)->second; - for (unsigned int q = 0; q < numQuadPoints; ++q) - for (unsigned int idim = 0; idim < 3; idim++) - gradRhoCoreQuads[q][idim][iSubCell] = - temp1[3 * q + idim]; - - if (dftPtr->d_excManagerPtr - ->getDensityBasedFamilyType() == - densityFamilyType::GGA) - { - const std::vector &temp2 = - hessianRhoCoreValues.find(subCellId) - ->second; - for (unsigned int q = 0; q < numQuadPoints; - ++q) - for (unsigned int idim = 0; idim < 3; - ++idim) - for (unsigned int jdim = 0; jdim < 3; - ++jdim) - hessianRhoCoreQuads - [q][idim][jdim][iSubCell] = - temp2[9 * q + 3 * idim + jdim]; - } + derExchCorrEnergyWithGradRhoOutSpin0Quads + [q][idim][iSubCell] = + 2.0 * + (pdexDensityOutSigma[3 * q + 0] + + pdecDensityOutSigma[3 * q + 0]) * + gradDensityXCOutSpinUp[3 * q + idim]; + derExchCorrEnergyWithGradRhoOutSpin0Quads + [q][idim][iSubCell] += + (pdexDensityOutSigma[3 * q + 1] + + pdecDensityOutSigma[3 * q + 1]) * + gradDensityXCOutSpinDown[3 * q + idim]; + + derExchCorrEnergyWithGradRhoOutSpin1Quads + [q][idim][iSubCell] += + 2.0 * + (pdexDensityOutSigma[3 * q + 2] + + pdecDensityOutSigma[3 * q + 2]) * + gradDensityXCOutSpinDown[3 * q + idim]; + derExchCorrEnergyWithGradRhoOutSpin1Quads + [q][idim][iSubCell] += + (pdexDensityOutSigma[3 * q + 1] + + pdecDensityOutSigma[3 * q + 1]) * + gradDensityXCOutSpinUp[3 * q + idim]; } } - } // subcell loop - - dealii::Tensor<2, 3, dealii::VectorizedArray> - EQuadSum = zeroTensor4; - for (unsigned int q = 0; q < numQuadPoints; ++q) - { - dealii::Tensor<2, 3, dealii::VectorizedArray> - E = eshelbyTensor::getELocXcEshelbyTensor( - rhoXCQuads[q], - gradRhoQuads[q], - excQuads[q], - derExchCorrEnergyWithGradRhoOutQuads[q]); - - EQuadSum += E * forceEval.JxW(q); - } // quad point loop + } + if (d_dftParams.nonLinearCoreCorrection == true) + for (unsigned int q = 0; q < numQuadPoints; ++q) + { + const std::vector &temp1 = + gradRhoCoreValues.find(subCellId)->second; + for (unsigned int q = 0; q < numQuadPoints; ++q) + for (unsigned int idim = 0; idim < 3; idim++) + gradRhoCoreQuads[q][idim][iSubCell] = + temp1[3 * q + idim] / 2.0; + + if (dftPtr->d_excManagerPtr + ->getDensityBasedFamilyType() == + densityFamilyType::GGA) + { + const std::vector &temp2 = + hessianRhoCoreValues.find(subCellId)->second; + for (unsigned int q = 0; q < numQuadPoints; ++q) + for (unsigned int idim = 0; idim < 3; ++idim) + for (unsigned int jdim = 0; jdim < 3; ++jdim) + hessianRhoCoreQuads + [q][idim][jdim][iSubCell] = + temp2[9 * q + 3 * idim + jdim] / 2.0; + } + } + + } // subcell loop + + dealii::Tensor<2, 3, dealii::VectorizedArray> EQuadSum = + zeroTensor4; + for (unsigned int q = 0; q < numQuadPoints; ++q) + { + dealii::Tensor<2, 3, dealii::VectorizedArray> E = + eshelbyTensorSP::getELocXcEshelbyTensor( + gradRhoSpin0QuadsVect[q], + gradRhoSpin1QuadsVect[q], + excQuads[q], + derExchCorrEnergyWithGradRhoOutSpin0Quads[q], + derExchCorrEnergyWithGradRhoOutSpin1Quads[q]); + + EQuadSum += E * forceEval.JxW(q); + } // quad point loop + + if (isPseudopotential) + { + if (d_dftParams.nonLinearCoreCorrection) + addENonlinearCoreCorrectionStressContributionSpinPolarized( + forceEval, + matrixFreeData, + cell, + vxcRhoOutSpin0Quads, + vxcRhoOutSpin1Quads, + derExchCorrEnergyWithGradRhoOutSpin0Quads, + derExchCorrEnergyWithGradRhoOutSpin1Quads, + gradRhoCoreAtoms, + hessianRhoCoreAtoms, + dftPtr->d_excManagerPtr->getDensityBasedFamilyType() == + densityFamilyType::GGA); + } - if (isPseudopotential) + for (unsigned int iSubCell = 0; iSubCell < numSubCells; + ++iSubCell) + for (unsigned int idim = 0; idim < 3; ++idim) + for (unsigned int jdim = 0; jdim < 3; ++jdim) { - if (d_dftParams.nonLinearCoreCorrection) - addENonlinearCoreCorrectionStressContribution( - forceEval, - matrixFreeData, - cell, - vxcRhoOutQuads, - derExchCorrEnergyWithGradRhoOutQuads, - gradRhoCoreAtoms, - hessianRhoCoreAtoms); + d_stress[idim][jdim] += EQuadSum[idim][jdim][iSubCell]; } + } // kpt paral + } // macrocell loop - for (unsigned int iSubCell = 0; iSubCell < numSubCells; - ++iSubCell) - for (unsigned int idim = 0; idim < 3; ++idim) - for (unsigned int jdim = 0; jdim < 3; ++jdim) - { - d_stress[idim][jdim] += - EQuadSum[idim][jdim][iSubCell]; - } - } // kpt paral - } // cell loop - } ////Add electrostatic stress contribution//////////////// computeStressEEshelbyEElectroPhiTot(matrixFreeDataElectro, diff --git a/src/force/eshelbyTensor/eshelbyTensor.cc b/src/force/eshelbyTensor/eshelbyTensor.cc index 3230d3b11..21bd0794e 100644 --- a/src/force/eshelbyTensor/eshelbyTensor.cc +++ b/src/force/eshelbyTensor/eshelbyTensor.cc @@ -104,7 +104,6 @@ namespace dftfe dealii::Tensor<2, 3, dealii::VectorizedArray> getELocXcEshelbyTensor( - const dealii::VectorizedArray & rho, const dealii::Tensor<1, 3, dealii::VectorizedArray> &gradRho, const dealii::VectorizedArray & exc, const dealii::Tensor<1, 3, dealii::VectorizedArray> @@ -112,7 +111,7 @@ namespace dftfe { dealii::Tensor<2, 3, dealii::VectorizedArray> eshelbyTensor = -outer_product(gradRho, derExcGradRho); - dealii::VectorizedArray identityTensorFactor = exc * rho; + dealii::VectorizedArray identityTensorFactor = exc; eshelbyTensor[0][0] += identityTensorFactor; diff --git a/src/force/eshelbyTensor/eshelbyTensorSpinPolarized.cc b/src/force/eshelbyTensor/eshelbyTensorSpinPolarized.cc index d78562ae7..888e05d0d 100644 --- a/src/force/eshelbyTensor/eshelbyTensorSpinPolarized.cc +++ b/src/force/eshelbyTensor/eshelbyTensorSpinPolarized.cc @@ -25,7 +25,6 @@ namespace dftfe { dealii::Tensor<2, 3, dealii::VectorizedArray> getELocXcEshelbyTensor( - const dealii::VectorizedArray & rho, const dealii::Tensor<1, 3, dealii::VectorizedArray> &gradRhoSpin0, const dealii::Tensor<1, 3, dealii::VectorizedArray> &gradRhoSpin1, const dealii::VectorizedArray & exc, @@ -37,7 +36,7 @@ namespace dftfe dealii::Tensor<2, 3, dealii::VectorizedArray> eshelbyTensor = -outer_product(derExcGradRhoSpin0, gradRhoSpin0) - outer_product(derExcGradRhoSpin1, gradRhoSpin1); - dealii::VectorizedArray identityTensorFactor = exc * rho; + dealii::VectorizedArray identityTensorFactor = exc; eshelbyTensor[0][0] += identityTensorFactor; eshelbyTensor[1][1] += identityTensorFactor; eshelbyTensor[2][2] += identityTensorFactor; diff --git a/tests/dft/allElectron/complex/silicon_01.prm.in b/tests/dft/allElectron/complex/silicon_01.prm.in index eb7e65b9b..29c66fa4d 100644 --- a/tests/dft/allElectron/complex/silicon_01.prm.in +++ b/tests/dft/allElectron/complex/silicon_01.prm.in @@ -64,7 +64,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =false - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/allElectron/complex/silicon_01_b.prm.in b/tests/dft/allElectron/complex/silicon_01_b.prm.in index 274750866..540049918 100644 --- a/tests/dft/allElectron/complex/silicon_01_b.prm.in +++ b/tests/dft/allElectron/complex/silicon_01_b.prm.in @@ -65,7 +65,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =false - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/allElectron/real/methane_01.prm.in b/tests/dft/allElectron/real/methane_01.prm.in index 7e3fbdb88..60b3ce81a 100644 --- a/tests/dft/allElectron/real/methane_01.prm.in +++ b/tests/dft/allElectron/real/methane_01.prm.in @@ -35,7 +35,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = false end diff --git a/tests/dft/allElectron/real/methane_01_b.prm.in b/tests/dft/allElectron/real/methane_01_b.prm.in index b63e14f3d..b799da140 100644 --- a/tests/dft/allElectron/real/methane_01_b.prm.in +++ b/tests/dft/allElectron/real/methane_01_b.prm.in @@ -35,7 +35,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = false end diff --git a/tests/dft/allElectron/real/oxygenMolecule_01.mpirun=4.output b/tests/dft/allElectron/real/oxygenMolecule_01.mpirun=4.output index 8d0af5919..34e5e849a 100644 --- a/tests/dft/allElectron/real/oxygenMolecule_01.mpirun=4.output +++ b/tests/dft/allElectron/real/oxygenMolecule_01.mpirun=4.output @@ -33,7 +33,7 @@ SCF iterations converged to the specified tolerance after: 22 iterations. Energy computations (Hartree) ------------------- - Total energy: -148.96483916 + Total energy: -148.96483978 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/allElectron/real/oxygenMolecule_01.prm.in b/tests/dft/allElectron/real/oxygenMolecule_01.prm.in index 3035f2b55..652eabb29 100644 --- a/tests/dft/allElectron/real/oxygenMolecule_01.prm.in +++ b/tests/dft/allElectron/real/oxygenMolecule_01.prm.in @@ -35,7 +35,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = false set SPIN POLARIZATION = 1 set START MAGNETIZATION = 0.0625 diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_01.mpirun=4.output b/tests/dft/pseudopotential/complex/cubicAlPrim_01.mpirun=4.output index e8033240d..13ed7fcfa 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_01.mpirun=4.output +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_01.mpirun=4.output @@ -36,7 +36,7 @@ SCF iterations converged to the specified tolerance after: 11 iterations. Energy computations (Hartree) ------------------- - Total energy: -68.93466749 + Total energy: -68.93466746 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_01.prm.in b/tests/dft/pseudopotential/complex/cubicAlPrim_01.prm.in index 93d88c400..ff29d4337 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_01.prm.in +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_01.prm.in @@ -61,7 +61,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDO TESTS FLAG = true set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.mpirun=4.output b/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.mpirun=4.output index e8033240d..13ed7fcfa 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.mpirun=4.output +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.mpirun=4.output @@ -36,7 +36,7 @@ SCF iterations converged to the specified tolerance after: 11 iterations. Energy computations (Hartree) ------------------- - Total energy: -68.93466749 + Total energy: -68.93466746 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.prm.in b/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.prm.in index a1934d87e..166b6011d 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.prm.in +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_01_b.prm.in @@ -60,7 +60,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDO TESTS FLAG = true set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_02.mpirun=8.output b/tests/dft/pseudopotential/complex/cubicAlPrim_02.mpirun=8.output index dc599b521..84264a330 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_02.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_02.mpirun=8.output @@ -36,7 +36,7 @@ SCF iterations converged to the specified tolerance after: 11 iterations. Energy computations (Hartree) ------------------- - Total energy: -68.97017909 + Total energy: -68.97017913 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_02.prm.in b/tests/dft/pseudopotential/complex/cubicAlPrim_02.prm.in index 2fce1deb2..2626e5f4d 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_02.prm.in +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_02.prm.in @@ -61,7 +61,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDO TESTS FLAG = true set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.mpirun=8.output b/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.mpirun=8.output index dc599b521..84264a330 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.mpirun=8.output @@ -36,7 +36,7 @@ SCF iterations converged to the specified tolerance after: 11 iterations. Energy computations (Hartree) ------------------- - Total energy: -68.97017909 + Total energy: -68.97017913 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.prm.in b/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.prm.in index a87e5da17..f093ee4fe 100644 --- a/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.prm.in +++ b/tests/dft/pseudopotential/complex/cubicAlPrim_02_b.prm.in @@ -61,7 +61,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDO TESTS FLAG = true set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 diff --git a/tests/dft/pseudopotential/complex/d3/d3_graphite.prm.in b/tests/dft/pseudopotential/complex/d3/d3_graphite.prm.in index 130fb082c..9d616e58e 100644 --- a/tests/dft/pseudopotential/complex/d3/d3_graphite.prm.in +++ b/tests/dft/pseudopotential/complex/d3/d3_graphite.prm.in @@ -43,7 +43,7 @@ subsection Brillouin zone k point sampling options end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudographite.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/d4/d4_graphite.prm.in b/tests/dft/pseudopotential/complex/d4/d4_graphite.prm.in index f7fda5bc2..998d3a8ae 100644 --- a/tests/dft/pseudopotential/complex/d4/d4_graphite.prm.in +++ b/tests/dft/pseudopotential/complex/d4/d4_graphite.prm.in @@ -43,7 +43,7 @@ subsection Brillouin zone k point sampling options end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudographite.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_01.prm.in b/tests/dft/pseudopotential/complex/fccAl_01.prm.in index 313e22b56..6872c173f 100644 --- a/tests/dft/pseudopotential/complex/fccAl_01.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_01.prm.in @@ -28,7 +28,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_02.prm.in b/tests/dft/pseudopotential/complex/fccAl_02.prm.in index 7b7754979..1dd363d78 100644 --- a/tests/dft/pseudopotential/complex/fccAl_02.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_02.prm.in @@ -30,7 +30,7 @@ subsection Parallelization end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_02_c.prm.in b/tests/dft/pseudopotential/complex/fccAl_02_c.prm.in index fb50f7142..e30bce88d 100644 --- a/tests/dft/pseudopotential/complex/fccAl_02_c.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_02_c.prm.in @@ -28,7 +28,7 @@ subsection Parallelization end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_02_d.prm.in b/tests/dft/pseudopotential/complex/fccAl_02_d.prm.in index 079f56390..d0551a198 100644 --- a/tests/dft/pseudopotential/complex/fccAl_02_d.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_02_d.prm.in @@ -28,7 +28,7 @@ subsection Parallelization end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_02_e.prm.in b/tests/dft/pseudopotential/complex/fccAl_02_e.prm.in index 4ba93de98..f8e61ce7c 100644 --- a/tests/dft/pseudopotential/complex/fccAl_02_e.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_02_e.prm.in @@ -28,7 +28,7 @@ subsection Parallelization end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_03.prm.in b/tests/dft/pseudopotential/complex/fccAl_03.prm.in index fc3ef9d64..0fb5548f9 100644 --- a/tests/dft/pseudopotential/complex/fccAl_03.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_03.prm.in @@ -37,7 +37,7 @@ subsection Parallelization end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_04.prm.in b/tests/dft/pseudopotential/complex/fccAl_04.prm.in index 8e3c3ad10..a4304003c 100644 --- a/tests/dft/pseudopotential/complex/fccAl_04.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_04.prm.in @@ -36,7 +36,7 @@ subsection Parallelization end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/fccAl_05.prm.in b/tests/dft/pseudopotential/complex/fccAl_05.prm.in index f770a3fff..ef880b882 100644 --- a/tests/dft/pseudopotential/complex/fccAl_05.prm.in +++ b/tests/dft/pseudopotential/complex/fccAl_05.prm.in @@ -36,7 +36,7 @@ subsection Parallelization end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/graphene_01.mpirun=4.output b/tests/dft/pseudopotential/complex/graphene_01.mpirun=4.output index d25bc62b7..b522fc02d 100644 --- a/tests/dft/pseudopotential/complex/graphene_01.mpirun=4.output +++ b/tests/dft/pseudopotential/complex/graphene_01.mpirun=4.output @@ -37,4 +37,4 @@ SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- - Total energy: -11.40150452 + Total energy: -11.40150499 diff --git a/tests/dft/pseudopotential/complex/graphene_01.prm.in b/tests/dft/pseudopotential/complex/graphene_01.prm.in index 9e423efcb..c66da4fba 100644 --- a/tests/dft/pseudopotential/complex/graphene_01.prm.in +++ b/tests/dft/pseudopotential/complex/graphene_01.prm.in @@ -60,7 +60,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoCarbon.inp - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDO TESTS FLAG = true set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 diff --git a/tests/dft/pseudopotential/complex/graphene_01_b.mpirun=4.output b/tests/dft/pseudopotential/complex/graphene_01_b.mpirun=4.output index d25bc62b7..b522fc02d 100644 --- a/tests/dft/pseudopotential/complex/graphene_01_b.mpirun=4.output +++ b/tests/dft/pseudopotential/complex/graphene_01_b.mpirun=4.output @@ -37,4 +37,4 @@ SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- - Total energy: -11.40150452 + Total energy: -11.40150499 diff --git a/tests/dft/pseudopotential/complex/graphene_01_b.prm.in b/tests/dft/pseudopotential/complex/graphene_01_b.prm.in index 9e423efcb..c66da4fba 100644 --- a/tests/dft/pseudopotential/complex/graphene_01_b.prm.in +++ b/tests/dft/pseudopotential/complex/graphene_01_b.prm.in @@ -60,7 +60,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoCarbon.inp - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDO TESTS FLAG = true set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 diff --git a/tests/dft/pseudopotential/complex/graphene_01_c.mpirun=16.output b/tests/dft/pseudopotential/complex/graphene_01_c.mpirun=16.output index aef0fd17a..766116295 100644 --- a/tests/dft/pseudopotential/complex/graphene_01_c.mpirun=16.output +++ b/tests/dft/pseudopotential/complex/graphene_01_c.mpirun=16.output @@ -36,4 +36,4 @@ SCF iterations converged to the specified tolerance after: 20 iterations. Energy computations (Hartree) ------------------- - Total energy: -11.43025736 + Total energy: -11.43025918 diff --git a/tests/dft/pseudopotential/complex/graphene_01_c.prm.in b/tests/dft/pseudopotential/complex/graphene_01_c.prm.in index ce4fc85bc..496465a31 100644 --- a/tests/dft/pseudopotential/complex/graphene_01_c.prm.in +++ b/tests/dft/pseudopotential/complex/graphene_01_c.prm.in @@ -60,7 +60,7 @@ end subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoCarbon.inp - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDO TESTS FLAG = true set SPIN POLARIZATION=1 set START MAGNETIZATION=0.1 diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_01.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_01.prm.in index 9649b9a22..272d65761 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_01.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_01.prm.in @@ -62,7 +62,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_01_b.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_01_b.prm.in index 854869844..ef08d52d3 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_01_b.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_01_b.prm.in @@ -61,7 +61,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_01_c.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_01_c.prm.in index e356f961d..4be40ed41 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_01_c.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_01_c.prm.in @@ -61,7 +61,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.mpirun=8.output b/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.mpirun=8.output index 3476f9ec7..fa913040f 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.mpirun=8.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 15 iterations. Energy computations (Hartree) ------------------- - Total energy: -137.95735290 + Total energy: -137.95735313 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.prm.in index 9d6fcfc9b..c6c89885c 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_01_d.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.mpirun=8.output b/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.mpirun=8.output index 3476f9ec7..fa913040f 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.mpirun=8.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 15 iterations. Energy computations (Hartree) ------------------- - Total energy: -137.95735290 + Total energy: -137.95735313 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.prm.in index 9d6fcfc9b..c6c89885c 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_01_e.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_02.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_02.prm.in index b81c6a0ef..82e1c219b 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_02.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_02.prm.in @@ -66,7 +66,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_02_b.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_02_b.prm.in index 3e3d40550..e66022f2e 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_02_b.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_02_b.prm.in @@ -66,7 +66,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_02_c.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_02_c.prm.in index 04e4b2a2e..cb1a4a262 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_02_c.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_02_c.prm.in @@ -67,7 +67,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.mpirun=8.output b/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.mpirun=8.output index 10291c7e9..bfa927d96 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.mpirun=8.output @@ -33,7 +33,7 @@ Reading initial guess for electron-density..... Pseudopotential initalization.... Starting SCF iterations.... -SCF iterations converged to the specified tolerance after: 10 iterations. +SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- @@ -41,13 +41,13 @@ Energy computations (Hartree) Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- -AtomId 0: 0.000013,0.000007,0.008617 -AtomId 1: 0.006120,0.003534,0.008617 +AtomId 0: 0.000011,0.000007,0.008599 +AtomId 1: 0.006122,0.003534,0.008599 -------------------------------------------------------------------------------------------- Absolute value of cell stress (Hartree/Bohr^3) ------------------------------------------------------------------------ -0.005461 0.001399 0.000000 -0.001399 0.003845 0.000000 +0.005460 0.001399 0.000000 +0.001399 0.003844 0.000000 0.000000 0.000000 0.001757 ------------------------------------------------------------------------ diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.prm.in index b41e4bec4..3527e40b5 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_02_d.prm.in @@ -66,7 +66,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=-0.05 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_03.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_03.prm.in index 423071969..7b65ec89d 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_03.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_03.prm.in @@ -62,7 +62,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=4.output b/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=4.output index 2b9d4e1c1..95993a96a 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=4.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=4.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 15 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.23777807 + Total energy: -138.23777830 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=8.output b/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=8.output index 24e684eb9..95993a96a 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_04.mpirun=8.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 15 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.23777808 + Total energy: -138.23777830 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_04.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_04.prm.in index 8766ab137..ff486805f 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_04.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_04.prm.in @@ -62,7 +62,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=4.output b/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=4.output index 2b9d4e1c1..95993a96a 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=4.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=4.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 15 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.23777807 + Total energy: -138.23777830 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=8.output b/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=8.output index 24e684eb9..95993a96a 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.mpirun=8.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 15 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.23777808 + Total energy: -138.23777830 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.prm.in index edd37022d..93e4e2696 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_04_b.prm.in @@ -61,7 +61,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_05.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_05.prm.in index d55307682..b008b1a88 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_05.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_05.prm.in @@ -62,7 +62,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=11.output b/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=11.output index 1374a33b2..a6736f082 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=11.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=11.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.73853419 + Total energy: -138.73853572 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=7.output b/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=7.output index 50ae9a753..a6736f082 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=7.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_06.mpirun=7.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.73853417 + Total energy: -138.73853572 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_06.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_06.prm.in index 325df544f..895123aa0 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_06.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_06.prm.in @@ -62,7 +62,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=11.output b/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=11.output index 1374a33b2..a6736f082 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=11.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=11.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.73853419 + Total energy: -138.73853572 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=7.output b/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=7.output index 50ae9a753..a6736f082 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=7.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.mpirun=7.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.73853417 + Total energy: -138.73853572 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.prm.in index 067413871..aa4bb8a5a 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_06_b.prm.in @@ -61,7 +61,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_07.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_07.prm.in index 79ff0a890..e48a38bbc 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_07.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_07.prm.in @@ -66,7 +66,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=0 set START MAGNETIZATION=0.0 end diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.mpirun=8.output b/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.mpirun=8.output index 6b78b867c..dd6698943 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.mpirun=8.output +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.mpirun=8.output @@ -37,7 +37,7 @@ SCF iterations converged to the specified tolerance after: 11 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.22325653 + Total energy: -138.22326013 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.prm.in b/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.prm.in index 34f3cba27..14ed893f5 100644 --- a/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.prm.in +++ b/tests/dft/pseudopotential/complex/hcpMgPrim_07_b.prm.in @@ -66,7 +66,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/complex/mdLGPSNVE_01.prm.in b/tests/dft/pseudopotential/complex/mdLGPSNVE_01.prm.in index 8c6ac1396..51d798da1 100644 --- a/tests/dft/pseudopotential/complex/mdLGPSNVE_01.prm.in +++ b/tests/dft/pseudopotential/complex/mdLGPSNVE_01.prm.in @@ -23,7 +23,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/LGPSMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/mdLGPSNVE_02.prm.in b/tests/dft/pseudopotential/complex/mdLGPSNVE_02.prm.in index fc175ea50..5382eb2c1 100644 --- a/tests/dft/pseudopotential/complex/mdLGPSNVE_02.prm.in +++ b/tests/dft/pseudopotential/complex/mdLGPSNVE_02.prm.in @@ -23,7 +23,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/LGPSMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/complex/nitrogenMolecule_02.prm.in b/tests/dft/pseudopotential/complex/nitrogenMolecule_02.prm.in index 5cdc04196..5e491f0db 100644 --- a/tests/dft/pseudopotential/complex/nitrogenMolecule_02.prm.in +++ b/tests/dft/pseudopotential/complex/nitrogenMolecule_02.prm.in @@ -39,7 +39,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/aluminumSingleAtom_01.prm.in b/tests/dft/pseudopotential/real/aluminumSingleAtom_01.prm.in index 92aa113d5..2b258caaa 100644 --- a/tests/dft/pseudopotential/real/aluminumSingleAtom_01.prm.in +++ b/tests/dft/pseudopotential/real/aluminumSingleAtom_01.prm.in @@ -44,7 +44,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ end diff --git a/tests/dft/pseudopotential/real/aluminumSingleAtom_01_b.prm.in b/tests/dft/pseudopotential/real/aluminumSingleAtom_01_b.prm.in index d4f643ffe..e108fc117 100644 --- a/tests/dft/pseudopotential/real/aluminumSingleAtom_01_b.prm.in +++ b/tests/dft/pseudopotential/real/aluminumSingleAtom_01_b.prm.in @@ -44,7 +44,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlKB.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 1 + set EXCHANGE CORRELATION TYPE = LDA-PZ end diff --git a/tests/dft/pseudopotential/real/d3/d3_kryptondimer.prm.in b/tests/dft/pseudopotential/real/d3/d3_kryptondimer.prm.in index 8ce3c4178..368eccf6d 100644 --- a/tests/dft/pseudopotential/real/d3/d3_kryptondimer.prm.in +++ b/tests/dft/pseudopotential/real/d3/d3_kryptondimer.prm.in @@ -22,7 +22,7 @@ subsection Boundary conditions end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoKr.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/d4/d4_kryptondimer.prm.in b/tests/dft/pseudopotential/real/d4/d4_kryptondimer.prm.in index 7db9af9ac..6ea4b7237 100644 --- a/tests/dft/pseudopotential/real/d4/d4_kryptondimer.prm.in +++ b/tests/dft/pseudopotential/real/d4/d4_kryptondimer.prm.in @@ -22,7 +22,7 @@ subsection Boundary conditions end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoKr.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/fccAlPert_01.mpirun=24.output b/tests/dft/pseudopotential/real/fccAlPert_01.mpirun=24.output index 3291933a2..7b2cec8c4 100644 --- a/tests/dft/pseudopotential/real/fccAlPert_01.mpirun=24.output +++ b/tests/dft/pseudopotential/real/fccAlPert_01.mpirun=24.output @@ -39,7 +39,7 @@ SCF iterations converged to the specified tolerance after: 19 iterations. Energy computations (Hartree) ------------------- - Total energy: -8.98497919 + Total energy: -8.98497918 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- @@ -59,7 +59,7 @@ Writing tdos File... epsValue SpinUpDos SpinDownDos -8.33764673 0.00015609 0.00012668 -8.31043534 0.00015832 0.00012822 --8.28322395 0.00016060 0.00012979 +-8.28322396 0.00016060 0.00012979 -8.25601257 0.00016294 0.00013139 -8.22880118 0.00016534 0.00013303 -8.20158980 0.00016780 0.00013471 @@ -79,10 +79,10 @@ epsValue SpinUpDos SpinDownDos -7.82063039 0.00021051 0.00016263 -7.79341901 0.00021429 0.00016501 -7.76620762 0.00021820 0.00016745 --7.73899623 0.00022224 0.00016996 +-7.73899624 0.00022224 0.00016996 -7.71178485 0.00022641 0.00017253 -7.68457346 0.00023073 0.00017517 --7.65736207 0.00023519 0.00017788 +-7.65736208 0.00023519 0.00017788 -7.63015069 0.00023981 0.00018067 -7.60293930 0.00024460 0.00018353 -7.57572792 0.00024955 0.00018648 @@ -92,7 +92,7 @@ epsValue SpinUpDos SpinDownDos -7.46688237 0.00027130 0.00019915 -7.43967099 0.00027728 0.00020255 -7.41245960 0.00028349 0.00020607 --7.38524821 0.00028995 0.00020969 +-7.38524822 0.00028995 0.00020969 -7.35803683 0.00029669 0.00021342 -7.33082544 0.00030370 0.00021728 -7.30361406 0.00031102 0.00022126 @@ -102,7 +102,7 @@ epsValue SpinUpDos SpinDownDos -7.19476851 0.00034371 0.00023856 -7.16755713 0.00035286 0.00024326 -7.14034574 0.00036244 0.00024814 --7.11313435 0.00037249 0.00025319 +-7.11313436 0.00037249 0.00025319 -7.08592297 0.00038306 0.00025843 -7.05871158 0.00039416 0.00026386 -7.03150020 0.00040585 0.00026950 @@ -117,7 +117,7 @@ epsValue SpinUpDos SpinDownDos -6.78659772 0.00054621 0.00033178 -6.75938634 0.00056707 0.00034029 -6.73217495 0.00058935 0.00034920 --6.70496356 0.00061320 0.00035853 +-6.70496357 0.00061320 0.00035853 -6.67775218 0.00063876 0.00036831 -6.65054079 0.00066621 0.00037858 -6.62332941 0.00069575 0.00038936 @@ -127,12 +127,12 @@ epsValue SpinUpDos SpinDownDos -6.51448386 0.00083982 0.00043849 -6.48727248 0.00088391 0.00045251 -6.46006109 0.00093204 0.00046733 --6.43284970 0.00098474 0.00048303 +-6.43284971 0.00098474 0.00048303 -6.40563832 0.00104260 0.00049969 -6.37842693 0.00110636 0.00051737 -6.35121555 0.00117684 0.00053617 -6.32400416 0.00125505 0.00055620 --6.29679277 0.00134218 0.00057757 +-6.29679278 0.00134218 0.00057757 -6.26958139 0.00143965 0.00060040 -6.24237000 0.00154921 0.00062484 -6.21515862 0.00167293 0.00065105 @@ -147,7 +147,7 @@ epsValue SpinUpDos SpinDownDos -5.97025614 0.00417416 0.00100696 -5.94304476 0.00478914 0.00106668 -5.91583337 0.00555331 0.00113253 --5.88862198 0.00651765 0.00120540 +-5.88862199 0.00651765 0.00120540 -5.86141060 0.00775585 0.00128636 -5.83419921 0.00937691 0.00137664 -5.80698783 0.01154555 0.00147778 @@ -157,7 +157,7 @@ epsValue SpinUpDos SpinDownDos -5.69814228 0.03330408 0.00203420 -5.67093090 0.04553064 0.00222699 -5.64371951 0.06100040 0.00245050 --5.61650812 0.07499292 0.00271159 +-5.61650813 0.07499292 0.00271159 -5.58929674 0.07814389 0.00301916 -5.56208535 0.06765242 0.00338485 -5.53487397 0.05186753 0.00382413 @@ -167,12 +167,12 @@ epsValue SpinUpDos SpinDownDos -5.42602842 0.01616025 0.00687422 -5.39881704 0.01274703 0.00821698 -5.37160565 0.01028257 0.00998622 --5.34439426 0.00846037 0.01236982 +-5.34439427 0.00846037 0.01236982 -5.31718288 0.00708282 0.01565873 -5.28997149 0.00602032 0.02030630 -5.26276011 0.00518605 0.02700119 -5.23554872 0.00452054 0.03667291 --5.20833733 0.00398218 0.05006324 +-5.20833734 0.00398218 0.05006324 -5.18112595 0.00354124 0.06587922 -5.15391456 0.00317610 0.07753191 -5.12670318 0.00287077 0.07611407 @@ -180,7 +180,7 @@ epsValue SpinUpDos SpinDownDos -5.07228040 0.00239432 0.04724488 -5.04506902 0.00220696 0.03457870 -5.01785763 0.00204562 0.02555994 --4.99064624 0.00190593 0.01933016 +-4.99064625 0.00190593 0.01933016 -4.96343486 0.00178442 0.01499532 -4.93622347 0.00167828 0.01191659 -4.90901209 0.00158522 0.00967722 @@ -190,12 +190,12 @@ epsValue SpinUpDos SpinDownDos -4.80016654 0.00131110 0.00498113 -4.77295516 0.00126117 0.00435915 -4.74574377 0.00121693 0.00385411 --4.71853238 0.00117776 0.00343912 +-4.71853239 0.00117776 0.00343912 -4.69132100 0.00114311 0.00309452 -4.66410961 0.00111252 0.00280569 -4.63689823 0.00108559 0.00256158 -4.60968684 0.00106197 0.00235376 --4.58247545 0.00104138 0.00217566 +-4.58247546 0.00104138 0.00217566 -4.55526407 0.00102356 0.00202217 -4.52805268 0.00100829 0.00188921 -4.50084130 0.00099539 0.00177352 @@ -205,7 +205,7 @@ epsValue SpinUpDos SpinDownDos -4.39199575 0.00096450 0.00143776 -4.36478437 0.00096139 0.00137743 -4.33757298 0.00095997 0.00132420 --4.31036159 0.00096017 0.00127724 +-4.31036160 0.00096017 0.00127724 -4.28315021 0.00096194 0.00123583 -4.25593882 0.00096525 0.00119936 -4.22872744 0.00097006 0.00116733 @@ -215,7 +215,7 @@ epsValue SpinUpDos SpinDownDos -4.11988189 0.00100418 0.00107570 -4.09267051 0.00101644 0.00106041 -4.06545912 0.00103024 0.00104770 --4.03824773 0.00104560 0.00103741 +-4.03824774 0.00104560 0.00103741 -4.01103635 0.00106256 0.00102939 -3.98382496 0.00108118 0.00102351 -3.95661358 0.00110152 0.00101966 @@ -225,7 +225,7 @@ epsValue SpinUpDos SpinDownDos -3.84776803 0.00120162 0.00102309 -3.82055665 0.00123182 0.00102840 -3.79334526 0.00126433 0.00103543 --3.76613387 0.00129932 0.00104417 +-3.76613388 0.00129932 0.00104417 -3.73892249 0.00133693 0.00105463 -3.71171110 0.00137735 0.00106682 -3.68449972 0.00142080 0.00108076 @@ -240,17 +240,17 @@ epsValue SpinUpDos SpinDownDos -3.43959724 0.00199780 0.00129436 -3.41238586 0.00209055 0.00132962 -3.38517447 0.00219133 0.00136769 --3.35796308 0.00230103 0.00140878 +-3.35796309 0.00230103 0.00140878 -3.33075170 0.00242070 0.00145311 -3.30354031 0.00255154 0.00150092 -3.27632893 0.00269494 0.00155250 -3.24911754 0.00285251 0.00160816 --3.22190615 0.00302614 0.00166825 +-3.22190616 0.00302614 0.00166825 -3.19469477 0.00321806 0.00173319 -3.16748338 0.00343088 0.00180342 -3.14027200 0.00366770 0.00187945 -3.11306061 0.00393226 0.00196188 --3.08584922 0.00422900 0.00205137 +-3.08584923 0.00422900 0.00205137 -3.05863784 0.00456333 0.00214868 -3.03142645 0.00494183 0.00225467 -3.00421507 0.00537257 0.00237035 @@ -270,35 +270,35 @@ epsValue SpinUpDos SpinDownDos -2.62325566 0.03613230 0.00624226 -2.59604428 0.04569838 0.00687438 -2.56883289 0.05918842 0.00761164 --2.54162150 0.07859475 0.00847844 +-2.54162151 0.07859475 0.00847844 -2.51441012 0.10665473 0.00950655 -2.48719873 0.14577167 0.01073801 -2.45998735 0.19301654 0.01222916 -2.43277596 0.23032879 0.01405687 --2.40556457 0.23026930 0.01632783 +-2.40556458 0.23026930 0.01632783 -2.37835319 0.19290504 0.01919303 -2.35114180 0.14569530 0.02287074 --2.32393041 0.10664011 0.02768338 +-2.32393042 0.10664011 0.02768338 -2.29671903 0.07863782 0.03411794 -2.26950764 0.05928006 0.04292456 -2.24229626 0.04583147 0.05527203 -2.21508487 0.03630227 0.07296173 --2.18787348 0.02938855 0.09857236 +-2.18787349 0.02938855 0.09857236 -2.16066210 0.02425368 0.13484601 -2.13345071 0.02035668 0.18102739 -2.10623933 0.01734126 0.22357612 -2.07902794 0.01496763 0.23454111 --2.05181655 0.01307078 0.20421368 --2.02460517 0.01153479 0.15696133 +-2.05181656 0.01307078 0.20421368 +-2.02460517 0.01153479 0.15696132 -1.99739378 0.01027653 0.11517237 -1.97018240 0.00923539 0.08456199 -1.94297101 0.00836635 0.06332634 --1.91575962 0.00763554 0.04861985 +-1.91575963 0.00763554 0.04861985 -1.88854824 0.00701711 0.03825477 -1.86133685 0.00649107 0.03077712 -1.83412547 0.00604183 0.02525275 -1.80691408 0.00565708 0.02107963 --1.77970269 0.00532703 0.01786323 +-1.77970270 0.00532703 0.01786323 -1.75249131 0.00504387 0.01533949 -1.72527992 0.00480129 0.01332767 -1.69806854 0.00459419 0.01170137 @@ -308,7 +308,7 @@ epsValue SpinUpDos SpinDownDos -1.58922299 0.00404921 0.00757484 -1.56201161 0.00397155 0.00691739 -1.53480022 0.00391413 0.00635587 --1.50758883 0.00387600 0.00587360 +-1.50758884 0.00387600 0.00587360 -1.48037745 0.00385658 0.00545745 -1.45316606 0.00385555 0.00509694 -1.42595468 0.00387291 0.00478367 @@ -323,18 +323,18 @@ epsValue SpinUpDos SpinDownDos -1.18105220 0.00501790 0.00328796 -1.15384082 0.00529740 0.00321779 -1.12662943 0.00562333 0.00316118 --1.09941804 0.00600341 0.00311742 +-1.09941805 0.00600341 0.00311742 -1.07220666 0.00644729 0.00308591 -1.04499527 0.00696709 0.00306629 -1.01778389 0.00757817 0.00305828 -0.99057250 0.00830019 0.00306182 --0.96336111 0.00915858 0.00307693 +-0.96336112 0.00915858 0.00307693 -0.93614973 0.01018663 0.00310383 -0.90893834 0.01142850 0.00314285 -0.88172696 0.01294367 0.00319451 -0.85451557 0.01481353 0.00325949 --0.82730418 0.01715154 0.00333868 +-0.82730419 0.01715154 0.00333868 -0.80009280 0.02011890 0.00343317 -0.77288141 0.02394959 0.00354432 -0.74567003 0.02899076 0.00367376 --0.71845864 0.03576879 0.00382351 +-0.71845864 0.03576878 0.00382351 diff --git a/tests/dft/pseudopotential/real/fccAlPert_01.prm.in b/tests/dft/pseudopotential/real/fccAlPert_01.prm.in index 2a72e79c2..1b87887b5 100644 --- a/tests/dft/pseudopotential/real/fccAlPert_01.prm.in +++ b/tests/dft/pseudopotential/real/fccAlPert_01.prm.in @@ -48,7 +48,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlNLCC.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=-0.1 end diff --git a/tests/dft/pseudopotential/real/fccAlPert_01_b.mpirun=24.output b/tests/dft/pseudopotential/real/fccAlPert_01_b.mpirun=24.output index 76e8203e1..e8ed05066 100644 --- a/tests/dft/pseudopotential/real/fccAlPert_01_b.mpirun=24.output +++ b/tests/dft/pseudopotential/real/fccAlPert_01_b.mpirun=24.output @@ -76,12 +76,12 @@ epsValue Dos -7.39147830 0.00042918 -7.36426692 0.00043699 -7.33705553 0.00044507 --7.30984415 0.00045341 +-7.30984414 0.00045341 -7.28263276 0.00046203 -7.25542137 0.00047096 -7.22820999 0.00048019 -7.20099860 0.00048975 --7.17378722 0.00049965 +-7.17378721 0.00049965 -7.14657583 0.00050992 -7.11936444 0.00052057 -7.09215306 0.00053163 @@ -131,12 +131,12 @@ epsValue Dos -5.89485207 0.00266855 -5.86764069 0.00286116 -5.84042930 0.00307751 --5.81321792 0.00332170 +-5.81321791 0.00332170 -5.78600653 0.00359877 -5.75879514 0.00391493 -5.73158376 0.00427794 -5.70437237 0.00469752 --5.67716099 0.00518609 +-5.67716098 0.00518609 -5.64994960 0.00575959 -5.62273821 0.00643878 -5.59552683 0.00725107 @@ -179,7 +179,7 @@ epsValue Dos -4.58870554 0.00385846 -4.56149416 0.00361234 -4.53428277 0.00339754 --4.50707139 0.00320941 +-4.50707138 0.00320941 -4.47986000 0.00304414 -4.45264861 0.00289858 -4.42543723 0.00277014 @@ -234,7 +234,7 @@ epsValue Dos -3.09207931 0.00393631 -3.06486793 0.00411674 -3.03765654 0.00431279 --3.01044516 0.00452619 +-3.01044515 0.00452619 -2.98323377 0.00475896 -2.95602238 0.00501339 -2.92881100 0.00529216 @@ -273,11 +273,11 @@ epsValue Dos -2.03083526 0.40933521 -2.00362387 0.31490079 -1.97641249 0.23113865 --1.94920110 0.16972350 +-1.94920110 0.16972349 -1.92198971 0.12711059 -1.89477833 0.09760454 -1.86756694 0.07681513 --1.84035556 0.06182262 +-1.84035555 0.06182262 -1.81314417 0.05075094 -1.78593278 0.04239120 -1.75872140 0.03595135 @@ -287,7 +287,7 @@ epsValue Dos -1.64987585 0.02097282 -1.62266447 0.01877774 -1.59545308 0.01694693 --1.56824170 0.01540750 +-1.56824169 0.01540750 -1.54103031 0.01410399 -1.51381892 0.01299364 -1.48660754 0.01204314 @@ -337,7 +337,7 @@ epsValue Dos -0.28930655 0.05936077 -0.26209517 0.07346988 -0.23488378 0.09294429 --0.20767240 0.12046655 +-0.20767239 0.12046655 -0.18046101 0.16011794 -0.15324962 0.21744150 --0.12603824 0.29701539 \ No newline at end of file +-0.12603824 0.29701539 diff --git a/tests/dft/pseudopotential/real/fccAlPert_01_b.prm.in b/tests/dft/pseudopotential/real/fccAlPert_01_b.prm.in index 9aded9241..06bd54f99 100644 --- a/tests/dft/pseudopotential/real/fccAlPert_01_b.prm.in +++ b/tests/dft/pseudopotential/real/fccAlPert_01_b.prm.in @@ -48,7 +48,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlNLCC.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/fccAlPert_01_c.prm.in b/tests/dft/pseudopotential/real/fccAlPert_01_c.prm.in index 72352f7cf..563e8ab18 100644 --- a/tests/dft/pseudopotential/real/fccAlPert_01_c.prm.in +++ b/tests/dft/pseudopotential/real/fccAlPert_01_c.prm.in @@ -44,7 +44,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlNLCC.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/fccAlPert_01_d.mpirun=24.output b/tests/dft/pseudopotential/real/fccAlPert_01_d.mpirun=24.output index e5f366689..271b4f45f 100644 --- a/tests/dft/pseudopotential/real/fccAlPert_01_d.mpirun=24.output +++ b/tests/dft/pseudopotential/real/fccAlPert_01_d.mpirun=24.output @@ -39,7 +39,7 @@ SCF iterations converged to the specified tolerance after: 22 iterations. Energy computations (Hartree) ------------------- - Total energy: -8.98497952 + Total energy: -8.98497929 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/real/fccAlPert_01_d.prm.in b/tests/dft/pseudopotential/real/fccAlPert_01_d.prm.in index cb73ebf51..53ad32bb7 100644 --- a/tests/dft/pseudopotential/real/fccAlPert_01_d.prm.in +++ b/tests/dft/pseudopotential/real/fccAlPert_01_d.prm.in @@ -44,7 +44,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlNLCC.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=-0.1 end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01.prm.in index b6399007d..db31d6302 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_b.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_b.prm.in index a6dccd4dc..a4106bde2 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_b.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_b.prm.in @@ -59,7 +59,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_c.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_c.prm.in index 94ca99b61..6f6ad21b2 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_c.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_c.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_d.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_d.prm.in index 4fdba1c09..8f58d0478 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_d.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_d.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_e.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_e.prm.in index 9c6fc8501..89bbe03d6 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_e.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_e.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_f.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_f.prm.in index 38d062305..5ef6e92a5 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_f.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_f.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_g.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_g.prm.in index 6774b5a3d..9cd9ddf36 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_g.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_g.prm.in @@ -65,7 +65,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_h.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_h.prm.in index b6399007d..db31d6302 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_h.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_h.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_l.mpirun=8.output b/tests/dft/pseudopotential/real/hcpMgPrim_01_l.mpirun=8.output index 608341dcb..bb7dd183d 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_l.mpirun=8.output +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_l.mpirun=8.output @@ -36,7 +36,7 @@ SCF iterations converged to the specified tolerance after: 15 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.31672356 + Total energy: -138.31672389 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_l.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_l.prm.in index 95f9d6c42..790b24563 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_l.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_l.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_m.mpirun=8.output b/tests/dft/pseudopotential/real/hcpMgPrim_01_m.mpirun=8.output index fcccd3d80..a7dc68c3f 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_m.mpirun=8.output +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_m.mpirun=8.output @@ -36,7 +36,7 @@ SCF iterations converged to the specified tolerance after: 12 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.31672439 + Total energy: -138.31672389 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_m.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_m.prm.in index 79a2df427..f08c9ab73 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_m.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_m.prm.in @@ -64,7 +64,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.4 end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_s.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_s.prm.in index a49300c87..c6fc80c77 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_s.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_s.prm.in @@ -58,7 +58,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_01_t.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_01_t.prm.in index 93c8c52d8..341dec835 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_01_t.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_01_t.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_02.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_02.prm.in index 1ec03af82..b92d1a599 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_02.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_02.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_02_b.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_02_b.prm.in index 54d147d7f..3c8459ca6 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_02_b.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_02_b.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_03.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_03.prm.in index 02f629b32..05d46207e 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_03.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_03.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_03_b.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_03_b.prm.in index 678679744..54345ebf3 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_03_b.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_03_b.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_03_c.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_03_c.prm.in index 309e1b592..45f945d9b 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_03_c.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_03_c.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end subsection Parallelization diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_03_d.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_03_d.prm.in index 926f4a9e2..5852d767e 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_03_d.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_03_d.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end subsection Parallelization diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_03_e.mpirun=5.output b/tests/dft/pseudopotential/real/hcpMgPrim_03_e.mpirun=5.output index 9d9652b35..1d8d6b144 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_03_e.mpirun=5.output +++ b/tests/dft/pseudopotential/real/hcpMgPrim_03_e.mpirun=5.output @@ -36,7 +36,7 @@ SCF iterations converged to the specified tolerance after: 10 iterations. Energy computations (Hartree) ------------------- - Total energy: -138.81281953 + Total energy: -138.81282039 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_03_e.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_03_e.prm.in index 4bc507133..bc74e248b 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_03_e.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_03_e.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set SPIN POLARIZATION=1 set START MAGNETIZATION=0.2 end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_05.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_05.prm.in index b2a0bbde7..7fc3c9a94 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_05.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_05.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/hcpMgPrim_05_b.prm.in b/tests/dft/pseudopotential/real/hcpMgPrim_05_b.prm.in index 4c51ff68a..01cba60aa 100644 --- a/tests/dft/pseudopotential/real/hcpMgPrim_05_b.prm.in +++ b/tests/dft/pseudopotential/real/hcpMgPrim_05_b.prm.in @@ -60,7 +60,7 @@ subsection DFT functional parameters set PSEUDOPOTENTIAL CALCULATION =true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoAlONCV.inp set PSEUDO TESTS FLAG = true - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE end diff --git a/tests/dft/pseudopotential/real/mdAlNVE_01.prm.in b/tests/dft/pseudopotential/real/mdAlNVE_01.prm.in index 4267e78f4..f11f66756 100644 --- a/tests/dft/pseudopotential/real/mdAlNVE_01.prm.in +++ b/tests/dft/pseudopotential/real/mdAlNVE_01.prm.in @@ -23,7 +23,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/aluminumMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/mdAlNVT_01.prm.in b/tests/dft/pseudopotential/real/mdAlNVT_01.prm.in index 84646d8c5..f446add7a 100644 --- a/tests/dft/pseudopotential/real/mdAlNVT_01.prm.in +++ b/tests/dft/pseudopotential/real/mdAlNVT_01.prm.in @@ -23,7 +23,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/aluminumMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/mdAlNVT_02.prm.in b/tests/dft/pseudopotential/real/mdAlNVT_02.prm.in index 3549b795a..d5a5ae573 100644 --- a/tests/dft/pseudopotential/real/mdAlNVT_02.prm.in +++ b/tests/dft/pseudopotential/real/mdAlNVT_02.prm.in @@ -23,7 +23,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/aluminumMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/methanepsp_01.prm.in b/tests/dft/pseudopotential/real/methanepsp_01.prm.in index 8e76b59b1..183b4c468 100644 --- a/tests/dft/pseudopotential/real/methanepsp_01.prm.in +++ b/tests/dft/pseudopotential/real/methanepsp_01.prm.in @@ -35,7 +35,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoMethaneNLCC.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/methanepsp_01_b.prm.in b/tests/dft/pseudopotential/real/methanepsp_01_b.prm.in index c446d5cc0..4e2c961fc 100644 --- a/tests/dft/pseudopotential/real/methanepsp_01_b.prm.in +++ b/tests/dft/pseudopotential/real/methanepsp_01_b.prm.in @@ -35,7 +35,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 5 + set EXCHANGE CORRELATION TYPE = GGA-RPBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoMethaneNLCC.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/nebH3.mpirun=16.output b/tests/dft/pseudopotential/real/nebH3.mpirun=16.output index ad0f0c897..7ed085f25 100644 --- a/tests/dft/pseudopotential/real/nebH3.mpirun=16.output +++ b/tests/dft/pseudopotential/real/nebH3.mpirun=16.output @@ -3,16 +3,16 @@ ----------------------------------------------------------------------- NEB STEP: 0 ----------------------------------------------------------------------- ---> Activation Energy (meV): 2.1965e+02 -<-- Activation Energy (meV): 2.1967e+02 +--> Activation Energy (meV): 2.1971e+02 +<-- Activation Energy (meV): 2.1971e+02 ----------------------------------------------------------------------- NEB STEP: 1 ----------------------------------------------------------------------- ---> Activation Energy (meV): 2.1965e+02 -<-- Activation Energy (meV): 2.1967e+02 +--> Activation Energy (meV): 2.1971e+02 +<-- Activation Energy (meV): 2.1971e+02 ----------------------------------------------------------------------- NEB STEP: 2 ----------------------------------------------------------------------- ---> Activation Energy (meV): 2.1965e+02 -<-- Activation Energy (meV): 2.1967e+02 +--> Activation Energy (meV): 2.1971e+02 +<-- Activation Energy (meV): 2.1971e+02 Optimization Criteria Met!! diff --git a/tests/dft/pseudopotential/real/nebH3.prm.in b/tests/dft/pseudopotential/real/nebH3.prm.in index e7b2260c2..2843609ed 100644 --- a/tests/dft/pseudopotential/real/nebH3.prm.in +++ b/tests/dft/pseudopotential/real/nebH3.prm.in @@ -23,7 +23,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/H3NEB_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/tests/dft/pseudopotential/real/nitrogenAtomCharged_01.prm.in b/tests/dft/pseudopotential/real/nitrogenAtomCharged_01.prm.in index ee3c97289..348b31a5d 100644 --- a/tests/dft/pseudopotential/real/nitrogenAtomCharged_01.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenAtomCharged_01.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_01.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_01.prm.in index fc65f3cf9..c8e9cd618 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_01.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_01.prm.in @@ -39,7 +39,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_02.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_02.prm.in index 47efb9b34..4077ab276 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_02.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_02.prm.in @@ -39,7 +39,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_02_b.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_02_b.prm.in index 6057bdf01..b721567a9 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_02_b.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_02_b.prm.in @@ -38,7 +38,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_02_c.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_02_c.prm.in index 0aa4f3c59..6a0ee4ab3 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_02_c.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_02_c.prm.in @@ -38,7 +38,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_02_d.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_02_d.prm.in index 72b9c9e3b..8bda772ad 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_02_d.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_02_d.prm.in @@ -40,7 +40,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_02_e.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_02_e.prm.in index 16258f6e8..f7c9cffcf 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_02_e.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_02_e.prm.in @@ -33,7 +33,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_02_erestart.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_02_erestart.prm.in index 7aa6f2759..161a72da6 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_02_erestart.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_02_erestart.prm.in @@ -33,7 +33,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03.prm.in index 3809b2720..b038f4e07 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_b.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_b.prm.in index 3259a6f0f..3de06c853 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_b.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_b.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_c.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_c.prm.in index 02e1c8ceb..92c9ca8e2 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_c.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_c.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_d.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_d.prm.in index 3259a6f0f..3de06c853 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_d.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_d.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_e.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_e.prm.in index d94e059cf..a619f263c 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_e.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_e.prm.in @@ -34,7 +34,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_g.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_g.prm.in index 852e3d55b..03de314d0 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_g.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_g.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_h.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_h.prm.in index 7e118f191..5627cf6b0 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_h.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_h.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_i.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_i.prm.in index f5f3d20ed..fa40f8c89 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_i.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_i.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_j.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_j.prm.in index dc433e964..a551e5d6d 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_j.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_j.prm.in @@ -31,7 +31,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_03_l.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_03_l.prm.in index f04c9ffce..bc5399fe8 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_03_l.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_03_l.prm.in @@ -32,7 +32,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_md.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_md.prm.in index 9bf5c5894..fdc5cb853 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_md.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_md.prm.in @@ -40,7 +40,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/tests/dft/pseudopotential/real/nitrogenMolecule_mdrestart.prm.in b/tests/dft/pseudopotential/real/nitrogenMolecule_mdrestart.prm.in index bcd8b6f0b..1a3c51d31 100644 --- a/tests/dft/pseudopotential/real/nitrogenMolecule_mdrestart.prm.in +++ b/tests/dft/pseudopotential/real/nitrogenMolecule_mdrestart.prm.in @@ -40,7 +40,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDO TESTS FLAG = true set PSEUDOPOTENTIAL FILE NAMES LIST = @SOURCE_DIR@/pseudoNGGA.inp diff --git a/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_4 b/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_4 index 37260f3a9..f364f1c56 100644 --- a/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_4 +++ b/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_4 @@ -66,15 +66,15 @@ SCF iterations converged to the specified tolerance after: 39 iterations. Energy computations (Hartree) ------------------- - Total energy: -1673.56610253 + Total energy: -1673.56610064 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- AtomId 0: 0.000820,0.001893,0.012176 AtomId 1: 0.001957,0.000000,0.000544 AtomId 2: 0.000000,0.001558,0.141588 -AtomId 3: 0.000050,0.000000,0.001169 -AtomId 4: 0.000591,0.001197,0.010672 +AtomId 3: 0.000051,0.000000,0.001169 +AtomId 4: 0.000591,0.001197,0.010671 AtomId 5: 0.002144,0.000000,0.000842 AtomId 6: 0.000000,0.000888,0.144486 AtomId 7: 0.000007,0.000000,0.001077 @@ -90,10 +90,10 @@ AtomId 16: 0.000820,0.001893,0.012176 AtomId 17: 0.001957,0.000000,0.000544 AtomId 18: 0.000059,0.001056,0.143329 AtomId 19: 0.000039,0.000000,0.000261 -AtomId 20: 0.000591,0.001197,0.010672 +AtomId 20: 0.000591,0.001197,0.010671 AtomId 21: 0.002144,0.000000,0.000842 AtomId 22: 0.000059,0.001259,0.144065 -AtomId 23: 0.000007,0.000000,0.000709 +AtomId 23: 0.000007,0.000000,0.000710 AtomId 24: 0.000820,0.001893,0.012176 AtomId 25: 0.000298,0.000000,0.001856 AtomId 26: 0.000059,0.001056,0.143329 diff --git a/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_7 b/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_7 index 37260f3a9..f364f1c56 100644 --- a/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_7 +++ b/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_7 @@ -66,15 +66,15 @@ SCF iterations converged to the specified tolerance after: 39 iterations. Energy computations (Hartree) ------------------- - Total energy: -1673.56610253 + Total energy: -1673.56610064 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- AtomId 0: 0.000820,0.001893,0.012176 AtomId 1: 0.001957,0.000000,0.000544 AtomId 2: 0.000000,0.001558,0.141588 -AtomId 3: 0.000050,0.000000,0.001169 -AtomId 4: 0.000591,0.001197,0.010672 +AtomId 3: 0.000051,0.000000,0.001169 +AtomId 4: 0.000591,0.001197,0.010671 AtomId 5: 0.002144,0.000000,0.000842 AtomId 6: 0.000000,0.000888,0.144486 AtomId 7: 0.000007,0.000000,0.001077 @@ -90,10 +90,10 @@ AtomId 16: 0.000820,0.001893,0.012176 AtomId 17: 0.001957,0.000000,0.000544 AtomId 18: 0.000059,0.001056,0.143329 AtomId 19: 0.000039,0.000000,0.000261 -AtomId 20: 0.000591,0.001197,0.010672 +AtomId 20: 0.000591,0.001197,0.010671 AtomId 21: 0.002144,0.000000,0.000842 AtomId 22: 0.000059,0.001259,0.144065 -AtomId 23: 0.000007,0.000000,0.000709 +AtomId 23: 0.000007,0.000000,0.000710 AtomId 24: 0.000820,0.001893,0.012176 AtomId 25: 0.000298,0.000000,0.001856 AtomId 26: 0.000059,0.001056,0.143329 diff --git a/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_8 b/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_8 index e8474b169..051f7391a 100644 --- a/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_8 +++ b/testsGPU/pseudopotential/complex/accuracyBenchmarks/outputMg2x_8 @@ -62,93 +62,82 @@ Reading initial guess for electron-density..... Pseudopotential initalization.... Starting SCF iterations.... -Energy residual : 2.8460e+01 -Energy residual : 2.2528e+01 -Energy residual : 2.1117e+00 -Energy residual : 9.6181e-01 -Energy residual : 2.5866e-01 -Energy residual : 1.4833e-01 -Energy residual : 5.0433e-02 -Energy residual : 7.0491e-02 -Energy residual : 6.3258e-02 -Energy residual : 4.8374e-02 -Energy residual : 3.6016e-02 -Energy residual : 3.6163e-02 -Energy residual : 3.1624e-02 -Energy residual : 2.6834e-02 -Energy residual : 1.6281e-02 -Energy residual : 1.3537e-02 -Energy residual : 6.1284e-03 -Energy residual : 3.8847e-03 -Energy residual : 9.1916e-04 -Energy residual : 4.9047e-04 -Energy residual : 2.3086e-04 -Energy residual : 4.0514e-04 -Energy residual : 3.5866e-04 -Energy residual : 3.0853e-04 -Energy residual : 1.3754e-04 -Energy residual : 2.2222e-04 -Energy residual : 1.5146e-04 -Energy residual : 1.1316e-04 -Energy residual : 1.0185e-04 -Energy residual : 7.0003e-05 -Energy residual : 4.6342e-05 -Energy residual : 2.7636e-05 -Energy residual : 1.5984e-05 -Energy residual : 3.3789e-06 -Energy residual : 1.0235e-05 -Energy residual : 5.1345e-06 -Energy residual : 6.5343e-06 -Energy residual : 4.0463e-06 -Energy residual : 1.8893e-06 -Energy residual : 4.4723e-07 -Energy residual : 3.5242e-07 -Energy residual : 7.1301e-07 -Energy residual : 6.6343e-07 -Energy residual : 5.2183e-07 -Energy residual : 2.3832e-07 -Energy residual : 2.5120e-07 -Energy residual : 1.5266e-07 -Energy residual : 1.1084e-07 -Energy residual : 7.5416e-08 -Energy residual : 4.2787e-08 -SCF iterations converged to the specified tolerance after: 50 iterations. +Energy residual : 9.0617e-01 +Energy residual : 6.3686e-01 +Energy residual : 1.9503e+00 +Energy residual : 8.8894e-01 +Energy residual : 2.8522e-01 +Energy residual : 7.8816e-02 +Energy residual : 1.0592e-04 +Energy residual : 2.8668e-04 +Energy residual : 9.0853e-05 +Energy residual : 1.8207e-04 +Energy residual : 8.3803e-05 +Energy residual : 1.0515e-04 +Energy residual : 3.7551e-05 +Energy residual : 1.2536e-05 +Energy residual : 9.4266e-05 +Energy residual : 5.8270e-05 +Energy residual : 2.8180e-05 +Energy residual : 6.3595e-07 +Energy residual : 3.1844e-07 +Energy residual : 1.5547e-07 +Energy residual : 4.8372e-07 +Energy residual : 7.0483e-07 +Energy residual : 1.3964e-07 +Energy residual : 5.4906e-08 +Energy residual : 6.7099e-08 +Energy residual : 4.7286e-08 +Energy residual : 3.7581e-08 +Energy residual : 1.1046e-08 +Energy residual : 1.8336e-10 +Energy residual : 5.0715e-10 +Energy residual : 3.0443e-10 +Energy residual : 1.4737e-09 +Energy residual : 1.6431e-09 +Energy residual : 2.5899e-10 +Energy residual : 6.0060e-10 +Energy residual : 6.1211e-10 +Energy residual : 4.4511e-10 +Energy residual : 3.1256e-10 +Energy residual : 6.3364e-11 +SCF iterations converged to the specified tolerance after: 39 iterations. Energy computations (Hartree) ------------------- - Total energy: -1673.56610057 + Total energy: -1673.56610064 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- -AtomId 0: 0.000820,0.001892,0.012176 +AtomId 0: 0.000820,0.001893,0.012176 AtomId 1: 0.001957,0.000000,0.000544 AtomId 2: 0.000000,0.001558,0.141588 -AtomId 3: 0.000050,0.000000,0.001169 -AtomId 4: 0.000591,0.001197,0.010672 +AtomId 3: 0.000051,0.000000,0.001169 +AtomId 4: 0.000591,0.001197,0.010671 AtomId 5: 0.002144,0.000000,0.000842 -AtomId 6: 0.000000,0.000888,0.144485 -AtomId 7: 0.000007,0.000000,0.001078 -AtomId 8: 0.000820,0.001892,0.012176 -AtomId 9: 0.000298,0.000000,0.001855 +AtomId 6: 0.000000,0.000888,0.144486 +AtomId 7: 0.000007,0.000000,0.001077 +AtomId 8: 0.000820,0.001893,0.012176 +AtomId 9: 0.000298,0.000000,0.001856 AtomId 10: 0.000000,0.001558,0.141588 AtomId 11: 0.000007,0.000000,0.000027 -AtomId 12: 0.000591,0.001197,0.010672 -AtomId 13: 0.000615,0.000000,0.002027 -AtomId 14: 0.000000,0.000889,0.144485 +AtomId 12: 0.000591,0.001197,0.010671 +AtomId 13: 0.000615,0.000000,0.002028 +AtomId 14: 0.000000,0.000888,0.144486 AtomId 15: 0.000048,0.000000,0.001309 -AtomId 16: 0.000820,0.001892,0.012176 +AtomId 16: 0.000820,0.001893,0.012176 AtomId 17: 0.001957,0.000000,0.000544 AtomId 18: 0.000059,0.001056,0.143329 AtomId 19: 0.000039,0.000000,0.000261 -AtomId 20: 0.000591,0.001197,0.010672 +AtomId 20: 0.000591,0.001197,0.010671 AtomId 21: 0.002144,0.000000,0.000842 -AtomId 22: 0.000059,0.001258,0.144065 +AtomId 22: 0.000059,0.001259,0.144065 AtomId 23: 0.000007,0.000000,0.000710 -AtomId 24: 0.000820,0.001892,0.012176 -AtomId 25: 0.000298,0.000000,0.001855 +AtomId 24: 0.000820,0.001893,0.012176 +AtomId 25: 0.000298,0.000000,0.001856 AtomId 26: 0.000059,0.001056,0.143329 AtomId 27: 0.000007,0.000000,0.000171 -AtomId 28: 0.000591,0.001197,0.010672 -AtomId 29: 0.000615,0.000000,0.002027 -AtomId 30: 0.000059,0.001258,0.144065 +AtomId 28: 0.000591,0.001197,0.010671 +AtomId 29: 0.000615,0.000000,0.002028 +AtomId 30: 0.000059,0.001259,0.144065 -------------------------------------------------------------------------------------------- diff --git a/testsGPU/pseudopotential/complex/parameterFileBe.prm b/testsGPU/pseudopotential/complex/parameterFileBe.prm index 9fbad2ef9..c1c19d382 100644 --- a/testsGPU/pseudopotential/complex/parameterFileBe.prm +++ b/testsGPU/pseudopotential/complex/parameterFileBe.prm @@ -33,7 +33,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoBe.inp end diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_1.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_1.prm index 46666f50e..2aae7d537 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_1.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_1.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_2.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_2.prm index 4d2295b82..db5ce71ae 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_2.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_2.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_3.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_3.prm index 9aae19560..ce7a13e37 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_3.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_3.prm @@ -21,7 +21,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_4.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_4.prm index 2b5061d05..9aa2aa923 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_4.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_4.prm @@ -21,7 +21,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp set SPIN POLARIZATION=1 diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_5.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_5.prm index a41a02adf..f14b59f48 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_5.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_5.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_6.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_6.prm index 715f0256b..f0c3c45dd 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_6.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_6.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_7.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_7.prm index 3a13a0bb2..429814560 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_7.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_7.prm @@ -21,7 +21,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp set SPIN POLARIZATION=1 diff --git a/testsGPU/pseudopotential/complex/parameterFileMg2x_8.prm b/testsGPU/pseudopotential/complex/parameterFileMg2x_8.prm index ec9136862..f89ab786b 100644 --- a/testsGPU/pseudopotential/complex/parameterFileMg2x_8.prm +++ b/testsGPU/pseudopotential/complex/parameterFileMg2x_8.prm @@ -21,7 +21,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp set SPIN POLARIZATION=1 diff --git a/testsGPU/pseudopotential/real/Input_MD_0.prm b/testsGPU/pseudopotential/real/Input_MD_0.prm index 0566d22e3..a5abe9916 100644 --- a/testsGPU/pseudopotential/real/Input_MD_0.prm +++ b/testsGPU/pseudopotential/real/Input_MD_0.prm @@ -24,7 +24,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = aluminumMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/testsGPU/pseudopotential/real/Input_MD_1.prm b/testsGPU/pseudopotential/real/Input_MD_1.prm index f26cd9b1b..e022a5449 100644 --- a/testsGPU/pseudopotential/real/Input_MD_1.prm +++ b/testsGPU/pseudopotential/real/Input_MD_1.prm @@ -24,7 +24,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = aluminumMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/testsGPU/pseudopotential/real/Input_MD_2.prm b/testsGPU/pseudopotential/real/Input_MD_2.prm index 847336add..b30597532 100644 --- a/testsGPU/pseudopotential/real/Input_MD_2.prm +++ b/testsGPU/pseudopotential/real/Input_MD_2.prm @@ -24,7 +24,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = aluminumMD_pseudo.inp set PSEUDO TESTS FLAG = true diff --git a/testsGPU/pseudopotential/real/accuracyBenchmarks/outputMg2x_1_spin_gpu b/testsGPU/pseudopotential/real/accuracyBenchmarks/outputMg2x_1_spin_gpu index 58bcfdd64..6587e82f5 100644 --- a/testsGPU/pseudopotential/real/accuracyBenchmarks/outputMg2x_1_spin_gpu +++ b/testsGPU/pseudopotential/real/accuracyBenchmarks/outputMg2x_1_spin_gpu @@ -65,7 +65,7 @@ SCF iterations converged to the specified tolerance after: 37 iterations. Energy computations (Hartree) ------------------- - Total energy: -1666.91407024 + Total energy: -1666.91407298 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/testsGPU/pseudopotential/real/accuracyBenchmarks/outputN2_4 b/testsGPU/pseudopotential/real/accuracyBenchmarks/outputN2_4 index 8d2f77f83..c282da746 100644 --- a/testsGPU/pseudopotential/real/accuracyBenchmarks/outputN2_4 +++ b/testsGPU/pseudopotential/real/accuracyBenchmarks/outputN2_4 @@ -34,7 +34,7 @@ SCF iterations converged to the specified tolerance after: 13 iterations. Energy computations (Hartree) ------------------- - Total energy: -19.66693762 + Total energy: -19.66693754 Absolute values of ion forces (Hartree/Bohr) -------------------------------------------------------------------------------------------- diff --git a/testsGPU/pseudopotential/real/parameterFileBe.prm b/testsGPU/pseudopotential/real/parameterFileBe.prm index babe8f6ff..a1e12cd91 100644 --- a/testsGPU/pseudopotential/real/parameterFileBe.prm +++ b/testsGPU/pseudopotential/real/parameterFileBe.prm @@ -33,7 +33,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoBe.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_1.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_1.prm index 46ce9e21d..ea4698d3b 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_1.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_1.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_10.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_10.prm index 21b3a2018..9b4846e36 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_10.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_10.prm @@ -22,7 +22,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_11.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_11.prm index 3e31b8db3..847878d24 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_11.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_11.prm @@ -20,7 +20,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_12.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_12.prm index 9fb15cac1..7a443663f 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_12.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_12.prm @@ -18,7 +18,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_13.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_13.prm index 25b2016a5..c11b810a3 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_13.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_13.prm @@ -18,7 +18,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_14.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_14.prm index 0693d47a4..c7ab254d1 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_14.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_14.prm @@ -13,7 +13,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_15.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_15.prm index 426c4a5c3..f806aeac0 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_15.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_15.prm @@ -13,7 +13,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_16.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_16.prm index 73f2f30e3..fdc7c5b2e 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_16.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_16.prm @@ -20,7 +20,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_1_spingpu.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_1_spingpu.prm index 21e964fc0..edc67051c 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_1_spingpu.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_1_spingpu.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp set SPIN POLARIZATION=1 diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_2.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_2.prm index f3428aefe..529416faa 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_2.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_2.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_3.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_3.prm index df9fdc77e..96be11554 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_3.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_3.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_4.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_4.prm index d9304bc4c..0f224ec80 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_4.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_4.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_5.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_5.prm index e232a4043..f882ab60b 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_5.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_5.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_6.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_6.prm index 852c74a99..0e981cc66 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_6.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_6.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_7.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_7.prm index 82eef12a2..f68095c10 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_7.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_7.prm @@ -19,7 +19,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_8.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_8.prm index 4c8a77493..d755e9f67 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_8.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_8.prm @@ -20,7 +20,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileMg2x_9.prm b/testsGPU/pseudopotential/real/parameterFileMg2x_9.prm index 88054d764..dc2efb042 100644 --- a/testsGPU/pseudopotential/real/parameterFileMg2x_9.prm +++ b/testsGPU/pseudopotential/real/parameterFileMg2x_9.prm @@ -20,7 +20,7 @@ end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudoMg.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileN2_1.prm b/testsGPU/pseudopotential/real/parameterFileN2_1.prm index 7c224c064..01f9d9a1d 100644 --- a/testsGPU/pseudopotential/real/parameterFileN2_1.prm +++ b/testsGPU/pseudopotential/real/parameterFileN2_1.prm @@ -36,7 +36,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileN2_2.prm b/testsGPU/pseudopotential/real/parameterFileN2_2.prm index a287f66a6..712e7e0e7 100644 --- a/testsGPU/pseudopotential/real/parameterFileN2_2.prm +++ b/testsGPU/pseudopotential/real/parameterFileN2_2.prm @@ -36,7 +36,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileN2_3.prm b/testsGPU/pseudopotential/real/parameterFileN2_3.prm index 3678f49bf..8a664ff27 100644 --- a/testsGPU/pseudopotential/real/parameterFileN2_3.prm +++ b/testsGPU/pseudopotential/real/parameterFileN2_3.prm @@ -36,7 +36,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/testsGPU/pseudopotential/real/parameterFileN2_4.prm b/testsGPU/pseudopotential/real/parameterFileN2_4.prm index 58cb9b577..b21802b9b 100644 --- a/testsGPU/pseudopotential/real/parameterFileN2_4.prm +++ b/testsGPU/pseudopotential/real/parameterFileN2_4.prm @@ -37,7 +37,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp set SPIN POLARIZATION = 1 diff --git a/testsGPU/pseudopotential/real/parameterFileN2_5.prm b/testsGPU/pseudopotential/real/parameterFileN2_5.prm index 40cdec9d5..30e949cbf 100644 --- a/testsGPU/pseudopotential/real/parameterFileN2_5.prm +++ b/testsGPU/pseudopotential/real/parameterFileN2_5.prm @@ -36,7 +36,7 @@ subsection Finite element mesh parameters end subsection DFT functional parameters - set EXCHANGE CORRELATION TYPE = 4 + set EXCHANGE CORRELATION TYPE = GGA-PBE set PSEUDOPOTENTIAL CALCULATION = true set PSEUDOPOTENTIAL FILE NAMES LIST = pseudo.inp end diff --git a/utils/FiniteDifference.cc b/utils/FiniteDifference.cc new file mode 100644 index 000000000..b5b152002 --- /dev/null +++ b/utils/FiniteDifference.cc @@ -0,0 +1,622 @@ +#include +#include +#include +#include "Exceptions.h" + +namespace dftfe +{ + namespace utils + { + std::vector + FiniteDifference::getStencilGridOneVariableCentral( + const unsigned int totalStencilSize, + const double h) + { + std::vector stencil(totalStencilSize, 0); + + std::string errMsg = "Stencil size invalid. "; + dftfe::utils::throwException(totalStencilSize > 2 && + totalStencilSize % 2 == 1, + errMsg); + + for (unsigned int i = 0; i < totalStencilSize; i++) + stencil[i] = (-std::floor(totalStencilSize / 2) * h + i * h); + + return stencil; + } + + + void + FiniteDifference::firstOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * firstOrderDerivative) + { + std::string errMsg = "Stencil size invalid. "; + dftfe::utils::throwException(totalStencilSize > 2 && + totalStencilSize % 2 == 1, + errMsg); + + switch (totalStencilSize) + { + case 3: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (-1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2]) / + (2.0 * h); + } + break; + case 5: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 8.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 8.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4]) / + (12.0 * h); + } + break; + case 7: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (-1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 9.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 45.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 45.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 9.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6]) / + (60.0 * h); + } + break; + case 9: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (3.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 32.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 168 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 672.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 672.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] - + 168.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] + + 32.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 3.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8]) / + (840.0 * h); + } + break; + case 11: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (-2.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 25.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 150 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 2100.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] + + 2100.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] - + 600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] + + 150.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] - + 25.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] + + 2.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10]) / + (2520.0 * h); + } + break; + case 13: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (5.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 72.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 495.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 2200.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 23760.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 23760.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] + + 2200.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] - + 495.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10] + + 72.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 11] - + 5.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 12]) / + (27720.0 * h); + } + break; + default: + std::string errMsg = "Stencil size not implemented. "; + dftfe::utils::throwException(false, errMsg); + break; + } + } + + void + FiniteDifference::firstOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double * h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * firstOrderDerivative) + { + std::string errMsg = "Stencil size invalid. "; + dftfe::utils::throwException(totalStencilSize > 2 && + totalStencilSize % 2 == 1, + errMsg); + + switch (totalStencilSize) + { + case 3: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (-1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2]) / + (2.0 * h[iquad]); + } + break; + case 5: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 8.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 8.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4]) / + (12.0 * h[iquad]); + } + break; + case 7: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (-1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 9.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 45.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 45.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 9.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6]) / + (60.0 * h[iquad]); + } + break; + case 9: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (3.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 32.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 168 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 672.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 672.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] - + 168.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] + + 32.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 3.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8]) / + (840.0 * h[iquad]); + } + break; + case 11: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (-2.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 25.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 150 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 2100.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] + + 2100.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] - + 600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] + + 150.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] - + 25.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] + + 2.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10]) / + (2520.0 * h[iquad]); + } + break; + case 13: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + firstOrderDerivative[iquad] = + (5.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 72.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 495.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 2200.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 23760.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 23760.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] + + 2200.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] - + 495.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10] + + 72.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 11] - + 5.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 12]) / + (27720.0 * h[iquad]); + } + break; + default: + std::string errMsg = "Stencil size not implemented. "; + dftfe::utils::throwException(false, errMsg); + break; + } + } + + void + FiniteDifference::secondOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * secondOrderDerivative) + { + std::string errMsg = "Stencil size invalid. "; + dftfe::utils::throwException(totalStencilSize > 2 && + totalStencilSize % 2 == 1, + errMsg); + + switch (totalStencilSize) + { + case 3: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 2.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2]) / + (h * h); + } + break; + case 5: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (-1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 16.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 30.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 16.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + -1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4]) / + (12.0 * h * h); + } + break; + case 7: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (2.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 27.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 270.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 490.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 270.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 27.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 2.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6]) / + (180.0 * h * h); + } + break; + case 9: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (-9.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 128.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 1008.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 8064.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 14350.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] + + 8064.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] - + 1008.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] + + 128.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 9.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8]) / + (5040.0 * h * h); + } + break; + case 11: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (8.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 125.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 1000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 6000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 42000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 73766.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 42000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] - + 6000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] + + 1000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] - + 125.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] + + 125.0 * 8.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10]) / + (25200.0 * h * h); + } + break; + case 13: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (-50.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 864.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 44000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 222750.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] + + 1425600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] - + 2480478.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] + + 1425600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 222750.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] + + 44000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] - + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10] + + 864.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 11] - + 50.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 12]) / + (831600.0 * h * h); + } + break; + default: + std::string errMsg = "Stencil size not implemented. "; + dftfe::utils::throwException(false, errMsg); + break; + } + } + + void + FiniteDifference::secondOrderDerivativeOneVariableCentral( + const unsigned int totalStencilSize, + const double * h, + const unsigned int numQuadPoints, + const double * stencilDataAllQuadPoints, + double * secondOrderDerivative) + { + std::string errMsg = "Stencil size invalid. "; + dftfe::utils::throwException(totalStencilSize > 2 && + totalStencilSize % 2 == 1, + errMsg); + + switch (totalStencilSize) + { + case 3: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 2.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2]) / + (h[iquad] * h[iquad]); + } + break; + case 5: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (-1.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 16.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 30.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 16.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + -1.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4]) / + (12.0 * h[iquad] * h[iquad]); + } + break; + case 7: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (2.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 27.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 270.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 490.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 270.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 27.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 2.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6]) / + (180.0 * h[iquad] * h[iquad]); + } + break; + case 9: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (-9.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 128.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 1008.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 8064.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 14350.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] + + 8064.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] - + 1008.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] + + 128.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 9.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8]) / + (5040.0 * h[iquad] * h[iquad]); + } + break; + case 11: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (8.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] - + 125.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] + + 1000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] - + 6000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] + + 42000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] - + 73766.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] + + 42000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] - + 6000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] + + 1000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] - + 125.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] + + 125.0 * 8.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10]) / + (25200.0 * h[iquad] * h[iquad]); + } + break; + case 13: + for (unsigned int iquad = 0; iquad < numQuadPoints; iquad++) + { + secondOrderDerivative[iquad] = + (-50.0 * stencilDataAllQuadPoints[iquad * totalStencilSize] + + 864.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 1] - + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 2] + + 44000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 3] - + 222750.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 4] + + 1425600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 5] - + 2480478.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 6] + + 1425600.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 7] - + 222750.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 8] + + 44000.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 9] - + 7425.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 10] + + 864.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 11] - + 50.0 * + stencilDataAllQuadPoints[iquad * totalStencilSize + 12]) / + (831600.0 * h[iquad] * h[iquad]); + } + break; + default: + std::string errMsg = "Stencil size not implemented. "; + dftfe::utils::throwException(false, errMsg); + break; + } + } + + } // namespace utils +} // namespace dftfe diff --git a/utils/dftParameters.cc b/utils/dftParameters.cc index 5b012fd32..fbb42e54d 100644 --- a/utils/dftParameters.cc +++ b/utils/dftParameters.cc @@ -630,16 +630,28 @@ namespace dftfe prm.declare_entry( "EXCHANGE CORRELATION TYPE", - "1", - dealii::Patterns::Integer(1, 8), - R"([Standard] Parameter specifying the type of exchange-correlation to be used: 1(LDA: Perdew Zunger Ceperley Alder correlation with Slater Exchange[PRB. 23, 5048 (1981)]), 2(LDA: Perdew-Wang 92 functional with Slater Exchange [PRB. 45, 13244 (1992)]), 3(LDA: Vosko, Wilk \& Nusair with Slater Exchange[Can. J. Phys. 58, 1200 (1980)]), 4(GGA: Perdew-Burke-Ernzerhof functional [PRL. 77, 3865 (1996)], 5(RPBE: B. Hammer, L. B. Hansen, and J. K. Nørskov, Phys. Rev. B 59, 7413 (1999)), 6(ML-XC NNLDA: LDA-PW + NN), 7(ML-XC NNGGA: GGA-PBE + NN). Caution: options 6-7 are experimental and only accessible to the DFT-FE developers currently.)"); + "GGA-PBE", + dealii::Patterns::Selection( + "LDA-PZ|LDA-PW|LDA-VWN|GGA-PBE|GGA-RPBE|MLXC-NNLDA|MLXC-NNGGA|MLXC-NNLLMGGA"), + R"([Standard] Parameter specifying the type of exchange-correlation to be used: LDA-PZ (Perdew Zunger Ceperley Alder correlation with Slater Exchange[PRB. 23, 5048 (1981)]), LDA-PW (Perdew-Wang 92 functional with Slater Exchange [PRB. 45, 13244 (1992)]), LDA-VWN (Vosko, Wilk \& Nusair with Slater Exchange[Can. J. Phys. 58, 1200 (1980)]), GGA-PBE (Perdew-Burke-Ernzerhof functional [PRL. 77, 3865 (1996)]), GGA-RPBE (RPBE: B. Hammer, L. B. Hansen, and J. K. Nørskov, Phys. Rev. B 59, 7413 (1999)), MLXC-NNLDA (LDA-PW + NN-LDA), MLXC-NNGGA (GGA-PBE + NN-GGA), MLXC-NNLLMGGA (GGA-PBE + NN Laplacian level MGGA). Caution: MLXC options are experimental.)"); prm.declare_entry( "MODEL XC INPUT FILE", "", dealii::Patterns::Anything(), - "[Developer] File that contains both the pytorch ML-XC NN model (.ptc file) and the tolerances. This is an experimental feature to test out any new XC functional developed using machine learning."); + "[Developer] File that contains both the pytorch MLXC NN model (.ptc file) and the tolerances. This is an experimental feature to test out any new XC functional developed using machine learning."); + + prm.declare_entry( + "AUX BASIS TYPE", + "FE", + dealii::Patterns::Selection("FE|SLATER|PW"), + "[Developer] Auxiliary basis for projecting the Kohn-Sham density or density matrix for XC evaluation. FE is the default option."); + prm.declare_entry( + "AUX BASIS DATA", + "", + dealii::Patterns::Anything(), + "[Developer] File that contains additional information for the Auxiliary basis selected in AUX BASIS TYPE."); prm.declare_entry( "NET CHARGE", @@ -1163,9 +1175,11 @@ namespace dftfe finiteElementPolynomialOrderElectrostatics = 1; n_refinement_steps = 1; numberEigenValues = 1; - xc_id = 1; + XCType = "GGA-PBE"; spinPolarized = 0; modelXCInputFile = ""; + auxBasisTypeXC = ""; + auxBasisDataXC = ""; nkx = 1; nky = 1; nkz = 1; @@ -1556,9 +1570,11 @@ namespace dftfe isPseudopotential = prm.get_bool("PSEUDOPOTENTIAL CALCULATION"); pseudoTestsFlag = prm.get_bool("PSEUDO TESTS FLAG"); pseudoPotentialFile = prm.get("PSEUDOPOTENTIAL FILE NAMES LIST"); - xc_id = prm.get_integer("EXCHANGE CORRELATION TYPE"); + XCType = prm.get("EXCHANGE CORRELATION TYPE"); spinPolarized = prm.get_integer("SPIN POLARIZATION"); modelXCInputFile = prm.get("MODEL XC INPUT FILE"); + auxBasisTypeXC = prm.get("AUX BASIS TYPE"); + auxBasisDataXC = prm.get("AUX BASIS DATA"); start_magnetization = prm.get_double("START MAGNETIZATION"); pspCutoffImageCharges = prm.get_double("PSP CUTOFF IMAGE CHARGES"); netCharge = prm.get_double("NET CHARGE");