57#include "./base/base_uses.f90"
63 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_band_structure'
79 LOGICAL :: do_kpoints, explicit
87 CALL do_calculate_band_structure(qs_env)
92 CALL do_calculate_band_structure(qs_env_kp)
94 DEALLOCATE (qs_env_kp)
106 SUBROUTINE do_calculate_band_structure(qs_env)
107 TYPE(qs_environment_type),
POINTER :: qs_env
109 CHARACTER(LEN=default_string_length) :: filename, ustr
110 CHARACTER(LEN=default_string_length), &
111 DIMENSION(:),
POINTER :: spname, strptr
112 CHARACTER(LEN=max_line_length) :: error_message
113 INTEGER :: bs_data_unit, i, i_rep, ik, ikk, ikpgr, &
114 imo, ip, ispin, n_ptr, n_rep, nadd, &
115 nkp, nmo, npline, npoints, nspins, &
117 INTEGER,
DIMENSION(2) :: kp_range
118 LOGICAL :: explicit, io_default, my_kpgrp
119 REAL(kind=dp) :: t1, t2
120 REAL(kind=dp),
DIMENSION(3) :: kpptr
121 REAL(kind=dp),
DIMENSION(3, 3) :: cart_hmat
122 REAL(kind=dp),
DIMENSION(:),
POINTER :: eigenvalues, eigval, occnum, &
123 occupation_numbers, wkp
124 REAL(kind=dp),
DIMENSION(:, :),
POINTER :: kpgeneral, kspecial, xkp
125 TYPE(cell_type),
POINTER :: cell
126 TYPE(dft_control_type),
POINTER :: dft_control
127 TYPE(kpoint_env_type),
POINTER :: kp
128 TYPE(kpoint_type),
POINTER :: kpoint
129 TYPE(mp_para_env_type),
POINTER :: para_env
130 TYPE(section_vals_type),
POINTER :: bs_input, kpset
132 bs_input => section_vals_get_subs_vals(qs_env%input,
"DFT%PRINT%BAND_STRUCTURE")
133 CALL section_vals_get(bs_input, explicit=explicit)
135 CALL section_vals_val_get(bs_input,
"FILE_NAME", c_val=filename)
136 CALL section_vals_val_get(bs_input,
"ADDED_MOS", i_val=nadd)
137 unit_nr = cp_logger_get_default_io_unit()
138 CALL get_qs_env(qs_env=qs_env, para_env=para_env)
139 CALL get_qs_env(qs_env, cell=cell)
140 cart_hmat(:, :) = cell%hmat(:, :)
141 IF (cell%input_cell_canonicalized) cart_hmat(:, :) = cell%input_hmat(:, :)
142 kpset => section_vals_get_subs_vals(bs_input,
"KPOINT_SET")
143 CALL section_vals_get(kpset, n_repetition=n_rep)
144 IF (unit_nr > 0)
THEN
145 WRITE (unit_nr, fmt=
"(/,T2,A)")
"KPOINTS| Band Structure Calculation"
146 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Number of k-point sets", n_rep
148 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Number of added MOs/bands", nadd
151 IF (filename ==
"")
THEN
153 bs_data_unit = unit_nr
157 IF (para_env%is_source())
THEN
158 CALL open_file(filename, unit_number=bs_data_unit, file_status=
"UNKNOWN", file_action=
"WRITE", &
159 file_position=
"APPEND")
166 CALL section_vals_val_get(kpset,
"NPOINTS", i_rep_section=i_rep, i_val=npline)
167 CALL section_vals_val_get(kpset,
"UNITS", i_rep_section=i_rep, c_val=ustr)
169 CALL section_vals_val_get(kpset,
"SPECIAL_POINT", i_rep_section=i_rep, n_rep_val=n_ptr)
170 ALLOCATE (kspecial(3, n_ptr))
171 ALLOCATE (spname(n_ptr))
173 CALL section_vals_val_get(kpset,
"SPECIAL_POINT", i_rep_section=i_rep, i_rep_val=ip, c_vals=strptr)
174 IF (
SIZE(strptr(:), 1) == 4)
THEN
175 spname(ip) = strptr(1)
177 CALL read_float_object(strptr(i + 1), kpptr(i), error_message)
178 IF (len_trim(error_message) > 0) cpabort(trim(error_message))
180 ELSE IF (
SIZE(strptr(:), 1) == 3)
THEN
181 spname(ip) =
"not specified"
183 CALL read_float_object(strptr(i), kpptr(i), error_message)
184 IF (len_trim(error_message) > 0) cpabort(trim(error_message))
187 cpabort(
"Input SPECIAL_POINT invalid")
191 kspecial(1:3, ip) = kpptr(1:3)
192 CASE (
"CART_ANGSTROM")
193 kspecial(1:3, ip) = (kpptr(1)*cart_hmat(1, 1:3) + &
194 kpptr(2)*cart_hmat(2, 1:3) + &
195 kpptr(3)*cart_hmat(3, 1:3))/twopi*angstrom
197 kspecial(1:3, ip) = (kpptr(1)*cart_hmat(1, 1:3) + &
198 kpptr(2)*cart_hmat(2, 1:3) + &
199 kpptr(3)*cart_hmat(3, 1:3))/twopi
201 cpabort(
"Unknown unit <"//trim(ustr)//
"> specified for k-point definition")
204 npoints = (n_ptr - 1)*npline + 1
205 cpassert(npoints >= 1)
208 ALLOCATE (kpgeneral(3, npoints))
209 kpgeneral(1:3, 1) = kspecial(1:3, 1)
214 kpgeneral(1:3, ikk) = kspecial(1:3, ik - 1) + &
215 REAL(ip, kind=dp)/real(npline, kind=dp)* &
216 (kspecial(1:3, ik) - kspecial(1:3, ik - 1))
221 DEALLOCATE (kpgeneral)
223 CALL get_qs_env(qs_env, dft_control=dft_control)
224 nspins = dft_control%nspins
225 kp => kpoint%kp_env(1)%kpoint_env
226 CALL get_mo_set(kp%mos(1), nmo=nmo)
227 ALLOCATE (eigval(nmo), occnum(nmo))
228 CALL get_kpoint_info(kpoint, nkp=nkp, kp_range=kp_range, xkp=xkp, wkp=wkp)
230 IF (unit_nr > 0)
THEN
231 WRITE (unit=unit_nr, fmt=
"(T2,A,I4,T71,I10)") &
232 "KPOINTS| Number of k-points in set ", i_rep, npoints
233 WRITE (unit=unit_nr, fmt=
"(T2,A)") &
234 "KPOINTS| In units of b-vector [2pi/Bohr]"
236 WRITE (unit=unit_nr, fmt=
"(T2,A,I5,1X,A11,3(1X,F12.6))") &
237 "KPOINTS| Special point ", ip, adjustl(trim(spname(ip))), kspecial(1:3, ip)
240 IF (bs_data_unit > 0 .AND. (bs_data_unit /= unit_nr))
THEN
241 WRITE (unit=bs_data_unit, fmt=
"(4(A,I0),A)") &
242 "# Set ", i_rep,
": ", n_ptr,
" special points, ", npoints,
" k-points, ", nmo,
" bands"
244 WRITE (unit=bs_data_unit, fmt=
"(A,I0,T20,T24,3(1X,F14.8),2X,A)") &
245 "# Special point ", ip, kspecial(1:3, ip), adjustl(trim(spname(ip)))
250 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
253 ikpgr = ik - kp_range(1) + 1
254 kp => kpoint%kp_env(ikpgr)%kpoint_env
255 CALL get_mo_set(kp%mos(ispin), eigenvalues=eigenvalues, occupation_numbers=occupation_numbers)
256 eigval(1:nmo) = eigenvalues(1:nmo)
257 occnum(1:nmo) = occupation_numbers(1:nmo)
259 eigval(1:nmo) = 0.0_dp
260 occnum(1:nmo) = 0.0_dp
262 CALL kpoint%para_env_inter_kp%sum(eigval)
263 CALL kpoint%para_env_inter_kp%sum(occnum)
264 IF (bs_data_unit > 0)
THEN
265 WRITE (unit=bs_data_unit, fmt=
"(A,I0,T15,A,I0,A,T24,3(1X,F14.8),3X,F14.8)") &
266 "# Point ", ik,
" Spin ", ispin,
":", xkp(1:3, ik), wkp(ik)
267 WRITE (unit=bs_data_unit, fmt=
"(A)") &
268 "# Band Energy [eV] Occupation"
270 WRITE (unit=bs_data_unit, fmt=
"(T2,I7,2(1X,F14.8))") &
271 imo, eigval(imo)*evolt, occnum(imo)
277 DEALLOCATE (kspecial, spname)
278 DEALLOCATE (eigval, occnum)
279 CALL kpoint_release(kpoint)
281 IF (unit_nr > 0)
THEN
282 WRITE (unit=unit_nr, fmt=
"(T2,A,T67,F14.3)")
"KPOINTS| Time for k-point line ", t2 - t1
288 IF (.NOT. io_default)
THEN
289 IF (para_env%is_source())
CALL close_file(bs_data_unit)
294 END SUBROUTINE do_calculate_band_structure
310 kp_shift, gamma_centered)
311 TYPE(qs_environment_type),
POINTER :: qs_env
312 TYPE(kpoint_type),
POINTER :: kpoint
313 CHARACTER(LEN=*),
INTENT(IN) :: scheme
314 INTEGER,
INTENT(IN) :: nadd
315 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: mp_grid
316 REAL(kind=dp),
DIMENSION(:, :),
INTENT(IN), &
317 OPTIONAL :: kpgeneral
318 INTEGER,
INTENT(IN),
OPTIONAL :: group_size_ext
319 REAL(kind=dp),
DIMENSION(3),
INTENT(IN),
OPTIONAL :: kp_shift
320 LOGICAL,
INTENT(IN),
OPTIONAL :: gamma_centered
324 REAL(dp),
POINTER :: potential(:, :)
325 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
326 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s
327 TYPE(dft_control_type),
POINTER :: dft_control
328 TYPE(kpoint_type),
POINTER :: scf_kpoints
329 TYPE(mp_para_env_type),
POINTER :: para_env
330 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
332 TYPE(qs_scf_env_type),
POINTER :: scf_env
333 TYPE(scf_control_type),
POINTER :: scf_control
336 kp_shift, gamma_centered)
338 CALL get_qs_env(qs_env=qs_env, para_env=para_env, blacs_env=blacs_env)
339 CALL kpoint_env_initialize(kpoint, para_env, blacs_env)
341 CALL kpoint_initialize_mos(kpoint, qs_env%mos, nadd)
342 CALL kpoint_initialize_mo_set(kpoint)
344 CALL get_qs_env(qs_env, sab_kp=sab_nl, dft_control=dft_control)
345 CALL kpoint_init_cell_index(kpoint, sab_nl, para_env, dft_control%nimages)
347 CALL get_qs_env(qs_env, matrix_ks_kp=matrix_ks, matrix_s_kp=matrix_s, &
348 scf_env=scf_env, scf_control=scf_control, kpoints=scf_kpoints)
350 IF (
ASSOCIATED(scf_kpoints))
THEN
351 IF (
ALLOCATED(scf_kpoints%lowdin_v))
THEN
352 IF (any(scf_kpoints%lowdin_v /= 0.0_dp)) potential => scf_kpoints%lowdin_v
355 IF (
ASSOCIATED(potential))
THEN
356 CALL diag_kp_smat(matrix_s, kpoint, scf_env%scf_work1)
357 DO ik = 1,
SIZE(kpoint%kp_env)
358 CALL lowdin_kp_prepare(kpoint%kp_env(ik)%kpoint_env, scf_kpoints%lowdin_orbitals, .false.)
361 CALL do_general_diag_kp(matrix_ks, matrix_s, kpoint, scf_env, scf_control, .false., diis_step, &
377 kp_shift, gamma_centered)
379 TYPE(kpoint_type),
POINTER :: kpoint
380 CHARACTER(LEN=*),
INTENT(IN) :: scheme
381 INTEGER,
INTENT(IN),
OPTIONAL :: group_size_ext
382 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: mp_grid
383 REAL(kind=dp),
DIMENSION(:, :),
INTENT(IN), &
384 OPTIONAL :: kpgeneral
385 REAL(kind=dp),
DIMENSION(3),
INTENT(IN),
OPTIONAL :: kp_shift
386 LOGICAL,
INTENT(IN),
OPTIONAL :: gamma_centered
388 INTEGER :: i, idim, ix, iy, iz, npoints
389 INTEGER,
DIMENSION(3) :: ik
390 LOGICAL :: gamma_mesh
391 REAL(kind=dp),
DIMENSION(3) :: kpt_latt, shift
393 cpassert(.NOT.
ASSOCIATED(kpoint))
395 CALL kpoint_create(kpoint)
397 IF (
PRESENT(kp_shift))
THEN
402 IF (
PRESENT(gamma_centered))
THEN
403 gamma_mesh = gamma_centered
408 kpoint%kp_scheme = scheme
409 kpoint%symmetry = .false.
410 kpoint%verbose = .false.
411 kpoint%full_grid = .false.
412 kpoint%use_real_wfn = .false.
413 kpoint%gamma_centered = gamma_mesh
414 kpoint%kp_shift = shift
415 kpoint%eps_geo = 1.e-6_dp
416 IF (
PRESENT(group_size_ext))
THEN
417 kpoint%parallel_group_size = group_size_ext
419 kpoint%parallel_group_size = -1
424 ALLOCATE (kpoint%xkp(3, 1), kpoint%wkp(1))
425 kpoint%xkp(1:3, 1) = 0.0_dp
426 kpoint%wkp(1) = 1.0_dp
427 kpoint%symmetry = .true.
428 ALLOCATE (kpoint%kp_sym(1))
429 NULLIFY (kpoint%kp_sym(1)%kpoint_sym)
430 CALL kpoint_sym_create(kpoint%kp_sym(1)%kpoint_sym)
431 CASE (
"MONKHORST-PACK",
"MACDONALD")
432 cpassert(
PRESENT(mp_grid))
433 npoints = mp_grid(1)*mp_grid(2)*mp_grid(3)
434 kpoint%nkp_grid(1:3) = mp_grid(1:3)
435 kpoint%full_grid = .true.
437 ALLOCATE (kpoint%xkp(3, npoints), kpoint%wkp(npoints))
438 kpoint%wkp(:) = 1._dp/real(npoints, kind=dp)
440 DO ix = 1, mp_grid(1)
441 DO iy = 1, mp_grid(2)
442 DO iz = 1, mp_grid(3)
446 IF (gamma_mesh .AND. mod(mp_grid(idim), 2) == 0)
THEN
447 kpt_latt(idim) = real(2*ik(idim) - mp_grid(idim), kind=dp)/ &
448 (2._dp*real(mp_grid(idim), kind=dp))
450 kpt_latt(idim) = real(2*ik(idim) - mp_grid(idim) - 1, kind=dp)/ &
451 (2._dp*real(mp_grid(idim), kind=dp))
454 kpoint%xkp(1:3, i) = kpt_latt(1:3) + shift(1:3)
459 ALLOCATE (kpoint%kp_sym(kpoint%nkp))
461 NULLIFY (kpoint%kp_sym(i)%kpoint_sym)
462 CALL kpoint_sym_create(kpoint%kp_sym(i)%kpoint_sym)
465 cpassert(
PRESENT(kpgeneral))
466 npoints =
SIZE(kpgeneral, 2)
468 ALLOCATE (kpoint%xkp(3, npoints), kpoint%wkp(npoints))
469 kpoint%wkp(:) = 1._dp/real(npoints, kind=dp)
470 kpoint%xkp(1:3, 1:npoints) = kpgeneral(1:3, 1:npoints)
472 ALLOCATE (kpoint%kp_sym(kpoint%nkp))
474 NULLIFY (kpoint%kp_sym(i)%kpoint_sym)
475 CALL kpoint_sym_create(kpoint%kp_sym(i)%kpoint_sym)
478 cpabort(
"Unknown kpoint scheme requested")
Handles all functions related to the CELL.
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
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...
Utility routines to read data from files. Kept as close as possible to the old parser because.
elemental subroutine, public read_float_object(string, object, error_message)
Returns a floating point number read from a string including fraction like z1/z2.
Add the DFT+U contribution to the Hamiltonian matrix.
subroutine, public lowdin_kp_prepare(kp, orbitals, use_real_wfn, smat)
Prepare selected Lowdin projectors and their reusable product workspace.
Defines the basic variable types.
integer, parameter, public max_line_length
integer, parameter, public dp
integer, parameter, public default_string_length
Routines needed for kpoint calculation.
subroutine, public kpoint_initialize_mo_set(kpoint)
...
subroutine, public kpoint_init_cell_index(kpoint, sab_nl, para_env, nimages)
Generates the mapping of cell indices and linear RS index CELL (0,0,0) is always mapped to index 1.
subroutine, public kpoint_initialize_mos(kpoint, mos, added_mos, for_aux_fit)
Initialize a set of MOs and density matrix for each kpoint (kpoint group).
subroutine, public kpoint_env_initialize(kpoint, para_env, blacs_env, with_aux_fit)
Initialize the kpoint environment.
Types and basic routines needed for a kpoint calculation.
subroutine, public kpoint_sym_create(kp_sym)
Create a single kpoint symmetry environment.
subroutine, public kpoint_release(kpoint)
Release a kpoint environment, deallocate all data.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, lattice_fft)
Retrieve information from a kpoint environment.
subroutine, public kpoint_create(kpoint)
Create a kpoint environment.
Machine interface based on Fortran 2003 and POSIX.
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Interface to the message passing library MPI.
Definition of physical constants:
real(kind=dp), parameter, public evolt
real(kind=dp), parameter, public angstrom
Calculation of band structures.
subroutine, public calculate_kpoints_for_bs(kpoint, scheme, group_size_ext, mp_grid, kpgeneral, kp_shift, gamma_centered)
...
subroutine, public calculate_kp_orbitals(qs_env, kpoint, scheme, nadd, mp_grid, kpgeneral, group_size_ext, kp_shift, gamma_centered)
diagonalize KS matrices at a set of kpoints
subroutine, public calculate_band_structure(qs_env)
Main routine for band structure calculation.
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, mimic, 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, sab_cneo, 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, matrix_vhxc, 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, xcint_weights, 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, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_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, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public qs_env_release(qs_env)
releases the given qs_env (see doc/ReferenceCounting.html)
Initialize a qs_env for kpoint calculations starting from a gamma point qs_env.
subroutine, public create_kp_from_gamma(qs_env, qs_env_kp, with_xc_terms)
...
Definition and initialisation of the mo data type.
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, cmo_coeff)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
Different diagonalization schemes that can be used for the iterative solution of the eigenvalue probl...
subroutine, public do_general_diag_kp(matrix_ks, matrix_s, kpoints, scf_env, scf_control, update_p, diis_step, diis_error, qs_env, probe, added_mos_auto_grow, potential)
Kpoint diagonalization routine Transforms matrices to kpoint, distributes kpoint groups,...
subroutine, public diag_kp_smat(matrix_s, kpoints, fmwork, lowdin_forces)
Kpoint diagonalization routine Transforms matrices to kpoint, distributes kpoint groups,...
module that contains the definitions of the scf types
parameters that control an scf iteration
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Type defining parameters related to the simulation cell.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
Keeps information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment