Skip to content

Commit

Permalink
GAPW ADMM Linres: bugfixes (#2371)
Browse files Browse the repository at this point in the history
* Bug fix for GAPW xc 2nd derivatives (GGA)

* Bug fix GAPW ADMM linres Kernel, add regtests

* Pretty

* Adjust regtests

* Speedup regtests
  • Loading branch information
juerghutter committed Oct 25, 2022
1 parent 26c4836 commit 10874d4
Show file tree
Hide file tree
Showing 20 changed files with 1,157 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/qs_linres_kernel.F
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ SUBROUTINE apply_xc_admm(qs_env, p_env)
CALL prepare_gapw_den(qs_env, local_rho_set=p_env%local_rho_set_admm, &
do_rho0=.FALSE., kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
rho_atom_set => admm_env%admm_gapw_env%local_rho_set%rho_atom_set
rho1_atom_set => p_env%local_rho_set%rho_atom_set
rho1_atom_set => p_env%local_rho_set_admm%rho_atom_set
CALL calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, xc_section, para_env, &
do_tddft=.FALSE., do_triplet=.FALSE., &
kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
Expand All @@ -934,7 +934,7 @@ SUBROUTINE apply_xc_admm(qs_env, p_env)
CALL dbcsr_copy(xcmat%matrix, matrix_s(1)%matrix)
CALL dbcsr_set(xcmat%matrix, 0.0_dp)
CALL integrate_v_rspace(v_rspace=v_xc(ispin)%pw, hmat=xcmat, qs_env=qs_env, &
calculate_forces=.FALSE., basis_type="AUX_FIT", &
calculate_forces=.FALSE., basis_type=basis_type, &
task_list_external=task_list)
CALL dbcsr_add(p_env%kpp1_admm(ispin)%matrix, xcmat%matrix, 1.0_dp, alpha)
END DO
Expand Down
20 changes: 10 additions & 10 deletions src/xc/xc.F
Original file line number Diff line number Diff line change
Expand Up @@ -2845,26 +2845,26 @@ SUBROUTINE xc_calc_2nd_deriv_analytical(v_xc, v_xc_tau, deriv_set, rho_set, rho1
DO idir = 1, 3
DO ispin = 1, nspins
vxg(idir, ia, ir, ispin) = &
v_drhoa(ispin)%pw%cr3d(ia, ir, 1)*drhoa(idir)%array(ia, ir, 1) + &
v_drhob(ispin)%pw%cr3d(ia, ir, 1)*drhob(idir)%array(ia, ir, 1) + &
v_drho(ispin)%pw%cr3d(ia, ir, 1)*drho(idir)%array(ia, ir, 1)
-(v_drhoa(ispin)%pw%cr3d(ia, ir, 1)*drhoa(idir)%array(ia, ir, 1) + &
v_drhob(ispin)%pw%cr3d(ia, ir, 1)*drhob(idir)%array(ia, ir, 1) + &
v_drho(ispin)%pw%cr3d(ia, ir, 1)*drho(idir)%array(ia, ir, 1))
END DO
IF (ASSOCIATED(e_drhoa)) THEN
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) - &
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) + &
e_drhoa(ia, ir, 1)*drho1a(idir)%array(ia, ir, 1)
END IF
IF (nspins /= 1 .AND. ASSOCIATED(e_drhob)) THEN
vxg(idir, ia, ir, 2) = vxg(idir, ia, ir, 2) - &
vxg(idir, ia, ir, 2) = vxg(idir, ia, ir, 2) + &
e_drhob(ia, ir, 1)*drho1b(idir)%array(ia, ir, 1)
END IF
IF (ASSOCIATED(e_drho)) THEN
IF (nspins /= 1) THEN
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) - &
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) + &
e_drho(ia, ir, 1)*drho1(idir)%array(ia, ir, 1)
vxg(idir, ia, ir, 2) = vxg(idir, ia, ir, 2) - &
vxg(idir, ia, ir, 2) = vxg(idir, ia, ir, 2) + &
e_drho(ia, ir, 1)*drho1(idir)%array(ia, ir, 1)
ELSE
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) - &
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) + &
e_drho(ia, ir, 1)*(drho1a(idir)%array(ia, ir, 1) + &
fac*drho1b(idir)%array(ia, ir, 1))
END IF
Expand Down Expand Up @@ -2996,9 +2996,9 @@ SUBROUTINE xc_calc_2nd_deriv_analytical(v_xc, v_xc_tau, deriv_set, rho_set, rho1
!$OMP SHARED(bo,vxg,drho,v_drho,e_drho,drho1,idir) COLLAPSE(2)
DO ia = bo(1, 1), bo(2, 1)
DO ir = bo(1, 2), bo(2, 2)
vxg(idir, ia, ir, 1) = drho(idir)%array(ia, ir, 1)*v_drho(1)%pw%cr3d(ia, ir, 1)
vxg(idir, ia, ir, 1) = -drho(idir)%array(ia, ir, 1)*v_drho(1)%pw%cr3d(ia, ir, 1)
IF (ASSOCIATED(e_drho)) THEN
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) - drho1(idir)%array(ia, ir, 1)*e_drho(ia, ir, 1)
vxg(idir, ia, ir, 1) = vxg(idir, ia, ir, 1) + drho1(idir)%array(ia, ir, 1)*e_drho(ia, ir, 1)
END IF
END DO
END DO
Expand Down
4 changes: 2 additions & 2 deletions tests/QS/regtest-debug-1/TEST_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ h2o_polar.inp 87 1e-05
h2o_pdip.inp 86 1e-05 0.961018561809E+00
h2o_periodic.inp 87 1e-05 0.139741440657E+02
h2o_gga.inp 87 1e-05 0.165143521103E+02
h2o_gapw.inp 87 1e-05 0.170288288429E+02
h2o_gapw_xc.inp 87 1e-05 0.170335568962E+02
h2o_gapw.inp 87 1e-05 0.170608453409E+02
h2o_gapw_xc.inp 87 1e-05 0.170656058892E+02
#EOF
4 changes: 2 additions & 2 deletions tests/QS/regtest-debug-2/TEST_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ h2o_lri.inp 87 1e-05
h2o_pade_fd.inp 87 1e-05 0.168333363169E+02
h2o_hfx.inp 87 1e-05 0.155040875037E+02
h2o_hfx_admm.inp 87 1e-05 0.153251090463E+02
h2o_admm_gapw.inp 87 1e-05 0.165349668089E+02
h2o_admm_x.inp 87 1e-05 0.165735315660E+02
h2o_admm_gapw.inp 87 1e-05 0.165414714809E+02
h2o_admm_x.inp 87 1e-05 0.165835444154E+02
#EOF
17 changes: 17 additions & 0 deletions tests/QS/regtest-debug-7/TEST_FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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
ch2o_gapw_t1.inp 87 1e-05 0.483221735787E+02
ch2o_gapw_t2.inp 87 1e-05 0.523034637680E+02
ch2o_gapw_t3.inp 87 1e-05 0.514019909196E+02
ch2o_gapw_t4.inp 87 1e-05 0.509623579715E+02
ch2o_gapw_t5.inp 87 1e-05 0.510993992202E+02
ch2o_gapw_t6.inp 87 1e-05 0.560991029797E+02
ch2o_gapw_xc_t1.inp 87 1e-05 0.531344520427E+02
ch2o_gapw_xc_t2.inp 87 1e-05 0.522983512347E+02
ch2o_gapw_xc_t3.inp 87 1e-05 0.513981803741E+02
ch2o_gapw_xc_t4.inp 87 1e-05 0.509588648640E+02
ch2o_gapw_xc_t5.inp 87 1e-05 0.510955039506E+02
#EOF
96 changes: 96 additions & 0 deletions tests/QS/regtest-debug-7/ch2o_gapw_t1.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
&FORCE_EVAL
METHOD Quickstep
&PROPERTIES
&LINRES
PRECONDITIONER FULL_ALL
EPS 1.e-10
&POLAR
DO_RAMAN T
PERIODIC_DIPOLE_OPERATOR F
&END
&END
&END
&DFT
&QS
METHOD GAPW
EPS_DEFAULT 1.e-14
&END QS
&MGRID
CUTOFF 300
REL_CUTOFF 50
&END MGRID
&EFIELD
&END
&SCF
SCF_GUESS ATOMIC
&OT
PRECONDITIONER FULL_ALL
MINIMIZER DIIS
&END
&OUTER_SCF
MAX_SCF 10
EPS_SCF 1.0E-7
&END
MAX_SCF 20
EPS_SCF 1.0E-7
&END SCF
&XC
&XC_FUNCTIONAL PADE
&END XC_FUNCTIONAL
&END XC
&POISSON
POISSON_SOLVER MT
PERIODIC NONE
&END POISSON
&PRINT
&MOMENTS ON
PERIODIC .FALSE.
REFERENCE COM
&END
&END
&END DFT
&SUBSYS
&CELL
ABC [angstrom] 4.0 4.0 4.0
PERIODIC NONE
&END
&TOPOLOGY
&CENTER_COORDINATES
&END
&END TOPOLOGY
&COORD
O 0.094933 -0.000368 0.895642
C -0.031077 -0.000121 -0.307326
H -0.090437 0.947608 -0.895642
H -0.094933 -0.947608 -0.895562
&END COORD
&KIND O
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q6
&END KIND
&KIND C
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q4
&END KIND
&KIND H
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q1
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
PRINT_LEVEL LOW
PROJECT Gdeb
RUN_TYPE DEBUG
&END GLOBAL

&DEBUG
DEBUG_FORCES .FALSE.
DEBUG_STRESS_TENSOR .FALSE.
DEBUG_DIPOLE .FALSE.
DEBUG_POLARIZABILITY .TRUE.
DE 0.005
EPS_NO_ERROR_CHECK 5.e-5
&END


88 changes: 88 additions & 0 deletions tests/QS/regtest-debug-7/ch2o_gapw_t2.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
&FORCE_EVAL
METHOD Quickstep
&PROPERTIES
&LINRES
PRECONDITIONER FULL_ALL
EPS 1.e-10
&POLAR
DO_RAMAN T
PERIODIC_DIPOLE_OPERATOR F
&END
&END
&END
&DFT
&QS
METHOD GAPW
EPS_DEFAULT 1.e-10
&END QS
&MGRID
CUTOFF 200
REL_CUTOFF 40
&END MGRID
&EFIELD
&END
&SCF
SCF_GUESS ATOMIC
&OT
PRECONDITIONER FULL_ALL
MINIMIZER DIIS
&END
&OUTER_SCF
MAX_SCF 10
EPS_SCF 1.0E-6
&END
MAX_SCF 20
EPS_SCF 1.0E-6
&END SCF
&XC
&XC_FUNCTIONAL PBE
&END XC_FUNCTIONAL
&END XC
&PRINT
&MOMENTS ON
PERIODIC .FALSE.
REFERENCE COM
&END
&END
&END DFT
&SUBSYS
&CELL
ABC [angstrom] 4.0 4.0 4.0
PERIODIC NONE
&END
&COORD
O 0.094933 -0.000368 0.895642
C -0.031077 -0.000121 -0.307326
H -0.090437 0.947608 -0.895642
H -0.094933 -0.947608 -0.895562
&END COORD
&KIND O
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q6
&END KIND
&KIND C
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q4
&END KIND
&KIND H
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q1
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
PRINT_LEVEL LOW
PROJECT Gdeb
RUN_TYPE DEBUG
&END GLOBAL

&DEBUG
DEBUG_FORCES .FALSE.
DEBUG_STRESS_TENSOR .FALSE.
DEBUG_DIPOLE .FALSE.
DEBUG_POLARIZABILITY .TRUE.
DE 0.005
EPS_NO_ERROR_CHECK 5.e-5
&END


88 changes: 88 additions & 0 deletions tests/QS/regtest-debug-7/ch2o_gapw_t3.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
&FORCE_EVAL
METHOD Quickstep
&PROPERTIES
&LINRES
PRECONDITIONER FULL_ALL
EPS 1.e-10
&POLAR
DO_RAMAN T
PERIODIC_DIPOLE_OPERATOR F
&END
&END
&END
&DFT
&QS
METHOD GAPW
EPS_DEFAULT 1.e-10
&END QS
&MGRID
CUTOFF 200
REL_CUTOFF 40
&END MGRID
&EFIELD
&END
&SCF
SCF_GUESS ATOMIC
&OT
PRECONDITIONER FULL_ALL
MINIMIZER DIIS
&END
&OUTER_SCF
MAX_SCF 10
EPS_SCF 1.0E-6
&END
MAX_SCF 20
EPS_SCF 1.0E-6
&END SCF
&XC
&XC_FUNCTIONAL PBE0
&END XC_FUNCTIONAL
&END XC
&PRINT
&MOMENTS ON
PERIODIC .FALSE.
REFERENCE COM
&END
&END
&END DFT
&SUBSYS
&CELL
ABC [angstrom] 4.0 4.0 4.0
PERIODIC NONE
&END
&COORD
O 0.094933 -0.000368 0.895642
C -0.031077 -0.000121 -0.307326
H -0.090437 0.947608 -0.895642
H -0.094933 -0.947608 -0.895562
&END COORD
&KIND O
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q6
&END KIND
&KIND C
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q4
&END KIND
&KIND H
BASIS_SET DZVP-GTH-PADE
POTENTIAL GTH-PBE-q1
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
PRINT_LEVEL LOW
PROJECT Gdeb
RUN_TYPE DEBUG
&END GLOBAL

&DEBUG
DEBUG_FORCES .FALSE.
DEBUG_STRESS_TENSOR .FALSE.
DEBUG_DIPOLE .FALSE.
DEBUG_POLARIZABILITY .TRUE.
DE 0.005
EPS_NO_ERROR_CHECK 5.e-5
&END


0 comments on commit 10874d4

Please sign in to comment.