(git:08825b9)
Loading...
Searching...
No Matches
upf_types.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Owned UPF dataset and radial conventions shared by ATOM and Quickstep.
10!> Dataset availability does not select an orbital representation or calculation method.
11! **************************************************************************************************
13 USE kinds, ONLY: default_path_length,&
15 dp
16#include "../base/base_uses.f90"
17
18 IMPLICIT NONE
19 PRIVATE
20
21 ! use same value as in atom_types!
22 INTEGER, PARAMETER :: lmat = 3
23
25 ! Original r*phi(r), one AE/PS pair per beta projector; not the atomic guesses.
26 REAL(dp), ALLOCATABLE :: ae_wfc(:, :), ps_wfc(:, :)
27 INTEGER, ALLOCATABLE :: angular_momenta(:)
29
31 CHARACTER(LEN=2) :: symbol = ""
32 CHARACTER(LEN=default_string_length) :: pname = ""
33 INTEGER, DIMENSION(0:lmat) :: econf = 0
34 REAL(dp) :: zion = 0.0_dp
35 CHARACTER(LEN=default_string_length) :: version = ""
36 CHARACTER(LEN=default_path_length) :: filename = ""
37 ! <INFO>
38 INTEGER :: maxinfo = 100
39 CHARACTER(LEN=default_string_length), DIMENSION(100) &
40 :: info = ""
41 ! <HEADER>
42 CHARACTER(LEN=default_string_length) :: generated = ""
43 CHARACTER(LEN=default_string_length) :: author = ""
44 CHARACTER(LEN=default_string_length) :: date = ""
45 CHARACTER(LEN=default_string_length) :: comment = ""
46 CHARACTER(LEN=4) :: pseudo_type = ""
47 CHARACTER(LEN=15) :: relativistic = ""
48 CHARACTER(LEN=default_string_length) :: functional = ""
49 LOGICAL :: is_ultrasoft = .false.
50 LOGICAL :: is_paw = .false.
51 LOGICAL :: is_coulomb = .false.
52 LOGICAL :: has_so = .false.
53 LOGICAL :: has_wfc = .false.
54 LOGICAL :: has_gipaw = .false.
55 LOGICAL :: paw_as_gipaw = .false.
56 LOGICAL :: core_correction = .false.
57 REAL(dp) :: total_psenergy = 0.0_dp
58 REAL(dp) :: wfc_cutoff = 0.0_dp
59 REAL(dp) :: rho_cutoff = 0.0_dp
60 INTEGER :: l_max = -100
61 INTEGER :: l_max_rho = -1
62 INTEGER :: l_local = -1
63 INTEGER :: mesh_size = -1
64 INTEGER :: number_of_wfc = -1
65 INTEGER :: number_of_proj = -1
66 ! <MESH>
67 REAL(dp) :: dx = 0.0_dp
68 REAL(dp) :: xmin = 0.0_dp
69 REAL(dp) :: rmax = 0.0_dp
70 REAL(dp) :: zmesh = 0.0_dp
71 REAL(dp), DIMENSION(:), ALLOCATABLE :: r, rab
72 ! <NLCC>
73 REAL(dp), DIMENSION(:), ALLOCATABLE :: rho_nlcc
74 ! <LOCAL>
75 REAL(dp), DIMENSION(:), ALLOCATABLE :: vlocal
76 ! <NONLOCAL>: keep the tabulated projector amplitude; D includes Ry -> Hartree.
77 ! beta stores beta(r), with the radial prefactor in PP_BETA removed.
78 REAL(dp), DIMENSION(:, :), ALLOCATABLE :: dion
79 REAL(dp), DIMENSION(:, :), ALLOCATABLE :: beta
80 INTEGER, DIMENSION(:), ALLOCATABLE :: lbeta
81 ! <AUGMENTATION>: PP_Q and r**2*Q_ij^L(r), in the original beta convention.
82 ! The pair index is j*(j-1)/2+i for i<=j; the last dimension starts at L=0.
83 REAL(dp), DIMENSION(:, :), ALLOCATABLE :: qij
84 REAL(dp), DIMENSION(:, :, :), ALLOCATABLE :: qijl
85 TYPE(upf_partial_waves_type), ALLOCATABLE :: partial_waves
86 ! <SEMILOCAL>
87 REAL(dp), DIMENSION(:, :), ALLOCATABLE :: vsemi
88 END TYPE atom_upfpot_type
89
92CONTAINS
93
94! **************************************************************************************************
95!> \brief Composite Simpson weights for dr on the supplied UPF mesh index.
96!> \param pot Original radial coordinates and dr/d(index).
97!> \return Radial weights, with a last trapezoidal interval for an even mesh size.
98! **************************************************************************************************
99 FUNCTION upf_radial_weights(pot) RESULT(weights)
100 TYPE(atom_upfpot_type), INTENT(IN) :: pot
101 REAL(dp) :: weights(size(pot%r))
102
103 INTEGER :: n, ns
104
105 n = SIZE(pot%r)
106 cpassert(n >= 3 .AND. SIZE(pot%rab) == n)
107 cpassert(all(pot%r(2:) > pot%r(:n - 1)) .AND. all(pot%rab > 0.0_dp))
108 ns = n - 1 + modulo(n, 2)
109 weights = 0.0_dp
110 weights(1:ns:2) = 2.0_dp/3.0_dp
111 weights(2:ns - 1:2) = 4.0_dp/3.0_dp
112 weights(1) = 1.0_dp/3.0_dp
113 weights(ns) = 1.0_dp/3.0_dp
114 IF (ns < n) weights(n - 1:n) = weights(n - 1:n) + 0.5_dp
115 weights(:) = weights*pot%rab
116 END FUNCTION upf_radial_weights
117
118! **************************************************************************************************
119!> \brief Check for a complete projector-indexed pair of original AE and PS waves.
120!> \param pot Original UPF dataset; atomic guess waves do not satisfy this query.
121!> \return Whether every beta projector has a compatible full-wave pair.
122! **************************************************************************************************
123 PURE FUNCTION upf_has_complete_partial_waves(pot) RESULT(complete)
124 TYPE(atom_upfpot_type), INTENT(IN) :: pot
125 LOGICAL :: complete
126
127 INTEGER :: n, nb
128
129 complete = .false.
130 IF (.NOT. ALLOCATED(pot%partial_waves)) RETURN
131 IF (.NOT. ALLOCATED(pot%lbeta)) RETURN
132 IF (.NOT. ALLOCATED(pot%r) .OR. .NOT. ALLOCATED(pot%rab)) RETURN
133 n = pot%mesh_size
134 nb = pot%number_of_proj
135 IF (n < 3 .OR. nb < 1 .OR. SIZE(pot%lbeta) /= nb) RETURN
136 IF (SIZE(pot%r) /= n .OR. SIZE(pot%rab) /= n) RETURN
137 associate(waves => pot%partial_waves)
138 IF (.NOT. ALLOCATED(waves%ae_wfc) .OR. .NOT. ALLOCATED(waves%ps_wfc)) RETURN
139 IF (.NOT. ALLOCATED(waves%angular_momenta)) RETURN
140 IF (any(shape(waves%ae_wfc) /= [n, nb])) RETURN
141 IF (any(shape(waves%ps_wfc) /= [n, nb])) RETURN
142 IF (SIZE(waves%angular_momenta) /= nb) RETURN
143 complete = all(waves%angular_momenta == pot%lbeta)
144 END associate
146
147! **************************************************************************************************
148!> \brief Release every owned field and reset metadata before reusing a dataset.
149!> \param pot Owned UPF dataset.
150! **************************************************************************************************
151 PURE SUBROUTINE upf_release(pot)
152 TYPE(atom_upfpot_type), INTENT(INOUT) :: pot
153
154 pot = atom_upfpot_type()
155 END SUBROUTINE upf_release
156END MODULE upf_types
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Owned UPF dataset and radial conventions shared by ATOM and Quickstep. Dataset availability does not ...
Definition upf_types.F:12
real(dp) function, dimension(size(pot%r)), public upf_radial_weights(pot)
Composite Simpson weights for dr on the supplied UPF mesh index.
Definition upf_types.F:100
pure logical function, public upf_has_complete_partial_waves(pot)
Check for a complete projector-indexed pair of original AE and PS waves.
Definition upf_types.F:124
pure subroutine, public upf_release(pot)
Release every owned field and reset metadata before reusing a dataset.
Definition upf_types.F:152