(git:0de0cc2)
atom_energy.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4 ! !
5 ! SPDX-License-Identifier: GPL-2.0-or-later !
6 !--------------------------------------------------------------------------------------------------!
7 
8 MODULE atom_energy
11  USE atom_fit, ONLY: atom_fit_density,&
14  USE atom_operators, ONLY: atom_int_release,&
20  USE atom_output, ONLY: atom_print_basis,&
27  USE atom_types, ONLY: &
28  atom_basis_type, atom_gthpot_type, atom_integrals, atom_optimization_type, atom_orbitals, &
29  atom_p_type, atom_potential_type, atom_state, atom_type, create_atom_orbs, &
32  set_atom
33  USE atom_utils, ONLY: &
37  USE atom_xc, ONLY: calculate_atom_ext_vxc,&
40  cp_logger_type
43  USE input_constants, ONLY: do_analytic
46  section_vals_type,&
48  USE kinds, ONLY: default_string_length,&
49  dp
50  USE mathconstants, ONLY: dfac,&
51  gamma1,&
52  pi
53  USE periodic_table, ONLY: nelem,&
54  ptable
55  USE physcon, ONLY: bohr
56 #include "./base/base_uses.f90"
57 
58  IMPLICIT NONE
59  PRIVATE
60  PUBLIC :: atom_energy_opt
61 
62  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'atom_energy'
63 
64 CONTAINS
65 
66 ! **************************************************************************************************
67 !> \brief Compute the atomic energy.
68 !> \param atom_section ATOM input section
69 !> \par History
70 !> * 11.2016 geometrical response basis set [Juerg Hutter]
71 !> * 07.2016 ADMM analysis [Juerg Hutter]
72 !> * 02.2014 non-additive kinetic energy term [Juerg Hutter]
73 !> * 11.2013 Zhao, Morrison, and Parr (ZMP) potential [Daniele Varsano]
74 !> * 02.2010 unrestricted KS and HF methods [Juerg Hutter]
75 !> * 05.2009 electronic density fit [Juerg Hutter]
76 !> * 04.2009 refactored and renamed to atom_energy_opt() [Juerg Hutter]
77 !> * 08.2008 created as atom_energy() [Juerg Hutter]
78 ! **************************************************************************************************
79  SUBROUTINE atom_energy_opt(atom_section)
80  TYPE(section_vals_type), POINTER :: atom_section
81 
82  CHARACTER(len=*), PARAMETER :: routinen = 'atom_energy_opt'
83 
84  CHARACTER(LEN=2) :: elem
85  CHARACTER(LEN=default_string_length) :: filename
86  CHARACTER(LEN=default_string_length), &
87  DIMENSION(:), POINTER :: tmpstringlist
88  INTEGER :: do_eric, do_erie, handle, i, im, in, iw, k, maxl, mb, method, mo, n_meth, n_rep, &
89  nder, nr_gh, num_gau, num_gto, num_pol, reltyp, zcore, zval, zz
90  INTEGER, DIMENSION(0:lmat) :: maxn
91  INTEGER, DIMENSION(:), POINTER :: cn
92  LOGICAL :: dm, do_gh, do_zmp, doread, eri_c, eri_e, &
93  had_ae, had_pp, lcomp, lcond, pp_calc, &
94  read_vxc
95  REAL(kind=dp) :: crad, delta, lambda
96  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: ext_density, ext_vxc
97  REAL(kind=dp), DIMENSION(0:lmat, 10) :: pocc
98  TYPE(atom_basis_type), POINTER :: ae_basis, pp_basis
99  TYPE(atom_integrals), POINTER :: ae_int, pp_int
100  TYPE(atom_optimization_type) :: optimization
101  TYPE(atom_orbitals), POINTER :: orbitals
102  TYPE(atom_p_type), DIMENSION(:, :), POINTER :: atom_info
103  TYPE(atom_potential_type), POINTER :: ae_pot, p_pot
104  TYPE(atom_state), POINTER :: state
105  TYPE(cp_logger_type), POINTER :: logger
106  TYPE(section_vals_type), POINTER :: admm_section, basis_section, external_vxc_section, &
107  method_section, opt_section, potential_section, powell_section, sgp_section, xc_section, &
108  zmp_restart_section, zmp_section
109 
110  CALL timeset(routinen, handle)
111 
112  ! What atom do we calculate
113  CALL section_vals_val_get(atom_section, "ATOMIC_NUMBER", i_val=zval)
114  CALL section_vals_val_get(atom_section, "ELEMENT", c_val=elem)
115  zz = 0
116  DO i = 1, nelem
117  IF (ptable(i)%symbol == elem) THEN
118  zz = i
119  EXIT
120  END IF
121  END DO
122  IF (zz /= 1) zval = zz
123 
124  ! read and set up inofrmation on the basis sets
125  ALLOCATE (ae_basis, pp_basis)
126  basis_section => section_vals_get_subs_vals(atom_section, "AE_BASIS")
127  NULLIFY (ae_basis%grid)
128  CALL init_atom_basis(ae_basis, basis_section, zval, "AE")
129  NULLIFY (pp_basis%grid)
130  basis_section => section_vals_get_subs_vals(atom_section, "PP_BASIS")
131  CALL init_atom_basis(pp_basis, basis_section, zval, "PP")
132 
133  ! print general and basis set information
134  logger => cp_get_default_logger()
135  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%PROGRAM_BANNER", extension=".log")
136  IF (iw > 0) CALL atom_print_info(zval, "Atomic Energy Calculation", iw)
137  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%PROGRAM_BANNER")
138  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%BASIS_SET", extension=".log")
139  IF (iw > 0) THEN
140  CALL atom_print_basis(ae_basis, iw, " All Electron Basis")
141  CALL atom_print_basis(pp_basis, iw, " Pseudopotential Basis")
142  END IF
143  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%BASIS_SET")
144 
145  ! read and setup information on the pseudopotential
146  NULLIFY (potential_section)
147  potential_section => section_vals_get_subs_vals(atom_section, "POTENTIAL")
148  ALLOCATE (ae_pot, p_pot)
149  CALL init_atom_potential(p_pot, potential_section, zval)
150  CALL init_atom_potential(ae_pot, potential_section, -1)
151 
152  ! if the ERI's are calculated analytically, we have to precalculate them
153  eri_c = .false.
154  CALL section_vals_val_get(atom_section, "COULOMB_INTEGRALS", i_val=do_eric)
155  IF (do_eric == do_analytic) eri_c = .true.
156  eri_e = .false.
157  CALL section_vals_val_get(atom_section, "EXCHANGE_INTEGRALS", i_val=do_erie)
158  IF (do_erie == do_analytic) eri_e = .true.
159  CALL section_vals_val_get(atom_section, "USE_GAUSS_HERMITE", l_val=do_gh)
160  CALL section_vals_val_get(atom_section, "GRID_POINTS_GH", i_val=nr_gh)
161 
162  ! information on the states to be calculated
163  CALL section_vals_val_get(atom_section, "MAX_ANGULAR_MOMENTUM", i_val=maxl)
164  maxn = 0
165  CALL section_vals_val_get(atom_section, "CALCULATE_STATES", i_vals=cn)
166  DO in = 1, min(SIZE(cn), 4)
167  maxn(in - 1) = cn(in)
168  END DO
169  DO in = 0, lmat
170  maxn(in) = min(maxn(in), ae_basis%nbas(in))
171  maxn(in) = min(maxn(in), pp_basis%nbas(in))
172  END DO
173 
174  ! read optimization section
175  opt_section => section_vals_get_subs_vals(atom_section, "OPTIMIZATION")
176  CALL read_atom_opt_section(optimization, opt_section)
177 
178  had_ae = .false.
179  had_pp = .false.
180 
181  ! Check for the total number of electron configurations to be calculated
182  CALL section_vals_val_get(atom_section, "ELECTRON_CONFIGURATION", n_rep_val=n_rep)
183  ! Check for the total number of method types to be calculated
184  method_section => section_vals_get_subs_vals(atom_section, "METHOD")
185  CALL section_vals_get(method_section, n_repetition=n_meth)
186 
187  ! integrals
188  ALLOCATE (ae_int, pp_int)
189 
190  ALLOCATE (atom_info(n_rep, n_meth))
191 
192  DO in = 1, n_rep
193  DO im = 1, n_meth
194 
195  NULLIFY (atom_info(in, im)%atom)
196  CALL create_atom_type(atom_info(in, im)%atom)
197 
198  atom_info(in, im)%atom%optimization = optimization
199 
200  atom_info(in, im)%atom%z = zval
201  xc_section => section_vals_get_subs_vals(method_section, "XC", i_rep_section=im)
202  atom_info(in, im)%atom%xc_section => xc_section
203 
204  ! ZMP Reading input sections if they are found initialize everything
205  do_zmp = .false.
206  doread = .false.
207  read_vxc = .false.
208 
209  zmp_section => section_vals_get_subs_vals(method_section, "ZMP")
210  CALL section_vals_get(zmp_section, explicit=do_zmp)
211  atom_info(in, im)%atom%do_zmp = do_zmp
212  CALL section_vals_val_get(zmp_section, "FILE_DENSITY", c_val=filename)
213  atom_info(in, im)%atom%ext_file = filename
214  CALL section_vals_val_get(zmp_section, "GRID_TOL", &
215  r_val=atom_info(in, im)%atom%zmpgrid_tol)
216  CALL section_vals_val_get(zmp_section, "LAMBDA", r_val=lambda)
217  atom_info(in, im)%atom%lambda = lambda
218  CALL section_vals_val_get(zmp_section, "DM", l_val=dm)
219  atom_info(in, im)%atom%dm = dm
220 
221  zmp_restart_section => section_vals_get_subs_vals(zmp_section, "RESTART")
222  CALL section_vals_get(zmp_restart_section, explicit=doread)
223  atom_info(in, im)%atom%doread = doread
224  CALL section_vals_val_get(zmp_restart_section, "FILE_RESTART", c_val=filename)
225  atom_info(in, im)%atom%zmp_restart_file = filename
226 
227  ! ZMP Reading external vxc section, if found initialize
228  external_vxc_section => section_vals_get_subs_vals(method_section, "EXTERNAL_VXC")
229  CALL section_vals_get(external_vxc_section, explicit=read_vxc)
230  atom_info(in, im)%atom%read_vxc = read_vxc
231  CALL section_vals_val_get(external_vxc_section, "FILE_VXC", c_val=filename)
232  atom_info(in, im)%atom%ext_vxc_file = filename
233  CALL section_vals_val_get(external_vxc_section, "GRID_TOL", &
234  r_val=atom_info(in, im)%atom%zmpvxcgrid_tol)
235 
236  ALLOCATE (state)
237 
238  ! get the electronic configuration
239  CALL section_vals_val_get(atom_section, "ELECTRON_CONFIGURATION", i_rep_val=in, &
240  c_vals=tmpstringlist)
241 
242  ! set occupations
243  CALL atom_set_occupation(tmpstringlist, state%occ, state%occupation, state%multiplicity)
244  state%maxl_occ = get_maxl_occ(state%occ)
245  state%maxn_occ = get_maxn_occ(state%occ)
246 
247  ! set number of states to be calculated
248  state%maxl_calc = max(maxl, state%maxl_occ)
249  state%maxl_calc = min(lmat, state%maxl_calc)
250  state%maxn_calc = 0
251  DO k = 0, state%maxl_calc
252  state%maxn_calc(k) = max(maxn(k), state%maxn_occ(k))
253  END DO
254 
255  ! is there a pseudo potential
256  pp_calc = any(index(tmpstringlist(1:), "CORE") /= 0)
257  IF (pp_calc) THEN
258  ! get and set the core occupations
259  CALL section_vals_val_get(atom_section, "CORE", c_vals=tmpstringlist)
260  CALL atom_set_occupation(tmpstringlist, state%core, pocc)
261  zcore = zval - nint(sum(state%core))
262  CALL set_atom(atom_info(in, im)%atom, zcore=zcore, pp_calc=.true.)
263  ELSE
264  state%core = 0._dp
265  CALL set_atom(atom_info(in, im)%atom, zcore=zval, pp_calc=.false.)
266  END IF
267 
268  CALL section_vals_val_get(method_section, "METHOD_TYPE", i_val=method, i_rep_section=im)
269  CALL section_vals_val_get(method_section, "RELATIVISTIC", i_val=reltyp, i_rep_section=im)
270  CALL set_atom(atom_info(in, im)%atom, method_type=method, relativistic=reltyp)
271 
272  IF (atom_consistent_method(method, state%multiplicity)) THEN
273  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%METHOD_INFO", extension=".log")
274  CALL atom_print_method(atom_info(in, im)%atom, iw)
275  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%METHOD_INFO")
276 
277  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%POTENTIAL", extension=".log")
278  IF (pp_calc) THEN
279  IF (iw > 0) CALL atom_print_potential(p_pot, iw)
280  ELSE
281  IF (iw > 0) CALL atom_print_potential(ae_pot, iw)
282  END IF
283  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%POTENTIAL")
284  END IF
285 
286  ! calculate integrals
287  IF (pp_calc) THEN
288  ! general integrals
289  CALL atom_int_setup(pp_int, pp_basis, &
290  potential=p_pot, eri_coulomb=eri_c, eri_exchange=eri_e)
291  ! potential
292  CALL atom_ppint_setup(pp_int, pp_basis, potential=p_pot)
293  !
294  NULLIFY (pp_int%tzora, pp_int%hdkh)
295  !
296  CALL set_atom(atom_info(in, im)%atom, basis=pp_basis, integrals=pp_int, potential=p_pot)
297  state%maxn_calc(:) = min(state%maxn_calc(:), pp_basis%nbas(:))
298  cpassert(all(state%maxn_calc(:) >= state%maxn_occ))
299  had_pp = .true.
300  ELSE
301  ! general integrals
302  CALL atom_int_setup(ae_int, ae_basis, potential=ae_pot, &
303  eri_coulomb=eri_c, eri_exchange=eri_e)
304  ! potential
305  CALL atom_ppint_setup(ae_int, ae_basis, potential=ae_pot)
306  ! relativistic correction terms
307  CALL atom_relint_setup(ae_int, ae_basis, reltyp, zcore=real(zval, dp))
308  !
309  CALL set_atom(atom_info(in, im)%atom, basis=ae_basis, integrals=ae_int, potential=ae_pot)
310  state%maxn_calc(:) = min(state%maxn_calc(:), ae_basis%nbas(:))
311  cpassert(all(state%maxn_calc(:) >= state%maxn_occ))
312  had_ae = .true.
313  END IF
314 
315  CALL set_atom(atom_info(in, im)%atom, state=state)
316 
317  CALL set_atom(atom_info(in, im)%atom, coulomb_integral_type=do_eric, &
318  exchange_integral_type=do_erie)
319  atom_info(in, im)%atom%hfx_pot%do_gh = do_gh
320  atom_info(in, im)%atom%hfx_pot%nr_gh = nr_gh
321 
322  NULLIFY (orbitals)
323  mo = maxval(state%maxn_calc)
324  mb = maxval(atom_info(in, im)%atom%basis%nbas)
325  CALL create_atom_orbs(orbitals, mb, mo)
326  CALL set_atom(atom_info(in, im)%atom, orbitals=orbitals)
327 
328  IF (atom_consistent_method(method, state%multiplicity)) THEN
329  !Calculate the electronic structure
330  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%SCF_INFO", extension=".log")
331  CALL calculate_atom(atom_info(in, im)%atom, iw)
332  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%SCF_INFO")
333 
334  ! ZMP If we have the external density do zmp
335  IF (atom_info(in, im)%atom%do_zmp) THEN
336  CALL atom_write_zmp_restart(atom_info(in, im)%atom)
337 
338  ALLOCATE (ext_density(atom_info(in, im)%atom%basis%grid%nr))
339  ext_density = 0._dp
340  CALL atom_read_external_density(ext_density, atom_info(in, im)%atom, iw)
341  CALL calculate_atom_zmp(ext_density=ext_density, &
342  atom=atom_info(in, im)%atom, &
343  lprint=.true.)
344  DEALLOCATE (ext_density)
345  END IF
346  ! ZMP If we have the external v_xc calculate KS quantities
347  IF (atom_info(in, im)%atom%read_vxc) THEN
348  ALLOCATE (ext_vxc(atom_info(in, im)%atom%basis%grid%nr))
349  ext_vxc = 0._dp
350  CALL atom_read_external_vxc(ext_vxc, atom_info(in, im)%atom, iw)
351  CALL calculate_atom_ext_vxc(vxc=ext_vxc, &
352  atom=atom_info(in, im)%atom, &
353  lprint=.true.)
354  DEALLOCATE (ext_vxc)
355  END IF
356 
357  ! Print out the orbitals if requested
358  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%ORBITALS", extension=".log")
359  IF (iw > 0) THEN
360  CALL atom_print_orbitals(atom_info(in, im)%atom, iw)
361  END IF
362  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%ORBITALS")
363 
364  ! perform a fit of the total electronic density
365  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%FIT_DENSITY", extension=".log")
366  IF (iw > 0) THEN
367  CALL section_vals_val_get(atom_section, "PRINT%FIT_DENSITY%NUM_GTO", i_val=num_gto)
368  powell_section => section_vals_get_subs_vals(atom_section, "POWELL")
369  CALL atom_fit_density(atom_info(in, im)%atom, num_gto, 0, iw, powell_section=powell_section)
370  END IF
371  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%FIT_DENSITY")
372 
373  ! Optimize a local potential for the non-additive kinetic energy term in KG
374  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%FIT_KGPOT", extension=".log")
375  IF (iw > 0) THEN
376  CALL section_vals_val_get(atom_section, "PRINT%FIT_KGPOT%NUM_GAUSSIAN", i_val=num_gau)
377  CALL section_vals_val_get(atom_section, "PRINT%FIT_KGPOT%NUM_POLYNOM", i_val=num_pol)
378  powell_section => section_vals_get_subs_vals(atom_section, "POWELL")
379  CALL atom_fit_kgpot(atom_info(in, im)%atom, num_gau, num_pol, iw, powell_section=powell_section)
380  END IF
381  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%FIT_KGPOT")
382 
383  ! generate a response basis
384  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%RESPONSE_BASIS", extension=".log")
385  IF (iw > 0) THEN
386  CALL section_vals_val_get(atom_section, "PRINT%RESPONSE_BASIS%DELTA_CHARGE", r_val=delta)
387  CALL section_vals_val_get(atom_section, "PRINT%RESPONSE_BASIS%DERIVATIVES", i_val=nder)
388  CALL atom_response_basis(atom_info(in, im)%atom, delta, nder, iw)
389  END IF
390  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%RESPONSE_BASIS")
391 
392  ! generate a UPF file
393  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%UPF_FILE", extension=".upf", &
394  file_position="REWIND")
395  IF (iw > 0) THEN
396  CALL atom_write_upf(atom_info(in, im)%atom, iw)
397  END IF
398  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%UPF_FILE")
399  END IF
400 
401  END DO
402  END DO
403 
404  ! generate a geometrical response basis (GRB)
405  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%GEOMETRICAL_RESPONSE_BASIS", extension=".log")
406  IF (iw > 0) THEN
407  CALL atom_grb_construction(atom_info, atom_section, iw)
408  END IF
409  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%GEOMETRICAL_RESPONSE_BASIS")
410 
411  ! Analyze basis sets
412  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%ANALYZE_BASIS", extension=".log")
413  IF (iw > 0) THEN
414  CALL section_vals_val_get(atom_section, "PRINT%ANALYZE_BASIS%OVERLAP_CONDITION_NUMBER", l_val=lcond)
415  CALL section_vals_val_get(atom_section, "PRINT%ANALYZE_BASIS%COMPLETENESS", l_val=lcomp)
416  crad = ptable(zval)%covalent_radius*bohr
417  IF (had_ae) THEN
418  IF (lcond) CALL atom_condnumber(ae_basis, crad, iw)
419  IF (lcomp) CALL atom_completeness(ae_basis, zval, iw)
420  END IF
421  IF (had_pp) THEN
422  IF (lcond) CALL atom_condnumber(pp_basis, crad, iw)
423  IF (lcomp) CALL atom_completeness(pp_basis, zval, iw)
424  END IF
425  END IF
426  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%ANALYZE_BASIS")
427 
428  ! Analyse ADMM approximation
429  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%ADMM", extension=".log")
430  admm_section => section_vals_get_subs_vals(atom_section, "PRINT%ADMM")
431  IF (iw > 0) THEN
432  CALL atom_admm(atom_info, admm_section, iw)
433  END IF
434  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%ADMM")
435 
436  ! Generate a separable form of the pseudopotential using Gaussian functions
437  iw = cp_print_key_unit_nr(logger, atom_section, "PRINT%SEPARABLE_GAUSSIAN_PSEUDO", extension=".log")
438  sgp_section => section_vals_get_subs_vals(atom_section, "PRINT%SEPARABLE_GAUSSIAN_PSEUDO")
439  IF (iw > 0) THEN
440  CALL atom_sgp_construction(atom_info, sgp_section, iw)
441  END IF
442  CALL cp_print_key_finished_output(iw, logger, atom_section, "PRINT%SEPARABLE_GAUSSIAN_PSEUDO")
443 
444  ! clean up
445  IF (had_ae) THEN
446  CALL atom_int_release(ae_int)
447  CALL atom_ppint_release(ae_int)
448  CALL atom_relint_release(ae_int)
449  END IF
450  IF (had_pp) THEN
451  CALL atom_int_release(pp_int)
452  CALL atom_ppint_release(pp_int)
453  CALL atom_relint_release(pp_int)
454  END IF
455  CALL release_atom_basis(ae_basis)
456  CALL release_atom_basis(pp_basis)
457 
458  CALL release_atom_potential(p_pot)
459  CALL release_atom_potential(ae_pot)
460 
461  DO in = 1, n_rep
462  DO im = 1, n_meth
463  CALL release_atom_type(atom_info(in, im)%atom)
464  END DO
465  END DO
466  DEALLOCATE (atom_info)
467 
468  DEALLOCATE (ae_pot, p_pot, ae_basis, pp_basis, ae_int, pp_int)
469 
470  CALL timestop(handle)
471 
472  END SUBROUTINE atom_energy_opt
473 
474 ! **************************************************************************************************
475 !> \brief Calculate response basis contraction coefficients.
476 !> \param atom information about the atomic kind
477 !> \param delta variation of charge used in finite difference derivative calculation
478 !> \param nder number of wavefunction derivatives to calculate
479 !> \param iw output file unit
480 !> \par History
481 !> * 10.2011 Gram-Schmidt orthogonalization [Joost VandeVondele]
482 !> * 05.2009 created [Juerg Hutter]
483 ! **************************************************************************************************
484  SUBROUTINE atom_response_basis(atom, delta, nder, iw)
485 
486  TYPE(atom_type), POINTER :: atom
487  REAL(kind=dp), INTENT(IN) :: delta
488  INTEGER, INTENT(IN) :: nder, iw
489 
490  INTEGER :: i, ider, j, k, l, lhomo, m, n, nhomo, &
491  s1, s2
492  REAL(kind=dp) :: dene, emax, expzet, fhomo, o, prefac, &
493  zeta
494  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: amat
495  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :) :: rbasis
496  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :, :, :) :: wfn
497  REAL(kind=dp), DIMENSION(:, :, :), POINTER :: ovlp
498  TYPE(atom_state), POINTER :: state
499 
500  WRITE (iw, '(/," ",79("*"),/,T30,A,A/," ",79("*"))') "RESPONSE BASIS for ", ptable(atom%z)%symbol
501 
502  state => atom%state
503  ovlp => atom%integrals%ovlp
504 
505  ! find HOMO
506  lhomo = -1
507  nhomo = -1
508  emax = -huge(1._dp)
509  DO l = 0, state%maxl_occ
510  DO i = 1, state%maxn_occ(l)
511  IF (atom%orbitals%ener(i, l) > emax) THEN
512  lhomo = l
513  nhomo = i
514  emax = atom%orbitals%ener(i, l)
515  fhomo = state%occupation(l, i)
516  END IF
517  END DO
518  END DO
519 
520  s1 = SIZE(atom%orbitals%wfn, 1)
521  s2 = SIZE(atom%orbitals%wfn, 2)
522  ALLOCATE (wfn(s1, s2, 0:lmat, -nder:nder))
523  s2 = maxval(state%maxn_occ) + nder
524  ALLOCATE (rbasis(s1, s2, 0:lmat))
525  rbasis = 0._dp
526 
527  DO ider = -nder, nder
528  dene = real(ider, kind=dp)*delta
529  cpassert(fhomo > abs(dene))
530  state%occupation(lhomo, nhomo) = fhomo + dene
531  CALL calculate_atom(atom, iw=0, noguess=.true.)
532  wfn(:, :, :, ider) = atom%orbitals%wfn
533  state%occupation(lhomo, nhomo) = fhomo
534  END DO
535 
536  DO l = 0, state%maxl_occ
537  ! occupied states
538  DO i = 1, max(state%maxn_occ(l), 1)
539  rbasis(:, i, l) = wfn(:, i, l, 0)
540  END DO
541  ! differentiation
542  DO ider = 1, nder
543  i = max(state%maxn_occ(l), 1)
544  SELECT CASE (ider)
545  CASE (1)
546  rbasis(:, i + 1, l) = 0.5_dp*(wfn(:, i, l, 1) - wfn(:, i, l, -1))/delta
547  CASE (2)
548  rbasis(:, i + 2, l) = 0.25_dp*(wfn(:, i, l, 2) - 2._dp*wfn(:, i, l, 0) + wfn(:, i, l, -2))/delta**2
549  CASE (3)
550  rbasis(:, i + 3, l) = 0.125_dp*(wfn(:, i, l, 3) - 3._dp*wfn(:, i, l, 1) &
551  + 3._dp*wfn(:, i, l, -1) - wfn(:, i, l, -3))/delta**3
552  CASE DEFAULT
553  cpabort("")
554  END SELECT
555  END DO
556 
557  ! orthogonalization, use gram-schmidt in order to keep the natural order (semi-core, valence, response) of the wfn.
558  n = state%maxn_occ(l) + nder
559  m = atom%basis%nbas(l)
560  DO i = 1, n
561  DO j = 1, i - 1
562  o = dot_product(rbasis(1:m, j, l), reshape(matmul(ovlp(1:m, 1:m, l), rbasis(1:m, i:i, l)), (/m/)))
563  rbasis(1:m, i, l) = rbasis(1:m, i, l) - o*rbasis(1:m, j, l)
564  END DO
565  o = dot_product(rbasis(1:m, i, l), reshape(matmul(ovlp(1:m, 1:m, l), rbasis(1:m, i:i, l)), (/m/)))
566  rbasis(1:m, i, l) = rbasis(1:m, i, l)/sqrt(o)
567  END DO
568 
569  ! check
570  ALLOCATE (amat(n, n))
571  amat(1:n, 1:n) = matmul(transpose(rbasis(1:m, 1:n, l)), matmul(ovlp(1:m, 1:m, l), rbasis(1:m, 1:n, l)))
572  DO i = 1, n
573  amat(i, i) = amat(i, i) - 1._dp
574  END DO
575  IF (maxval(abs(amat)) > 1.e-12) THEN
576  WRITE (iw, '(/,A,G20.10)') " Orthogonality error ", maxval(abs(amat))
577  END IF
578  DEALLOCATE (amat)
579 
580  ! Quickstep normalization
581  WRITE (iw, '(/,A,T30,I3)') " Angular momentum :", l
582 
583  WRITE (iw, '(/,A,I0,A,I0,A)') " Exponent Coef.(Quickstep Normalization), first ", &
584  n - nder, " valence ", nder, " response"
585  expzet = 0.25_dp*real(2*l + 3, dp)
586  prefac = sqrt(sqrt(pi)/2._dp**(l + 2)*dfac(2*l + 1))
587  DO i = 1, m
588  zeta = (2._dp*atom%basis%am(i, l))**expzet
589  WRITE (iw, '(4X,F20.10,4X,15ES20.6)') atom%basis%am(i, l), ((prefac*rbasis(i, k, l)/zeta), k=1, n)
590  END DO
591 
592  END DO
593 
594  DEALLOCATE (wfn, rbasis)
595 
596  WRITE (iw, '(" ",79("*"))')
597 
598  END SUBROUTINE atom_response_basis
599 
600 ! **************************************************************************************************
601 !> \brief Write pseudo-potential in Quantum Espresso UPF format.
602 !> \param atom information about the atomic kind
603 !> \param iw output file unit
604 !> \par History
605 !> * 09.2012 created [Juerg Hutter]
606 ! **************************************************************************************************
607  SUBROUTINE atom_write_upf(atom, iw)
608 
609  TYPE(atom_type), POINTER :: atom
610  INTEGER, INTENT(IN) :: iw
611 
612  CHARACTER(LEN=default_string_length) :: string
613  INTEGER :: i, ibeta, j, k, l, lmax, nbeta, nr, &
614  nwfc, nwfn
615  LOGICAL :: up
616  REAL(kind=dp) :: pf, rl, rmax
617  REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: beta, corden, dens, ef, locpot, rp
618  REAL(kind=dp), ALLOCATABLE, DIMENSION(:, :) :: dij
619  TYPE(atom_gthpot_type), POINTER :: pot
620 
621  IF (.NOT. atom%pp_calc) RETURN
622  IF (atom%potential%ppot_type /= gth_pseudo) RETURN
623  pot => atom%potential%gth_pot
624  cpassert(.NOT. pot%lsdpot)
625 
626  WRITE (iw, '(A)') '<UPF version="2.0.1">'
627 
628  WRITE (iw, '(T4,A)') '<PP_INFO>'
629  WRITE (iw, '(T8,A)') 'Converted from CP2K GTH format'
630  WRITE (iw, '(T8,A)') '<PP_INPUTFILE>'
631  CALL atom_write_pseudo_param(pot, iw)
632  WRITE (iw, '(T8,A)') '</PP_INPUTFILE>'
633  WRITE (iw, '(T4,A)') '</PP_INFO>'
634  WRITE (iw, '(T4,A)') '<PP_HEADER'
635  WRITE (iw, '(T8,A)') 'generated="Generated in analytical, separable form"'
636  WRITE (iw, '(T8,A)') 'author="Goedecker/Hartwigsen/Hutter/Teter"'
637  WRITE (iw, '(T8,A)') 'date="Phys.Rev.B58, 3641 (1998); B54, 1703 (1996)"'
638  WRITE (iw, '(T8,A)') 'comment="This file generated by CP2K ATOM code"'
639  CALL compose(string, "element", cval=pot%symbol)
640  WRITE (iw, '(T8,A)') trim(string)
641  WRITE (iw, '(T8,A)') 'pseudo_type="NC"'
642  WRITE (iw, '(T8,A)') 'relativistic="no"'
643  WRITE (iw, '(T8,A)') 'is_ultrasoft="F"'
644  WRITE (iw, '(T8,A)') 'is_paw="F"'
645  WRITE (iw, '(T8,A)') 'is_coulomb="F"'
646  WRITE (iw, '(T8,A)') 'has_so="F"'
647  WRITE (iw, '(T8,A)') 'has_wfc="F"'
648  WRITE (iw, '(T8,A)') 'has_gipaw="F"'
649  WRITE (iw, '(T8,A)') 'paw_as_gipaw="F"'
650  IF (pot%nlcc) THEN
651  WRITE (iw, '(T8,A)') 'core_correction="T"'
652  ELSE
653  WRITE (iw, '(T8,A)') 'core_correction="F"'
654  END IF
655  WRITE (iw, '(T8,A)') 'functional="DFT"'
656  CALL compose(string, "z_valence", rval=pot%zion)
657  WRITE (iw, '(T8,A)') trim(string)
658  CALL compose(string, "total_psenergy", rval=2._dp*atom%energy%etot)
659  WRITE (iw, '(T8,A)') trim(string)
660  WRITE (iw, '(T8,A)') 'wfc_cutoff="0.0E+00"'
661  WRITE (iw, '(T8,A)') 'rho_cutoff="0.0E+00"'
662  lmax = -1
663  DO l = 0, lmat
664  IF (pot%nl(l) > 0) lmax = l
665  END DO
666  CALL compose(string, "l_max", ival=lmax)
667  WRITE (iw, '(T8,A)') trim(string)
668  WRITE (iw, '(T8,A)') 'l_max_rho="0"'
669  WRITE (iw, '(T8,A)') 'l_local="-3"'
670  nr = atom%basis%grid%nr
671  CALL compose(string, "mesh_size", ival=nr)
672  WRITE (iw, '(T8,A)') trim(string)
673  nwfc = sum(atom%state%maxn_occ)
674  CALL compose(string, "number_of_wfc", ival=nwfc)
675  WRITE (iw, '(T8,A)') trim(string)
676  nbeta = sum(pot%nl)
677  CALL compose(string, "number_of_proj", ival=nbeta)
678  WRITE (iw, '(T8,A)') trim(string)//'/>'
679 
680  ! Mesh
681  up = atom%basis%grid%rad(1) < atom%basis%grid%rad(nr)
682  WRITE (iw, '(T4,A)') '<PP_MESH'
683  WRITE (iw, '(T8,A)') 'dx="1.E+00"'
684  CALL compose(string, "mesh", ival=nr)
685  WRITE (iw, '(T8,A)') trim(string)
686  WRITE (iw, '(T8,A)') 'xmin="1.E+00"'
687  rmax = maxval(atom%basis%grid%rad)
688  CALL compose(string, "rmax", rval=rmax)
689  WRITE (iw, '(T8,A)') trim(string)
690  WRITE (iw, '(T8,A)') 'zmesh="1.E+00">'
691  WRITE (iw, '(T8,A)') '<PP_R type="real"'
692  CALL compose(string, "size", ival=nr)
693  WRITE (iw, '(T12,A)') trim(string)
694  WRITE (iw, '(T12,A)') 'columns="4">'
695  IF (up) THEN
696  WRITE (iw, '(T12,4ES25.12E3)') (atom%basis%grid%rad(i), i=1, nr)
697  ELSE
698  WRITE (iw, '(T12,4ES25.12E3)') (atom%basis%grid%rad(i), i=nr, 1, -1)
699  END IF
700  WRITE (iw, '(T8,A)') '</PP_R>'
701  WRITE (iw, '(T8,A)') '<PP_RAB type="real"'
702  CALL compose(string, "size", ival=nr)
703  WRITE (iw, '(T12,A)') trim(string)
704  WRITE (iw, '(T12,A)') 'columns="4">'
705  IF (up) THEN
706  WRITE (iw, '(T12,4ES25.12E3)') (atom%basis%grid%wr(i)/atom%basis%grid%rad2(i), i=1, nr)
707  ELSE
708  WRITE (iw, '(T12,4ES25.12E3)') (atom%basis%grid%wr(i)/atom%basis%grid%rad2(i), i=nr, 1, -1)
709  END IF
710  WRITE (iw, '(T8,A)') '</PP_RAB>'
711  WRITE (iw, '(T4,A)') '</PP_MESH>'
712 
713  ! NLCC
714  IF (pot%nlcc) THEN
715  WRITE (iw, '(T4,A)') '<PP_NLCC type="real"'
716  CALL compose(string, "size", ival=nr)
717  WRITE (iw, '(T8,A)') trim(string)
718  WRITE (iw, '(T8,A)') 'columns="4">'
719  ALLOCATE (corden(nr))
720  corden(:) = 0.0_dp
721  CALL atom_core_density(corden, atom%potential, "RHO", atom%basis%grid%rad)
722  IF (up) THEN
723  WRITE (iw, '(T8,4ES25.12E3)') (corden(i), i=1, nr)
724  ELSE
725  WRITE (iw, '(T8,4ES25.12E3)') (corden(i), i=nr, 1, -1)
726  END IF
727  DEALLOCATE (corden)
728  WRITE (iw, '(T4,A)') '</PP_NLCC>'
729  END IF
730 
731  ! local PP
732  WRITE (iw, '(T4,A)') '<PP_LOCAL type="real"'
733  CALL compose(string, "size", ival=nr)
734  WRITE (iw, '(T8,A)') trim(string)
735  WRITE (iw, '(T8,A)') 'columns="4">'
736  ALLOCATE (locpot(nr))
737  locpot(:) = 0.0_dp
738  CALL atom_local_potential(locpot, pot, atom%basis%grid%rad)
739  IF (up) THEN
740  WRITE (iw, '(T8,4ES25.12E3)') (2.0_dp*locpot(i), i=1, nr)
741  ELSE
742  WRITE (iw, '(T8,4ES25.12E3)') (2.0_dp*locpot(i), i=nr, 1, -1)
743  END IF
744  DEALLOCATE (locpot)
745  WRITE (iw, '(T4,A)') '</PP_LOCAL>'
746 
747  ! nonlocal PP
748  WRITE (iw, '(T4,A)') '<PP_NONLOCAL>'
749  ALLOCATE (rp(nr), ef(nr), beta(nr))
750  ibeta = 0
751  DO l = 0, lmat
752  IF (pot%nl(l) == 0) cycle
753  rl = pot%rcnl(l)
754  rp(:) = atom%basis%grid%rad
755  ef(:) = exp(-0.5_dp*rp*rp/(rl*rl))
756  DO i = 1, pot%nl(l)
757  pf = rl**(l + 0.5_dp*(4._dp*i - 1._dp))
758  j = l + 2*i - 1
759  pf = sqrt(2._dp)/(pf*sqrt(gamma1(j)))
760  beta(:) = pf*rp**(l + 2*i - 2)*ef
761  ibeta = ibeta + 1
762  CALL compose(string, "<PP_BETA", counter=ibeta)
763  WRITE (iw, '(T8,A)') trim(string)
764  CALL compose(string, "angular_momentum", ival=l)
765  WRITE (iw, '(T12,A)') trim(string)
766  WRITE (iw, '(T12,A)') 'type="real"'
767  CALL compose(string, "size", ival=nr)
768  WRITE (iw, '(T12,A)') trim(string)
769  WRITE (iw, '(T12,A)') 'columns="4">'
770  beta(:) = beta*rp
771  IF (up) THEN
772  WRITE (iw, '(T12,4ES25.12E3)') (2._dp*beta(j), j=1, nr)
773  ELSE
774  WRITE (iw, '(T12,4ES25.12E3)') (2._dp*beta(j), j=nr, 1, -1)
775  END IF
776  CALL compose(string, "</PP_BETA", counter=ibeta, isfinal=.true.)
777  WRITE (iw, '(T8,A)') trim(string)
778  END DO
779  END DO
780  DEALLOCATE (rp, ef, beta)
781  ! nonlocal PP matrix elements
782  ALLOCATE (dij(nbeta, nbeta))
783  dij = 0._dp
784  DO l = 0, lmat
785  IF (pot%nl(l) == 0) cycle
786  ibeta = sum(pot%nl(0:l - 1)) + 1
787  i = ibeta + pot%nl(l) - 1
788  dij(ibeta:i, ibeta:i) = pot%hnl(1:pot%nl(l), 1:pot%nl(l), l)
789  END DO
790  WRITE (iw, '(T8,A)') '<PP_DIJ type="real"'
791  WRITE (iw, '(T12,A)') 'columns="4">'
792  WRITE (iw, '(T12,4ES25.12E3)') ((0.5_dp*dij(i, j), j=1, nbeta), i=1, nbeta)
793  WRITE (iw, '(T8,A)') '</PP_DIJ>'
794  DEALLOCATE (dij)
795  WRITE (iw, '(T4,A)') '</PP_NONLOCAL>'
796 
797  ! atomic wavefunctions
798  ALLOCATE (beta(nr))
799  WRITE (iw, '(T4,A)') '<PP_PSWFC>'
800  nwfn = 0
801  DO l = 0, lmat
802  DO i = 1, 10
803  IF (abs(atom%state%occupation(l, i)) == 0._dp) cycle
804  nwfn = nwfn + 1
805  CALL compose(string, "<PP_CHI", counter=nwfn)
806  WRITE (iw, '(T8,A)') trim(string)
807  CALL compose(string, "l", ival=l)
808  WRITE (iw, '(T12,A)') trim(string)
809  CALL compose(string, "occupation", rval=atom%state%occupation(l, i))
810  WRITE (iw, '(T12,A)') trim(string)
811  CALL compose(string, "pseudo_energy", rval=2._dp*atom%orbitals%ener(i, l))
812  WRITE (iw, '(T12,A)') trim(string)
813  WRITE (iw, '(T12,A)') 'columns="4">'
814  beta = 0._dp
815  DO k = 1, atom%basis%nbas(l)
816  beta(:) = beta(:) + atom%orbitals%wfn(k, i, l)*atom%basis%bf(:, k, l)
817  END DO
818  beta(:) = beta*atom%basis%grid%rad
819  IF (up) THEN
820  WRITE (iw, '(T12,4ES25.12E3)') (beta(j)*atom%basis%grid%rad(j), j=1, nr)
821  ELSE
822  WRITE (iw, '(T12,4ES25.12E3)') (beta(j)*atom%basis%grid%rad(j), j=nr, 1, -1)
823  END IF
824  CALL compose(string, "</PP_CHI", counter=nwfn, isfinal=.true.)
825  WRITE (iw, '(T8,A)') trim(string)
826  END DO
827  END DO
828  WRITE (iw, '(T4,A)') '</PP_PSWFC>'
829  DEALLOCATE (beta)
830 
831  ! atomic charge
832  ALLOCATE (dens(nr))
833  WRITE (iw, '(T4,A)') '<PP_RHOATOM type="real"'
834  CALL compose(string, "size", ival=nr)
835  WRITE (iw, '(T8,A)') trim(string)
836  WRITE (iw, '(T8,A)') 'columns="4">'
837  CALL atom_density(dens, atom%orbitals%pmat, atom%basis, atom%state%maxl_occ, &
838  "RHO", atom%basis%grid%rad)
839  IF (up) THEN
840  WRITE (iw, '(T8,4ES25.12E3)') (4._dp*pi*dens(j)*atom%basis%grid%rad2(j), j=1, nr)
841  ELSE
842  WRITE (iw, '(T8,4ES25.12E3)') (4._dp*pi*dens(j)*atom%basis%grid%rad2(j), j=nr, 1, -1)
843  END IF
844  WRITE (iw, '(T4,A)') '</PP_RHOATOM>'
845  DEALLOCATE (dens)
846 
847  WRITE (iw, '(A)') '</UPF>'
848 
849  END SUBROUTINE atom_write_upf
850 
851 ! **************************************************************************************************
852 !> \brief Produce an XML attribute string 'tag="counter/rval/ival/cval"'
853 !> \param string composed string
854 !> \param tag attribute tag
855 !> \param counter counter
856 !> \param rval real variable
857 !> \param ival integer variable
858 !> \param cval string variable
859 !> \param isfinal close the current XML element if this is the last attribute
860 !> \par History
861 !> * 09.2012 created [Juerg Hutter]
862 ! **************************************************************************************************
863  SUBROUTINE compose(string, tag, counter, rval, ival, cval, isfinal)
864  CHARACTER(len=*), INTENT(OUT) :: string
865  CHARACTER(len=*), INTENT(IN) :: tag
866  INTEGER, INTENT(IN), OPTIONAL :: counter
867  REAL(kind=dp), INTENT(IN), OPTIONAL :: rval
868  INTEGER, INTENT(IN), OPTIONAL :: ival
869  CHARACTER(len=*), INTENT(IN), OPTIONAL :: cval
870  LOGICAL, INTENT(IN), OPTIONAL :: isfinal
871 
872  CHARACTER(LEN=default_string_length) :: str
873  LOGICAL :: fin
874 
875  IF (PRESENT(counter)) THEN
876  WRITE (str, "(I12)") counter
877  ELSEIF (PRESENT(rval)) THEN
878  WRITE (str, "(G18.8)") rval
879  ELSEIF (PRESENT(ival)) THEN
880  WRITE (str, "(I12)") ival
881  ELSEIF (PRESENT(cval)) THEN
882  WRITE (str, "(A)") trim(adjustl(cval))
883  ELSE
884  WRITE (str, "(A)") ""
885  END IF
886  fin = .false.
887  IF (PRESENT(isfinal)) fin = isfinal
888  IF (PRESENT(counter)) THEN
889  IF (fin) THEN
890  WRITE (string, "(A,A1,A,A1)") trim(adjustl(tag)), '.', trim(adjustl(str)), '>'
891  ELSE
892  WRITE (string, "(A,A1,A)") trim(adjustl(tag)), '.', trim(adjustl(str))
893  END IF
894  ELSE
895  IF (fin) THEN
896  WRITE (string, "(A,A2,A,A2)") trim(adjustl(tag)), '="', trim(adjustl(str)), '>"'
897  ELSE
898  WRITE (string, "(A,A2,A,A1)") trim(adjustl(tag)), '="', trim(adjustl(str)), '"'
899  END IF
900  END IF
901  END SUBROUTINE compose
902 
903 END MODULE atom_energy
static GRID_HOST_DEVICE orbital up(const int i, const orbital a)
Increase i'th component of given orbital angular momentum.
Definition: grid_common.h:133
subroutine, public atom_admm(atom_info, admm_section, iw)
Analysis of ADMM approximation to exact exchange.
subroutine, public calculate_atom(atom, iw, noguess, converged)
General routine to perform electronic structure atomic calculations.
subroutine, public atom_energy_opt(atom_section)
Compute the atomic energy.
Definition: atom_energy.F:80
routines that fit parameters for /from atomic calculations
Definition: atom_fit.F:11
subroutine, public atom_fit_density(atom, num_gto, norder, iunit, powell_section, results)
Fit the atomic electron density using a geometrical Gaussian basis set.
Definition: atom_fit.F:77
subroutine, public atom_fit_kgpot(atom, num_gau, num_pol, iunit, powell_section, results)
...
Definition: atom_fit.F:1867
subroutine, public atom_grb_construction(atom_info, atom_section, iw)
Construct geometrical response basis set.
Definition: atom_grb.F:78
Calculate the atomic operator matrices.
subroutine, public atom_ppint_release(integrals)
Release memory allocated for atomic integrals (core electrons).
subroutine, public atom_int_setup(integrals, basis, potential, eri_coulomb, eri_exchange, all_nu)
Set up atomic integrals.
subroutine, public atom_relint_setup(integrals, basis, reltyp, zcore, alpha)
...
subroutine, public atom_relint_release(integrals)
Release memory allocated for atomic integrals (relativistic effects).
subroutine, public atom_ppint_setup(integrals, basis, potential)
...
subroutine, public atom_int_release(integrals)
Release memory allocated for atomic integrals (valence electrons).
Routines that print various information about an atomic kind.
Definition: atom_output.F:11
subroutine, public atom_print_basis(atom_basis, iw, title)
Print atomic basis set.
Definition: atom_output.F:292
subroutine, public atom_write_pseudo_param(gthpot, iunit)
Print GTH pseudo-potential parameters.
Definition: atom_output.F:744
subroutine, public atom_print_method(atom, iw)
Print information about the electronic structure method in use.
Definition: atom_output.F:503
subroutine, public atom_print_orbitals(atom, iw)
Print atomic orbitals.
Definition: atom_output.F:812
subroutine, public atom_print_potential(potential, iw)
Print information about the pseudo-potential.
Definition: atom_output.F:639
subroutine, public atom_print_info(zval, info, iw)
Print an information string related to the atomic kind.
Definition: atom_output.F:63
subroutine, public atom_sgp_construction(atom_info, input_section, iw)
...
Definition: atom_sgp.F:201
Define the atom type and its sub types.
Definition: atom_types.F:15
subroutine, public read_atom_opt_section(optimization, opt_section)
...
Definition: atom_types.F:2395
subroutine, public create_atom_type(atom)
...
Definition: atom_types.F:944
subroutine, public release_atom_type(atom)
...
Definition: atom_types.F:968
subroutine, public release_atom_potential(potential)
...
Definition: atom_types.F:2521
subroutine, public init_atom_basis(basis, basis_section, zval, btyp)
Initialize the basis for the atomic code.
Definition: atom_types.F:375
integer, parameter, public lmat
Definition: atom_types.F:67
subroutine, public set_atom(atom, basis, state, integrals, orbitals, potential, zcore, pp_calc, do_zmp, doread, read_vxc, method_type, relativistic, coulomb_integral_type, exchange_integral_type, fmat)
...
Definition: atom_types.F:1009
subroutine, public init_atom_potential(potential, potential_section, zval)
...
Definition: atom_types.F:2421
subroutine, public release_atom_basis(basis)
...
Definition: atom_types.F:910
subroutine, public create_atom_orbs(orbs, mbas, mo)
...
Definition: atom_types.F:1055
Some basic routines for atomic calculations.
Definition: atom_utils.F:15
subroutine, public atom_condnumber(basis, crad, iw)
Print condition numbers of the given atomic basis set.
Definition: atom_utils.F:2310
pure subroutine, public atom_local_potential(locpot, gthpot, rr)
...
Definition: atom_utils.F:800
subroutine, public atom_read_external_vxc(vxc, atom, iw)
ZMP subroutine to read external v_xc in the atomic code.
Definition: atom_utils.F:608
pure logical function, public atom_consistent_method(method, multiplicity)
Check that the atomic multiplicity is consistent with the electronic structure method.
Definition: atom_utils.F:2189
subroutine, public atom_core_density(corden, potential, typ, rr)
...
Definition: atom_utils.F:694
pure integer function, dimension(0:lmat), public get_maxn_occ(occupation)
Return the maximum principal quantum number of occupied orbitals.
Definition: atom_utils.F:302
subroutine, public atom_density(density, pmat, basis, maxl, typ, rr)
Map the electron density on an atomic radial grid.
Definition: atom_utils.F:367
subroutine, public atom_read_external_density(density, atom, iw)
ZMP subroutine to read external density from linear grid of density matrix.
Definition: atom_utils.F:517
subroutine, public atom_completeness(basis, zv, iw)
Estimate completeness of the given atomic basis set.
Definition: atom_utils.F:2345
subroutine, public atom_write_zmp_restart(atom)
ZMP subroutine to write external restart file.
Definition: atom_utils.F:424
subroutine, public atom_set_occupation(ostring, occupation, wfnocc, multiplicity)
Set occupation of atomic orbitals.
Definition: atom_utils.F:104
pure integer function, public get_maxl_occ(occupation)
Return the maximum orbital quantum number of occupied orbitals.
Definition: atom_utils.F:282
routines that build the integrals of the Vxc potential calculated for the atomic code
Definition: atom_xc.F:12
subroutine, public calculate_atom_ext_vxc(vxc, atom, lprint, xcmat)
ZMP subroutine for the scf external density from the external v_xc.
Definition: atom_xc.F:148
subroutine, public calculate_atom_zmp(ext_density, atom, lprint, xcmat)
ZMP subroutine for the calculation of the effective constraint potential in the atomic code.
Definition: atom_xc.F:78
Definition: atom.F:9
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public do_analytic
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
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
Definition of mathematical constants and functions.
Definition: mathconstants.F:16
real(kind=dp), dimension(0:maxfac), parameter, public gamma1
Definition: mathconstants.F:95
real(kind=dp), parameter, public pi
real(kind=dp), dimension(-1:2 *maxfac+1), parameter, public dfac
Definition: mathconstants.F:61
Periodic Table related data definitions.
type(atom), dimension(0:nelem), public ptable
integer, parameter, public nelem
Definition of physical constants:
Definition: physcon.F:68
real(kind=dp), parameter, public bohr
Definition: physcon.F:147