31 use,
intrinsic :: iso_fortran_env
61 real(real64),
allocatable :: c6free(:)
62 real(real64),
allocatable :: dpfree(:)
63 real(real64),
allocatable :: r0free(:)
64 real(real64),
allocatable :: c6abfree(:, :)
65 real(real64),
allocatable :: volfree(:)
66 real(real64),
allocatable :: c6ab(:, :)
67 real(real64) :: cutoff
68 real(real64) :: damping
71 real(real64),
allocatable :: derivative_coeff(:)
77 type(vdw_ts_t),
intent(out) :: this
78 type(namespace_t),
intent(in) :: namespace
79 type(ions_t),
intent(in) :: ions
81 integer :: ispecies, jspecies
82 real(real64) :: num, den
120 safe_allocate(this%c6free(1:ions%nspecies))
121 safe_allocate(this%dpfree(1:ions%nspecies))
122 safe_allocate(this%r0free(1:ions%nspecies))
123 safe_allocate(this%volfree(1:ions%nspecies))
124 safe_allocate(this%c6abfree(1:ions%nspecies, 1:ions%nspecies))
125 safe_allocate(this%c6ab(1:ions%natoms, 1:ions%natoms))
126 safe_allocate(this%derivative_coeff(1:ions%natoms))
128 do ispecies = 1, ions%nspecies
129 call get_vdw_param(namespace, ions%species(ispecies)%s%get_label(), &
130 this%c6free(ispecies), this%dpfree(ispecies), this%r0free(ispecies))
131 select type(spec=>ions%species(ispecies)%s)
139 do ispecies = 1, ions%nspecies
140 do jspecies = 1, ions%nspecies
141 num =
m_two*this%c6free(ispecies)*this%c6free(jspecies)
142 den = (this%dpfree(jspecies)/this%dpfree(ispecies))*this%c6free(ispecies) &
143 + (this%dpfree(ispecies)/this%dpfree(jspecies))*this%c6free(jspecies)
144 this%c6abfree(ispecies, jspecies) = num/den
153 type(vdw_ts_t),
intent(inout) :: this
157 safe_deallocate_a(this%c6free)
158 safe_deallocate_a(this%dpfree)
159 safe_deallocate_a(this%r0free)
160 safe_deallocate_a(this%volfree)
161 safe_deallocate_a(this%c6abfree)
162 safe_deallocate_a(this%c6ab)
163 safe_deallocate_a(this%derivative_coeff)
170 subroutine vdw_ts_calculate(this, namespace, space, latt, atom, natoms, pos, mesh, nspin, density, energy, potential, force)
171 type(
vdw_ts_t),
intent(inout) :: this
173 class(
space_t),
intent(in) :: space
175 type(
atom_t),
intent(in) :: atom(:)
176 integer,
intent(in) :: natoms
177 real(real64),
intent(in) :: pos(1:space%dim,1:natoms)
178 class(
mesh_t),
intent(in) :: mesh
179 integer,
intent(in) :: nspin
180 real(real64),
intent(in) :: density(:, :)
181 real(real64),
intent(out) :: energy
182 real(real64),
intent(out) :: potential(:)
183 real(real64),
intent(out) :: force(:, :)
186 subroutine f90_vdw_calculate(natoms, dd, sr, zatom, coordinates, vol_ratio, &
187 energy, force, derivative_coeff)
188 use,
intrinsic :: iso_fortran_env
190 integer,
intent(in) :: natoms
191 real(real64),
intent(in) :: dd
192 real(real64),
intent(in) :: sr
193 integer,
intent(in) :: zatom
194 real(real64),
intent(in) :: coordinates
195 real(real64),
intent(in) :: vol_ratio
196 real(real64),
intent(out) :: energy
197 real(real64),
intent(out) :: force
198 real(real64),
intent(out) :: derivative_coeff
199 end subroutine f90_vdw_calculate
203 integer :: iatom, jatom, ispecies, jspecies, jcopy, ip
204 real(real64) :: rr, rr6, dffdr0, ee, ff, dee, dffdrab, dffdvra, deabdvra
205 real(real64),
allocatable :: coordinates(:,:), vol_ratio(:), dvadens(:), dvadrr(:), &
206 dr0dvra(:), r0ab(:,:)
208 integer,
allocatable :: zatom(:)
209 real(real64) :: x_j(space%dim)
213 safe_allocate(vol_ratio(1:natoms))
214 safe_allocate(dvadens(1:mesh%np))
215 safe_allocate(dvadrr(1:3))
216 safe_allocate(dr0dvra(1:natoms))
219 force(1:space%dim, 1:natoms) =
m_zero
220 this%derivative_coeff(1:natoms) =
m_zero
221 call hirshfeld_init(hirshfeld, mesh, namespace, space, latt, atom, natoms, pos, nspin)
228 ispecies = atom(iatom)%species%get_index()
231 jspecies = atom(jatom)%species%get_index()
232 this%c6ab(iatom,jatom) = vol_ratio(iatom)*vol_ratio(jatom)*this%c6abfree(ispecies,jspecies)
236 if (space%is_periodic())
then
237 safe_allocate(r0ab(1:natoms,1:natoms))
241 ispecies = atom(iatom)%species%get_index()
243 jspecies = atom(jatom)%species%get_index()
245 r0ab(iatom,jatom) = (vol_ratio(iatom)**(
m_one/
m_three))*this%r0free(ispecies) &
246 + (vol_ratio(jatom)**(
m_one/
m_three))*this%r0free(jspecies)
252 jspecies = atom(jatom)%species%get_index()
254 do jcopy = 1, latt_iter%n_cells
255 x_j = pos(:, jatom) + latt_iter%get(jcopy)
258 ispecies = atom(iatom)%species%get_index()
259 rr = norm2(x_j - pos(:, iatom))
262 if (rr < 1.0e-10_real64) cycle
264 ee =
exp(-this%damping * ((rr / (this%sr*r0ab(iatom, jatom))) -
m_one))
269 dffdrab = (this%damping/(this%sr*r0ab(iatom, jatom)))*dee
271 dffdr0 = -this%damping*rr/(this%sr*r0ab(iatom, jatom)**2)*dee
273 energy = energy -
m_half*ff*this%c6ab(iatom, jatom)/rr6
276 dffdvra = dffdr0*dr0dvra(iatom)
279 deabdvra = (dffdvra*this%c6ab(iatom, jatom) + ff*vol_ratio(jatom)*this%c6abfree(ispecies, jspecies))/rr6
281 this%derivative_coeff(iatom) = this%derivative_coeff(iatom) + deabdvra
287 safe_deallocate_a(r0ab)
289 safe_allocate(coordinates(1:space%dim, 1:natoms))
290 safe_allocate(zatom(1:natoms))
293 coordinates(:, iatom) = pos(:, iatom)
294 zatom(iatom) = int(atom(iatom)%species%get_z())
298 call f90_vdw_calculate(natoms, this%damping, this%sr, zatom(1), coordinates(1, 1), &
299 vol_ratio(1), energy, force(1, 1), this%derivative_coeff(1))
302 safe_deallocate_a(coordinates)
303 safe_deallocate_a(zatom)
310 call lalg_axpy(mesh%np, -this%derivative_coeff(iatom), dvadens, potential)
319 safe_deallocate_a(vol_ratio)
320 safe_deallocate_a(dvadens)
321 safe_deallocate_a(dvadrr)
322 safe_deallocate_a(dr0dvra)
332 type(
ions_t),
intent(in) :: ions
333 real(real64),
intent(inout) :: force_vdw(1:ions%space%dim, 1:ions%natoms)
334 class(
mesh_t),
intent(in) :: mesh
335 integer,
intent(in) :: nspin
336 real(real64),
intent(in) :: density(:, :)
341 integer :: iatom, jatom, ispecies, jspecies, jcopy
342 real(real64) :: rr, rr6, dffdr0, ee, ff, dee, dffdvra, deabdvra, deabdrab, x_j(ions%space%dim)
343 real(real64),
allocatable :: vol_ratio(:), dvadrr(:), dr0dvra(:), r0ab(:,:), derivative_coeff(:), c6ab(:,:)
349 safe_allocate(vol_ratio(1:ions%natoms))
350 safe_allocate(dvadrr(1:3))
351 safe_allocate(dr0dvra(1:ions%natoms))
352 safe_allocate(r0ab(1:ions%natoms,1:ions%natoms))
353 safe_allocate(derivative_coeff(1:ions%natoms))
354 safe_allocate(c6ab(1:ions%natoms,1:ions%natoms))
357 force_vdw(1:ions%space%dim, 1:ions%natoms) =
m_zero
358 derivative_coeff(1:ions%natoms) =
m_zero
359 c6ab(1:ions%natoms,1:ions%natoms) =
m_zero
360 r0ab(1:ions%natoms,1:ions%natoms) =
m_zero
361 dr0dvra(1:ions%natoms) =
m_zero
362 dvadrr(1:ions%space%dim) =
m_zero
363 vol_ratio(1:ions%natoms) =
m_zero
366 call hirshfeld_init(hirshfeld, mesh, ions%namespace, ions%space, ions%latt, ions%atom, ions%natoms, ions%pos, nspin)
369 do iatom = 1, ions%natoms
373 do iatom = 1, ions%natoms
374 ispecies = ions%atom(iatom)%species%get_index()
376 do jatom = 1, ions%natoms
377 jspecies = ions%atom(jatom)%species%get_index()
378 c6ab(iatom, jatom) = vol_ratio(iatom)*vol_ratio(jatom)*this%c6abfree(ispecies, jspecies)
383 do iatom = 1, ions%natoms
384 ispecies = ions%atom(iatom)%species%get_index()
385 do jatom = iatom, ions%natoms
386 jspecies = ions%atom(jatom)%species%get_index()
388 r0ab(iatom, jatom) = (vol_ratio(iatom)**(
m_one/
m_three))*this%r0free(ispecies) &
389 + (vol_ratio(jatom)**(
m_one/
m_three))*this%r0free(jspecies)
390 if (iatom /= jatom) r0ab(jatom, iatom) = r0ab(iatom, jatom)
395 do jatom = 1, ions%natoms
396 jspecies = ions%atom(jatom)%species%get_index()
398 do jcopy = 1, latt_iter%n_cells
399 x_j = ions%pos(:, jatom) + latt_iter%get(jcopy)
400 do iatom = 1, ions%natoms
401 ispecies = ions%atom(iatom)%species%get_index()
402 rr = norm2(x_j - ions%pos(:, iatom))
407 ee =
exp(-this%damping*(rr/(this%sr*r0ab(iatom, jatom)) -
m_one))
411 dffdr0 = -this%damping*rr/( this%sr*r0ab(iatom, jatom)**2)*dee
413 deabdrab = c6ab(iatom,jatom)*(this%damping/(this%sr*r0ab(iatom, jatom))*dee - 6.0_real64*ff/rr)/rr6
415 dffdvra = dffdr0*dr0dvra(iatom)
417 deabdvra = (dffdvra*c6ab(iatom, jatom) + ff*vol_ratio(jatom)*this%c6abfree(ispecies, jspecies))/rr6
419 derivative_coeff(iatom) = derivative_coeff(iatom) + deabdvra
422 deabdrab = c6ab(iatom, jatom)*(this%damping/(this%sr*r0ab(iatom, jatom))*dee - 6.0_real64*ff/rr)/rr6
423 force_vdw(:, iatom) = force_vdw(:, iatom) +
m_half*deabdrab*(ions%pos(:, iatom) - x_j)/rr
428 do iatom = 1, ions%natoms
429 do jatom = 1, ions%natoms
431 force_vdw(:, jatom)= force_vdw(:, jatom) + derivative_coeff(iatom)*dvadrr
437 safe_deallocate_a(vol_ratio)
438 safe_deallocate_a(dvadrr)
439 safe_deallocate_a(dr0dvra)
440 safe_deallocate_a(r0ab)
441 safe_deallocate_a(derivative_coeff)
442 safe_deallocate_a(c6ab)
452 type(
vdw_ts_t) ,
intent(inout) :: this
453 type(
ions_t),
intent(in) :: ions
454 character(len=*),
intent(in) :: dir, fname
457 integer :: iunit, iatom, jatom
463 iunit =
io_open(trim(dir) //
"/" // trim(fname), namespace, action=
'write')
464 write(iunit,
'(a)')
' # Atom1 Atom2 C6_{12}^{eff}'
467 do iatom = 1, ions%natoms
468 do jatom = 1, ions%natoms
469 write(iunit,
'(3x, i5, i5, e15.6)') iatom, jatom, this%c6ab(iatom, jatom)
485 character(len=*),
intent(in) :: atom
486 real(real64),
intent(out) :: c6
487 real(real64),
intent(out) :: alpha
488 real(real64),
intent(out) :: r0
492 select case (trim(atom))
495 alpha = 4.500000_real64
500 alpha = 1.380000_real64
505 alpha = 164.200000_real64
506 c6 = 1387.000000_real64
510 alpha = 38.000000_real64
511 c6 = 214.000000_real64
515 alpha = 21.000000_real64
516 c6 = 99.500000_real64
520 alpha = 12.000000_real64
521 c6 = 46.600000_real64
525 alpha = 7.400000_real64
526 c6 = 24.200000_real64
530 alpha = 5.400000_real64
531 c6 = 15.600000_real64
535 alpha = 3.800000_real64
540 alpha = 2.670000_real64
545 alpha = 162.700000_real64
546 c6 = 1556.000000_real64
550 alpha = 71.000000_real64
551 c6 = 627.000000_real64
555 alpha = 60.000000_real64
556 c6 = 528.000000_real64
560 alpha = 37.000000_real64
561 c6 = 305.000000_real64
565 alpha = 25.000000_real64
566 c6 = 185.000000_real64
570 alpha = 19.600000_real64
571 c6 = 134.000000_real64
575 alpha = 15.000000_real64
576 c6 = 94.600000_real64
580 alpha = 11.100000_real64
581 c6 = 64.300000_real64
585 alpha = 292.900000_real64
586 c6 = 3897.000000_real64
590 alpha = 160.000000_real64
591 c6 = 2221.000000_real64
595 alpha = 120.000000_real64
596 c6 = 1383.000000_real64
600 alpha = 98.000000_real64
601 c6 = 1044.000000_real64
605 alpha = 84.000000_real64
606 c6 = 832.000000_real64
610 alpha = 78.000000_real64
611 c6 = 602.000000_real64
615 alpha = 63.000000_real64
616 c6 = 552.000000_real64
620 alpha = 56.000000_real64
621 c6 = 482.000000_real64
625 alpha = 50.000000_real64
626 c6 = 408.000000_real64
630 alpha = 48.000000_real64
631 c6 = 373.000000_real64
635 alpha = 42.000000_real64
636 c6 = 253.000000_real64
640 alpha = 40.000000_real64
641 c6 = 284.000000_real64
645 alpha = 60.000000_real64
646 c6 = 498.000000_real64
650 alpha = 41.000000_real64
651 c6 = 354.000000_real64
655 alpha = 29.000000_real64
656 c6 = 246.000000_real64
660 alpha = 25.000000_real64
661 c6 = 210.000000_real64
665 alpha = 20.000000_real64
666 c6 = 162.000000_real64
670 alpha = 16.800000_real64
671 c6 = 129.600000_real64
675 alpha = 319.200000_real64
676 c6 = 4691.000000_real64
680 alpha = 199.000000_real64
681 c6 = 3170.000000_real64
690 alpha = 23.680000_real64
691 c6 = 157.500000_real64
695 alpha = 50.600000_real64
696 c6 = 339.000000_real64
710 alpha = 35.000000_real64
711 c6 = 385.000000_real64
715 alpha = 27.300000_real64
716 c6 = 285.900000_real64
756 call messages_write(
'vdw ts: reference free atom parameters not available for species '//trim(atom))
constant times a vector plus a vector
double exp(double __x) __attribute__((__nothrow__
type(debug_t), save, public debug
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_half
real(real64), parameter, public m_one
real(real64), parameter, public m_three
subroutine, public hirshfeld_init(this, mesh, namespace, space, latt, atom, natoms, pos, nspin)
real(real64), parameter, public tol_hirshfeld
subroutine, public hirshfeld_end(this)
subroutine, public hirshfeld_density_derivative(this, iatom, ddensity)
subroutine, public hirshfeld_position_derivative(this, space, iatom, jatom, density, dposition)
subroutine, public hirshfeld_volume_ratio(this, iatom, density, volume_ratio)
subroutine, public dio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
subroutine, public io_close(iunit, grp)
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
This module defines the meshes, which are used in Octopus.
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
logical function mpi_grp_is_root(grp)
type(mpi_grp_t), public mpi_world
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
real(real64) function, public ps_density_volume(ps, namespace)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.
type(unit_system_t), public units_inp
the units systems for reading and writing
type(unit_t), public unit_one
some special units required for particular quantities
subroutine, public vdw_ts_init(this, namespace, ions)
subroutine, public vdw_ts_calculate(this, namespace, space, latt, atom, natoms, pos, mesh, nspin, density, energy, potential, force)
Calculate the potential for the Tatchenko-Scheffler vdW correction as described in Phys....
subroutine, public vdw_ts_write_c6ab(this, ions, dir, fname, namespace)
subroutine get_vdw_param(namespace, atom, c6, alpha, r0)
subroutine, public vdw_ts_force_calculate(this, force_vdw, ions, mesh, nspin, density)
subroutine, public vdw_ts_end(this)
The following class implements a lattice iterator. It allows one to loop over all cells that are with...
Describes mesh distribution to nodes.