72#include "./base/base_uses.f90"
78 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pao_methods'
100 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_init_kinds'
102 CHARACTER(LEN=default_path_length) :: pao_model_file
103 INTEGER :: handle, i, ikind, pao_basis_size
107 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
109 CALL timeset(routinen, handle)
110 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
112 DO ikind = 1,
SIZE(qs_kind_set)
114 basis_set=basis_set, &
115 pao_basis_size=pao_basis_size, &
116 pao_model_file=pao_model_file, &
118 pao_descriptors=pao_descriptors)
120 IF (pao_basis_size < 1)
THEN
122 CALL set_qs_kind(qs_kind_set(ikind), pao_basis_size=basis_set%nsgf)
129 DO i = 1,
SIZE(pao_descriptors)
130 pao_descriptors(i)%beta_radius =
exp_radius(0, pao_descriptors(i)%beta, pao%eps_pgf, 1.0_dp)
131 pao_descriptors(i)%screening_radius =
exp_radius(0, pao_descriptors(i)%screening, pao%eps_pgf, 1.0_dp)
135 IF (len_trim(pao_model_file) > 0)
THEN
136 IF (.NOT.
ALLOCATED(pao%models))
THEN
137 ALLOCATE (pao%models(
SIZE(qs_kind_set)))
139 CALL pao_model_load(pao, qs_env, ikind, pao_model_file, pao%models(ikind))
143 CALL timestop(handle)
153 INTEGER :: iatom, natoms
154 INTEGER,
DIMENSION(:),
POINTER :: pao_basis, param_cols, param_rows, &
157 CALL dbcsr_get_info(pao%matrix_Y, row_blk_size=pri_basis, col_blk_size=pao_basis)
158 cpassert(
SIZE(pao_basis) ==
SIZE(pri_basis))
159 natoms =
SIZE(pao_basis)
161 CALL dbcsr_get_info(pao%matrix_X, row_blk_size=param_rows, col_blk_size=param_cols)
162 cpassert(
SIZE(param_rows) == natoms .AND.
SIZE(param_cols) == natoms)
164 IF (pao%iw_atoms > 0)
THEN
166 WRITE (pao%iw_atoms,
"(A,I7,T20,A,I3,T45,A,I3,T65,A,I3)") &
167 " PAO| atom: ", iatom, &
168 " prim_basis: ", pri_basis(iatom), &
169 " pao_basis: ", pao_basis(iatom), &
170 " pao_params: ", (param_cols(iatom)*param_rows(iatom))
184 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_build_orthogonalizer'
186 INTEGER :: acol, arow, handle, i, iatom, j, k, n
189 REAL(
dp),
DIMENSION(:),
POINTER :: evals
190 REAL(
dp),
DIMENSION(:, :),
POINTER :: a, block_n, block_n_inv, block_s
194 CALL timeset(routinen, handle)
198 CALL dbcsr_create(pao%matrix_N, template=matrix_s(1)%matrix, name=
"PAO matrix_N")
201 CALL dbcsr_create(pao%matrix_N_inv, template=matrix_s(1)%matrix, name=
"PAO matrix_N_inv")
209 iatom = arow; cpassert(arow == acol)
211 CALL dbcsr_get_block_p(matrix=pao%matrix_N_inv, row=iatom, col=iatom, block=block_n_inv, found=found)
212 cpassert(
ASSOCIATED(block_n_inv))
214 CALL dbcsr_get_block_p(matrix=matrix_s(1)%matrix, row=iatom, col=iatom, block=block_s, found=found)
215 cpassert(
ASSOCIATED(block_s))
217 n =
SIZE(block_s, 1); cpassert(
SIZE(block_s, 1) ==
SIZE(block_s, 2))
218 ALLOCATE (a(n, n), evals(n))
228 w = 1.0_dp/sqrt(evals(k))
232 block_n(i, j) = block_n(i, j) + w*a(i, k)*a(j, k)
233 block_n_inv(i, j) = block_n_inv(i, j) + v*a(i, k)*a(j, k)
237 DEALLOCATE (a, evals)
244 name=
"PAO matrix_N_diag", &
245 dist=pao%diag_distribution, &
246 template=matrix_s(1)%matrix)
250 name=
"PAO matrix_N_inv_diag", &
251 dist=pao%diag_distribution, &
252 template=matrix_s(1)%matrix)
256 CALL timestop(handle)
268 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_build_selector'
270 INTEGER :: acol, arow, handle, i, iatom, ikind, m, &
272 INTEGER,
DIMENSION(:),
POINTER :: blk_sizes_aux, blk_sizes_pri
273 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_y
277 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
279 CALL timeset(routinen, handle)
284 qs_kind_set=qs_kind_set, &
285 particle_set=particle_set)
287 CALL dbcsr_get_info(matrix_s(1)%matrix, col_blk_size=blk_sizes_pri)
289 ALLOCATE (blk_sizes_aux(natoms))
291 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
292 CALL get_qs_kind(qs_kind_set(ikind), pao_basis_size=m)
294 IF (blk_sizes_pri(iatom) < m)
THEN
295 cpabort(
"PAO basis size exceeds primary basis size.")
297 blk_sizes_aux(iatom) = m
301 template=matrix_s(1)%matrix, &
303 row_blk_size=blk_sizes_pri, &
304 col_blk_size=blk_sizes_aux, &
306 DEALLOCATE (blk_sizes_aux)
318 block_y(i, i) = 1.0_dp
324 CALL timestop(handle)
336 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_build_diag_distribution'
338 INTEGER :: handle, iatom, natoms, pgrid_cols, &
340 INTEGER,
DIMENSION(:),
POINTER :: diag_col_dist, diag_row_dist
344 CALL timeset(routinen, handle)
346 CALL get_qs_env(qs_env, natom=natoms, matrix_s=matrix_s)
349 CALL dbcsr_get_info(matrix=matrix_s(1)%matrix, distribution=main_dist)
353 ALLOCATE (diag_row_dist(natoms), diag_col_dist(natoms))
355 diag_row_dist(iatom) = mod(iatom - 1, pgrid_rows)
356 diag_col_dist(iatom) = mod((iatom - 1)/pgrid_rows, pgrid_cols)
361 row_dist=diag_row_dist, col_dist=diag_col_dist)
363 DEALLOCATE (diag_row_dist, diag_col_dist)
365 CALL timestop(handle)
377 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_build_matrix_X'
379 INTEGER :: handle, iatom, ikind, natoms
380 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, row_blk_size
383 CALL timeset(routinen, handle)
387 particle_set=particle_set)
390 ALLOCATE (row_blk_size(natoms), col_blk_size(natoms))
393 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
399 name=
"PAO matrix_X", &
400 dist=pao%diag_distribution, &
402 row_blk_size=row_blk_size, &
403 col_blk_size=col_blk_size)
404 DEALLOCATE (row_blk_size, col_blk_size)
409 CALL timestop(handle)
423 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
427 atomic_kind_set=atomic_kind_set, &
428 qs_kind_set=qs_kind_set)
432 name=
"PAO matrix_H0", &
433 dist=pao%diag_distribution, &
434 template=matrix_s(1)%matrix)
457 REAL(kind=
dp),
INTENT(IN) :: new_energy
458 LOGICAL,
INTENT(OUT) :: is_converged
460 REAL(kind=
dp) :: energy_diff, loop_eps, now, time_diff
463 energy_diff = new_energy - pao%energy_prev
464 pao%energy_prev = new_energy
466 time_diff = now - pao%step_start_time
467 pao%step_start_time = now
470 loop_eps = pao%norm_G/ls_scf_env%nelectron_total
471 is_converged = loop_eps < pao%eps_pao
473 IF (pao%istep > 1)
THEN
474 IF (pao%iw > 0)
WRITE (pao%iw, *)
"PAO| energy improvement:", energy_diff
478 IF (pao%iw > 0)
WRITE (pao%iw,
'(A,I6,11X,F20.9,1X,E10.3,1X,E10.3,1X,F9.3)') &
483 pao%linesearch%step_size, &
499 REAL(kind=
dp),
INTENT(OUT) :: energy
501 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_calc_energy'
503 INTEGER :: handle, ispin
504 REAL(kind=
dp) :: penalty, trace_ph
506 CALL timeset(routinen, handle)
509 CALL pao_calc_ab(pao, qs_env, ls_scf_env, gradient=.false., penalty=penalty)
512 CALL pao_rebuild_s(qs_env, ls_scf_env)
515 CALL pao_dm_trs4(qs_env, ls_scf_env)
519 DO ispin = 1, ls_scf_env%nspins
520 CALL dbcsr_dot(ls_scf_env%matrix_p(ispin), ls_scf_env%matrix_ks(ispin), trace_ph)
521 energy = energy + trace_ph
525 energy = energy + penalty
529 WRITE (pao%iw, *)
"PAO| energy:", energy,
"penalty:", penalty
531 CALL timestop(handle)
541 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_check_trace_PS'
543 INTEGER :: handle, ispin
544 REAL(kind=
dp) :: tmp, trace_ps
547 CALL timeset(routinen, handle)
548 CALL dbcsr_create(matrix_s_desym, template=ls_scf_env%matrix_s, matrix_type=
"N")
552 DO ispin = 1, ls_scf_env%nspins
553 CALL dbcsr_dot(ls_scf_env%matrix_p(ispin), matrix_s_desym, tmp)
554 trace_ps = trace_ps + tmp
559 IF (abs(ls_scf_env%nelectron_total - trace_ps) > 0.5)
THEN
560 cpabort(
"Number of electrons wrong. Trace(PS) ="//
cp_to_string(trace_ps))
563 CALL timestop(handle)
571 SUBROUTINE pao_read_preopt_dm(pao, qs_env)
575 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_read_preopt_dm'
577 INTEGER :: handle, ispin
578 REAL(kind=
dp) :: cs_pos
580 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, rho_ao
586 CALL timeset(routinen, handle)
589 dft_control=dft_control, &
596 IF (dft_control%nspins /= 1) cpabort(
"open shell not yet implemented")
600 DO ispin = 1, dft_control%nspins
601 CALL dbcsr_binary_read(pao%preopt_dm_file, matrix_new=matrix_tmp, distribution=dist)
603 IF (pao%iw > 0)
WRITE (pao%iw, *)
"PAO| Read restart DM "// &
604 trim(pao%preopt_dm_file)//
" with checksum: ", cs_pos
605 CALL dbcsr_copy(rho_ao(ispin)%matrix, matrix_tmp, keep_sparsity=.true.)
613 just_energy=.false., print_active=.true.)
614 IF (pao%iw > 0)
WRITE (pao%iw, *)
"PAO| Quickstep energy from restart density:", energy%total
616 CALL timestop(handle)
618 END SUBROUTINE pao_read_preopt_dm
625 SUBROUTINE pao_rebuild_s(qs_env, ls_scf_env)
629 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_rebuild_S'
634 CALL timeset(routinen, handle)
643 CALL timestop(handle)
644 END SUBROUTINE pao_rebuild_s
651 SUBROUTINE pao_dm_trs4(qs_env, ls_scf_env)
655 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_dm_trs4'
657 CHARACTER(LEN=default_path_length) :: project_name
658 INTEGER :: handle, ispin, nelectron_spin_real, nspin
660 REAL(kind=
dp) :: homo_spin, lumo_spin, mu_spin
664 CALL timeset(routinen, handle)
666 project_name = logger%iter_info%project_name
667 nspin = ls_scf_env%nspins
671 CALL matrix_qs_to_ls(ls_scf_env%matrix_ks(ispin), matrix_ks(ispin)%matrix, &
672 ls_scf_env%ls_mstruct, covariant=.true.)
674 nelectron_spin_real = ls_scf_env%nelectron_spin(ispin)
675 IF (ls_scf_env%nspins == 1) nelectron_spin_real = nelectron_spin_real/2
677 ls_scf_env%matrix_s_sqrt_inv, &
678 nelectron_spin_real, ls_scf_env%eps_filter, homo_spin, lumo_spin, mu_spin, &
679 dynamic_threshold=.false., converged=converged, &
680 max_iter_lanczos=ls_scf_env%max_iter_lanczos, &
681 eps_lanczos=ls_scf_env%eps_lanczos)
682 IF (.NOT. converged) cpabort(
"TRS4 did not converge")
685 IF (nspin == 1)
CALL dbcsr_scale(ls_scf_env%matrix_p(1), 2.0_dp)
687 CALL timestop(handle)
688 END SUBROUTINE pao_dm_trs4
701 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_check_grad'
703 INTEGER :: handle, i, iatom, j, natoms
704 INTEGER,
DIMENSION(:),
POINTER :: blk_sizes_col, blk_sizes_row
706 REAL(
dp) :: delta, delta_max, eps, gij_num
707 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_g, block_x
711 IF (pao%check_grad_tol < 0.0_dp)
RETURN
713 CALL timeset(routinen, handle)
715 ls_mstruct => ls_scf_env%ls_mstruct
717 CALL get_qs_env(qs_env, para_env=para_env, natom=natoms)
719 eps = pao%num_grad_eps
722 CALL dbcsr_get_info(pao%matrix_X, col_blk_size=blk_sizes_col, row_blk_size=blk_sizes_row)
726 IF (pao%iw > 0)
WRITE (pao%iw, *)
'PAO| checking gradient of atom ', iatom
727 CALL dbcsr_get_block_p(matrix=pao%matrix_X, row=iatom, col=iatom, block=block_x, found=found)
729 IF (
ASSOCIATED(block_x))
THEN
730 CALL dbcsr_get_block_p(matrix=pao%matrix_G, row=iatom, col=iatom, block=block_g, found=found)
731 cpassert(
ASSOCIATED(block_g))
734 DO i = 1, blk_sizes_row(iatom)
735 DO j = 1, blk_sizes_col(iatom)
736 SELECT CASE (pao%num_grad_order)
738 gij_num = -eval_point(block_x, i, j, -eps, pao, ls_scf_env, qs_env)
739 gij_num = gij_num + eval_point(block_x, i, j, +eps, pao, ls_scf_env, qs_env)
740 gij_num = gij_num/(2.0_dp*eps)
743 gij_num = eval_point(block_x, i, j, -2_dp*eps, pao, ls_scf_env, qs_env)
744 gij_num = gij_num - 8_dp*eval_point(block_x, i, j, -1_dp*eps, pao, ls_scf_env, qs_env)
745 gij_num = gij_num + 8_dp*eval_point(block_x, i, j, +1_dp*eps, pao, ls_scf_env, qs_env)
746 gij_num = gij_num - eval_point(block_x, i, j, +2_dp*eps, pao, ls_scf_env, qs_env)
747 gij_num = gij_num/(12.0_dp*eps)
750 gij_num = -1_dp*eval_point(block_x, i, j, -3_dp*eps, pao, ls_scf_env, qs_env)
751 gij_num = gij_num + 9_dp*eval_point(block_x, i, j, -2_dp*eps, pao, ls_scf_env, qs_env)
752 gij_num = gij_num - 45_dp*eval_point(block_x, i, j, -1_dp*eps, pao, ls_scf_env, qs_env)
753 gij_num = gij_num + 45_dp*eval_point(block_x, i, j, +1_dp*eps, pao, ls_scf_env, qs_env)
754 gij_num = gij_num - 9_dp*eval_point(block_x, i, j, +2_dp*eps, pao, ls_scf_env, qs_env)
755 gij_num = gij_num + 1_dp*eval_point(block_x, i, j, +3_dp*eps, pao, ls_scf_env, qs_env)
756 gij_num = gij_num/(60.0_dp*eps)
759 cpabort(
"Unsupported numerical derivative order: "//
cp_to_string(pao%num_grad_order))
762 IF (
ASSOCIATED(block_x))
THEN
763 delta = abs(gij_num - block_g(i, j))
764 delta_max = max(delta_max, delta)
771 CALL para_env%max(delta_max)
772 IF (pao%iw > 0)
WRITE (pao%iw, *)
'PAO| checked gradient, max delta:', delta_max
773 IF (delta_max > pao%check_grad_tol)
CALL cp_abort(__location__, &
774 "Analytic and numeric gradients differ too much:"//
cp_to_string(delta_max))
776 CALL timestop(handle)
790 FUNCTION eval_point(block_X, i, j, eps, pao, ls_scf_env, qs_env)
RESULT(energy)
791 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_x
792 INTEGER,
INTENT(IN) :: i, j
793 REAL(
dp),
INTENT(IN) :: eps
801 IF (
ASSOCIATED(block_x))
THEN
802 old_xij = block_x(i, j)
803 block_x(i, j) = block_x(i, j) + eps
810 IF (
ASSOCIATED(block_x))
THEN
811 block_x(i, j) = old_xij
814 END FUNCTION eval_point
825 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_store_P'
827 INTEGER :: handle, ispin, istore
833 IF (ls_scf_env%scf_history%nstore == 0)
RETURN
834 CALL timeset(routinen, handle)
835 ls_mstruct => ls_scf_env%ls_mstruct
836 pao => ls_scf_env%pao_env
837 CALL get_qs_env(qs_env, dft_control=dft_control, matrix_s=matrix_s)
839 ls_scf_env%scf_history%istore = ls_scf_env%scf_history%istore + 1
840 istore = mod(ls_scf_env%scf_history%istore - 1, ls_scf_env%scf_history%nstore) + 1
841 IF (pao%iw > 0)
WRITE (pao%iw, *)
"PAO| Storing density matrix for ASPC guess in slot:", istore
844 IF (ls_scf_env%scf_history%istore <= ls_scf_env%scf_history%nstore)
THEN
845 DO ispin = 1, dft_control%nspins
846 CALL dbcsr_create(ls_scf_env%scf_history%matrix(ispin, istore), template=matrix_s(1)%matrix)
853 DO ispin = 1, dft_control%nspins
855 CALL matrix_ls_to_qs(ls_scf_env%scf_history%matrix(ispin, istore), ls_scf_env%matrix_p(ispin), &
856 ls_scf_env%ls_mstruct, covariant=.false., keep_sparsity=.false.)
859 CALL timestop(handle)
873 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_guess_initial_P'
877 CALL timeset(routinen, handle)
879 IF (ls_scf_env%scf_history%istore > 0)
THEN
880 CALL pao_aspc_guess_p(pao, qs_env, ls_scf_env)
881 pao%need_initial_scf = .true.
883 IF (len_trim(pao%preopt_dm_file) > 0)
THEN
884 CALL pao_read_preopt_dm(pao, qs_env)
885 pao%need_initial_scf = .false.
886 pao%preopt_dm_file =
""
889 IF (pao%iw > 0)
WRITE (pao%iw,
'(A,F20.9)') &
890 " PAO| Energy from initial atomic guess:", ls_scf_env%energy_init
891 pao%need_initial_scf = .true.
895 CALL timestop(handle)
905 SUBROUTINE pao_aspc_guess_p(pao, qs_env, ls_scf_env)
910 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_aspc_guess_P'
912 INTEGER :: handle, iaspc, ispin, istore, naspc
919 CALL timeset(routinen, handle)
920 ls_mstruct => ls_scf_env%ls_mstruct
921 cpassert(ls_scf_env%scf_history%istore > 0)
924 CALL get_qs_env(qs_env, dft_control=dft_control, matrix_s=matrix_s)
926 IF (pao%iw > 0)
WRITE (pao%iw, *)
"PAO| Calculating initial guess with ASPC"
928 CALL dbcsr_create(matrix_p, template=matrix_s(1)%matrix)
930 naspc = min(ls_scf_env%scf_history%istore, ls_scf_env%scf_history%nstore)
931 DO ispin = 1, dft_control%nspins
935 alpha = (-1.0_dp)**(iaspc + 1)*real(iaspc, kind=
dp)* &
937 istore = mod(ls_scf_env%scf_history%istore - iaspc, ls_scf_env%scf_history%nstore) + 1
938 CALL dbcsr_add(matrix_p, ls_scf_env%scf_history%matrix(ispin, istore), 1.0_dp, alpha)
942 CALL matrix_qs_to_ls(ls_scf_env%matrix_p(ispin), matrix_p, ls_scf_env%ls_mstruct, covariant=.false.)
948 DO ispin = 1, dft_control%nspins
949 IF (dft_control%nspins == 1)
CALL dbcsr_scale(ls_scf_env%matrix_p(ispin), 0.5_dp)
951 CALL dbcsr_filter(ls_scf_env%matrix_p(ispin), ls_scf_env%eps_filter**(2.0_dp/3.0_dp))
954 CALL purify_mcweeny(ls_scf_env%matrix_p(ispin:ispin), ls_scf_env%matrix_s, ls_scf_env%eps_filter, 10)
955 IF (dft_control%nspins == 1)
CALL dbcsr_scale(ls_scf_env%matrix_p(ispin), 2.0_dp)
961 CALL ls_scf_dm_to_ks(qs_env, ls_scf_env, ls_scf_env%energy_init, iscf=0)
963 CALL timestop(handle)
964 END SUBROUTINE pao_aspc_guess_p
975 CHARACTER(len=*),
PARAMETER :: routinen =
'pao_add_forces'
977 INTEGER :: handle, iatom, natoms
978 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: forces
983 CALL timeset(routinen, handle)
984 pao => ls_scf_env%pao_env
986 IF (pao%iw > 0)
WRITE (pao%iw, *)
"PAO| Adding forces."
988 IF (pao%max_pao /= 0)
THEN
989 IF (pao%penalty_strength /= 0.0_dp)
THEN
990 cpabort(
"PAO forces require PENALTY_STRENGTH or MAX_PAO set to zero")
992 IF (pao%linpot_regu_strength /= 0.0_dp)
THEN
993 cpabort(
"PAO forces require LINPOT_REGULARIZATION_STRENGTH or MAX_PAO set to zero")
995 IF (pao%regularization /= 0.0_dp)
THEN
996 cpabort(
"PAO forces require REGULARIZATION or MAX_PAO set to zero")
1001 para_env=para_env, &
1002 particle_set=particle_set, &
1005 ALLOCATE (forces(natoms, 3))
1006 CALL pao_calc_ab(pao, qs_env, ls_scf_env, gradient=.true., forces=forces)
1008 IF (
SIZE(pao%ml_training_set) > 0)
THEN
1012 IF (
ALLOCATED(pao%models))
THEN
1016 CALL para_env%sum(forces)
1017 DO iatom = 1, natoms
1018 particle_set(iatom)%f = particle_set(iatom)%f + forces(iatom, :)
1023 CALL timestop(handle)
All kind of helpful little routines.
real(kind=dp) function, public exp_radius(l, alpha, threshold, prefactor, epsabs, epsrel, rlow)
The radius of a primitive Gaussian function for a given threshold is calculated. g(r) = prefactor*r**...
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public kuhne2007
integer, save, public kolafa2004
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, reuse_arrays)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_complete_redistribute(matrix, redist)
...
subroutine, public dbcsr_binary_read(filepath, distribution, matrix_new)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
real(kind=dp) function, public dbcsr_checksum(matrix, pos)
Calculates the checksum of a DBCSR matrix.
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
subroutine, public dbcsr_reserve_diag_blocks(matrix)
Reserves all diagonal blocks.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
lower level routines for linear scaling SCF
subroutine, public density_matrix_trs4(matrix_p, matrix_ks, matrix_s_sqrt_inv, nelectron, threshold, e_homo, e_lumo, e_mu, dynamic_threshold, matrix_ks_deviation, max_iter_lanczos, eps_lanczos, converged, iounit)
compute the density matrix using a trace-resetting algorithm
subroutine, public ls_scf_init_matrix_s(matrix_s, ls_scf_env)
initialize S matrix related properties (sqrt, inverse...) Might be factored-out since this seems comm...
Routines for a linear scaling quickstep SCF run based on the density matrix, with a focus on the inte...
subroutine, public ls_scf_qs_atomic_guess(qs_env, ls_scf_env, energy, nonscf)
get an atomic initial guess
subroutine, public matrix_ls_to_qs(matrix_qs, matrix_ls, ls_mstruct, covariant, keep_sparsity)
second link to QS, copy a LS matrix to QS matrix used to isolate QS style matrices from LS style will...
subroutine, public ls_scf_dm_to_ks(qs_env, ls_scf_env, energy_new, iscf)
use the density matrix in ls_scf_env to compute the new energy and KS matrix
subroutine, public matrix_qs_to_ls(matrix_ls, matrix_qs, ls_mstruct, covariant)
first link to QS, copy a QS matrix to LS matrix used to isolate QS style matrices from LS style will ...
Types needed for a linear scaling quickstep SCF run based on the density matrix.
Routines useful for iterative matrix calculations.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
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
Collection of simple mathematical functions and subroutines.
elemental real(kind=dp) function, public binomial(n, k)
The binomial coefficient n over k for 0 <= k <= n is calculated, otherwise zero is returned.
subroutine, public diamat_all(a, eigval, dac)
Diagonalize the symmetric n by n matrix a using the LAPACK library. Only the upper triangle of matrix...
Interface to the message passing library MPI.
Methods used by pao_main.F.
subroutine, public pao_build_orthogonalizer(pao, qs_env)
Constructs matrix_N and its inverse.
subroutine, public pao_build_core_hamiltonian(pao, qs_env)
Creates the matrix_H0 which contains the core hamiltonian.
subroutine, public pao_guess_initial_p(pao, qs_env, ls_scf_env)
Provide an initial guess for the density matrix.
subroutine, public pao_test_convergence(pao, ls_scf_env, new_energy, is_converged)
Test whether the PAO optimization has reached convergence.
subroutine, public pao_add_forces(qs_env, ls_scf_env)
Calculate the forces contributed by PAO.
subroutine, public pao_check_trace_ps(ls_scf_env)
Ensure that the number of electrons is correct.
subroutine, public pao_init_kinds(pao, qs_env)
Initialize qs kinds.
subroutine, public pao_build_matrix_x(pao, qs_env)
Creates the matrix_X.
subroutine, public pao_check_grad(pao, qs_env, ls_scf_env)
Debugging routine for checking the analytic gradient.
subroutine, public pao_print_atom_info(pao)
Prints a one line summary for each atom.
subroutine, public pao_store_p(qs_env, ls_scf_env)
Stores density matrix as initial guess for next SCF optimization.
subroutine, public pao_build_selector(pao, qs_env)
Build rectangular matrix to converert between primary and PAO basis.
subroutine, public pao_calc_energy(pao, qs_env, ls_scf_env, energy)
Calculate the pao energy.
subroutine, public pao_build_diag_distribution(pao, qs_env)
Creates new DBCSR distribution which spreads diagonal blocks evenly across ranks.
Main module for PAO Machine Learning.
subroutine, public pao_ml_forces(pao, qs_env, matrix_g, forces)
Calculate forces contributed by machine learning.
Module for equivariant PAO-ML based on PyTorch.
subroutine, public pao_model_forces(pao, qs_env, matrix_g, forces)
Calculate forces contributed by machine learning.
subroutine, public pao_model_load(pao, qs_env, ikind, pao_model_file, model)
Loads a PAO-ML model.
Front-End for any PAO parametrization.
subroutine, public pao_calc_ab(pao, qs_env, ls_scf_env, gradient, penalty, forces)
Takes current matrix_X and calculates the matrices A and B.
subroutine, public pao_param_count(pao, qs_env, ikind, nparams)
Returns the number of parameters for given atomic kind.
Factory routines for potentials used e.g. by pao_param_exp and pao_ml.
Types used by the PAO machinery.
Define the data structure for the particle information.
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, 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.
Routines to somehow generate an initial guess.
subroutine, public calculate_atomic_fock_matrix(matrix_f, atomic_kind_set, qs_kind_set, ounit)
returns a block diagonal fock matrix.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public set_qs_kind(qs_kind, paw_atom, ghost, floating, hard_radius, hard0_radius, covalent_radius, vdw_radius, lmax_rho0, zeff, no_optimize, dispersion, u_minus_j, reltmat, dftb_parameter, xtb_parameter, elec_conf, pao_basis_size)
Set the components of an atomic kind data set.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
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)
subroutine, public qs_ks_did_change(ks_env, s_mstruct_changed, rho_changed, potential_changed, full_reset)
tells that some of the things relevant to the ks calculation did change. has to be called when change...
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
superstucture that hold various representations of the density and keeps track of which ones are vali...
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...
Provides all information about an atomic kind.
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
Holds information about a PAO descriptor.
Holds information about a PAO potential.
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.