56#include "./base/base_uses.f90"
62 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'preconditioner'
103 matrix_t, mo_set, energy_gap, convert_precond_to_dbcsr, chol_type)
106 INTEGER,
INTENT(IN) :: precon_type, solver_type
108 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: matrix_s, matrix_t
110 REAL(kind=
dp) :: energy_gap
111 LOGICAL,
INTENT(IN),
OPTIONAL :: convert_precond_to_dbcsr
112 INTEGER,
INTENT(IN),
OPTIONAL :: chol_type
114 CHARACTER(len=*),
PARAMETER :: routinen =
'make_preconditioner'
116 INTEGER :: handle, k, my_solver_type, nao, nhomo
117 LOGICAL :: my_convert_precond_to_dbcsr, &
118 needs_full_spectrum, needs_homo, &
120 REAL(kind=
dp) :: energy_homo
121 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues_ot
127 CALL timeset(routinen, handle)
129 CALL get_mo_set(mo_set=mo_set, mo_coeff=mo_coeff, mo_coeff_b=mo_coeff_b, homo=nhomo)
130 use_mo_coeff_b = mo_set%use_mo_coeff_b
134 my_convert_precond_to_dbcsr = .false.
135 IF (
PRESENT(convert_precond_to_dbcsr)) my_convert_precond_to_dbcsr = convert_precond_to_dbcsr
143 needs_full_spectrum = .false.
146 SELECT CASE (precon_type)
148 needs_full_spectrum = .true.
150 IF (use_mo_coeff_b)
THEN
156 needs_full_spectrum = .true.
161 cpabort(
"The preconditioner is unknown ...")
164 ALLOCATE (eigenvalues_ot(k))
166 IF (needs_full_spectrum)
THEN
173 IF (use_mo_coeff_b)
THEN
175 eigenvalues_ot, do_rotation=.false., &
176 para_env=mo_coeff%matrix_struct%para_env, &
177 blacs_env=mo_coeff%matrix_struct%context)
180 eigenvalues_ot, do_rotation=.false.)
183 cpassert(nhomo > 0 .AND. nhomo <= k)
184 energy_homo = eigenvalues_ot(nhomo)
188 cpabort(
"Not yet implemented")
195 my_solver_type = solver_type
196 preconditioner_env%in_use = precon_type
198 IF (
PRESENT(chol_type)) preconditioner_env%cholesky_use = chol_type
199 preconditioner_env%in_use = precon_type
202 energy_homo, eigenvalues_ot, energy_gap, my_solver_type)
205 context=preconditioner_env%ctxt, &
206 para_env=preconditioner_env%para_env)
212 energy_homo, eigenvalues_ot(1:nhomo), energy_gap, my_solver_type)
222 IF (my_convert_precond_to_dbcsr)
THEN
226 preconditioner_env%para_env, preconditioner_env%ctxt)
229 DEALLOCATE (eigenvalues_ot)
231 CALL timestop(handle)
247 INTEGER,
INTENT(IN) :: prec_type, nspins
253 NULLIFY (para_env, blacs_env)
254 CALL get_qs_env(qs_env, para_env=para_env, blacs_env=blacs_env)
257 SELECT CASE (prec_type)
273 SELECT CASE (prec_type)
306 ot_preconditioner, prec_type, solver_type, &
307 energy_gap, nspins, has_unit_metric, &
308 convert_to_dbcsr, chol_type, full_mo_set)
311 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
312 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
314 INTEGER,
INTENT(IN) :: prec_type, solver_type
315 REAL(
dp),
INTENT(IN) :: energy_gap
316 INTEGER,
INTENT(IN) :: nspins
317 LOGICAL,
INTENT(IN),
OPTIONAL :: has_unit_metric, convert_to_dbcsr
318 INTEGER,
INTENT(IN),
OPTIONAL :: chol_type
319 LOGICAL,
INTENT(IN),
OPTIONAL :: full_mo_set
321 CHARACTER(LEN=*),
PARAMETER :: routinen =
'prepare_preconditioner'
323 CHARACTER(LEN=default_string_length) :: msg
324 INTEGER :: handle, icall, ispin, n_loops
325 INTEGER,
DIMENSION(5) :: nocc, norb
326 LOGICAL :: do_co_rotate, my_convert_to_dbcsr, &
327 my_full_mo_set, my_has_unit_metric, &
332 TYPE(
dbcsr_type),
POINTER :: matrix_t, mo_coeff_b
336 CALL timeset(routinen, handle)
337 NULLIFY (matrix_t, mo_coeff_b, mo_coeff, kinetic, dft_control, para_env, blacs_env)
338 my_has_unit_metric = .false.
339 IF (
PRESENT(has_unit_metric)) my_has_unit_metric = has_unit_metric
340 my_convert_to_dbcsr = .true.
341 IF (
PRESENT(convert_to_dbcsr)) my_convert_to_dbcsr = convert_to_dbcsr
342 my_full_mo_set = .false.
343 IF (
PRESENT(full_mo_set)) my_full_mo_set = full_mo_set
346 dft_control=dft_control, &
350 IF (dft_control%qs_control%semi_empirical .OR. dft_control%qs_control%dftb .OR. &
351 dft_control%qs_control%xtb)
THEN
353 msg =
"Full_kinetic not available for semi-empirical methods"
356 matrix_t => matrix_s(1)%matrix
358 cpassert(.NOT. my_has_unit_metric)
360 matrix_t => kinetic(1)%matrix
366 IF (my_full_mo_set)
THEN
368 CALL get_mo_set(mo_set=mos(ispin), homo=nocc(ispin), nmo=norb(ispin))
369 CALL set_mo_set(mo_set=mos(ispin), homo=norb(ispin))
376 SELECT CASE (prec_type)
381 do_co_rotate =
ASSOCIATED(qs_env%mo_derivs)
383 CALL get_mo_set(mo_set=mos(ispin), mo_coeff_b=mo_coeff_b, mo_coeff=mo_coeff)
384 use_mo_coeff_b = mos(ispin)%use_mo_coeff_b
385 IF (use_mo_coeff_b .AND. do_co_rotate)
THEN
387 do_rotation=.true., &
388 co_rotate=qs_env%mo_derivs(ispin)%matrix, &
391 ELSEIF (use_mo_coeff_b)
THEN
393 do_rotation=.true., &
406 SELECT CASE (prec_type)
408 DO ispin = 1,
SIZE(ot_preconditioner)
409 ot_preconditioner(ispin)%preconditioner%in_use = 0
412 DO icall = 1, n_loops
413 IF (my_has_unit_metric)
THEN
417 matrix_h=matrix_ks(icall)%matrix, &
419 energy_gap=energy_gap, &
420 convert_precond_to_dbcsr=my_convert_to_dbcsr)
425 matrix_h=matrix_ks(icall)%matrix, &
426 matrix_s=matrix_s(1)%matrix, &
429 energy_gap=energy_gap, &
430 convert_precond_to_dbcsr=my_convert_to_dbcsr, chol_type=chol_type)
436 IF (my_full_mo_set)
THEN
438 CALL set_mo_set(mo_set=mos(ispin), homo=nocc(ispin))
442 CALL timestop(handle)
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS 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
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_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Interface to the message passing library MPI.
computes preconditioners, and implements methods to apply them currently used in qs_ot
subroutine, public apply_preconditioner_fm(preconditioner_env, matrix_in, matrix_out)
applies a previously created preconditioner to a full matrix
subroutine, public apply_preconditioner_dbcsr(preconditioner_env, matrix_in, matrix_out)
...
computes preconditioners, and implements methods to apply them currently used in qs_ot
subroutine, public make_preconditioner_matrix(preconditioner_env, matrix_h, matrix_s, matrix_t, mo_coeff, energy_homo, eigenvalues_ot, energy_gap, my_solver_type)
...
solves the preconditioner, contains to utility function for fm<->dbcsr transfers, should be moved soo...
subroutine, public transfer_dbcsr_to_fm(dbcsr_matrix, fm_matrix, para_env, context)
transfers a dbcsr to a full matrix
subroutine, public solve_preconditioner(my_solver_type, preconditioner_env, matrix_s, matrix_h)
...
subroutine, public transfer_fm_to_dbcsr(fm_matrix, dbcsr_matrix, template_mat)
transfers a full matrix to a dbcsr
subroutine, public init_preconditioner(preconditioner_env, para_env, blacs_env)
...
subroutine, public destroy_preconditioner(preconditioner_env)
...
computes preconditioners, and implements methods to apply them currently used in qs_ot
subroutine, public restart_preconditioner(qs_env, preconditioner, prec_type, nspins)
Allows for a restart of the preconditioner depending on the method it purges all arrays or keeps them...
subroutine, public prepare_preconditioner(qs_env, mos, matrix_ks, matrix_s, ot_preconditioner, prec_type, solver_type, energy_gap, nspins, has_unit_metric, convert_to_dbcsr, chol_type, full_mo_set)
...
subroutine, public make_preconditioner(preconditioner_env, precon_type, solver_type, matrix_h, matrix_s, matrix_t, mo_set, energy_gap, convert_precond_to_dbcsr, chol_type)
...
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.
collects routines that perform operations directly related to MOs
Definition and initialisation of the mo data type.
subroutine, public set_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, uniform_occupation, kts, mu, flexible_electron_count)
Set the components of a MO set data structure.
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.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
stores all the informations relevant to an mpi environment