Skip to content

Commit

Permalink
Merged in mlxcSlaterTest (pull request #617)
Browse files Browse the repository at this point in the history
MlxcSlaterTest

Approved-by: Vishal Subramanian
  • Loading branch information
dsambit committed Aug 27, 2024
2 parents 6cae63e + c9000ee commit b423e5b
Show file tree
Hide file tree
Showing 64 changed files with 4,295 additions and 2,854 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ SET(TARGET_SRC
./src/excManager/excDensityGGAClass.cpp
./src/excManager/excDensityLLMGGAClass.cpp
./src/excManager/excManager.cpp
./src/excManager/AuxDensityMatrixAtomicBasis.cpp
./src/excManager/AuxDensityMatrixFE.cpp
./src/excManager/ExcDFTPlusU.cpp
./src/excManager/AuxDensityMatrixSlater.cpp
./src/excManager/AtomicBasisData.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/excManager/AtomicBasisData.cpp
./src/excManager/SlaterBasis.cpp
./src/excManager/GaussianBasis.cpp
./src/poisson/poissonSolverProblem.cc
./src/poisson/MultiVectorPoissonLinearSolverProblem.cpp
./src/helmholtz/kerkerSolverProblem.cc
Expand Down Expand Up @@ -123,6 +124,8 @@ SET(TARGET_SRC
./utils/QuadDataCompositeWrite.cpp
./utils/PeriodicTable.cc
./utils/FiniteDifference.cc
./utils/StringOperations.cpp
./utils/SphericalFunctionUtil.cpp
./src/dft/dftd.cc
./src/mdi/MDIEngine.cpp
./src/mdi/libraryMDI.cpp
Expand Down
66 changes: 66 additions & 0 deletions include/AtomicBasis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// ---------------------------------------------------------------------
//
// 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 Bikash Kanungo
//

#ifndef DFTFE_ATOMICBASIS_H
#define DFTFE_ATOMICBASIS_H

#include <vector>
#include <unordered_map>
#include <string>
#include <utility>

namespace dftfe
{
class AtomicBasis
{
public:
enum class BasisType
{
SLATER,
GAUSSIAN,
BESSELORTHO
};

// Default destructor
~AtomicBasis() = default;

virtual void
constructBasisSet(
const std::vector<std::pair<std::string, std::vector<double>>>
&atomCoords,
const std::unordered_map<std::string, std::string>
&atomBasisFileNames) = 0;

virtual int
getNumBasis() const = 0;

virtual std::vector<double>
getBasisValue(const unsigned int basisId,
const std::vector<double> &x) const = 0;

virtual std::vector<double>
getBasisGradient(const unsigned int basisId,
const std::vector<double> &x) const = 0;

virtual std::vector<double>
getBasisLaplacian(const unsigned int basisId,
const std::vector<double> &x) const = 0;
};
} // namespace dftfe
#endif // DFTFE_ATOMICBASIS_H
41 changes: 41 additions & 0 deletions include/AtomicBasisData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Created by Sambit Das
//

#ifndef DFTFE_ATOMBASISDATA_H
#define DFTFE_ATOMBASISDATA_H

#include <vector>
#include <memory>
#include "AtomicBasis.h"

namespace dftfe
{
class AtomicBasisData
{
public:
/// quadpoints in Cartesian coordinates
void
evalBasisData(const std::vector<double> &quadpts,
const AtomicBasis & atomicBasis,
const unsigned int maxDerOrder);

const std::vector<double> &
getBasisValues() const;


const std::vector<double> &
getBasisGradValues() const;

const std::vector<double> &
getBasisLaplacianValues() const;


private:
// Member variables
std::vector<double> d_basisValues;
std::vector<double> d_basisGradValues;
std::vector<double> d_basisLaplacianValues;
};
} // namespace dftfe
#endif // DFTFE_ATOMBASISDATA_H
22 changes: 9 additions & 13 deletions include/AuxDensityMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ namespace dftfe
virtual void
evalOverlapMatrixEnd(const MPI_Comm &mpiComm) = 0;

// FIXME: to be extended to memoryspace
/**
* @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;
const std::unordered_map<std::string, std::vector<dataTypes::number>>
&projectionInputsDataType,
const std::unordered_map<std::string, std::vector<double>>
& projectionInputsReal,
const int iSpin) = 0;

/**
* @brief for MPI accumulation
Expand All @@ -75,23 +79,15 @@ namespace dftfe
* @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;
projectDensityStart(
const std::unordered_map<std::string, std::vector<double>>
&projectionInputs) = 0;

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

virtual void
getDensityMatrixComponents_occupancies(
const std::vector<double> &occupancies) const = 0;

virtual void
getDensityMatrixComponents_wavefunctions(
const dftfe::utils::MemoryStorage<dataTypes::number, memorySpace>
&eigenVectors) const = 0;
};
} // namespace dftfe

Expand Down
107 changes: 107 additions & 0 deletions include/AuxDensityMatrixAtomicBasis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//
// Created by Arghadwip Paul, Sambit Das
//

#ifndef DFTFE_AUXDM_AUXDENSITYMATRIXATOMICBASIS_H
#define DFTFE_AUXDM_AUXDENSITYMATRIXATOMICBASIS_H

#include "AuxDensityMatrix.h"
#include "AtomicBasis.h"
#include "AtomicBasisData.h"
#include <vector>
#include <utility>
#include <map>
#include <algorithm>


namespace dftfe
{
template <dftfe::utils::MemorySpace memorySpace>
class AuxDensityMatrixAtomicBasis : public AuxDensityMatrix<memorySpace>
{
public:
void
reinit(
const AtomicBasis::BasisType basisType,
const std::vector<std::pair<std::string, std::vector<double>>>
& atomCoords,
const std::unordered_map<std::string, std::string> &atomBasisFileNames,
const int nSpin,
const int maxDerOrder);

void
applyLocalOperations(
const std::vector<double> &quadpts,
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;

/**
*
* @param projectionInputs is a map from string to inputs needed
* for projection.
* eg - projectionInputsReal["quadpts"],
* projectionInputsReal["quadWt"],
* projectionInputsDataType["psiFunc"],
* projectionInputsReal["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.
*
*/
virtual void
projectDensityMatrixStart(
const std::unordered_map<std::string, std::vector<dataTypes::number>>
&projectionInputsDataType,
const std::unordered_map<std::string, std::vector<double>>
& projectionInputsReal,
const int iSpin) override;

void
projectDensityMatrixEnd(const MPI_Comm &mpiComm) override;

void
projectDensityStart(
const std::unordered_map<std::string, std::vector<double>>
&projectionInputs) override;

void
projectDensityEnd(const MPI_Comm &mpiComm) override;


private:
int d_nQuad;
int d_nSpin;
std::unique_ptr<AtomicBasis> d_atomicBasisPtr;
AtomicBasisData d_atomicBasisData;

int d_nBasis;
int d_maxDerOrder;

std::vector<double> d_DM;
std::vector<double> d_SMatrix;
std::vector<double> d_SMatrixInv;
std::vector<double> d_basisWFCInnerProducts;
std::vector<double> d_fValues;

int d_nWFC;
int d_iSpin;


void
evalOverlapMatrixInv();
std::vector<double> &
getOverlapMatrixInv();
};
} // namespace dftfe
#endif // DFTFE_AUXDM_AUXDENSITYMATRIXATOMICBASIS_H
40 changes: 28 additions & 12 deletions include/AuxDensityMatrixFE.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ namespace dftfe
class AuxDensityMatrixFE : public AuxDensityMatrix<memorySpace>
{
public:
// FIXME: to be implemented

void
setDensityMatrixComponents(
const dftfe::utils::MemoryStorage<dataTypes::number, memorySpace>
& eigenVectorsFlattenedMemSpace,
const std::vector<std::vector<double>> &fractionalOccupancies);



// CAUTION: points have to be a contiguous subset of d_quadPointsSet
void
applyLocalOperations(
Expand All @@ -29,10 +39,13 @@ namespace dftfe
void
evalOverlapMatrixEnd(const MPI_Comm &mpiComm) override;

void
virtual void
projectDensityMatrixStart(
std::unordered_map<std::string, std::vector<double>> &projectionInputs,
int iSpin) override;
const std::unordered_map<std::string, std::vector<dataTypes::number>>
&projectionInputsDataType,
const std::unordered_map<std::string, std::vector<double>>
& projectionInputsReal,
const int iSpin) override;

void
projectDensityMatrixEnd(const MPI_Comm &mpiComm) override;
Expand All @@ -59,22 +72,25 @@ namespace dftfe
*
*/
void
projectDensityStart(std::unordered_map<std::string, std::vector<double>>
&projectionInputs) override;
projectDensityStart(
const std::unordered_map<std::string, std::vector<double>>
&projectionInputs) override;

void
projectDensityEnd(const MPI_Comm &mpiComm) override;

void
getDensityMatrixComponents_occupancies(
const std::vector<double> &occupancies) const override;
const std::vector<std::vector<double>> *
getDensityMatrixComponents_occupancies() const;

void
getDensityMatrixComponents_wavefunctions(
const dftfe::utils::MemoryStorage<dataTypes::number, memorySpace>
&eigenVectors) const override;
const dftfe::utils::MemoryStorage<dataTypes::number, memorySpace> *
getDensityMatrixComponents_wavefunctions() const;

private:
const dftfe::utils::MemoryStorage<dataTypes::number, memorySpace>
*d_eigenVectorsFlattenedMemSpacePtr;

const std::vector<std::vector<double>> *d_fractionalOccupancies;

std::vector<double> d_densityValsTotalAllQuads;
std::vector<double> d_densityValsSpinUpAllQuads;
std::vector<double> d_densityValsSpinDownAllQuads;
Expand Down
Loading

0 comments on commit b423e5b

Please sign in to comment.