(git:374b731)
Loading...
Searching...
No Matches
localization_tb.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Localization/Wannier functions for TB
10!> \par History
11!> \author JHU (03.2019)
12! **************************************************************************************************
17 USE cp_fm_types, ONLY: cp_fm_create,&
28 USE kinds, ONLY: dp
31 USE pw_env_types, ONLY: pw_env_get,&
33 USE pw_pool_types, ONLY: pw_pool_p_type,&
35 USE pw_types, ONLY: pw_c1d_gs_type,&
41 USE qs_loc_dipole, ONLY: loc_dipole
50 USE qs_mo_types, ONLY: get_mo_set,&
54#include "./base/base_uses.f90"
55
56 IMPLICIT NONE
57 PRIVATE
58
59 ! Global parameters
60 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'localization_tb'
61 PUBLIC :: wfn_localization_tb
62
63CONTAINS
64
65! **************************************************************************************************
66!> \brief wfn localization
67!> \param qs_env ...
68!> \param tb_type ...
69!> \par History
70!> 03.2019 initial version
71!> \author JHU
72!> \note
73! **************************************************************************************************
74 SUBROUTINE wfn_localization_tb(qs_env, tb_type)
75
76 TYPE(qs_environment_type), POINTER :: qs_env
77 CHARACTER(LEN=*) :: tb_type
78
79 CHARACTER(len=*), PARAMETER :: routinen = 'wfn_localization_tb'
80
81 INTEGER :: handle, iounit, ispin, nspins
82 INTEGER, DIMENSION(:, :, :), POINTER :: marked_states
83 LOGICAL :: do_homo, do_kpoints, explicit, &
84 loc_explicit
85 REAL(kind=dp), DIMENSION(:), POINTER :: mo_eigenvalues
86 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
87 TYPE(cp_1d_r_p_type), DIMENSION(:), POINTER :: occupied_evals
88 TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:) :: homo_localized, occupied_orbs
89 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mo_loc_history
90 TYPE(cp_fm_type), POINTER :: mo_coeff
91 TYPE(cp_logger_type), POINTER :: logger
92 TYPE(dft_control_type), POINTER :: dft_control
93 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
94 TYPE(particle_list_type), POINTER :: particles
95 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
96 TYPE(pw_c1d_gs_type) :: wf_g
97 TYPE(pw_env_type), POINTER :: pw_env
98 TYPE(pw_pool_p_type), DIMENSION(:), POINTER :: pw_pools
99 TYPE(pw_pool_type), POINTER :: auxbas_pw_pool
100 TYPE(pw_r3d_rs_type) :: wf_r
101 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
102 TYPE(qs_loc_env_type), POINTER :: qs_loc_env_homo
103 TYPE(qs_subsys_type), POINTER :: subsys
104 TYPE(section_vals_type), POINTER :: dft_section, loc_print_section, &
105 localize_section
106
107 CALL timeset(routinen, handle)
108
109 logger => cp_get_default_logger()
110 iounit = cp_logger_get_default_io_unit(logger)
111
112 cpassert(ASSOCIATED(qs_env))
113 dft_section => section_vals_get_subs_vals(qs_env%input, "DFT")
114 localize_section => section_vals_get_subs_vals(dft_section, "LOCALIZE")
115 loc_print_section => section_vals_get_subs_vals(localize_section, "PRINT")
116 CALL section_vals_get(localize_section, explicit=loc_explicit)
117 !
118 IF (trim(tb_type) == "xTB") THEN
119 ! okay
120 ELSE
121 IF (loc_explicit) THEN
122 cpwarn("Wfn localization for this TB type not implemented")
123 loc_explicit = .false.
124 END IF
125 END IF
126
127 IF (loc_explicit) THEN
128 CALL section_vals_val_get(localize_section, "LIST", explicit=explicit)
129 IF (explicit) THEN
130 cpwarn("Localization using LIST of states not implemented for TB methods")
131 END IF
132 CALL section_vals_val_get(localize_section, "ENERGY_RANGE", explicit=explicit)
133 IF (explicit) THEN
134 cpwarn("Localization using energy range not implemented for TB methods")
135 END IF
136 CALL section_vals_val_get(localize_section, "LIST_UNOCCUPIED", explicit=explicit)
137 IF (explicit) THEN
138 cpwarn("Localization of unoccupied states not implemented for TB methods")
139 END IF
140 ! localize all occupied states
141 IF (iounit > 0) THEN
142 WRITE (iounit, "(/,T11,A)") " +++++++++++++ Start Localization of Orbitals +++++++++++++"
143 END IF
144 !
145 CALL get_qs_env(qs_env, &
146 dft_control=dft_control, &
147 do_kpoints=do_kpoints, &
148 subsys=subsys, &
149 particle_set=particle_set, &
150 atomic_kind_set=atomic_kind_set, &
151 qs_kind_set=qs_kind_set)
152 CALL qs_subsys_get(subsys, particles=particles)
153
154 IF (do_kpoints) THEN
155 cpwarn("Localization not implemented for k-point calculations!!")
156 ELSEIF (dft_control%restricted) THEN
157 IF (iounit > 0) WRITE (iounit, *) &
158 " Unclear how we define MOs / localization in the restricted case ... skipping"
159 ELSE
160 CALL get_qs_env(qs_env, mos=mos)
161 nspins = dft_control%nspins
162 ALLOCATE (occupied_orbs(nspins))
163 ALLOCATE (occupied_evals(nspins))
164 ALLOCATE (homo_localized(nspins))
165 DO ispin = 1, nspins
166 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, &
167 eigenvalues=mo_eigenvalues)
168 occupied_orbs(ispin) = mo_coeff
169 occupied_evals(ispin)%array => mo_eigenvalues
170 CALL cp_fm_create(homo_localized(ispin), occupied_orbs(ispin)%matrix_struct)
171 CALL cp_fm_to_fm(occupied_orbs(ispin), homo_localized(ispin))
172 END DO
173
174 CALL get_qs_env(qs_env, mo_loc_history=mo_loc_history)
175 do_homo = .true.
176
177 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env)
178 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, pw_pools=pw_pools)
179 CALL auxbas_pw_pool%create_pw(wf_r)
180 CALL auxbas_pw_pool%create_pw(wf_g)
181
182 NULLIFY (marked_states, qs_loc_env_homo)
183 ALLOCATE (qs_loc_env_homo)
184 CALL qs_loc_env_create(qs_loc_env_homo)
185 CALL qs_loc_control_init(qs_loc_env_homo, localize_section, do_homo=do_homo)
186 CALL qs_loc_init(qs_env, qs_loc_env_homo, localize_section, homo_localized, do_homo, &
187 .false., mo_loc_history=mo_loc_history)
188 CALL get_localization_info(qs_env, qs_loc_env_homo, localize_section, homo_localized, &
189 wf_r, wf_g, particles, occupied_orbs, occupied_evals, marked_states)
190
191 !retain the homo_localized for future use
192 IF (qs_loc_env_homo%localized_wfn_control%use_history) THEN
193 CALL retain_history(mo_loc_history, homo_localized)
194 CALL set_qs_env(qs_env, mo_loc_history=mo_loc_history)
195 END IF
196
197 !write restart for localization of occupied orbitals
198 CALL loc_write_restart(qs_loc_env_homo, loc_print_section, mos, &
199 homo_localized, do_homo)
200 CALL cp_fm_release(homo_localized)
201 DEALLOCATE (occupied_orbs)
202 DEALLOCATE (occupied_evals)
203 ! Print Total Dipole if the localization has been performed
204 IF (qs_loc_env_homo%do_localize) THEN
205 CALL loc_dipole(qs_env%input, dft_control, qs_loc_env_homo, logger, qs_env)
206 END IF
207 CALL auxbas_pw_pool%give_back_pw(wf_g)
208 CALL auxbas_pw_pool%give_back_pw(wf_r)
209 CALL qs_loc_env_release(qs_loc_env_homo)
210 DEALLOCATE (qs_loc_env_homo)
211 IF (ASSOCIATED(marked_states)) THEN
212 DEALLOCATE (marked_states)
213 END IF
214 END IF
215
216 END IF
217
218 CALL timestop(handle)
219
220 END SUBROUTINE wfn_localization_tb
221
222! **************************************************************************************************
223
224END MODULE localization_tb
Define the atomic kind types and their sub types.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
objects that represent the structure of input sections and the data contained in an input section
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_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Localization/Wannier functions for TB.
subroutine, public wfn_localization_tb(qs_env, tb_type)
wfn localization
represent a simple array based list of the given type
Define the data structure for the particle information.
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Set the QUICKSTEP environment.
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_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, 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, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public loc_dipole(input, dft_control, qs_loc_env, logger, qs_env)
Computes and prints the Dipole (using localized charges)
subroutine, public get_localization_info(qs_env, qs_loc_env, loc_section, mo_local, wf_r, wf_g, particles, coeff, evals, marked_states)
Performs localization of the orbitals.
New version of the module for the localization of the molecular orbitals This should be able to use d...
subroutine, public qs_loc_env_release(qs_loc_env)
...
subroutine, public qs_loc_env_create(qs_loc_env)
...
Some utilities for the construction of the localization environment.
subroutine, public loc_write_restart(qs_loc_env, section, mo_array, coeff_localized, do_homo, evals, do_mixed)
...
subroutine, public qs_loc_control_init(qs_loc_env, loc_section, do_homo, do_mixed, do_xas, nloc_xas, spin_xas)
initializes everything needed for localization of the HOMOs
subroutine, public retain_history(mo_loc_history, mo_loc)
copy old mos to new ones, allocating as necessary
subroutine, public qs_loc_init(qs_env, qs_loc_env, localize_section, mos_localized, do_homo, do_mo_cubes, mo_loc_history, evals, tot_zeff_corr, do_mixed)
initializes everything needed for localization of the 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.
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
Provides all information about an atomic kind.
represent a pointer to a 1d array
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
contained for different pw related things
to create arrays of pools
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
contains all the info needed by quickstep to calculate the spread of a selected set of orbitals and i...