ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
deepks_pdm.h
Go to the documentation of this file.
1#ifndef DEEPKS_PDM_H
2#define DEEPKS_PDM_H
3
4#ifdef __MLALGO
5
8#include "source_base/timer.h"
12
13#include <torch/script.h>
14#include <torch/torch.h>
15
16namespace DeePKS_domain
17{
18//-------------------
19// deepks_pdm.cpp
20//-------------------
21
22// This file contains subroutines for calculating pdm,
23// which is defind as sum_mu,nu rho_mu,nu (<chi_mu|alpha><alpha|chi_nu>);
24// It also contains subroutines for printing pdm for checking purpose
25
26// There are 3 subroutines in this file:
27// 1. read_pdm, which reads pdm from file
28// 2. cal_pdm, which is used for calculating pdm
29// 3. check_pdm, which prints pdm to descriptor.dat
30
31// read pdm from file, do it only once in whole calculation
32void read_pdm(bool read_pdm_file,
33 bool is_equiv,
34 bool& init_pdm,
35 const int nat,
36 const int inlmax,
37 const int lmaxd,
38 const std::vector<int>& inl2l,
39 const Numerical_Orbital& alpha,
40 std::vector<torch::Tensor>& pdm);
41
42template <typename TK>
43void update_dmr(const std::vector<ModuleBase::Vector3<double>>& kvec_d,
44 const std::vector<std::vector<TK>>& dmk,
45 const UnitCell& ucell,
46 const LCAO_Orbitals& orb,
47 const Parallel_Orbitals& pv,
48 const Grid_Driver& GridD,
49 hamilt::HContainer<double>* dmr_deepks);
50
51// calculate projected density matrix: pdm = sum_i,occ <phi_i|alpha1><alpha2|phi_k>
52// 3 cases to skip calculation of pdm:
53// - NSCF calculation of DeePKS, init_chg = file and pdm has been read
54// - SCF calculation of DeePKS with init_chg = file and pdm has been read for restarting SCF
55// - Relax/Cell-Relax/MD calculation, non-first step will use the convergence pdm from the last step as initial pdm
56template <typename TK>
57void cal_pdm(bool& init_pdm,
58 const int inlmax,
59 const int lmaxd,
60 const std::vector<int>& inl2l,
61 const ModuleBase::IntArray* inl_index,
62 const std::vector<ModuleBase::Vector3<double>>& kvec_d,
64 const std::vector<hamilt::HContainer<double>*> phialpha,
65 const UnitCell& ucell,
66 const LCAO_Orbitals& orb,
67 const Grid_Driver& GridD,
68 const Parallel_Orbitals& pv,
69 std::vector<torch::Tensor>& pdm);
70
71void check_pdm(const int inlmax, const std::vector<int>& inl2l, const std::vector<torch::Tensor>& pdm);
72} // namespace DeePKS_domain
73
74#endif
75#endif
Definition sltk_grid_driver.h:43
Definition ORB_read.h:19
Integer array.
Definition intarray.h:20
3 elements vector
Definition vector3.h:22
Definition ORB_atomic.h:52
Definition parallel_orbitals.h:9
Definition unitcell.h:16
Definition hcontainer.h:144
Definition deepks_basic.h:14
void cal_pdm(bool &init_pdm, const int inlmax, const int lmaxd, const std::vector< int > &inl2l, const ModuleBase::IntArray *inl_index, const std::vector< ModuleBase::Vector3< double > > &kvec_d, const hamilt::HContainer< double > *dmr, const std::vector< hamilt::HContainer< double > * > phialpha, const UnitCell &ucell, const LCAO_Orbitals &orb, const Grid_Driver &GridD, const Parallel_Orbitals &pv, std::vector< torch::Tensor > &pdm)
Definition deepks_pdm.cpp:179
void update_dmr(const std::vector< ModuleBase::Vector3< double > > &kvec_d, const std::vector< std::vector< TK > > &dmk, const UnitCell &ucell, const LCAO_Orbitals &orb, const Parallel_Orbitals &pv, const Grid_Driver &GridD, hamilt::HContainer< double > *dmr_deepks)
Definition deepks_pdm.cpp:90
void read_pdm(bool read_pdm_file, bool is_equiv, bool &init_pdm, const int nat, const int inlmax, const int lmaxd, const std::vector< int > &inl2l, const Numerical_Orbital &alpha, std::vector< torch::Tensor > &pdm)
Definition deepks_pdm.cpp:28
void check_pdm(const int inlmax, const std::vector< int > &inl2l, const std::vector< torch::Tensor > &pdm)
Definition deepks_pdm.cpp:459