Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add RDMFT(Reduced Density Matrix Functional Theory) code #5325

Open
wants to merge 196 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 178 commits
Commits
Show all changes
196 commits
Select commit Hold shift + click to select a range
412a27b
first add rdmft files in abacus-v3.4.4, run 1 processor is successful…
JGHan7 Dec 20, 2023
7fb74a9
in last commit, 2 processor has 'malloc(): memory corruption:' becaus…
JGHan7 Dec 20, 2023
309294f
first push with rdmft writed in abacus-v3.4.4
JGHan7 Dec 20, 2023
507395c
update README.md
JGHan7 Dec 20, 2023
f485988
update README.md again
JGHan7 Dec 20, 2023
7eb1301
find all parameters used in Veff_rdmft (for hartree and local, XC sti…
JGHan7 Dec 20, 2023
ac14215
use class Veff_rdmft get correct Ehartree and Eexx, but Etotal is wrong
JGHan7 Dec 21, 2023
248c6f6
all energy terms correct, ETV_RDMFT = E_one_elec, Ehartree_RDMFT = E_…
JGHan7 Dec 21, 2023
64c6029
z/dgemm_() is used correctly, next step to use pz/dgemm_()
JGHan7 Dec 21, 2023
84b0af4
just one processor is correct, 2 processors have some problem and may…
JGHan7 Dec 21, 2023
d1555bd
2 processors is wrong but 6 processors is correct...
JGHan7 Dec 21, 2023
81a60cd
check 2 processors error
JGHan7 Dec 21, 2023
8690d60
update, realize print Dmn in different processors
JGHan7 Dec 22, 2023
36a5783
get successful result in different numbers of processors, and the pri…
JGHan7 Dec 22, 2023
9c3ffa5
get the sum of different processors, that is, get the true total ener…
JGHan7 Dec 22, 2023
7697eb6
delete some printout and next step is replace the pz/dgemm_() used in…
JGHan7 Dec 22, 2023
469b8d4
add some comments
JGHan7 Dec 24, 2023
57f26bc
do some little modifications to make the code more concise
JGHan7 Dec 24, 2023
f812b24
just save
JGHan7 Dec 24, 2023
6a79558
just save
JGHan7 Dec 28, 2023
12f6fae
last save before realizing gamma_only calculation
JGHan7 Dec 29, 2023
afb6f2f
gamma_only calculation with errors
JGHan7 Dec 29, 2023
21f294b
save with errors in gamma_only
JGHan7 Dec 29, 2023
7206d95
gamma_only realization with errors in E_T+nonlocal
JGHan7 Dec 30, 2023
da23b18
gamma_only successful with one processors, but multi-processor errors
JGHan7 Dec 31, 2023
bd1eaf3
support g(wg)*H_wfc and g(wg)*wfcHwfc with different g(wg) which is p…
JGHan7 Jan 11, 2024
59b792f
get the special DM used in constructing V_XC, and can be used for spl…
JGHan7 Jan 11, 2024
7e805f8
get the special DM used in constructing V_XC and run successfully (no…
JGHan7 Jan 12, 2024
eadb2a1
modify the namespace of rdmft_test files from hamilt to rdmft
JGHan7 Jan 12, 2024
bbcaa60
error with using spilt_m2D_ktoR()
JGHan7 Jan 12, 2024
48bd584
successfully get Ds_XC, next step is update abacus to have the new in…
JGHan7 Jan 12, 2024
ecb152c
merge with newest abacus-v3.5.0
JGHan7 Jan 12, 2024
2c59145
successfully run rdmft with power functional in multi-k calculation, …
JGHan7 Jan 12, 2024
b2e5cbe
do some little modifications to make the code more concise
JGHan7 Jan 13, 2024
567326c
fix interface provided by class OperatorEXX but having errors when do…
JGHan7 Jan 13, 2024
4d9423a
print data of tensor from Ds_XC
JGHan7 Jan 13, 2024
2da31a8
just save
JGHan7 Jan 13, 2024
4a8fb2f
check the length and data of LM->Hexxc and Vxc_fromRI_c.Hexxs
JGHan7 Jan 13, 2024
97893a8
have modified op_exx_lcao.h/.cpp, RI_2D_Comm.h/.cpp files, delete the…
JGHan7 Jan 14, 2024
7ebdb14
save
JGHan7 Jan 14, 2024
af7101f
successfullu add power XC_functional and run correctly with Si soilds…
JGHan7 Jan 15, 2024
727d784
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Jan 15, 2024
b109fe2
successfully realize power functional with testing Si solids, and som…
JGHan7 Jan 15, 2024
ae61ae2
Print: last push before delete many printout
JGHan7 Jan 16, 2024
4b7b65d
delete modifying in source code
JGHan7 Jan 16, 2024
c312fdf
Refactor: first add class RDMFT
JGHan7 Jan 18, 2024
c85e116
save
JGHan7 Jan 25, 2024
ef391fc
get DM used for updating charge/rho
JGHan7 Feb 27, 2024
ff3a134
try to initial DMR of class DensityMatrix
JGHan7 Feb 28, 2024
fef0f07
save before modifying gint.cpp
JGHan7 Mar 1, 2024
1cf10c7
update charge using wg&wfc which provided by me successfully
JGHan7 Mar 2, 2024
5903818
delete some comment
JGHan7 Mar 2, 2024
6b41e83
last save before transfer wg -> natural occupation numbers (occupatio…
JGHan7 Mar 4, 2024
46688de
successfully transfer wg -> occ_number and get correct result in Mull…
JGHan7 Mar 4, 2024
aa35d9f
modifying some variable names, function names and comments (for wg ->…
JGHan7 Mar 5, 2024
18f4a22
add module_rdmft and copy code here working successfully
JGHan7 Mar 7, 2024
4ab0d04
delete rdmft_test.h/.cpp files in module_hamilt_lcao/... and modify c…
JGHan7 Mar 7, 2024
ab3d552
add rdmft.h, rdmft.cpp, rdmft_tools.cpp files to create class RDMFT
JGHan7 Mar 11, 2024
d339946
just save. In the process of factor function rdmft_cal() -> class RDMFT
JGHan7 Mar 11, 2024
cb82c05
modify rdmft_solver in esolver_ks_lcao.h/.cpp
JGHan7 Mar 12, 2024
de94f6f
push with compile error in cal_dm.h( psiMulPsiMpi() function with the…
JGHan7 Mar 13, 2024
c0eb22a
add class rdmft and do rdmft_solver.init() successfully, next step is…
JGHan7 Mar 14, 2024
29462f0
successfully move functions of class RDMFT to rdmft.cpp
JGHan7 Mar 14, 2024
e1639b3
just save
JGHan7 Mar 15, 2024
c33010a
just save
JGHan7 Mar 15, 2024
e6f5cdc
factor function rdmft_cal() -> class RDMFT and with running error
JGHan7 Mar 15, 2024
55a8b39
just save
JGHan7 Mar 15, 2024
ec31ad1
Factor: transfer function rdmft_cal() -> class RDMFT and run in after…
JGHan7 Mar 16, 2024
4a18ca9
just save
JGHan7 Mar 16, 2024
fc7aa6e
now get V_local in eiter, next step move it to istep, i.e. together w…
JGHan7 Mar 16, 2024
6d97a8b
move the obtaining of V_local from elec-step to ion-step
JGHan7 Mar 16, 2024
01b486b
successfully find where to do update_ion()
JGHan7 Mar 16, 2024
ce1cd9a
class RDMFT get correct E_TV and E_hartree, but E_XC=0.0
JGHan7 Mar 16, 2024
f68a3a4
Factor: complete func rdmft_cal() -> class RDMFT and find where to us…
JGHan7 Mar 17, 2024
2016a9c
save
JGHan7 Mar 17, 2024
c8a0680
save for debug
JGHan7 Mar 19, 2024
e11009f
Fix: fix bug in HkPsi(), transfer 'T'->'C'
JGHan7 Mar 19, 2024
17faaa5
save
JGHan7 Mar 20, 2024
40da285
Fix: fix nk_total in class RDMFT depend on the Symmetry::symm_flag
JGHan7 Mar 20, 2024
f96c8c5
save
JGHan7 Mar 20, 2024
2b4ecfd
test different branch
JGHan7 Mar 22, 2024
9cb16b8
add Dell_abaInstall.sh for Dell_server
JGHan7 Apr 8, 2024
6167846
modify module_rdmft to latest version
JGHan7 Sep 6, 2024
ac00ce4
just save for updating branch rdmft
JGHan7 Sep 6, 2024
787eac6
update module_xc for rdmft(WP22,CWP22 and so on)
JGHan7 Sep 6, 2024
4f35e36
Fix memory bug in XC_Functional_Libxc::cal_gdr()
PeizeLin Oct 8, 2024
e0f5436
merge to abacus-v3.7.5, but don't debug(many, because many functions …
JGHan7 Oct 9, 2024
1e79ca3
Refactor XC_Functional_Libxc::convert_vtxc_v()
PeizeLin Oct 10, 2024
1c9712a
merge to abacus-v3.7850 but don't debug(many, because many functions …
JGHan7 Oct 10, 2024
4f0e78e
merge to abacus-v3.8.0 but don't debug(many, because many functions a…
JGHan7 Oct 10, 2024
5778743
Merge branch 'convert_vtxc_v' of https://gitee.com/linpeize/abacus-de…
JGHan7 Oct 10, 2024
802d141
merge to abacus-v3.8.0 and add scaling_factor in libxc_cpp files
JGHan7 Oct 10, 2024
85c4833
merge to abacus-v3.8.0 and debug is not finished
JGHan7 Oct 10, 2024
c1c8d76
just save
JGHan7 Oct 11, 2024
abc17af
just save
JGHan7 Oct 12, 2024
5669f69
after merging into abacus-v3.8.0, the first compilation passed, but t…
JGHan7 Oct 12, 2024
52f4412
after merging to abacus-v3.8.0, the program ran successfully for the …
JGHan7 Oct 14, 2024
24ff6a7
just save
JGHan7 Oct 15, 2024
1b2dd3a
just save
JGHan7 Oct 15, 2024
b55b13a
just save
JGHan7 Oct 16, 2024
16c4b8b
the Vexx may have error when symmetry==1, skip it and continue do my …
JGHan7 Oct 16, 2024
aa7a4d9
add parameters used in rdmft in input_parameters.h and so on
JGHan7 Oct 16, 2024
4c44b46
merge all rdmft-code to abacus-v3.8.0, next step is debug and test
JGHan7 Oct 16, 2024
fcd682b
debug now ,some energy is little different from abacus
JGHan7 Oct 17, 2024
ed133cb
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Oct 17, 2024
7649263
merge to the latest aABACUS
JGHan7 Oct 17, 2024
3cbf187
Fix the bug caused by merging the latest ABAUCS, need to test other b…
JGHan7 Oct 17, 2024
4ebc6c1
merge to ABACUS-v3.8.1, 2024-10-22
JGHan7 Oct 22, 2024
8c5ea60
just save
JGHan7 Oct 22, 2024
6441a65
add XC-functional BLYP_LIBXC and BLYP_LR to test
JGHan7 Oct 22, 2024
424efc2
stop tracking abaInstall_HZWpara.sh
JGHan7 Oct 22, 2024
55d56c7
Merge remote-tracking branch 'upstream/develop' into rdmft
JGHan7 Oct 22, 2024
d10ac66
just save
JGHan7 Oct 22, 2024
0b20c6c
just save
JGHan7 Oct 22, 2024
4058957
save
JGHan7 Oct 22, 2024
c904262
just save
JGHan7 Oct 22, 2024
755b828
modify cmake/FindELPA.cmake
JGHan7 Oct 22, 2024
06f5865
save
JGHan7 Oct 22, 2024
d18fc5c
add RDMFT(Reduced Density Matrix Functional Theory) code
JGHan7 Oct 22, 2024
0dac83c
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Oct 22, 2024
e754f5f
Merge branch 'develop' into rdmft_PR
mohanchen Oct 23, 2024
00fc015
delete lib64/ and include/
JGHan7 Oct 23, 2024
cbcfb7b
delete some production code and modify some variable/function names
JGHan7 Oct 23, 2024
490d14e
Merge branch 'develop' into rdmft_PR
mohanchen Oct 23, 2024
c24725d
save
JGHan7 Oct 23, 2024
6c0dca4
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Oct 23, 2024
3df7b0c
merge to the latest abacus
JGHan7 Oct 23, 2024
8f02b0a
merge and modify rdmft_PR branch
JGHan7 Oct 23, 2024
5259994
Merge branch 'rdmft_PR' of github.com:JGHan7/abacus-develop into rdmf…
JGHan7 Oct 23, 2024
7370ba2
just save
JGHan7 Oct 24, 2024
d9e89f0
add tests for rdmft
JGHan7 Oct 24, 2024
4e542de
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Oct 24, 2024
ab5a514
change branch from rdmft to rdmft_PR, prepare for PR
JGHan7 Oct 24, 2024
af28473
recover accidentally deleted files
JGHan7 Oct 24, 2024
641a9a0
move rdmft related functions and their calls from esolver_ks to esolv…
JGHan7 Oct 25, 2024
0040b42
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Oct 25, 2024
1c1d006
save
JGHan7 Oct 25, 2024
a45138b
save
JGHan7 Oct 25, 2024
600abc0
save
JGHan7 Oct 25, 2024
b90f546
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Oct 25, 2024
0796389
add '#ifdef __MPI', delete run_rdmft() and so on
JGHan7 Oct 25, 2024
3c13b1a
just save
JGHan7 Oct 25, 2024
d0b366c
prepare for PR
JGHan7 Oct 25, 2024
7d47d0a
prepare for PR
JGHan7 Oct 25, 2024
278ea05
Merge branch 'rdmft' into rdmft_PR
JGHan7 Oct 25, 2024
061a9c3
save
JGHan7 Oct 25, 2024
909f291
debug
JGHan7 Oct 25, 2024
4d0851d
add if(ENABLE_LCAO) in rdmft/CMakeLists.txt
JGHan7 Oct 26, 2024
7c6c782
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Oct 26, 2024
c531c38
save
JGHan7 Oct 26, 2024
32c9ecb
save
JGHan7 Oct 26, 2024
025b199
Merge branch 'rdmft' of gitlab.com:JGHan7/rdmft-abacus into rdmft
JGHan7 Oct 26, 2024
a0e7a02
prepare for PR
JGHan7 Oct 26, 2024
5223952
fix compile problem
maki49 Oct 26, 2024
c74d4c6
Merge pull request #1 from maki49/rdmft_PR
JGHan7 Oct 26, 2024
3a2d9a5
save
JGHan7 Oct 26, 2024
0803f58
modify the error in module_io/test/read_input_ptest.cpp
JGHan7 Oct 26, 2024
d2e2640
prepare for PR
JGHan7 Oct 26, 2024
588e0e4
save
JGHan7 Oct 27, 2024
e0ba750
add symmetry calculation of exx in rdmft
JGHan7 Oct 27, 2024
e23a0e9
add test in esolver_ks_lcao.cpp, function after_scf(): update exx to …
JGHan7 Oct 27, 2024
178f039
delete rdmft_test.h/.cpp
JGHan7 Oct 27, 2024
dd78eef
delete the test for exx in esolver_ks_lcao.cpp, after_scf(
JGHan7 Oct 27, 2024
0a72e69
update test with symmetry, tests/integrate/1001_NO_Si2_dzp_rdmft
JGHan7 Oct 27, 2024
28b8e58
prepare for PR
JGHan7 Oct 27, 2024
ea575ed
save
JGHan7 Oct 27, 2024
80545b8
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Oct 27, 2024
2aa8c2b
save
JGHan7 Oct 29, 2024
73a4eae
delete the new ord_file in tests/
JGHan7 Oct 29, 2024
51657ad
last save befor move cal_V_ TV/hartree/XC from rdmft.cpp to cal_V_rdm…
JGHan7 Oct 29, 2024
a4597be
last save before move the functions about update_state from rdmft.cpp…
JGHan7 Oct 29, 2024
1aca681
save
JGHan7 Oct 29, 2024
99823cf
save
JGHan7 Oct 29, 2024
9b6b43d
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Oct 29, 2024
73d97e8
prepare for PR
JGHan7 Oct 29, 2024
69551e2
Merge branch 'rdmft_PR' of github.com:JGHan7/abacus-develop into rdmf…
JGHan7 Oct 29, 2024
5a9febe
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Oct 29, 2024
f977c2d
Merge branch 'develop' into rdmft_PR
mohanchen Nov 1, 2024
3019e9a
save
JGHan7 Nov 1, 2024
65b45fb
modify ab_initio_type to bool rdmft
JGHan7 Nov 4, 2024
9f9863f
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Nov 4, 2024
b13bc06
save
JGHan7 Nov 4, 2024
e432d86
Fix: let nk_total *= nspin, in rdmft
JGHan7 Nov 4, 2024
8996e78
modified according to Mr. Chen's suggestion
JGHan7 Nov 4, 2024
9db254c
save
JGHan7 Nov 4, 2024
59371ce
prepare for PR
JGHan7 Nov 4, 2024
e1d3a77
Merge branch 'rdmft_PR' of github.com:JGHan7/abacus-develop into rdmf…
JGHan7 Nov 4, 2024
db647d7
Merge branch 'develop' into rdmft_PR
mohanchen Nov 5, 2024
7061eb7
save
JGHan7 Nov 5, 2024
50fe6d7
merge the latest abacus
JGHan7 Nov 6, 2024
cd41a28
merge the latest abacus
JGHan7 Nov 14, 2024
b8a89e0
merge the latest abacus
JGHan7 Nov 14, 2024
60403f5
Merge branch 'develop' of https://gitee.com/deepmodeling/abacus-devel…
JGHan7 Nov 14, 2024
d65e8b1
prepare for PR
JGHan7 Nov 14, 2024
64ae540
Merge branch 'rdmft_PR' of github.com:JGHan7/abacus-develop into rdmf…
JGHan7 Nov 14, 2024
aedb2fa
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,8 @@ if(ENABLE_LCAO)
hcontainer
deltaspin
numerical_atomic_orbitals
lr)
lr
rdmft)
if(USE_ELPA)
target_link_libraries(${ABACUS_BIN_NAME} genelpa)
endif()
Expand Down
20 changes: 20 additions & 0 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@
- [abs\_broadening](#abs_broadening)
- [ri\_hartree\_benchmark](#ri_hartree_benchmark)
- [aims_nbasis](#aims_nbasis)
- [Reduced Density Matrix Functional Theory](#Reduced-Density-Matrix-Functional-Theory)
- [ab\_initio\_type](#ab_initio_type)
- [rdmft\_power\_alpha](#rdmft_power_alpha)

[back to top](#full-list-of-input-keywords)
## System variables
Expand Down Expand Up @@ -3999,4 +4002,21 @@ The output files are `OUT.${suffix}/Excitation_Energy.dat` and `OUT.${suffix}/Ex
- **Description**: Atomic basis set size for each atom type (with the same order as in `STRU`) in FHI-aims.
- **Default**: {} (empty list, where ABACUS use its own basis set size)

## Reduced Density Matrix Functional Theory

ab-initio methods and the xc-functional parameters used in RDMFT.
The physical quantities that RDMFT temporarily expects to output are the kinetic energy, total energy, and 1-RDM of the system in the ground state, etc.

### ab_initio_type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, there is another keyword esolver_type, and ksdft is a possible value of it, could you check if rdmft can be a param of it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theoretically, rdmft can be a value of esolver_type.

But there are too many places in the program that involve esolver_type, which makes me think that it is dangerous to use esolver_type to express rdmft (when calculating rdmft, we usually need to run one or several steps of ksdft calculation to get the initial value, so when running rdmft, we must ensure that the ksdft program can run completely normally)

So I temporarily added the parameter ab_initio_type

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your opinion, senior sister.

In fact, the theoretical status of RDMFT and DFT is the same, but when we apply RDMFT in practice, we can use the results of one or several steps of KS as the initial value (of course, we can also use a random 1-RDM as the initial value), which requires KSDFT to run completely in the actual program.

However, in the current RDMFT implementation, I am still writing the program for variational optimization to the 1-RDM of the ground state (the optimization program of the cooperating teacher is not fully written yet), so it seems that the code I pushed up is doing some "repetitive" calculations without practical significance except for using a few new functionals.

Professor Ren meant that, because ABACUS is often refactored, I need to spend a long time to rewrite the correct rdmft code in the old version into the new version every once in a while, which is a waste of time and has no practical significance for the development of new methods. Therefore, it is recommended that I merge the rdmft code into the developer branch in time, but not release it in the user-oriented version(as long as my code itself does not affect the normal code of ABACUS, for example, when the ab_initio_type of INPUT is the default "ksdft", my code has no effect on other calculations of ABACUS), so the current rdmft module is still considered a production version.

The physical quantities that rdmft temporarily expects to output are the kinetic energy, total energy and 1-RDM of the system in the ground state (by the way, where is this document)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I mean such information can appear in the parameter description in this .md file.

The physical quantities that rdmft temporarily expects to output are the kinetic energy, total energy and 1-RDM of the system in the ground state (by the way, where is this document)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest changing " ab_initio_type" to "rdmft" and set its type to bool, and make this variable controlled by yourself. Do not invent any ambiguous variable for other developers to think they can do something new with this variable.


- **Type**: String
- **Description**: Determine the ab-initio method, ksdft or rdmft (reduced density matrix funcional theory)
- **Default**: ksdft

### rdmft_power_alpha

- **Type**: Real
- **Description**: The alpha parameter of power-functional(or other exx-type/hybrid functionals) which used in RDMFT, g(occ_number) = occ_number^alpha
- **Default**: 0.656

[back to top](#full-list-of-input-keywords)
3 changes: 3 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ add_subdirectory(module_ri)
add_subdirectory(module_parameter)
add_subdirectory(module_lr)

# add by jghan
add_subdirectory(module_rdmft)

add_library(
driver
OBJECT
Expand Down
7 changes: 7 additions & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ VPATH=./src_global:\
./module_lr/operator_casida:\
./module_lr/potentials:\
./module_lr/utils:\
./module_rdmft:\
./\

OBJS_ABACUS_PW=${OBJS_MAIN}\
Expand Down Expand Up @@ -113,6 +114,7 @@ ${OBJS_DELTASPIN}\
${OBJS_TENSOR}\
${OBJS_HSOLVER_PEXSI}\
${OBJS_LR}\
${OBJS_RDMFT}

OBJS_MAIN=main.o\
driver.o\
Expand Down Expand Up @@ -730,3 +732,8 @@ OBJS_TENSOR=tensor.o\
lr_spectrum.o\
hamilt_casida.o\
esolver_lrtd_lcao.o\

OBJS_RDMFT=rdmft.o\
rdmft_tools.o\
cal_V_rdmft.o\
update_state_rdmft.o\
4 changes: 3 additions & 1 deletion source/module_esolver/esolver_ks.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "module_hsolver/hsolver.h"
#include "module_io/cal_test.h"
#include "module_psi/psi.h"

#include <fstream>
#include <cstring>
namespace ModuleESolver
Expand Down Expand Up @@ -94,6 +93,9 @@ class ESolver_KS : public ESolver_FP

wavefunc wf;

// // TR need be std::complex<double> when NSPIN = 4
// rdmft::RDMFT<T, double> rdmft_solver; // add by jghan for rdmft calculation

// wavefunction coefficients
psi::Psi<T>* psi = nullptr;

Expand Down
89 changes: 88 additions & 1 deletion source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
#include "module_io/write_dmr.h"
#include "module_io/write_wfc_nao.h"

// test RDMFT
#include "module_rdmft/rdmft.h"
#include "module_elecstate/module_dm/cal_dm_psi.h" //temp ,delete

#include <iostream>

namespace ModuleESolver
{

Expand Down Expand Up @@ -256,7 +262,15 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(const Input_para& inp, UnitCell
this->pelec->fixed_weights(PARAM.inp.ocp_kb, PARAM.inp.nbands, PARAM.inp.nelec);
}

// 15) if kpar is not divisible by nks, print a warning

// 15) initialize rdmft, added by jghan
if( PARAM.inp.ab_initio_type == "rdmft" )
mohanchen marked this conversation as resolved.
Show resolved Hide resolved
{
rdmft_solver.init( this->GG, this->GK, this->pv, ucell, this->kv, *(this->pelec),
this->orb_, two_center_bundle_, PARAM.inp.dft_functional, PARAM.inp.rdmft_power_alpha);
}

// 16) if kpar is not divisible by nks, print a warning
if (GlobalV::KPAR_LCAO > 1)
{
if (this->kv.get_nks() % GlobalV::KPAR_LCAO != 0)
Expand Down Expand Up @@ -902,6 +916,7 @@ void ESolver_KS_LCAO<TK, TR>::update_pot(const int istep, const int iter)
{
this->pelec->cal_converged();
}

}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -939,7 +954,24 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
}
}

// 2.5) determine whether rdmft needs to get the initial value, added by jghan, 2024-10-25
int one_step_exx = false;
bool get_init_value_rdmft = false;
if( iter == 1 ) get_init_value_rdmft = true; // the case without hybrid functionals
#ifdef __EXX
if( GlobalC::exx_info.info_global.cal_exx )
{
if( this->conv_esolver ) one_step_exx = true;
// the case with hybrid functionals, calculate rdmft just after updateExx, cal once in one inner loop
if( one_step_exx ) get_init_value_rdmft = true;
else get_init_value_rdmft = false;
}
#endif

#ifdef __EXX

if( GlobalC::exx_info.info_global.cal_exx && this->conv_esolver ) one_step_exx = true;

// 3) save exx matrix
int two_level_step = GlobalC::exx_info.info_ri.real_number ? this->exd->two_level_step : this->exc->two_level_step;

Expand Down Expand Up @@ -1068,6 +1100,37 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
{
GlobalC::dftu.initialed_locale = true;
}

// 7) rdmft, added by jghan, 2024-10-25
if ( PARAM.inp.ab_initio_type == "rdmft" )
mohanchen marked this conversation as resolved.
Show resolved Hide resolved
{
ModuleBase::TITLE("RDMFT", "E & Egradient");
ModuleBase::timer::tick("RDMFT", "E & Egradient");

if( get_init_value_rdmft )
{
ModuleBase::matrix occ_number_ks(this->pelec->wg);
for(int ik=0; ik < occ_number_ks.nr; ++ik)
{
for(int inb=0; inb < occ_number_ks.nc; ++inb) occ_number_ks(ik, inb) /= this->kv.wk[ik];
}

this->rdmft_solver.update_elec(occ_number_ks, *(this->psi));
std::cout << "\n******\n" << "update elec in rdmft successfully" << "\n******\n" << std::endl;

//initialize the gradients of Etotal on occupation numbers and wfc, and set all elements to 0.
ModuleBase::matrix dE_dOccNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
psi::Psi<TK> dE_dWfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
dE_dWfc.zero_out();

double Etotal_RDMFT = this->rdmft_solver.run(dE_dOccNum, dE_dWfc);

ModuleBase::timer::tick("RDMFT", "E & Egradient");

// break;
}
}

}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -1162,6 +1225,29 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
ModuleBase::timer::tick("ESolver_KS_LCAO", "out_deepks_labels");
#endif

/******** test RDMFT *********/

// rdmft, added by jghan, 2024-10-17
if ( PARAM.inp.ab_initio_type == "rdmft" )
mohanchen marked this conversation as resolved.
Show resolved Hide resolved
{
ModuleBase::matrix occ_number_ks(this->pelec->wg);
for(int ik=0; ik < occ_number_ks.nr; ++ik)
{
for(int inb=0; inb < occ_number_ks.nc; ++inb) occ_number_ks(ik, inb) /= this->kv.wk[ik];
}
this->rdmft_solver.update_elec(occ_number_ks, *(this->psi));

//initialize the gradients of Etotal on occupation numbers and wfc, and set all elements to 0.
ModuleBase::matrix dE_dOccNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
psi::Psi<TK> dE_dWfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
dE_dWfc.zero_out();

double Etotal_RDMFT = this->rdmft_solver.run(dE_dOccNum, dE_dWfc);
}

/******** test RDMFT *********/


#ifdef __EXX
// 11) write rpa information
if (PARAM.inp.rpa)
Expand Down Expand Up @@ -1287,6 +1373,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
}
}


//------------------------------------------------------------------------------
//! the 20th,21th,22th functions of ESolver_KS_LCAO
//! mohan add 2024-05-11
Expand Down
5 changes: 5 additions & 0 deletions source/module_esolver/esolver_ks_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "module_basis/module_nao/two_center_bundle.h"
#include "module_io/output_mat_sparse.h"

// added by jghan for rdmft calculation
#include "module_rdmft/rdmft.h"

#include <memory>

namespace LR
Expand Down Expand Up @@ -78,6 +81,8 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {

TwoCenterBundle two_center_bundle_;

rdmft::RDMFT<TK, TR> rdmft_solver; // added by jghan for rdmft calculation, 2024-03-16
mohanchen marked this conversation as resolved.
Show resolved Hide resolved

// temporary introduced during removing GlobalC::ORB
LCAO_Orbitals orb_;

Expand Down
8 changes: 8 additions & 0 deletions source/module_esolver/lcao_before_scf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
}

this->p_hamilt->non_first_scf = istep;

// update in ion-step
if( PARAM.inp.ab_initio_type == "rdmft" )
{
// necessary operation of these parameters have be done with p_esolver->Init() in source/driver_run.cpp
rdmft_solver.update_ion(GlobalC::ucell, *(this->pw_rho), GlobalC::ppcell.vloc, this->sf.strucFac); // add by jghan, 2024-03-16/2024-10-08
}

return;
}

Expand Down
60 changes: 59 additions & 1 deletion source/module_hamilt_general/module_xc/xc_functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ std::vector<int> XC_Functional::func_id(1);
int XC_Functional::func_type = 0;
bool XC_Functional::use_libxc = true;
double XC_Functional::hybrid_alpha = 0.25;
std::map<int, double> XC_Functional::scaling_factor_xc = { {1, 1.0} }; // added by jghan, 2024-10-10

void XC_Functional::set_hybrid_alpha(const double alpha_in)
{
Expand Down Expand Up @@ -61,6 +62,7 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
// func_id.push_back(XC_GGA_C_PBE);

func_id.clear();
scaling_factor_xc.clear(); // added by jghan, 2024-07-07
std::string xc_func = xc_func_in;
std::transform(xc_func.begin(), xc_func.end(), xc_func.begin(), (::toupper));
if( xc_func == "LDA" || xc_func == "PZ" || xc_func == "SLAPZNOGXNOGC") //SLA+PZ
Expand Down Expand Up @@ -196,13 +198,68 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
{
// not doing anything
}
else if( xc_func == "MULLER" || xc_func == "POWER" ) // added by jghan, 2024-07-06
{
func_type = 4;
use_libxc = false;
}
#ifdef USE_LIBXC
else if( xc_func == "HSE")
{
func_id.push_back(XC_HYB_GGA_XC_HSE06);
func_type = 4;
use_libxc = true;
}
// added by jghan, 2024-07-06
else if( xc_func == "WP22")
{
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
func_type = 4;
use_libxc = true;
}
else if( xc_func == "CWP22")
{
// BLYP_XC_lr = -BLYP_XC_sr + BLYP_XC, the realization of it is in v_xc_libxc() function, xc_functional_libxc_vxc.cpp
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
func_id.push_back(XC_GGA_C_LYP); // complete LYP_C, id=131

// the scaling factor of CWP22-functionals
scaling_factor_xc[XC_GGA_X_ITYH] = -1.0;
scaling_factor_xc[XC_GGA_C_LYPR] = -1.0;
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
scaling_factor_xc[XC_GGA_X_B88] = 1.0;

func_type = 4;
use_libxc = true;
}
// just for test BLYP in libxc, added by jghan, 2024-10-22
else if( xc_func == "BLYP_LIBXC")
{
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
func_id.push_back(XC_GGA_C_LYP); // complete LYP_C, id=131
func_type = 2;
use_libxc = true;
}
else if( xc_func == "BLYP_LR")
{
// BLYP_XC_lr = -BLYP_XC_sr + BLYP_XC, the realization of it is in v_xc_libxc() function, xc_functional_libxc_vxc.cpp
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
func_id.push_back(XC_GGA_C_LYP); // complete LYP_C, id=131

// the scaling factor of BLYP_LR-functionals
scaling_factor_xc[XC_GGA_X_ITYH] = -1.0;
scaling_factor_xc[XC_GGA_C_LYPR] = -1.0;
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
scaling_factor_xc[XC_GGA_X_B88] = 1.0;

func_type = 2;
use_libxc = true;
}
#endif
else
{
Expand Down Expand Up @@ -243,7 +300,8 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
#endif

#ifndef USE_LIBXC
if(xc_func == "SCAN" || xc_func == "HSE" || xc_func == "SCAN0")
if(xc_func == "SCAN" || xc_func == "HSE" || xc_func == "SCAN0"
|| xc_func == "MULLER" || xc_func == "POWER" || xc_func == "WP22" || xc_func == "CWP22")
{
ModuleBase::WARNING_QUIT("set_xc_type","to use SCAN, SCAN0, or HSE, LIBXC is required");
}
Expand Down
8 changes: 7 additions & 1 deletion source/module_hamilt_general/module_xc/xc_functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "module_elecstate/module_charge/charge.h"
#include "module_cell/unitcell.h"

#include <map> // added by jghan, 2024-10-10

class XC_Functional
{
public:
Expand Down Expand Up @@ -80,6 +82,10 @@ class XC_Functional
//exx_hybrid_alpha for mixing exx in hybrid functional:
static double hybrid_alpha;

// added by jghan, 2024-07-07
// as a scaling factor for different xc-functionals
static std::map<int, double> scaling_factor_xc;

public:
static std::vector<int> get_func_id() { return func_id; }

Expand Down Expand Up @@ -162,7 +168,7 @@ class XC_Functional
ModulePW::PW_Basis* rhopw,
const UnitCell* ucell,
std::vector<double>& stress_gga,
const bool is_stress = 0);
const bool is_stress = false);
template <typename T, typename Device,
typename Real = typename GetTypeReal<T>::type>
static void grad_wfc(
Expand Down
Loading
Loading