(git:374b731)
Loading...
Searching...
No Matches
wannier_states.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 Routines for the calculation of wannier states
10!> \author Alin M Elena
11! **************************************************************************************************
17 USE cp_fm_types, ONLY: cp_fm_create,&
29 USE dbcsr_api, ONLY: dbcsr_type
33 USE kinds, ONLY: default_string_length,&
34 dp
40!!!! this ones are needed to mapping
41#include "./base/base_uses.f90"
42
43 IMPLICIT NONE
44
45 PRIVATE
46
47! *** Global parameters ***
48
49 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'wannier_states'
50
51 LOGICAL, PARAMETER, PRIVATE :: debug_this_module = .true.
52
53! *** Public subroutines ***
54
56
57CONTAINS
58
59! **************************************************************************************************
60!> \brief constructs wannier states. mo_localized should not be overwritten!
61!> \param mo_localized ...
62!> \param Hks ...
63!> \param qs_env ...
64!> \param loc_print_section ...
65!> \param WannierCentres ...
66!> \param ns ...
67!> \param states ...
68! **************************************************************************************************
69 SUBROUTINE construct_wannier_states(mo_localized, &
70 Hks, qs_env, loc_print_section, WannierCentres, ns, states)
71
72 TYPE(cp_fm_type), INTENT(in) :: mo_localized
73 TYPE(dbcsr_type), POINTER :: hks
74 TYPE(qs_environment_type), POINTER :: qs_env
75 TYPE(section_vals_type), POINTER :: loc_print_section
76 TYPE(wannier_centres_type), INTENT(INOUT) :: wanniercentres
77 INTEGER, INTENT(IN) :: ns
78 INTEGER, INTENT(IN), POINTER :: states(:)
79
80 CHARACTER(len=*), PARAMETER :: routinen = 'construct_wannier_states'
81
82 CHARACTER(default_string_length) :: unit_str
83 INTEGER :: handle, i, iproc, ncol_global, nproc, &
84 nrow_global, nstates(2), output_unit, &
85 unit_mat
86 REAL(kind=dp) :: unit_conv
87 TYPE(cp_fm_struct_type), POINTER :: fm_struct_tmp
88 TYPE(cp_fm_type) :: b, c, d
89 TYPE(cp_logger_type), POINTER :: logger
90 TYPE(mp_para_env_type), POINTER :: para_env
91 TYPE(section_vals_type), POINTER :: print_key
92
93!-----------------------------------------------------------------------
94!-----------------------------------------------------------------------
95
96 CALL timeset(routinen, handle)
97 NULLIFY (logger, para_env)
98
99 CALL get_qs_env(qs_env, para_env=para_env)
100 nproc = para_env%num_pe
101
102 logger => cp_get_default_logger()
103 output_unit = cp_logger_get_default_io_unit(logger)
104 CALL cp_fm_get_info(mo_localized, &
105 ncol_global=ncol_global, &
106 nrow_global=nrow_global)
107
108 nstates(1) = ns
109 nstates(2) = para_env%mepos
110 iproc = nstates(2)
111 NULLIFY (fm_struct_tmp, print_key)
112
113 print_key => section_vals_get_subs_vals(loc_print_section, "WANNIER_CENTERS")
114 CALL section_vals_val_get(print_key, "UNIT", c_val=unit_str)
115 unit_conv = cp_unit_from_cp2k(1.0_dp, trim(unit_str))
116
117 CALL cp_fm_struct_create(fm_struct_tmp, nrow_global=nrow_global, &
118 ncol_global=1, &
119 para_env=mo_localized%matrix_struct%para_env, &
120 context=mo_localized%matrix_struct%context)
121
122 CALL cp_fm_create(b, fm_struct_tmp, name="b")
123 CALL cp_fm_create(c, fm_struct_tmp, name="c")
124
125 CALL cp_fm_struct_release(fm_struct_tmp)
126
127 CALL cp_fm_struct_create(fm_struct_tmp, nrow_global=1, ncol_global=1, &
128 para_env=mo_localized%matrix_struct%para_env, &
129 context=mo_localized%matrix_struct%context)
130
131 CALL cp_fm_create(d, fm_struct_tmp, name="d")
132 CALL cp_fm_struct_release(fm_struct_tmp)
133
134 wanniercentres%WannierHamDiag = 0.0_dp
135 ! try to print the matrix
136
137 unit_mat = cp_print_key_unit_nr(logger, loc_print_section, &
138 "WANNIER_STATES", extension=".whks", &
139 ignore_should_output=.false.)
140 IF (unit_mat > 0) THEN
141 WRITE (unit_mat, '(a16,1(i0,1x))') "Wannier states: ", ns
142 WRITE (unit_mat, '(a16)') "#No x y z energy "
143 END IF
144 DO i = 1, ns
145 CALL cp_fm_to_fm(mo_localized, b, 1, states(i), 1)
146 CALL cp_dbcsr_sm_fm_multiply(hks, b, c, 1)
147 CALL parallel_gemm('T', 'N', 1, 1, nrow_global, 1.0_dp, &
148 b, c, 0.0_dp, d)
149 CALL cp_fm_get_element(d, 1, 1, wanniercentres%WannierHamDiag(i))
150 ! if (iproc==para_env%mepos) WRITE(unit_mat,'(f16.8,2x)', advance='no')WannierCentres%WannierHamDiag(i)
151 IF (unit_mat > 0) WRITE (unit_mat, '(i0,1x,4(f16.8,2x))') states(i), &
152 wanniercentres%centres(1:3, states(i))*unit_conv, wanniercentres%WannierHamDiag(states(i))
153 END DO
154
155 IF (unit_mat > 0) WRITE (unit_mat, *)
156 CALL cp_print_key_finished_output(unit_mat, logger, loc_print_section, &
157 "WANNIER_STATES")
158 IF (output_unit > 0) THEN
159 WRITE (output_unit, *) ""
160 WRITE (output_unit, *) "NUMBER OF Wannier STATES ", ns
161 WRITE (output_unit, *) "ENERGY original MO-index"
162 DO i = 1, ns
163 WRITE (output_unit, '(f16.8,2x,i0)') wanniercentres%WannierHamDiag(i), states(i)
164 END DO
165 END IF
166 CALL cp_fm_release(b)
167 CALL cp_fm_release(c)
168 CALL cp_fm_release(d)
169 CALL timestop(handle)
170 END SUBROUTINE construct_wannier_states
171
172END MODULE wannier_states
173
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
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_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_get_element(matrix, irow_global, icol_global, alpha, local)
returns an element of a fm this value is valid on every cpu using this call is expensive
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
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
unit conversion facility
Definition cp_units.F:30
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Definition cp_units.F:1179
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_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
integer, parameter, public default_string_length
Definition kinds.F:57
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
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.
defines the type needed for computing wannier states expectations
Routines for the calculation of wannier states.
subroutine, public construct_wannier_states(mo_localized, hks, qs_env, loc_print_section, wanniercentres, ns, states)
constructs wannier states. mo_localized should not be overwritten!
keeps the information about the structure of a full matrix
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...
stores all the informations relevant to an mpi environment