Skip to content

Commit

Permalink
Bug fix xTB geo_opt with Broyden mixing SCF (#631)
Browse files Browse the repository at this point in the history
* Bug fix xTB geo_opt with Broyden mixing SCF

* Fix memory leak
  • Loading branch information
juerghutter committed Nov 18, 2019
1 parent 04316ae commit 8164ea4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/qs_mixing_utils.F
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ SUBROUTINE mixing_allocate(qs_env, mixing_method, p_mix_new, p_delta, nspins, mi
CALL get_qs_env(qs_env, local_particles=distribution_1d)
nkind = SIZE(distribution_1d%n_el)
na = SUM(distribution_1d%n_el(:))
IF (ASSOCIATED(mixing_store%atlist)) DEALLOCATE (mixing_store%atlist)
ALLOCATE (mixing_store%atlist(na))
mixing_store%nat_local = na
mixing_store%max_shell = max_shell
Expand Down
9 changes: 4 additions & 5 deletions src/qs_scf_initialization.F
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@ SUBROUTINE qs_scf_ensure_scf_env(qs_env, scf_env)

IF (.NOT. ASSOCIATED(scf_env)) THEN ! i.e. for MD this is associated on the second step (it so seems)
CALL scf_env_create(scf_env)
! CALL set_qs_env(qs_env,scf_env=scf_env)
! CALL scf_env_release(scf_env)
! CALL get_qs_env(qs_env=qs_env,scf_env=scf_env)
ELSE
! Reallocate mixing store, if the g space grid (cell) has changed
SELECT CASE (scf_env%mixing_method)
Expand All @@ -256,8 +253,10 @@ SUBROUTINE qs_scf_ensure_scf_env(qs_env, scf_env)
! the new grid are accidentily equal is rather low
CALL get_qs_env(qs_env, rho=rho)
CALL qs_rho_get(rho, rho_g=rho_g)
IF (SIZE(rho_g(1)%pw%pw_grid%gsq) /= SIZE(scf_env%mixing_store%rhoin(1)%cc)) &
CALL mixing_storage_release(scf_env%mixing_store)
IF (ASSOCIATED(scf_env%mixing_store%rhoin)) THEN
IF (SIZE(rho_g(1)%pw%pw_grid%gsq) /= SIZE(scf_env%mixing_store%rhoin(1)%cc)) &
CALL mixing_storage_release(scf_env%mixing_store)
END IF
END IF
END SELECT
END IF
Expand Down
69 changes: 69 additions & 0 deletions tests/xTB/regtest-5/Ru_geo.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
&GLOBAL
PROJECT Ru_geo
RUN_TYPE GEO_OPT
PRINT_LEVEL LOW
&END GLOBAL

&FORCE_EVAL
METHOD Quickstep
&DFT
&QS
METHOD xTB
&xTB
DO_EWALD T
&END XTB
&END QS
&POISSON
&EWALD
EWALD_TYPE SPME
&END EWALD
&END POISSON
&KPOINTS
SCHEME MONKHORST-PACK 3 3 3
&END KPOINTS

&SCF
MAX_SCF 500
SCF_GUESS MOPAC
EPS_SCF 1.0E-7
ADDED_MOS 400
&DIAGONALIZATION
ALGORITHM STANDARD
EPS_ADAPT 0.01
&END DIAGONALIZATION
&SMEAR ON
METHOD FERMI_DIRAC
ELECTRONIC_TEMPERATURE [K] 300
&END SMEAR
&MIXING
METHOD BROYDEN_MIXING
ALPHA 0.1
&END
&END SCF

&PRINT
&MULLIKEN
FILENAME=mulliken
COMMON_ITERATION_LEVELS 10
&EACH
MD 1
&END EACH
&END MULLIKEN
&PDOS
NLUMO -1
&END
&END PRINT
&END DFT

&SUBSYS
&CELL
ABC 2.7330 2.7330 4.3140
ALPHA_BETA_GAMMA 90 90 120
PERIODIC XYZ
&END CELL
&COORD
Ru 0.9109 1.8221 3.2355
Ru 1.8221 0.9109 1.0785
&END
&END SUBSYS
&END FORCE_EVAL
1 change: 1 addition & 0 deletions tests/xTB/regtest-5/TEST_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
AdeThyvdW.inp 1 1.0E-12 -58.89501875071196
ice.inp 1 1.0E-10 -46.31849039679943
ice2.inp 1 1.0E-10 -46.30633640965694
Ru_geo.inp 1 1.0E-10 -7.01246011345805
#EOF

0 comments on commit 8164ea4

Please sign in to comment.