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
194 TYPE(cp_parser_type) :: parser
202 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
203 IF (nametag(1:1) /=
"<") cycle
206 IF (nametag(2:4) ==
"UPF")
THEN
207 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
209 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
210 pot%version = trim(nametag)
211 cpassert(nametag(1:5) ==
"2.0.1")
212 CALL parser_get_object(parser, nametag, lower_to_upper=.true.)
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)
291 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
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))
304 CALL parser_get_object(parser, string)
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)
320 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
323 CHARACTER(LEN=default_string_length) :: string
329 cpassert(.NOT. at_end)
331 CALL parser_get_object(parser, string, lower_to_upper=.true.)
332 IF (string ==
"/>")
EXIT
335 CALL parser_get_object(parser, pot%generated)
337 CALL parser_get_object(parser, pot%author)
339 CALL parser_get_object(parser, pot%date)
341 CALL parser_get_object(parser, pot%comment)
343 CALL parser_get_object(parser, pot%symbol)
344 cpassert(2 <= len(pot%symbol))
346 CALL parser_get_object(parser, pot%pseudo_type)
347 CASE (
"RELATIVISTIC")
348 CALL parser_get_object(parser, pot%relativistic)
349 CASE (
"IS_ULTRASOFT")
350 CALL parser_get_object(parser, pot%is_ultrasoft)
352 CALL parser_get_object(parser, pot%is_paw)
354 CALL parser_get_object(parser, pot%is_coulomb)
356 CALL parser_get_object(parser, pot%has_so)
358 CALL parser_get_object(parser, pot%has_wfc)
360 CALL parser_get_object(parser, pot%has_gipaw)
361 CASE (
"PAW_AS_GIPAW")
362 CALL parser_get_object(parser, pot%paw_as_gipaw)
363 CASE (
"CORE_CORRECTION")
364 CALL parser_get_object(parser, pot%core_correction)
366 CALL parser_get_object(parser, pot%functional)
368 CALL parser_get_object(parser, pot%zion)
369 CASE (
"TOTAL_PSENERGY")
370 CALL parser_get_object(parser, pot%total_psenergy)
372 CALL parser_get_object(parser, pot%wfc_cutoff)
374 CALL parser_get_object(parser, pot%rho_cutoff)
376 CALL parser_get_object(parser, pot%l_max)
378 CALL parser_get_object(parser, pot%l_max_rho)
380 CALL parser_get_object(parser, pot%l_local)
382 CALL parser_get_object(parser, pot%mesh_size)
383 CASE (
"NUMBER_OF_WFC")
384 CALL parser_get_object(parser, pot%number_of_wfc)
385 CASE (
"NUMBER_OF_PROJ")
386 CALL parser_get_object(parser, pot%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)
402 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
405 CHARACTER(LEN=default_string_length) :: string
412 cpassert(.NOT. at_end)
414 CALL parser_get_object(parser, string, lower_to_upper=.true.)
415 IF (string ==
">")
EXIT
418 CALL parser_get_object(parser, pot%dx)
420 CALL parser_get_object(parser, pot%xmin)
422 CALL parser_get_object(parser, pot%rmax)
424 CALL parser_get_object(parser, jj)
425 cpassert(pot%mesh_size == jj)
427 CALL parser_get_object(parser, pot%zmesh)
429 cpabort(
"Unknown UPF PP_MESH option <"//trim(string)//
"> found")
434 END SUBROUTINE upf_mesh_option
441 SUBROUTINE upf_mesh_section(parser, pot)
442 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
445 CHARACTER(LEN=default_string_length) :: line, string, string2
446 INTEGER :: icount, m, mc, ms
451 cpassert(.NOT. at_end)
452 CALL parser_get_object(parser, string, lower_to_upper=.true.)
458 IF (string(6:6) /=
">")
THEN
463 cpassert(.NOT. at_end)
465 CALL parser_get_object(parser, string2, lower_to_upper=.true.)
466 IF (string2 ==
">")
EXIT
467 SELECT CASE (string2)
469 CALL parser_get_object(parser, line, lower_to_upper=.true.)
470 cpassert(line ==
"REAL")
472 CALL parser_get_object(parser, ms)
475 CALL parser_get_object(parser, mc)
477 cpabort(
"Unknown UPF PP_R option <"//trim(string2)//
"> found")
487 cpassert(.NOT. at_end)
489 CALL parser_get_object(parser, pot%r(icount))
492 IF (icount > ms)
EXIT
495 IF (string(6:6) /=
">")
THEN
500 cpassert(.NOT. at_end)
502 CALL parser_get_object(parser, string2, lower_to_upper=.true.)
503 IF (string2 ==
">")
EXIT
504 SELECT CASE (string2)
506 CALL parser_get_object(parser, line, lower_to_upper=.true.)
507 cpassert(line ==
"REAL")
509 CALL parser_get_object(parser, ms)
512 CALL parser_get_object(parser, mc)
514 cpabort(
"Unknown UPF PP_RAB option <"//trim(string2)//
"> found")
518 ALLOCATE (pot%rab(m))
524 cpassert(.NOT. at_end)
526 CALL parser_get_object(parser, pot%rab(icount))
529 IF (icount > ms)
EXIT
538 END SUBROUTINE upf_mesh_section
546 SUBROUTINE upf_nlcc_section(parser, pot, options)
547 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
549 LOGICAL,
INTENT(IN) :: options
551 CHARACTER(LEN=default_string_length) :: line, string
552 INTEGER :: icount, m, mc, ms
562 cpassert(.NOT. at_end)
564 CALL parser_get_object(parser, string, lower_to_upper=.true.)
565 IF (string ==
">")
EXIT
568 CALL parser_get_object(parser, line, lower_to_upper=.true.)
569 cpassert(line ==
"REAL")
571 CALL parser_get_object(parser, ms)
574 CALL parser_get_object(parser, mc)
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)
589 CALL parser_get_object(parser, pot%rho_nlcc(icount))
592 IF (icount > ms)
EXIT
596 cpassert(.NOT. at_end)
597 CALL parser_get_object(parser, string, lower_to_upper=.true.)
598 cpassert(string ==
"</PP_NLCC>")
600 END SUBROUTINE upf_nlcc_section
608 SUBROUTINE upf_local_section(parser, pot, options)
609 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
611 LOGICAL,
INTENT(IN) :: options
613 CHARACTER(LEN=default_string_length) :: line, string
614 INTEGER :: icount, m, mc, ms
624 cpassert(.NOT. at_end)
626 CALL parser_get_object(parser, string, lower_to_upper=.true.)
627 IF (string ==
">")
EXIT
630 CALL parser_get_object(parser, line, lower_to_upper=.true.)
631 cpassert(line ==
"REAL")
633 CALL parser_get_object(parser, ms)
636 CALL parser_get_object(parser, mc)
638 cpabort(
"Unknown UPF PP_LOCAL option <"//trim(string)//
"> found")
643 ALLOCATE (pot%vlocal(m))
649 cpassert(.NOT. at_end)
651 CALL parser_get_object(parser, pot%vlocal(icount))
654 IF (icount > ms)
EXIT
658 pot%vlocal = 0.5_dp*pot%vlocal
661 cpassert(.NOT. at_end)
662 CALL parser_get_object(parser, string, lower_to_upper=.true.)
663 cpassert(string ==
"</PP_LOCAL>")
665 END SUBROUTINE upf_local_section
672 SUBROUTINE upf_nonlocal_section(parser, pot)
673 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
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)
692 CALL parser_get_object(parser, string, lower_to_upper=.true.)
693 IF (string(1:8) ==
"<PP_BETA")
THEN
698 cpassert(ibeta <= nbeta)
702 cpassert(.NOT. at_end)
704 CALL parser_get_object(parser, string, lower_to_upper=.true.)
705 IF (string ==
">")
EXIT
708 CALL parser_get_object(parser, line, lower_to_upper=.true.)
709 cpassert(line ==
"REAL")
711 CALL parser_get_object(parser, ms)
714 CALL parser_get_object(parser, mc)
716 CALL parser_get_object(parser, i1)
717 cpassert(i1 <= nbeta)
718 CASE (
"ANGULAR_MOMENTUM")
719 CALL parser_get_object(parser, la)
721 CALL parser_get_object(parser, line)
723 CASE (
"CUTOFF_RADIUS_INDEX")
724 CALL parser_get_object(parser, line)
726 CASE (
"CUTOFF_RADIUS")
727 CALL parser_get_object(parser, line)
729 CASE (
"ULTRASOFT_CUTOFF_RADIUS")
730 CALL parser_get_object(parser, line)
733 cpabort(
"Unknown UPF PP_BETA option <"//trim(string)//
"> found")
741 cpassert(.NOT. at_end)
743 CALL parser_get_object(parser, pot%beta(icount, i1))
746 IF (icount > ms)
EXIT
748 ELSE IF (string(1:7) ==
"<PP_DIJ")
THEN
753 cpassert(.NOT. at_end)
755 CALL parser_get_object(parser, string, lower_to_upper=.true.)
756 IF (string ==
">")
EXIT
759 CALL parser_get_object(parser, line, lower_to_upper=.true.)
760 cpassert(line ==
"REAL")
762 CALL parser_get_object(parser, ms)
765 CALL parser_get_object(parser, mc)
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
778 CALL parser_get_object(parser, pot%dion(i1, i2))
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)
802 TYPE(cp_parser_type),
INTENT(INOUT) :: parser
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)
818 CALL parser_get_object(parser, string, lower_to_upper=.true.)
819 IF (string(1:7) ==
"<PP_VNL")
THEN
824 cpassert(ib <= lmax + 1)
828 cpassert(.NOT. at_end)
830 CALL parser_get_object(parser, string, lower_to_upper=.true.)
831 IF (string ==
">")
EXIT
834 CALL parser_get_object(parser, line, lower_to_upper=.true.)
835 cpassert(line ==
"REAL")
837 CALL parser_get_object(parser, ms)
840 CALL parser_get_object(parser, mc)
842 CALL parser_get_object(parser, la)
844 cpabort(
"Unknown UPF PP_VNL option <"//trim(string)//
"> found")
852 cpassert(.NOT. at_end)
854 CALL parser_get_object(parser, pot%vsemi(icount, i1))
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.