25#include "./base/base_uses.f90"
30 INTEGER,
PARAMETER ::
lmat = 3
33 CHARACTER(LEN=2) :: symbol =
""
34 CHARACTER(LEN=default_string_length) :: pname =
""
35 INTEGER,
DIMENSION(0:lmat) :: econf = 0
36 REAL(
dp) :: zion = 0.0_dp
37 CHARACTER(LEN=default_string_length) :: version =
""
38 CHARACTER(LEN=default_string_length) :: filename =
""
40 INTEGER :: maxinfo = 100
41 CHARACTER(LEN=default_string_length),
DIMENSION(100) &
44 CHARACTER(LEN=default_string_length) :: generated =
""
45 CHARACTER(LEN=default_string_length) :: author =
""
46 CHARACTER(LEN=default_string_length) :: date =
""
47 CHARACTER(LEN=default_string_length) :: comment =
""
48 CHARACTER(LEN=4) :: pseudo_type =
""
49 CHARACTER(LEN=15) :: relativistic =
""
50 CHARACTER(LEN=default_string_length) :: functional =
""
51 LOGICAL :: is_ultrasoft = .false.
52 LOGICAL :: is_paw = .false.
53 LOGICAL :: is_coulomb = .false.
54 LOGICAL :: has_so = .false.
55 LOGICAL :: has_wfc = .false.
56 LOGICAL :: has_gipaw = .false.
57 LOGICAL :: paw_as_gipaw = .false.
58 LOGICAL :: core_correction = .false.
59 REAL(
dp) :: total_psenergy = 0.0_dp
60 REAL(
dp) :: wfc_cutoff = 0.0_dp
61 REAL(
dp) :: rho_cutoff = 0.0_dp
62 INTEGER :: l_max = -100
63 INTEGER :: l_max_rho = -1
64 INTEGER :: l_local = -1
65 INTEGER :: mesh_size = -1
66 INTEGER :: number_of_wfc = -1
67 INTEGER :: number_of_proj = -1
69 REAL(
dp) :: dx = 0.0_dp
70 REAL(
dp) :: xmin = 0.0_dp
71 REAL(
dp) :: rmax = 0.0_dp
72 REAL(
dp) :: zmesh = 0.0_dp
73 REAL(
dp),
DIMENSION(:),
ALLOCATABLE :: r, rab
75 REAL(
dp),
DIMENSION(:),
ALLOCATABLE :: rho_nlcc
77 REAL(
dp),
DIMENSION(:),
ALLOCATABLE :: vlocal
79 REAL(
dp),
DIMENSION(:, :),
ALLOCATABLE :: dion
80 REAL(
dp),
DIMENSION(:, :),
ALLOCATABLE :: beta
81 INTEGER,
DIMENSION(:),
ALLOCATABLE :: lbeta
83 REAL(
dp),
DIMENSION(:, :),
ALLOCATABLE :: vsemi
89 CHARACTER(len=*),
PARAMETER,
PRIVATE :: modulen =
'atom_upf'
104 CHARACTER(len=*),
INTENT(IN) :: upf_filename
105 LOGICAL,
INTENT(IN),
OPTIONAL :: read_header
107 CHARACTER(LEN=2) :: symbol
108 INTEGER :: l, ncore, nel
111 IF (
PRESENT(read_header))
THEN
112 readall = .NOT. read_header
118 pot%filename = adjustl(trim(upf_filename))
121 l = len_trim(pot%filename)
122 IF (pot%filename(l - 4:l) ==
'.json')
THEN
127 CALL atom_read_upf_v2(pot, upf_filename, readall)
130 IF (sum(pot%econf) == 0)
THEN
131 symbol = adjustl(trim(pot%symbol))
133 pot%econf(0:3) =
ptable(ncore)%e_conv(0:3)
134 nel = nint(ncore - pot%zion)
137 cpabort(
"Unknown Core State")
141 pot%econf(0:3) = pot%econf(0:3) -
ptable(2)%e_conv(0:3)
143 pot%econf(0:3) = pot%econf(0:3) -
ptable(10)%e_conv(0:3)
145 pot%econf(0:3) = pot%econf(0:3) -
ptable(18)%e_conv(0:3)
147 pot%econf(0:3) = pot%econf(0:3) -
ptable(18)%e_conv(0:3)
148 pot%econf(2) = pot%econf(2) - 10
150 pot%econf(0:3) = pot%econf(0:3) -
ptable(36)%e_conv(0:3)
152 pot%econf(0:3) = pot%econf(0:3) -
ptable(36)%e_conv(0:3)
153 pot%econf(2) = pot%econf(2) - 10
155 pot%econf(0:3) = pot%econf(0:3) -
ptable(54)%e_conv(0:3)
157 pot%econf(0:3) = pot%econf(0:3) -
ptable(36)%e_conv(0:3)
158 pot%econf(2) = pot%econf(2) - 10
159 pot%econf(3) = pot%econf(3) - 14
161 pot%econf(0:3) = pot%econf(0:3) -
ptable(54)%e_conv(0:3)
162 pot%econf(3) = pot%econf(3) - 14
164 pot%econf(0:3) = pot%econf(0:3) -
ptable(54)%e_conv(0:3)
165 pot%econf(2) = pot%econf(2) - 10
166 pot%econf(3) = pot%econf(3) - 14
169 cpassert(all(pot%econf >= 0))
173 IF (pot%pname ==
"")
THEN
174 pot%pname = adjustl(trim(pot%symbol))
185 SUBROUTINE atom_read_upf_v2(pot, upf_filename, readall)
188 CHARACTER(len=*),
INTENT(IN) :: upf_filename
189 LOGICAL,
INTENT(IN) :: readall
191 CHARACTER(LEN=default_string_length) :: nametag
203 IF (nametag(1:1) /=
"<") cycle
206 IF (nametag(2:4) ==
"UPF")
THEN
210 pot%version = trim(nametag)
211 cpassert(nametag(1:5) ==
"2.0.1")
213 cpassert(nametag(1:1) ==
">")
216 ELSE IF (ntag == 1)
THEN
218 IF (nametag(2:8) ==
"PP_INFO")
THEN
219 cpassert(nametag(9:9) ==
">")
220 CALL upf_info_section(parser, pot)
221 ELSEIF (nametag(2:10) ==
"PP_HEADER")
THEN
222 IF (.NOT. (nametag(11:11) ==
">"))
THEN
223 CALL upf_header_option(parser, pot)
225 ELSEIF (nametag(2:8) ==
"PP_MESH")
THEN
226 IF (.NOT. (nametag(9:9) ==
">"))
THEN
227 CALL upf_mesh_option(parser, pot)
229 CALL upf_mesh_section(parser, pot)
230 ELSEIF (nametag(2:8) ==
"PP_NLCC")
THEN
231 IF (nametag(9:9) ==
">")
THEN
232 CALL upf_nlcc_section(parser, pot, .false.)
234 CALL upf_nlcc_section(parser, pot, .true.)
236 ELSEIF (nametag(2:9) ==
"PP_LOCAL")
THEN
237 IF (nametag(10:10) ==
">")
THEN
238 CALL upf_local_section(parser, pot, .false.)
240 CALL upf_local_section(parser, pot, .true.)
242 ELSEIF (nametag(2:12) ==
"PP_NONLOCAL")
THEN
243 cpassert(nametag(13:13) ==
">")
244 CALL upf_nonlocal_section(parser, pot)
245 ELSEIF (nametag(2:13) ==
"PP_SEMILOCAL")
THEN
246 CALL upf_semilocal_section(parser, pot)
247 ELSEIF (nametag(2:9) ==
"PP_PSWFC")
THEN
249 ELSEIF (nametag(2:11) ==
"PP_RHOATOM")
THEN
251 ELSEIF (nametag(2:7) ==
"PP_PAW")
THEN
253 ELSEIF (nametag(2:6) ==
"/UPF>")
THEN
263 IF (
ALLOCATED(pot%beta))
THEN
264 DO ib = 1, pot%number_of_proj
265 IF (pot%r(1) == 0.0_dp)
THEN
266 pot%beta(2:, ib) = pot%beta(2:, ib)/pot%r(2:)
268 pot%beta(:, ib) = pot%beta(:, ib)/pot%r(:)
275 IF (pot%is_ultrasoft)
THEN
276 cpabort(
"UPF ultrasoft pseudopotential not implemented")
279 cpabort(
"UPF PAW potential not implemented")
283 END SUBROUTINE atom_read_upf_v2
290 SUBROUTINE upf_info_section(parser, pot)
294 CHARACTER(LEN=default_string_length) :: line, string
295 INTEGER :: icount, iline
301 cpassert(.NOT. at_end)
302 iline = parser%buffer%present_line_number
303 line = trim(parser%buffer%input_lines(iline))
305 IF (string(1:10) ==
"</PP_INFO>")
EXIT
307 IF (icount > pot%maxinfo) cycle
308 pot%info(icount) = line
312 END SUBROUTINE upf_info_section
319 SUBROUTINE upf_header_option(parser, pot)
323 CHARACTER(LEN=default_string_length) :: string
329 cpassert(.NOT. at_end)
332 IF (string ==
"/>")
EXIT
344 cpassert(2 <= len(pot%symbol))
347 CASE (
"RELATIVISTIC")
349 CASE (
"IS_ULTRASOFT")
361 CASE (
"PAW_AS_GIPAW")
363 CASE (
"CORE_CORRECTION")
369 CASE (
"TOTAL_PSENERGY")
383 CASE (
"NUMBER_OF_WFC")
385 CASE (
"NUMBER_OF_PROJ")
389 CALL cp_abort(__location__,
"Error while parsing UPF header: "// &
390 "Adjust format of delimiters ... only double quotes are admissible.")
394 END SUBROUTINE upf_header_option
401 SUBROUTINE upf_mesh_option(parser, pot)
405 CHARACTER(LEN=default_string_length) :: string
412 cpassert(.NOT. at_end)
415 IF (string ==
">")
EXIT
425 cpassert(pot%mesh_size == jj)
429 cpabort(
"Unknown UPF PP_MESH option <"//trim(string)//
"> found")
434 END SUBROUTINE upf_mesh_option
441 SUBROUTINE upf_mesh_section(parser, pot)
445 CHARACTER(LEN=default_string_length) :: line, string, string2
446 INTEGER :: icount, m, mc, ms
451 cpassert(.NOT. at_end)
458 IF (string(6:6) /=
">")
THEN
463 cpassert(.NOT. at_end)
466 IF (string2 ==
">")
EXIT
467 SELECT CASE (string2)
470 cpassert(line ==
"REAL")
477 cpabort(
"Unknown UPF PP_R option <"//trim(string2)//
"> found")
487 cpassert(.NOT. at_end)
492 IF (icount > ms)
EXIT
495 IF (string(6:6) /=
">")
THEN
500 cpassert(.NOT. at_end)
503 IF (string2 ==
">")
EXIT
504 SELECT CASE (string2)
507 cpassert(line ==
"REAL")
514 cpabort(
"Unknown UPF PP_RAB option <"//trim(string2)//
"> found")
518 ALLOCATE (pot%rab(m))
524 cpassert(.NOT. at_end)
529 IF (icount > ms)
EXIT
538 END SUBROUTINE upf_mesh_section
546 SUBROUTINE upf_nlcc_section(parser, pot, options)
549 LOGICAL,
INTENT(IN) :: options
551 CHARACTER(LEN=default_string_length) :: line, string
552 INTEGER :: icount, m, mc, ms
562 cpassert(.NOT. at_end)
565 IF (string ==
">")
EXIT
569 cpassert(line ==
"REAL")
576 cpabort(
"Unknown UPF PP_NLCC option <"//trim(string)//
"> found")
581 ALLOCATE (pot%rho_nlcc(m))
582 pot%rho_nlcc = 0.0_dp
587 cpassert(.NOT. at_end)
592 IF (icount > ms)
EXIT
596 cpassert(.NOT. at_end)
598 cpassert(string ==
"</PP_NLCC>")
600 END SUBROUTINE upf_nlcc_section
608 SUBROUTINE upf_local_section(parser, pot, options)
611 LOGICAL,
INTENT(IN) :: options
613 CHARACTER(LEN=default_string_length) :: line, string
614 INTEGER :: icount, m, mc, ms
624 cpassert(.NOT. at_end)
627 IF (string ==
">")
EXIT
631 cpassert(line ==
"REAL")
638 cpabort(
"Unknown UPF PP_LOCAL option <"//trim(string)//
"> found")
643 ALLOCATE (pot%vlocal(m))
649 cpassert(.NOT. at_end)
654 IF (icount > ms)
EXIT
658 pot%vlocal = 0.5_dp*pot%vlocal
661 cpassert(.NOT. at_end)
663 cpassert(string ==
"</PP_LOCAL>")
665 END SUBROUTINE upf_local_section
672 SUBROUTINE upf_nonlocal_section(parser, pot)
676 CHARACTER(LEN=default_string_length) :: line, string
677 INTEGER :: i1, i2, ibeta, icount, la, m, mc, ms, &
682 nbeta = pot%number_of_proj
683 ALLOCATE (pot%dion(nbeta, nbeta), pot%beta(m, nbeta), pot%lbeta(nbeta))
691 cpassert(.NOT. at_end)
693 IF (string(1:8) ==
"<PP_BETA")
THEN
698 cpassert(ibeta <= nbeta)
702 cpassert(.NOT. at_end)
705 IF (string ==
">")
EXIT
709 cpassert(line ==
"REAL")
717 cpassert(i1 <= nbeta)
718 CASE (
"ANGULAR_MOMENTUM")
723 CASE (
"CUTOFF_RADIUS_INDEX")
726 CASE (
"CUTOFF_RADIUS")
729 CASE (
"ULTRASOFT_CUTOFF_RADIUS")
733 cpabort(
"Unknown UPF PP_BETA option <"//trim(string)//
"> found")
741 cpassert(.NOT. at_end)
746 IF (icount > ms)
EXIT
748 ELSE IF (string(1:7) ==
"<PP_DIJ")
THEN
753 cpassert(.NOT. at_end)
756 IF (string ==
">")
EXIT
760 cpassert(line ==
"REAL")
767 cpabort(
"Unknown UPF PP_DIJ option <"//trim(string)//
"> found")
774 cpassert(.NOT. at_end)
776 i1 = (icount - 1)/nbeta + 1
777 i2 = mod(icount - 1, nbeta) + 1
781 IF (icount > ms)
EXIT
783 ELSE IF (string(1:7) ==
"<PP_QIJL")
THEN
785 ELSE IF (string(1:14) ==
"</PP_NONLOCAL>")
THEN
791 pot%dion = 2.0_dp*pot%dion
792 pot%beta = 0.5_dp*pot%beta
794 END SUBROUTINE upf_nonlocal_section
801 SUBROUTINE upf_semilocal_section(parser, pot)
805 CHARACTER(LEN=default_string_length) :: line, string
806 INTEGER :: i1, ib, icount, la, lmax, m, mc, ms
811 ALLOCATE (pot%vsemi(m, lmax + 1))
817 cpassert(.NOT. at_end)
819 IF (string(1:7) ==
"<PP_VNL")
THEN
824 cpassert(ib <= lmax + 1)
828 cpassert(.NOT. at_end)
831 IF (string ==
">")
EXIT
835 cpassert(line ==
"REAL")
844 cpabort(
"Unknown UPF PP_VNL option <"//trim(string)//
"> found")
852 cpassert(.NOT. at_end)
857 IF (icount > ms)
EXIT
859 ELSEIF (string(1:15) ==
"</PP_SEMILOCAL>")
THEN
866 pot%vsemi = 0.5_dp*pot%vsemi
868 END SUBROUTINE upf_semilocal_section
878 IF (
ALLOCATED(upfpot%r))
DEALLOCATE (upfpot%r)
879 IF (
ALLOCATED(upfpot%rab))
DEALLOCATE (upfpot%rab)
880 IF (
ALLOCATED(upfpot%vlocal))
DEALLOCATE (upfpot%vlocal)
881 IF (
ALLOCATED(upfpot%dion))
DEALLOCATE (upfpot%dion)
882 IF (
ALLOCATED(upfpot%beta))
DEALLOCATE (upfpot%beta)
883 IF (
ALLOCATED(upfpot%lbeta))
DEALLOCATE (upfpot%lbeta)
884 IF (
ALLOCATED(upfpot%vsemi))
DEALLOCATE (upfpot%vsemi)
Routines that process Quantum Espresso UPF files.
subroutine, public atom_read_upf(pot, upf_filename, read_header)
...
pure subroutine, public atom_release_upf(upfpot)
...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_get_next_line(parser, nline, at_end)
Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all ...
character(len=3) function, public parser_test_next_token(parser, string_length)
Test next input object.
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
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.