20 USE dbcsr_api,
ONLY: dbcsr_deallocate_matrix,&
28 #include "./base/base_uses.f90"
33 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
34 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_wf_history_types'
36 PUBLIC :: qs_wf_snapshot_type, &
37 qs_wf_history_type, qs_wf_history_p_type
58 TYPE qs_wf_snapshot_type
59 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: wf
60 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
61 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g
62 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao
63 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
64 TYPE(dbcsr_type),
POINTER :: overlap
65 TYPE(qs_rho_type),
POINTER :: rho_frozen
67 END TYPE qs_wf_snapshot_type
76 TYPE qs_wf_snapshot_p_type
77 TYPE(qs_wf_snapshot_type),
POINTER :: snapshot
78 END TYPE qs_wf_snapshot_p_type
98 TYPE qs_wf_history_type
99 INTEGER :: ref_count, memory_depth, last_state_index, &
100 interpolation_method_nr, snapshot_count
101 LOGICAL :: store_wf, store_rho_r, store_rho_g, store_rho_ao, store_rho_ao_kp, &
102 store_overlap, store_frozen_density
103 TYPE(qs_wf_snapshot_p_type),
DIMENSION(:),
POINTER :: past_states
104 END TYPE qs_wf_history_type
111 TYPE qs_wf_history_p_type
112 TYPE(qs_wf_history_type),
POINTER :: wf_history
113 END TYPE qs_wf_history_p_type
125 SUBROUTINE wfs_release(snapshot)
126 TYPE(qs_wf_snapshot_type),
INTENT(INOUT) :: snapshot
128 CALL cp_fm_release(snapshot%wf)
131 IF (
ASSOCIATED(snapshot%rho_ao))
THEN
134 IF (
ASSOCIATED(snapshot%rho_ao_kp))
THEN
137 IF (
ASSOCIATED(snapshot%overlap))
THEN
138 CALL dbcsr_deallocate_matrix(snapshot%overlap)
140 IF (
ASSOCIATED(snapshot%rho_frozen))
THEN
142 DEALLOCATE (snapshot%rho_frozen)
145 END SUBROUTINE wfs_release
155 TYPE(qs_wf_history_type),
POINTER :: wf_history
157 cpassert(
ASSOCIATED(wf_history))
158 wf_history%ref_count = wf_history%ref_count + 1
171 TYPE(qs_wf_history_type),
POINTER :: wf_history
175 IF (
ASSOCIATED(wf_history))
THEN
176 cpassert(wf_history%ref_count > 0)
177 wf_history%ref_count = wf_history%ref_count - 1
178 IF (wf_history%ref_count == 0)
THEN
179 IF (
ASSOCIATED(wf_history%past_states))
THEN
180 DO i = 1,
SIZE(wf_history%past_states)
181 IF (
ASSOCIATED(wf_history%past_states(i)%snapshot))
THEN
182 CALL wfs_release(wf_history%past_states(i)%snapshot)
183 DEALLOCATE (wf_history%past_states(i)%snapshot)
186 DEALLOCATE (wf_history%past_states)
188 DEALLOCATE (wf_history)
204 TYPE(qs_wf_history_type),
POINTER :: wf_history
205 INTEGER,
INTENT(in) :: wf_index
206 TYPE(qs_wf_snapshot_type),
POINTER :: res
210 cpassert(
ASSOCIATED(wf_history))
211 cpassert(
ASSOCIATED(wf_history%past_states))
212 IF (wf_index > wf_history%memory_depth .OR. wf_index > wf_history%snapshot_count)
THEN
215 res => wf_history%past_states( &
216 modulo(wf_history%snapshot_count + 1 - wf_index, &
217 wf_history%memory_depth) + 1)%snapshot
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
DBCSR operations in CP2K.
represent a full matrix distributed on many processors
Defines the basic variable types.
integer, parameter, public dp
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_release(rho_struct)
releases a rho_struct by decreasing the reference count by one and deallocating if it reaches 0 (to b...
interpolate the wavefunctions to speed up the convergence when doing MD
type(qs_wf_snapshot_type) function, pointer, public wfi_get_snapshot(wf_history, wf_index)
returns a snapshot, the first being the latest snapshot
subroutine, public wfi_retain(wf_history)
retains a wf history (see doc/ReferenceCounting.html)
subroutine, public wfi_release(wf_history)
releases a wf_history of a wavefunction (see doc/ReferenceCounting.html)