(git:ccc2433)
qs_gamma2kp.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 Initialize a qs_env for kpoint calculations starting from a gamma point qs_env
10 !> \par History
11 !> 11.2016 created [JGH]
12 !> \author JGH
13 ! **************************************************************************************************
15  USE cp_subsys_types, ONLY: cp_subsys_type
16  USE dbcsr_api, ONLY: dbcsr_add,&
17  dbcsr_p_type
18  USE input_constants, ONLY: atomic_guess,&
19  xc_none
21  section_vals_type,&
24  USE kinds, ONLY: dp
25  USE kpoint_types, ONLY: kpoint_create,&
26  kpoint_type
27  USE message_passing, ONLY: mp_para_env_type
28  USE pw_methods, ONLY: pw_copy
29  USE pw_types, ONLY: pw_c1d_gs_type,&
30  pw_r3d_rs_type
32  USE qs_environment, ONLY: qs_init
33  USE qs_environment_types, ONLY: get_qs_env,&
35  qs_environment_type,&
38  USE qs_rho_types, ONLY: qs_rho_get,&
39  qs_rho_type
41  USE qs_scf_types, ONLY: qs_scf_env_type
42  USE scf_control_types, ONLY: scf_control_type
43 #include "./base/base_uses.f90"
44 
45  IMPLICIT NONE
46  PRIVATE
47 
48  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_gamma2kp'
49 
50  PUBLIC :: create_kp_from_gamma
51 
52 ! **************************************************************************************************
53 
54 CONTAINS
55 
56 ! **************************************************************************************************
57 !> \brief ...
58 !> \param qs_env ...
59 !> \param qs_env_kp ...
60 !> \param with_xc_terms ...
61 ! **************************************************************************************************
62  SUBROUTINE create_kp_from_gamma(qs_env, qs_env_kp, with_xc_terms)
63  TYPE(qs_environment_type), POINTER :: qs_env, qs_env_kp
64  LOGICAL, OPTIONAL :: with_xc_terms
65 
66  INTEGER :: ispin, xc_func
67  LOGICAL :: without_xc_terms
68  TYPE(cp_subsys_type), POINTER :: cp_subsys
69  TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: rho_ao_kp, rho_ao_kp_gamma
70  TYPE(kpoint_type), POINTER :: kpoint
71  TYPE(mp_para_env_type), POINTER :: para_env
72  TYPE(pw_c1d_gs_type), DIMENSION(:), POINTER :: rho_g_gamma, rho_g_kp
73  TYPE(pw_r3d_rs_type), DIMENSION(:), POINTER :: rho_r_gamma, rho_r_kp
74  TYPE(qs_rho_type), POINTER :: rho, rho_gamma
75  TYPE(qs_scf_env_type), POINTER :: scf_env
76  TYPE(scf_control_type), POINTER :: scf_control
77  TYPE(section_vals_type), POINTER :: force_env_section, subsys_section, &
78  xc_fun_section
79 
80  CALL get_qs_env(qs_env, &
81  para_env=para_env, &
82  input=force_env_section, &
83  cp_subsys=cp_subsys)
84 
85  NULLIFY (subsys_section)
86 
87  NULLIFY (kpoint)
88  CALL kpoint_create(kpoint)
89  kpoint%kp_scheme = "GAMMA"
90  kpoint%symmetry = .false.
91  kpoint%verbose = .false.
92  kpoint%full_grid = .true.
93  kpoint%eps_geo = 1.0e-6_dp
94  kpoint%use_real_wfn = .true.
95  kpoint%parallel_group_size = 0
96 
97  without_xc_terms = .false.
98  IF (PRESENT(with_xc_terms)) without_xc_terms = .NOT. with_xc_terms
99 
100  IF (without_xc_terms) THEN
101  xc_fun_section => section_vals_get_subs_vals(force_env_section, "DFT%XC%XC_FUNCTIONAL")
102  CALL section_vals_val_get(xc_fun_section, "_SECTION_PARAMETERS_", i_val=xc_func)
103  CALL section_vals_val_set(xc_fun_section, "_SECTION_PARAMETERS_", i_val=xc_none)
104  END IF
105 
106  ALLOCATE (qs_env_kp)
107  CALL qs_env_create(qs_env_kp)
108  CALL qs_init(qs_env_kp, para_env, cp_subsys=cp_subsys, kpoint_env=kpoint, &
109  force_env_section=force_env_section, subsys_section=subsys_section, &
110  use_motion_section=.false.)
111 
112  CALL get_qs_env(qs_env_kp, scf_control=scf_control)
113  scf_control%density_guess = atomic_guess
114  CALL qs_energies_init(qs_env_kp, calc_forces=.false.)
115 
116  NULLIFY (scf_env)
117  CALL qs_scf_env_init_basic(qs_env_kp, scf_env)
118 
119  CALL set_qs_env(qs_env_kp, scf_env=scf_env)
120 
121  ! copy density matrix, n(r) and n(G) from Gamma-only to kpoint calculation
122  CALL get_qs_env(qs_env, rho=rho_gamma)
123  CALL qs_rho_get(rho_gamma, rho_ao_kp=rho_ao_kp_gamma, rho_r=rho_r_gamma, rho_g=rho_g_gamma)
124  CALL get_qs_env(qs_env_kp, rho=rho)
125  CALL qs_rho_get(rho, rho_ao_kp=rho_ao_kp, rho_r=rho_r_kp, rho_g=rho_g_kp)
126 
127  DO ispin = 1, SIZE(rho_r_gamma)
128  CALL pw_copy(rho_r_gamma(ispin), rho_r_kp(ispin))
129  CALL pw_copy(rho_g_gamma(ispin), rho_g_kp(ispin))
130  CALL dbcsr_add(matrix_a=rho_ao_kp(ispin, 1)%matrix, alpha_scalar=0.0_dp, &
131  matrix_b=rho_ao_kp_gamma(ispin, 1)%matrix, beta_scalar=1.0_dp)
132  END DO
133 
134  CALL qs_ks_update_qs_env(qs_env_kp, print_active=.false.)
135 
136  IF (without_xc_terms) THEN
137  ! set back the functional
138  CALL section_vals_val_set(xc_fun_section, "_SECTION_PARAMETERS_", i_val=xc_func)
139  END IF
140 
141  END SUBROUTINE create_kp_from_gamma
142 
143 END MODULE qs_gamma2kp
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 atomic_guess
integer, parameter, public xc_none
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_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
Types and basic routines needed for a kpoint calculation.
Definition: kpoint_types.F:15
subroutine, public kpoint_create(kpoint)
Create a kpoint environment.
Definition: kpoint_types.F:188
Interface to the message passing library MPI.
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...
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.
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 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)
Read the input and the database files for the setup of the QUICKSTEP environment.
Initialize a qs_env for kpoint calculations starting from a gamma point qs_env.
Definition: qs_gamma2kp.F:14
subroutine, public create_kp_from_gamma(qs_env, qs_env_kp, with_xc_terms)
...
Definition: qs_gamma2kp.F:63
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
Definition: qs_ks_methods.F:22
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
superstucture that hold various representations of the density and keeps track of which ones are vali...
Definition: qs_rho_types.F:18
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
Definition: qs_rho_types.F:229
Utility routines for qs_scf.
subroutine, public qs_scf_env_init_basic(qs_env, scf_env)
initializes input parameters if needed for non-scf calclulations using diagonalization
module that contains the definitions of the scf types
Definition: qs_scf_types.F:14
parameters that control an scf iteration