29 USE iso_c_binding,
ONLY: c_char,&
52 USE xc_gauxc_interface,
ONLY: &
53 cp_gauxc_basisset_type, cp_gauxc_grid_type, cp_gauxc_integrator_type, &
54 cp_gauxc_molecule_type, cp_gauxc_status_type, cp_gauxc_xc_gradient_type, cp_gauxc_xc_type, &
55 gauxc_check_status, gauxc_compute_xc, gauxc_compute_xc_gradient, gauxc_create_basisset, &
56 gauxc_create_grid, gauxc_create_integrator, gauxc_create_molecule, gauxc_destroy_basisset, &
57 gauxc_destroy_grid, gauxc_destroy_integrator, gauxc_destroy_molecule, &
58 gauxc_write_basisset_hdf5, gauxc_write_molecule_hdf5
60#include "../base/base_uses.f90"
66 LOGICAL,
PARAMETER :: debug_this_module = .true.
67 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'xc_gauxc_functional'
72 INTEGER(c_int) FUNCTION c_setenv(name, value, overwrite)
BIND(C, name="setenv")
73 IMPORT :: c_char, c_int
74 CHARACTER(KIND=c_char),
DIMENSION(*),
INTENT(IN) :: name, value
75 INTEGER(c_int),
VALUE :: overwrite
78 INTEGER(c_int) FUNCTION c_unsetenv(name)
BIND(C, name="unsetenv")
79 IMPORT :: c_char, c_int
80 CHARACTER(KIND=c_char),
DIMENSION(*),
INTENT(IN) :: name
81 END FUNCTION c_unsetenv
91 SUBROUTINE set_gauxc_onedft_atom_chunk_env(atom_chunk_size, is_explicit)
92 INTEGER,
INTENT(IN) :: atom_chunk_size
93 LOGICAL,
INTENT(IN) :: is_explicit
95 CHARACTER(LEN=32) :: chunk_value
96 INTEGER(c_int) :: ierr
98 IF (.NOT. is_explicit)
RETURN
100 IF (atom_chunk_size < 0)
THEN
101 ierr = c_unsetenv(
"GAUXC_ONEDFT_ATOM_CHUNK_SIZE"//c_null_char)
103 WRITE (chunk_value,
'(I0)') atom_chunk_size
105 "GAUXC_ONEDFT_ATOM_CHUNK_SIZE"//c_null_char, &
106 trim(chunk_value)//c_null_char, &
109 IF (ierr /= 0_c_int)
THEN
110 CALL cp_abort(__location__, &
111 "Could not set GAUXC_ONEDFT_ATOM_CHUNK_SIZE for GauXC OneDFT/SKALA.")
113 END SUBROUTINE set_gauxc_onedft_atom_chunk_env
120 SUBROUTINE dbcsr_to_dense(dbcsr_mat, dense_mat)
124 TYPE(dbcsr_p_type),
INTENT(IN) :: dbcsr_mat
125 REAL(c_double),
ALLOCATABLE,
DIMENSION(:, :), &
126 INTENT(INOUT) :: dense_mat
128 CHARACTER :: matrix_type
129 INTEGER :: col, col_end, col_start, icol, irow, &
130 nblkcols_total, nblkrows_total, ncols, &
131 nrows, row, row_end, row_start
132 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: c_offset, r_offset
133 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, row_blk_size
134 LOGICAL :: transposed
135 REAL(c_double),
POINTER :: block(:, :)
136 TYPE(dbcsr_iterator_type) :: iter
139 row_blk_size=row_blk_size, &
140 col_blk_size=col_blk_size, &
141 nblkrows_total=nblkrows_total, &
142 nblkcols_total=nblkcols_total, &
143 nfullrows_total=nrows, &
144 nfullcols_total=ncols)
147 IF (.NOT.
ALLOCATED(dense_mat))
THEN
148 ALLOCATE (dense_mat(nrows, ncols))
149 ELSE IF (.NOT. all(shape(dense_mat) == [nrows, ncols]))
THEN
150 DEALLOCATE (dense_mat)
151 ALLOCATE (dense_mat(nrows, ncols))
153 cpassert(all(shape(dense_mat) == [nrows, ncols]))
157 ALLOCATE (r_offset(nblkrows_total), c_offset(nblkcols_total))
160 DO row = 2, nblkrows_total
161 r_offset(row) = r_offset(row - 1) + row_blk_size(row - 1)
164 DO col = 2, nblkcols_total
165 c_offset(col) = c_offset(col - 1) + col_blk_size(col - 1)
171 row_start = r_offset(irow)
172 row_end = row_start + row_blk_size(irow) - 1
173 col_start = c_offset(icol)
174 col_end = col_start + col_blk_size(icol) - 1
176 dense_mat(row_start:row_end, col_start:col_end) = transpose(block)
177 IF (irow /= icol)
THEN
178 IF (matrix_type == dbcsr_type_symmetric)
THEN
179 dense_mat(col_start:col_end, row_start:row_end) = block
180 ELSE IF (matrix_type == dbcsr_type_antisymmetric)
THEN
181 dense_mat(col_start:col_end, row_start:row_end) = -block
185 dense_mat(row_start:row_end, col_start:col_end) = block
186 IF (irow /= icol)
THEN
187 IF (matrix_type == dbcsr_type_symmetric)
THEN
188 dense_mat(col_start:col_end, row_start:row_end) = transpose(block)
189 ELSE IF (matrix_type == dbcsr_type_antisymmetric)
THEN
190 dense_mat(col_start:col_end, row_start:row_end) = -transpose(block)
197 DEALLOCATE (r_offset, c_offset)
199 END SUBROUTINE dbcsr_to_dense
209 FUNCTION dense_to_dbcsr(dense_mat, template_dbcsr)
RESULT(dbcsr_mat)
220 dbcsr_type_symmetric, &
222 REAL(c_double),
DIMENSION(:, :),
INTENT(IN) :: dense_mat
223 TYPE(dbcsr_p_type),
INTENT(IN) :: template_dbcsr
224 TYPE(dbcsr_p_type) :: dbcsr_mat
226 INTEGER :: col, icol, irow, mynode, nblkcols_total, &
227 nblkrows_total, ncols, nrows, owner, &
229 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: c_offset, r_offset
230 INTEGER,
DIMENSION(:),
POINTER :: col_blk_size, row_blk_size
231 TYPE(dbcsr_distribution_type) :: dist
234 row_blk_size=row_blk_size, &
235 col_blk_size=col_blk_size, &
236 nblkrows_total=nblkrows_total, &
237 nblkcols_total=nblkcols_total, &
238 nfullrows_total=nrows, &
239 nfullcols_total=ncols, &
243 cpassert(nrows ==
SIZE(dense_mat, 1))
244 cpassert(ncols ==
SIZE(dense_mat, 2))
248 template=template_dbcsr%matrix, &
249 name=
"VXC from GauXC (dense)", &
250 matrix_type=dbcsr_type_symmetric)
253 ALLOCATE (r_offset(nblkrows_total), c_offset(nblkcols_total))
256 DO row = 2, nblkrows_total
257 r_offset(row) = r_offset(row - 1) + row_blk_size(row - 1)
260 DO col = 2, nblkcols_total
261 c_offset(col) = c_offset(col - 1) + col_blk_size(col - 1)
264 DO irow = 1, nblkrows_total
265 DO icol = 1, nblkcols_total
266 IF (irow > icol) cycle
268 IF (owner /= mynode) cycle
271 dense_mat(r_offset(irow):r_offset(irow) + row_blk_size(irow) - 1, &
272 c_offset(icol):c_offset(icol) + col_blk_size(icol) - 1) + &
273 transpose(dense_mat(r_offset(icol):r_offset(icol) + row_blk_size(icol) - 1, &
274 c_offset(irow):c_offset(irow) + col_blk_size(irow) - 1))))
280 DEALLOCATE (r_offset, c_offset)
282 END FUNCTION dense_to_dbcsr
289 FUNCTION get_gauxc_functional(xc_section)
RESULT(gauxc_functional_section)
290 TYPE(section_vals_type),
INTENT(in),
POINTER :: xc_section
291 TYPE(section_vals_type),
POINTER :: gauxc_functional_section
294 TYPE(section_vals_type),
POINTER :: functionals, xc_fun
296 NULLIFY (gauxc_functional_section)
299 IF (.NOT.
ASSOCIATED(functionals))
THEN
300 cpabort(
"XC_FUNCTIONAL section not found")
307 IF (.NOT.
ASSOCIATED(xc_fun))
EXIT
308 IF (xc_fun%section%name /=
"GAUXC" .OR. ifun > 1)
THEN
309 cpabort(
"GauXC functionals are mutually exclusive with any other functional.")
311 gauxc_functional_section => xc_fun
314 IF (.NOT.
ASSOCIATED(gauxc_functional_section))
THEN
315 cpabort(
"No XC functional found in XC_FUNCTIONAL section")
317 END FUNCTION get_gauxc_functional
326 LOGICAL :: uses_gauxc
332 IF (.NOT.
ASSOCIATED(xc_section))
RETURN
335 IF (.NOT.
ASSOCIATED(functionals))
RETURN
341 IF (.NOT.
ASSOCIATED(xc_fun))
EXIT
342 IF (xc_fun%section%name ==
"GAUXC")
THEN
354 SUBROUTINE ensure_gauxc_gapw_all_electron(qs_kind_set)
355 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
361 cpassert(
ASSOCIATED(qs_kind_set))
363 DO ikind = 1,
SIZE(qs_kind_set)
364 NULLIFY (gth_potential, sgp_potential)
366 gth_potential=gth_potential, &
367 sgp_potential=sgp_potential)
368 IF (
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
369 CALL cp_abort(__location__, &
370 "GauXC with METHOD GAPW currently supports all-electron potentials only. "// &
371 "Use POTENTIAL ALL for GAPW validation or METHOD GPW with pseudopotentials.")
375 END SUBROUTINE ensure_gauxc_gapw_all_electron
387 SUBROUTINE ensure_gauxc_periodic_reference_scope( &
388 dft_control, cell, qs_kind_set, do_kpoints, periodic_reference)
391 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
392 LOGICAL,
INTENT(IN) :: do_kpoints, periodic_reference
395 LOGICAL :: is_periodic
399 cpassert(
ASSOCIATED(dft_control))
400 cpassert(
ASSOCIATED(qs_kind_set))
402 is_periodic = .false.
403 IF (
ASSOCIATED(cell)) is_periodic = any(cell%perd /= 0)
406 CALL cp_abort(__location__, &
407 "GauXC currently supports only Gamma-only density matrices in CP2K. "// &
408 "Periodic k-point density matrices require a dedicated GauXC periodic interface.")
410 IF (dft_control%nimages /= 1)
THEN
411 CALL cp_abort(__location__, &
412 "GauXC currently supports only a single AO image in CP2K. "// &
413 "Periodic neighbour-cell AO blocks require a dedicated GauXC periodic interface.")
415 IF (.NOT. is_periodic)
RETURN
417 IF (.NOT. periodic_reference)
THEN
418 CALL cp_abort(__location__, &
419 "Periodic GauXC calculations in CP2K require GAUXC%PERIODIC_REFERENCE T. "// &
420 "This opt-in documents that the current path is only an isolated-cell, "// &
421 "Gamma-only, single-image METHOD GPW reference path using GauXC molecular "// &
422 "quadrature, not a dedicated periodic GauXC interface.")
425 IF (.NOT. all(cell%perd == 1))
THEN
426 CALL cp_abort(__location__, &
427 "The current GauXC isolated-cell reference path supports only PERIODIC XYZ. "// &
428 "Partial periodicity requires a dedicated GauXC periodic interface.")
430 IF (.NOT. dft_control%qs_control%gpw)
THEN
431 CALL cp_abort(__location__, &
432 "The current GauXC isolated-cell reference path is limited to METHOD GPW with GTH "// &
433 "pseudopotentials. GAPW, GAPW_XC, and other QS methods are not supported here.")
436 DO ikind = 1,
SIZE(qs_kind_set)
437 NULLIFY (gth_potential, sgp_potential)
439 gth_potential=gth_potential, &
440 sgp_potential=sgp_potential)
441 IF (.NOT.
ASSOCIATED(gth_potential) .OR.
ASSOCIATED(sgp_potential))
THEN
442 CALL cp_abort(__location__, &
443 "The current GauXC isolated-cell reference path is limited to GTH pseudopotentials. "// &
444 "Use non-periodic all-electron GAPW validation for molecular GAPW cases.")
448 END SUBROUTINE ensure_gauxc_periodic_reference_scope
457 SUBROUTINE add_gauxc_gradient_to_force(exc_grad, force, atomic_kind_set, para_env)
458 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: exc_grad
463 INTEGER :: ia, iatom, ikind, natom_kind
466 cpassert(
ASSOCIATED(force))
467 cpassert(
ASSOCIATED(atomic_kind_set))
469 IF (para_env%mepos /= 0)
RETURN
471 DO ikind = 1,
SIZE(atomic_kind_set, 1)
472 atomic_kind => atomic_kind_set(ikind)
474 DO ia = 1, natom_kind
475 iatom = atomic_kind%atom_list(ia)
476 force(ikind)%rho_elec(:, ia) = force(ikind)%rho_elec(:, ia) + &
477 exc_grad(3*iatom - 2:3*iatom)
481 END SUBROUTINE add_gauxc_gradient_to_force
501 SUBROUTINE gauxc_xc_energy_for_particles( &
502 particle_set_eval, qs_kind_set, density_scalar, nspins, model_name, &
503 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
504 int_exec_space, batch_size, device_runtime_fill_fraction, exc, density_zeta)
505 TYPE(
particle_type),
DIMENSION(:),
INTENT(IN) :: particle_set_eval
506 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
507 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: density_scalar
508 INTEGER,
INTENT(IN) :: nspins
509 CHARACTER(len=*),
INTENT(IN) :: model_name, xc_fun_name, grid_type, &
510 radial_quadrature, pruning_scheme, &
511 lb_exec_space, int_exec_space
512 INTEGER,
INTENT(IN) :: batch_size
513 REAL(kind=
dp),
INTENT(IN) :: device_runtime_fill_fraction
514 REAL(kind=
dp),
INTENT(OUT) :: exc
515 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
516 OPTIONAL :: density_zeta
518 TYPE(cp_gauxc_basisset_type) :: gauxc_basis_fd
519 TYPE(cp_gauxc_grid_type) :: gauxc_grid_fd
520 TYPE(cp_gauxc_integrator_type) :: gauxc_integrator_fd
521 TYPE(cp_gauxc_molecule_type) :: gauxc_mol_fd
522 TYPE(cp_gauxc_status_type) :: gauxc_status
523 TYPE(cp_gauxc_xc_type) :: gauxc_xc_result
525 gauxc_mol_fd = gauxc_create_molecule(particle_set_eval, gauxc_status)
526 CALL gauxc_check_status(gauxc_status)
527 gauxc_basis_fd = gauxc_create_basisset(qs_kind_set, particle_set_eval, gauxc_status)
528 CALL gauxc_check_status(gauxc_status)
529 gauxc_grid_fd = gauxc_create_grid( &
537 device_runtime_fill_fraction, &
540 CALL gauxc_check_status(gauxc_status)
541 gauxc_integrator_fd = gauxc_create_integrator( &
547 CALL gauxc_check_status(gauxc_status)
549 IF (nspins == 1)
THEN
550 gauxc_xc_result = gauxc_compute_xc( &
551 gauxc_integrator_fd, &
554 status=gauxc_status, &
555 model=trim(model_name))
557 cpassert(nspins == 2)
558 cpassert(
PRESENT(density_zeta))
559 gauxc_xc_result = gauxc_compute_xc( &
560 gauxc_integrator_fd, &
565 model=trim(model_name))
567 CALL gauxc_check_status(gauxc_status)
568 exc = gauxc_xc_result%exc
570 IF (
ALLOCATED(gauxc_xc_result%vxc_scalar))
DEALLOCATE (gauxc_xc_result%vxc_scalar)
571 IF (
ALLOCATED(gauxc_xc_result%vxc_zeta))
DEALLOCATE (gauxc_xc_result%vxc_zeta)
573 CALL gauxc_destroy_integrator(gauxc_integrator_fd, gauxc_status)
574 CALL gauxc_check_status(gauxc_status)
575 CALL gauxc_destroy_grid(gauxc_grid_fd, gauxc_status)
576 CALL gauxc_check_status(gauxc_status)
577 CALL gauxc_destroy_basisset(gauxc_basis_fd, gauxc_status)
578 CALL gauxc_check_status(gauxc_status)
579 CALL gauxc_destroy_molecule(gauxc_mol_fd, gauxc_status)
580 CALL gauxc_check_status(gauxc_status)
582 END SUBROUTINE gauxc_xc_energy_for_particles
604 SUBROUTINE gauxc_xc_gradient_fd( &
605 particle_set, qs_kind_set, density_scalar, nspins, model_name, &
606 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
607 int_exec_space, batch_size, device_runtime_fill_fraction, dx, para_env, exc_grad, &
610 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
611 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: density_scalar
612 INTEGER,
INTENT(IN) :: nspins
613 CHARACTER(len=*),
INTENT(IN) :: model_name, xc_fun_name, grid_type, &
614 radial_quadrature, pruning_scheme, &
615 lb_exec_space, int_exec_space
616 INTEGER,
INTENT(IN) :: batch_size
617 REAL(kind=
dp),
INTENT(IN) :: device_runtime_fill_fraction, dx
619 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:), &
620 INTENT(OUT) :: exc_grad
621 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
622 OPTIONAL :: density_zeta
624 INTEGER :: iatom, idir
625 REAL(kind=
dp) :: xc_minus, xc_plus
626 TYPE(
particle_type),
ALLOCATABLE,
DIMENSION(:) :: particle_set_minus, particle_set_plus
628 cpassert(
ASSOCIATED(particle_set))
629 cpassert(dx > 0.0_dp)
631 ALLOCATE (exc_grad(3*
SIZE(particle_set)))
634 IF (para_env%mepos == 0)
THEN
635 ALLOCATE (particle_set_minus(
SIZE(particle_set)), particle_set_plus(
SIZE(particle_set)))
637 DO iatom = 1,
SIZE(particle_set)
639 particle_set_minus = particle_set
640 particle_set_plus = particle_set
641 particle_set_minus(iatom)%r(idir) = particle_set_minus(iatom)%r(idir) - dx
642 particle_set_plus(iatom)%r(idir) = particle_set_plus(iatom)%r(idir) + dx
643 IF (
PRESENT(density_zeta))
THEN
644 CALL gauxc_xc_energy_for_particles( &
645 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
646 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
647 int_exec_space, batch_size, device_runtime_fill_fraction, xc_plus, &
648 density_zeta=density_zeta)
649 CALL gauxc_xc_energy_for_particles( &
650 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
651 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
652 int_exec_space, batch_size, device_runtime_fill_fraction, xc_minus, &
653 density_zeta=density_zeta)
655 CALL gauxc_xc_energy_for_particles( &
656 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
657 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
658 int_exec_space, batch_size, device_runtime_fill_fraction, xc_plus)
659 CALL gauxc_xc_energy_for_particles( &
660 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
661 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
662 int_exec_space, batch_size, device_runtime_fill_fraction, xc_minus)
664 exc_grad(3*iatom - 3 + idir) = (xc_plus - xc_minus)/(2.0_dp*dx)
668 DEALLOCATE (particle_set_minus, particle_set_plus)
671 CALL para_env%bcast(exc_grad, 0)
673 END SUBROUTINE gauxc_xc_gradient_fd
695 SUBROUTINE debug_gauxc_molecular_virial( &
696 exc_grad, particle_set, 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, batch_size, device_runtime_fill_fraction, dx, para_env, density_zeta)
699 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: exc_grad
701 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
702 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: density_scalar
703 INTEGER,
INTENT(IN) :: nspins
704 CHARACTER(len=*),
INTENT(IN) :: model_name, xc_fun_name, grid_type, &
705 radial_quadrature, pruning_scheme, &
706 lb_exec_space, int_exec_space
707 INTEGER,
INTENT(IN) :: batch_size
708 REAL(kind=
dp),
INTENT(IN) :: device_runtime_fill_fraction, dx
710 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN), &
711 OPTIONAL :: density_zeta
714 REAL(kind=
dp) :: analytic_trace, diff_trace, &
715 numerical_trace, xc_minus, xc_plus
716 REAL(kind=
dp),
DIMENSION(3) :: center, displacement, grad
717 TYPE(
particle_type),
ALLOCATABLE,
DIMENSION(:) :: particle_set_minus, particle_set_plus
719 cpassert(
ASSOCIATED(particle_set))
720 cpassert(
SIZE(exc_grad) == 3*
SIZE(particle_set))
722 IF (para_env%mepos /= 0)
RETURN
725 DO iatom = 1,
SIZE(particle_set)
726 center = center + particle_set(iatom)%r
728 center = center/real(
SIZE(particle_set),
dp)
730 ALLOCATE (particle_set_minus(
SIZE(particle_set)), particle_set_plus(
SIZE(particle_set)))
731 particle_set_minus = particle_set
732 particle_set_plus = particle_set
734 analytic_trace = 0.0_dp
735 DO iatom = 1,
SIZE(particle_set)
736 grad = exc_grad(3*iatom - 2:3*iatom)
737 displacement = particle_set(iatom)%r - center
738 analytic_trace = analytic_trace + dot_product(grad, displacement)
739 particle_set_minus(iatom)%r = center + (1.0_dp - dx)*displacement
740 particle_set_plus(iatom)%r = center + (1.0_dp + dx)*displacement
742 analytic_trace = analytic_trace/3.0_dp
744 IF (
PRESENT(density_zeta))
THEN
745 CALL gauxc_xc_energy_for_particles( &
746 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
747 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
748 int_exec_space, batch_size, device_runtime_fill_fraction, xc_plus, &
749 density_zeta=density_zeta)
750 CALL gauxc_xc_energy_for_particles( &
751 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
752 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
753 int_exec_space, batch_size, device_runtime_fill_fraction, xc_minus, &
754 density_zeta=density_zeta)
756 CALL gauxc_xc_energy_for_particles( &
757 particle_set_plus, qs_kind_set, density_scalar, nspins, model_name, &
758 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
759 int_exec_space, batch_size, device_runtime_fill_fraction, xc_plus)
760 CALL gauxc_xc_energy_for_particles( &
761 particle_set_minus, qs_kind_set, density_scalar, nspins, model_name, &
762 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, lb_exec_space, &
763 int_exec_space, batch_size, device_runtime_fill_fraction, xc_minus)
766 numerical_trace = (xc_plus - xc_minus)/(2.0_dp*dx)/3.0_dp
767 diff_trace = analytic_trace - numerical_trace
771 WRITE (unit=iw, fmt=
"(/,T2,A,1X,ES11.4)") &
772 "GAUXC| Molecular XC virial finite-difference dx", dx
773 WRITE (unit=iw, fmt=
"(T2,A,3(1X,ES19.11))") &
774 "GAUXC| Molecular XC virial FD 1/3 Trace", &
775 analytic_trace, numerical_trace, diff_trace
778 DEALLOCATE (particle_set_minus, particle_set_plus)
780 END SUBROUTINE debug_gauxc_molecular_virial
788 SUBROUTINE print_gauxc_molecular_virial(exc_grad, particle_set, para_env)
789 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: exc_grad
793 CHARACTER(len=1),
DIMENSION(3),
PARAMETER :: label = [
"x",
"y",
"z"]
795 INTEGER :: i, iatom, iw, j
796 REAL(kind=
dp),
DIMENSION(3) :: center, displacement, grad, grad_sum
797 REAL(kind=
dp),
DIMENSION(3, 3) :: molecular_virial
799 cpassert(
ASSOCIATED(particle_set))
800 cpassert(
SIZE(exc_grad) == 3*
SIZE(particle_set))
802 IF (para_env%mepos /= 0)
RETURN
805 DO iatom = 1,
SIZE(particle_set)
806 center = center + particle_set(iatom)%r
808 center = center/real(
SIZE(particle_set),
dp)
811 molecular_virial = 0.0_dp
812 DO iatom = 1,
SIZE(particle_set)
813 grad = exc_grad(3*iatom - 2:3*iatom)
814 displacement = particle_set(iatom)%r - center
815 grad_sum = grad_sum + grad
818 molecular_virial(i, j) = molecular_virial(i, j) + grad(i)*displacement(j)
826 WRITE (unit=iw, fmt=
"(/,T2,A)") &
827 "GAUXC| Molecular XC gradient virial diagnostic [a.u.]"
828 WRITE (unit=iw, fmt=
"(T2,A,T20,A,T40,A,T60,A)")
"GAUXC|",
"x",
"y",
"z"
830 WRITE (unit=iw, fmt=
"(T2,A,1X,A1,3(1X,ES19.11))") &
831 "GAUXC|", label(i), molecular_virial(i, :)
833 WRITE (unit=iw, fmt=
"(T2,A,1X,ES19.11)") &
834 "GAUXC| Molecular XC gradient virial 1/3 Trace", &
835 (molecular_virial(1, 1) + molecular_virial(2, 2) + molecular_virial(3, 3))/3.0_dp
836 WRITE (unit=iw, fmt=
"(T2,A,3(1X,ES19.11))") &
837 "GAUXC| Molecular XC gradient sum", grad_sum
838 WRITE (unit=iw, fmt=
"(T2,A)") &
839 "GAUXC| Diagnostic only; this is not an analytical periodic stress tensor."
841 END SUBROUTINE print_gauxc_molecular_virial
853 SUBROUTINE skala_info(functional, lsd, reference, shortform, needs, max_deriv)
855 LOGICAL,
INTENT(in) :: lsd
856 CHARACTER(LEN=*),
INTENT(OUT),
OPTIONAL :: reference, shortform
858 INTEGER,
INTENT(out),
OPTIONAL :: max_deriv
860 CHARACTER(len=default_path_length) :: model_key, model_name
861 CHARACTER(len=default_string_length) :: xc_fun_name
862 LOGICAL :: native_grid
867 model_key = adjustl(model_name)
870 IF (
PRESENT(reference))
THEN
871 IF (trim(model_key) ==
"NONE" .OR. trim(model_key) ==
"")
THEN
872 reference =
"Functional computed by GauXC (underlying: "//trim(xc_fun_name)//
")"
874 reference =
"Functional computed by GauXC OneDFT model "//trim(model_name)
877 IF (
PRESENT(shortform))
THEN
878 IF (trim(model_key) ==
"NONE" .OR. trim(model_key) ==
"")
THEN
879 shortform =
"GAUXC ("//trim(xc_fun_name)//
")"
881 shortform =
"GAUXC OneDFT"
884 IF (
PRESENT(needs))
THEN
885 IF (native_grid .AND. trim(model_key) /=
"NONE" .AND. trim(model_key) /=
"")
THEN
887 needs%rho_spin = .true.
888 needs%drho_spin = .true.
889 needs%tau_spin = .true.
898 needs%rho_spin = .true.
902 IF (
PRESENT(max_deriv)) max_deriv = 1
919 LOGICAL,
INTENT(IN) :: calculate_forces
921 CHARACTER(len=*),
PARAMETER :: gapw_xc_abort_message = &
922 "GauXC with METHOD GAPW_XC is not supported yet. "// &
923 "The GAPW_XC one-center XC correction needs a dedicated GauXC design.", &
924 nonlocal_vdw_abort_message = &
925 "GauXC does not support non-local VDW_POTENTIAL corrections. "// &
926 "Use an additive PAIR_POTENTIAL dispersion correction or disable GauXC."
927 REAL(kind=
dp),
PARAMETER :: gapw_fd_gradient_dx = 1.0e-4_dp
929 CHARACTER(len=32) :: gradient_mpi_runtime_env
930 CHARACTER(len=default_path_length) :: model_key, model_name, output_path
931 CHARACTER(len=default_string_length) :: grid_key, grid_type, int_exec_space, lb_exec_space, &
932 pruning_key, pruning_scheme, radial_quadrature, skala_runtime, skala_runtime_key, &
934 INTEGER :: batch_size, env_status, img, ispin, &
935 natom, nimages, nspins, &
936 onedft_atom_chunk_size
937 LOGICAL :: do_kpoints, grid_explicit, hdf5_output, is_periodic, molecular_virial, &
938 molecular_virial_debug, onedft_atom_chunk_size_explicit, periodic_reference, &
939 pruning_explicit, use_fd_gradient, use_gradient_mpi_runtime, use_gradient_self_runtime, &
940 use_onedft, use_self_runtime, use_skala_model, write_hdf5_output
941 REAL(kind=
dp) :: device_runtime_fill_fraction, &
942 molecular_virial_debug_dx
943 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: density_scalar, density_zeta
946 TYPE(cp_gauxc_basisset_type) :: gauxc_basis
947 TYPE(cp_gauxc_grid_type) :: gauxc_gradient_grid_result, &
949 TYPE(cp_gauxc_integrator_type) :: gauxc_gradient_integrator_result, gauxc_integrator_result
950 TYPE(cp_gauxc_molecule_type) :: gauxc_mol
951 TYPE(cp_gauxc_status_type) :: gauxc_status
952 TYPE(cp_gauxc_xc_gradient_type) :: exc_grad
953 TYPE(cp_gauxc_xc_type) :: gauxc_xc_result
954 TYPE(dbcsr_p_type) :: vxc_zeta_tmp
955 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_vxc
956 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao
962 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
988 dft_control=dft_control, &
989 do_kpoints=do_kpoints, &
992 matrix_vxc=matrix_vxc, &
994 atomic_kind_set=atomic_kind_set, &
997 particle_set=particle_set, &
998 qs_kind_set=qs_kind_set, &
1003 IF (dft_control%qs_control%gapw_xc)
THEN
1004 cpabort(gapw_xc_abort_message)
1006 IF (dft_control%qs_control%gapw)
THEN
1007 CALL ensure_gauxc_gapw_all_electron(qs_kind_set)
1009 cpassert(
ASSOCIATED(rho))
1015 nimages = dft_control%nimages
1016 nspins = dft_control%nspins
1017 is_periodic = .false.
1018 IF (
ASSOCIATED(cell)) is_periodic = any(cell%perd /= 0)
1020 IF (
ASSOCIATED(qs_env%dispersion_env))
THEN
1022 cpabort(nonlocal_vdw_abort_message)
1025 NULLIFY (vxc_zeta_tmp%matrix)
1027 gauxc_functional_section => get_gauxc_functional(xc_section)
1029 gauxc_functional_section, &
1033 gauxc_functional_section, &
1037 gauxc_functional_section, &
1040 explicit=grid_explicit)
1042 gauxc_functional_section, &
1043 "RADIAL_QUADRATURE", &
1044 c_val=radial_quadrature)
1046 gauxc_functional_section, &
1048 c_val=pruning_scheme, &
1049 explicit=pruning_explicit)
1051 gauxc_functional_section, &
1055 gauxc_functional_section, &
1056 "DEVICE_RUNTIME_FILL_FRACTION", &
1057 r_val=device_runtime_fill_fraction)
1059 gauxc_functional_section, &
1060 "ONEDFT_ATOM_CHUNK_SIZE", &
1061 i_val=onedft_atom_chunk_size, &
1062 explicit=onedft_atom_chunk_size_explicit)
1064 gauxc_functional_section, &
1065 "PERIODIC_REFERENCE", &
1066 l_val=periodic_reference)
1068 gauxc_functional_section, &
1069 "MOLECULAR_VIRIAL", &
1070 l_val=molecular_virial)
1072 gauxc_functional_section, &
1073 "MOLECULAR_VIRIAL_DEBUG", &
1074 l_val=molecular_virial_debug)
1076 gauxc_functional_section, &
1077 "MOLECULAR_VIRIAL_DEBUG_DX", &
1078 r_val=molecular_virial_debug_dx)
1080 gauxc_functional_section, &
1081 "LB_EXECUTION_SPACE", &
1082 c_val=lb_exec_space)
1084 gauxc_functional_section, &
1085 "INT_EXECUTION_SPACE", &
1086 c_val=int_exec_space)
1088 gauxc_functional_section, &
1090 c_val=skala_runtime)
1092 gauxc_functional_section, &
1096 model_key = adjustl(model_name)
1098 skala_runtime_key = adjustl(skala_runtime)
1100 use_onedft = (trim(model_key) /=
"" .AND. trim(model_key) /=
"NONE")
1101 use_skala_model = (index(trim(model_key),
"SKALA") > 0)
1102 IF (device_runtime_fill_fraction <= 0.0_dp .OR. device_runtime_fill_fraction > 1.0_dp)
THEN
1103 CALL cp_abort(__location__, &
1104 "GAUXC%DEVICE_RUNTIME_FILL_FRACTION must be > 0 and <= 1.")
1106 IF (onedft_atom_chunk_size < -1)
THEN
1107 CALL cp_abort(__location__, &
1108 "GAUXC%ONEDFT_ATOM_CHUNK_SIZE must be -1, zero, or positive.")
1110 IF (molecular_virial_debug)
THEN
1111 IF (molecular_virial_debug_dx <= 0.0_dp)
THEN
1112 CALL cp_abort(__location__, &
1113 "GauXC MOLECULAR_VIRIAL_DEBUG_DX must be positive.")
1115 molecular_virial = .true.
1117 CALL ensure_gauxc_periodic_reference_scope( &
1118 dft_control, cell, qs_kind_set, do_kpoints, periodic_reference)
1119 IF (is_periodic .AND. periodic_reference .AND. para_env%mepos == 0)
THEN
1120 IF (
ASSOCIATED(scf_env))
THEN
1121 IF (scf_env%iter_count == 1)
THEN
1124 "GAUXC%PERIODIC_REFERENCE uses GauXC molecular quadrature for isolated validation "// &
1125 "cells. Compact periodic materials require a dedicated periodic GauXC interface.")
1129 IF (dft_control%qs_control%gapw_xc .AND. use_onedft)
THEN
1130 CALL cp_abort(__location__, &
1131 "GauXC OneDFT/SKALA with METHOD GAPW_XC is not implemented. "// &
1132 "The GAPW_XC one-center XC correction must be evaluated by the same GauXC model.")
1134 IF (use_onedft)
THEN
1136 CALL cp_abort(__location__, &
1137 "GauXC OneDFT/SKALA with NLCC pseudopotentials is not implemented. "// &
1138 "The frozen core density would need a SKALA-consistent feature definition.")
1141 IF (use_onedft)
THEN
1142 CALL set_gauxc_onedft_atom_chunk_env( &
1143 onedft_atom_chunk_size, onedft_atom_chunk_size_explicit)
1144 IF (.NOT. grid_explicit) grid_type =
"SUPERFINE"
1145 IF (.NOT. pruning_explicit) pruning_scheme =
"UNPRUNED"
1147 grid_key = adjustl(grid_type)
1148 pruning_key = adjustl(pruning_scheme)
1151 IF (use_skala_model .AND. (calculate_forces .OR. molecular_virial) .AND. &
1152 (trim(grid_key) /=
"SUPERFINE" .OR. trim(pruning_key) /=
"UNPRUNED"))
THEN
1155 "GauXC OneDFT/SKALA nuclear gradients are sensitive to the GauXC molecular grid. "// &
1156 "Use GRID SUPERFINE and PRUNING_SCHEME UNPRUNED for quantitative force checks.")
1158 IF (trim(model_key) ==
"SKALA")
THEN
1159 CALL get_environment_variable(
"GAUXC_SKALA_MODEL", model_name, status=env_status)
1160 IF (env_status /= 0 .OR. len_trim(model_name) == 0)
THEN
1161 cpabort(
"MODEL SKALA requires the GAUXC_SKALA_MODEL environment variable")
1165 SELECT CASE (trim(skala_runtime_key))
1167 use_self_runtime = use_skala_model .AND. para_env%num_pe > 1 .AND. nspins > 1
1169 use_self_runtime = .false.
1171 use_self_runtime = use_skala_model .AND. para_env%num_pe > 1
1173 CALL cp_abort(__location__,
"Unknown GAUXC%SKALA_RUNTIME value.")
1175 IF (.NOT. use_skala_model) use_self_runtime = .false.
1176 use_gradient_self_runtime = calculate_forces .AND. use_onedft .AND. &
1177 para_env%num_pe > 1 .AND. .NOT. use_self_runtime
1178 IF (use_skala_model .AND. para_env%num_pe > 1 .AND. .NOT. use_self_runtime .AND. &
1179 para_env%mepos == 0 .AND.
ASSOCIATED(scf_env))
THEN
1180 IF (scf_env%iter_count == 1)
THEN
1183 "GAUXC%SKALA_RUNTIME uses the MPI communicator for energy/VXC. "// &
1184 "SKALA Torch atom chunks can be distributed across MPI ranks; "// &
1185 "set GAUXC_ONEDFT_DISTRIBUTED_TORCH=0 to force rank-0 Torch inference.")
1188 use_gradient_mpi_runtime = .false.
1189 CALL get_environment_variable(
"GAUXC_GRADIENT_MPI_RUNTIME", gradient_mpi_runtime_env, &
1191 IF (env_status == 0)
THEN
1192 CALL uppercase(gradient_mpi_runtime_env)
1193 SELECT CASE (trim(gradient_mpi_runtime_env))
1194 CASE (
"",
"0",
"FALSE",
"F",
"OFF",
"AUTO")
1195 use_gradient_mpi_runtime = .false.
1196 CASE (
"1",
"TRUE",
"T",
"ON",
"MPI")
1197 use_gradient_mpi_runtime = .true.
1199 CALL cp_abort(__location__, &
1200 "GAUXC_GRADIENT_MPI_RUNTIME must be 0/1, TRUE/FALSE, ON/OFF, or MPI.")
1204 gauxc_mol = gauxc_create_molecule( &
1207 CALL gauxc_check_status(gauxc_status)
1208 gauxc_basis = gauxc_create_basisset( &
1212 CALL gauxc_check_status(gauxc_status)
1213 hdf5_output = (trim(output_path) /=
"")
1214 write_hdf5_output = hdf5_output .AND. para_env%mepos == 0
1215 IF (write_hdf5_output .AND.
ASSOCIATED(scf_env))
THEN
1216 write_hdf5_output = scf_env%iter_count == 1
1218 IF (write_hdf5_output)
THEN
1219 CALL gauxc_write_molecule_hdf5( &
1225 CALL gauxc_check_status(gauxc_status)
1226 CALL gauxc_write_basisset_hdf5( &
1232 CALL gauxc_check_status(gauxc_status)
1234 use_fd_gradient = dft_control%qs_control%gapw .AND. calculate_forces .AND. &
1235 (use_skala_model .OR. gauxc_basis%max_l > 3)
1236 IF (use_gradient_mpi_runtime)
THEN
1237 use_gradient_self_runtime = .false.
1239 IF (use_fd_gradient .AND. para_env%mepos == 0)
THEN
1242 "Using finite-difference GauXC XC gradients for METHOD GAPW with SKALA or "// &
1243 "all-electron basis functions beyond f shells. The upstream analytical GauXC "// &
1244 "gradient path is not yet reliable for this case.")
1246 IF (use_self_runtime)
THEN
1249 gauxc_grid_result = gauxc_create_grid( &
1253 radial_quadrature, &
1257 device_runtime_fill_fraction, &
1265 gauxc_grid_result = gauxc_create_grid( &
1269 radial_quadrature, &
1273 device_runtime_fill_fraction, &
1275 mpi_comm=para_env%get_handle())
1277 CALL gauxc_check_status(gauxc_status)
1278 gauxc_integrator_result = gauxc_create_integrator( &
1279 trim(xc_fun_name), &
1280 gauxc_grid_result, &
1284 CALL gauxc_check_status(gauxc_status)
1286 IF (use_gradient_self_runtime)
THEN
1290 gauxc_gradient_grid_result = gauxc_create_grid( &
1294 radial_quadrature, &
1298 device_runtime_fill_fraction, &
1301 CALL gauxc_check_status(gauxc_status)
1302 gauxc_gradient_integrator_result = gauxc_create_integrator( &
1303 trim(xc_fun_name), &
1304 gauxc_gradient_grid_result, &
1308 CALL gauxc_check_status(gauxc_status)
1311 IF (qs_env%run_rtp)
THEN
1312 cpabort(
"GAUXC XC energy currently does not support real-time propagation")
1322 cpabort(
"UNIMPLEMENTED: Handling nimg>1 in k-point integration")
1324 CALL dbcsr_to_dense(rho_ao(1, img), density_scalar)
1325 CALL para_env%sum(density_scalar)
1326 IF (nspins == 1)
THEN
1327 gauxc_xc_result = gauxc_compute_xc( &
1328 gauxc_integrator_result, &
1331 status=gauxc_status, &
1332 model=trim(model_name))
1333 CALL gauxc_check_status(gauxc_status)
1334 IF (calculate_forces)
THEN
1335 IF (use_fd_gradient)
THEN
1336 CALL gauxc_xc_gradient_fd( &
1337 particle_set, qs_kind_set, density_scalar, nspins, model_name, &
1338 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, &
1339 lb_exec_space, int_exec_space, batch_size, &
1340 device_runtime_fill_fraction, gapw_fd_gradient_dx, para_env, &
1342 ELSE IF (use_gradient_self_runtime)
THEN
1343 exc_grad = gauxc_compute_xc_gradient( &
1344 gauxc_gradient_integrator_result, &
1348 status=gauxc_status, &
1349 model=trim(model_name))
1351 exc_grad = gauxc_compute_xc_gradient( &
1352 gauxc_integrator_result, &
1356 status=gauxc_status, &
1357 model=trim(model_name))
1359 CALL gauxc_check_status(gauxc_status)
1360 CALL add_gauxc_gradient_to_force( &
1361 exc_grad%exc_grad, &
1365 IF (molecular_virial)
THEN
1366 CALL print_gauxc_molecular_virial(exc_grad%exc_grad, particle_set, para_env)
1368 IF (molecular_virial_debug)
THEN
1369 CALL debug_gauxc_molecular_virial( &
1370 exc_grad%exc_grad, particle_set, qs_kind_set, density_scalar, nspins, &
1371 model_name, xc_fun_name, grid_type, radial_quadrature, pruning_scheme, &
1372 lb_exec_space, int_exec_space, batch_size, device_runtime_fill_fraction, &
1373 molecular_virial_debug_dx, para_env)
1375 DEALLOCATE (exc_grad%exc_grad)
1378 cpassert(nspins == 2)
1382 CALL dbcsr_to_dense(rho_ao(2, img), density_zeta)
1383 CALL para_env%sum(density_zeta)
1385 density_scalar(:, :) = density_scalar(:, :) + density_zeta(:, :)
1390 density_zeta(:, :) = density_scalar(:, :) - 2.0_dp*density_zeta(:, :)
1391 gauxc_xc_result = gauxc_compute_xc( &
1392 gauxc_integrator_result, &
1397 model=trim(model_name))
1398 CALL gauxc_check_status(gauxc_status)
1399 IF (calculate_forces)
THEN
1400 IF (use_fd_gradient)
THEN
1401 CALL gauxc_xc_gradient_fd( &
1402 particle_set, qs_kind_set, density_scalar, nspins, model_name, &
1403 xc_fun_name, grid_type, radial_quadrature, pruning_scheme, &
1404 lb_exec_space, int_exec_space, batch_size, &
1405 device_runtime_fill_fraction, gapw_fd_gradient_dx, para_env, &
1406 exc_grad%exc_grad, density_zeta=density_zeta)
1407 ELSE IF (use_gradient_self_runtime)
THEN
1408 exc_grad = gauxc_compute_xc_gradient( &
1409 gauxc_gradient_integrator_result, &
1415 model=trim(model_name))
1417 exc_grad = gauxc_compute_xc_gradient( &
1418 gauxc_integrator_result, &
1424 model=trim(model_name))
1426 CALL gauxc_check_status(gauxc_status)
1427 CALL add_gauxc_gradient_to_force( &
1428 exc_grad%exc_grad, &
1432 IF (molecular_virial)
THEN
1433 CALL print_gauxc_molecular_virial(exc_grad%exc_grad, particle_set, para_env)
1435 IF (molecular_virial_debug)
THEN
1436 CALL debug_gauxc_molecular_virial( &
1437 exc_grad%exc_grad, particle_set, qs_kind_set, density_scalar, nspins, &
1438 model_name, xc_fun_name, grid_type, radial_quadrature, pruning_scheme, &
1439 lb_exec_space, int_exec_space, batch_size, device_runtime_fill_fraction, &
1440 molecular_virial_debug_dx, para_env, density_zeta=density_zeta)
1442 DEALLOCATE (exc_grad%exc_grad)
1446 energy%exc = energy%exc + gauxc_xc_result%exc
1448 IF (nspins == 1)
THEN
1450 matrix_vxc(1) = dense_to_dbcsr(gauxc_xc_result%vxc_scalar, rho_ao(1, img))
1452 cpabort(
"UNIMPLEMENTED: Handling multiple result matrices in k-point integration")
1455 cpassert(nspins == 2)
1457 vxc_zeta_tmp = dense_to_dbcsr(gauxc_xc_result%vxc_zeta, rho_ao(1, img))
1460 matrix_vxc(ispin) = dense_to_dbcsr(gauxc_xc_result%vxc_scalar, rho_ao(ispin, 1))
1462 matrix_vxc(ispin)%matrix, &
1463 vxc_zeta_tmp%matrix, &
1466 1.0_dp - real(ispin - 1,
dp)*2.0_dp)
1469 cpabort(
"UNIMPLEMENTED: Handling multiple result matrices in k-point integration")
1471 CALL dbcsr_release(vxc_zeta_tmp%matrix)
1472 DEALLOCATE (vxc_zeta_tmp%matrix)
1476 DEALLOCATE (density_scalar)
1477 IF (
ALLOCATED(density_zeta))
DEALLOCATE (density_zeta)
1478 DEALLOCATE (gauxc_xc_result%vxc_scalar)
1479 IF (
ALLOCATED(gauxc_xc_result%vxc_zeta))
DEALLOCATE (gauxc_xc_result%vxc_zeta)
1481 CALL set_ks_env(ks_env, matrix_vxc=matrix_vxc)
1482 DO ispin = 1, nspins
1483 CALL dbcsr_finalize(matrix_vxc(ispin)%matrix)
1486 IF (use_gradient_self_runtime)
THEN
1487 CALL gauxc_destroy_integrator(gauxc_gradient_integrator_result, gauxc_status)
1488 CALL gauxc_check_status(gauxc_status)
1489 CALL gauxc_destroy_grid(gauxc_gradient_grid_result, gauxc_status)
1490 CALL gauxc_check_status(gauxc_status)
1492 CALL gauxc_destroy_integrator(gauxc_integrator_result, gauxc_status)
1493 CALL gauxc_check_status(gauxc_status)
1494 CALL gauxc_destroy_grid(gauxc_grid_result, gauxc_status)
1495 CALL gauxc_check_status(gauxc_status)
1496 CALL gauxc_destroy_basisset(gauxc_basis, gauxc_status)
1497 CALL gauxc_check_status(gauxc_status)
1498 CALL gauxc_destroy_molecule(gauxc_mol, gauxc_status)
1499 CALL gauxc_check_status(gauxc_status)
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...
character function, public dbcsr_get_matrix_type(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
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_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_finalize(matrix)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
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.
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...