24 use,
intrinsic :: iso_fortran_env
41 logical :: initialized
42 logical :: kleinman_bylander
44 logical :: has_density
45 integer :: atomic_number
47 real(real64) :: valence_charge
52 integer :: nwavefunctions
53 real(real64),
allocatable :: grid(:)
54 real(real64),
allocatable :: weights(:)
55 real(real64),
allocatable :: potential(:, :)
56 real(real64),
allocatable :: wavefunction(:, :)
57 real(real64),
allocatable :: projector(:, :, :)
58 real(real64),
allocatable :: dij(:, :, :)
59 real(real64),
allocatable :: qij(:, :, :)
60 logical :: has_qij_integrals
61 logical :: has_radial_augmentation
62 logical :: radial_augmentation_has_angular_channels
63 integer :: radial_augmentation_lmax
64 real(real64),
allocatable :: radial_augmentation(:, :, :, :)
65 real(real64),
allocatable :: nlcc_density(:)
66 real(real64),
allocatable :: density(:)
67 integer,
allocatable :: wf_n(:)
68 integer,
allocatable :: wf_l(:)
69 real(real64),
allocatable :: wf_occ(:)
70 type(pseudo_t) :: pseudo
71 integer,
allocatable :: kb_radius(:,:)
77 subroutine ps_xml_init(this, namespace, filename, fmt, ierr)
78 type(ps_xml_t),
intent(inout) :: this
79 type(namespace_t),
intent(in) :: namespace
80 character(len=*),
intent(in) :: filename
81 integer,
intent(in) :: fmt
82 integer,
intent(out) :: ierr
84 integer :: ll, ii, jj, ic, jc, ip, nproj
85 type(pseudo_t) :: pseudo
89 this%initialized = .false.
94 call messages_write(
"Pseudopotential file '" // trim(filename) //
"' not found")
99 call messages_write(
"Cannot determine the format for pseudopotential file '" // trim(filename) //
"'")
104 call messages_write(
"Ultrasoft pseudopotential file '" // trim(filename) //
"' not supported")
109 call messages_write(
"PAW pseudopotential file '" // trim(filename) //
"' not supported")
114 call messages_write(
"Pseudopotential file '" // trim(filename) //
"' not supported")
119 call messages_write(
"Pseudopotential file '" // trim(filename) //
"' not supported")
123 this%initialized = .
true.
134 call messages_write(
"Ultrasoft pseudopotential file '" // trim(filename) //
"' does not contain PP_Q or PP_QIJ")
144 safe_allocate(this%grid(1:this%grid_size))
145 safe_allocate(this%weights(1:this%grid_size))
150 if (.not. this%kleinman_bylander)
then
152 safe_allocate(this%potential(1:this%grid_size, 0:this%lmax))
153 safe_allocate(this%wavefunction(1:this%grid_size, 0:this%lmax))
157 call messages_write(
"The pseudopotential file '"//trim(filename)//
"' does not contain")
169 safe_allocate(this%potential(1:this%grid_size, this%llocal:this%llocal))
173 safe_allocate(this%projector(1:this%grid_size, 0:this%lmax, 1:this%nchannels))
177 safe_allocate(this%kb_radius(0:this%lmax, 1:this%nchannels))
178 this%kb_radius = this%grid_size
181 if (this%llocal == ll) cycle
185 do ip = this%grid_size, 1, -1
186 if (abs(this%projector(ip, ll, ic)) >
m_epsilon)
then
187 this%kb_radius(ll, ic) = ip
194 if (this%has_radial_augmentation)
then
195 safe_allocate(this%radial_augmentation(1:this%grid_size, 1:nproj, 1:nproj, 0:this%radial_augmentation_lmax))
199 do ll = 0, this%radial_augmentation_lmax
207 safe_allocate(this%dij(0:this%lmax, 1:this%nchannels, 1:this%nchannels))
208 safe_allocate(this%qij(0:this%lmax, 1:this%nchannels, 1:this%nchannels))
210 this%dij = 0.0_real64
211 this%qij = 0.0_real64
213 do ic = 1, this%nchannels
214 do jc = 1, this%nchannels
215 this%dij(ll, ic, jc) =
pseudo_dij(pseudo, ll, ic, jc)
216 if (this%has_qij_integrals) this%qij(ll, ic, jc) =
pseudo_qij(pseudo, ll, ic, jc)
223 safe_allocate(this%wavefunction(1:this%grid_size, 1:this%nwavefunctions))
224 safe_allocate(this%wf_n(1:this%nwavefunctions))
225 safe_allocate(this%wf_l(1:this%nwavefunctions))
226 safe_allocate(this%wf_occ(1:this%nwavefunctions))
228 do ii = 1, this%nwavefunctions
229 call pseudo_wavefunction(pseudo, ii, this%wf_n(ii), this%wf_l(ii), this%wf_occ(ii), this%wavefunction(1, ii))
236 if (this%has_density)
then
237 safe_allocate(this%density(1:this%grid_size))
243 safe_allocate(this%nlcc_density(1:this%grid_size))
261 real(real64) :: nrm, rr
268 do ip = 1, this%grid_size
270 nrm = nrm + this%wavefunction(ip, ll)**2*this%weights(ip)*rr**2
274 nrm = abs(nrm -
m_one)
275 if (nrm > 1.0e-5_real64)
then
276 write(
message(1),
'(a,i2,a)')
"Eigenstate for l = ", ll,
' is not normalized'
277 write(
message(2),
'(a, f12.6,a)')
'(abs(1 - norm) = ', nrm,
')'
288 type(
ps_xml_t),
intent(inout) :: this
294 safe_deallocate_a(this%grid)
295 safe_deallocate_a(this%weights)
296 safe_deallocate_a(this%potential)
297 safe_deallocate_a(this%wavefunction)
298 safe_deallocate_a(this%projector)
299 safe_deallocate_a(this%dij)
300 safe_deallocate_a(this%qij)
301 safe_deallocate_a(this%radial_augmentation)
302 safe_deallocate_a(this%nlcc_density)
303 safe_deallocate_a(this%density)
304 safe_deallocate_a(this%wf_n)
305 safe_deallocate_a(this%wf_l)
306 safe_deallocate_a(this%wf_occ)
307 safe_deallocate_a(this%kb_radius)
309 this%initialized = .false.
double sqrt(double __x) __attribute__((__nothrow__
real(real64), parameter, public m_zero
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_one
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_new_line()
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
subroutine, public ps_xml_end(this)
subroutine ps_xml_check_normalization(this, namespace)
checks normalization of the pseudo wavefunctions
subroutine, public ps_xml_init(this, namespace, filename, fmt, ierr)
integer, parameter, public pseudo_type_kleinman_bylander
logical function, public pseudo_has_radial_function(pseudo, l)
logical function, public pseudo_has_density(pseudo)
logical function, public pseudo_has_radial_augmentation(pseudo)
logical function, public pseudo_has_nlcc(pseudo)
integer, parameter, public pseudo_status_unsupported_type
integer, parameter, public pseudo_status_file_not_found
logical function, public pseudo_has_qij_integrals(pseudo)
integer, parameter, public pseudo_type_ultrasoft
integer, parameter, public pseudo_status_unsupported_type_ultrasoft
logical function, public pseudo_radial_augmentation_has_angular_channels(pseudo)
integer, parameter, public pseudo_status_unknown_format
integer, parameter, public pseudo_status_unsupported_type_paw
integer, parameter, public pseudo_status_format_not_supported
character(kind=c_char, len=1) function, dimension(:), allocatable, public string_f_to_c(f_string)
convert a Fortran string to a C string