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
6#include "deepks_param.h"
9#include "source_base/timer.h"
13
14#include <torch/script.h>
15#include <torch/torch.h>
16
17namespace DeePKS_domain
18{
19//-------------------
20// deepks_pdm.cpp
21//-------------------
22
23// This file contains subroutines for calculating pdm,
24// which is defind as sum_mu,nu rho_mu,nu (<chi_mu|alpha><alpha|chi_nu>);
25// It also contains subroutines for printing pdm for checking purpose
26
27// There are 3 subroutines in this file:
28// 1. read_pdm, which reads pdm from file
29// 2. cal_pdm, which is used for calculating pdm
30// 3. check_pdm, which prints pdm to descriptor.dat
31
32// read pdm from file, do it only once in whole calculation
33void read_pdm(bool read_pdm_file,
34 bool is_equiv,
35 bool& init_pdm,
36 const int nat,
37 const DeePKS_Param& deepks_param,
38 const Numerical_Orbital& alpha,
39 std::vector<torch::Tensor>& pdm);
40
41template <typename TK>
42void update_dmr(const std::vector<ModuleBase::Vector3<double>>& kvec_d,
43 const std::vector<std::vector<TK>>& dmk,
44 const UnitCell& ucell,
45 const LCAO_Orbitals& orb,
46 const Parallel_Orbitals& pv,
47 const Grid_Driver& GridD,
48 hamilt::HContainer<double>* dmr_deepks);
49
50// calculate projected density matrix: pdm = sum_i,occ <phi_i|alpha1><alpha2|phi_k>
51// 3 cases to skip calculation of pdm:
52// - NSCF calculation of DeePKS, init_chg = file and pdm has been read
53// - SCF calculation of DeePKS with init_chg = file and pdm has been read for restarting SCF
54// - Relax/Cell-Relax/MD calculation, non-first step will use the convergence pdm from the last step as initial pdm
55template <typename TK>
56void cal_pdm(bool& init_pdm,
57 const DeePKS_Param& deepks_param,
58 const std::vector<ModuleBase::Vector3<double>>& kvec_d,
60 const std::vector<hamilt::HContainer<double>*> phialpha,
61 const UnitCell& ucell,
62 const LCAO_Orbitals& orb,
63 const Grid_Driver& GridD,
64 const Parallel_Orbitals& pv,
65 std::vector<torch::Tensor>& pdm);
66
67void check_pdm(const DeePKS_Param& deepks_param, const std::vector<torch::Tensor>& pdm);
68} // namespace DeePKS_domain
69
70#endif
71#endif
Definition sltk_grid_driver.h:43
Definition ORB_read.h:19
3 elements vector
Definition vector3.h:22
Definition ORB_atomic.h:52
Definition parallel_orbitals.h:9
Definition unitcell.h:17
Definition hcontainer.h:144
Definition deepks_basic.h:15
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:88
void check_pdm(const DeePKS_Param &deepks_param, const std::vector< torch::Tensor > &pdm)
Definition deepks_pdm.cpp:454
void read_pdm(bool read_pdm_file, bool is_equiv, bool &init_pdm, const int nat, const DeePKS_Param &deepks_param, const Numerical_Orbital &alpha, std::vector< torch::Tensor > &pdm)
Definition deepks_pdm.cpp:28
void cal_pdm(bool &init_pdm, const DeePKS_Param &deepks_param, 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:177
Definition deepks_param.h:11