(git:08825b9)
Loading...
Searching...
No Matches
tblite_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief types for tblite
10!> \author JVP
11!> \history creation 09.2024
12! **************************************************************************************************
13
15
16#if defined(__TBLITE)
17 USE mctc_io, ONLY: structure_type
18 USE tblite_xtb_calculator, ONLY: xtb_calculator
19 USE tblite_container_cache, ONLY: container_cache
20 USE tblite_scf_mixer, ONLY: mixer_type
21 USE tblite_wavefunction_type, ONLY: wavefunction_type
22 USE tblite_scf_potential, ONLY: potential_type
23 USE tblite_param, ONLY: param_record
24#endif
25
26 USE cp_dbcsr_api, ONLY: dbcsr_p_type
34 USE kinds, ONLY: dp
35
36#include "../base/base_uses.f90"
37 IMPLICIT NONE
38
39 PRIVATE
40
41 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'tblite_types'
42
44
46
47 LOGICAL :: use_virial = .false.
48 INTEGER, ALLOCATABLE :: el_num(:)
49
50 REAL(kind=dp) :: accuracy = 1.0_dp
51 REAL(kind=dp), DIMENSION(3, 3) :: sigma = -1.0_dp
52 ! tblite contributions are currently replicated on every MPI rank.
53 ! Force/virial assembly accounts for CP2K's subsequent MPI reductions.
54 REAL(kind=dp), ALLOCATABLE :: e_hal(:)
55 REAL(kind=dp), ALLOCATABLE :: e_rep(:)
56 REAL(kind=dp), ALLOCATABLE :: e_disp(:)
57 REAL(kind=dp), ALLOCATABLE :: e_scd(:)
58 REAL(kind=dp), ALLOCATABLE :: e_es(:)
59 REAL(kind=dp), ALLOCATABLE :: e_int(:)
60 REAL(kind=dp), ALLOCATABLE :: selfenergy(:)
61 REAL(kind=dp), ALLOCATABLE :: cn(:)
62
63 REAL(kind=dp), ALLOCATABLE :: grad(:, :)
64 !derivatives w. r. t. coordination number
65 REAL(kind=dp), ALLOCATABLE :: dsedcn(:)
66 REAL(kind=dp), ALLOCATABLE :: dcndr(:, :, :)
67 REAL(kind=dp), ALLOCATABLE :: dcndl(:, :, :)
68
69 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: dipbra => null(), &
70 dipket => null()
71 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: quadbra => null(), &
72 quadket => null()
73 ! Spin-resolved density snapshot used by the UKS/LSD force path.
74 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp_ref => null()
75 INTEGER :: mixer_memory = tblite_mixer_iterations_default
76 REAL(kind=dp) :: mixer_damping = tblite_mixer_damping_default
77 REAL(kind=dp) :: mixer_max_weight = tblite_mixer_max_weight_default
78 REAL(kind=dp) :: mixer_min_weight = tblite_mixer_min_weight_default
79 REAL(kind=dp) :: mixer_omega0 = tblite_mixer_omega0_default
80 REAL(kind=dp) :: mixer_weight_factor = tblite_mixer_weight_factor_default
81
82#if defined(__TBLITE)
83 TYPE(structure_type) :: mol = structure_type()
84 TYPE(xtb_calculator) :: calc = xtb_calculator()
85 ! Geometry-dependent caches: Coulomb, dispersion and additional interactions.
86 ! Refreshed by tb_init_ham, reused for SCC potentials, energies and gradients.
87 TYPE(container_cache) :: cache = container_cache()
88 TYPE(container_cache) :: dcache = container_cache()
89 TYPE(container_cache) :: icache = container_cache()
90 TYPE(wavefunction_type) :: wfn = wavefunction_type()
91 TYPE(potential_type) :: pot = potential_type()
92 CLASS(mixer_type), ALLOCATABLE :: mixer
93 TYPE(param_record), ALLOCATABLE :: param
94#endif
95
96 END TYPE tblite_type
97
98CONTAINS
99
100! **************************************************************************************************
101!> \brief ...
102!> \param tb_tblite ...
103! **************************************************************************************************
104 SUBROUTINE allocate_tblite_type(tb_tblite)
105
106 TYPE(tblite_type), POINTER :: tb_tblite
107
108 CALL deallocate_tblite_type(tb_tblite)
109
110 ALLOCATE (tb_tblite)
111
112 END SUBROUTINE allocate_tblite_type
113
114! **************************************************************************************************
115!> \brief ...
116!> \param tb_tblite ...
117! **************************************************************************************************
118 SUBROUTINE deallocate_tblite_type(tb_tblite)
119
120 TYPE(tblite_type), POINTER :: tb_tblite
121
122 IF (ASSOCIATED(tb_tblite)) THEN
123 ! Release pointer-owned DBCSR objects; allocatable components are released
124 ! automatically when the parent object is deallocated.
125 IF (ASSOCIATED(tb_tblite%dipbra)) THEN
126 CALL dbcsr_deallocate_matrix_set(tb_tblite%dipbra)
127 END IF
128 IF (ASSOCIATED(tb_tblite%dipket)) THEN
129 CALL dbcsr_deallocate_matrix_set(tb_tblite%dipket)
130 END IF
131 IF (ASSOCIATED(tb_tblite%quadbra)) THEN
132 CALL dbcsr_deallocate_matrix_set(tb_tblite%quadbra)
133 END IF
134 IF (ASSOCIATED(tb_tblite%quadket)) THEN
135 CALL dbcsr_deallocate_matrix_set(tb_tblite%quadket)
136 END IF
137 IF (ASSOCIATED(tb_tblite%rho_ao_kp_ref)) THEN
138 CALL dbcsr_deallocate_matrix_set(tb_tblite%rho_ao_kp_ref)
139 END IF
140 DEALLOCATE (tb_tblite)
141 NULLIFY (tb_tblite)
142 END IF
143
144 END SUBROUTINE deallocate_tblite_type
145
146END MODULE tblite_types
DBCSR operations in CP2K.
collects all constants needed in input so that they can be used without circular dependencies
real(kind=dp), parameter, public tblite_mixer_damping_default
integer, parameter, public tblite_mixer_iterations_default
real(kind=dp), parameter, public tblite_mixer_max_weight_default
real(kind=dp), parameter, public tblite_mixer_omega0_default
real(kind=dp), parameter, public tblite_mixer_weight_factor_default
real(kind=dp), parameter, public tblite_mixer_min_weight_default
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
types for tblite
subroutine, public allocate_tblite_type(tb_tblite)
...
subroutine, public deallocate_tblite_type(tb_tblite)
...