Skip to content

Commit fbb27b3

Browse files
committed
update bfgs method
2 parents e394d58 + b377902 commit fbb27b3

File tree

603 files changed

+11259
-10226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

603 files changed

+11259
-10226
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ target_link_libraries(
709709
hamilt_stodft
710710
psi
711711
psi_initializer
712+
psi_overall_init
712713
esolver
713714
vdw
714715
device
@@ -724,7 +725,8 @@ if(ENABLE_LCAO)
724725
hcontainer
725726
deltaspin
726727
numerical_atomic_orbitals
727-
lr)
728+
lr
729+
rdmft)
728730
if(USE_ELPA)
729731
target_link_libraries(${ABACUS_BIN_NAME} genelpa)
730732
endif()

docs/advanced/elec_properties/hs_matrix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ We also offer the option of only calculating the overlap matrix without running
6161

6262
A file named `SR.csr` will be generated in the working directory, which contains the overlap matrix.
6363

64+
> When `nspin` is set to 1 or 2, the dimension of the overlap matrix is nlocal $\times$ nlocal, where nlocal is the total number of numerical atomic orbitals.
65+
These numerical atomic orbitals are ordered from outer to inner loop as atom, angular quantum number $l$, zeta (multiple radial orbitals corresponding to each $l$), and magnetic quantum number $m$.
66+
When `nspin` is set to 4, the dimension of the overlap matrix is (2 $\times$ nlocal) $\times$ (2 $\times$ nlocal). In this case, the numerical atomic orbitals are ordered from outer to inner loop as atom, angular quantum number $l$, zeta (multiple radial orbitals corresponding to each $l$), magnetic quantum number $m$, and npol (index of spin, ranges from 0 to 1).
67+
68+
6469
## examples
6570
We provide [examples](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/matrix_hs) of outputting the matrices. There are four examples:
6671

docs/advanced/elec_properties/position_matrix.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ Each file or each section of the appended file starts with "STEP: " followed by
1818

1919
Each block here contains the matrix for the corresponding cell. There are three columns in each block, giving the matrix elements in x, y, z directions, respectively. There are altogether nbasis * nbasis lines in each block, which emulates the matrix elements.
2020

21-
In molecular dynamics (MD) calculations, if [out_app_flag](../input_files/input-main.md#out_app_flag) is set to true, then `data-rR-tr` is written in an append manner. Otherwise, output files will be put in a separate directory, `matrix`, and named as `$x`_data-rR-tr, where `$x` is the number of MD step. In addition, The output frequency is controlled by [out_interval](../input_files/input-main.md#out_interval). For example, if we are running a 10-step MD with out_interval = 3, then `$x` will be 0, 3, 6, and 9.
21+
In molecular dynamics (MD) calculations, if [out_app_flag](../input_files/input-main.md#out_app_flag) is set to true, then `data-rR-tr` is written in an append manner. Otherwise, output files will be put in a separate directory, `matrix`, and named as `$x`_data-rR-tr, where `$x` is the number of MD step. In addition, the output frequency is controlled by [out_interval](../input_files/input-main.md#out_interval). For example, if we are running a 10-step MD with out_interval = 3, then `$x` will be 0, 3, 6, and 9.
22+
23+
## get_S
24+
We also offer the option of only calculating the position matrix without running SCF. For that purpose, in `INPUT` file we need to set the keyword [calculation](../input_files/input-main.md#calculation) to `get_S`, and [out_mat_r](../input_files/input-main.md#out_mat_r) to `true`.

docs/advanced/input_files/input-main.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@
423423
- [pexsi\_zero\_thr](#pexsi_zero_thr)
424424
- [Linear Response TDDFT](#linear-response-tddft)
425425
- [xc\_kernel](#xc_kernel)
426+
- [lr\_init\_xc\_kernel](#lr_init_xc_kernel)
426427
- [lr\_solver](#lr_solver)
427428
- [lr\_thr](#lr_thr)
428429
- [nocc](#nocc)
@@ -434,6 +435,9 @@
434435
- [abs\_broadening](#abs_broadening)
435436
- [ri\_hartree\_benchmark](#ri_hartree_benchmark)
436437
- [aims\_nbasis](#aims_nbasis)
438+
- [Reduced Density Matrix Functional Theory](#Reduced-Density-Matrix-Functional-Theory)
439+
- [rdmft](#rdmft)
440+
- [rdmft\_power\_alpha](#rdmft_power_alpha)
437441

438442
[back to top](#full-list-of-input-keywords)
439443
## System variables
@@ -988,7 +992,7 @@ calculations.
988992

989993
- **Type**: String
990994
- **Description**: In our package, the XC functional can either be set explicitly using the `dft_functional` keyword in `INPUT` file. If `dft_functional` is not specified, ABACUS will use the xc functional indicated in the pseudopotential file.
991-
On the other hand, if dft_functional is specified, it will overwrite the functional from pseudopotentials and performs calculation with whichever functional the user prefers. We further offer two ways of supplying exchange-correlation functional. The first is using 'short-hand' names such as 'LDA', 'PBE', 'SCAN'. A complete list of 'short-hand' expressions can be found in [the source code](../../../source/module_hamilt_general/module_xc/xc_functional.cpp). The other way is only available when ***compiling with LIBXC***, and it allows for supplying exchange-correlation functionals as combinations of LIBXC keywords for functional components, joined by a plus sign, for example, 'dft_functional='LDA_X_1D_EXPONENTIAL+LDA_C_1D_CSC'. The list of LIBXC keywords can be found on its [website](https://www.tddft.org/programs/libxc/functionals/). In this way, **we support all the LDA,GGA and mGGA functionals provided by LIBXC**.
995+
On the other hand, if dft_functional is specified, it will overwrite the functional from pseudopotentials and performs calculation with whichever functional the user prefers. We further offer two ways of supplying exchange-correlation functional. The first is using 'short-hand' names such as 'LDA', 'PBE', 'SCAN'. A complete list of 'short-hand' expressions can be found in [the source code](../../../source/module_hamilt_general/module_xc/xc_functional.cpp). The other way is only available when ***compiling with LIBXC***, and it allows for supplying exchange-correlation functionals as combinations of LIBXC keywords for functional components, joined by a plus sign, for example, dft_functional='LDA_X_1D_EXPONENTIAL+LDA_C_1D_CSC'. The list of LIBXC keywords can be found on its [website](https://libxc.gitlab.io/functionals/). In this way, **we support all the LDA,GGA and mGGA functionals provided by LIBXC**.
992996

993997
Furthermore, the old INPUT parameter exx_hybrid_type for hybrid functionals has been absorbed into dft_functional. Options are `hf` (pure Hartree-Fock), `pbe0`(PBE0), `hse` (Note: in order to use HSE functional, LIBXC is required). Note also that HSE has been tested while PBE0 has NOT been fully tested yet, and the maximum CPU cores for running exx in parallel is $N(N+1)/2$, with N being the number of atoms. And forces for hybrid functionals are not supported yet.
994998

@@ -1389,7 +1393,7 @@ These variables are used to control the geometry relaxation.
13891393
### relax_nmax
13901394

13911395
- **Type**: Integer
1392-
- **Description**: The maximal number of ionic iteration steps, the minimum value is 1.
1396+
- **Description**: The maximal number of ionic iteration steps. If set to 0, the code performs a quick "dry run", stopping just after initialization. This is useful to check for input correctness and to have the summary printed.
13931397
- **Default**: 1 for SCF, 50 for relax and cell-relax calcualtions
13941398

13951399
### relax_cg_thr
@@ -1717,7 +1721,7 @@ These variables are used to control the output of properties.
17171721

17181722
- **Type**: Boolean
17191723
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1720-
- **Description**: Whether to print the matrix representation of the position matrix (in Bohr) into a file named `data-rR-tr` in the directory `OUT.${suffix}`. For more information, please refer to [position_matrix.md](../elec_properties/position_matrix.md#extracting-position-matrices).
1724+
- **Description**: Whether to print the matrix representation of the position matrix (in Bohr) into a file named `data-rR-tr` in the directory `OUT.${suffix}`. If [calculation](#calculation) is set to `get_S`, the position matrix can be obtained without scf iterations. For more information, please refer to [position_matrix.md](../elec_properties/position_matrix.md#extracting-position-matrices).
17211725
- **Default**: False
17221726

17231727
### out_mat_hs2
@@ -1760,14 +1764,14 @@ The band (KS orbital) energy for each (k-point, spin, band) will be printed in t
17601764

17611765
- **Type**: Boolean
17621766
- **Availability**: Numerical atomic orbital basis
1763-
- **Description**: Whether to print Hamiltonian matrices H(R)/density matrics DM(R) in npz format. This feature does not work for gamma-only calculations. Currently only intended for internal usage.
1767+
- **Description**: Whether to print Hamiltonian matrices $H(R)$/density matrics $DM(R)$ in npz format. This feature does not work for gamma-only calculations. Currently only intended for internal usage.
17641768
- **Default**: False
17651769

17661770
### dm_to_rho
17671771

17681772
- **Type**: Boolean
17691773
- **Availability**: Numerical atomic orbital basis
1770-
- **Description**: Reads density matrix DM(R) in npz format and creates electron density on grids. This feature does not work for gamma-only calculations. Only supports serial calculations. Currently only intended for internal usage.
1774+
- **Description**: Reads density matrix $DM(R)$ in npz format and creates electron density on grids. This feature does not work for gamma-only calculations. Only supports serial calculations. Currently only intended for internal usage.
17711775
- **Default**: False
17721776

17731777
### out_app_flag
@@ -2926,7 +2930,7 @@ These variables are used to control DFT+U correlated parameters
29262930

29272931
- where $\gamma$ is a parameter that adjusts the relative weight of the error function to the derivative error function.
29282932
- **Unit**: Bohr
2929-
- **Default**: 5.0
2933+
- **Default**: 3.0
29302934

29312935
[back to top](#full-list-of-input-keywords)
29322936

@@ -3944,6 +3948,15 @@ These parameters are used to solve the excited states using. e.g. LR-TDDFT.
39443948
Currently supported: `RPA`, `LDA`, `PBE`, `HSE`, `HF`.
39453949
- **Default**: LDA
39463950

3951+
### lr_init_xc_kernel
3952+
3953+
- **Type**: String
3954+
- **Description**: The method to initalize the xc kernel.
3955+
- "default": Calculate xc kerenel ($f_\text{xc}$) from the ground-state charge density.
3956+
- "file": Read the xc kernel $f_\text{xc}$ on grid from the provided files. The following words should be the paths of ".cube" files, where the first 1 (*[nspin](#nspin)==1*) or 3 (*[nspin](#nspin)==2*, namely spin-aa, spin-ab and spin-bb) will be read in. The parameter [xc_kernel](#xc_kernel) will be invalid. Now only LDA-type kernel is supproted as the potential will be calculated by directly multiplying the transition density.
3957+
- "from_charge_file": Calculate fxc from the charge density read from the provided files. The following words should be the paths of ".cube" files, where the first [nspin]($nspin) files will be read in.
3958+
- **Default**: "default"
3959+
39473960
### lr_solver
39483961

39493962
- **Type**: String
@@ -4022,4 +4035,21 @@ The output files are `OUT.${suffix}/Excitation_Energy.dat` and `OUT.${suffix}/Ex
40224035
- **Description**: Atomic basis set size for each atom type (with the same order as in `STRU`) in FHI-aims.
40234036
- **Default**: {} (empty list, where ABACUS use its own basis set size)
40244037

4038+
## Reduced Density Matrix Functional Theory
4039+
4040+
ab-initio methods and the xc-functional parameters used in RDMFT.
4041+
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.
4042+
4043+
### rdmft
4044+
4045+
- **Type**: Boolean
4046+
- **Description**: Whether to perform rdmft calculation (reduced density matrix funcional theory)
4047+
- **Default**: false
4048+
4049+
### rdmft_power_alpha
4050+
4051+
- **Type**: Real
4052+
- **Description**: The alpha parameter of power-functional(or other exx-type/hybrid functionals) which used in RDMFT, g(occ_number) = occ_number^alpha
4053+
- **Default**: 0.656
4054+
40254055
[back to top](#full-list-of-input-keywords)

examples/bsse/water/result.ref

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-13.31798074740440
2-
E_H2O: -466.1225988776397
3-
E_O: -427.6271689751553
4-
E_H1: -12.58872469295076
5-
E_H2: -12.58872446212924
1+
-13.49968292248493
2+
E_H2O: -466.1225988772539
3+
E_O: -427.5222287307378
4+
E_H1: -12.55034372743879
5+
E_H2: -12.55034349659238

examples/scf/lcao_Cu/INPUT

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ orbital_dir ../../../tests/PP_ORB
44
nbands 10
55

66
calculation scf
7-
ecutwfc 100
87
ecutwfc 100 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
98
scf_thr 1.0e-8
109
scf_nmax 100

source/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ add_subdirectory(module_ri)
1818
add_subdirectory(module_parameter)
1919
add_subdirectory(module_lr)
2020

21+
# add by jghan
22+
add_subdirectory(module_rdmft)
23+
2124
add_library(
2225
driver
2326
OBJECT

source/Makefile.Objects

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ VPATH=./src_global:\
7474
./module_lr/operator_casida:\
7575
./module_lr/potentials:\
7676
./module_lr/utils:\
77+
./module_rdmft:\
7778
./\
7879

7980
OBJS_ABACUS_PW=${OBJS_MAIN}\
@@ -115,6 +116,7 @@ ${OBJS_DELTASPIN}\
115116
${OBJS_TENSOR}\
116117
${OBJS_HSOLVER_PEXSI}\
117118
${OBJS_LR}\
119+
${OBJS_RDMFT}
118120

119121
OBJS_MAIN=main.o\
120122
driver.o\
@@ -226,9 +228,9 @@ OBJS_ELECSTAT=elecstate.o\
226228
H_Hartree_pw.o\
227229
H_TDDFT_pw.o\
228230
pot_xc.o\
231+
cal_ux.o\
229232

230233
OBJS_ELECSTAT_LCAO=elecstate_lcao.o\
231-
elecstate_lcao_tddft.o\
232234
elecstate_lcao_cal_tau.o\
233235
density_matrix.o\
234236
density_matrix_io.o\
@@ -246,18 +248,13 @@ OBJS_ESOLVER=esolver.o\
246248
esolver_of.o\
247249
esolver_of_tool.o\
248250
esolver_of_interface.o\
249-
pw_init_after_vc.o\
250-
pw_init_globalc.o\
251251
pw_others.o\
252252

253253
OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
254254
esolver_ks_lcao_tddft.o\
255-
dpks_cal_e_delta_band.o\
256-
set_matrix_grid.o\
257255
lcao_before_scf.o\
258256
esolver_gets.o\
259257
lcao_others.o\
260-
lcao_init_after_vc.o\
261258

262259
OBJS_GINT=gint.o\
263260
gint_gamma_env.o\
@@ -318,7 +315,7 @@ OBJS_HAMILT_LCAO=hamilt_lcao.o\
318315
op_dftu_lcao.o\
319316
deepks_lcao.o\
320317
op_exx_lcao.o\
321-
sc_lambda_lcao.o\
318+
dspin_lcao.o\
322319
dftu_lcao.o\
323320

324321
OBJS_HCONTAINER=base_matrix.o\
@@ -407,9 +404,7 @@ OBJS_PSI_INITIALIZER=psi_initializer.o\
407404
psi_initializer_nao.o\
408405
psi_initializer_nao_random.o\
409406

410-
OBJS_PW=fft.o\
411-
fft_bundle.o\
412-
fft_base.o\
407+
OBJS_PW=fft_bundle.o\
413408
fft_cpu.o\
414409
pw_basis.o\
415410
pw_basis_k.o\
@@ -445,7 +440,6 @@ OBJS_SURCHEM=surchem.o\
445440
cal_totn.o\
446441
cal_vcav.o\
447442
cal_vel.o\
448-
corrected_energy.o\
449443
minimize_cg.o\
450444
sol_force.o\
451445

@@ -674,7 +668,7 @@ OBJS_SRCPW=H_Ewald_pw.o\
674668
symmetry_rhog.o\
675669
wavefunc.o\
676670
wf_atomic.o\
677-
wfinit.o\
671+
psi_init.o\
678672
elecond.o\
679673
sto_tool.o\
680674
sto_elecond.o\
@@ -699,14 +693,11 @@ OBJS_DFTU=dftu.o\
699693
dftu_hamilt.o
700694

701695
OBJS_DELTASPIN=basic_funcs.o\
702-
cal_h_lambda.o\
703696
cal_mw_from_lambda.o\
704-
cal_mw_helper.o\
705697
cal_mw.o\
706698
init_sc.o\
707699
lambda_loop_helper.o\
708700
lambda_loop.o\
709-
sc_parse_json.o\
710701
spin_constrain.o\
711702
template_helpers.o\
712703

@@ -733,8 +724,13 @@ OBJS_TENSOR=tensor.o\
733724
dmr_complex.o\
734725
operator_lr_hxc.o\
735726
operator_lr_exx.o\
736-
kernel_xc.o\
727+
xc_kernel.o\
737728
pot_hxc_lrtd.o\
738729
lr_spectrum.o\
739730
hamilt_casida.o\
740731
esolver_lrtd_lcao.o\
732+
733+
OBJS_RDMFT=rdmft.o\
734+
rdmft_tools.o\
735+
rdmft_pot.o\
736+
update_state_rdmft.o\

source/driver.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ Driver::Driver()
1919

2020
Driver::~Driver()
2121
{
22-
// Release the device memory within singleton object GlobalC::ppcell
23-
// before the main function exits.
24-
GlobalC::ppcell.release_memory();
2522
}
2623

2724
void Driver::init()
@@ -183,7 +180,7 @@ void Driver::atomic_world()
183180
//--------------------------------------------------
184181

185182
// where the actual stuff is done
186-
this->driver_run();
183+
this->driver_run(GlobalC::ucell);
187184

188185
ModuleBase::timer::finish(GlobalV::ofs_running);
189186
ModuleBase::Memory::print_all(GlobalV::ofs_running);

source/driver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef DRIVER_H
22
#define DRIVER_H
33

4+
#include "module_cell/unitcell.h"
5+
46
class Driver
57
{
68
public:
@@ -34,7 +36,7 @@ class Driver
3436
void atomic_world();
3537

3638
// the actual calculations
37-
void driver_run();
39+
void driver_run(UnitCell& ucell);
3840
};
3941

4042
#endif

0 commit comments

Comments
 (0)