(git:ed6f26b)
Loading...
Searching...
No Matches
qs_eht_guess.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Generate an initial guess (dm and orb) from EHT calculation
10! **************************************************************************************************
14 USE cp_dbcsr_api, ONLY: dbcsr_create,&
20 dbcsr_type_no_symmetry
25 USE cp_fm_diag, ONLY: cp_fm_geeig
29 USE cp_fm_types, ONLY: cp_fm_create,&
40 USE kinds, ONLY: dp
44 USE qs_environment, ONLY: qs_init
54 USE qs_mo_types, ONLY: get_mo_set,&
59#include "./base/base_uses.f90"
60
61 IMPLICIT NONE
62
63 PRIVATE
64
65 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_eht_guess'
66
67 PUBLIC :: calculate_eht_guess
68
69! **************************************************************************************************
70
71CONTAINS
72
73! **************************************************************************************************
74!> \brief EHT MO guess calclulation
75!> \param qs_env ...
76!> \param mo_array ...
77! **************************************************************************************************
78 SUBROUTINE calculate_eht_guess(qs_env, mo_array)
79 TYPE(qs_environment_type), POINTER :: qs_env
80 TYPE(mo_set_type), DIMENSION(:), POINTER :: mo_array
81
82 CHARACTER(LEN=*), PARAMETER :: routinen = 'calculate_eht_guess'
83
84 INTEGER :: handle, ispin, nao, nbas, neeht, neorb, &
85 nkind, nmo, nspins, zero
86 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: eigenvalues
87 REAL(kind=dp), DIMENSION(:), POINTER :: eigval
88 TYPE(cp_blacs_env_type), POINTER :: blacs_env
89 TYPE(cp_fm_struct_type), POINTER :: mstruct_ee, mstruct_oe, mstruct_oo
90 TYPE(cp_fm_type) :: fmksmat, fmorb, fmscr, fmsmat, fmvec, &
91 fmwork, sfull, sinv
92 TYPE(cp_fm_type), POINTER :: mo_coeff
93 TYPE(cp_subsys_type), POINTER :: cp_subsys
94 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: ksmat, matrix_s, matrix_t, smat
95 TYPE(dbcsr_type) :: tempmat, tmat
96 TYPE(gto_basis_set_p_type), DIMENSION(:), POINTER :: basis_set_list_a, basis_set_list_b
97 TYPE(mp_para_env_type), POINTER :: para_env
98 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
99 POINTER :: sab_nl
100 TYPE(qs_environment_type), POINTER :: eht_env
101 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
102 TYPE(qs_ks_env_type), POINTER :: ks_env
103 TYPE(section_vals_type), POINTER :: dft_section, eht_force_env_section, &
104 force_env_section, qs_section, &
105 subsys_section, xtb_section
106
107 CALL timeset(routinen, handle)
108
109 NULLIFY (subsys_section)
110 CALL get_qs_env(qs_env, &
111 ks_env=ks_env, &
112 para_env=para_env, &
113 input=force_env_section, &
114 cp_subsys=cp_subsys)
115 NULLIFY (eht_force_env_section)
116 CALL section_vals_duplicate(force_env_section, eht_force_env_section)
117 dft_section => section_vals_get_subs_vals(eht_force_env_section, "DFT")
118 qs_section => section_vals_get_subs_vals(dft_section, "QS")
119 CALL section_vals_val_set(qs_section, "METHOD", i_val=do_method_xtb)
120 xtb_section => section_vals_get_subs_vals(qs_section, "xTB")
121 zero = 0
122 CALL section_vals_val_set(xtb_section, "GFN_TYPE", i_val=zero)
123 !
124 ALLOCATE (eht_env)
125 CALL qs_env_create(eht_env)
126 CALL qs_init(eht_env, para_env, cp_subsys=cp_subsys, &
127 force_env_section=eht_force_env_section, &
128 subsys_section=subsys_section, &
129 use_motion_section=.false., silent=.true.)
130 !
131 CALL get_qs_env(qs_env, nelectron_total=neorb)
132 CALL get_qs_env(eht_env, nelectron_total=neeht)
133 IF (neorb /= neeht) THEN
134 cpwarn("EHT has different number of electrons than calculation method.")
135 cpabort("EHT Initial Guess")
136 END IF
137 !
138 CALL qs_env_rebuild_pw_env(eht_env)
139 CALL qs_energies_init(eht_env, calc_forces=.false.)
140 CALL build_xtb_ks_matrix(eht_env, .false., .false.)
141 !
142 CALL get_qs_env(eht_env, &
143 matrix_s=smat, matrix_ks=ksmat)
144 nspins = SIZE(ksmat, 1)
145 CALL get_qs_env(eht_env, para_env=para_env, blacs_env=blacs_env)
146 CALL dbcsr_get_info(smat(1)%matrix, nfullrows_total=nao)
147 CALL cp_fm_struct_create(fmstruct=mstruct_ee, context=blacs_env, &
148 nrow_global=nao, ncol_global=nao)
149 CALL cp_fm_create(fmksmat, mstruct_ee)
150 CALL cp_fm_create(fmsmat, mstruct_ee)
151 CALL cp_fm_create(fmvec, mstruct_ee)
152 CALL cp_fm_create(fmwork, mstruct_ee)
153 ALLOCATE (eigenvalues(nao))
154
155 ! DBCSR matrix
156 CALL dbcsr_create(tempmat, template=smat(1)%matrix, matrix_type=dbcsr_type_no_symmetry)
157
158 ! transfer to FM
159 CALL dbcsr_desymmetrize(smat(1)%matrix, tempmat)
160 CALL copy_dbcsr_to_fm(tempmat, fmsmat)
161
162 !SINV of origianl basis
163 CALL get_qs_env(qs_env, para_env=para_env, blacs_env=blacs_env)
164 CALL get_qs_env(qs_env, matrix_s=matrix_s)
165 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nbas)
166 CALL dbcsr_create(tmat, template=matrix_s(1)%matrix, matrix_type=dbcsr_type_no_symmetry)
167 CALL cp_fm_struct_create(fmstruct=mstruct_oo, context=blacs_env, &
168 nrow_global=nbas, ncol_global=nbas)
169 CALL cp_fm_create(sfull, mstruct_oo)
170 CALL cp_fm_create(sinv, mstruct_oo)
171 CALL dbcsr_desymmetrize(matrix_s(1)%matrix, tmat)
172 CALL copy_dbcsr_to_fm(tmat, sfull)
173 CALL cp_fm_invert(sfull, sinv)
174 CALL dbcsr_release(tmat)
175 CALL cp_fm_release(sfull)
176 !TMAT(bas1, bas2)
177 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set, sab_all=sab_nl, nkind=nkind)
178 IF (.NOT. ASSOCIATED(sab_nl)) THEN
179 cpwarn("Full neighborlist not available for this method. EHT initial guess not possible.")
180 cpabort("EHT Initial Guess")
181 END IF
182 ALLOCATE (basis_set_list_a(nkind), basis_set_list_b(nkind))
183 CALL basis_set_list_setup(basis_set_list_a, "ORB", qs_kind_set)
184 CALL get_qs_env(eht_env, qs_kind_set=qs_kind_set)
185 CALL basis_set_list_setup(basis_set_list_b, "ORB", qs_kind_set)
186 !
187 NULLIFY (matrix_t)
188 CALL build_overlap_matrix_simple(ks_env, matrix_t, &
189 basis_set_list_a, basis_set_list_b, sab_nl)
190 DEALLOCATE (basis_set_list_a, basis_set_list_b)
191
192 ! KS matrix is not spin dependent!
193 CALL dbcsr_desymmetrize(ksmat(1)%matrix, tempmat)
194 CALL copy_dbcsr_to_fm(tempmat, fmksmat)
195 ! diagonalize
196 CALL cp_fm_geeig(fmksmat, fmsmat, fmvec, eigenvalues, fmwork)
197 ! Sinv*T*d
198 CALL cp_fm_struct_create(fmstruct=mstruct_oe, context=blacs_env, &
199 nrow_global=nbas, ncol_global=nao)
200 CALL cp_fm_create(fmscr, mstruct_oe)
201 CALL cp_fm_create(fmorb, mstruct_oe)
202 CALL cp_dbcsr_sm_fm_multiply(matrix_t(1)%matrix, fmvec, fmscr, ncol=nao)
203 CALL parallel_gemm('N', 'N', nbas, nao, nbas, 1.0_dp, sinv, fmscr, 0.0_dp, fmorb)
204 !
205 DO ispin = 1, nspins
206 CALL get_mo_set(mo_set=mo_array(ispin), mo_coeff=mo_coeff, nmo=nmo)
207 CALL cp_fm_to_fm(fmorb, mo_coeff, nmo, 1, 1)
208 NULLIFY (eigval)
209 CALL get_mo_set(mo_set=mo_array(ispin), eigenvalues=eigval)
210 IF (ASSOCIATED(eigval)) THEN
211 eigval(1:nmo) = eigenvalues(1:nmo)
212 END IF
213 END DO
214 CALL set_mo_occupation(mo_array, smear=qs_env%scf_control%smear)
215
216 DEALLOCATE (eigenvalues)
217 CALL dbcsr_release(tempmat)
218 CALL dbcsr_deallocate_matrix_set(matrix_t)
219 CALL cp_fm_release(fmksmat)
220 CALL cp_fm_release(fmsmat)
221 CALL cp_fm_release(fmvec)
222 CALL cp_fm_release(fmwork)
223 CALL cp_fm_release(fmscr)
224 CALL cp_fm_release(fmorb)
225 CALL cp_fm_release(sinv)
226 CALL cp_fm_struct_release(mstruct_ee)
227 CALL cp_fm_struct_release(mstruct_oe)
228 CALL cp_fm_struct_release(mstruct_oo)
229 !
230 CALL qs_env_release(eht_env)
231 DEALLOCATE (eht_env)
232 CALL section_vals_release(eht_force_env_section)
233
234 CALL timestop(handle)
235
236 END SUBROUTINE calculate_eht_guess
237
238END MODULE qs_eht_guess
methods related to the blacs parallel environment
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_release(matrix)
...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
basic linear algebra operations for full matrices
subroutine, public cp_fm_invert(matrix_a, matrix_inverse, det_a, eps_svd, eigval)
Inverts a cp_fm_type matrix, optionally returning the determinant of the input matrix.
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
Definition cp_fm_diag.F:17
subroutine, public cp_fm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
types that represent a subsys, i.e. a part of the system
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_method_xtb
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_set(section_vals, keyword_name, i_rep_section, i_rep_val, val, l_val, i_val, r_val, c_val, l_vals_ptr, i_vals_ptr, r_vals_ptr, c_vals_ptr)
sets the requested value
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_duplicate(section_vals_in, section_vals_out, i_rep_start, i_rep_end)
creates a deep copy from section_vals_in to section_vals_out
recursive subroutine, public section_vals_release(section_vals)
releases the given object
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Generate an initial guess (dm and orb) from EHT calculation.
subroutine, public calculate_eht_guess(qs_env, mo_array)
EHT MO guess calclulation.
Utility subroutine for qs energy calculation.
subroutine, public qs_energies_init(qs_env, calc_forces)
Refactoring of qs_energies_scf. Driver routine for the initial setup and calculations for a qs energy...
qs_environment methods that use many other modules
subroutine, public qs_env_rebuild_pw_env(qs_env)
rebuilds the pw_env in the given qs_env, allocating it if necessary
subroutine, public qs_env_release(qs_env)
releases the given qs_env (see doc/ReferenceCounting.html)
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs)
Get the QUICKSTEP environment.
subroutine, public qs_env_create(qs_env, globenv)
allocates and intitializes a qs_env
subroutine, public qs_init(qs_env, para_env, root_section, globenv, cp_subsys, kpoint_env, cell, cell_ref, qmmm, qmmm_env_qm, force_env_section, subsys_section, use_motion_section, silent)
Read the input and the database files for the setup of the QUICKSTEP environment.
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
Define the quickstep kind type and their sub types.
Set occupation of molecular orbitals.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
Calculation of overlap matrix, its derivatives and forces.
Definition qs_overlap.F:19
subroutine, public build_overlap_matrix_simple(ks_env, matrix_s, basis_set_list_a, basis_set_list_b, sab_nl)
Calculation of the overlap matrix over Cartesian Gaussian functions.
Definition qs_overlap.F:558
Calculation of KS matrix in xTB Reference: Stefan Grimme, Christoph Bannwarth, Philip Shushkov JCTC 1...
subroutine, public build_xtb_ks_matrix(qs_env, calculate_forces, just_energy, ext_ks_matrix)
...
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
represent a full matrix
represents a system: atoms, molecules, their pos,vel,...
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...