(git:3d5d2e5)
Loading...
Searching...
No Matches
external_potential_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 Definition of the atomic potential types.
10!> \par History
11!> GT, 22.09.2002: added elp_potential_types
12!> \author Matthias Krack (04.07.2000)
13! **************************************************************************************************
15
16 USE ao_util, ONLY: exp_radius
17 USE bibliography, ONLY: goedecker1996,&
19 krack2000,&
20 krack2005,&
21 cite_reference
35 USE input_val_types, ONLY: val_get,&
37 USE kinds, ONLY: default_path_length,&
39 dp
40 USE mathconstants, ONLY: dfac,&
41 fac,&
42 fourpi,&
43 pi,&
44 rootpi
45 USE mathlib, ONLY: symmetrize_matrix
48 USE orbital_pointers, ONLY: co,&
49 coset,&
51 nco,&
52 ncoset,&
53 nso
55 USE periodic_table, ONLY: ptable
56 USE string_utilities, ONLY: remove_word,&
62#include "../base/base_uses.f90"
63
64 IMPLICIT NONE
65
66 PRIVATE
67
68 ! Global parameters
69
70 CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'external_potential_types'
71
72 ! Define the all-electron potential type
73 ! Literature: M. Krack and M. Parrinello,
74 ! Phys. Chem. Chem. Phys. 2, 2105 (2000)
76 !MK PRIVATE
77 CHARACTER(LEN=default_string_length) :: name = ""
78 CHARACTER(LEN=default_string_length), &
79 DIMENSION(2) :: description = ["All-electron potential ", &
80 "Krack, Parrinello, PCCP 2, 2105 (2000)"]
81 REAL(kind=dp) :: alpha_core_charge = 0.0_dp, &
82 ccore_charge = 0.0_dp, &
83 core_charge_radius = 0.0_dp, &
84 zeff = 0.0_dp, zeff_correction = 0.0_dp
85 INTEGER :: z = 0
86 INTEGER, DIMENSION(:), POINTER :: elec_conf => null()
87 END TYPE all_potential_type
88
89 ! Define the effective charge & inducible dipole potential type (for Fist)
91 PRIVATE
92 CHARACTER(LEN=default_string_length) :: name = ""
93 CHARACTER(LEN=default_string_length), &
94 DIMENSION(1) :: description = "Effective charge and inducible dipole potential"
95 REAL(kind=dp) :: apol = 0.0_dp, cpol = 0.0_dp, mm_radius = 0.0_dp, qeff = 0.0_dp, &
96 qmmm_corr_radius = 0.0_dp, qmmm_radius = 0.0_dp
97
98 END TYPE fist_potential_type
99
100 ! Local potential type
101 ! V(r) = SUM_i exp(0.5*(r/rci)**2) * ( C1i + C2i (r/rci)**2 + C3i (r/rci)**4 ...)
102 ! alpha = 0.5/rci**2
104 !PRIVATE
105 CHARACTER(LEN=default_string_length) :: name = ""
106 CHARACTER(LEN=default_string_length), &
107 DIMENSION(4) :: description = "Local short-range pseudopotential"
108 INTEGER :: ngau = 0, npol = 0
109 REAL(kind=dp) :: radius = 0.0_dp
110 REAL(kind=dp), DIMENSION(:), POINTER :: alpha => null()
111 REAL(kind=dp), DIMENSION(:, :), POINTER :: cval => null()
112 END TYPE local_potential_type
113
114 ! Define the GTH potential type
115 ! Literature: - S. Goedecker, M. Teter and J. Hutter,
116 ! Phys. Rev. B 54, 1703 (1996)
117 ! - C. Hartwigsen, S. Goedecker and J. Hutter,
118 ! Phys. Rev. B 58, 3641 (1998)
119 ! - M. Krack,
120 ! Theor. Chem. Acc. 114, 145 (2005)
122 CHARACTER(LEN=default_string_length) :: name = ""
123 CHARACTER(LEN=default_string_length) :: aliases = ""
124 CHARACTER(LEN=default_string_length), &
125 DIMENSION(4) :: description = ["Goedecker-Teter-Hutter pseudopotential", &
126 "Goedecker et al., PRB 54, 1703 (1996) ", &
127 "Hartwigsen et al., PRB 58, 3641 (1998)", &
128 "Krack, TCA 114, 145 (2005) "]
129 REAL(kind=dp) :: alpha_core_charge = 0.0_dp, &
130 alpha_ppl = 0.0_dp, &
131 ccore_charge = 0.0_dp, &
132 cerf_ppl = 0.0_dp, &
133 zeff = 0.0_dp, &
134 core_charge_radius = 0.0_dp, &
135 ppl_radius = 0.0_dp, &
136 ppnl_radius = 0.0_dp, &
137 zeff_correction = 0.0_dp
138 INTEGER :: lppnl = 0, &
139 lprj_ppnl_max = 0, &
140 nexp_ppl = 0, &
141 nppnl = 0, &
142 nprj_ppnl_max = 0, z = 0
143 REAL(kind=dp), DIMENSION(:), POINTER :: alpha_ppnl => null(), &
144 cexp_ppl => null()
145 INTEGER, DIMENSION(:), POINTER :: elec_conf => null()
146 ! Non-local projectors
147 INTEGER, DIMENSION(:), POINTER :: nprj_ppnl => null()
148 REAL(kind=dp), DIMENSION(:, :), POINTER :: cprj => null(), &
149 cprj_ppnl => null(), &
150 vprj_ppnl => null(), &
151 wprj_ppnl => null()
152 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: hprj_ppnl => null(), &
153 kprj_ppnl => null()
154 ! Type extensions
155 ! Spin-orbit coupling (SOC) parameters
156 LOGICAL :: soc = .false.
157 ! NLCC
158 LOGICAL :: nlcc = .false.
159 INTEGER :: nexp_nlcc = 0
160 REAL(kind=dp), DIMENSION(:), POINTER :: alpha_nlcc => null()
161 INTEGER, DIMENSION(:), POINTER :: nct_nlcc => null()
162 REAL(kind=dp), DIMENSION(:, :), POINTER :: cval_nlcc => null()
163 ! LSD potential
164 LOGICAL :: lsdpot = .false.
165 INTEGER :: nexp_lsd = 0
166 REAL(kind=dp), DIMENSION(:), POINTER :: alpha_lsd => null()
167 INTEGER, DIMENSION(:), POINTER :: nct_lsd => null()
168 REAL(kind=dp), DIMENSION(:, :), POINTER :: cval_lsd => null()
169 ! Extended local potential
170 LOGICAL :: lpotextended = .false.
171 INTEGER :: nexp_lpot = 0
172 REAL(kind=dp), DIMENSION(:), POINTER :: alpha_lpot => null()
173 INTEGER, DIMENSION(:), POINTER :: nct_lpot => null()
174 REAL(kind=dp), DIMENSION(:, :), POINTER :: cval_lpot => null()
175 ! monovalent pseudopotential
176 LOGICAL :: monovalent = .false.
177 END TYPE gth_potential_type
178
180 CHARACTER(LEN=default_string_length) :: name = ""
181 CHARACTER(LEN=default_string_length) :: aliases = ""
182 CHARACTER(LEN=default_string_length), &
183 DIMENSION(4) :: description = ["Separable Gaussian pseudopotential ", &
184 "M. Pelissier, N. Komiha, J.P. Daudey, JCC, 9, 298 (1988)", &
185 "create from ", &
186 " "]
187 ! CHARGE
188 INTEGER :: z = 0
189 REAL(kind=dp) :: zeff = 0.0_dp, &
190 zeff_correction = 0.0_dp
191 REAL(kind=dp) :: alpha_core_charge = 0.0_dp, &
192 ccore_charge = 0.0_dp, &
193 core_charge_radius = 0.0_dp
194 REAL(kind=dp) :: ppl_radius = 0.0_dp, ppnl_radius = 0.0_dp
195 INTEGER, DIMENSION(:), POINTER :: elec_conf => null()
196 ! LOCAL
197 LOGICAL :: ecp_local = .false.
198 INTEGER :: n_local = 0
199 REAL(kind=dp), DIMENSION(:), POINTER :: a_local => null()
200 REAL(kind=dp), DIMENSION(:), POINTER :: c_local => null()
201 ! ECP local
202 INTEGER :: nloc = 0 ! # terms
203 INTEGER, DIMENSION(1:10) :: nrloc = 0 ! r**(n-2)
204 REAL(dp), DIMENSION(1:10) :: aloc = 0.0_dp ! coefficient
205 REAL(dp), DIMENSION(1:10) :: bloc = 0.0_dp ! exponent
206 ! ECP semi-local
207 LOGICAL :: ecp_semi_local = .false.
208 INTEGER :: sl_lmax = 0
209 INTEGER, DIMENSION(0:10) :: npot = 0 ! # terms
210 INTEGER, DIMENSION(1:15, 0:10) :: nrpot = 0 ! r**(n-2)
211 REAL(dp), DIMENSION(1:15, 0:10) :: apot = 0.0_dp ! coefficient
212 REAL(dp), DIMENSION(1:15, 0:10) :: bpot = 0.0_dp ! exponent
213 ! NON-LOCAL
214 INTEGER :: n_nonlocal = 0
215 INTEGER :: nppnl = 0
216 INTEGER :: lmax = -1
217 LOGICAL, DIMENSION(0:5) :: is_nonlocal = .false.
218 REAL(kind=dp), DIMENSION(:), POINTER :: a_nonlocal => null()
219 REAL(kind=dp), DIMENSION(:, :), POINTER :: h_nonlocal => null()
220 REAL(kind=dp), DIMENSION(:, :, :), POINTER :: c_nonlocal => null()
221 REAL(kind=dp), DIMENSION(:, :), POINTER :: cprj_ppnl => null()
222 REAL(kind=dp), DIMENSION(:), POINTER :: vprj_ppnl => null()
223 ! Original scalar UPF projectors and their immutable quadrature cache.
224 TYPE(atom_upfpot_type), ALLOCATABLE :: upf_data
225 TYPE(upf_projector_type) :: upf_projectors
226 TYPE(upf_local_type) :: upf_local
227 ! NLCC
228 LOGICAL :: has_nlcc = .false.
229 INTEGER :: n_nlcc = 0
230 REAL(kind=dp), DIMENSION(:), POINTER :: a_nlcc => null()
231 REAL(kind=dp), DIMENSION(:), POINTER :: c_nlcc => null()
232 END TYPE sgp_potential_type
233
235 TYPE(gth_potential_type), POINTER :: gth_potential => null()
236 END TYPE gth_potential_p_type
237
239 TYPE(sgp_potential_type), POINTER :: sgp_potential => null()
240 END TYPE sgp_potential_p_type
241
242 ! Public subroutines
243 PUBLIC :: allocate_potential, &
252
253 ! Public data types
254
255 PUBLIC :: all_potential_type, &
260 PUBLIC :: gth_potential_p_type, &
262
264 MODULE PROCEDURE allocate_all_potential, &
265 allocate_fist_potential, &
266 allocate_local_potential, &
267 allocate_gth_potential, &
268 allocate_sgp_potential
269 END INTERFACE
270
272 MODULE PROCEDURE deallocate_all_potential, &
273 deallocate_fist_potential, &
274 deallocate_local_potential, &
275 deallocate_sgp_potential, &
276 deallocate_gth_potential
277 END INTERFACE
278
280 MODULE PROCEDURE get_all_potential, &
281 get_fist_potential, &
282 get_local_potential, &
283 get_gth_potential, &
284 get_sgp_potential
285 END INTERFACE
286
288 MODULE PROCEDURE init_all_potential, &
289 init_gth_potential, &
290 init_sgp_potential
291 END INTERFACE
292
294 MODULE PROCEDURE read_all_potential, &
295 read_all_potential_files, &
296 read_local_potential, &
297 read_local_potential_files, &
298 read_gth_potential, &
299 read_gth_potential_files
300 END INTERFACE
301
303 MODULE PROCEDURE set_all_potential, &
304 set_fist_potential, &
305 set_local_potential, &
306 set_gth_potential, &
307 set_sgp_potential
308 END INTERFACE
309
311 MODULE PROCEDURE write_all_potential, &
312 write_local_potential, &
313 write_gth_potential, &
314 write_sgp_potential
315 END INTERFACE
316
318 MODULE PROCEDURE copy_all_potential, &
319 copy_gth_potential, &
320 copy_sgp_potential
321 END INTERFACE
322
323CONTAINS
324
325! **************************************************************************************************
326!> \brief Abort after a potential could not be found in any requested library file.
327!> \param element_symbol ...
328!> \param potential_name ...
329!> \param potential_file_names ...
330! **************************************************************************************************
331 SUBROUTINE potential_files_not_found(element_symbol, potential_name, potential_file_names)
332
333 CHARACTER(LEN=*), INTENT(IN) :: element_symbol, potential_name
334 CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: potential_file_names
335
336 CHARACTER(LEN=:), ALLOCATABLE :: file_list
337 INTEGER :: i
338
339 file_list = ""
340 DO i = 1, SIZE(potential_file_names)
341 file_list = trim(file_list)//"<"//trim(potential_file_names(i))//"> "
342 END DO
343 CALL cp_abort(__location__, &
344 "The requested potential <"//trim(potential_name)// &
345 "> for element <"//trim(element_symbol)// &
346 "> was not found in the potential files "//trim(file_list))
347
348 END SUBROUTINE potential_files_not_found
349
350! **************************************************************************************************
351!> \brief Allocate an atomic all-electron potential data set.
352!> \param potential ...
353!> \date 25.07.2000,
354!> \author MK
355!> \version 1.0
356! **************************************************************************************************
357 SUBROUTINE allocate_all_potential(potential)
358 TYPE(all_potential_type), INTENT(INOUT), POINTER :: potential
359
360 IF (ASSOCIATED(potential)) CALL deallocate_potential(potential)
361
362 ALLOCATE (potential)
363
364 END SUBROUTINE allocate_all_potential
365
366! **************************************************************************************************
367!> \brief Allocate an effective charge and inducible dipole potential data set.
368!> \param potential ...
369!> \date 05.03.2010
370!> \author Toon.Verstraelen@gmail.com
371! **************************************************************************************************
372 SUBROUTINE allocate_fist_potential(potential)
373 TYPE(fist_potential_type), INTENT(INOUT), POINTER :: potential
374
375 IF (ASSOCIATED(potential)) CALL deallocate_potential(potential)
376
377 ALLOCATE (potential)
378
379 END SUBROUTINE allocate_fist_potential
380
381! **************************************************************************************************
382!> \brief Allocate an atomic local potential data set.
383!> \param potential ...
384!> \date 24.01.2014
385!> \author JGH
386!> \version 1.0
387! **************************************************************************************************
388 SUBROUTINE allocate_local_potential(potential)
389 TYPE(local_potential_type), INTENT(INOUT), POINTER :: potential
390
391 IF (ASSOCIATED(potential)) CALL deallocate_potential(potential)
392
393 ALLOCATE (potential)
394
395 END SUBROUTINE allocate_local_potential
396
397! **************************************************************************************************
398!> \brief Allocate an atomic GTH potential data set.
399!> \param potential ...
400!> \date 25.07.2000
401!> \author MK
402!> \version 1.0
403! **************************************************************************************************
404 SUBROUTINE allocate_gth_potential(potential)
405 TYPE(gth_potential_type), INTENT(INOUT), POINTER :: potential
406
407 IF (ASSOCIATED(potential)) CALL deallocate_potential(potential)
408
409 ALLOCATE (potential)
410
411 END SUBROUTINE allocate_gth_potential
412
413! **************************************************************************************************
414!> \brief Allocate an atomic SGP potential data set.
415!> \param potential ...
416!> \version 1.0
417! **************************************************************************************************
418 SUBROUTINE allocate_sgp_potential(potential)
419 TYPE(sgp_potential_type), INTENT(INOUT), POINTER :: potential
420
421 IF (ASSOCIATED(potential)) CALL deallocate_potential(potential)
422
423 ALLOCATE (potential)
424
425 END SUBROUTINE allocate_sgp_potential
426! **************************************************************************************************
427!> \brief Deallocate an atomic all-electron potential data set.
428!> \param potential ...
429!> \date 03.11.2000
430!> \author MK
431!> \version 1.0
432! **************************************************************************************************
433 SUBROUTINE deallocate_all_potential(potential)
434 TYPE(all_potential_type), POINTER :: potential
435
436 IF (.NOT. ASSOCIATED(potential)) THEN
437 cpabort("The pointer potential is not associated.")
438 END IF
439
440 DEALLOCATE (potential%elec_conf)
441 DEALLOCATE (potential)
442
443 END SUBROUTINE deallocate_all_potential
444
445! **************************************************************************************************
446!> \brief Deallocate an effective charge and inducible dipole potential data set.
447!> \param potential ...
448!> \date 05.03.2010
449!> \author Toon.Verstraelen@gmail.com
450! **************************************************************************************************
451 SUBROUTINE deallocate_fist_potential(potential)
452 TYPE(fist_potential_type), POINTER :: potential
453
454 IF (.NOT. ASSOCIATED(potential)) THEN
455 cpabort("The pointer potential is not associated.")
456 END IF
457
458 ! Nothing exciting here yet.
459 DEALLOCATE (potential)
460
461 END SUBROUTINE deallocate_fist_potential
462
463! **************************************************************************************************
464!> \brief Deallocate an atomic local potential data set.
465!> \param potential ...
466!> \date 24.01.2014
467!> \author JGH
468!> \version 1.0
469! **************************************************************************************************
470 SUBROUTINE deallocate_local_potential(potential)
471 TYPE(local_potential_type), POINTER :: potential
472
473 IF (.NOT. ASSOCIATED(potential)) THEN
474 cpabort("The pointer potential is not associated.")
475 END IF
476
477 IF (ASSOCIATED(potential%alpha)) THEN
478 DEALLOCATE (potential%alpha)
479 END IF
480 IF (ASSOCIATED(potential%cval)) THEN
481 DEALLOCATE (potential%cval)
482 END IF
483
484 DEALLOCATE (potential)
485
486 END SUBROUTINE deallocate_local_potential
487
488! **************************************************************************************************
489!> \brief Deallocate an atomic GTH potential data set.
490!> \param potential ...
491!> \date 03.11.2000
492!> \author MK
493!> \version 1.0
494! **************************************************************************************************
495 SUBROUTINE deallocate_gth_potential(potential)
496 TYPE(gth_potential_type), POINTER :: potential
497
498 IF (.NOT. ASSOCIATED(potential)) THEN
499 cpabort("The pointer potential is not associated.")
500 END IF
501
502 DEALLOCATE (potential%elec_conf)
503 ! Deallocate the parameters of the local part
504
505 IF (ASSOCIATED(potential%cexp_ppl)) THEN
506 DEALLOCATE (potential%cexp_ppl)
507 END IF
508
509 ! Deallocate the parameters of the non-local part
510 IF (ASSOCIATED(potential%alpha_ppnl)) THEN
511 DEALLOCATE (potential%alpha_ppnl)
512 DEALLOCATE (potential%cprj)
513 DEALLOCATE (potential%cprj_ppnl)
514 DEALLOCATE (potential%hprj_ppnl)
515 DEALLOCATE (potential%kprj_ppnl)
516 DEALLOCATE (potential%nprj_ppnl)
517 DEALLOCATE (potential%vprj_ppnl)
518 DEALLOCATE (potential%wprj_ppnl)
519 END IF
520
521 IF (ASSOCIATED(potential%alpha_lpot)) THEN
522 DEALLOCATE (potential%alpha_lpot)
523 DEALLOCATE (potential%nct_lpot)
524 DEALLOCATE (potential%cval_lpot)
525 END IF
526
527 IF (ASSOCIATED(potential%alpha_lsd)) THEN
528 DEALLOCATE (potential%alpha_lsd)
529 DEALLOCATE (potential%nct_lsd)
530 DEALLOCATE (potential%cval_lsd)
531 END IF
532
533 IF (ASSOCIATED(potential%alpha_nlcc)) THEN
534 DEALLOCATE (potential%alpha_nlcc)
535 DEALLOCATE (potential%nct_nlcc)
536 DEALLOCATE (potential%cval_nlcc)
537 END IF
538
539 DEALLOCATE (potential)
540
541 END SUBROUTINE deallocate_gth_potential
542
543! **************************************************************************************************
544!> \brief Deallocate an atomic SGP potential data set.
545!> \param potential ...
546! **************************************************************************************************
547 SUBROUTINE deallocate_sgp_potential(potential)
548 TYPE(sgp_potential_type), POINTER :: potential
549
550 IF (.NOT. ASSOCIATED(potential)) THEN
551 cpabort("The pointer potential is not associated.")
552 END IF
553
554 IF (ASSOCIATED(potential%elec_conf)) THEN
555 DEALLOCATE (potential%elec_conf)
556 END IF
557 IF (ASSOCIATED(potential%a_local)) THEN
558 DEALLOCATE (potential%a_local)
559 END IF
560 IF (ASSOCIATED(potential%c_local)) THEN
561 DEALLOCATE (potential%c_local)
562 END IF
563
564 IF (ASSOCIATED(potential%a_nonlocal)) THEN
565 DEALLOCATE (potential%a_nonlocal)
566 END IF
567 IF (ASSOCIATED(potential%h_nonlocal)) THEN
568 DEALLOCATE (potential%h_nonlocal)
569 END IF
570 IF (ASSOCIATED(potential%c_nonlocal)) THEN
571 DEALLOCATE (potential%c_nonlocal)
572 END IF
573 IF (ASSOCIATED(potential%cprj_ppnl)) THEN
574 DEALLOCATE (potential%cprj_ppnl)
575 END IF
576 IF (ASSOCIATED(potential%vprj_ppnl)) THEN
577 DEALLOCATE (potential%vprj_ppnl)
578 END IF
579
580 IF (ASSOCIATED(potential%a_nlcc)) THEN
581 DEALLOCATE (potential%a_nlcc)
582 END IF
583 IF (ASSOCIATED(potential%c_nlcc)) THEN
584 DEALLOCATE (potential%c_nlcc)
585 END IF
586
587 DEALLOCATE (potential)
588
589 END SUBROUTINE deallocate_sgp_potential
590
591! **************************************************************************************************
592!> \brief Get attributes of an all-electron potential data set.
593!> \param potential ...
594!> \param name ...
595!> \param alpha_core_charge ...
596!> \param ccore_charge ...
597!> \param core_charge_radius ...
598!> \param z ...
599!> \param zeff ...
600!> \param zeff_correction ...
601!> \param elec_conf ...
602!> \date 11.01.2002
603!> \author MK
604!> \version 1.0
605! **************************************************************************************************
606 SUBROUTINE get_all_potential(potential, name, alpha_core_charge, &
607 ccore_charge, core_charge_radius, z, zeff, &
608 zeff_correction, elec_conf)
609 TYPE(all_potential_type), INTENT(IN) :: potential
610 CHARACTER(LEN=default_string_length), &
611 INTENT(OUT), OPTIONAL :: name
612 REAL(KIND=dp), INTENT(OUT), OPTIONAL :: alpha_core_charge, ccore_charge, &
613 core_charge_radius
614 INTEGER, INTENT(OUT), OPTIONAL :: z
615 REAL(KIND=dp), INTENT(OUT), OPTIONAL :: zeff, zeff_correction
616 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf
617
618 IF (PRESENT(name)) name = potential%name
619 IF (PRESENT(alpha_core_charge)) THEN
620 alpha_core_charge = potential%alpha_core_charge
621 END IF
622 IF (PRESENT(ccore_charge)) ccore_charge = potential%ccore_charge
623 IF (PRESENT(core_charge_radius)) THEN
624 core_charge_radius = potential%core_charge_radius
625 END IF
626 IF (PRESENT(z)) z = potential%z
627 IF (PRESENT(zeff)) zeff = potential%zeff
628 IF (PRESENT(zeff_correction)) zeff_correction = potential%zeff_correction
629 IF (PRESENT(elec_conf)) elec_conf => potential%elec_conf
630
631 END SUBROUTINE get_all_potential
632
633! **************************************************************************************************
634!> \brief Get attributes of an effective point charge and inducible dipole
635!> potential.
636!> \param potential ...
637!> \param name ...
638!> \param apol ...
639!> \param cpol ...
640!> \param mm_radius ...
641!> \param qeff ...
642!> \param qmmm_corr_radius ...
643!> \param qmmm_radius ...
644!> \date 05.03-2010
645!> \author Toon.Verstraelen@UGent.be
646! **************************************************************************************************
647 ELEMENTAL SUBROUTINE get_fist_potential(potential, name, apol, cpol, mm_radius, qeff, &
648 qmmm_corr_radius, qmmm_radius)
649 TYPE(fist_potential_type), INTENT(IN) :: potential
650 CHARACTER(LEN=default_string_length), &
651 INTENT(OUT), OPTIONAL :: name
652 REAL(kind=dp), INTENT(OUT), OPTIONAL :: apol, cpol, mm_radius, qeff, &
653 qmmm_corr_radius, qmmm_radius
654
655 IF (PRESENT(name)) name = potential%name
656 IF (PRESENT(apol)) apol = potential%apol
657 IF (PRESENT(cpol)) cpol = potential%cpol
658 IF (PRESENT(mm_radius)) mm_radius = potential%mm_radius
659 IF (PRESENT(qeff)) qeff = potential%qeff
660 IF (PRESENT(qmmm_corr_radius)) qmmm_corr_radius = potential%qmmm_corr_radius
661 IF (PRESENT(qmmm_radius)) qmmm_radius = potential%qmmm_radius
662
663 END SUBROUTINE get_fist_potential
664
665! **************************************************************************************************
666!> \brief Get attributes of an atomic local potential data set.
667!> \param potential ...
668!> \param name ...
669!> \param ngau ...
670!> \param npol ...
671!> \param alpha ...
672!> \param cval ...
673!> \param radius ...
674!> \date 24.01.2014
675!> \author JGH
676!> \version 1.0
677! **************************************************************************************************
678 SUBROUTINE get_local_potential(potential, name, ngau, npol, alpha, cval, radius)
679 TYPE(local_potential_type), INTENT(IN) :: potential
680 CHARACTER(LEN=default_string_length), &
681 INTENT(OUT), OPTIONAL :: name
682 INTEGER, INTENT(OUT), OPTIONAL :: ngau, npol
683 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: alpha
684 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cval
685 REAL(kind=dp), INTENT(OUT), OPTIONAL :: radius
686
687 IF (PRESENT(name)) name = potential%name
688 IF (PRESENT(ngau)) ngau = potential%ngau
689 IF (PRESENT(npol)) npol = potential%npol
690 IF (PRESENT(alpha)) alpha => potential%alpha
691 IF (PRESENT(cval)) cval => potential%cval
692 IF (PRESENT(radius)) radius = potential%radius
693
694 END SUBROUTINE get_local_potential
695
696! **************************************************************************************************
697!> \brief Get attributes of a GTH potential data set.
698!> \param potential ...
699!> \param name ...
700!> \param aliases ...
701!> \param alpha_core_charge ...
702!> \param alpha_ppl ...
703!> \param ccore_charge ...
704!> \param cerf_ppl ...
705!> \param core_charge_radius ...
706!> \param ppl_radius ...
707!> \param ppnl_radius ...
708!> \param lppnl ...
709!> \param lprj_ppnl_max ...
710!> \param nexp_ppl ...
711!> \param nppnl ...
712!> \param nprj_ppnl_max ...
713!> \param z ...
714!> \param zeff ...
715!> \param zeff_correction ...
716!> \param ppl_present ...
717!> \param ppnl_present ...
718!> \param soc_present ...
719!> \param alpha_ppnl ...
720!> \param cexp_ppl ...
721!> \param elec_conf ...
722!> \param nprj_ppnl ...
723!> \param cprj ...
724!> \param cprj_ppnl ...
725!> \param vprj_ppnl ...
726!> \param wprj_ppnl ...
727!> \param hprj_ppnl ...
728!> \param kprj_ppnl ...
729!> \param lpot_present ...
730!> \param nexp_lpot ...
731!> \param alpha_lpot ...
732!> \param nct_lpot ...
733!> \param cval_lpot ...
734!> \param lsd_present ...
735!> \param nexp_lsd ...
736!> \param alpha_lsd ...
737!> \param nct_lsd ...
738!> \param cval_lsd ...
739!> \param nlcc_present ...
740!> \param nexp_nlcc ...
741!> \param alpha_nlcc ...
742!> \param nct_nlcc ...
743!> \param cval_nlcc ...
744!> \param monovalent ...
745!> \date 11.01.2002
746!> \author MK
747!> \version 1.0
748! **************************************************************************************************
749 SUBROUTINE get_gth_potential(potential, name, aliases, alpha_core_charge, &
750 alpha_ppl, ccore_charge, cerf_ppl, &
751 core_charge_radius, ppl_radius, ppnl_radius, &
752 lppnl, lprj_ppnl_max, nexp_ppl, nppnl, &
753 nprj_ppnl_max, z, zeff, zeff_correction, &
754 ppl_present, ppnl_present, soc_present, &
755 alpha_ppnl, cexp_ppl, elec_conf, nprj_ppnl, cprj, &
756 cprj_ppnl, vprj_ppnl, wprj_ppnl, hprj_ppnl, kprj_ppnl, &
757 lpot_present, nexp_lpot, alpha_lpot, nct_lpot, cval_lpot, &
758 lsd_present, nexp_lsd, alpha_lsd, nct_lsd, cval_lsd, &
759 nlcc_present, nexp_nlcc, alpha_nlcc, nct_nlcc, cval_nlcc, &
760 monovalent)
761
762 TYPE(gth_potential_type), INTENT(IN) :: potential
763 CHARACTER(LEN=default_string_length), &
764 INTENT(OUT), OPTIONAL :: name, aliases
765 REAL(kind=dp), INTENT(OUT), OPTIONAL :: alpha_core_charge, alpha_ppl, &
766 ccore_charge, cerf_ppl, &
767 core_charge_radius, ppl_radius, &
768 ppnl_radius
769 INTEGER, INTENT(OUT), OPTIONAL :: lppnl, lprj_ppnl_max, nexp_ppl, nppnl, &
770 nprj_ppnl_max, z
771 REAL(kind=dp), INTENT(OUT), OPTIONAL :: zeff, zeff_correction
772 LOGICAL, INTENT(OUT), OPTIONAL :: ppl_present, ppnl_present, soc_present
773 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: alpha_ppnl, cexp_ppl
774 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf, nprj_ppnl
775 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cprj, cprj_ppnl, vprj_ppnl, wprj_ppnl
776 REAL(kind=dp), DIMENSION(:, :, :), OPTIONAL, &
777 POINTER :: hprj_ppnl, kprj_ppnl
778 LOGICAL, INTENT(OUT), OPTIONAL :: lpot_present
779 INTEGER, INTENT(OUT), OPTIONAL :: nexp_lpot
780 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: alpha_lpot
781 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: nct_lpot
782 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cval_lpot
783 LOGICAL, INTENT(OUT), OPTIONAL :: lsd_present
784 INTEGER, INTENT(OUT), OPTIONAL :: nexp_lsd
785 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: alpha_lsd
786 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: nct_lsd
787 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cval_lsd
788 LOGICAL, INTENT(OUT), OPTIONAL :: nlcc_present
789 INTEGER, INTENT(OUT), OPTIONAL :: nexp_nlcc
790 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: alpha_nlcc
791 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: nct_nlcc
792 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cval_nlcc
793 LOGICAL, INTENT(OUT), OPTIONAL :: monovalent
794
795 IF (PRESENT(name)) name = potential%name
796 IF (PRESENT(aliases)) aliases = potential%aliases
797 IF (PRESENT(alpha_core_charge)) THEN
798 alpha_core_charge = potential%alpha_core_charge
799 END IF
800 IF (PRESENT(alpha_ppl)) alpha_ppl = potential%alpha_ppl
801 IF (PRESENT(ccore_charge)) ccore_charge = potential%ccore_charge
802 IF (PRESENT(cerf_ppl)) cerf_ppl = potential%cerf_ppl
803 IF (PRESENT(core_charge_radius)) THEN
804 core_charge_radius = potential%core_charge_radius
805 END IF
806 IF (PRESENT(ppl_radius)) ppl_radius = potential%ppl_radius
807 IF (PRESENT(ppnl_radius)) ppnl_radius = potential%ppnl_radius
808 IF (PRESENT(soc_present)) soc_present = potential%soc
809 IF (PRESENT(lppnl)) lppnl = potential%lppnl
810 IF (PRESENT(lprj_ppnl_max)) lprj_ppnl_max = potential%lprj_ppnl_max
811 IF (PRESENT(nexp_ppl)) nexp_ppl = potential%nexp_ppl
812 IF (PRESENT(nppnl)) nppnl = potential%nppnl
813 IF (PRESENT(nprj_ppnl_max)) nprj_ppnl_max = potential%nprj_ppnl_max
814 IF (PRESENT(z)) z = potential%z
815 IF (PRESENT(zeff)) zeff = potential%zeff
816 IF (PRESENT(zeff_correction)) zeff_correction = potential%zeff_correction
817 IF (PRESENT(ppl_present)) ppl_present = (potential%nexp_ppl > 0)
818 IF (PRESENT(ppnl_present)) ppnl_present = (potential%nppnl > 0)
819 IF (PRESENT(alpha_ppnl)) alpha_ppnl => potential%alpha_ppnl
820 IF (PRESENT(cexp_ppl)) cexp_ppl => potential%cexp_ppl
821 IF (PRESENT(elec_conf)) elec_conf => potential%elec_conf
822 IF (PRESENT(nprj_ppnl)) nprj_ppnl => potential%nprj_ppnl
823 IF (PRESENT(cprj)) cprj => potential%cprj
824 IF (PRESENT(cprj_ppnl)) cprj_ppnl => potential%cprj_ppnl
825 IF (PRESENT(hprj_ppnl)) hprj_ppnl => potential%hprj_ppnl
826 IF (PRESENT(kprj_ppnl)) kprj_ppnl => potential%kprj_ppnl
827 IF (PRESENT(vprj_ppnl)) vprj_ppnl => potential%vprj_ppnl
828 IF (PRESENT(wprj_ppnl)) wprj_ppnl => potential%wprj_ppnl
829
830 IF (PRESENT(lpot_present)) lpot_present = potential%lpotextended
831 IF (PRESENT(nexp_lpot)) nexp_lpot = potential%nexp_lpot
832 IF (PRESENT(alpha_lpot)) alpha_lpot => potential%alpha_lpot
833 IF (PRESENT(nct_lpot)) nct_lpot => potential%nct_lpot
834 IF (PRESENT(cval_lpot)) cval_lpot => potential%cval_lpot
835
836 IF (PRESENT(lsd_present)) lsd_present = potential%lsdpot
837 IF (PRESENT(nexp_lsd)) nexp_lsd = potential%nexp_lsd
838 IF (PRESENT(alpha_lsd)) alpha_lsd => potential%alpha_lsd
839 IF (PRESENT(nct_lsd)) nct_lsd => potential%nct_lsd
840 IF (PRESENT(cval_lsd)) cval_lsd => potential%cval_lsd
841
842 IF (PRESENT(nlcc_present)) nlcc_present = potential%nlcc
843 IF (PRESENT(nexp_nlcc)) nexp_nlcc = potential%nexp_nlcc
844 IF (PRESENT(alpha_nlcc)) alpha_nlcc => potential%alpha_nlcc
845 IF (PRESENT(nct_nlcc)) nct_nlcc => potential%nct_nlcc
846 IF (PRESENT(cval_nlcc)) cval_nlcc => potential%cval_nlcc
847
848 IF (PRESENT(monovalent)) monovalent = potential%monovalent
849
850 END SUBROUTINE get_gth_potential
851
852! **************************************************************************************************
853!> \brief ...
854!> \param potential ...
855!> \param name ...
856!> \param description ...
857!> \param aliases ...
858!> \param elec_conf ...
859!> \param z ...
860!> \param zeff ...
861!> \param zeff_correction ...
862!> \param alpha_core_charge ...
863!> \param ccore_charge ...
864!> \param core_charge_radius ...
865!> \param ppl_radius ...
866!> \param ppnl_radius ...
867!> \param ppl_present ...
868!> \param ppnl_present ...
869!> \param ppsl_present ...
870!> \param ecp_local ...
871!> \param n_local ...
872!> \param a_local ...
873!> \param c_local ...
874!> \param nloc ...
875!> \param nrloc ...
876!> \param aloc ...
877!> \param bloc ...
878!> \param ecp_semi_local ...
879!> \param sl_lmax ...
880!> \param npot ...
881!> \param nrpot ...
882!> \param apot ...
883!> \param bpot ...
884!> \param n_nonlocal ...
885!> \param nppnl ...
886!> \param lmax ...
887!> \param is_nonlocal ...
888!> \param a_nonlocal ...
889!> \param h_nonlocal ...
890!> \param c_nonlocal ...
891!> \param cprj_ppnl ...
892!> \param vprj_ppnl ...
893!> \param has_nlcc ...
894!> \param n_nlcc ...
895!> \param a_nlcc ...
896!> \param c_nlcc ...
897! **************************************************************************************************
898 SUBROUTINE get_sgp_potential(potential, name, description, aliases, elec_conf, &
899 z, zeff, zeff_correction, alpha_core_charge, &
900 ccore_charge, core_charge_radius, &
901 ppl_radius, ppnl_radius, ppl_present, ppnl_present, ppsl_present, &
902 ecp_local, n_local, a_local, c_local, &
903 nloc, nrloc, aloc, bloc, &
904 ecp_semi_local, sl_lmax, npot, nrpot, apot, bpot, &
905 n_nonlocal, nppnl, lmax, is_nonlocal, a_nonlocal, h_nonlocal, c_nonlocal, &
906 cprj_ppnl, vprj_ppnl, has_nlcc, n_nlcc, a_nlcc, c_nlcc)
907
908 TYPE(sgp_potential_type), INTENT(IN) :: potential
909 CHARACTER(LEN=default_string_length), &
910 INTENT(OUT), OPTIONAL :: name
911 CHARACTER(LEN=default_string_length), &
912 DIMENSION(4), INTENT(OUT), OPTIONAL :: description
913 CHARACTER(LEN=default_string_length), &
914 INTENT(OUT), OPTIONAL :: aliases
915 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf
916 INTEGER, INTENT(OUT), OPTIONAL :: z
917 REAL(KIND=dp), INTENT(OUT), OPTIONAL :: zeff, zeff_correction, &
918 alpha_core_charge, ccore_charge, &
919 core_charge_radius, ppl_radius, &
920 ppnl_radius
921 LOGICAL, INTENT(OUT), OPTIONAL :: ppl_present, ppnl_present, ppsl_present, &
922 ecp_local
923 INTEGER, INTENT(OUT), OPTIONAL :: n_local
924 REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: a_local, c_local
925 INTEGER, INTENT(OUT), OPTIONAL :: nloc
926 INTEGER, DIMENSION(1:10), INTENT(OUT), OPTIONAL :: nrloc
927 REAL(dp), DIMENSION(1:10), INTENT(OUT), OPTIONAL :: aloc, bloc
928 LOGICAL, INTENT(OUT), OPTIONAL :: ecp_semi_local
929 INTEGER, INTENT(OUT), OPTIONAL :: sl_lmax
930 INTEGER, DIMENSION(0:10), OPTIONAL :: npot
931 INTEGER, DIMENSION(1:15, 0:10), OPTIONAL :: nrpot
932 REAL(dp), DIMENSION(1:15, 0:10), OPTIONAL :: apot, bpot
933 INTEGER, INTENT(OUT), OPTIONAL :: n_nonlocal, nppnl, lmax
934 LOGICAL, DIMENSION(0:5), OPTIONAL :: is_nonlocal
935 REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: a_nonlocal
936 REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: h_nonlocal
937 REAL(KIND=dp), DIMENSION(:, :, :), OPTIONAL, &
938 POINTER :: c_nonlocal
939 REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cprj_ppnl
940 REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: vprj_ppnl
941 LOGICAL, INTENT(OUT), OPTIONAL :: has_nlcc
942 INTEGER, INTENT(OUT), OPTIONAL :: n_nlcc
943 REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: a_nlcc, c_nlcc
944
945 IF (PRESENT(name)) name = potential%name
946 IF (PRESENT(aliases)) aliases = potential%aliases
947 IF (PRESENT(description)) description = potential%description
948
949 IF (PRESENT(elec_conf)) elec_conf => potential%elec_conf
950
951 IF (PRESENT(z)) z = potential%z
952 IF (PRESENT(zeff)) zeff = potential%zeff
953 IF (PRESENT(zeff_correction)) zeff_correction = potential%zeff_correction
954 IF (PRESENT(alpha_core_charge)) alpha_core_charge = potential%alpha_core_charge
955 IF (PRESENT(ccore_charge)) ccore_charge = potential%ccore_charge
956 IF (PRESENT(core_charge_radius)) core_charge_radius = potential%core_charge_radius
957
958 IF (PRESENT(ppl_radius)) ppl_radius = potential%ppl_radius
959 IF (PRESENT(ppnl_radius)) ppnl_radius = potential%ppnl_radius
960 IF (PRESENT(ppl_present)) THEN
961 ppl_present = (potential%nloc > 0 .OR. potential%n_local > 0)
962 END IF
963 IF (PRESENT(ppnl_present)) THEN
964 ppnl_present = any(potential%is_nonlocal)
965 END IF
966 IF (PRESENT(ppsl_present)) THEN
967 ppsl_present = potential%ecp_semi_local
968 END IF
969
970 IF (PRESENT(ecp_local)) ecp_local = potential%ecp_local
971 IF (PRESENT(n_local)) n_local = potential%n_local
972 IF (PRESENT(a_local)) a_local => potential%a_local
973 IF (PRESENT(c_local)) c_local => potential%c_local
974
975 IF (PRESENT(nloc)) nloc = potential%nloc
976 IF (PRESENT(nrloc)) nrloc = potential%nrloc
977 IF (PRESENT(aloc)) aloc = potential%aloc
978 IF (PRESENT(bloc)) bloc = potential%bloc
979
980 IF (PRESENT(ecp_semi_local)) ecp_semi_local = potential%ecp_semi_local
981 IF (PRESENT(sl_lmax)) sl_lmax = potential%sl_lmax
982 IF (PRESENT(npot)) npot = potential%npot
983 IF (PRESENT(nrpot)) nrpot = potential%nrpot
984 IF (PRESENT(apot)) apot = potential%apot
985 IF (PRESENT(bpot)) bpot = potential%bpot
986
987 IF (PRESENT(n_nonlocal)) n_nonlocal = potential%n_nonlocal
988 IF (PRESENT(nppnl)) nppnl = potential%nppnl
989 IF (PRESENT(lmax)) lmax = potential%lmax
990 IF (PRESENT(is_nonlocal)) is_nonlocal(:) = potential%is_nonlocal(:)
991 IF (PRESENT(a_nonlocal)) a_nonlocal => potential%a_nonlocal
992 IF (PRESENT(c_nonlocal)) c_nonlocal => potential%c_nonlocal
993 IF (PRESENT(h_nonlocal)) h_nonlocal => potential%h_nonlocal
994 IF (PRESENT(cprj_ppnl)) cprj_ppnl => potential%cprj_ppnl
995 IF (PRESENT(vprj_ppnl)) vprj_ppnl => potential%vprj_ppnl
996
997 IF (PRESENT(has_nlcc)) has_nlcc = potential%has_nlcc
998 IF (PRESENT(n_nlcc)) n_nlcc = potential%n_nlcc
999 IF (PRESENT(a_nlcc)) a_nlcc => potential%a_nlcc
1000 IF (PRESENT(c_nlcc)) c_nlcc => potential%c_nlcc
1001
1002 END SUBROUTINE get_sgp_potential
1003
1004! **************************************************************************************************
1005!> \brief Initialise the coefficients of the projectors of the non-local
1006!> part of the GTH pseudopotential and the transformation matrices
1007!> for Cartesian overlap integrals between the orbital basis
1008!> functions and the projector functions.
1009!> \param potential ...
1010!> \date 16.10.2000
1011!> \author MK
1012!> \version 1.0
1013! **************************************************************************************************
1014 ELEMENTAL SUBROUTINE init_cprj_ppnl(potential)
1015
1016 TYPE(gth_potential_type), INTENT(INOUT) :: potential
1017
1018 INTEGER :: cpx, cpy, cpz, cx, cy, cz, ico, iprj, &
1019 iprj_ppnl, l, lp, lprj_ppnl, nprj, px, &
1020 py, pz
1021 REAL(kind=dp) :: alpha_ppnl, cp
1022
1023 nprj = 0
1024
1025 DO l = 0, potential%lppnl
1026 alpha_ppnl = potential%alpha_ppnl(l)
1027 DO iprj_ppnl = 1, potential%nprj_ppnl(l)
1028 lp = iprj_ppnl - 1
1029 lprj_ppnl = l + 2*lp
1030 cp = sqrt(2.0_dp**(2.0_dp*real(lprj_ppnl, dp) + 3.5_dp)* &
1031 alpha_ppnl**(real(lprj_ppnl, dp) + 1.5_dp)/ &
1032 (rootpi*dfac(2*lprj_ppnl + 1)))
1033 potential%cprj_ppnl(iprj_ppnl, l) = cp
1034 DO cx = 0, l
1035 DO cy = 0, l - cx
1036 cz = l - cx - cy
1037 iprj = nprj + co(cx, cy, cz)
1038 DO px = 0, lp
1039 DO py = 0, lp - px
1040 pz = lp - px - py
1041 cpx = cx + 2*px
1042 cpy = cy + 2*py
1043 cpz = cz + 2*pz
1044 ico = coset(cpx, cpy, cpz)
1045 potential%cprj(ico, iprj) = cp*fac(lp)/(fac(px)*fac(py)*fac(pz))
1046 END DO
1047 END DO
1048 END DO
1049 END DO
1050 nprj = nprj + nco(l)
1051 END DO
1052 END DO
1053
1054 END SUBROUTINE init_cprj_ppnl
1055
1056! **************************************************************************************************
1057!> \brief Initialise a GTH potential data set structure.
1058!> \param potential ...
1059!> \date 27.10.2000
1060!> \author MK
1061!> \version 1.0
1062! **************************************************************************************************
1063 SUBROUTINE init_gth_potential(potential)
1064
1065 TYPE(gth_potential_type), INTENT(IN), POINTER :: potential
1066
1067 IF (.NOT. ASSOCIATED(potential)) RETURN
1068
1069 IF (potential%nppnl > 0) THEN
1070
1071 ! Initialise the projector coefficients of the non-local part of the GTH pseudopotential
1072 ! and the transformation matrices "pgf" -> "prj_ppnl"
1073 CALL init_cprj_ppnl(potential)
1074
1075 ! Initialise the h(i,j) projector coefficients of the non-local part of the
1076 ! GTH pseudopotential
1077 CALL init_vprj_ppnl(potential)
1078
1079 END IF
1080
1081 END SUBROUTINE init_gth_potential
1082
1083! **************************************************************************************************
1084!> \brief Initialise the h(i,j) projector coefficients of the non-local part
1085!> of the GTH pseudopotential (and k(i,j) for SOC, see Hartwigsen, Goedecker, Hutter, PRB 1998).
1086!> \param potential ...
1087!> \date 24.10.2000
1088!> \author MK
1089!> \version 1.0
1090! **************************************************************************************************
1091 ELEMENTAL SUBROUTINE init_vprj_ppnl(potential)
1092
1093 TYPE(gth_potential_type), INTENT(INOUT) :: potential
1094
1095 INTEGER :: i, ico, iprj, iprj_ppnl, iso, j, jco, &
1096 jprj, jprj_ppnl, l, nprj
1097
1098 nprj = 0
1099
1100 DO l = 0, potential%lppnl
1101 DO iprj_ppnl = 1, potential%nprj_ppnl(l)
1102 iprj = nprj + (iprj_ppnl - 1)*nco(l)
1103 DO jprj_ppnl = 1, potential%nprj_ppnl(l)
1104 jprj = nprj + (jprj_ppnl - 1)*nco(l)
1105 DO ico = 1, nco(l)
1106 i = iprj + ico
1107 DO jco = 1, nco(l)
1108 j = jprj + jco
1109 DO iso = 1, nso(l)
1110 potential%vprj_ppnl(i, j) = potential%vprj_ppnl(i, j) + &
1111 orbtramat(l)%slm(iso, ico)* &
1112 potential%hprj_ppnl(iprj_ppnl, &
1113 jprj_ppnl, l)* &
1114 orbtramat(l)%slm(iso, jco)
1115 IF (potential%soc) THEN
1116 ! Transform spin-orbit part
1117 potential%wprj_ppnl(i, j) = potential%wprj_ppnl(i, j) + &
1118 orbtramat(l)%slm(iso, ico)* &
1119 potential%kprj_ppnl(iprj_ppnl, &
1120 jprj_ppnl, l)* &
1121 orbtramat(l)%slm(iso, jco)
1122 END IF
1123 END DO
1124 END DO
1125 END DO
1126 END DO
1127 END DO
1128 nprj = nprj + potential%nprj_ppnl(l)*nco(l)
1129 END DO
1130
1131 END SUBROUTINE init_vprj_ppnl
1132
1133! **************************************************************************************************
1134!> \brief ...
1135!> \param potential ...
1136!> \param itype ...
1137!> \param zeff ...
1138!> \param zeff_correction ...
1139! **************************************************************************************************
1140 PURE SUBROUTINE init_all_potential(potential, itype, zeff, zeff_correction)
1141
1142 TYPE(all_potential_type), INTENT(INOUT), POINTER :: potential
1143 CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: itype
1144 REAL(kind=dp), INTENT(IN), OPTIONAL :: zeff, zeff_correction
1145
1146 INTEGER :: dz
1147
1148 IF (.NOT. ASSOCIATED(potential)) RETURN
1149
1150 IF (PRESENT(zeff)) potential%zeff = zeff
1151 IF (PRESENT(zeff_correction)) potential%zeff_correction = zeff_correction
1152 dz = potential%z - int(potential%zeff - potential%zeff_correction)
1153 SELECT CASE (dz)
1154 CASE DEFAULT
1155 CASE (2)
1156 potential%elec_conf(0) = potential%elec_conf(0) - 2
1157 CASE (10)
1158 potential%elec_conf(0) = potential%elec_conf(0) - 4
1159 potential%elec_conf(1) = potential%elec_conf(1) - 6
1160 CASE (18)
1161 potential%elec_conf(0) = potential%elec_conf(0) - 6
1162 potential%elec_conf(1) = potential%elec_conf(1) - 12
1163 CASE (28)
1164 potential%elec_conf(0) = potential%elec_conf(0) - 6
1165 potential%elec_conf(1) = potential%elec_conf(1) - 12
1166 potential%elec_conf(2) = potential%elec_conf(2) - 10
1167 CASE (30)
1168 potential%elec_conf(0) = potential%elec_conf(0) - 8
1169 potential%elec_conf(1) = potential%elec_conf(1) - 12
1170 potential%elec_conf(2) = potential%elec_conf(2) - 10
1171 CASE (36)
1172 potential%elec_conf(0) = potential%elec_conf(0) - 8
1173 potential%elec_conf(1) = potential%elec_conf(1) - 18
1174 potential%elec_conf(2) = potential%elec_conf(2) - 10
1175 CASE (46)
1176 potential%elec_conf(0) = potential%elec_conf(0) - 8
1177 potential%elec_conf(1) = potential%elec_conf(1) - 18
1178 potential%elec_conf(2) = potential%elec_conf(2) - 20
1179 CASE (48)
1180 potential%elec_conf(0) = potential%elec_conf(0) - 10
1181 potential%elec_conf(1) = potential%elec_conf(1) - 18
1182 potential%elec_conf(2) = potential%elec_conf(2) - 20
1183 CASE (54)
1184 potential%elec_conf(0) = potential%elec_conf(0) - 10
1185 potential%elec_conf(1) = potential%elec_conf(1) - 24
1186 potential%elec_conf(2) = potential%elec_conf(2) - 20
1187 CASE (68)
1188 potential%elec_conf(0) = potential%elec_conf(0) - 10
1189 potential%elec_conf(1) = potential%elec_conf(1) - 24
1190 potential%elec_conf(2) = potential%elec_conf(2) - 20
1191 potential%elec_conf(3) = potential%elec_conf(3) - 14
1192 CASE (78)
1193 potential%elec_conf(0) = potential%elec_conf(0) - 10
1194 potential%elec_conf(1) = potential%elec_conf(1) - 24
1195 potential%elec_conf(2) = potential%elec_conf(2) - 30
1196 potential%elec_conf(3) = potential%elec_conf(3) - 14
1197 CASE (80)
1198 potential%elec_conf(0) = potential%elec_conf(0) - 12
1199 potential%elec_conf(1) = potential%elec_conf(1) - 24
1200 potential%elec_conf(2) = potential%elec_conf(2) - 30
1201 potential%elec_conf(3) = potential%elec_conf(3) - 14
1202 CASE (86)
1203 potential%elec_conf(0) = potential%elec_conf(0) - 12
1204 potential%elec_conf(1) = potential%elec_conf(1) - 30
1205 potential%elec_conf(2) = potential%elec_conf(2) - 30
1206 potential%elec_conf(3) = potential%elec_conf(3) - 14
1207 CASE (100)
1208 potential%elec_conf(0) = potential%elec_conf(0) - 12
1209 potential%elec_conf(1) = potential%elec_conf(1) - 30
1210 potential%elec_conf(2) = potential%elec_conf(2) - 30
1211 potential%elec_conf(3) = potential%elec_conf(3) - 28
1212 END SELECT
1213
1214 IF (PRESENT(itype)) THEN
1215 IF (itype == "BARE") THEN
1216 potential%description(1) = "Bare Coulomb Potential"
1217 IF (dz > 0) THEN
1218 potential%description(2) = "Valence charge only"
1219 ELSE
1220 potential%description(2) = "Full atomic charge"
1221 END IF
1222 END IF
1223 END IF
1224
1225 END SUBROUTINE init_all_potential
1226! **************************************************************************************************
1227!> \brief Initialise a SGP potential data set structure.
1228!> \param potential ...
1229!> \version 1.0
1230! **************************************************************************************************
1231 SUBROUTINE init_sgp_potential(potential)
1232 TYPE(sgp_potential_type), INTENT(IN), POINTER :: potential
1233
1234 INTEGER :: i1, i2, j1, j2, l, la, lb, n1, n2, nnl, &
1235 nprj
1236 INTEGER, ALLOCATABLE, DIMENSION(:, :) :: ind1, ind2
1237 REAL(KIND=dp), DIMENSION(:, :), POINTER :: cprj, hnl
1238 REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: cn
1239
1240 IF (ASSOCIATED(potential)) THEN
1241 IF (ALLOCATED(potential%upf_data)) THEN
1242 potential%nppnl = 0
1243 IF (potential%upf_data%number_of_proj > 0) THEN
1244 IF (potential%upf_projectors%degree < 0) THEN
1245 CALL upf_projector_init(potential%upf_data, 0, potential%upf_projectors)
1246 END IF
1247 potential%nppnl = potential%upf_projectors%nproj
1248 END IF
1249 RETURN
1250 END IF
1251 IF (potential%nppnl > 0) THEN
1252 !
1253 IF (ASSOCIATED(potential%cprj_ppnl)) THEN
1254 DEALLOCATE (potential%cprj_ppnl)
1255 END IF
1256 nnl = potential%n_nonlocal
1257 nprj = 0
1258 DO l = 0, potential%lmax
1259 nprj = nprj + nnl*nso(l)
1260 END DO
1261 ALLOCATE (potential%cprj_ppnl(potential%nppnl, nprj))
1262 cprj => potential%cprj_ppnl
1263 cprj = 0.0_dp
1264 cn => potential%c_nonlocal
1265 !
1266 ALLOCATE (ind1(potential%nppnl, 3))
1267 n1 = 0
1268 DO i1 = 1, nnl
1269 DO la = 0, potential%lmax
1270 DO j1 = 1, nco(la)
1271 n1 = n1 + 1
1272 ind1(n1, 1) = la
1273 ind1(n1, 2) = j1
1274 ind1(n1, 3) = i1
1275 END DO
1276 END DO
1277 END DO
1278 !
1279 ALLOCATE (ind2(nprj, 3))
1280 n2 = 0
1281 DO i2 = 1, nnl
1282 DO lb = 0, potential%lmax
1283 DO j2 = 1, nso(lb)
1284 n2 = n2 + 1
1285 ind2(n2, 1) = lb
1286 ind2(n2, 2) = j2
1287 ind2(n2, 3) = i2
1288 END DO
1289 END DO
1290 END DO
1291 !
1292 DO n1 = 1, SIZE(ind1, 1)
1293 la = ind1(n1, 1)
1294 j1 = ind1(n1, 2)
1295 i1 = ind1(n1, 3)
1296 DO n2 = 1, SIZE(ind2, 1)
1297 lb = ind2(n2, 1)
1298 IF (la /= lb) cycle
1299 j2 = ind2(n2, 2)
1300 i2 = ind2(n2, 3)
1301 ! Primitive overlap integrals contain unnormalized Cartesian
1302 ! monomials. SGP radial coefficients include 1/sqrt(4*pi),
1303 ! whereas slm supplies unit-normalized real solid harmonics.
1304 cprj(n1, n2) = sqrt(fourpi)*orbtramat(la)%slm(j2, j1)*cn(i1, i2, la)
1305 END DO
1306 END DO
1307 !
1308 hnl => potential%h_nonlocal
1309 IF (ASSOCIATED(potential%vprj_ppnl)) THEN
1310 DEALLOCATE (potential%vprj_ppnl)
1311 END IF
1312 ALLOCATE (potential%vprj_ppnl(nprj))
1313 potential%vprj_ppnl = 0.0_dp
1314 DO n2 = 1, SIZE(ind2, 1)
1315 lb = ind2(n2, 1)
1316 i2 = ind2(n2, 3)
1317 potential%vprj_ppnl(n2) = hnl(i2, lb)
1318 END DO
1319 !
1320 DEALLOCATE (ind1, ind2)
1321 END IF
1322 END IF
1323
1324 END SUBROUTINE init_sgp_potential
1325
1326! **************************************************************************************************
1327!> \brief Read an atomic all-electron potential data set.
1328!> \param element_symbol ...
1329!> \param potential_name ...
1330!> \param potential ...
1331!> \param zeff_correction ...
1332!> \param para_env ...
1333!> \param potential_file_name ...
1334!> \param potential_section ...
1335!> \param update_input ...
1336!> \param potential_found ...
1337!> \date 14.05.2000
1338!> \author MK
1339!> \version 1.0
1340! **************************************************************************************************
1341 SUBROUTINE read_all_potential(element_symbol, potential_name, potential, zeff_correction, &
1342 para_env, potential_file_name, potential_section, update_input, &
1343 potential_found)
1344
1345 CHARACTER(LEN=*), INTENT(IN) :: element_symbol, potential_name
1346 TYPE(all_potential_type), INTENT(INOUT) :: potential
1347 REAL(KIND=dp), INTENT(IN) :: zeff_correction
1348 TYPE(mp_para_env_type), INTENT(IN), POINTER :: para_env
1349 CHARACTER(LEN=default_path_length), INTENT(IN) :: potential_file_name
1350 TYPE(section_vals_type), INTENT(IN), POINTER :: potential_section
1351 LOGICAL, INTENT(IN) :: update_input
1352 LOGICAL, INTENT(OUT), OPTIONAL :: potential_found
1353
1354 CHARACTER(LEN=240) :: line
1355 CHARACTER(LEN=242) :: line2
1356 CHARACTER(LEN=5*default_string_length) :: line_att
1357 CHARACTER(LEN=LEN(element_symbol)) :: symbol
1358 CHARACTER(LEN=LEN(element_symbol)+2) :: symbol2
1359 CHARACTER(LEN=LEN(potential_name)) :: apname
1360 CHARACTER(LEN=LEN(potential_name)+2) :: apname2
1361 INTEGER :: irep, l, strlen1, strlen2
1362 INTEGER, DIMENSION(:), POINTER :: elec_conf
1363 LOGICAL :: found, is_ok, match, read_from_input
1364 REAL(KIND=dp) :: alpha, r
1365 TYPE(cp_parser_type), POINTER :: parser
1366 TYPE(cp_sll_val_type), POINTER :: list
1367 TYPE(val_type), POINTER :: val
1368
1369 line2 = ""
1370 symbol2 = ""
1371 apname2 = ""
1372 NULLIFY (parser)
1373 CALL cite_reference(krack2000)
1374
1375 IF (PRESENT(potential_found)) potential_found = .false.
1376
1377 potential%name = potential_name
1378 read_from_input = .false.
1379 CALL section_vals_get(potential_section, explicit=read_from_input)
1380 IF (.NOT. read_from_input) THEN
1381 ALLOCATE (parser)
1382 CALL parser_create(parser, potential_file_name, para_env=para_env)
1383 END IF
1384
1385 ! Search for the requested potential in the potential file
1386 ! until the potential is found or the end of file is reached
1387
1388 apname = potential_name
1389 symbol = element_symbol
1390 irep = 0
1391 search_loop: DO
1392 IF (read_from_input) THEN
1393 NULLIFY (list, val)
1394 found = .true.
1395 CALL section_vals_list_get(potential_section, "_DEFAULT_KEYWORD_", list=list)
1396 ELSE
1397 CALL parser_search_string(parser, trim(apname), .true., found, line)
1398 END IF
1399 IF (found) THEN
1400 CALL uppercase(symbol)
1401 CALL uppercase(apname)
1402
1403 IF (read_from_input) THEN
1404 match = .true.
1405 ELSE
1406 ! Check both the element symbol and the atomic potential name
1407 match = .false.
1408 CALL uppercase(line)
1409 line2 = " "//line//" "
1410 symbol2 = " "//trim(symbol)//" "
1411 apname2 = " "//trim(apname)//" "
1412 strlen1 = len_trim(symbol2) + 1
1413 strlen2 = len_trim(apname2) + 1
1414
1415 IF ((index(line2, symbol2(:strlen1)) > 0) .AND. &
1416 (index(line2, apname2(:strlen2)) > 0)) match = .true.
1417 END IF
1418 IF (match) THEN
1419 ! Read the electronic configuration
1420 NULLIFY (elec_conf)
1421 l = 0
1422 CALL reallocate(elec_conf, 0, l)
1423 IF (read_from_input) THEN
1424 is_ok = cp_sll_val_next(list, val)
1425 IF (.NOT. is_ok) THEN
1426 CALL cp_abort(__location__, &
1427 "Error reading the Potential from input file!")
1428 END IF
1429 CALL val_get(val, c_val=line_att)
1430 READ (line_att, *) elec_conf(l)
1431 CALL remove_word(line_att)
1432 DO WHILE (len_trim(line_att) /= 0)
1433 l = l + 1
1434 CALL reallocate(elec_conf, 0, l)
1435 READ (line_att, *) elec_conf(l)
1436 CALL remove_word(line_att)
1437 END DO
1438 ELSE
1439 CALL parser_get_object(parser, elec_conf(l), newline=.true.)
1440 DO WHILE (parser_test_next_token(parser) == "INT")
1441 l = l + 1
1442 CALL reallocate(elec_conf, 0, l)
1443 CALL parser_get_object(parser, elec_conf(l))
1444 END DO
1445 irep = irep + 1
1446 IF (update_input) THEN
1447 WRITE (unit=line_att, fmt="(T8,*(1X,I0))") elec_conf(:)
1448 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1449 c_val=trim(line_att))
1450 END IF
1451 END IF
1452
1453 CALL reallocate(potential%elec_conf, 0, l)
1454 potential%elec_conf(:) = elec_conf(:)
1455
1456 potential%zeff_correction = zeff_correction
1457 potential%zeff = real(sum(elec_conf), dp) + zeff_correction
1458
1459 DEALLOCATE (elec_conf)
1460
1461 ! Read r(loc) to define the exponent of the core charge
1462 ! distribution and calculate the corresponding coefficient
1463
1464 IF (read_from_input) THEN
1465 is_ok = cp_sll_val_next(list, val)
1466 IF (.NOT. is_ok) THEN
1467 CALL cp_abort(__location__, &
1468 "Error reading the Potential from input file!")
1469 END IF
1470 CALL val_get(val, c_val=line_att)
1471 READ (line_att, *) r
1472 ELSE
1473 CALL parser_get_object(parser, r, newline=.true.)
1474 irep = irep + 1
1475 IF (update_input) THEN
1476 WRITE (unit=line_att, fmt="(T9,ES25.16E3)") r
1477 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1478 c_val=trim(line_att))
1479 END IF
1480 END IF
1481 alpha = 1.0_dp/(2.0_dp*r**2)
1482
1483 potential%alpha_core_charge = alpha
1484 potential%ccore_charge = potential%zeff*sqrt((alpha/pi)**3)
1485
1486 EXIT search_loop
1487 END IF
1488 ELSE
1489 ! Stop program, if the end of file is reached
1490 IF (PRESENT(potential_found)) THEN
1491 CALL parser_release(parser)
1492 DEALLOCATE (parser)
1493 RETURN
1494 END IF
1495 CALL cp_abort(__location__, &
1496 "The requested atomic potential <"// &
1497 trim(potential_name)// &
1498 "> for element <"// &
1499 trim(symbol)// &
1500 "> was not found in the potential file <"// &
1501 trim(potential_file_name)//">")
1502 END IF
1503 END DO search_loop
1504
1505 IF (PRESENT(potential_found)) potential_found = .true.
1506
1507 IF (.NOT. read_from_input) THEN
1508 ! Dump the potential info in the potential section
1509 IF (match .AND. update_input) THEN
1510 irep = irep + 1
1511 WRITE (unit=line_att, fmt="(T9,A)") &
1512 "# Potential name: "//trim(adjustl(apname2(:strlen2)))// &
1513 " for element symbol: "//trim(adjustl(symbol2(:strlen1)))
1514 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1515 c_val=trim(line_att))
1516 irep = irep + 1
1517 WRITE (unit=line_att, fmt="(T9,A)") &
1518 "# Potential read from the potential filename: "//trim(adjustl(potential_file_name))
1519 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1520 c_val=trim(line_att))
1521 END IF
1522 CALL parser_release(parser)
1523 DEALLOCATE (parser)
1524 END IF
1525
1526 END SUBROUTINE read_all_potential
1527
1528! **************************************************************************************************
1529!> \brief Read an all-electron potential from an ordered list of library files.
1530!> \param element_symbol ...
1531!> \param potential_name ...
1532!> \param potential ...
1533!> \param zeff_correction ...
1534!> \param para_env ...
1535!> \param potential_file_names ...
1536!> \param potential_section ...
1537!> \param update_input ...
1538! **************************************************************************************************
1539 SUBROUTINE read_all_potential_files(element_symbol, potential_name, potential, zeff_correction, &
1540 para_env, potential_file_names, potential_section, update_input)
1541
1542 CHARACTER(LEN=*), INTENT(IN) :: element_symbol, potential_name
1543 TYPE(all_potential_type), INTENT(INOUT) :: potential
1544 REAL(KIND=dp), INTENT(IN) :: zeff_correction
1545 TYPE(mp_para_env_type), INTENT(IN), POINTER :: para_env
1546 CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: potential_file_names
1547 TYPE(section_vals_type), INTENT(IN), POINTER :: potential_section
1548 LOGICAL, INTENT(IN) :: update_input
1549
1550 INTEGER :: i
1551 LOGICAL :: potential_found
1552
1553 DO i = 1, SIZE(potential_file_names)
1554 CALL read_all_potential(element_symbol, potential_name, potential, zeff_correction, &
1555 para_env, potential_file_names(i), potential_section, update_input, &
1556 potential_found)
1557 IF (potential_found) RETURN
1558 END DO
1559 CALL potential_files_not_found(element_symbol, potential_name, potential_file_names)
1560
1561 END SUBROUTINE read_all_potential_files
1562
1563! **************************************************************************************************
1564!> \brief Read an atomic local potential data set.
1565!> \param element_symbol ...
1566!> \param potential_name ...
1567!> \param potential ...
1568!> \param para_env ...
1569!> \param potential_file_name ...
1570!> \param potential_section ...
1571!> \param update_input ...
1572!> \param potential_found ...
1573!> \date 24.12.2014
1574!> \author JGH
1575!> \version 1.0
1576! **************************************************************************************************
1577 SUBROUTINE read_local_potential(element_symbol, potential_name, potential, &
1578 para_env, potential_file_name, potential_section, update_input, &
1579 potential_found)
1580
1581 CHARACTER(LEN=*), INTENT(IN) :: element_symbol, potential_name
1582 TYPE(local_potential_type), INTENT(INOUT) :: potential
1583 TYPE(mp_para_env_type), INTENT(IN), POINTER :: para_env
1584 CHARACTER(LEN=default_path_length), INTENT(IN) :: potential_file_name
1585 TYPE(section_vals_type), INTENT(IN), POINTER :: potential_section
1586 LOGICAL, INTENT(IN) :: update_input
1587 LOGICAL, INTENT(OUT), OPTIONAL :: potential_found
1588
1589 REAL(KIND=dp), PARAMETER :: eps_tpot = 1.0e-10_dp
1590
1591 CHARACTER(LEN=240) :: line
1592 CHARACTER(LEN=242) :: line2
1593 CHARACTER(LEN=5*default_string_length) :: line_att
1594 CHARACTER(LEN=LEN(element_symbol)) :: symbol
1595 CHARACTER(LEN=LEN(element_symbol)+2) :: symbol2
1596 CHARACTER(LEN=LEN(potential_name)) :: apname
1597 CHARACTER(LEN=LEN(potential_name)+2) :: apname2
1598 INTEGER :: igau, ipol, irep, l, ngau, npol, &
1599 strlen1, strlen2
1600 LOGICAL :: found, is_ok, match, read_from_input
1601 REAL(KIND=dp), DIMENSION(:), POINTER :: alpha
1602 REAL(KIND=dp), DIMENSION(:, :), POINTER :: cval
1603 TYPE(cp_parser_type), POINTER :: parser
1604 TYPE(cp_sll_val_type), POINTER :: list
1605 TYPE(val_type), POINTER :: val
1606
1607 line2 = ""
1608 symbol2 = ""
1609 apname2 = ""
1610 NULLIFY (parser, alpha, cval)
1611
1612 IF (PRESENT(potential_found)) potential_found = .false.
1613
1614 potential%name = potential_name
1615 read_from_input = .false.
1616 CALL section_vals_get(potential_section, explicit=read_from_input)
1617 IF (.NOT. read_from_input) THEN
1618 ALLOCATE (parser)
1619 CALL parser_create(parser, potential_file_name, para_env=para_env)
1620 END IF
1621
1622 ! Search for the requested potential in the potential file
1623 ! until the potential is found or the end of file is reached
1624
1625 apname = potential_name
1626 symbol = element_symbol
1627 irep = 0
1628 search_loop: DO
1629 IF (read_from_input) THEN
1630 NULLIFY (list, val)
1631 found = .true.
1632 CALL section_vals_list_get(potential_section, "_DEFAULT_KEYWORD_", list=list)
1633 ELSE
1634 CALL parser_search_string(parser, trim(apname), .true., found, line)
1635 END IF
1636 IF (found) THEN
1637 CALL uppercase(symbol)
1638 CALL uppercase(apname)
1639
1640 IF (read_from_input) THEN
1641 match = .true.
1642 ELSE
1643 ! Check both the element symbol and the atomic potential name
1644 match = .false.
1645 CALL uppercase(line)
1646 line2 = " "//line//" "
1647 symbol2 = " "//trim(symbol)//" "
1648 apname2 = " "//trim(apname)//" "
1649 strlen1 = len_trim(symbol2) + 1
1650 strlen2 = len_trim(apname2) + 1
1651
1652 IF ((index(line2, symbol2(:strlen1)) > 0) .AND. &
1653 (index(line2, apname2(:strlen2)) > 0)) match = .true.
1654 END IF
1655 IF (match) THEN
1656
1657 ! Read ngau and npol
1658 IF (read_from_input) THEN
1659 is_ok = cp_sll_val_next(list, val)
1660 IF (.NOT. is_ok) THEN
1661 CALL cp_abort(__location__, &
1662 "Error reading the Potential from input file!")
1663 END IF
1664 CALL val_get(val, c_val=line_att)
1665 READ (line_att, *) ngau, npol
1666 CALL remove_word(line_att)
1667 ELSE
1668 CALL parser_get_object(parser, ngau, newline=.true.)
1669 CALL parser_get_object(parser, npol)
1670 irep = irep + 1
1671 IF (update_input) THEN
1672 WRITE (unit=line_att, fmt="(2(1X,I0))") ngau, npol
1673 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1674 c_val=trim(line_att))
1675 END IF
1676 END IF
1677
1678 CALL reallocate(alpha, 1, ngau)
1679 CALL reallocate(cval, 1, ngau, 1, npol)
1680 DO igau = 1, ngau
1681 IF (read_from_input) THEN
1682 is_ok = cp_sll_val_next(list, val)
1683 IF (.NOT. is_ok) THEN
1684 CALL cp_abort(__location__, &
1685 "Error reading the Potential from input file!")
1686 END IF
1687 CALL val_get(val, c_val=line_att)
1688 READ (line_att, *) alpha(igau), (cval(igau, ipol), ipol=1, npol)
1689 ELSE
1690 CALL parser_get_object(parser, alpha(igau), newline=.true.)
1691 DO ipol = 1, npol
1692 CALL parser_get_object(parser, cval(igau, ipol), newline=.false.)
1693 END DO
1694 irep = irep + 1
1695 IF (update_input) THEN
1696 WRITE (unit=line_att, fmt="(*(ES25.16E3))") alpha(igau), (cval(igau, ipol), ipol=1, npol)
1697 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1698 c_val=trim(line_att))
1699 END IF
1700 END IF
1701 END DO
1702 alpha = 1.0_dp/(2.0_dp*alpha**2)
1703
1704 potential%ngau = ngau
1705 potential%npol = npol
1706
1707 potential%alpha => alpha
1708 potential%cval => cval
1709
1710 potential%radius = 0.0_dp
1711 DO igau = 1, ngau
1712 DO ipol = 1, npol
1713 l = 2*(ipol - 1)
1714 potential%radius = max(potential%radius, &
1715 exp_radius(l, alpha(igau), eps_tpot, cval(igau, ipol), &
1716 rlow=potential%radius))
1717 END DO
1718 END DO
1719
1720 EXIT search_loop
1721 END IF
1722 ELSE
1723 ! Stop program, if the end of file is reached
1724 IF (PRESENT(potential_found)) THEN
1725 CALL parser_release(parser)
1726 DEALLOCATE (parser)
1727 RETURN
1728 END IF
1729 CALL cp_abort(__location__, &
1730 "The requested local atomic potential <"// &
1731 trim(potential_name)// &
1732 "> for element <"// &
1733 trim(symbol)// &
1734 "> was not found in the potential file <"// &
1735 trim(potential_file_name)//">")
1736 END IF
1737 END DO search_loop
1738
1739 IF (PRESENT(potential_found)) potential_found = .true.
1740
1741 IF (.NOT. read_from_input) THEN
1742 ! Dump the potential info in the potential section
1743 IF (match .AND. update_input) THEN
1744 irep = irep + 1
1745 WRITE (unit=line_att, fmt="(A)") &
1746 "# Potential name: "//trim(adjustl(apname2(:strlen2)))// &
1747 " for element symbol: "//trim(adjustl(symbol2(:strlen1)))
1748 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1749 c_val=trim(line_att))
1750 irep = irep + 1
1751 WRITE (unit=line_att, fmt="(A)") &
1752 "# Potential read from the potential filename: "//trim(adjustl(potential_file_name))
1753 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1754 c_val=trim(line_att))
1755 END IF
1756 CALL parser_release(parser)
1757 DEALLOCATE (parser)
1758 END IF
1759
1760 END SUBROUTINE read_local_potential
1761
1762! **************************************************************************************************
1763!> \brief Read a local potential from an ordered list of library files.
1764!> \param element_symbol ...
1765!> \param potential_name ...
1766!> \param potential ...
1767!> \param para_env ...
1768!> \param potential_file_names ...
1769!> \param potential_section ...
1770!> \param update_input ...
1771! **************************************************************************************************
1772 SUBROUTINE read_local_potential_files(element_symbol, potential_name, potential, &
1773 para_env, potential_file_names, potential_section, update_input)
1774
1775 CHARACTER(LEN=*), INTENT(IN) :: element_symbol, potential_name
1776 TYPE(local_potential_type), INTENT(INOUT) :: potential
1777 TYPE(mp_para_env_type), INTENT(IN), POINTER :: para_env
1778 CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: potential_file_names
1779 TYPE(section_vals_type), INTENT(IN), POINTER :: potential_section
1780 LOGICAL, INTENT(IN) :: update_input
1781
1782 INTEGER :: i
1783 LOGICAL :: potential_found
1784
1785 DO i = 1, SIZE(potential_file_names)
1786 CALL read_local_potential(element_symbol, potential_name, potential, para_env, &
1787 potential_file_names(i), potential_section, update_input, potential_found)
1788 IF (potential_found) RETURN
1789 END DO
1790 CALL potential_files_not_found(element_symbol, potential_name, potential_file_names)
1791
1792 END SUBROUTINE read_local_potential_files
1793
1794! **************************************************************************************************
1795!> \brief Read an atomic GTH potential data set.
1796!> \param element_symbol ...
1797!> \param potential_name ...
1798!> \param potential ...
1799!> \param zeff_correction ...
1800!> \param para_env ...
1801!> \param potential_file_name ...
1802!> \param potential_section ...
1803!> \param update_input ...
1804!> \param monovalent ...
1805!> \param potential_found ...
1806!> \date 14.05.2000
1807!> \par Literature
1808!> - S. Goedecker, M. Teter and J. Hutter,
1809!> Phys. Rev. B 54, 1703 (1996)
1810!> - C. Hartwigsen, S. Goedecker and J. Hutter,
1811!> Phys. Rev. B 58, 3641 (1998)
1812!> \par History
1813!> - Add SOC key (27.06.2023, MK)
1814!> \author MK
1815!> \version 1.0
1816! **************************************************************************************************
1817 SUBROUTINE read_gth_potential(element_symbol, potential_name, potential, zeff_correction, &
1818 para_env, potential_file_name, potential_section, update_input, &
1819 monovalent, potential_found)
1820
1821 CHARACTER(LEN=*), INTENT(IN) :: element_symbol, potential_name
1822 TYPE(gth_potential_type), INTENT(INOUT) :: potential
1823 REAL(KIND=dp), INTENT(IN) :: zeff_correction
1824 TYPE(mp_para_env_type), INTENT(IN), POINTER :: para_env
1825 CHARACTER(LEN=default_path_length), INTENT(IN) :: potential_file_name
1826 TYPE(section_vals_type), INTENT(IN), POINTER :: potential_section
1827 LOGICAL, INTENT(IN) :: update_input
1828 LOGICAL, INTENT(IN), OPTIONAL :: monovalent
1829 LOGICAL, INTENT(OUT), OPTIONAL :: potential_found
1830
1831 CHARACTER(LEN=240) :: line
1832 CHARACTER(LEN=242) :: line2
1833 CHARACTER(LEN=5*default_string_length) :: line_att
1834 CHARACTER(LEN=LEN(element_symbol)) :: symbol
1835 CHARACTER(LEN=LEN(element_symbol)+2) :: symbol2
1836 CHARACTER(LEN=LEN(potential_name)) :: apname
1837 CHARACTER(LEN=LEN(potential_name)+2) :: apname2
1838 INTEGER :: i, ic, ipot, irep, istr, j, l, lppnl, &
1839 lprj_ppnl_max, maxlppl, n, nppnl, &
1840 nprj_ppnl, nprj_ppnl_max, strlen1, &
1841 strlen2
1842 INTEGER, DIMENSION(:), POINTER :: elec_conf
1843 LOGICAL :: found, is_ok, match, read_from_input
1844 REAL(KIND=dp) :: alpha, ci, r, rc2
1845 REAL(KIND=dp), DIMENSION(:), POINTER :: tmp_vals
1846 REAL(KIND=dp), DIMENSION(:, :, :), POINTER :: hprj_ppnl, kprj_ppnl
1847 TYPE(cp_parser_type), POINTER :: parser
1848 TYPE(cp_sll_val_type), POINTER :: list
1849 TYPE(val_type), POINTER :: val
1850
1851 line2 = ""
1852 symbol2 = ""
1853 apname2 = ""
1854 NULLIFY (parser, tmp_vals)
1855 CALL cite_reference(goedecker1996)
1856 CALL cite_reference(hartwigsen1998)
1857 CALL cite_reference(krack2005)
1858
1859 IF (PRESENT(potential_found)) potential_found = .false.
1860
1861 potential%monovalent = .false.
1862 IF (PRESENT(monovalent)) potential%monovalent = monovalent
1863
1864 potential%name = potential_name
1865 potential%aliases = potential_name
1866 read_from_input = .false.
1867 CALL section_vals_get(potential_section, explicit=read_from_input)
1868 IF (.NOT. read_from_input) THEN
1869 ALLOCATE (parser)
1870 CALL parser_create(parser, potential_file_name, para_env=para_env)
1871 END IF
1872
1873 ! Initialize extended form
1874 potential%lpotextended = .false.
1875 potential%nexp_lpot = 0
1876 potential%lsdpot = .false.
1877 potential%nexp_lsd = 0
1878 potential%nlcc = .false.
1879 potential%nexp_nlcc = 0
1880
1881 ! Search for the requested potential in the potential file
1882 ! until the potential is found or the end of file is reached
1883 apname = potential_name
1884 symbol = element_symbol
1885 irep = 0
1886 search_loop: DO
1887 IF (read_from_input) THEN
1888 NULLIFY (list, val)
1889 found = .true.
1890 CALL section_vals_list_get(potential_section, "_DEFAULT_KEYWORD_", list=list)
1891 ELSE
1892 CALL parser_search_string(parser, trim(apname), .true., found, line)
1893 END IF
1894 IF (found) THEN
1895 CALL uppercase(symbol)
1896 CALL uppercase(apname)
1897 IF (read_from_input) THEN
1898 match = .true.
1899 ELSE
1900 ! Check both the element symbol and the atomic potential name
1901 match = .false.
1902 CALL uppercase(line)
1903 line2 = " "//line//" "
1904 symbol2 = " "//trim(symbol)//" "
1905 apname2 = " "//trim(apname)//" "
1906 strlen1 = len_trim(symbol2) + 1
1907 strlen2 = len_trim(apname2) + 1
1908 i = index(line2, symbol2(:strlen1))
1909 j = index(line2, apname2(:strlen2))
1910 IF (i > 0 .AND. j > 0) THEN
1911 match = .true.
1912 i = i + 1 + index(line2(i + 1:), " ")
1913 potential%aliases = line2(i:) ! copy all names into aliases field
1914 END IF
1915 END IF
1916 IF (match) THEN
1917 ! Read the electronic configuration
1918 NULLIFY (elec_conf)
1919 l = 0
1920 CALL reallocate(elec_conf, 0, l)
1921 IF (read_from_input) THEN
1922 is_ok = cp_sll_val_next(list, val)
1923 IF (.NOT. is_ok) THEN
1924 CALL cp_abort(__location__, &
1925 "Error while reading GTH potential from input file")
1926 END IF
1927 CALL val_get(val, c_val=line_att)
1928 READ (line_att, *) elec_conf(l)
1929 CALL remove_word(line_att)
1930 DO WHILE (len_trim(line_att) /= 0)
1931 l = l + 1
1932 CALL reallocate(elec_conf, 0, l)
1933 READ (line_att, *) elec_conf(l)
1934 CALL remove_word(line_att)
1935 END DO
1936 ELSE
1937 CALL parser_get_object(parser, elec_conf(l), newline=.true.)
1938 DO WHILE (parser_test_next_token(parser) == "INT")
1939 l = l + 1
1940 CALL reallocate(elec_conf, 0, l)
1941 CALL parser_get_object(parser, elec_conf(l))
1942 END DO
1943 irep = irep + 1
1944 IF (update_input) THEN
1945 WRITE (unit=line_att, fmt="(T8,*(1X,I0))") elec_conf(:)
1946 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
1947 c_val=trim(line_att))
1948 END IF
1949 END IF
1950
1951 CALL reallocate(potential%elec_conf, 0, l)
1952 IF (potential%monovalent) THEN
1953 potential%elec_conf(0) = 1
1954 ELSE
1955 potential%elec_conf(:) = elec_conf(:)
1956 END IF
1957
1958 potential%zeff_correction = zeff_correction
1959 potential%zeff = real(sum(potential%elec_conf), dp) + zeff_correction
1960
1961 DEALLOCATE (elec_conf)
1962
1963 ! Read r(loc) to define the exponent of the core charge
1964 ! distribution and calculate the corresponding coefficient
1965 IF (read_from_input) THEN
1966 is_ok = cp_sll_val_next(list, val)
1967 IF (.NOT. is_ok) THEN
1968 CALL cp_abort(__location__, &
1969 "Error while reading GTH potential from input file")
1970 END IF
1971 CALL val_get(val, c_val=line_att)
1972 READ (line_att, *) r
1973 CALL remove_word(line_att)
1974 ELSE
1975 line_att = ""
1976 CALL parser_get_object(parser, r, newline=.true.)
1977 istr = len_trim(line_att) + 1
1978 WRITE (unit=line_att(istr:), fmt="(T9,ES25.16E3)") r
1979 END IF
1980 alpha = 1.0_dp/(2.0_dp*r**2)
1981
1982 potential%alpha_core_charge = alpha
1983 potential%ccore_charge = potential%zeff*sqrt((alpha/pi)**3)
1984
1985 potential%alpha_ppl = alpha
1986 potential%cerf_ppl = potential%zeff*sqrt((alpha/pi)**3)
1987
1988 ! Read the parameters for the local part of the GTH pseudopotential (ppl)
1989 IF (read_from_input) THEN
1990 READ (line_att, *) n
1991 CALL remove_word(line_att)
1992 ELSE
1993 CALL parser_get_object(parser, n)
1994 istr = len_trim(line_att) + 1
1995 WRITE (unit=line_att(istr:), fmt="(1X,I0)") n
1996 END IF
1997 potential%nexp_ppl = n
1998 CALL reallocate(potential%cexp_ppl, 1, n)
1999
2000 DO i = 1, n
2001 IF (read_from_input) THEN
2002 READ (line_att, *) ci
2003 CALL remove_word(line_att)
2004 ELSE
2005 CALL parser_get_object(parser, ci)
2006 istr = len_trim(line_att) + 1
2007 WRITE (unit=line_att(istr:), fmt="(ES25.16E3)") ci
2008 END IF
2009 rc2 = (2.0_dp*potential%alpha_ppl)
2010 potential%cexp_ppl(i) = rc2**(i - 1)*ci
2011 END DO
2012
2013 IF (.NOT. read_from_input) THEN
2014 irep = irep + 1
2015 IF (update_input) THEN
2016 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2017 c_val=trim(line_att))
2018 END IF
2019 line_att = ""
2020 ELSE
2021 IF (len_trim(line_att) /= 0) THEN
2022 CALL cp_abort(__location__, &
2023 "Error while reading GTH potential from input file")
2024 END IF
2025 END IF
2026 maxlppl = 2*(n - 1)
2027
2028 IF (maxlppl > -1) CALL init_orbital_pointers(maxlppl)
2029
2030 ! Read extended form of GTH pseudopotential
2031 ! local potential, NLCC, LSD potential, spin-orbit coupling (SOC)
2032 IF (read_from_input) THEN
2033 read_keywords_from_input: DO
2034 is_ok = cp_sll_val_next(list, val)
2035 cpassert(is_ok)
2036 CALL val_get(val, c_val=line_att)
2037 IF (index(line_att, "LPOT") /= 0) THEN
2038 potential%lpotextended = .true.
2039 CALL remove_word(line_att)
2040 READ (line_att, *) potential%nexp_lpot
2041 n = potential%nexp_lpot
2042 maxlppl = 2*(n - 1)
2043 IF (maxlppl > -1) CALL init_orbital_pointers(maxlppl)
2044 NULLIFY (potential%alpha_lpot, potential%nct_lpot, potential%cval_lpot)
2045 CALL reallocate(potential%alpha_lpot, 1, n)
2046 CALL reallocate(potential%nct_lpot, 1, n)
2047 CALL reallocate(potential%cval_lpot, 1, 4, 1, n)
2048 DO ipot = 1, potential%nexp_lpot
2049 is_ok = cp_sll_val_next(list, val)
2050 cpassert(is_ok)
2051 CALL val_get(val, c_val=line_att)
2052 READ (line_att, *) r
2053 potential%alpha_lpot(ipot) = 0.5_dp/(r*r)
2054 CALL remove_word(line_att)
2055 READ (line_att, *) potential%nct_lpot(ipot)
2056 CALL remove_word(line_att)
2057 DO ic = 1, potential%nct_lpot(ipot)
2058 READ (line_att, *) ci
2059 rc2 = (2._dp*potential%alpha_lpot(ipot))**(ic - 1)
2060 potential%cval_lpot(ic, ipot) = ci*rc2
2061 CALL remove_word(line_att)
2062 END DO
2063 END DO
2064 ELSE IF (index(line_att, "NLCC") /= 0) THEN
2065 potential%nlcc = .true.
2066 CALL remove_word(line_att)
2067 READ (line_att, *) potential%nexp_nlcc
2068 n = potential%nexp_nlcc
2069 NULLIFY (potential%alpha_nlcc, potential%nct_nlcc, potential%cval_nlcc)
2070 CALL reallocate(potential%alpha_nlcc, 1, n)
2071 CALL reallocate(potential%nct_nlcc, 1, n)
2072 CALL reallocate(potential%cval_nlcc, 1, 4, 1, n)
2073 DO ipot = 1, potential%nexp_nlcc
2074 is_ok = cp_sll_val_next(list, val)
2075 cpassert(is_ok)
2076 CALL val_get(val, c_val=line_att)
2077 READ (line_att, *) potential%alpha_nlcc(ipot)
2078 CALL remove_word(line_att)
2079 READ (line_att, *) potential%nct_nlcc(ipot)
2080 CALL remove_word(line_att)
2081 DO ic = 1, potential%nct_nlcc(ipot)
2082 READ (line_att, *) potential%cval_nlcc(ic, ipot)
2083 ! Make it compatible with BigDFT style
2084 potential%cval_nlcc(ic, ipot) = potential%cval_nlcc(ic, ipot)/(4.0_dp*pi)
2085 CALL remove_word(line_att)
2086 END DO
2087 END DO
2088 ELSE IF (index(line_att, "LSD") /= 0) THEN
2089 potential%lsdpot = .true.
2090 CALL remove_word(line_att)
2091 READ (line_att, *) potential%nexp_lsd
2092 n = potential%nexp_lsd
2093 NULLIFY (potential%alpha_lsd, potential%nct_lsd, potential%cval_lsd)
2094 CALL reallocate(potential%alpha_lsd, 1, n)
2095 CALL reallocate(potential%nct_lsd, 1, n)
2096 CALL reallocate(potential%cval_lsd, 1, 4, 1, n)
2097 DO ipot = 1, potential%nexp_lsd
2098 is_ok = cp_sll_val_next(list, val)
2099 cpassert(is_ok)
2100 CALL val_get(val, c_val=line_att)
2101 READ (line_att, *) r
2102 potential%alpha_lsd(ipot) = 0.5_dp/(r*r)
2103 CALL remove_word(line_att)
2104 READ (line_att, *) potential%nct_lsd(ipot)
2105 CALL remove_word(line_att)
2106 DO ic = 1, potential%nct_lsd(ipot)
2107 READ (line_att, *) ci
2108 rc2 = (2._dp*potential%alpha_lsd(ipot))**(ic - 1)
2109 potential%cval_lsd(ic, ipot) = ci*rc2
2110 CALL remove_word(line_att)
2111 END DO
2112 END DO
2113 ELSE
2114 EXIT read_keywords_from_input
2115 END IF
2116 END DO read_keywords_from_input
2117 ELSE
2118 read_keywords: DO
2119 CALL parser_get_next_line(parser, 1)
2120 IF (parser_test_next_token(parser) == "INT") THEN
2121 EXIT read_keywords
2122 ELSE IF (parser_test_next_token(parser) == "STR") THEN
2123 CALL parser_get_object(parser, line)
2124 IF (index(line, "LPOT") /= 0) THEN
2125 ! Local potential
2126 potential%lpotextended = .true.
2127 CALL parser_get_object(parser, potential%nexp_lpot)
2128 n = potential%nexp_lpot
2129 NULLIFY (potential%alpha_lpot, potential%nct_lpot, potential%cval_lpot)
2130 CALL reallocate(potential%alpha_lpot, 1, n)
2131 CALL reallocate(potential%nct_lpot, 1, n)
2132 CALL reallocate(potential%cval_lpot, 1, 4, 1, n)
2133 ! Add to input section
2134 irep = irep + 1
2135 IF (update_input) THEN
2136 WRITE (unit=line_att, fmt="(T9,A,1X,I0)") "LPOT", n
2137 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2138 c_val=trim(line_att))
2139 END IF
2140 DO ipot = 1, potential%nexp_lpot
2141 CALL parser_get_object(parser, r, newline=.true.)
2142 potential%alpha_lpot(ipot) = 0.5_dp/(r*r)
2143 CALL parser_get_object(parser, potential%nct_lpot(ipot))
2144 CALL reallocate(tmp_vals, 1, potential%nct_lpot(ipot))
2145 DO ic = 1, potential%nct_lpot(ipot)
2146 CALL parser_get_object(parser, ci)
2147 tmp_vals(ic) = ci
2148 rc2 = (2._dp*potential%alpha_lpot(ipot))**(ic - 1)
2149 potential%cval_lpot(ic, ipot) = ci*rc2
2150 END DO
2151 ! Add to input section
2152 irep = irep + 1
2153 IF (update_input) THEN
2154 WRITE (unit=line_att, fmt="(T9,ES25.16E3,1X,I0,*(ES25.16E3))") &
2155 r, potential%nct_lpot(ipot), tmp_vals(1:potential%nct_lpot(ipot))
2156 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2157 c_val=trim(line_att))
2158 END IF
2159 END DO
2160 ELSE IF (index(line, "NLCC") /= 0) THEN
2161 ! NLCC
2162 potential%nlcc = .true.
2163 CALL parser_get_object(parser, potential%nexp_nlcc)
2164 n = potential%nexp_nlcc
2165 NULLIFY (potential%alpha_nlcc, potential%nct_nlcc, potential%cval_nlcc)
2166 CALL reallocate(potential%alpha_nlcc, 1, n)
2167 CALL reallocate(potential%nct_nlcc, 1, n)
2168 CALL reallocate(potential%cval_nlcc, 1, 4, 1, n)
2169 ! Add to input section
2170 WRITE (unit=line_att, fmt="(T9,A,1X,I0)") "NLCC", n
2171 irep = irep + 1
2172 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2173 c_val=trim(line_att))
2174 DO ipot = 1, potential%nexp_nlcc
2175 CALL parser_get_object(parser, potential%alpha_nlcc(ipot), newline=.true.)
2176 CALL parser_get_object(parser, potential%nct_nlcc(ipot))
2177 CALL reallocate(tmp_vals, 1, potential%nct_nlcc(ipot))
2178 DO ic = 1, potential%nct_nlcc(ipot)
2179 CALL parser_get_object(parser, potential%cval_nlcc(ic, ipot))
2180 tmp_vals(ic) = potential%cval_nlcc(ic, ipot)
2181 ! Make it compatible with BigDFT style
2182 potential%cval_nlcc(ic, ipot) = potential%cval_nlcc(ic, ipot)/(4.0_dp*pi)
2183 END DO
2184 ! Add to input section
2185 irep = irep + 1
2186 IF (update_input) THEN
2187 WRITE (unit=line_att, fmt="(T9,ES25.16E3,1X,I0,*(ES25.16E3))") &
2188 potential%alpha_nlcc(ipot), potential%nct_nlcc(ipot), &
2189 tmp_vals(1:potential%nct_nlcc(ipot))
2190 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2191 c_val=trim(line_att))
2192 END IF
2193 END DO
2194 ELSE IF (index(line, "LSD") /= 0) THEN
2195 ! LSD potential
2196 potential%lsdpot = .true.
2197 CALL parser_get_object(parser, potential%nexp_lsd)
2198 n = potential%nexp_lsd
2199 NULLIFY (potential%alpha_lsd, potential%nct_lsd, potential%cval_lsd)
2200 CALL reallocate(potential%alpha_lsd, 1, n)
2201 CALL reallocate(potential%nct_lsd, 1, n)
2202 CALL reallocate(potential%cval_lsd, 1, 4, 1, n)
2203 ! Add to input section
2204 irep = irep + 1
2205 IF (update_input) THEN
2206 WRITE (unit=line_att, fmt="(T9,A,1X,I0)") "LSD", n
2207 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2208 c_val=trim(line_att))
2209 END IF
2210 DO ipot = 1, potential%nexp_lsd
2211 CALL parser_get_object(parser, r, newline=.true.)
2212 potential%alpha_lsd(ipot) = 0.5_dp/(r*r)
2213 CALL parser_get_object(parser, potential%nct_lsd(ipot))
2214 CALL reallocate(tmp_vals, 1, potential%nct_lsd(ipot))
2215 DO ic = 1, potential%nct_lsd(ipot)
2216 CALL parser_get_object(parser, ci)
2217 tmp_vals(ic) = ci
2218 rc2 = (2._dp*potential%alpha_lsd(ipot))**(ic - 1)
2219 potential%cval_lsd(ic, ipot) = ci*rc2
2220 END DO
2221 ! Add to input section
2222 irep = irep + 1
2223 IF (update_input) THEN
2224 WRITE (unit=line_att, fmt="(T9,ES25.16E3,1X,I0,*(ES25.16E3))") r, potential%nct_lsd(ipot), &
2225 tmp_vals(1:potential%nct_lsd(ipot))
2226 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2227 c_val=trim(line_att))
2228 END IF
2229 END DO
2230 ELSE
2231 CALL cp_abort(__location__, &
2232 "Syntax error for <"// &
2233 trim(element_symbol)// &
2234 "> in the atomic potential <"// &
2235 trim(potential_name)// &
2236 "> potential file <"// &
2237 trim(potential_file_name)//">: "// &
2238 "Expected LPOT/NLCC/LSD keyword, got: <"// &
2239 trim(line)//">")
2240 END IF
2241 ELSE
2242 CALL parser_get_object(parser, line)
2243 CALL cp_abort(__location__, &
2244 "Syntax error for <"// &
2245 trim(element_symbol)// &
2246 "> in the atomic potential <"// &
2247 trim(potential_name)// &
2248 "> potential file <"// &
2249 trim(potential_file_name)//">: "// &
2250 "Expected LPOT/NLCC/LSD keyword or INTEGER, got: <"// &
2251 trim(line)//">")
2252 END IF
2253 END DO read_keywords
2254 END IF
2255
2256 ! Read the parameters for the non-local part of the GTH pseudopotential (ppnl)
2257 IF (read_from_input) THEN
2258 READ (line_att, *) n
2259 CALL remove_word(line_att)
2260 IF (index(line_att, "SOC") /= 0) THEN
2261 potential%soc = .true.
2262 CALL remove_word(line_att)
2263 END IF
2264 ELSE
2265 CALL parser_get_object(parser, n)
2266 IF (parser_test_next_token(parser) == "STR") THEN
2267 CALL parser_get_object(parser, line)
2268 IF (index(line, "SOC") /= 0) potential%soc = .true.
2269 END IF
2270 irep = irep + 1
2271 IF (update_input) THEN
2272 IF (potential%soc) THEN
2273 WRITE (unit=line_att, fmt="(T9,I0,2X,A)") n, "SOC"
2274 ELSE
2275 WRITE (unit=line_att, fmt="(T9,I0)") n
2276 END IF
2277 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2278 c_val=trim(line_att))
2279 END IF
2280 END IF
2281 potential%lppnl = n - 1
2282 potential%nppnl = 0
2283
2284 potential%lprj_ppnl_max = n - 1
2285 potential%nprj_ppnl_max = 0
2286
2287 IF (n > 0) THEN
2288
2289 lppnl = potential%lppnl
2290 nppnl = potential%nppnl
2291
2292 CALL init_orbital_pointers(lppnl)
2293
2294 NULLIFY (hprj_ppnl, kprj_ppnl)
2295
2296 ! Load the parameter for n non-local projectors
2297
2298 CALL reallocate(potential%alpha_ppnl, 0, lppnl)
2299 CALL reallocate(potential%nprj_ppnl, 0, lppnl)
2300
2301 lprj_ppnl_max = -1
2302 nprj_ppnl_max = 0
2303
2304 DO l = 0, lppnl
2305 IF (read_from_input) THEN
2306 is_ok = cp_sll_val_next(list, val)
2307 IF (.NOT. is_ok) THEN
2308 CALL cp_abort(__location__, &
2309 "Error while reading GTH potential from input file")
2310 END IF
2311 CALL val_get(val, c_val=line_att)
2312 READ (line_att, *) r
2313 CALL remove_word(line_att)
2314 READ (line_att, *) nprj_ppnl
2315 CALL remove_word(line_att)
2316 ELSE
2317 line_att = ""
2318 CALL parser_get_object(parser, r, newline=.true.)
2319 CALL parser_get_object(parser, nprj_ppnl)
2320 istr = len_trim(line_att) + 1
2321 WRITE (unit=line_att(istr:), fmt="(T9,ES25.16E3,1X,I0)") r, nprj_ppnl
2322 END IF
2323 IF (r == 0.0_dp .AND. nprj_ppnl /= 0) THEN
2324 CALL cp_abort(__location__, &
2325 "An error was detected in the atomic potential <"// &
2326 trim(potential_name)// &
2327 "> potential file <"// &
2328 trim(potential_file_name)//">")
2329 END IF
2330 potential%alpha_ppnl(l) = 0.0_dp
2331 IF (r /= 0.0_dp .AND. n /= 0) potential%alpha_ppnl(l) = 1.0_dp/(2.0_dp*r**2)
2332 potential%nprj_ppnl(l) = nprj_ppnl
2333 nppnl = nppnl + nprj_ppnl*nco(l)
2334 IF (nprj_ppnl > nprj_ppnl_max) THEN
2335 nprj_ppnl_max = nprj_ppnl
2336 CALL reallocate(hprj_ppnl, 1, nprj_ppnl_max, &
2337 1, nprj_ppnl_max, &
2338 0, lppnl)
2339 CALL reallocate(kprj_ppnl, 1, nprj_ppnl_max, &
2340 1, nprj_ppnl_max, &
2341 0, lppnl)
2342 END IF
2343 DO i = 1, nprj_ppnl
2344 IF (i == 1) THEN
2345 IF (read_from_input) THEN
2346 READ (line_att, *) hprj_ppnl(i, i, l)
2347 CALL remove_word(line_att)
2348 ELSE
2349 CALL parser_get_object(parser, hprj_ppnl(i, i, l))
2350 istr = len_trim(line_att) + 1
2351 WRITE (unit=line_att(istr:), fmt="(ES25.16E3)") hprj_ppnl(i, i, l)
2352 END IF
2353 ELSE
2354 IF (read_from_input) THEN
2355 IF (len_trim(line_att) /= 0) THEN
2356 CALL cp_abort(__location__, &
2357 "Error while reading GTH potential from input file")
2358 END IF
2359 is_ok = cp_sll_val_next(list, val)
2360 IF (.NOT. is_ok) THEN
2361 CALL cp_abort(__location__, &
2362 "Error while reading GTH potential from input file")
2363 END IF
2364 CALL val_get(val, c_val=line_att)
2365 READ (line_att, *) hprj_ppnl(i, i, l)
2366 CALL remove_word(line_att)
2367 ELSE
2368 IF (update_input) THEN
2369 irep = irep + 1
2370 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2371 c_val=trim(line_att))
2372 END IF
2373 line_att = ""
2374 CALL parser_get_object(parser, hprj_ppnl(i, i, l), newline=.true.)
2375 istr = len_trim(line_att) + 1
2376 WRITE (unit=line_att(istr:), fmt="(T36,A,ES25.16E3)") &
2377 repeat(" ", 25*(i - 1)), hprj_ppnl(i, i, l)
2378 END IF
2379 END IF
2380 DO j = i + 1, nprj_ppnl
2381 IF (read_from_input) THEN
2382 READ (line_att, *) hprj_ppnl(i, j, l)
2383 CALL remove_word(line_att)
2384 ELSE
2385 CALL parser_get_object(parser, hprj_ppnl(i, j, l))
2386 istr = len_trim(line_att) + 1
2387 WRITE (unit=line_att(istr:), fmt="(ES25.16E3)") hprj_ppnl(i, j, l)
2388 END IF
2389 END DO
2390 END DO
2391 IF (.NOT. read_from_input) THEN
2392 IF (update_input) THEN
2393 irep = irep + 1
2394 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2395 c_val=trim(line_att))
2396 END IF
2397 line_att = ""
2398 ELSE
2399 IF (len_trim(line_att) /= 0) THEN
2400 CALL cp_abort(__location__, &
2401 "Error while reading GTH potential from input file")
2402 END IF
2403 END IF
2404 IF (nprj_ppnl > 1) THEN
2405 CALL symmetrize_matrix(hprj_ppnl(:, :, l), "upper_to_lower")
2406 END IF
2407 IF (potential%soc .AND. (l > 0)) THEN
2408 ! Read non-local parameters for spin-orbit coupling
2409 DO i = 1, nprj_ppnl
2410 IF (read_from_input) THEN
2411 IF (len_trim(line_att) /= 0) THEN
2412 CALL cp_abort(__location__, &
2413 "Error while reading GTH potential from input file")
2414 END IF
2415 is_ok = cp_sll_val_next(list, val)
2416 IF (.NOT. is_ok) THEN
2417 CALL cp_abort(__location__, &
2418 "Error while reading GTH potential from input file")
2419 END IF
2420 CALL val_get(val, c_val=line_att)
2421 READ (line_att, *) kprj_ppnl(i, i, l)
2422 CALL remove_word(line_att)
2423 ELSE
2424 IF (i > 1 .AND. update_input) THEN
2425 irep = irep + 1
2426 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2427 c_val=trim(line_att))
2428 END IF
2429 line_att = ""
2430 CALL parser_get_object(parser, kprj_ppnl(i, i, l), newline=.true.)
2431 istr = len_trim(line_att) + 1
2432 WRITE (unit=line_att(istr:), fmt="(T36,A,ES25.16E3)") &
2433 repeat(" ", 25*(i - 1)), kprj_ppnl(i, i, l)
2434 END IF
2435 DO j = i + 1, nprj_ppnl
2436 IF (read_from_input) THEN
2437 READ (line_att, *) kprj_ppnl(i, j, l)
2438 CALL remove_word(line_att)
2439 ELSE
2440 CALL parser_get_object(parser, kprj_ppnl(i, j, l))
2441 istr = len_trim(line_att) + 1
2442 WRITE (unit=line_att(istr:), fmt="(ES25.16E3)") kprj_ppnl(i, j, l)
2443 END IF
2444 END DO
2445 END DO
2446 IF (read_from_input) THEN
2447 IF (len_trim(line_att) /= 0) THEN
2448 CALL cp_abort(__location__, &
2449 "Error while reading GTH potential from input file")
2450 END IF
2451 ELSE
2452 IF (update_input) THEN
2453 irep = irep + 1
2454 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2455 c_val=trim(line_att))
2456 END IF
2457 line_att = ""
2458 END IF
2459 IF (nprj_ppnl > 1) THEN
2460 CALL symmetrize_matrix(kprj_ppnl(:, :, l), "upper_to_lower")
2461 END IF
2462 END IF ! SOC
2463 lprj_ppnl_max = max(lprj_ppnl_max, l + 2*(nprj_ppnl - 1))
2464 END DO ! lppnl
2465
2466 potential%nppnl = nppnl
2467 CALL init_orbital_pointers(lprj_ppnl_max)
2468
2469 potential%lprj_ppnl_max = lprj_ppnl_max
2470 potential%nprj_ppnl_max = nprj_ppnl_max
2471 CALL reallocate(potential%hprj_ppnl, 1, nprj_ppnl_max, &
2472 1, nprj_ppnl_max, &
2473 0, lppnl)
2474 potential%hprj_ppnl(:, :, :) = hprj_ppnl(:, :, :)
2475 CALL reallocate(potential%kprj_ppnl, 1, nprj_ppnl_max, &
2476 1, nprj_ppnl_max, &
2477 0, lppnl)
2478 potential%kprj_ppnl(:, :, :) = kprj_ppnl(:, :, :)
2479
2480 CALL reallocate(potential%cprj, 1, ncoset(lprj_ppnl_max), 1, nppnl)
2481 CALL reallocate(potential%cprj_ppnl, 1, nprj_ppnl_max, 0, lppnl)
2482 CALL reallocate(potential%vprj_ppnl, 1, nppnl, 1, nppnl)
2483 CALL reallocate(potential%wprj_ppnl, 1, nppnl, 1, nppnl)
2484
2485 DEALLOCATE (hprj_ppnl, kprj_ppnl)
2486 END IF
2487 EXIT search_loop
2488 END IF
2489 ELSE
2490 ! Stop program, if the end of file is reached
2491 IF (PRESENT(potential_found)) THEN
2492 CALL parser_release(parser)
2493 DEALLOCATE (parser)
2494 RETURN
2495 END IF
2496 CALL cp_abort(__location__, &
2497 "The requested atomic potential <"// &
2498 trim(potential_name)// &
2499 "> for element <"// &
2500 trim(symbol)// &
2501 "> was not found in the potential file <"// &
2502 trim(potential_file_name)//">")
2503 END IF
2504 END DO search_loop
2505
2506 IF (PRESENT(potential_found)) potential_found = .true.
2507
2508 IF (.NOT. read_from_input) THEN
2509 ! Dump the potential info in the potential section
2510 IF (match .AND. update_input) THEN
2511 irep = irep + 1
2512 WRITE (unit=line_att, fmt="(T9,A)") &
2513 "# Potential name: "//trim(adjustl(apname2(:strlen2)))// &
2514 " for element symbol: "//trim(adjustl(symbol2(:strlen1)))
2515 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2516 c_val=trim(line_att))
2517 irep = irep + 1
2518 WRITE (unit=line_att, fmt="(T9,A)") &
2519 "# Potential read from the potential filename: "//trim(adjustl(potential_file_name))
2520 CALL section_vals_val_set(potential_section, "_DEFAULT_KEYWORD_", i_rep_val=irep, &
2521 c_val=trim(line_att))
2522 END IF
2523 CALL parser_release(parser)
2524 DEALLOCATE (parser)
2525 END IF
2526
2527 IF (ASSOCIATED(tmp_vals)) DEALLOCATE (tmp_vals)
2528
2529 END SUBROUTINE read_gth_potential
2530
2531! **************************************************************************************************
2532!> \brief Read a GTH potential from an ordered list of library files.
2533!> \param element_symbol ...
2534!> \param potential_name ...
2535!> \param potential ...
2536!> \param zeff_correction ...
2537!> \param para_env ...
2538!> \param potential_file_names ...
2539!> \param potential_section ...
2540!> \param update_input ...
2541!> \param monovalent ...
2542! **************************************************************************************************
2543 SUBROUTINE read_gth_potential_files(element_symbol, potential_name, potential, zeff_correction, &
2544 para_env, potential_file_names, potential_section, update_input, &
2545 monovalent)
2546
2547 CHARACTER(LEN=*), INTENT(IN) :: element_symbol, potential_name
2548 TYPE(gth_potential_type), INTENT(INOUT) :: potential
2549 REAL(KIND=dp), INTENT(IN) :: zeff_correction
2550 TYPE(mp_para_env_type), INTENT(IN), POINTER :: para_env
2551 CHARACTER(LEN=*), DIMENSION(:), INTENT(IN) :: potential_file_names
2552 TYPE(section_vals_type), INTENT(IN), POINTER :: potential_section
2553 LOGICAL, INTENT(IN) :: update_input
2554 LOGICAL, INTENT(IN), OPTIONAL :: monovalent
2555
2556 INTEGER :: i
2557 LOGICAL :: potential_found
2558
2559 DO i = 1, SIZE(potential_file_names)
2560 CALL read_gth_potential(element_symbol, potential_name, potential, zeff_correction, para_env, &
2561 potential_file_names(i), potential_section, update_input, monovalent, &
2562 potential_found)
2563 IF (potential_found) RETURN
2564 END DO
2565 CALL potential_files_not_found(element_symbol, potential_name, potential_file_names)
2566
2567 END SUBROUTINE read_gth_potential_files
2568
2569! **************************************************************************************************
2570!> \brief ...
2571!> \param potential ...
2572!> \param z ...
2573!> \param zeff_correction ...
2574! **************************************************************************************************
2575 SUBROUTINE set_default_all_potential(potential, z, zeff_correction)
2576
2577 TYPE(all_potential_type), INTENT(INOUT) :: potential
2578 INTEGER, INTENT(IN) :: z
2579 REAL(kind=dp), INTENT(IN) :: zeff_correction
2580
2581 CHARACTER(LEN=default_string_length) :: name
2582 INTEGER, DIMENSION(:), POINTER :: elec_conf
2583 REAL(kind=dp) :: alpha, alpha_core_charge, ccore_charge, &
2584 core_charge_radius, r, zeff
2585
2586 ALLOCATE (elec_conf(0:3))
2587 elec_conf(0:3) = ptable(z)%e_conv(0:3)
2588 zeff = real(sum(elec_conf), dp) + zeff_correction
2589 name = ptable(z)%name
2590
2591 r = ptable(z)%covalent_radius*0.5_dp
2592 r = max(r, 0.2_dp)
2593 r = min(r, 1.0_dp)
2594 alpha = 1.0_dp/(2.0_dp*r**2)
2595
2596 core_charge_radius = r
2597 alpha_core_charge = alpha
2598 ccore_charge = zeff*sqrt((alpha/pi)**3)
2599
2600 CALL set_all_potential(potential, &
2601 name=name, &
2602 alpha_core_charge=alpha_core_charge, &
2603 ccore_charge=ccore_charge, &
2604 core_charge_radius=core_charge_radius, &
2605 z=z, &
2606 zeff=zeff, &
2607 zeff_correction=zeff_correction, &
2608 elec_conf=elec_conf)
2609
2610 DEALLOCATE (elec_conf)
2611
2612 END SUBROUTINE set_default_all_potential
2613
2614! **************************************************************************************************
2615!> \brief Set the attributes of an all-electron potential data set.
2616!> \param potential ...
2617!> \param name ...
2618!> \param alpha_core_charge ...
2619!> \param ccore_charge ...
2620!> \param core_charge_radius ...
2621!> \param z ...
2622!> \param zeff ...
2623!> \param zeff_correction ...
2624!> \param elec_conf ...
2625!> \date 11.01.2002
2626!> \author MK
2627!> \version 1.0
2628! **************************************************************************************************
2629 SUBROUTINE set_all_potential(potential, name, alpha_core_charge, &
2630 ccore_charge, core_charge_radius, z, zeff, &
2631 zeff_correction, elec_conf)
2632
2633 TYPE(all_potential_type), INTENT(INOUT) :: potential
2634 CHARACTER(LEN=default_string_length), INTENT(IN), &
2635 OPTIONAL :: name
2636 REAL(kind=dp), INTENT(IN), OPTIONAL :: alpha_core_charge, ccore_charge, &
2637 core_charge_radius
2638 INTEGER, INTENT(IN), OPTIONAL :: z
2639 REAL(kind=dp), INTENT(IN), OPTIONAL :: zeff, zeff_correction
2640 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf
2641
2642 IF (PRESENT(name)) potential%name = name
2643 IF (PRESENT(alpha_core_charge)) THEN
2644 potential%alpha_core_charge = alpha_core_charge
2645 END IF
2646 IF (PRESENT(ccore_charge)) potential%ccore_charge = ccore_charge
2647 IF (PRESENT(core_charge_radius)) THEN
2648 potential%core_charge_radius = core_charge_radius
2649 END IF
2650 IF (PRESENT(z)) potential%z = z
2651 IF (PRESENT(zeff)) potential%zeff = zeff
2652 IF (PRESENT(zeff_correction)) potential%zeff_correction = zeff_correction
2653 IF (PRESENT(elec_conf)) THEN
2654 IF (.NOT. ASSOCIATED(potential%elec_conf)) THEN
2655 CALL reallocate(potential%elec_conf, 0, SIZE(elec_conf) - 1)
2656 END IF
2657 potential%elec_conf(:) = elec_conf(:)
2658 END IF
2659
2660 END SUBROUTINE set_all_potential
2661
2662! **************************************************************************************************
2663!> \brief Set the attributes of an atomic local potential data set.
2664!> \param potential ...
2665!> \param name ...
2666!> \param alpha ...
2667!> \param cval ...
2668!> \param radius ...
2669!> \date 24.01.2014
2670!> \author JGH
2671!> \version 1.0
2672! **************************************************************************************************
2673 SUBROUTINE set_local_potential(potential, name, alpha, cval, radius)
2674
2675 TYPE(local_potential_type), INTENT(INOUT) :: potential
2676 CHARACTER(LEN=default_string_length), INTENT(IN), &
2677 OPTIONAL :: name
2678 REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: alpha
2679 REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cval
2680 REAL(KIND=dp), INTENT(IN), OPTIONAL :: radius
2681
2682 IF (PRESENT(name)) potential%name = name
2683 IF (PRESENT(alpha)) potential%alpha => alpha
2684 IF (PRESENT(cval)) potential%cval => cval
2685 IF (PRESENT(radius)) potential%radius = radius
2686
2687 END SUBROUTINE set_local_potential
2688
2689! **************************************************************************************************
2690!> \brief Set the attributes of an effective charge and inducible point
2691!> dipole potential data set.
2692!> \param potential ...
2693!> \param apol ...
2694!> \param cpol ...
2695!> \param qeff ...
2696!> \param mm_radius ...
2697!> \param qmmm_corr_radius ...
2698!> \param qmmm_radius ...
2699!> \date 05.03.2010
2700!> \author Toon.Verstraelen@gmail.com
2701! **************************************************************************************************
2702 SUBROUTINE set_fist_potential(potential, apol, cpol, qeff, mm_radius, &
2703 qmmm_corr_radius, qmmm_radius)
2704
2705 TYPE(fist_potential_type), INTENT(INOUT) :: potential
2706 REAL(kind=dp), INTENT(IN), OPTIONAL :: apol, cpol, qeff, mm_radius, &
2707 qmmm_corr_radius, qmmm_radius
2708
2709 IF (PRESENT(apol)) potential%apol = apol
2710 IF (PRESENT(cpol)) potential%cpol = cpol
2711 IF (PRESENT(mm_radius)) potential%mm_radius = mm_radius
2712 IF (PRESENT(qeff)) potential%qeff = qeff
2713 IF (PRESENT(qmmm_corr_radius)) potential%qmmm_corr_radius = qmmm_corr_radius
2714 IF (PRESENT(qmmm_radius)) potential%qmmm_radius = qmmm_radius
2715
2716 END SUBROUTINE set_fist_potential
2717
2718! **************************************************************************************************
2719!> \brief Set the attributes of a GTH potential data set.
2720!> \param potential ...
2721!> \param name ...
2722!> \param alpha_core_charge ...
2723!> \param alpha_ppl ...
2724!> \param ccore_charge ...
2725!> \param cerf_ppl ...
2726!> \param core_charge_radius ...
2727!> \param ppl_radius ...
2728!> \param ppnl_radius ...
2729!> \param lppnl ...
2730!> \param lprj_ppnl_max ...
2731!> \param nexp_ppl ...
2732!> \param nppnl ...
2733!> \param nprj_ppnl_max ...
2734!> \param z ...
2735!> \param zeff ...
2736!> \param zeff_correction ...
2737!> \param alpha_ppnl ...
2738!> \param cexp_ppl ...
2739!> \param elec_conf ...
2740!> \param nprj_ppnl ...
2741!> \param cprj ...
2742!> \param cprj_ppnl ...
2743!> \param vprj_ppnl ...
2744!> \param wprj_ppnl ...
2745!> \param hprj_ppnl ...
2746!> \param kprj_ppnl ...
2747!> \date 11.01.2002
2748!> \author MK
2749!> \version 1.0
2750! **************************************************************************************************
2751 SUBROUTINE set_gth_potential(potential, name, alpha_core_charge, alpha_ppl, &
2752 ccore_charge, cerf_ppl, core_charge_radius, &
2753 ppl_radius, ppnl_radius, lppnl, lprj_ppnl_max, &
2754 nexp_ppl, nppnl, nprj_ppnl_max, z, zeff, zeff_correction, &
2755 alpha_ppnl, cexp_ppl, elec_conf, nprj_ppnl, cprj, cprj_ppnl, &
2756 vprj_ppnl, wprj_ppnl, hprj_ppnl, kprj_ppnl)
2757
2758 TYPE(gth_potential_type), INTENT(INOUT) :: potential
2759 CHARACTER(LEN=default_string_length), INTENT(IN), &
2760 OPTIONAL :: name
2761 REAL(kind=dp), INTENT(IN), OPTIONAL :: alpha_core_charge, alpha_ppl, &
2762 ccore_charge, cerf_ppl, &
2763 core_charge_radius, ppl_radius, &
2764 ppnl_radius
2765 INTEGER, INTENT(IN), OPTIONAL :: lppnl, lprj_ppnl_max, nexp_ppl, nppnl, &
2766 nprj_ppnl_max, z
2767 REAL(kind=dp), INTENT(IN), OPTIONAL :: zeff, zeff_correction
2768 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: alpha_ppnl, cexp_ppl
2769 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf, nprj_ppnl
2770 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: cprj, cprj_ppnl, vprj_ppnl, wprj_ppnl
2771 REAL(kind=dp), DIMENSION(:, :, :), OPTIONAL, &
2772 POINTER :: hprj_ppnl, kprj_ppnl
2773
2774 IF (PRESENT(name)) potential%name = name
2775 IF (PRESENT(alpha_core_charge)) THEN
2776 potential%alpha_core_charge = alpha_core_charge
2777 END IF
2778 IF (PRESENT(alpha_ppl)) potential%alpha_ppl = alpha_ppl
2779 IF (PRESENT(ccore_charge)) potential%ccore_charge = ccore_charge
2780 IF (PRESENT(cerf_ppl)) potential%cerf_ppl = cerf_ppl
2781 IF (PRESENT(core_charge_radius)) THEN
2782 potential%core_charge_radius = core_charge_radius
2783 END IF
2784 IF (PRESENT(ppl_radius)) potential%ppl_radius = ppl_radius
2785 IF (PRESENT(ppnl_radius)) potential%ppnl_radius = ppnl_radius
2786 IF (PRESENT(lppnl)) potential%lppnl = lppnl
2787 IF (PRESENT(lprj_ppnl_max)) potential%lprj_ppnl_max = lprj_ppnl_max
2788 IF (PRESENT(nexp_ppl)) potential%nexp_ppl = nexp_ppl
2789 IF (PRESENT(nppnl)) potential%nppnl = nppnl
2790 IF (PRESENT(nprj_ppnl_max)) potential%nprj_ppnl_max = nprj_ppnl_max
2791 IF (PRESENT(z)) potential%z = z
2792 IF (PRESENT(zeff)) potential%zeff = zeff
2793 IF (PRESENT(zeff_correction)) potential%zeff_correction = zeff_correction
2794 IF (PRESENT(alpha_ppnl)) potential%alpha_ppnl => alpha_ppnl
2795 IF (PRESENT(cexp_ppl)) potential%cexp_ppl => cexp_ppl
2796 IF (PRESENT(elec_conf)) THEN
2797 IF (ASSOCIATED(potential%elec_conf)) THEN
2798 DEALLOCATE (potential%elec_conf)
2799 END IF
2800 ALLOCATE (potential%elec_conf(0:SIZE(elec_conf) - 1))
2801 potential%elec_conf(:) = elec_conf(:)
2802 END IF
2803 IF (PRESENT(nprj_ppnl)) potential%nprj_ppnl => nprj_ppnl
2804 IF (PRESENT(cprj)) potential%cprj => cprj
2805 IF (PRESENT(cprj_ppnl)) potential%cprj_ppnl => cprj_ppnl
2806 IF (PRESENT(hprj_ppnl)) potential%hprj_ppnl => hprj_ppnl
2807 IF (PRESENT(kprj_ppnl)) potential%kprj_ppnl => kprj_ppnl
2808 IF (PRESENT(vprj_ppnl)) potential%vprj_ppnl => vprj_ppnl
2809 IF (PRESENT(wprj_ppnl)) potential%wprj_ppnl => wprj_ppnl
2810
2811 END SUBROUTINE set_gth_potential
2812
2813! **************************************************************************************************
2814!> \brief ...
2815!> \param potential ...
2816!> \param name ...
2817!> \param description ...
2818!> \param aliases ...
2819!> \param elec_conf ...
2820!> \param z ...
2821!> \param zeff ...
2822!> \param zeff_correction ...
2823!> \param alpha_core_charge ...
2824!> \param ccore_charge ...
2825!> \param core_charge_radius ...
2826!> \param ppl_radius ...
2827!> \param ppnl_radius ...
2828!> \param ecp_local ...
2829!> \param n_local ...
2830!> \param a_local ...
2831!> \param c_local ...
2832!> \param nloc ...
2833!> \param nrloc ...
2834!> \param aloc ...
2835!> \param bloc ...
2836!> \param ecp_semi_local ...
2837!> \param sl_lmax ...
2838!> \param npot ...
2839!> \param nrpot ...
2840!> \param apot ...
2841!> \param bpot ...
2842!> \param n_nonlocal ...
2843!> \param nppnl ...
2844!> \param lmax ...
2845!> \param is_nonlocal ...
2846!> \param a_nonlocal ...
2847!> \param h_nonlocal ...
2848!> \param c_nonlocal ...
2849!> \param has_nlcc ...
2850!> \param n_nlcc ...
2851!> \param a_nlcc ...
2852!> \param c_nlcc ...
2853! **************************************************************************************************
2854 SUBROUTINE set_sgp_potential(potential, name, description, aliases, elec_conf, &
2855 z, zeff, zeff_correction, alpha_core_charge, &
2856 ccore_charge, core_charge_radius, &
2857 ppl_radius, ppnl_radius, &
2858 ecp_local, n_local, a_local, c_local, &
2859 nloc, nrloc, aloc, bloc, &
2860 ecp_semi_local, sl_lmax, npot, nrpot, apot, bpot, &
2861 n_nonlocal, nppnl, lmax, is_nonlocal, a_nonlocal, h_nonlocal, c_nonlocal, &
2862 has_nlcc, n_nlcc, a_nlcc, c_nlcc)
2863
2864 TYPE(sgp_potential_type), INTENT(INOUT) :: potential
2865 CHARACTER(LEN=default_string_length), INTENT(IN), &
2866 OPTIONAL :: name
2867 CHARACTER(LEN=default_string_length), &
2868 DIMENSION(4), INTENT(IN), OPTIONAL :: description
2869 CHARACTER(LEN=default_string_length), INTENT(IN), &
2870 OPTIONAL :: aliases
2871 INTEGER, DIMENSION(:), OPTIONAL, POINTER :: elec_conf
2872 INTEGER, INTENT(IN), OPTIONAL :: z
2873 REAL(kind=dp), INTENT(IN), OPTIONAL :: zeff, zeff_correction, &
2874 alpha_core_charge, ccore_charge, &
2875 core_charge_radius, ppl_radius, &
2876 ppnl_radius
2877 LOGICAL, INTENT(IN), OPTIONAL :: ecp_local
2878 INTEGER, INTENT(IN), OPTIONAL :: n_local
2879 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: a_local, c_local
2880 INTEGER, INTENT(IN), OPTIONAL :: nloc
2881 INTEGER, DIMENSION(1:10), INTENT(IN), OPTIONAL :: nrloc
2882 REAL(dp), DIMENSION(1:10), INTENT(IN), OPTIONAL :: aloc, bloc
2883 LOGICAL, INTENT(IN), OPTIONAL :: ecp_semi_local
2884 INTEGER, INTENT(IN), OPTIONAL :: sl_lmax
2885 INTEGER, DIMENSION(0:10), OPTIONAL :: npot
2886 INTEGER, DIMENSION(1:15, 0:10), OPTIONAL :: nrpot
2887 REAL(dp), DIMENSION(1:15, 0:10), OPTIONAL :: apot, bpot
2888 INTEGER, INTENT(IN), OPTIONAL :: n_nonlocal, nppnl, lmax
2889 LOGICAL, DIMENSION(0:5), INTENT(IN), OPTIONAL :: is_nonlocal
2890 REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: a_nonlocal
2891 REAL(KIND=dp), DIMENSION(:, :), OPTIONAL, POINTER :: h_nonlocal
2892 REAL(KIND=dp), DIMENSION(:, :, :), OPTIONAL, &
2893 POINTER :: c_nonlocal
2894 LOGICAL, INTENT(IN), OPTIONAL :: has_nlcc
2895 INTEGER, INTENT(IN), OPTIONAL :: n_nlcc
2896 REAL(KIND=dp), DIMENSION(:), OPTIONAL, POINTER :: a_nlcc, c_nlcc
2897
2898 IF (PRESENT(name)) potential%name = name
2899 IF (PRESENT(aliases)) potential%aliases = aliases
2900 IF (PRESENT(description)) potential%description = description
2901
2902 IF (PRESENT(elec_conf)) THEN
2903 IF (ASSOCIATED(potential%elec_conf)) THEN
2904 DEALLOCATE (potential%elec_conf)
2905 END IF
2906 ALLOCATE (potential%elec_conf(0:SIZE(elec_conf) - 1))
2907 potential%elec_conf(:) = elec_conf(:)
2908 END IF
2909
2910 IF (PRESENT(z)) potential%z = z
2911 IF (PRESENT(zeff)) potential%zeff = zeff
2912 IF (PRESENT(zeff_correction)) potential%zeff_correction = zeff_correction
2913 IF (PRESENT(alpha_core_charge)) potential%alpha_core_charge = alpha_core_charge
2914 IF (PRESENT(ccore_charge)) potential%ccore_charge = ccore_charge
2915 IF (PRESENT(core_charge_radius)) potential%core_charge_radius = core_charge_radius
2916
2917 IF (PRESENT(ppl_radius)) potential%ppl_radius = ppl_radius
2918 IF (PRESENT(ppnl_radius)) potential%ppnl_radius = ppnl_radius
2919
2920 IF (PRESENT(ecp_local)) potential%ecp_local = ecp_local
2921 IF (PRESENT(n_local)) potential%n_local = n_local
2922 IF (PRESENT(a_local)) potential%a_local => a_local
2923 IF (PRESENT(c_local)) potential%c_local => c_local
2924
2925 IF (PRESENT(nloc)) potential%nloc = nloc
2926 IF (PRESENT(nrloc)) potential%nrloc = nrloc
2927 IF (PRESENT(aloc)) potential%aloc = aloc
2928 IF (PRESENT(bloc)) potential%bloc = bloc
2929
2930 IF (PRESENT(ecp_semi_local)) potential%ecp_semi_local = ecp_semi_local
2931 IF (PRESENT(sl_lmax)) potential%sl_lmax = sl_lmax
2932 IF (PRESENT(npot)) potential%npot = npot
2933 IF (PRESENT(nrpot)) potential%nrpot = nrpot
2934 IF (PRESENT(apot)) potential%apot = apot
2935 IF (PRESENT(bpot)) potential%bpot = bpot
2936
2937 IF (PRESENT(n_nonlocal)) potential%n_nonlocal = n_nonlocal
2938 IF (PRESENT(nppnl)) potential%nppnl = nppnl
2939 IF (PRESENT(lmax)) potential%lmax = lmax
2940 IF (PRESENT(is_nonlocal)) potential%is_nonlocal(:) = is_nonlocal(:)
2941 IF (PRESENT(a_nonlocal)) potential%a_nonlocal => a_nonlocal
2942 IF (PRESENT(c_nonlocal)) potential%c_nonlocal => c_nonlocal
2943 IF (PRESENT(h_nonlocal)) potential%h_nonlocal => h_nonlocal
2944
2945 IF (PRESENT(has_nlcc)) potential%has_nlcc = has_nlcc
2946 IF (PRESENT(n_nlcc)) potential%n_nlcc = n_nlcc
2947 IF (PRESENT(a_nlcc)) potential%a_nlcc => a_nlcc
2948 IF (PRESENT(c_nlcc)) potential%c_nlcc => c_nlcc
2949
2950 END SUBROUTINE set_sgp_potential
2951
2952! **************************************************************************************************
2953!> \brief Write an atomic all-electron potential data set to the output unit
2954!> \param potential ...
2955!> \param output_unit ...
2956!> \par History
2957!> - Creation (09.02.2002, MK)
2958! **************************************************************************************************
2959 SUBROUTINE write_all_potential(potential, output_unit)
2960
2961 TYPE(all_potential_type), INTENT(IN) :: potential
2962 INTEGER, INTENT(IN) :: output_unit
2963
2964 CHARACTER(LEN=20) :: string
2965
2966 IF (output_unit > 0) THEN
2967 WRITE (unit=output_unit, fmt="(/,T6,A,T41,A40,/)") &
2968 "AE Potential information for", adjustr(trim(potential%name))
2969 WRITE (unit=output_unit, fmt="(T8,A,T41,A40)") &
2970 "Description: ", trim(potential%description(1)), &
2971 " ", trim(potential%description(2))
2972 WRITE (unit=output_unit, fmt="(/,T8,A,T69,F12.6)") &
2973 "Gaussian exponent of the core charge distribution: ", &
2974 potential%alpha_core_charge
2975 WRITE (unit=string, fmt="(5I4)") potential%elec_conf
2976 WRITE (unit=output_unit, fmt="(T8,A,T61,A20)") &
2977 "Electronic configuration (s p d ...):", &
2978 adjustr(trim(string))
2979 END IF
2980
2981 END SUBROUTINE write_all_potential
2982
2983! **************************************************************************************************
2984!> \brief Write an atomic local potential data set to the output unit
2985!> \param potential ...
2986!> \param output_unit ...
2987!> \par History
2988!> - Creation (24.01.2014, JGH)
2989! **************************************************************************************************
2990 SUBROUTINE write_local_potential(potential, output_unit)
2991
2992 TYPE(local_potential_type), INTENT(IN) :: potential
2993 INTEGER, INTENT(IN) :: output_unit
2994
2995 INTEGER :: igau, ipol
2996
2997 IF (output_unit > 0) THEN
2998 WRITE (unit=output_unit, fmt="(/,T6,A,T41,A40)") &
2999 "Local Potential information for", adjustr(trim(potential%name))
3000 WRITE (unit=output_unit, fmt="(T8,A,T41,A40)") &
3001 "Description: ", trim(potential%description(1))
3002 DO igau = 1, potential%ngau
3003 WRITE (unit=output_unit, fmt="(T8,A,F12.6,T50,A,4(T68,I2,F10.4))") &
3004 "Exponent: ", potential%alpha(igau), &
3005 "Coefficients: ", (2*ipol - 2, potential%cval(igau, ipol), ipol=1, potential%npol)
3006 END DO
3007 END IF
3008
3009 END SUBROUTINE write_local_potential
3010
3011! **************************************************************************************************
3012!> \brief Write an atomic GTH potential data set to the output unit
3013!> \param potential ...
3014!> \param output_unit ...
3015!> \par History
3016!> - Creation (09.02.2002, MK)
3017! **************************************************************************************************
3018 SUBROUTINE write_gth_potential(potential, output_unit)
3019
3020 TYPE(gth_potential_type), INTENT(IN) :: potential
3021 INTEGER, INTENT(IN) :: output_unit
3022
3023 CHARACTER(LEN=20) :: string
3024 INTEGER :: i, j, l
3025 REAL(KIND=dp) :: r
3026
3027 IF (output_unit > 0) THEN
3028 WRITE (unit=output_unit, fmt="(/,T6,A,T41,A40,/)") &
3029 "GTH Potential information for", adjustr(trim(potential%name))
3030 WRITE (unit=output_unit, fmt="(T8,A,T41,A40)") &
3031 "Description: ", adjustr(trim(potential%description(1))), &
3032 " ", adjustr(trim(potential%description(2))), &
3033 " ", adjustr(trim(potential%description(3))), &
3034 " ", adjustr(trim(potential%description(4)))
3035 WRITE (unit=output_unit, fmt="(/,T8,A,T69,F12.6)") &
3036 "Gaussian exponent of the core charge distribution: ", &
3037 potential%alpha_core_charge
3038 WRITE (unit=string, fmt="(5I4)") potential%elec_conf
3039 WRITE (unit=output_unit, fmt="(T8,A,T61,A20)") &
3040 "Electronic configuration (s p d ...):", &
3041 adjustr(trim(string))
3042
3043 r = 1.0_dp/sqrt(2.0_dp*potential%alpha_ppl)
3044
3045 WRITE (unit=output_unit, fmt="(/,T8,A,/,/,T27,A,/,T21,5F12.6)") &
3046 "Parameters of the local part of the GTH pseudopotential:", &
3047 "rloc C1 C2 C3 C4", &
3048 r, (potential%cexp_ppl(i)*r**(2*(i - 1)), i=1, potential%nexp_ppl)
3049
3050 IF (potential%lppnl > -1) THEN
3051 IF (potential%soc) THEN
3052 WRITE (unit=output_unit, fmt="(/,T8,A,/,/,(T20,A))") &
3053 "Parameters of the non-local part of the GTH (SOC) pseudopotential:", &
3054 "l r(l) h(i,j,l)", &
3055 " k(i,j,l)"
3056 ELSE
3057 WRITE (unit=output_unit, fmt="(/,T8,A,/,/,T20,A,/)") &
3058 "Parameters of the non-local part of the GTH pseudopotential:", &
3059 "l r(l) h(i,j,l)"
3060 END IF
3061 DO l = 0, potential%lppnl
3062 r = sqrt(0.5_dp/potential%alpha_ppnl(l))
3063 WRITE (unit=output_unit, fmt="(T19,I2,5F12.6)") &
3064 l, r, (potential%hprj_ppnl(1, j, l), j=1, potential%nprj_ppnl(l))
3065 DO i = 2, potential%nprj_ppnl(l)
3066 WRITE (unit=output_unit, fmt="(T33,4F12.6)") &
3067 (potential%hprj_ppnl(i, j, l), j=1, potential%nprj_ppnl(l))
3068 END DO
3069 IF (potential%soc .AND. (l > 0)) THEN
3070 DO i = 1, potential%nprj_ppnl(l)
3071 WRITE (unit=output_unit, fmt="(T33,4F12.6)") &
3072 (potential%kprj_ppnl(i, j, l), j=1, potential%nprj_ppnl(l))
3073 END DO
3074 END IF
3075 END DO
3076 END IF
3077 END IF
3078
3079 END SUBROUTINE write_gth_potential
3080
3081! **************************************************************************************************
3082!> \brief ...
3083!> \param potential ...
3084!> \param output_unit ...
3085! **************************************************************************************************
3086 SUBROUTINE write_sgp_potential(potential, output_unit)
3087
3088 TYPE(sgp_potential_type), INTENT(IN) :: potential
3089 INTEGER, INTENT(IN) :: output_unit
3090
3091 CHARACTER(LEN=40) :: string
3092 INTEGER :: i, l
3093 CHARACTER(LEN=1), DIMENSION(0:10), PARAMETER :: &
3094 slqval = ["s", "p", "d", "f", "g", "h", "j", "k", "l", "m", "n"]
3095
3096 IF (output_unit > 0) THEN
3097 WRITE (unit=output_unit, fmt="(/,T6,A,T41,A40,/)") &
3098 "SGP Potential information for", adjustr(trim(potential%name))
3099 WRITE (unit=output_unit, fmt="(T8,A,T25,A56)") &
3100 "Description: ", adjustr(trim(potential%description(1))), &
3101 " ", adjustr(trim(potential%description(2))), &
3102 " ", adjustr(trim(potential%description(3))), &
3103 " ", adjustr(trim(potential%description(4)))
3104 WRITE (unit=output_unit, fmt="(/,T8,A,T69,F12.6)") &
3105 "Gaussian exponent of the core charge distribution: ", &
3106 potential%alpha_core_charge
3107 WRITE (unit=string, fmt="(10I4)") potential%elec_conf
3108 WRITE (unit=output_unit, fmt="(T8,A,T61,A20)") &
3109 "Electronic configuration (s p d ...):", &
3110 adjustr(trim(string))
3111 IF (potential%ecp_local) THEN
3112 IF (potential%nloc > 0) THEN
3113 WRITE (unit=output_unit, fmt="(/,T8,'Local pseudopotential')")
3114 WRITE (unit=output_unit, fmt="(T20,'r**(n-2)',T50,'Coefficient',T73,'Exponent')")
3115 DO i = 1, potential%nloc
3116 WRITE (unit=output_unit, fmt="(T20,I5,T47,F14.8,T69,F12.6)") &
3117 potential%nrloc(i), potential%aloc(i), potential%bloc(i)
3118 END DO
3119 END IF
3120 ELSE
3121 IF (ALLOCATED(potential%upf_data)) THEN
3122 WRITE (unit=output_unit, fmt="(/,T8,A)") 'Local UPF potential: original radial table'
3123 WRITE (unit=output_unit, fmt="(T8,A)") 'Gaussian core electrostatics and direct short-range quadrature'
3124 ELSE IF (potential%n_local > 0) THEN
3125 WRITE (unit=output_unit, fmt="(/,T8,'Local pseudopotential')")
3126 WRITE (unit=output_unit, fmt="(T8,A,10(T21,6F10.4,/))") &
3127 'Exponents:', potential%a_local(1:potential%n_local)
3128 WRITE (unit=output_unit, fmt="(T8,A,10(T21,6F10.4,/))") &
3129 'Coefficients:', potential%c_local(1:potential%n_local)
3130 END IF
3131 END IF
3132 IF (potential%ecp_semi_local) THEN
3133 WRITE (unit=output_unit, fmt="(/,T8,'Semi-local pseudopotential')")
3134 DO l = 0, potential%sl_lmax
3135 WRITE (unit=output_unit, fmt="(T8,A,A)") 'l-value: ', slqval(l)
3136 DO i = 1, potential%npot(l)
3137 WRITE (unit=output_unit, fmt="(T21,I5,2F20.8)") &
3138 potential%nrpot(i, l), potential%bpot(i, l), potential%apot(i, l)
3139 END DO
3140 END DO
3141 END IF
3142 ! nonlocal PP
3143 IF (ALLOCATED(potential%upf_data)) THEN
3144 WRITE (unit=output_unit, fmt="(/,T8,A)") 'Nonlocal UPF potential: original radial projectors'
3145 WRITE (unit=output_unit, fmt="(T8,A,T71,I10)") 'Total number of projectors:', potential%nppnl
3146 WRITE (unit=output_unit, fmt="(T8,A)") 'Analytic angular integration and radial mesh quadrature'
3147 ELSE IF (potential%n_nonlocal > 0) THEN
3148 WRITE (unit=output_unit, fmt="(/,T8,'Nonlocal pseudopotential')")
3149 WRITE (unit=output_unit, fmt="(T8,A,T71,I10)") 'Total number of projectors:', potential%nppnl
3150 WRITE (unit=output_unit, fmt="(T8,A,10(T21,6F10.4,/))") &
3151 'Exponents:', potential%a_nonlocal(1:potential%n_nonlocal)
3152 DO l = 0, potential%lmax
3153 WRITE (unit=output_unit, fmt="(T8,'Coupling for l=',I4)") l
3154 WRITE (unit=output_unit, fmt="(10(T21,6F10.4,/))") &
3155 potential%h_nonlocal(1:potential%n_nonlocal, l)
3156 END DO
3157 END IF
3158 !
3159 IF (potential%has_nlcc) THEN
3160 WRITE (unit=output_unit, fmt="(/,T8,'Nonlinear Core Correction')")
3161 WRITE (unit=output_unit, fmt="(T8,A,10(T21,6F10.4,/))") &
3162 'Exponents:', potential%a_nlcc(1:potential%n_nlcc)
3163 WRITE (unit=output_unit, fmt="(T8,A,10(T21,6F10.4,/))") &
3164 'Coefficients:', potential%c_nlcc(1:potential%n_nlcc)
3165 END IF
3166 END IF
3167
3168 END SUBROUTINE write_sgp_potential
3169
3170! **************************************************************************************************
3171!> \brief Copy an all_potential_type to a new, unallocated variable
3172!> \param pot_in the input potential to copy
3173!> \param pot_out the newly copied and allocated potential
3174!> \par History
3175!> - Creation (12.2019, A. Bussy)
3176! **************************************************************************************************
3177 SUBROUTINE copy_all_potential(pot_in, pot_out)
3178
3179 TYPE(all_potential_type), INTENT(IN) :: pot_in
3180 TYPE(all_potential_type), INTENT(INOUT), POINTER :: pot_out
3181
3182 CALL allocate_all_potential(pot_out)
3183
3184 pot_out%name = pot_in%name
3185 pot_out%alpha_core_charge = pot_in%alpha_core_charge
3186 pot_out%ccore_charge = pot_in%ccore_charge
3187 pot_out%core_charge_radius = pot_in%core_charge_radius
3188 pot_out%zeff = pot_in%zeff
3189 pot_out%zeff_correction = pot_in%zeff_correction
3190 pot_out%z = pot_in%z
3191
3192 IF (ASSOCIATED(pot_in%elec_conf)) THEN
3193 ALLOCATE (pot_out%elec_conf(lbound(pot_in%elec_conf, 1):ubound(pot_in%elec_conf, 1)))
3194 pot_out%elec_conf(:) = pot_in%elec_conf(:)
3195 END IF
3196
3197 END SUBROUTINE copy_all_potential
3198
3199! **************************************************************************************************
3200!> \brief Copy a gth_potential_type to a new, unallocated variable
3201!> \param pot_in the input potential to copy
3202!> \param pot_out the newly copied and allocated potential
3203!> \par History
3204!> - Creation (12.2019, A. Bussy)
3205! **************************************************************************************************
3206 SUBROUTINE copy_gth_potential(pot_in, pot_out)
3207
3208 TYPE(gth_potential_type), INTENT(IN) :: pot_in
3209 TYPE(gth_potential_type), INTENT(INOUT), POINTER :: pot_out
3210
3211 CALL allocate_gth_potential(pot_out)
3212
3213 pot_out%name = pot_in%name
3214 pot_out%aliases = pot_in%aliases
3215 pot_out%alpha_core_charge = pot_in%alpha_core_charge
3216 pot_out%alpha_ppl = pot_in%alpha_ppl
3217 pot_out%ccore_charge = pot_in%ccore_charge
3218 pot_out%cerf_ppl = pot_in%cerf_ppl
3219 pot_out%zeff = pot_in%zeff
3220 pot_out%core_charge_radius = pot_in%core_charge_radius
3221 pot_out%ppl_radius = pot_in%ppl_radius
3222 pot_out%ppnl_radius = pot_in%ppnl_radius
3223 pot_out%zeff_correction = pot_in%zeff_correction
3224 pot_out%lppnl = pot_in%lppnl
3225 pot_out%lprj_ppnl_max = pot_in%lprj_ppnl_max
3226 pot_out%nexp_ppl = pot_in%nexp_ppl
3227 pot_out%nppnl = pot_in%nppnl
3228 pot_out%nprj_ppnl_max = pot_in%nprj_ppnl_max
3229 pot_out%z = pot_in%z
3230 pot_out%nlcc = pot_in%nlcc
3231 pot_out%nexp_nlcc = pot_in%nexp_nlcc
3232 pot_out%lsdpot = pot_in%lsdpot
3233 pot_out%nexp_lsd = pot_in%nexp_lsd
3234 pot_out%lpotextended = pot_in%lpotextended
3235 pot_out%nexp_lpot = pot_in%nexp_lpot
3236
3237 IF (ASSOCIATED(pot_in%alpha_ppnl)) THEN
3238 ALLOCATE (pot_out%alpha_ppnl(lbound(pot_in%alpha_ppnl, 1):ubound(pot_in%alpha_ppnl, 1)))
3239 pot_out%alpha_ppnl(:) = pot_in%alpha_ppnl(:)
3240 END IF
3241 IF (ASSOCIATED(pot_in%cexp_ppl)) THEN
3242 ALLOCATE (pot_out%cexp_ppl(lbound(pot_in%cexp_ppl, 1):ubound(pot_in%cexp_ppl, 1)))
3243 pot_out%cexp_ppl(:) = pot_in%cexp_ppl(:)
3244 END IF
3245 IF (ASSOCIATED(pot_in%elec_conf)) THEN
3246 ALLOCATE (pot_out%elec_conf(lbound(pot_in%elec_conf, 1):ubound(pot_in%elec_conf, 1)))
3247 pot_out%elec_conf(:) = pot_in%elec_conf(:)
3248 END IF
3249 IF (ASSOCIATED(pot_in%nprj_ppnl)) THEN
3250 ALLOCATE (pot_out%nprj_ppnl(lbound(pot_in%nprj_ppnl, 1):ubound(pot_in%nprj_ppnl, 1)))
3251 pot_out%nprj_ppnl(:) = pot_in%nprj_ppnl(:)
3252 END IF
3253 IF (ASSOCIATED(pot_in%cprj)) THEN
3254 ALLOCATE (pot_out%cprj(lbound(pot_in%cprj, 1):ubound(pot_in%cprj, 1), &
3255 lbound(pot_in%cprj, 2):ubound(pot_in%cprj, 2)))
3256 pot_out%cprj(:, :) = pot_in%cprj(:, :)
3257 END IF
3258 IF (ASSOCIATED(pot_in%cprj_ppnl)) THEN
3259 ALLOCATE (pot_out%cprj_ppnl(lbound(pot_in%cprj_ppnl, 1):ubound(pot_in%cprj_ppnl, 1), &
3260 lbound(pot_in%cprj_ppnl, 2):ubound(pot_in%cprj_ppnl, 2)))
3261 pot_out%cprj_ppnl(:, :) = pot_in%cprj_ppnl(:, :)
3262 END IF
3263 IF (ASSOCIATED(pot_in%hprj_ppnl)) THEN
3264 ALLOCATE (pot_out%hprj_ppnl(lbound(pot_in%hprj_ppnl, 1):ubound(pot_in%hprj_ppnl, 1), &
3265 lbound(pot_in%hprj_ppnl, 2):ubound(pot_in%hprj_ppnl, 2), &
3266 lbound(pot_in%hprj_ppnl, 3):ubound(pot_in%hprj_ppnl, 3)))
3267 pot_out%hprj_ppnl(:, :, :) = pot_in%hprj_ppnl(:, :, :)
3268 END IF
3269 IF (ASSOCIATED(pot_in%kprj_ppnl)) THEN
3270 ALLOCATE (pot_out%kprj_ppnl(lbound(pot_in%kprj_ppnl, 1):ubound(pot_in%kprj_ppnl, 1), &
3271 lbound(pot_in%kprj_ppnl, 2):ubound(pot_in%kprj_ppnl, 2), &
3272 lbound(pot_in%kprj_ppnl, 3):ubound(pot_in%kprj_ppnl, 3)))
3273 pot_out%kprj_ppnl(:, :, :) = pot_in%kprj_ppnl(:, :, :)
3274 END IF
3275 IF (ASSOCIATED(pot_in%vprj_ppnl)) THEN
3276 ALLOCATE (pot_out%vprj_ppnl(lbound(pot_in%vprj_ppnl, 1):ubound(pot_in%vprj_ppnl, 1), &
3277 lbound(pot_in%vprj_ppnl, 2):ubound(pot_in%vprj_ppnl, 2)))
3278 pot_out%vprj_ppnl(:, :) = pot_in%vprj_ppnl(:, :)
3279 END IF
3280 IF (ASSOCIATED(pot_in%wprj_ppnl)) THEN
3281 ALLOCATE (pot_out%wprj_ppnl(lbound(pot_in%wprj_ppnl, 1):ubound(pot_in%wprj_ppnl, 1), &
3282 lbound(pot_in%wprj_ppnl, 2):ubound(pot_in%wprj_ppnl, 2)))
3283 pot_out%wprj_ppnl(:, :) = pot_in%wprj_ppnl(:, :)
3284 END IF
3285 IF (ASSOCIATED(pot_in%alpha_nlcc)) THEN
3286 ALLOCATE (pot_out%alpha_nlcc(lbound(pot_in%alpha_nlcc, 1):ubound(pot_in%alpha_nlcc, 1)))
3287 pot_out%alpha_nlcc(:) = pot_in%alpha_nlcc(:)
3288 END IF
3289 IF (ASSOCIATED(pot_in%nct_nlcc)) THEN
3290 ALLOCATE (pot_out%nct_nlcc(lbound(pot_in%nct_nlcc, 1):ubound(pot_in%nct_nlcc, 1)))
3291 pot_out%nct_nlcc(:) = pot_in%nct_nlcc(:)
3292 END IF
3293 IF (ASSOCIATED(pot_in%cval_nlcc)) THEN
3294 ALLOCATE (pot_out%cval_nlcc(lbound(pot_in%cval_nlcc, 1):ubound(pot_in%cval_nlcc, 1), &
3295 lbound(pot_in%cval_nlcc, 2):ubound(pot_in%cval_nlcc, 2)))
3296 pot_out%cval_nlcc(:, :) = pot_in%cval_nlcc(:, :)
3297 END IF
3298 IF (ASSOCIATED(pot_in%alpha_lsd)) THEN
3299 ALLOCATE (pot_out%alpha_lsd(lbound(pot_in%alpha_lsd, 1):ubound(pot_in%alpha_lsd, 1)))
3300 pot_out%alpha_lsd(:) = pot_in%alpha_lsd(:)
3301 END IF
3302 IF (ASSOCIATED(pot_in%nct_lsd)) THEN
3303 ALLOCATE (pot_out%nct_lsd(lbound(pot_in%nct_lsd, 1):ubound(pot_in%nct_lsd, 1)))
3304 pot_out%nct_lsd(:) = pot_in%nct_lsd(:)
3305 END IF
3306 IF (ASSOCIATED(pot_in%cval_lsd)) THEN
3307 ALLOCATE (pot_out%cval_lsd(lbound(pot_in%cval_lsd, 1):ubound(pot_in%cval_lsd, 1), &
3308 lbound(pot_in%cval_lsd, 2):ubound(pot_in%cval_lsd, 2)))
3309 pot_out%cval_lsd(:, :) = pot_in%cval_lsd(:, :)
3310 END IF
3311 IF (ASSOCIATED(pot_in%alpha_lpot)) THEN
3312 ALLOCATE (pot_out%alpha_lpot(lbound(pot_in%alpha_lpot, 1):ubound(pot_in%alpha_lpot, 1)))
3313 pot_out%alpha_lpot(:) = pot_in%alpha_lpot(:)
3314 END IF
3315 IF (ASSOCIATED(pot_in%nct_lpot)) THEN
3316 ALLOCATE (pot_out%nct_lpot(lbound(pot_in%nct_lpot, 1):ubound(pot_in%nct_lpot, 1)))
3317 pot_out%nct_lpot(:) = pot_in%nct_lpot(:)
3318 END IF
3319 IF (ASSOCIATED(pot_in%cval_lpot)) THEN
3320 ALLOCATE (pot_out%cval_lpot(lbound(pot_in%cval_lpot, 1):ubound(pot_in%cval_lpot, 1), &
3321 lbound(pot_in%cval_lpot, 2):ubound(pot_in%cval_lpot, 2)))
3322 pot_out%cval_lpot(:, :) = pot_in%cval_lpot(:, :)
3323 END IF
3324
3325 END SUBROUTINE copy_gth_potential
3326
3327! **************************************************************************************************
3328!> \brief Copy a sgp_potential_type to a new, unallocated variable
3329!> \param pot_in the input potential to copy
3330!> \param pot_out the newly copied and allocated potential
3331!> \par History
3332!> - Creation (12.2019, A. Bussy)
3333! **************************************************************************************************
3334 SUBROUTINE copy_sgp_potential(pot_in, pot_out)
3335
3336 TYPE(sgp_potential_type), INTENT(IN) :: pot_in
3337 TYPE(sgp_potential_type), INTENT(INOUT), POINTER :: pot_out
3338
3339 CALL allocate_sgp_potential(pot_out)
3340
3341 pot_out%name = pot_in%name
3342 pot_out%aliases = pot_in%aliases
3343 pot_out%z = pot_in%z
3344 pot_out%zeff = pot_in%zeff
3345 pot_out%zeff_correction = pot_in%zeff_correction
3346 pot_out%alpha_core_charge = pot_in%alpha_core_charge
3347 pot_out%ccore_charge = pot_in%ccore_charge
3348 pot_out%core_charge_radius = pot_in%core_charge_radius
3349 pot_out%ppl_radius = pot_in%ppl_radius
3350 pot_out%ppnl_radius = pot_in%ppnl_radius
3351 pot_out%ecp_local = pot_in%ecp_local
3352 pot_out%n_local = pot_in%n_local
3353 pot_out%nloc = pot_in%nloc
3354 pot_out%nrloc = pot_in%nrloc
3355 pot_out%aloc = pot_in%aloc
3356 pot_out%bloc = pot_in%bloc
3357 pot_out%ecp_semi_local = pot_in%ecp_semi_local
3358 pot_out%sl_lmax = pot_in%sl_lmax
3359 pot_out%npot = pot_in%npot
3360 pot_out%nrpot = pot_in%nrpot
3361 pot_out%apot = pot_in%apot
3362 pot_out%bpot = pot_in%bpot
3363 pot_out%n_nonlocal = pot_in%n_nonlocal
3364 pot_out%nppnl = pot_in%nppnl
3365 pot_out%lmax = pot_in%lmax
3366 pot_out%is_nonlocal = pot_in%is_nonlocal
3367 pot_out%has_nlcc = pot_in%has_nlcc
3368 pot_out%n_nlcc = pot_in%n_nlcc
3369 IF (ALLOCATED(pot_in%upf_data)) THEN
3370 pot_out%upf_data = pot_in%upf_data
3371 pot_out%upf_projectors = pot_in%upf_projectors
3372 pot_out%upf_local = pot_in%upf_local
3373 END IF
3374
3375 IF (ASSOCIATED(pot_in%elec_conf)) THEN
3376 ALLOCATE (pot_out%elec_conf(lbound(pot_in%elec_conf, 1):ubound(pot_in%elec_conf, 1)))
3377 pot_out%elec_conf(:) = pot_in%elec_conf(:)
3378 END IF
3379 IF (ASSOCIATED(pot_in%a_local)) THEN
3380 ALLOCATE (pot_out%a_local(lbound(pot_in%a_local, 1):ubound(pot_in%a_local, 1)))
3381 pot_out%a_local(:) = pot_in%a_local(:)
3382 END IF
3383 IF (ASSOCIATED(pot_in%c_local)) THEN
3384 ALLOCATE (pot_out%c_local(lbound(pot_in%c_local, 1):ubound(pot_in%c_local, 1)))
3385 pot_out%c_local(:) = pot_in%c_local(:)
3386 END IF
3387 IF (ASSOCIATED(pot_in%a_nonlocal)) THEN
3388 ALLOCATE (pot_out%a_nonlocal(lbound(pot_in%a_nonlocal, 1):ubound(pot_in%a_nonlocal, 1)))
3389 pot_out%a_nonlocal(:) = pot_in%a_nonlocal(:)
3390 END IF
3391 IF (ASSOCIATED(pot_in%h_nonlocal)) THEN
3392 ALLOCATE (pot_out%h_nonlocal(lbound(pot_in%h_nonlocal, 1):ubound(pot_in%h_nonlocal, 1), &
3393 lbound(pot_in%h_nonlocal, 2):ubound(pot_in%h_nonlocal, 2)))
3394 pot_out%h_nonlocal(:, :) = pot_in%h_nonlocal(:, :)
3395 END IF
3396 IF (ASSOCIATED(pot_in%c_nonlocal)) THEN
3397 ALLOCATE (pot_out%c_nonlocal(lbound(pot_in%c_nonlocal, 1):ubound(pot_in%c_nonlocal, 1), &
3398 lbound(pot_in%c_nonlocal, 2):ubound(pot_in%c_nonlocal, 2), &
3399 lbound(pot_in%c_nonlocal, 3):ubound(pot_in%c_nonlocal, 3)))
3400 pot_out%c_nonlocal(:, :, :) = pot_in%c_nonlocal(:, :, :)
3401 END IF
3402 IF (ASSOCIATED(pot_in%cprj_ppnl)) THEN
3403 ALLOCATE (pot_out%cprj_ppnl(lbound(pot_in%cprj_ppnl, 1):ubound(pot_in%cprj_ppnl, 1), &
3404 lbound(pot_in%cprj_ppnl, 2):ubound(pot_in%cprj_ppnl, 2)))
3405 pot_out%cprj_ppnl(:, :) = pot_in%cprj_ppnl(:, :)
3406 END IF
3407 IF (ASSOCIATED(pot_in%vprj_ppnl)) THEN
3408 ALLOCATE (pot_out%vprj_ppnl(lbound(pot_in%vprj_ppnl, 1):ubound(pot_in%vprj_ppnl, 1)))
3409 pot_out%vprj_ppnl(:) = pot_in%vprj_ppnl(:)
3410 END IF
3411 IF (ASSOCIATED(pot_in%a_nlcc)) THEN
3412 ALLOCATE (pot_out%a_nlcc(lbound(pot_in%a_nlcc, 1):ubound(pot_in%a_nlcc, 1)))
3413 pot_out%a_nlcc(:) = pot_in%a_nlcc(:)
3414 END IF
3415 IF (ASSOCIATED(pot_in%c_nlcc)) THEN
3416 ALLOCATE (pot_out%c_nlcc(lbound(pot_in%c_nlcc, 1):ubound(pot_in%c_nlcc, 1)))
3417 pot_out%c_nlcc(:) = pot_in%c_nlcc(:)
3418 END IF
3419
3420 END SUBROUTINE copy_sgp_potential
3421
3422END MODULE external_potential_types
All kind of helpful little routines.
Definition ao_util.F:14
real(kind=dp) function, public exp_radius(l, alpha, threshold, prefactor, epsabs, epsrel, rlow)
The radius of a primitive Gaussian function for a given threshold is calculated. g(r) = prefactor*r**...
Definition ao_util.F:96
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public goedecker1996
integer, save, public hartwigsen1998
integer, save, public krack2000
integer, save, public krack2005
logical function, public cp_sll_val_next(iterator, el_att)
returns true if the actual element is valid (i.e. iterator ont at end) moves the iterator to the next...
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.
subroutine, public parser_search_string(parser, string, ignore_case, found, line, begin_line, search_from_begin_of_file)
Search a string pattern in a file defined by its logical unit number "unit". A case sensitive search ...
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.
Definition of the atomic potential types.
subroutine, public set_default_all_potential(potential, z, zeff_correction)
...
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_val_set(section_vals, keyword_name, i_rep_section, i_rep_val, val, l_val, i_val, r_val, c_val, l_vals_ptr, i_vals_ptr, r_vals_ptr, c_vals_ptr)
sets the requested value
subroutine, public section_vals_list_get(section_vals, keyword_name, i_rep_section, list)
returns the requested list
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
a wrapper for basic fortran types.
subroutine, public val_get(val, has_l, has_i, has_r, has_lc, has_c, l_val, l_vals, i_val, i_vals, r_val, r_vals, c_val, c_vals, len_c, type_of_var, enum)
returns the stored values
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
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition list.F:24
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), dimension(-1:2 *maxfac+1), parameter, public dfac
real(kind=dp), parameter, public rootpi
real(kind=dp), parameter, public fourpi
real(kind=dp), dimension(0:maxfac), parameter, public fac
Collection of simple mathematical functions and subroutines.
Definition mathlib.F:15
subroutine, public symmetrize_matrix(a, option)
Symmetrize the matrix a.
Definition mathlib.F:1209
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
integer, dimension(:, :, :), allocatable, public co
integer, dimension(:), allocatable, public nco
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :, :), allocatable, public coset
integer, dimension(:), allocatable, public nso
Calculation of the spherical harmonics and the corresponding orbital transformation matrices.
type(orbtramat_type), dimension(:), pointer, public orbtramat
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
Utilities for string manipulations.
character(len=1), parameter, public newline
subroutine, public remove_word(string)
remove a word from a string (words are separated by white spaces)
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Local UPF matrix elements from the original radial potential. The Gaussian core electrostatics suppli...
Half-numerical overlaps with the original scalar UPF radial projectors. Cartesian polynomials and ang...
subroutine, public upf_projector_init(pot, degree, projectors)
Prepare immutable radial and angular data outside parallel regions.
Owned UPF dataset and radial conventions shared by ATOM and Quickstep. Dataset availability does not ...
Definition upf_types.F:12
represent a single linked list that stores pointers to the elements
a type to have a wrapper that stores any basic fortran type
stores all the informations relevant to an mpi environment