29 USE iso_c_binding,
ONLY: c_char,&
55 USE xc_gauxc_interface,
ONLY: &
56 cp_gauxc_basisset_type, cp_gauxc_grid_type, cp_gauxc_integrator_type, &
57 cp_gauxc_molecule_type, cp_gauxc_status_type, cp_gauxc_xc_gradient_type, cp_gauxc_xc_type, &
58 gauxc_check_status, gauxc_compute_xc, gauxc_compute_xc_gradient, gauxc_create_basisset, &
59 gauxc_create_grid, gauxc_create_integrator, gauxc_create_molecule, gauxc_destroy_basisset, &
60 gauxc_destroy_grid, gauxc_destroy_integrator, gauxc_destroy_molecule, &
61 gauxc_write_basisset_hdf5, gauxc_write_molecule_hdf5
63#include "../base/base_uses.f90"
69 LOGICAL,
PARAMETER :: debug_this_module = .true.
70 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xc_gauxc_functional'
76 INTEGER(c_int) FUNCTION c_setenv(name, value, overwrite)
BIND(C, name="setenv")
77 IMPORT :: c_char, c_int
78 CHARACTER(KIND=c_char),
DIMENSION(*),
INTENT(IN) :: name, value
79 INTEGER(c_int),
VALUE :: overwrite
82 INTEGER(c_int) FUNCTION c_unsetenv(name)
BIND(C, name="unsetenv")
83 IMPORT :: c_char, c_int
84 CHARACTER(KIND=c_char),
DIMENSION(*),
INTENT(IN) :: name
85 END FUNCTION c_unsetenv
95 SUBROUTINE set_gauxc_model_atom_chunk_env(atom_chunk_size, is_explicit)
96 INTEGER,
INTENT(IN) :: atom_chunk_size
97 LOGICAL,
INTENT(IN) :: is_explicit
99 CHARACTER(LEN=32) :: chunk_value
100 INTEGER(c_int) :: ierr
102 IF (.NOT. is_explicit)
RETURN
104 IF (atom_chunk_size < 0)
THEN
105 ierr = c_unsetenv(
"GAUXC_ONEDFT_ATOM_CHUNK_SIZE"//c_null_char)
107 WRITE (chunk_value,
'(I0)') atom_chunk_size
109 "GAUXC_ONEDFT_ATOM_CHUNK_SIZE"//c_null_char, &
110 trim(chunk_value)//c_null_char, &
113 IF (ierr /= 0_c_int)
THEN
114 CALL cp_abort(__location__, &
115 "Could not set GAUXC_ONEDFT_ATOM_CHUNK_SIZE for GauXC Skala.")
117 END SUBROUTINE set_gauxc_model_atom_chunk_env
125 SUBROUTINE dbcsr_to_dense(dbcsr_mat, dense_mat, para_env)
130 TYPE(dbcsr_p_type),
INTENT(IN) :: dbcsr_mat
131 REAL(c_double),
ALLOCATABLE,
DIMENSION(:, :), &
132 INTENT(INOUT) :: dense_mat
133 TYPE(mp_para_env_type),
INTENT(IN),
POINTER :: para_env
135 CHARACTER :: matrix_type
136 INTEGER :: col, col_end, col_start, icol, irow, mynode, nblkcols_total, nblkrows_total, &
137 ncols, nrows, numnodes, owner, row, row_end, row_start
138 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: c_offset, r_offset
139 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, row_blk_size
141 REAL(c_double),
POINTER :: block(:, :)
142 TYPE(dbcsr_distribution_type) :: dist
145 row_blk_size=row_blk_size, &
146 col_blk_size=col_blk_size, &
147 nblkrows_total=nblkrows_total, &
148 nblkcols_total=nblkcols_total, &
149 nfullrows_total=nrows, &
150 nfullcols_total=ncols, &
155 IF (.NOT.
ALLOCATED(dense_mat))
THEN
156 ALLOCATE (dense_mat(nrows, ncols))
157 ELSE IF (.NOT. all(shape(dense_mat) == [nrows, ncols]))
THEN
158 DEALLOCATE (dense_mat)
159 ALLOCATE (dense_mat(nrows, ncols))
161 cpassert(all(shape(dense_mat) == [nrows, ncols]))
165 ALLOCATE (r_offset(nblkrows_total), c_offset(nblkcols_total))
168 DO row = 2, nblkrows_total
169 r_offset(row) = r_offset(row - 1) + row_blk_size(row - 1)
172 DO col = 2, nblkcols_total
173 c_offset(col) = c_offset(col - 1) + col_blk_size(col - 1)
177 DO irow = 1, nblkrows_total
178 DO icol = 1, nblkcols_total
179 IF (numnodes == 1 .AND. para_env%num_pe > 1 .AND. para_env%mepos /= 0) cycle
181 IF (owner /= mynode) cycle
183 block=block, found=found)
184 IF (.NOT. found) cycle
185 row_start = r_offset(irow)
186 row_end = row_start + row_blk_size(irow) - 1
187 col_start = c_offset(icol)
188 col_end = col_start + col_blk_size(icol) - 1
189 dense_mat(row_start:row_end, col_start:col_end) = block
190 IF (irow /= icol)
THEN
191 IF (matrix_type == dbcsr_type_symmetric)
THEN
192 dense_mat(col_start:col_end, row_start:row_end) = transpose(block)
193 ELSE IF (matrix_type == dbcsr_type_antisymmetric)
THEN
194 dense_mat(col_start:col_end, row_start:row_end) = -transpose(block)
200 DEALLOCATE (r_offset, c_offset)
202 END SUBROUTINE dbcsr_to_dense
212 FUNCTION dense_to_dbcsr(dense_mat, template_dbcsr)
RESULT(dbcsr_mat)
223 dbcsr_type_symmetric, &
225 REAL(c_double),
DIMENSION(:, :),
INTENT(IN) :: dense_mat
226 TYPE(dbcsr_p_type),
INTENT(IN) :: template_dbcsr
227 TYPE(dbcsr_p_type) :: dbcsr_mat
229 INTEGER :: col, icol, irow, mynode, nblkcols_total, &
230 nblkrows_total, ncols, nrows, owner, &
232 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: c_offset, r_offset
233 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, row_blk_size
234 TYPE(dbcsr_distribution_type) :: dist
237 row_blk_size=row_blk_size, &
238 col_blk_size=col_blk_size, &
239 nblkrows_total=nblkrows_total, &
240 nblkcols_total=nblkcols_total, &
241 nfullrows_total=nrows, &
242 nfullcols_total=ncols, &
246 cpassert(nrows ==
SIZE(dense_mat, 1))
247 cpassert(ncols ==
SIZE(dense_mat, 2))
251 template=template_dbcsr%matrix, &
252 name=
"VXC from GauXC (dense)", &
253 matrix_type=dbcsr_type_symmetric)
256 ALLOCATE (r_offset(nblkrows_total), c_offset(nblkcols_total))
259 DO row = 2, nblkrows_total
260 r_offset(row) = r_offset(row - 1) + row_blk_size(row - 1)
263 DO col = 2, nblkcols_total
264 c_offset(col) = c_offset(col - 1) + col_blk_size(col - 1)
267 DO irow = 1, nblkrows_total
268 DO icol = 1, nblkcols_total
269 IF (irow > icol) cycle
271 IF (owner /= mynode) cycle
274 dense_mat(r_offset(irow):r_offset(irow) + row_blk_size(irow) - 1, &
275 c_offset(icol):c_offset(icol) + col_blk_size(icol) - 1) + &
276 transpose(dense_mat(r_offset(icol):r_offset(icol) + row_blk_size(icol) - 1, &
277 c_offset(irow):c_offset(irow) + col_blk_size(irow) - 1))))
283 DEALLOCATE (r_offset, c_offset)
285 END FUNCTION dense_to_dbcsr
292 FUNCTION get_gauxc_functional(xc_section)
RESULT(gauxc_functional_section)
293 TYPE(section_vals_type),
INTENT(in),
POINTER :: xc_section
294 TYPE(section_vals_type),
POINTER :: gauxc_functional_section
297 TYPE(section_vals_type),
POINTER :: functionals, xc_fun
299 NULLIFY (gauxc_functional_section)
302 IF (.NOT.
ASSOCIATED(functionals))
THEN
303 cpabort(
"XC_FUNCTIONAL section not found")
310 IF (.NOT.
ASSOCIATED(xc_fun))
EXIT
311 IF (xc_fun%section%name /=
"GAUXC" .OR. ifun > 1)
THEN
312 cpabort(
"GauXC functionals are mutually exclusive with any other functional.")
314 gauxc_functional_section => xc_fun
317 IF (.NOT.
ASSOCIATED(gauxc_functional_section))
THEN
318 cpabort(
"No XC functional found in XC_FUNCTIONAL section")
320 END FUNCTION get_gauxc_functional
329 LOGICAL :: uses_gauxc
335 IF (.NOT.
ASSOCIATED(xc_section))
RETURN
338 IF (.NOT.
ASSOCIATED(functionals))
RETURN
344 IF (.NOT.
ASSOCIATED(xc_fun))
EXIT
345 IF (xc_fun%section%name ==
"GAUXC")
THEN
358 FUNCTION gauxc_gapw_has_pseudopotentials(qs_kind_set)
RESULT(has_pseudopotentials)
359 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
360 LOGICAL :: has_pseudopotentials
366 cpassert(
ASSOCIATED(qs_kind_set))
368 has_pseudopotentials = .false.
369 DO ikind = 1,
SIZE(qs_kind_set)
370 NULLIFY (gth_potential, sgp_potential)
372 gth_potential=gth_potential, &
373 sgp_potential=sgp_potential)
374 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
375 has_pseudopotentials = .true.
380 END FUNCTION gauxc_gapw_has_pseudopotentials
388 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
389 LOGICAL :: has_paw_pseudopotentials
392 LOGICAL :: gpw_type_forced, paw_atom
396 cpassert(
ASSOCIATED(qs_kind_set))
398 has_paw_pseudopotentials = .false.
399 DO ikind = 1,
SIZE(qs_kind_set)
400 NULLIFY (gth_potential, sgp_potential)
402 gth_potential=gth_potential, &
403 gpw_type_forced=gpw_type_forced, &
405 sgp_potential=sgp_potential)
406 IF ((
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential)) .AND. &
407 paw_atom .AND. .NOT. gpw_type_forced)
THEN
408 has_paw_pseudopotentials = .true.
425 SUBROUTINE ensure_gauxc_periodic_reference_scope( &
426 dft_control, cell, qs_kind_set, do_kpoints, periodic_reference)
429 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
430 LOGICAL,
INTENT(IN) :: do_kpoints, periodic_reference
433 LOGICAL :: is_periodic
437 cpassert(
ASSOCIATED(dft_control))
438 cpassert(
ASSOCIATED(qs_kind_set))
440 is_periodic = .false.
441 IF (
ASSOCIATED(cell)) is_periodic = any(cell%perd /= 0)
444 CALL cp_abort(__location__, &
445 "GauXC currently supports only Gamma-only density matrices in CP2K. "// &
446 "Periodic k-point density matrices require a dedicated GauXC periodic interface.")
448 IF (dft_control%nimages /= 1)
THEN
449 CALL cp_abort(__location__, &
450 "GauXC currently supports only a single AO image in CP2K. "// &
451 "Periodic neighbour-cell AO blocks require a dedicated GauXC periodic interface.")
453 IF (.NOT. is_periodic)
RETURN
455 IF (.NOT. periodic_reference)
THEN
456 CALL cp_abort(__location__, &
457 "Periodic GauXC calculations in CP2K require GAUXC%PERIODIC_REFERENCE T. "// &
458 "This opt-in documents that the current path is only an isolated-cell, "// &
459 "Gamma-only, single-image METHOD GPW reference path using GauXC molecular "// &
460 "quadrature, not a dedicated periodic GauXC interface.")
463 IF (.NOT. all(cell%perd == 1))
THEN
464 CALL cp_abort(__location__, &
465 "The current GauXC isolated-cell reference path supports only PERIODIC XYZ. "// &
466 "Partial periodicity requires a dedicated GauXC periodic interface.")
468 IF (.NOT. dft_control%qs_control%gpw)
THEN
469 CALL cp_abort(__location__, &
470 "The current GauXC isolated-cell reference path is limited to METHOD GPW with GTH "// &
471 "pseudopotentials. GAPW, GAPW_XC, and other QS methods are not supported here.")
474 DO ikind = 1,
SIZE(qs_kind_set)
475 NULLIFY (gth_potential, sgp_potential)
477 gth_potential=gth_potential, &
478 sgp_potential=sgp_potential)
479 IF (.NOT.
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
480 CALL cp_abort(__location__, &
481 "The current GauXC isolated-cell reference path is limited to GTH pseudopotentials. "// &
482 "Use non-periodic all-electron GAPW validation for molecular GAPW cases.")
486 END SUBROUTINE ensure_gauxc_periodic_reference_scope
495 SUBROUTINE add_gauxc_gradient_to_force(exc_grad, force, atomic_kind_set, para_env)
496 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: exc_grad
501 INTEGER :: ia, iatom, ikind, natom_kind
504 cpassert(
ASSOCIATED(force))
505 cpassert(
ASSOCIATED(atomic_kind_set))
507 IF (para_env%mepos /= 0)
RETURN
509 DO ikind = 1,
SIZE(atomic_kind_set, 1)
510 atomic_kind => atomic_kind_set(ikind)
512 DO ia = 1, natom_kind
513 iatom = atomic_kind%atom_list(ia)
514 force(ikind)%rho_elec(:, ia) = force(ikind)%rho_elec(:, ia) + &
515 exc_grad(3*iatom - 2:3*iatom)
519 END SUBROUTINE add_gauxc_gradient_to_force
540 SUBROUTINE gauxc_xc_energy_for_particles( &
541 particle_set_eval, qs_kind_set, density_scalar, nspins, model_name, &
542 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
543 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, exc, density_zeta)
544 TYPE(
particle_type),
DIMENSION(:),
INTENT(IN) :: particle_set_eval
545 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
546 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: density_scalar
547 INTEGER,
INTENT(IN) :: nspins
548 CHARACTER(len=*),
INTENT(IN) :: model_name, xc_fun_name, grid_type, radial_quadrature, &
549 pruning_scheme, lb_exec_space, int_exec_space, lwd_kernel
550 INTEGER,
INTENT(IN) :: batch_size
551 REAL(kind=
dp),
INTENT(IN) :: device_runtime_fill_fraction
552 REAL(kind=
dp),
INTENT(OUT) :: exc
553 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
554 OPTIONAL :: density_zeta
556 TYPE(cp_gauxc_basisset_type) :: gauxc_basis_fd
557 TYPE(cp_gauxc_grid_type) :: gauxc_grid_fd
558 TYPE(cp_gauxc_integrator_type) :: gauxc_integrator_fd
559 TYPE(cp_gauxc_molecule_type) :: gauxc_mol_fd
560 TYPE(cp_gauxc_status_type) :: gauxc_status
561 TYPE(cp_gauxc_xc_type) :: gauxc_xc_result
563 gauxc_mol_fd = gauxc_create_molecule(particle_set_eval, gauxc_status)
564 CALL gauxc_check_status(gauxc_status)
565 gauxc_basis_fd = gauxc_create_basisset(qs_kind_set, particle_set_eval, gauxc_status)
566 CALL gauxc_check_status(gauxc_status)
567 gauxc_grid_fd = gauxc_create_grid( &
575 device_runtime_fill_fraction, &
578 force_new_runtime=.true.)
579 CALL gauxc_check_status(gauxc_status)
580 gauxc_integrator_fd = gauxc_create_integrator( &
587 CALL gauxc_check_status(gauxc_status)
589 IF (nspins == 1)
THEN
590 gauxc_xc_result = gauxc_compute_xc( &
591 gauxc_integrator_fd, &
594 status=gauxc_status, &
595 model=trim(model_name))
597 cpassert(nspins == 2)
598 cpassert(
PRESENT(density_zeta))
599 gauxc_xc_result = gauxc_compute_xc( &
600 gauxc_integrator_fd, &
605 model=trim(model_name))
607 CALL gauxc_check_status(gauxc_status)
608 exc = gauxc_xc_result%exc
610 IF (
ALLOCATED(gauxc_xc_result%vxc_scalar))
DEALLOCATE (gauxc_xc_result%vxc_scalar)
611 IF (
ALLOCATED(gauxc_xc_result%vxc_zeta))
DEALLOCATE (gauxc_xc_result%vxc_zeta)
613 CALL gauxc_destroy_integrator(gauxc_integrator_fd, gauxc_status)
614 CALL gauxc_check_status(gauxc_status)
615 CALL gauxc_destroy_grid(gauxc_grid_fd, gauxc_status)
616 CALL gauxc_check_status(gauxc_status)
617 CALL gauxc_destroy_basisset(gauxc_basis_fd, gauxc_status)
618 CALL gauxc_check_status(gauxc_status)
619 CALL gauxc_destroy_molecule(gauxc_mol_fd, gauxc_status)
620 CALL gauxc_check_status(gauxc_status)
622 END SUBROUTINE gauxc_xc_energy_for_particles
645 SUBROUTINE gauxc_xc_gradient_fd( &
646 particle_set, qs_kind_set, density_scalar, nspins, model_name, &
647 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
648 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, dx, para_env, exc_grad, &
651 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
652 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: density_scalar
653 INTEGER,
INTENT(IN) :: nspins
654 CHARACTER(len=*),
INTENT(IN) :: model_name, xc_fun_name, grid_type, radial_quadrature, &
655 pruning_scheme, lb_exec_space, int_exec_space, lwd_kernel
656 INTEGER,
INTENT(IN) :: batch_size
657 REAL(kind=
dp),
INTENT(IN) :: device_runtime_fill_fraction, dx
659 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:), &
660 INTENT(OUT) :: exc_grad
661 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
662 OPTIONAL :: density_zeta
664 INTEGER :: iatom, idir
665 REAL(kind=
dp) :: xc_minus, xc_plus
666 TYPE(
particle_type),
ALLOCATABLE,
DIMENSION(:) :: particle_set_minus, particle_set_plus
668 cpassert(
ASSOCIATED(particle_set))
669 cpassert(dx > 0.0_dp)
671 ALLOCATE (exc_grad(3*
SIZE(particle_set)))
674 IF (para_env%mepos == 0)
THEN
675 ALLOCATE (particle_set_minus(
SIZE(particle_set)), particle_set_plus(
SIZE(particle_set)))
677 DO iatom = 1,
SIZE(particle_set)
679 particle_set_minus = particle_set
680 particle_set_plus = particle_set
681 particle_set_minus(iatom)%r(idir) = particle_set_minus(iatom)%r(idir) - dx
682 particle_set_plus(iatom)%r(idir) = particle_set_plus(iatom)%r(idir) + dx
683 IF (
PRESENT(density_zeta))
THEN
684 CALL gauxc_xc_energy_for_particles( &
685 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
686 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
687 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_plus, &
688 density_zeta=density_zeta)
689 CALL gauxc_xc_energy_for_particles( &
690 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
691 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
692 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_minus, &
693 density_zeta=density_zeta)
695 CALL gauxc_xc_energy_for_particles( &
696 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
697 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
698 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_plus)
699 CALL gauxc_xc_energy_for_particles( &
700 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
701 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
702 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_minus)
704 exc_grad(3*iatom - 3 + idir) = (xc_plus - xc_minus)/(2.0_dp*dx)
708 DEALLOCATE (particle_set_minus, particle_set_plus)
711 CALL para_env%bcast(exc_grad, 0)
713 END SUBROUTINE gauxc_xc_gradient_fd
736 SUBROUTINE debug_gauxc_molecular_virial( &
737 exc_grad, particle_set, qs_kind_set, density_scalar, nspins, model_name, &
738 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
739 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, dx, para_env, density_zeta)
740 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: exc_grad
742 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
743 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: density_scalar
744 INTEGER,
INTENT(IN) :: nspins
745 CHARACTER(len=*),
INTENT(IN) :: model_name, xc_fun_name, grid_type, radial_quadrature, &
746 pruning_scheme, lb_exec_space, int_exec_space, lwd_kernel
747 INTEGER,
INTENT(IN) :: batch_size
748 REAL(kind=
dp),
INTENT(IN) :: device_runtime_fill_fraction, dx
750 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
751 OPTIONAL :: density_zeta
754 REAL(kind=
dp) :: analytic_trace, diff_trace, &
755 numerical_trace, xc_minus, xc_plus
756 REAL(kind=
dp),
DIMENSION(3) :: center, displacement, grad
757 TYPE(
particle_type),
ALLOCATABLE,
DIMENSION(:) :: particle_set_minus, particle_set_plus
759 cpassert(
ASSOCIATED(particle_set))
760 cpassert(
SIZE(exc_grad) == 3*
SIZE(particle_set))
762 IF (para_env%mepos /= 0)
RETURN
765 DO iatom = 1,
SIZE(particle_set)
766 center = center + particle_set(iatom)%r
768 center = center/real(
SIZE(particle_set),
dp)
770 ALLOCATE (particle_set_minus(
SIZE(particle_set)), particle_set_plus(
SIZE(particle_set)))
771 particle_set_minus = particle_set
772 particle_set_plus = particle_set
774 analytic_trace = 0.0_dp
775 DO iatom = 1,
SIZE(particle_set)
776 grad = exc_grad(3*iatom - 2:3*iatom)
777 displacement = particle_set(iatom)%r - center
778 analytic_trace = analytic_trace + dot_product(grad, displacement)
779 particle_set_minus(iatom)%r = center + (1.0_dp - dx)*displacement
780 particle_set_plus(iatom)%r = center + (1.0_dp + dx)*displacement
782 analytic_trace = analytic_trace/3.0_dp
784 IF (
PRESENT(density_zeta))
THEN
785 CALL gauxc_xc_energy_for_particles( &
786 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
787 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
788 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_plus, &
789 density_zeta=density_zeta)
790 CALL gauxc_xc_energy_for_particles( &
791 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
792 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
793 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_minus, &
794 density_zeta=density_zeta)
796 CALL gauxc_xc_energy_for_particles( &
797 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
798 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
799 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_plus)
800 CALL gauxc_xc_energy_for_particles( &
801 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
802 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
803 int_exec_space, lwd_kernel, batch_size, device_runtime_fill_fraction, xc_minus)
806 numerical_trace = (xc_plus - xc_minus)/(2.0_dp*dx)/3.0_dp
807 diff_trace = analytic_trace - numerical_trace
811 WRITE (unit=iw, fmt=
"(/,T2,A,1X,ES11.4)") &
812 "GAUXC| Molecular XC virial finite-difference dx", dx
813 WRITE (unit=iw, fmt=
"(T2,A,3(1X,ES19.11))") &
814 "GAUXC| Molecular XC virial FD 1/3 Trace", &
815 analytic_trace, numerical_trace, diff_trace
818 DEALLOCATE (particle_set_minus, particle_set_plus)
820 END SUBROUTINE debug_gauxc_molecular_virial
828 SUBROUTINE print_gauxc_molecular_virial(exc_grad, particle_set, para_env)
829 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: exc_grad
833 CHARACTER(len=1),
DIMENSION(3),
PARAMETER :: label = [
"x",
"y",
"z"]
835 INTEGER :: i, iatom, iw, j
836 REAL(kind=
dp),
DIMENSION(3) :: center, displacement, grad, grad_sum
837 REAL(kind=
dp),
DIMENSION(3, 3) :: molecular_virial
839 cpassert(
ASSOCIATED(particle_set))
840 cpassert(
SIZE(exc_grad) == 3*
SIZE(particle_set))
842 IF (para_env%mepos /= 0)
RETURN
845 DO iatom = 1,
SIZE(particle_set)
846 center = center + particle_set(iatom)%r
848 center = center/real(
SIZE(particle_set),
dp)
851 molecular_virial = 0.0_dp
852 DO iatom = 1,
SIZE(particle_set)
853 grad = exc_grad(3*iatom - 2:3*iatom)
854 displacement = particle_set(iatom)%r - center
855 grad_sum = grad_sum + grad
858 molecular_virial(i, j) = molecular_virial(i, j) + grad(i)*displacement(j)
866 WRITE (unit=iw, fmt=
"(/,T2,A)") &
867 "GAUXC| Molecular XC gradient virial diagnostic [a.u.]"
868 WRITE (unit=iw, fmt=
"(T2,A,T20,A,T40,A,T60,A)")
"GAUXC|",
"x",
"y",
"z"
870 WRITE (unit=iw, fmt=
"(T2,A,1X,A1,3(1X,ES19.11))") &
871 "GAUXC|", label(i), molecular_virial(i, :)
873 WRITE (unit=iw, fmt=
"(T2,A,1X,ES19.11)") &
874 "GAUXC| Molecular XC gradient virial 1/3 Trace", &
875 (molecular_virial(1, 1) + molecular_virial(2, 2) + molecular_virial(3, 3))/3.0_dp
876 WRITE (unit=iw, fmt=
"(T2,A,3(1X,ES19.11))") &
877 "GAUXC| Molecular XC gradient sum", grad_sum
878 WRITE (unit=iw, fmt=
"(T2,A)") &
879 "GAUXC| Diagnostic only; this is not an analytical periodic stress tensor."
881 END SUBROUTINE print_gauxc_molecular_virial
893 SUBROUTINE skala_info(functional, lsd, reference, shortform, needs, max_deriv)
895 LOGICAL,
INTENT(in) :: lsd
896 CHARACTER(LEN=*),
INTENT(OUT),
OPTIONAL :: reference, shortform
898 INTEGER,
INTENT(out),
OPTIONAL :: max_deriv
900 CHARACTER(len=default_path_length) :: model_key, model_name
901 CHARACTER(len=default_string_length) :: xc_fun_key, xc_fun_name
902 LOGICAL :: native_grid
907 model_key = adjustl(model_name)
908 xc_fun_key = adjustl(xc_fun_name)
912 IF (
PRESENT(reference))
THEN
913 IF (trim(model_key) ==
"NONE" .OR. trim(model_key) ==
"" .OR. &
914 trim(model_key) == trim(xc_fun_key))
THEN
915 reference =
"Functional computed by GauXC (underlying: "//trim(xc_fun_name)//
")"
917 reference =
"Functional computed by GauXC Skala model "//trim(model_name)
920 IF (
PRESENT(shortform))
THEN
921 IF (trim(model_key) ==
"NONE" .OR. trim(model_key) ==
"" .OR. &
922 trim(model_key) == trim(xc_fun_key))
THEN
923 shortform =
"GAUXC ("//trim(xc_fun_name)//
")"
925 shortform =
"GAUXC Skala"
928 IF (
PRESENT(needs))
THEN
929 IF (native_grid .AND. trim(model_key) /=
"NONE" .AND. trim(model_key) /=
"" .AND. &
930 trim(model_key) /= trim(xc_fun_key))
THEN
932 needs%rho_spin = .true.
933 needs%drho_spin = .true.
934 needs%tau_spin = .true.
943 needs%rho_spin = .true.
947 IF (
PRESENT(max_deriv)) max_deriv = 1
964 LOGICAL,
INTENT(IN) :: calculate_forces
966 CHARACTER(len=*),
PARAMETER :: nonlocal_vdw_abort_message = &
967 "GauXC does not support non-local VDW_POTENTIAL corrections. "// &
968 "Use an additive PAIR_POTENTIAL dispersion correction or disable GauXC."
969 REAL(kind=
dp),
PARAMETER :: gapw_fd_gradient_dx = 1.0e-4_dp
971 CHARACTER(len=default_path_length) :: model_key, model_name, output_path
972 CHARACTER(len=default_string_length) :: gradient_runtime, gradient_runtime_key, &
973 grid_key, pruning_key, skala_runtime, &
974 skala_runtime_key, xc_fun_key
975 INTEGER :: atom_chunk_size, env_status, img, ispin, &
977 LOGICAL :: atom_chunk_size_explicit, do_kpoints, gapw_method, gapw_paw_pseudopotentials, &
978 gapw_pseudopotentials, grid_explicit, hdf5_output, is_periodic, molecular_virial, &
979 molecular_virial_debug, need_xc_gradient, periodic_reference, pruning_explicit, &
980 use_skala_model, write_hdf5_output
981 REAL(kind=
dp) :: molecular_virial_debug_dx
982 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: density_scalar, density_zeta
987 TYPE(cp_gauxc_status_type) :: gauxc_status
988 TYPE(cp_gauxc_xc_gradient_type) :: exc_grad
989 TYPE(cp_gauxc_xc_type) :: gauxc_xc_result
990 TYPE(dbcsr_p_type) :: vxc_zeta_tmp
991 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_vxc
992 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao
998 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1000 TYPE(
qs_rho_type),
POINTER :: rho, rho_use, rho_xc
1024 dft_control=dft_control, &
1025 do_kpoints=do_kpoints, &
1028 matrix_vxc=matrix_vxc, &
1029 natom=params%natom, &
1030 atomic_kind_set=atomic_kind_set, &
1032 para_env=para_env, &
1033 particle_set=particle_set, &
1034 qs_kind_set=qs_kind_set, &
1039 gapw_method = dft_control%qs_control%gapw .OR. dft_control%qs_control%gapw_xc
1040 gapw_pseudopotentials = gapw_method .AND. &
1041 gauxc_gapw_has_pseudopotentials(qs_kind_set)
1042 gapw_paw_pseudopotentials = gapw_method .AND. &
1044 IF (dft_control%qs_control%gapw_xc)
THEN
1045 cpassert(
ASSOCIATED(rho_xc))
1048 cpassert(
ASSOCIATED(rho))
1055 nimages = dft_control%nimages
1056 params%nspins = dft_control%nspins
1057 is_periodic = .false.
1058 IF (
ASSOCIATED(cell)) is_periodic = any(cell%perd /= 0)
1060 IF (
ASSOCIATED(qs_env%dispersion_env))
THEN
1062 cpabort(nonlocal_vdw_abort_message)
1065 NULLIFY (vxc_zeta_tmp%matrix)
1067 gauxc_functional_section => get_gauxc_functional(xc_section)
1069 gauxc_functional_section, &
1071 c_val=params%xc_fun_name)
1073 gauxc_functional_section, &
1077 gauxc_functional_section, &
1079 c_val=params%grid_type, &
1080 explicit=grid_explicit)
1082 gauxc_functional_section, &
1083 "RADIAL_QUADRATURE", &
1084 c_val=params%radial_quadrature)
1086 gauxc_functional_section, &
1088 c_val=params%pruning_scheme, &
1089 explicit=pruning_explicit)
1091 gauxc_functional_section, &
1093 i_val=params%batch_size)
1095 gauxc_functional_section, &
1096 "DEVICE_RUNTIME_FILL_FRACTION", &
1097 r_val=params%device_runtime_fill_fraction)
1099 gauxc_functional_section, &
1100 "MODEL_ATOM_CHUNK_SIZE", &
1101 i_val=atom_chunk_size, &
1102 explicit=atom_chunk_size_explicit)
1104 gauxc_functional_section, &
1105 "PERIODIC_REFERENCE", &
1106 l_val=periodic_reference)
1108 gauxc_functional_section, &
1109 "MOLECULAR_VIRIAL", &
1110 l_val=molecular_virial)
1112 gauxc_functional_section, &
1113 "MOLECULAR_VIRIAL_DEBUG", &
1114 l_val=molecular_virial_debug)
1116 gauxc_functional_section, &
1117 "MOLECULAR_VIRIAL_DEBUG_DX", &
1118 r_val=molecular_virial_debug_dx)
1120 gauxc_functional_section, &
1121 "LB_EXECUTION_SPACE", &
1122 c_val=params%lb_exec_space)
1124 gauxc_functional_section, &
1125 "INT_EXECUTION_SPACE", &
1126 c_val=params%int_exec_space)
1128 gauxc_functional_section, &
1130 c_val=params%lwd_kernel)
1132 gauxc_functional_section, &
1134 c_val=skala_runtime)
1136 gauxc_functional_section, &
1137 "MODEL_GRADIENT_RUNTIME", &
1138 c_val=gradient_runtime)
1140 gauxc_functional_section, &
1144 model_key = adjustl(model_name)
1146 xc_fun_key = adjustl(params%xc_fun_name)
1148 skala_runtime_key = adjustl(skala_runtime)
1150 gradient_runtime_key = adjustl(gradient_runtime)
1152 params%use_gauxc_model = (trim(model_key) /=
"" .AND. trim(model_key) /=
"NONE" .AND. &
1153 trim(model_key) /= trim(xc_fun_key))
1154 use_skala_model = (index(trim(model_key),
"SKALA") > 0)
1155 params%model_eval_name = model_name
1156 IF (.NOT. params%use_gauxc_model)
THEN
1158 params%model_eval_name =
"NONE"
1160 IF (gapw_pseudopotentials .AND. params%use_gauxc_model .AND. .NOT. dft_control%qs_control%gapw_xc .AND. &
1161 .NOT. gapw_paw_pseudopotentials .AND. para_env%mepos == 0 .AND.
ASSOCIATED(scf_env))
THEN
1162 IF (scf_env%iter_count == 1)
THEN
1165 "GauXC Skala with METHOD GAPW and GPW_TYPE pseudopotentials evaluates "// &
1166 "the XC term directly on the molecular AO/valence density; no GAPW one-center "// &
1167 "XC correction is used for those regular-grid kinds.")
1170 IF (params%device_runtime_fill_fraction <= 0.0_dp .OR. params%device_runtime_fill_fraction > 1.0_dp)
THEN
1171 CALL cp_abort(__location__, &
1172 "GAUXC%DEVICE_RUNTIME_FILL_FRACTION must be > 0 and <= 1.")
1174 IF (atom_chunk_size < -1)
THEN
1175 CALL cp_abort(__location__, &
1176 "GAUXC%MODEL_ATOM_CHUNK_SIZE must be -1, zero, or positive.")
1178 IF (molecular_virial_debug)
THEN
1179 IF (molecular_virial_debug_dx <= 0.0_dp)
THEN
1180 CALL cp_abort(__location__, &
1181 "GauXC MOLECULAR_VIRIAL_DEBUG_DX must be positive.")
1183 molecular_virial = .true.
1185 need_xc_gradient = calculate_forces .OR. molecular_virial
1186 CALL ensure_gauxc_periodic_reference_scope( &
1187 dft_control, cell, qs_kind_set, do_kpoints, periodic_reference)
1188 IF (is_periodic .AND. periodic_reference .AND. para_env%mepos == 0)
THEN
1189 IF (
ASSOCIATED(scf_env))
THEN
1190 IF (scf_env%iter_count == 1)
THEN
1193 "GAUXC%PERIODIC_REFERENCE uses GauXC molecular quadrature for isolated validation "// &
1194 "cells. Compact periodic materials require a dedicated periodic GauXC interface.")
1198 IF (params%use_gauxc_model)
THEN
1200 CALL cp_abort(__location__, &
1201 "GauXC Skala with NLCC pseudopotentials is not implemented. "// &
1202 "The frozen core density would need a SKALA-consistent feature definition.")
1205 IF (params%use_gauxc_model)
THEN
1206 CALL set_gauxc_model_atom_chunk_env( &
1207 atom_chunk_size, atom_chunk_size_explicit)
1208 IF (.NOT. grid_explicit) params%grid_type =
"SUPERFINE"
1209 IF (.NOT. pruning_explicit) params%pruning_scheme =
"UNPRUNED"
1211 grid_key = adjustl(params%grid_type)
1212 pruning_key = adjustl(params%pruning_scheme)
1215 IF (use_skala_model .AND. need_xc_gradient .AND. &
1216 (trim(grid_key) /=
"SUPERFINE" .OR. trim(pruning_key) /=
"UNPRUNED"))
THEN
1219 "GauXC Skala nuclear gradients are sensitive to the GauXC molecular grid. "// &
1220 "Use GRID SUPERFINE and PRUNING_SCHEME UNPRUNED for quantitative force checks.")
1222 IF (trim(model_key) ==
"SKALA")
THEN
1223 CALL get_environment_variable(
"GAUXC_SKALA_MODEL", model_name, status=env_status)
1224 IF (env_status /= 0 .OR. len_trim(model_name) == 0)
THEN
1225 cpabort(
"MODEL SKALA requires the GAUXC_SKALA_MODEL environment variable")
1227 params%model_eval_name = model_name
1230 SELECT CASE (trim(skala_runtime_key))
1232 params%use_self_runtime = use_skala_model .AND. para_env%num_pe > 1 .AND. params%nspins > 1
1234 params%use_self_runtime = .false.
1236 params%use_self_runtime = use_skala_model .AND. para_env%num_pe > 1
1238 CALL cp_abort(__location__,
"Unknown GAUXC%SKALA_RUNTIME value.")
1240 IF (.NOT. use_skala_model) params%use_self_runtime = .false.
1241 SELECT CASE (trim(gradient_runtime_key))
1242 CASE (
"AUTO",
"SELF")
1243 params%use_gradient_mpi_runtime = .false.
1244 params%use_gradient_self_runtime = need_xc_gradient .AND. params%use_gauxc_model .AND. &
1245 para_env%num_pe > 1 .AND. .NOT. params%use_self_runtime
1247 params%use_gradient_mpi_runtime = need_xc_gradient .AND. params%use_gauxc_model .AND. para_env%num_pe > 1
1248 params%use_gradient_self_runtime = .false.
1250 CALL cp_abort(__location__,
"Unknown GAUXC%MODEL_GRADIENT_RUNTIME value.")
1252 IF (.NOT. params%use_gauxc_model)
THEN
1253 params%use_gradient_mpi_runtime = .false.
1254 params%use_gradient_self_runtime = .false.
1256 IF (use_skala_model .AND. para_env%num_pe > 1 .AND. .NOT. params%use_self_runtime .AND. &
1257 para_env%mepos == 0 .AND.
ASSOCIATED(scf_env))
THEN
1258 IF (scf_env%iter_count == 1)
THEN
1261 "GAUXC%SKALA_RUNTIME uses the MPI communicator for energy/VXC. "// &
1262 "SKALA Torch atom chunks can be distributed across MPI ranks; "// &
1263 "set GAUXC_ONEDFT_DISTRIBUTED_TORCH=0 to force rank-0 Torch inference.")
1268 params%use_fd_gradient = gapw_method .AND. need_xc_gradient
1270 IF (.NOT.
ASSOCIATED(qs_env%gauxc_cache))
ALLOCATE (qs_env%gauxc_cache)
1271 cache => qs_env%gauxc_cache
1280 hdf5_output = (trim(output_path) /=
"")
1281 write_hdf5_output = hdf5_output .AND. para_env%mepos == 0
1282 IF (write_hdf5_output .AND.
ASSOCIATED(scf_env))
THEN
1283 write_hdf5_output = scf_env%iter_count == 1
1285 IF (write_hdf5_output)
THEN
1286 CALL gauxc_write_molecule_hdf5( &
1292 CALL gauxc_check_status(gauxc_status)
1293 CALL gauxc_write_basisset_hdf5( &
1299 CALL gauxc_check_status(gauxc_status)
1302 IF (qs_env%run_rtp)
THEN
1303 cpabort(
"GAUXC XC energy currently does not support real-time propagation")
1313 cpabort(
"UNIMPLEMENTED: Handling nimg>1 in k-point integration")
1315 CALL dbcsr_to_dense(rho_ao(1, img), density_scalar, para_env)
1316 CALL para_env%sum(density_scalar)
1317 IF (params%nspins == 1)
THEN
1318 gauxc_xc_result = gauxc_compute_xc( &
1321 nspins=params%nspins, &
1322 status=gauxc_status, &
1323 model=trim(params%model_eval_name))
1324 CALL gauxc_check_status(gauxc_status)
1325 IF (need_xc_gradient)
THEN
1326 IF (params%use_fd_gradient)
THEN
1327 CALL gauxc_xc_gradient_fd( &
1328 particle_set, qs_kind_set, density_scalar, params%nspins, params%model_eval_name, &
1329 params%xc_fun_name, params%grid_type, params%radial_quadrature, params%pruning_scheme, &
1330 params%lb_exec_space, params%int_exec_space, params%lwd_kernel, params%batch_size, &
1331 params%device_runtime_fill_fraction, gapw_fd_gradient_dx, para_env, &
1333 ELSE IF (params%use_gradient_self_runtime)
THEN
1334 exc_grad = gauxc_compute_xc_gradient( &
1335 cache%gradient_integrator, &
1337 nspins=params%nspins, &
1338 natom=params%natom, &
1339 status=gauxc_status, &
1340 model=trim(params%model_eval_name))
1342 exc_grad = gauxc_compute_xc_gradient( &
1345 nspins=params%nspins, &
1346 natom=params%natom, &
1347 status=gauxc_status, &
1348 model=trim(params%model_eval_name))
1350 CALL gauxc_check_status(gauxc_status)
1351 IF (calculate_forces)
THEN
1352 CALL add_gauxc_gradient_to_force( &
1353 exc_grad%exc_grad, &
1358 IF (molecular_virial)
THEN
1359 CALL print_gauxc_molecular_virial(exc_grad%exc_grad, particle_set, para_env)
1361 IF (molecular_virial_debug)
THEN
1362 CALL debug_gauxc_molecular_virial( &
1363 exc_grad%exc_grad, particle_set, qs_kind_set, density_scalar, params%nspins, &
1364 params%model_eval_name, params%xc_fun_name, params%grid_type, params%radial_quadrature, params%pruning_scheme, &
1365 params%lb_exec_space, params%int_exec_space, params%lwd_kernel, params%batch_size, &
1366 params%device_runtime_fill_fraction, molecular_virial_debug_dx, para_env)
1368 DEALLOCATE (exc_grad%exc_grad)
1371 cpassert(params%nspins == 2)
1375 CALL dbcsr_to_dense(rho_ao(2, img), density_zeta, para_env)
1376 CALL para_env%sum(density_zeta)
1378 density_scalar(:, :) = density_scalar(:, :) + density_zeta(:, :)
1383 density_zeta(:, :) = density_scalar(:, :) - 2.0_dp*density_zeta(:, :)
1384 gauxc_xc_result = gauxc_compute_xc( &
1390 model=trim(params%model_eval_name))
1391 CALL gauxc_check_status(gauxc_status)
1392 IF (need_xc_gradient)
THEN
1393 IF (params%use_fd_gradient)
THEN
1394 CALL gauxc_xc_gradient_fd( &
1395 particle_set, qs_kind_set, density_scalar, params%nspins, params%model_eval_name, &
1396 params%xc_fun_name, params%grid_type, params%radial_quadrature, params%pruning_scheme, &
1397 params%lb_exec_space, params%int_exec_space, params%lwd_kernel, params%batch_size, &
1398 params%device_runtime_fill_fraction, gapw_fd_gradient_dx, para_env, &
1399 exc_grad%exc_grad, density_zeta=density_zeta)
1400 ELSE IF (params%use_gradient_self_runtime)
THEN
1401 exc_grad = gauxc_compute_xc_gradient( &
1402 cache%gradient_integrator, &
1408 model=trim(params%model_eval_name))
1410 exc_grad = gauxc_compute_xc_gradient( &
1417 model=trim(params%model_eval_name))
1419 CALL gauxc_check_status(gauxc_status)
1420 IF (calculate_forces)
THEN
1421 CALL add_gauxc_gradient_to_force( &
1422 exc_grad%exc_grad, &
1427 IF (molecular_virial)
THEN
1428 CALL print_gauxc_molecular_virial(exc_grad%exc_grad, particle_set, para_env)
1430 IF (molecular_virial_debug)
THEN
1431 CALL debug_gauxc_molecular_virial( &
1432 exc_grad%exc_grad, particle_set, qs_kind_set, density_scalar, params%nspins, &
1433 params%model_eval_name, params%xc_fun_name, params%grid_type, params%radial_quadrature, params%pruning_scheme, &
1434 params%lb_exec_space, params%int_exec_space, params%lwd_kernel, params%batch_size, &
1435 params%device_runtime_fill_fraction, molecular_virial_debug_dx, para_env, &
1436 density_zeta=density_zeta)
1438 DEALLOCATE (exc_grad%exc_grad)
1442 energy%exc = energy%exc + gauxc_xc_result%exc
1444 IF (params%nspins == 1)
THEN
1446 matrix_vxc(1) = dense_to_dbcsr(gauxc_xc_result%vxc_scalar, rho_ao(1, img))
1448 cpabort(
"UNIMPLEMENTED: Handling multiple result matrices in k-point integration")
1451 cpassert(params%nspins == 2)
1453 vxc_zeta_tmp = dense_to_dbcsr(gauxc_xc_result%vxc_zeta, rho_ao(1, img))
1456 matrix_vxc(ispin) = dense_to_dbcsr(gauxc_xc_result%vxc_scalar, rho_ao(ispin, 1))
1458 matrix_vxc(ispin)%matrix, &
1459 vxc_zeta_tmp%matrix, &
1462 1.0_dp - real(ispin - 1,
dp)*2.0_dp)
1465 cpabort(
"UNIMPLEMENTED: Handling multiple result matrices in k-point integration")
1467 CALL dbcsr_release(vxc_zeta_tmp%matrix)
1468 DEALLOCATE (vxc_zeta_tmp%matrix)
1472 DEALLOCATE (density_scalar)
1473 IF (
ALLOCATED(density_zeta))
DEALLOCATE (density_zeta)
1474 DEALLOCATE (gauxc_xc_result%vxc_scalar)
1475 IF (
ALLOCATED(gauxc_xc_result%vxc_zeta))
DEALLOCATE (gauxc_xc_result%vxc_zeta)
1477 CALL set_ks_env(ks_env, matrix_vxc=matrix_vxc)
1478 DO ispin = 1, params%nspins
1479 CALL dbcsr_finalize(matrix_vxc(ispin)%matrix)
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.
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_get_readonly_block_p(matrix, row, col, block, found, row_size, col_size)
Like dbcsr_get_block_p() but with matrix being INTENT(IN). When invoking this routine,...
character function, public dbcsr_get_matrix_type(matrix)
...
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_get_stored_coordinates(matrix, row, column, processor)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_work_create(matrix, nblks_guess, sizedata_guess, n, work_mutable)
...
subroutine, public dbcsr_finalize(matrix)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_put_block(matrix, row, col, block, summation)
...
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)
...
DBCSR operations in CP2K.
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...
Definition of the atomic potential types.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Interface to the message passing library MPI.
type(mp_comm_type), parameter, public mp_comm_self
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.
Define the quickstep kind type and their sub types.
logical function, public has_nlcc(qs_kind_set)
finds if a given qs run needs to use nlcc
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_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
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...
module that contains the definitions of the scf types
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
subroutine, public gauxc_cache_init(cache, params, para_env, particle_set, qs_kind_set, status)
...
logical function, public gauxc_gapw_has_paw_pseudopotentials(qs_kind_set)
Return whether GauXC GAPW mode sees pseudopotential one-center GAPW kinds.
logical function, public xc_section_uses_gauxc(xc_section)
...
subroutine, public skala_info(functional, lsd, reference, shortform, needs, max_deriv)
Return information about the Skala functional.
subroutine, public apply_gauxc(qs_env, xc_section, calculate_forces)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.
contains a flag for each component of xc_rho_set, so that you can use it to tell which components you...