9#include "gauxc/gauxc_config.f"
12#define GAUXC_RETURN_IF_ERROR(status) IF (status%status%code /= 0) RETURN
14MODULE xc_gauxc_interface
16 USE iso_fortran_env,
ONLY: &
18#if defined (__HAS_IEEE_EXCEPTIONS)
19 USE ieee_exceptions,
ONLY: &
21 ieee_get_halting_mode, &
24 USE iso_c_binding,
ONLY: &
67 USE gauxc_status,
ONLY: &
68 gauxc_status_message, &
70 USE gauxc_enums,
ONLY: &
71 gauxc_atomicgridsizedefault, &
72 gauxc_executionspace, &
73 gauxc_pruningscheme, &
75 USE gauxc_runtime_environment,
ONLY: &
76 gauxc_runtime_environment_delete, &
77 gauxc_runtime_environment_new, &
78 gauxc_runtime_environment_type
79#ifdef GAUXC_HAS_DEVICE
80 USE gauxc_runtime_environment,
ONLY: &
81 gauxc_device_runtime_environment_new
83 USE gauxc_molecule,
ONLY: &
85 gauxc_molecule_new_from_atoms, &
87 USE gauxc_atom,
ONLY: &
89 USE gauxc_basisset,
ONLY: &
91 gauxc_basisset_new_from_shells, &
92 gauxc_basisset_type, &
94 USE gauxc_shell,
ONLY: &
96 USE gauxc_molgrid,
ONLY: &
98 gauxc_molgrid_new_default, &
100 USE gauxc_load_balancer,
ONLY: &
102 gauxc_load_balancer_factory_get_instance, &
103 gauxc_load_balancer_factory_new, &
104 gauxc_load_balancer_factory_type, &
105 gauxc_load_balancer_type
106 USE gauxc_molecular_weights,
ONLY: &
108 gauxc_get_instance, &
109 gauxc_molecular_weights_factory_new, &
110 gauxc_molecular_weights_factory_type, &
111 gauxc_molecular_weights_modify_weights, &
112 gauxc_molecular_weights_settings, &
113 gauxc_molecular_weights_type
114 USE gauxc_xc_functional,
ONLY: &
116 gauxc_functional_from_string, &
117 gauxc_functional_type
118 USE gauxc_integrator,
ONLY: &
120 gauxc_integrator_eval_exc_grad_rks, &
121 gauxc_integrator_eval_exc_grad_uks, &
122 gauxc_integrator_eval_exc_vxc_rks, &
123 gauxc_integrator_eval_exc_vxc_uks, &
124 gauxc_integrator_new, &
125 gauxc_integrator_type
126#ifdef GAUXC_HAS_ONEDFT
127 USE gauxc_integrator,
ONLY: &
128 gauxc_integrator_eval_exc_grad_onedft_uks, &
129 gauxc_integrator_eval_exc_vxc_onedft_uks
131 omp_get_max_threads, &
135 USE gauxc_external_hdf5_write,
ONLY: &
136 gauxc_write_hdf5_record
142#include "../base/base_uses.f90"
151 TYPE cp_gauxc_molecule_type
152 END TYPE cp_gauxc_molecule_type
154 TYPE cp_gauxc_basisset_type
155 INTEGER :: max_l = -1
156 END TYPE cp_gauxc_basisset_type
158 TYPE cp_gauxc_grid_type
159 END TYPE cp_gauxc_grid_type
161 TYPE cp_gauxc_integrator_type
162 END TYPE cp_gauxc_integrator_type
164 TYPE cp_gauxc_status_type
165 END TYPE cp_gauxc_status_type
171 TYPE cp_gauxc_molecule_type
172 TYPE(gauxc_molecule_type) :: molecule
173 END TYPE cp_gauxc_molecule_type
175 TYPE cp_gauxc_basisset_type
176 TYPE(gauxc_basisset_type) :: basis
177 INTEGER :: max_l = -1
178 END TYPE cp_gauxc_basisset_type
180 TYPE cp_gauxc_grid_type
181 TYPE(gauxc_molgrid_type) :: grid
182 TYPE(gauxc_load_balancer_type) :: lb
183 TYPE(gauxc_load_balancer_factory_type) :: lbf
184 TYPE(gauxc_molecular_weights_type) :: mw
185 TYPE(gauxc_molecular_weights_factory_type) :: mwf
186 TYPE(gauxc_runtime_environment_type) :: rt
187 LOGICAL :: owns_rt = .false.
188 END TYPE cp_gauxc_grid_type
190 TYPE cp_gauxc_integrator_type
191 TYPE(gauxc_functional_type) :: func
193 END TYPE cp_gauxc_integrator_type
195 TYPE cp_gauxc_status_type
196 TYPE(gauxc_status_type) :: status
197 END TYPE cp_gauxc_status_type
199 TYPE(gauxc_runtime_environment_type) :: rt
200 INTEGER :: rt_mpi_comm = -1
201 LOGICAL :: rt_has_mpi_comm = .false.
205 TYPE cp_gauxc_xc_type
206 REAL(c_double) :: exc = 0.0_c_double
207 REAL(c_double),
DIMENSION(:, :),
ALLOCATABLE :: vxc_scalar, vxc_zeta
208 END TYPE cp_gauxc_xc_type
210 TYPE cp_gauxc_xc_gradient_type
211 REAL(c_double),
ALLOCATABLE,
DIMENSION(:) :: exc_grad
212 END TYPE cp_gauxc_xc_gradient_type
214 CHARACTER(len=*),
PARAMETER :: no_gauxc_message =
"Compile CP2K with GauXC to use this functionality!"
217 cp_gauxc_basisset_type, &
218 cp_gauxc_grid_type, &
219 cp_gauxc_integrator_type, &
220 cp_gauxc_molecule_type, &
221 cp_gauxc_status_type, &
222 cp_gauxc_xc_gradient_type, &
224 gauxc_check_status, &
225 gauxc_compute_xc_gradient, &
227 gauxc_create_basisset, &
229 gauxc_create_integrator, &
230 gauxc_create_molecule, &
231 gauxc_destroy_basisset, &
232 gauxc_destroy_grid, &
233 gauxc_destroy_integrator, &
234 gauxc_destroy_molecule, &
237 gauxc_write_basisset_hdf5, &
238 gauxc_write_molecule_hdf5
247 TYPE(cp_gauxc_status_type) :: status
250 CHARACTER(kind=c_char),
POINTER :: s(:)
251 CHARACTER(len=32) :: stderr_env
252 INTEGER :: i, ierr, iw
253 LOGICAL :: print_to_stderr
254 INTEGER,
PARAMETER :: status_message_length = 4096
258 CALL get_environment_variable(
"CP2K_GAUXC_STATUS_STDERR", stderr_env)
260 SELECT CASE (trim(stderr_env))
261 CASE (
"",
"0",
"FALSE",
"F",
"OFF",
"NO")
262 print_to_stderr = .false.
263 CASE (
"1",
"TRUE",
"T",
"ON",
"YES")
264 print_to_stderr = .true.
266 print_to_stderr = .true.
269 WRITE (unit=iw, fmt=
'(a,1x,i0)')
"GauXC returned with status code", status%status%code
270 IF (c_associated(status%status%message))
THEN
271 WRITE (unit=iw, fmt=
'(a)', advance=
'no')
"GauXC status message: ["
273 CALL c_f_pointer(status%status%message, s, [status_message_length])
275 IF (s(i) == c_null_char)
EXIT
276 WRITE (unit=iw, fmt=
'(A)', advance=
'no') s(i)
279 WRITE (unit=iw, fmt=
'(a)')
"]"
281 WRITE (unit=iw, fmt=
'(a)')
"GauXC status message: [null]"
284 IF (print_to_stderr)
THEN
285 WRITE (unit=ierr, fmt=
'(a,1x,i0)')
"GauXC returned with status code", status%status%code
286 IF (c_associated(status%status%message))
THEN
287 WRITE (unit=ierr, fmt=
'(a)', advance=
'no')
"GauXC status message: ["
289 CALL c_f_pointer(status%status%message, s, [status_message_length])
291 IF (s(i) == c_null_char)
EXIT
292 WRITE (unit=ierr, fmt=
'(A)', advance=
'no') s(i)
295 WRITE (unit=ierr, fmt=
'(a)')
"]"
297 WRITE (unit=ierr, fmt=
'(a)')
"GauXC status message: [null]"
310 SUBROUTINE gauxc_init(mpi_comm, status)
311 INTEGER,
INTENT(IN),
OPTIONAL :: mpi_comm
312 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
315#if defined(GAUXC_HAS_MPI) && defined(__parallel)
316 IF (
PRESENT(mpi_comm))
THEN
317 rt = gauxc_runtime_environment_new(status%status, mpi_comm)
318 rt_mpi_comm = mpi_comm
319 rt_has_mpi_comm = .true.
321 rt = gauxc_runtime_environment_new(status%status)
323 rt_has_mpi_comm = .false.
327 rt = gauxc_runtime_environment_new(status%status)
329 rt_has_mpi_comm = .false.
331 gauxc_return_if_error(status)
336 END SUBROUTINE gauxc_init
342 SUBROUTINE gauxc_finalize(status)
343 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
346 CALL gauxc_runtime_environment_delete(status%status, rt)
347 gauxc_return_if_error(status)
349 rt_has_mpi_comm = .false.
353 END SUBROUTINE gauxc_finalize
361 FUNCTION gauxc_create_molecule(particle_set, status)
RESULT(res)
362 TYPE(
particle_type),
DIMENSION(:),
INTENT(IN) :: particle_set
363 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
364 TYPE(cp_gauxc_molecule_type) :: res
367 CHARACTER(LEN=2) :: element_symbol
368 INTEGER :: atomic_number, i, natoms
370 TYPE(gauxc_atom_type),
ALLOCATABLE,
DIMENSION(:) :: atoms
372 natoms =
SIZE(particle_set)
373 ALLOCATE (atoms(natoms))
376 atomic_kind => particle_set(i)%atomic_kind
379 atoms(i)%atomic_number = int(atomic_number, c_int64_t)
380 atoms(i)%x = real(particle_set(i)%r(1), c_double)
381 atoms(i)%y = real(particle_set(i)%r(2), c_double)
382 atoms(i)%z = real(particle_set(i)%r(3), c_double)
385 res%molecule = gauxc_molecule_new_from_atoms(status%status, atoms, int(natoms, c_size_t))
386 gauxc_return_if_error(status)
390 mark_used(particle_set)
393 cpabort(no_gauxc_message)
395 END FUNCTION gauxc_create_molecule
404 FUNCTION gauxc_create_basisset(qs_kind_set, particle_set, status)
RESULT(res)
406 POINTER :: qs_kind_set
407 TYPE(
particle_type),
DIMENSION(:),
INTENT(IN) :: particle_set
408 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
409 TYPE(cp_gauxc_basisset_type) :: res
412 INTEGER :: iatom, ikind, iprim, iset, ishell, lval, &
413 nkind, npgf, nset, nshell, &
414 nshell_total, shell_index, natoms
415 REAL(c_double),
DIMENSION(3) :: shell_origin
417 TYPE(gauxc_shell_type),
ALLOCATABLE,
DIMENSION(:) :: shells
421 nkind =
SIZE(qs_kind_set)
422 natoms =
SIZE(particle_set)
424 ALLOCATE (basis_set_list(nkind))
429 atomic_kind => particle_set(iatom)%atomic_kind
431 gto_basis => basis_set_list(ikind)%gto_basis_set
432 cpassert(
ASSOCIATED(gto_basis))
434 nshell_total = nshell_total + sum(gto_basis%nshell)
437 ALLOCATE (shells(nshell_total))
442 atomic_kind => particle_set(iatom)%atomic_kind
444 gto_basis => basis_set_list(ikind)%gto_basis_set
445 cpassert(
ASSOCIATED(gto_basis))
447 shell_origin(1) = real(particle_set(iatom)%r(1), c_double)
448 shell_origin(2) = real(particle_set(iatom)%r(2), c_double)
449 shell_origin(3) = real(particle_set(iatom)%r(3), c_double)
451 nset = gto_basis%nset
452 cpassert(nset ==
SIZE(gto_basis%nshell))
454 nshell = gto_basis%nshell(iset)
455 npgf = gto_basis%npgf(iset)
457 DO ishell = 1, gto_basis%nshell(iset)
458 shell_index = shell_index + 1
459 lval = gto_basis%l(ishell, iset)
460 res%max_l = max(res%max_l, lval)
461 shells(shell_index)%l = int(lval, c_int32_t)
464 shells(shell_index)%pure = .true._c_bool
465 shells(shell_index)%nprim = int(npgf, c_int32_t)
466 shells(shell_index)%origin = shell_origin
469 shells(shell_index)%exponents(iprim) = &
470 REAL(gto_basis%zet(iprim, iset), c_double)
471 shells(shell_index)%coefficients(iprim) = &
472 REAL(gto_basis%norm_cgf(gto_basis%first_cgf(ishell, iset))* &
473 gto_basis%gcc(iprim, ishell, iset), c_double)
479 res%basis = gauxc_basisset_new_from_shells( &
483 gauxc_return_if_error(status)
486 DEALLOCATE (basis_set_list)
489 mark_used(particle_set)
490 mark_used(qs_kind_set)
493 cpabort(no_gauxc_message)
495 END FUNCTION gauxc_create_basisset
512 FUNCTION gauxc_create_grid( &
520 device_runtime_fill_fraction, &
523 force_new_runtime)
RESULT(res)
525 TYPE(cp_gauxc_molecule_type),
INTENT(IN) :: molecule
526 TYPE(cp_gauxc_basisset_type),
INTENT(in) :: basis
527 CHARACTER(len=*) :: grid_type, lb_exec_space, &
528 pruning_scheme, radial_quadrature
529 INTEGER :: batch_size
530 REAL(c_double),
INTENT(IN) :: device_runtime_fill_fraction
531 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
532 INTEGER,
INTENT(IN),
OPTIONAL :: mpi_comm
533 LOGICAL,
INTENT(IN),
OPTIONAL :: force_new_runtime
534 TYPE(cp_gauxc_grid_type) :: res
537 INTEGER(c_int) :: grid_type_local, int_exec_space_local, &
538 lb_exec_space_local, &
539 pruning_scheme_local, radial_quad_local
540 LOGICAL :: force_new_runtime_local, use_device_runtime
542 grid_type_local = read_atomic_grid_size(grid_type)
543 radial_quad_local = read_radial_quad(radial_quadrature)
544 pruning_scheme_local = read_pruning_scheme(pruning_scheme)
545 lb_exec_space_local = read_execution_space(lb_exec_space)
546 int_exec_space_local = read_execution_space(
"host")
547 use_device_runtime = (lb_exec_space_local == gauxc_executionspace%device)
548 force_new_runtime_local = .false.
549 IF (
PRESENT(force_new_runtime)) force_new_runtime_local = force_new_runtime
550 res%owns_rt = .false.
552 IF (use_device_runtime)
THEN
553#ifdef GAUXC_HAS_DEVICE
554#if defined(GAUXC_HAS_MPI) && defined(__parallel)
555 IF (
PRESENT(mpi_comm))
THEN
556 res%rt = gauxc_device_runtime_environment_new( &
557 status%status, mpi_comm, device_runtime_fill_fraction)
559 res%rt = gauxc_device_runtime_environment_new( &
560 status%status, device_runtime_fill_fraction)
564 res%rt = gauxc_device_runtime_environment_new( &
565 status%status, device_runtime_fill_fraction)
567 gauxc_return_if_error(status)
570 mark_used(device_runtime_fill_fraction)
571 cpabort(
"GauXC was built without device runtime support")
574#if defined(GAUXC_HAS_MPI) && defined(__parallel)
575 IF (
PRESENT(mpi_comm))
THEN
578 IF (force_new_runtime_local .OR. .NOT. rt_has_mpi_comm .OR. &
579 mpi_comm /= rt_mpi_comm)
THEN
580 res%rt = gauxc_runtime_environment_new(status%status, mpi_comm)
581 gauxc_return_if_error(status)
587 mark_used(force_new_runtime)
591 res%grid = gauxc_molgrid_new_default( &
594 pruning_scheme_local, &
595 int(batch_size, c_int64_t), &
598 gauxc_return_if_error(status)
600 res%lbf = gauxc_load_balancer_factory_new( &
603 gauxc_return_if_error(status)
605 IF (res%owns_rt)
THEN
606 res%lb = gauxc_load_balancer_factory_get_instance( &
614 res%lb = gauxc_load_balancer_factory_get_instance( &
622 gauxc_return_if_error(status)
624 res%mwf = gauxc_molecular_weights_factory_new( &
626 int_exec_space_local)
627 gauxc_return_if_error(status)
629 res%mw = gauxc_get_instance( &
632 gauxc_return_if_error(status)
634 CALL gauxc_molecular_weights_modify_weights( &
638 gauxc_return_if_error(status)
642 mark_used(batch_size)
643 mark_used(device_runtime_fill_fraction)
645 mark_used(lb_exec_space)
647 mark_used(force_new_runtime)
649 mark_used(pruning_scheme)
650 mark_used(radial_quadrature)
653 cpabort(no_gauxc_message)
655 END FUNCTION gauxc_create_grid
667 FUNCTION gauxc_create_integrator( &
668 xc_functional_name, &
675 CHARACTER(len=*),
INTENT(IN) :: xc_functional_name, int_exec_space, &
677 TYPE(cp_gauxc_grid_type),
INTENT(IN) :: grid
678 INTEGER,
INTENT(IN) :: nspins
679 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
680 TYPE(cp_gauxc_integrator_type) :: res
683 INTEGER(c_int) :: int_exec_space_local
684 LOGICAL(c_bool) :: polarized
686 polarized = (nspins == 2)
687 res%func = gauxc_functional_from_string( &
689 xc_functional_name, &
691 gauxc_return_if_error(status)
693 int_exec_space_local = read_execution_space(int_exec_space)
694 res%integrator = gauxc_integrator_new( &
698 int_exec_space_local, &
699 local_work_kernel_name=trim(lwd_kernel))
700 gauxc_return_if_error(status)
704 mark_used(int_exec_space)
705 mark_used(lwd_kernel)
709 mark_used(xc_functional_name)
710 cpabort(no_gauxc_message)
712 END FUNCTION gauxc_create_integrator
724 FUNCTION gauxc_compute_xc( &
732 TYPE(cp_gauxc_integrator_type),
INTENT(IN) :: integrator
734 REAL(c_double),
DIMENSION(:, :) :: density_scalar
735 REAL(c_double),
DIMENSION(:, :),
INTENT(IN), &
736 OPTIONAL :: density_zeta
737 INTEGER,
INTENT(IN) :: nspins
738 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
739 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: model
740 TYPE(cp_gauxc_xc_type) :: res
743 CHARACTER(len=default_path_length) :: model_key
744 LOGICAL :: use_gauxc_model
745#ifdef GAUXC_HAS_ONEDFT
746 REAL(c_double),
ALLOCATABLE,
DIMENSION(:, :) :: density_zeta_zero
747#if defined (__HAS_IEEE_EXCEPTIONS)
748 LOGICAL,
DIMENSION(5) :: ieee_halt
750 INTEGER :: omp_max_threads_restore
753 use_gauxc_model = .false.
754 IF (
PRESENT(model))
THEN
755 model_key = adjustl(model)
757 use_gauxc_model = (trim(model_key) /=
"" .AND. trim(model_key) /=
"NONE")
760 IF (.NOT.
ALLOCATED(res%vxc_scalar))
THEN
761 ALLOCATE (res%vxc_scalar, mold=density_scalar)
763 cpassert(all(shape(res%vxc_scalar) == shape(density_scalar)))
765 res%vxc_scalar = 0._dp
767 IF (use_gauxc_model)
THEN
768#ifndef GAUXC_HAS_ONEDFT
769 cpabort(
"GauXC lacks Skala support")
773 omp_max_threads_restore = omp_get_max_threads()
774#if defined (__HAS_IEEE_EXCEPTIONS)
775 CALL ieee_get_halting_mode(ieee_all, ieee_halt)
776 CALL ieee_set_halting_mode(ieee_all, .false.)
778 IF (.NOT.
ALLOCATED(res%vxc_zeta))
THEN
779 ALLOCATE (res%vxc_zeta, mold=density_scalar)
781 cpassert(all(shape(res%vxc_zeta) == shape(density_scalar)))
785 IF (nspins == 1)
THEN
786 ALLOCATE (density_zeta_zero, mold=density_scalar)
787 density_zeta_zero = 0._dp
788 CALL gauxc_integrator_eval_exc_vxc_onedft_uks( &
797 DEALLOCATE (density_zeta_zero)
799 cpassert(
PRESENT(density_zeta))
800 CALL gauxc_integrator_eval_exc_vxc_onedft_uks( &
810#if defined (__HAS_IEEE_EXCEPTIONS)
811 CALL ieee_set_halting_mode(ieee_all, ieee_halt)
813 CALL omp_set_num_threads(omp_max_threads_restore)
814 gauxc_return_if_error(status)
819 IF (nspins == 1)
THEN
820 CALL gauxc_integrator_eval_exc_vxc_rks( &
827 cpassert(
PRESENT(density_zeta))
829 IF (.NOT.
ALLOCATED(res%vxc_zeta))
THEN
830 ALLOCATE (res%vxc_zeta, mold=density_zeta)
832 cpassert(all(shape(res%vxc_zeta) == shape(density_scalar)))
836 CALL gauxc_integrator_eval_exc_vxc_uks( &
845 gauxc_return_if_error(status)
849 mark_used(density_scalar)
850 mark_used(density_zeta)
854 cpabort(no_gauxc_message)
856 END FUNCTION gauxc_compute_xc
869 FUNCTION gauxc_compute_xc_gradient( &
878 TYPE(cp_gauxc_integrator_type),
INTENT(IN) :: integrator
879 REAL(c_double),
DIMENSION(:, :),
INTENT(IN) :: density_scalar
880 REAL(c_double),
DIMENSION(:, :),
INTENT(IN), &
881 OPTIONAL :: density_zeta
882 INTEGER,
INTENT(IN) :: nspins, natom
883 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
884 CHARACTER(len=*),
INTENT(IN),
OPTIONAL :: model
885 TYPE(cp_gauxc_xc_gradient_type) :: res
888 CHARACTER(len=default_path_length) :: model_key
889 LOGICAL :: use_gauxc_model
890#ifdef GAUXC_HAS_ONEDFT
891 REAL(c_double),
ALLOCATABLE,
DIMENSION(:, :) :: density_zeta_zero
892#if defined (__HAS_IEEE_EXCEPTIONS)
893 LOGICAL,
DIMENSION(5) :: ieee_halt
895 INTEGER :: omp_max_threads_restore
898 ALLOCATE (res%exc_grad(3*natom))
901 use_gauxc_model = .false.
902 IF (
PRESENT(model))
THEN
903 model_key = adjustl(model)
905 use_gauxc_model = (trim(model_key) /=
"" .AND. trim(model_key) /=
"NONE")
908 IF (use_gauxc_model)
THEN
909#ifndef GAUXC_HAS_ONEDFT
910 cpabort(
"GauXC lacks Skala support")
914 omp_max_threads_restore = omp_get_max_threads()
915#if defined (__HAS_IEEE_EXCEPTIONS)
916 CALL ieee_get_halting_mode(ieee_all, ieee_halt)
917 CALL ieee_set_halting_mode(ieee_all, .false.)
919 IF (nspins == 1)
THEN
920 ALLOCATE (density_zeta_zero, mold=density_scalar)
921 density_zeta_zero = 0._dp
922 CALL gauxc_integrator_eval_exc_grad_onedft_uks( &
929 DEALLOCATE (density_zeta_zero)
931 cpassert(
PRESENT(density_zeta))
932 CALL gauxc_integrator_eval_exc_grad_onedft_uks( &
940#if defined (__HAS_IEEE_EXCEPTIONS)
941 CALL ieee_set_halting_mode(ieee_all, ieee_halt)
943 CALL omp_set_num_threads(omp_max_threads_restore)
944 gauxc_return_if_error(status)
949 IF (nspins == 1)
THEN
950 CALL gauxc_integrator_eval_exc_grad_rks( &
956 cpassert(
PRESENT(density_zeta))
957 CALL gauxc_integrator_eval_exc_grad_uks( &
964 gauxc_return_if_error(status)
967 mark_used(density_scalar)
968 mark_used(density_zeta)
975 cpabort(no_gauxc_message)
977 END FUNCTION gauxc_compute_xc_gradient
984 SUBROUTINE gauxc_destroy_molecule(molecule, status)
985 TYPE(cp_gauxc_molecule_type),
INTENT(INOUT) :: molecule
986 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
989 CALL gauxc_delete(status%status, molecule%molecule)
990 gauxc_return_if_error(status)
994 cpabort(no_gauxc_message)
996 END SUBROUTINE gauxc_destroy_molecule
1003 SUBROUTINE gauxc_destroy_basisset(basis, status)
1004 TYPE(cp_gauxc_basisset_type),
INTENT(INOUT) :: basis
1005 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
1008 CALL gauxc_delete(status%status, basis%basis)
1009 gauxc_return_if_error(status)
1013 cpabort(no_gauxc_message)
1015 END SUBROUTINE gauxc_destroy_basisset
1022 SUBROUTINE gauxc_destroy_grid(grid_result, status)
1023 TYPE(cp_gauxc_grid_type),
INTENT(INOUT) :: grid_result
1024 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
1027 CALL gauxc_delete(status%status, grid_result%mw)
1028 gauxc_return_if_error(status)
1029 CALL gauxc_delete(status%status, grid_result%mwf)
1030 gauxc_return_if_error(status)
1031 CALL gauxc_delete(status%status, grid_result%lb)
1032 gauxc_return_if_error(status)
1033 CALL gauxc_delete(status%status, grid_result%lbf)
1034 gauxc_return_if_error(status)
1035 CALL gauxc_delete(status%status, grid_result%grid)
1036 gauxc_return_if_error(status)
1037 IF (grid_result%owns_rt)
THEN
1038 CALL gauxc_runtime_environment_delete(status%status, grid_result%rt)
1039 gauxc_return_if_error(status)
1040 grid_result%owns_rt = .false.
1043 mark_used(grid_result)
1045 cpabort(no_gauxc_message)
1047 END SUBROUTINE gauxc_destroy_grid
1054 SUBROUTINE gauxc_destroy_integrator(integrator_result, status)
1055 TYPE(cp_gauxc_integrator_type),
INTENT(INOUT) :: integrator_result
1056 TYPE(cp_gauxc_status_type),
INTENT(OUT) :: status
1059 CALL gauxc_delete(status%status, integrator_result%integrator)
1060 gauxc_return_if_error(status)
1061 CALL gauxc_delete(status%status, integrator_result%func)
1062 gauxc_return_if_error(status)
1064 mark_used(integrator_result)
1066 cpabort(no_gauxc_message)
1068 END SUBROUTINE gauxc_destroy_integrator
1074 SUBROUTINE gauxc_check_status(status)
1075 TYPE(cp_gauxc_status_type),
INTENT(IN) :: status
1078 IF (status%status%code /= 0)
THEN
1080 cpabort(
"GauXC returned with non-zero status code")
1085 END SUBROUTINE gauxc_check_status
1098 PURE FUNCTION read_execution_space(spec)
RESULT(val)
1099 CHARACTER(len=*),
INTENT(IN) :: spec
1100 INTEGER(c_int) :: val
1102 CHARACTER(len=LEN(spec)) :: spec_upper
1107 SELECT CASE (spec_upper)
1109 val = gauxc_executionspace%host
1111 val = gauxc_executionspace%device
1113 val = gauxc_executionspace%host
1115 END FUNCTION read_execution_space
1122 PURE FUNCTION read_atomic_grid_size(spec)
RESULT(val)
1123 CHARACTER(len=*),
INTENT(IN) :: spec
1124 INTEGER(c_int) :: val
1126 CHARACTER(len=LEN(spec)) :: spec_upper
1131 SELECT CASE (spec_upper)
1133 val = gauxc_atomicgridsizedefault%finegrid
1135 val = gauxc_atomicgridsizedefault%ultrafinegrid
1137 val = gauxc_atomicgridsizedefault%superfinegrid
1139 val = gauxc_atomicgridsizedefault%gm3
1141 val = gauxc_atomicgridsizedefault%gm5
1143 val = gauxc_atomicgridsizedefault%finegrid
1145 END FUNCTION read_atomic_grid_size
1152 PURE FUNCTION read_radial_quad(spec)
RESULT(val)
1153 CHARACTER(len=*),
INTENT(IN) :: spec
1154 INTEGER(c_int) :: val
1156 CHARACTER(len=LEN(spec)) :: spec_upper
1161 SELECT CASE (spec_upper)
1163 val = gauxc_radialquad%becke
1164 CASE (
"MURAKNOWLES")
1165 val = gauxc_radialquad%mura_knowles
1166 CASE (
"TREUTLERAHLRICHS")
1167 val = gauxc_radialquad%treutler_ahlrichs
1168 CASE (
"MURRAYHANDYLAMING")
1169 val = gauxc_radialquad%murray_handy_laming
1171 val = gauxc_radialquad%mura_knowles
1173 END FUNCTION read_radial_quad
1180 PURE FUNCTION read_pruning_scheme(spec)
RESULT(val)
1181 CHARACTER(len=*),
INTENT(IN) :: spec
1182 INTEGER(c_int) :: val
1184 CHARACTER(len=LEN(spec)) :: spec_upper
1189 SELECT CASE (spec_upper)
1191 val = gauxc_pruningscheme%unpruned
1193 val = gauxc_pruningscheme%robust
1195 val = gauxc_pruningscheme%treutler
1197 val = gauxc_pruningscheme%robust
1199 END FUNCTION read_pruning_scheme
1211 SUBROUTINE gauxc_write_molecule_hdf5(molecule, output_path, filename, dataset, status)
1212 TYPE(cp_gauxc_molecule_type),
INTENT(IN) :: molecule
1213 CHARACTER(len=*),
INTENT(IN) :: output_path, filename, dataset
1214 TYPE(cp_gauxc_status_type),
INTENT(INOUT) :: status
1216#if defined(__GAUXC) && defined(GAUXC_HAS_HDF5)
1217 CHARACTER(len=default_path_length) :: full_path
1219 full_path = trim(output_path)//
"/"//trim(filename)
1220 CALL gauxc_write_hdf5_record(status%status, molecule%molecule, full_path, dataset)
1223 mark_used(output_path)
1227 cpabort(
"GauXC HDF5 output requires GauXC to be built with HDF5 support.")
1229 END SUBROUTINE gauxc_write_molecule_hdf5
1239 SUBROUTINE gauxc_write_basisset_hdf5(basis, output_path, filename, dataset, status)
1240 TYPE(cp_gauxc_basisset_type),
INTENT(IN) :: basis
1241 CHARACTER(len=*),
INTENT(IN) :: output_path, filename, dataset
1242 TYPE(cp_gauxc_status_type),
INTENT(INOUT) :: status
1244#if defined(__GAUXC) && defined(GAUXC_HAS_HDF5)
1245 CHARACTER(len=default_path_length) :: full_path
1247 full_path = trim(output_path)//
"/"//trim(filename)
1248 CALL gauxc_write_hdf5_record(status%status, basis%basis, full_path, dataset)
1251 mark_used(output_path)
1255 cpabort(
"GauXC HDF5 output requires GauXC to be built with HDF5 support.")
1257 END SUBROUTINE gauxc_write_basisset_hdf5
1259END MODULE xc_gauxc_interface
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
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.
subroutine, public write_gto_basis_set(gto_basis_set, output_unit, header)
Write a Gaussian-type orbital (GTO) basis set data set to the output unit.
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...
Provides integrator routines (velocity verlet) for all the ensemble types.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Define the data structure for the particle information.
Periodic Table related data definitions.
subroutine, public get_ptable_info(symbol, number, amass, ielement, covalent_radius, metallic_radius, vdw_radius, found)
Pass information about the kind given the element symbol.
Definition of physical constants:
real(kind=dp), parameter, public bohr
Some utility functions for the calculation of integrals.
subroutine, public basis_set_list_setup(basis_set_list, basis_type, qs_kind_set)
Set up an easy accessible list of the basis sets for all kinds.
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.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Provides all information about an atomic kind.
Provides all information about a quickstep kind.
subroutine print_gauxc_status_message(status)
...