Skip to content

Commit

Permalink
Bug-fixes and upgrades to the Active Space Module
Browse files Browse the repository at this point in the history
- bug fixes of some incorrect indices
- extension to support UKS calculations
- implementation of an FCIDump checksum to ease testing
- addition of regression tests
- minor documentation improvements

After this PR, the active space module can be used in conjunction with HF-style calculations. This includes:

- GAPW with the ALL electron potential
- GAPW with the GTH-HF potential
- GPW with the GTH-HF potential

Regression tests for all of the above scenarios have been added in `tests/QS/regtest-as-1`.
```
% ../tools/regtesting/do_regtest -cp2kdir ../ -version sdbg -arch local -nobuild -restrictdir QS/regtest-as-1
<...>
--------------------------------- Summary --------------------------------
Number of FAILED  tests 0
Number of WRONG   tests 0
Number of CORRECT tests 26
Total number of   tests 26
GREPME 0 0 26 0 26 X

Summary: correct: 26 / 26; 3min
Status: OK
```
  • Loading branch information
mrossinek committed Dec 18, 2020
1 parent 5bf4af4 commit 6964239
Show file tree
Hide file tree
Showing 18 changed files with 1,447 additions and 164 deletions.
599 changes: 454 additions & 145 deletions src/qs_active_space_methods.F

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/qs_active_space_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ MODULE qs_active_space_types
END TYPE eri_type_eri_element_func

TYPE active_space_type
INTEGER :: nactive
INTEGER :: ninactive
INTEGER, DIMENSION(2) :: ninspin
INTEGER, DIMENSION(2) :: nelectrons
INTEGER :: nelec_active
INTEGER :: nelec_inactive
INTEGER, DIMENSION(2) :: nelec_inactive_spinwise
INTEGER, DIMENSION(2) :: nelec_total
INTEGER :: multiplicity
INTEGER :: nspins
LOGICAL :: molecule
Expand All @@ -86,7 +86,7 @@ MODULE qs_active_space_types
TYPE(mo_set_p_type), DIMENSION(:), POINTER :: mos_active
TYPE(mo_set_p_type), DIMENSION(:), POINTER :: mos_inactive
TYPE(eri_type) :: eri
TYPE(cp_fm_p_type), DIMENSION(:), POINTER :: p_ref
TYPE(cp_fm_p_type), DIMENSION(:), POINTER :: p_active
TYPE(cp_fm_p_type), DIMENSION(:), POINTER :: ks_sub
TYPE(cp_fm_p_type), DIMENSION(:), POINTER :: vxc_sub
TYPE(cp_fm_p_type), DIMENSION(:), POINTER :: h_sub
Expand Down Expand Up @@ -118,8 +118,8 @@ END FUNCTION eri_type_eri_element_func_interface
CONTAINS

! **************************************************************************************************
!> \brief ...
!> \param active_space_env ...
!> \brief Creates an active space environment type, nullifying all quantities.
!> \param active_space_env the active space environment to be initialized
! **************************************************************************************************
SUBROUTINE create_active_space_type(active_space_env)
TYPE(active_space_type), POINTER :: active_space_env
Expand All @@ -130,15 +130,15 @@ SUBROUTINE create_active_space_type(active_space_env)

ALLOCATE (active_space_env)
NULLIFY (active_space_env%mos_active, active_space_env%mos_inactive)
NULLIFY (active_space_env%ks_sub, active_space_env%p_ref)
NULLIFY (active_space_env%ks_sub, active_space_env%p_active)
NULLIFY (active_space_env%vxc_sub, active_space_env%h_sub)
NULLIFY (active_space_env%fock_sub, active_space_env%pmat_inactive)

END SUBROUTINE create_active_space_type

! **************************************************************************************************
!> \brief ...
!> \param active_space_env ...
!> \brief Releases all quantities in the active space environment.
!> \param active_space_env the active space environment to be released
! **************************************************************************************************
SUBROUTINE release_active_space_type(active_space_env)
TYPE(active_space_type), POINTER :: active_space_env
Expand All @@ -163,11 +163,11 @@ SUBROUTINE release_active_space_type(active_space_env)

CALL release_eri_type(active_space_env%eri)

IF (ASSOCIATED(active_space_env%p_ref)) THEN
DO isp = 1, SIZE(active_space_env%p_ref)
CALL cp_fm_release(active_space_env%p_ref(isp)%matrix)
IF (ASSOCIATED(active_space_env%p_active)) THEN
DO isp = 1, SIZE(active_space_env%p_active)
CALL cp_fm_release(active_space_env%p_active(isp)%matrix)
END DO
DEALLOCATE (active_space_env%p_ref)
DEALLOCATE (active_space_env%p_active)
END IF

IF (ASSOCIATED(active_space_env%ks_sub)) THEN
Expand Down Expand Up @@ -207,8 +207,8 @@ SUBROUTINE release_active_space_type(active_space_env)
END SUBROUTINE release_active_space_type

! **************************************************************************************************
!> \brief ...
!> \param eri_env ...
!> \brief Releases the ERI environment type.
!> \param eri_env the ERI environment to be released
! **************************************************************************************************
SUBROUTINE release_eri_type(eri_env)
TYPE(eri_type) :: eri_env
Expand Down Expand Up @@ -279,8 +279,8 @@ END SUBROUTINE csr_idx_from_combined

! **************************************************************************************************
!> \brief calculates index range for processor in group mp_group
!> \param nindex ...
!> \param mp_group ...
!> \param nindex the number of indices
!> \param mp_group message-passing group ID
!> \return a range tuple
!> \par History
!> 04.2016 created [JGH]
Expand Down
33 changes: 33 additions & 0 deletions tests/QS/regtest-as-1/TEST_FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# runs are executed in the same order as in this file
# the second field tells which test should be run in order to compare with the last available output
# e.g. 0 means do not compare anything, running is enough
# 1 compares the last total energy in the file
# for details see cp2k/tools/do_regtest
#
h2_gapw_2-2.inp 1 1e-12 -1.12703481947359
h2_gapw_2-2.inp 92 1e-8 4.08762365
h2_gapw_2-3.inp 1 1e-12 -1.12703481947359
h2_gapw_2-3.inp 92 1e-8 6.34129968
h2_gapw_2-4.inp 1 1e-12 -1.12703481947359
h2_gapw_2-4.inp 92 1e-8 10.57997133
h2_gapw_pp_2-2.inp 1 1e-12 -1.12609343153655
h2_gapw_pp_2-2.inp 92 1e-8 4.08439200
h2_gapw_pp_2-3.inp 1 1e-12 -1.12609343153655
h2_gapw_pp_2-3.inp 92 1e-8 6.33490411
h2_gapw_pp_2-4.inp 1 1e-12 -1.12609343153655
h2_gapw_pp_2-4.inp 92 1e-8 10.58497448
h2_gpw_pp_2-2.inp 1 1e-12 -1.12622646044780
h2_gpw_pp_2-2.inp 92 1e-8 4.08480362
h2_gpw_pp_2-3.inp 1 1e-12 -1.12622646044780
h2_gpw_pp_2-3.inp 92 1e-8 6.33542725
h2_gpw_pp_2-4.inp 1 1e-12 -1.12622646044780
h2_gpw_pp_2-4.inp 92 1e-8 10.58532335
h2o_gapw_2-2.inp 1 1e-12 -76.011970410506123
h2o_gapw_2-2.inp 92 1e-8 77.48403361
ch2_gapw_2-3.inp 1 1e-12 -38.91914381184247
ch2_gapw_2-3.inp 92 1e-8 50.38752107
ch2_gapw_pp_2-3.inp 1 1e-12 -6.51646227467145
ch2_gapw_pp_2-3.inp 92 1e-8 17.95445655
ch2_gpw_pp_2-3.inp 1 1e-12 -6.51682932586237
ch2_gpw_pp_2-3.inp 92 1e-8 17.95513412
#EOF
78 changes: 78 additions & 0 deletions tests/QS/regtest-as-1/ch2_gapw_2-3.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
&FORCE_EVAL
METHOD Quickstep
&DFT
&QS
METHOD GAPW
&END QS
UKS TRUE
MULTIPLICITY 3
&XC
&XC_FUNCTIONAL NONE
&END XC_FUNCTIONAL
&HF 1.0
&END HF
&END XC
&POISSON
POISSON_SOLVER ANALYTIC
PERIODIC NONE
&END POISSON
&MGRID
CUTOFF 500
&END MGRID
&SCF
ADDED_MOS 17
MAX_SCF 20
&PRINT
&RESTART OFF
&END RESTART
&END PRINT
&END SCF
&PRINT
&AO_MATRICES
CORE_HAMILTONIAN TRUE
KINETIC_ENERGY TRUE
POTENTIAL_ENERGY TRUE
&END AO_MATRICES
&ACTIVE_SPACE
ACTIVE_ELECTRONS 2
ACTIVE_ORBITALS 3 3
INACTIVE_ELECTRONS 3 3
ISOLATED_SYSTEM TRUE
&ERI
METHOD FULL_GPW
PERIODICITY 0 0 0
&END ERI
&ERI_GPW
CUTOFF 500
&END ERI_GPW
&FCIDUMP
FILENAME __STD_OUT__
&END FCIDUMP
&END ACTIVE_SPACE
&END PRINT
&END DFT
&SUBSYS
&CELL
ABC 6.0 6.0 6.0
PERIODIC NONE
&END CELL
&COORD
C 0.000 0.000 0.112
H 0.000 0.974 0.335
H 0.000 -0.974 -0.335
&END COORD
&KIND H
BASIS_SET 6-31G*
POTENTIAL ALL
&END KIND
&KIND C
BASIS_SET 6-31G*
POTENTIAL ALL
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
RUN_TYPE ENERGY
PRINT_LEVEL LOW
PROJECT ch2_gapw
&END GLOBAL
78 changes: 78 additions & 0 deletions tests/QS/regtest-as-1/ch2_gapw_pp_2-3.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
&FORCE_EVAL
METHOD Quickstep
&DFT
&QS
METHOD GAPW
&END QS
UKS TRUE
MULTIPLICITY 3
&XC
&XC_FUNCTIONAL NONE
&END XC_FUNCTIONAL
&HF 1.0
&END HF
&END XC
&POISSON
POISSON_SOLVER ANALYTIC
PERIODIC NONE
&END POISSON
&MGRID
CUTOFF 500
&END MGRID
&SCF
ADDED_MOS 17
MAX_SCF 20
&PRINT
&RESTART OFF
&END RESTART
&END PRINT
&END SCF
&PRINT
&AO_MATRICES
CORE_HAMILTONIAN TRUE
KINETIC_ENERGY TRUE
POTENTIAL_ENERGY TRUE
&END AO_MATRICES
&ACTIVE_SPACE
ACTIVE_ELECTRONS 2
ACTIVE_ORBITALS 3 3
INACTIVE_ELECTRONS 2 2
ISOLATED_SYSTEM TRUE
&ERI
METHOD FULL_GPW
PERIODICITY 0 0 0
&END ERI
&ERI_GPW
CUTOFF 500
&END ERI_GPW
&FCIDUMP
FILENAME __STD_OUT__
&END FCIDUMP
&END ACTIVE_SPACE
&END PRINT
&END DFT
&SUBSYS
&CELL
ABC 6.0 6.0 6.0
PERIODIC NONE
&END CELL
&COORD
C 0.000 0.000 0.112
H 0.000 0.974 0.335
H 0.000 -0.974 -0.335
&END COORD
&KIND H
BASIS_SET 6-31G*
POTENTIAL GTH-HF
&END KIND
&KIND C
BASIS_SET 6-31G*
POTENTIAL GTH-HF
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
RUN_TYPE ENERGY
PRINT_LEVEL LOW
PROJECT ch2_gapw_pp
&END GLOBAL
78 changes: 78 additions & 0 deletions tests/QS/regtest-as-1/ch2_gpw_pp_2-3.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
&FORCE_EVAL
METHOD Quickstep
&DFT
&QS
METHOD GPW
&END QS
UKS TRUE
MULTIPLICITY 3
&XC
&XC_FUNCTIONAL NONE
&END XC_FUNCTIONAL
&HF 1.0
&END HF
&END XC
&POISSON
POISSON_SOLVER ANALYTIC
PERIODIC NONE
&END POISSON
&MGRID
CUTOFF 500
&END MGRID
&SCF
ADDED_MOS 17
MAX_SCF 20
&PRINT
&RESTART OFF
&END RESTART
&END PRINT
&END SCF
&PRINT
&AO_MATRICES
CORE_HAMILTONIAN TRUE
KINETIC_ENERGY TRUE
POTENTIAL_ENERGY TRUE
&END AO_MATRICES
&ACTIVE_SPACE
ACTIVE_ELECTRONS 2
ACTIVE_ORBITALS 3 3
INACTIVE_ELECTRONS 2 2
ISOLATED_SYSTEM TRUE
&ERI
METHOD FULL_GPW
PERIODICITY 0 0 0
&END ERI
&ERI_GPW
CUTOFF 500
&END ERI_GPW
&FCIDUMP
FILENAME __STD_OUT__
&END FCIDUMP
&END ACTIVE_SPACE
&END PRINT
&END DFT
&SUBSYS
&CELL
ABC 6.0 6.0 6.0
PERIODIC NONE
&END CELL
&COORD
C 0.000 0.000 0.112
H 0.000 0.974 0.335
H 0.000 -0.974 -0.335
&END COORD
&KIND H
BASIS_SET 6-31G*
POTENTIAL GTH-HF
&END KIND
&KIND C
BASIS_SET 6-31G*
POTENTIAL GTH-HF
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
RUN_TYPE ENERGY
PRINT_LEVEL LOW
PROJECT ch2_gpw_pp
&END GLOBAL

0 comments on commit 6964239

Please sign in to comment.