69 CHARACTER(len=*),
PARAMETER :: routinen =
'atom_pseudo_opt'
71 CHARACTER(LEN=2) :: elem, refm
72 CHARACTER(LEN=default_string_length), &
73 DIMENSION(:),
POINTER :: tmpstringlist
74 INTEGER :: ads, do_eric, do_erie, handle, i, im, &
75 in, iw, k, l, maxl, mb, method, mo, &
76 n_meth, n_rep, nr_gh, reltyp, zcore, &
78 INTEGER,
DIMENSION(0:lmat) :: maxn
79 INTEGER,
DIMENSION(:),
POINTER :: cn
80 LOGICAL :: do_gh, do_ppref, eri_c, eri_e, explicit, &
82 REAL(kind=
dp) :: ne, nm
83 REAL(kind=
dp),
DIMENSION(0:lmat, 10) :: pocc
88 TYPE(
atom_p_type),
DIMENSION(:, :),
POINTER :: atom_info, atom_refs
90 TYPE(
atom_state),
POINTER :: state, statepp, stateref
93 opt_section, potential_section, &
94 powell_section, xc_section
96 CALL timeset(routinen, handle)
103 IF (
ptable(i)%symbol == elem)
THEN
108 IF (zz /= 1) zval = zz
111 ALLOCATE (ae_basis, pp_basis)
113 NULLIFY (ae_basis%grid)
115 NULLIFY (pp_basis%grid)
122 IF (iw > 0)
CALL atom_print_info(zval,
"Atomic Energy Calculation", iw)
134 do_ppref = (refm ==
"PP")
137 NULLIFY (potential_section)
139 ALLOCATE (ae_pot, p_pot)
149 IF (.NOT. p_pot%confinement .AND. .NOT. ae_pot%confinement)
THEN
151 p_pot%confinement = .true.
156 p_pot%rcon = (2._dp*
ptable(zval)%covalent_radius*
bohr)**2
157 ae_pot%confinement = .true.
162 ae_pot%rcon = (2._dp*
ptable(zval)%covalent_radius*
bohr)**2
179 DO in = 1, min(
SIZE(cn), 4)
180 maxn(in - 1) = cn(in)
183 maxn(in) = min(maxn(in), ae_basis%nbas(in))
197 ALLOCATE (ae_int, pp_int)
199 ALLOCATE (atom_info(n_rep, n_meth), atom_refs(n_rep, n_meth))
203 WRITE (iw,
'(/," ",79("*"))')
204 WRITE (iw,
'(" ",26("*"),A,25("*"))')
" Calculate Reference States "
205 WRITE (iw,
'(" ",79("*"))')
212 NULLIFY (atom_info(in, im)%atom, atom_refs(in, im)%atom)
216 atom_info(in, im)%atom%optimization = optimization
217 atom_refs(in, im)%atom%optimization = optimization
219 atom_info(in, im)%atom%z = zval
220 atom_refs(in, im)%atom%z = zval
222 atom_info(in, im)%atom%xc_section => xc_section
223 atom_refs(in, im)%atom%xc_section => xc_section
225 ALLOCATE (state, statepp, stateref)
229 c_vals=tmpstringlist)
231 pp_calc = index(tmpstringlist(1),
"CORE") /= 0
232 cpassert(.NOT. pp_calc)
239 state%maxl_calc = max(maxl, state%maxl_occ)
240 state%maxl_calc = min(
lmat, state%maxl_calc)
242 DO k = 0, state%maxl_calc
244 IF (state%maxn_occ(k) == 0) ads = 1
245 state%maxn_calc(k) = max(maxn(k), state%maxn_occ(k) + ads)
246 state%maxn_calc(k) = min(state%maxn_calc(k), ae_basis%nbas(k))
250 IF (state%multiplicity /= -1)
THEN
255 nm = real((2*l + 1), kind=
dp)
257 ne = state%occupation(l, k)
258 IF (ne == 0._dp)
THEN
260 ELSEIF (ne == 2._dp*nm)
THEN
261 state%occa(l, k) = nm
262 state%occb(l, k) = nm
263 ELSEIF (state%multiplicity == -2)
THEN
264 state%occa(l, k) = min(ne, nm)
265 state%occb(l, k) = max(0._dp, ne - nm)
267 state%occa(l, k) = 0.5_dp*(ne + state%multiplicity - 1._dp)
268 state%occb(l, k) = ne - state%occa(l, k)
283 zcore = zval - nint(sum(stateref%core))
284 CALL set_atom(atom_refs(in, im)%atom, zcore=zcore, pp_calc=.true.)
286 stateref%occ = state%occ - stateref%core
287 stateref%occupation = 0._dp
291 IF (stateref%occ(l, i) /= 0._dp)
THEN
293 stateref%occupation(l, k) = state%occ(l, i)
294 IF (state%multiplicity /= -1)
THEN
295 stateref%occa(l, k) = state%occa(l, i) - stateref%core(l, i)/2
296 stateref%occb(l, k) = state%occb(l, i) - stateref%core(l, i)/2
304 stateref%maxl_calc = state%maxl_calc
305 stateref%maxn_calc = 0
307 DO k = 0, stateref%maxl_calc
308 stateref%maxn_calc(k) = state%maxn_calc(k) - maxn(k)
309 stateref%maxn_calc(k) = min(stateref%maxn_calc(k), ae_basis%nbas(k))
311 stateref%multiplicity = state%multiplicity
316 CALL set_atom(atom_refs(in, im)%atom, zcore=zval, pp_calc=.false.)
323 zcore = zval - nint(sum(statepp%core))
324 CALL set_atom(atom_info(in, im)%atom, zcore=zcore, pp_calc=.true.)
326 statepp%occ = state%occ - statepp%core
327 statepp%occupation = 0._dp
331 IF (statepp%occ(l, i) /= 0._dp)
THEN
333 statepp%occupation(l, k) = state%occ(l, i)
334 IF (state%multiplicity /= -1)
THEN
335 statepp%occa(l, k) = state%occa(l, i) - statepp%core(l, i)/2
336 statepp%occb(l, k) = state%occb(l, i) - statepp%core(l, i)/2
344 statepp%maxl_calc = state%maxl_calc
345 statepp%maxn_calc = 0
347 DO k = 0, statepp%maxl_calc
348 statepp%maxn_calc(k) = state%maxn_calc(k) - maxn(k)
349 statepp%maxn_calc(k) = min(statepp%maxn_calc(k), pp_basis%nbas(k))
351 statepp%multiplicity = state%multiplicity
355 CALL set_atom(atom_info(in, im)%atom, method_type=method)
357 CALL set_atom(atom_refs(in, im)%atom, method_type=method)
359 CALL set_atom(atom_refs(in, im)%atom, method_type=method, relativistic=reltyp)
364 CALL atom_int_setup(pp_int, pp_basis, potential=p_pot, eri_coulomb=eri_c, eri_exchange=eri_e)
366 NULLIFY (pp_int%tzora, pp_int%hdkh)
370 CALL set_atom(atom_info(in, im)%atom, basis=pp_basis, integrals=pp_int, potential=p_pot)
371 statepp%maxn_calc(:) = min(statepp%maxn_calc(:), pp_basis%nbas(:))
372 cpassert(all(state%maxn_calc(:) >= state%maxn_occ))
377 eri_coulomb=eri_c, eri_exchange=eri_e)
381 NULLIFY (ae_int%tzora, ae_int%hdkh)
387 CALL set_atom(atom_refs(in, im)%atom, basis=ae_basis, integrals=ae_int, potential=ae_pot)
388 stateref%maxn_calc(:) = min(stateref%maxn_calc(:), ae_basis%nbas(:))
389 cpassert(all(stateref%maxn_calc(:) >= stateref%maxn_occ))
391 CALL set_atom(atom_info(in, im)%atom, coulomb_integral_type=do_eric, &
392 exchange_integral_type=do_erie)
393 CALL set_atom(atom_refs(in, im)%atom, coulomb_integral_type=do_eric, &
394 exchange_integral_type=do_erie)
395 atom_info(in, im)%atom%hfx_pot%do_gh = do_gh
396 atom_info(in, im)%atom%hfx_pot%nr_gh = nr_gh
397 atom_refs(in, im)%atom%hfx_pot%do_gh = do_gh
398 atom_refs(in, im)%atom%hfx_pot%nr_gh = nr_gh
400 CALL set_atom(atom_info(in, im)%atom, state=statepp)
402 mo = maxval(statepp%maxn_calc)
403 mb = maxval(atom_info(in, im)%atom%basis%nbas)
405 CALL set_atom(atom_info(in, im)%atom, orbitals=orbitals)
407 CALL set_atom(atom_refs(in, im)%atom, state=stateref)
409 mo = maxval(stateref%maxn_calc)
410 mb = maxval(atom_refs(in, im)%atom%basis%nbas)
412 CALL set_atom(atom_refs(in, im)%atom, orbitals=orbitals)
414 IF (
atom_consistent_method(atom_refs(in, im)%atom%method_type, atom_refs(in, im)%atom%state%multiplicity))
THEN
430 WRITE (iw,
'(/," ",79("*"))')
431 WRITE (iw,
'(" ",21("*"),A,21("*"))')
" Optimize Pseudopotential Parameters "
432 WRITE (iw,
'(" ",79("*"))')
485 DEALLOCATE (atom_info, atom_refs)
487 DEALLOCATE (ae_pot, p_pot, ae_basis, pp_basis, ae_int, pp_int)
489 CALL timestop(handle)