Skip to content

Commit

Permalink
Merged in ML-XC-LLmetaGGA (pull request #580)
Browse files Browse the repository at this point in the history
XC refactoring

Approved-by: Nikhil Kodali
Approved-by: Phani Motamarri
  • Loading branch information
dsambit committed Jul 1, 2024
2 parents ea97d31 + 854c708 commit a5bd20e
Show file tree
Hide file tree
Showing 222 changed files with 6,703 additions and 4,076 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion demo/ex1/parameterFile_a.prm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion demo/ex1/parameterFile_b.prm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion demo/ex2/parameterFile_a.prm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion demo/ex2/parameterFile_b.prm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion demo/ex3/parameterFile.prm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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\\}
Expand Down
42 changes: 37 additions & 5 deletions doc/manual/parameters.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions doc/manual/rundftfe.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
79 changes: 79 additions & 0 deletions include/AuxDensityFE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// Created by Sambit Das.
//

#ifndef DFTFE_AUXDM_AUXDENSITYFE_H
#define DFTFE_AUXDM_AUXDENSITYFE_H

#include <vector>
#include <utility>
#include <AuxDensityMatrix.h>

namespace dftfe
{
class AuxDensityFE : public AuxDensityMatrix
{
public:
// CAUTION: points have to be a contiguous subset of d_quadPointsSet
void
applyLocalOperations(
const std::vector<double> &points,
std::unordered_map<DensityDescriptorDataAttributes, std::vector<double>>
&densityData) override;

void
evalOverlapMatrixStart(const std::vector<double> &quadpts,
const std::vector<double> &quadWt) override;

void
evalOverlapMatrixEnd(const MPI_Comm &mpiComm) override;

void
projectDensityMatrixStart(
std::unordered_map<std::string, std::vector<double>> &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<std::string, std::vector<double>>
&projectionInputs) override;

void
projectDensityEnd(const MPI_Comm &mpiComm) override;


private:
std::vector<double> d_densityValsTotalAllQuads;
std::vector<double> d_densityValsSpinUpAllQuads;
std::vector<double> d_densityValsSpinDownAllQuads;
std::vector<double> d_gradDensityValsSpinUpAllQuads;
std::vector<double> d_gradDensityValsSpinDownAllQuads;
std::vector<double> d_quadPointsAll;
std::vector<double> d_quadWeightsAll;
};
} // namespace dftfe

#endif // DFTFE_AUXDM_AUXDENSITYFE_H
87 changes: 87 additions & 0 deletions include/AuxDensityMatrix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//
// Created by Arghadwip Paul.
//

#ifndef DFTFE_AUXDM_AUXDENSITYMATRIX_H
#define DFTFE_AUXDM_AUXDENSITYMATRIX_H

#include <vector>
#include <utility>
#include <map>
#include <string>
#include <unordered_map>
#include <mpi.h>

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<double> &Points,
std::unordered_map<DensityDescriptorDataAttributes, std::vector<double>>
&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<double> &quadpts,
const std::vector<double> &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<std::string, std::vector<double>> &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<std::string, std::vector<double>>
&projectionInputs) = 0;

/**
* @brief for MPI accumulation
*/
virtual void
projectDensityEnd(const MPI_Comm &mpiComm) = 0;
};
} // namespace dftfe

#endif // DFTFE_AUXDM_AUXDENSITYMATRIX_H
Loading

0 comments on commit a5bd20e

Please sign in to comment.