28 ewald_environment_type
30 neighbor_kind_pairs_type
32 fist_nonbond_env_type,&
49 #include "./base/base_uses.f90"
55 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'fist_nonbond_force'
56 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
79 SUBROUTINE force_nonbond(fist_nonbond_env, ewald_env, particle_set, cell, &
80 pot_nonbond, f_nonbond, pv_nonbond, fshell_nonbond, fcore_nonbond, &
81 atprop_env, atomic_kind_set, use_virial)
83 TYPE(fist_nonbond_env_type),
POINTER :: fist_nonbond_env
84 TYPE(ewald_environment_type),
POINTER :: ewald_env
85 TYPE(particle_type),
DIMENSION(:),
INTENT(IN) :: particle_set
86 TYPE(cell_type),
POINTER :: cell
87 REAL(kind=
dp),
INTENT(OUT) :: pot_nonbond
88 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: f_nonbond, pv_nonbond
89 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT), &
90 OPTIONAL :: fshell_nonbond, fcore_nonbond
91 TYPE(atprop_type),
POINTER :: atprop_env
92 TYPE(atomic_kind_type),
POINTER :: atomic_kind_set(:)
93 LOGICAL,
INTENT(IN) :: use_virial
95 CHARACTER(LEN=*),
PARAMETER :: routinen =
'force_nonbond'
97 INTEGER :: atom_a, atom_b, ewald_type, handle, i, iend, igrp, ikind, ilist, ipair, istart, &
98 j, kind_a, kind_b, nkind, npairs, shell_a, shell_b, shell_type
99 INTEGER,
DIMENSION(:, :),
POINTER ::
list
100 LOGICAL :: all_terms, do_multipoles, full_nl, &
102 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_shell_kind
103 REAL(kind=
dp) :: alpha, beta, beta_a, beta_b, energy, etot, fac_ei, fac_kind, fac_vdw, &
104 fscalar, mm_radius_a, mm_radius_b, qcore_a, qcore_b, qeff_a, qeff_b, qshell_a, qshell_b, &
105 rab2, rab2_com, rab2_max
106 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: mm_radius, qcore, qeff, qshell
107 REAL(kind=
dp),
DIMENSION(3) :: cell_v, cvi, fatom_a, fatom_b, fcore_a, &
108 fcore_b, fshell_a, fshell_b, rab, &
109 rab_cc, rab_com, rab_cs, rab_sc, rab_ss
110 REAL(kind=
dp),
DIMENSION(3, 3) :: pv, pv_thread
111 REAL(kind=
dp),
DIMENSION(3, 4) :: rab_list
112 REAL(kind=
dp),
DIMENSION(4) :: rab2_list
113 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: ij_kind_full_fac
114 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: ei_interaction_cutoffs
115 TYPE(atomic_kind_type),
POINTER :: atomic_kind
116 TYPE(cp_logger_type),
POINTER :: logger
117 TYPE(fist_neighbor_type),
POINTER :: nonbonded
118 TYPE(neighbor_kind_pairs_type),
POINTER :: neighbor_kind_pair
119 TYPE(pair_potential_pp_type),
POINTER :: potparm, potparm14
120 TYPE(pair_potential_single_type),
POINTER :: pot
121 TYPE(pos_type),
DIMENSION(:),
POINTER :: r_last_update, r_last_update_pbc, &
122 rcore_last_update_pbc, &
123 rshell_last_update_pbc
124 TYPE(shell_kind_type),
POINTER :: shell_kind
125 TYPE(spline_data_p_type),
DIMENSION(:),
POINTER :: spline_data
126 TYPE(spline_factor_type),
POINTER :: spl_f
128 CALL timeset(routinen, handle)
131 NULLIFY (pot, rshell_last_update_pbc, spl_f, ij_kind_full_fac)
133 potparm14=potparm14, potparm=potparm, r_last_update=r_last_update, &
134 r_last_update_pbc=r_last_update_pbc, natom_types=nkind, &
135 rshell_last_update_pbc=rshell_last_update_pbc, &
136 rcore_last_update_pbc=rcore_last_update_pbc, &
137 ij_kind_full_fac=ij_kind_full_fac)
138 CALL ewald_env_get(ewald_env, alpha=alpha, ewald_type=ewald_type, &
139 do_multipoles=do_multipoles, &
140 interaction_cutoffs=ei_interaction_cutoffs)
144 f_nonbond(:, :) = 0.0_dp
147 pv_nonbond(:, :) = 0.0_dp
149 shell_present = .false.
150 IF (
PRESENT(fshell_nonbond))
THEN
151 cpassert(
PRESENT(fcore_nonbond))
152 fshell_nonbond = 0.0_dp
153 fcore_nonbond = 0.0_dp
154 shell_present = .true.
157 ALLOCATE (mm_radius(nkind))
158 ALLOCATE (qeff(nkind))
159 ALLOCATE (qcore(nkind))
160 ALLOCATE (qshell(nkind))
161 ALLOCATE (is_shell_kind(nkind))
163 atomic_kind => atomic_kind_set(ikind)
166 mm_radius=mm_radius(ikind), &
168 is_shell_kind(ikind) =
ASSOCIATED(shell_kind)
169 IF (
ASSOCIATED(shell_kind))
THEN
171 charge_core=qcore(ikind), &
172 charge_shell=qshell(ikind))
174 qcore(ikind) = 0.0_dp
175 qshell(ikind) = 0.0_dp
179 lists:
DO ilist = 1, nonbonded%nlists
180 neighbor_kind_pair => nonbonded%neighbor_kind_pairs(ilist)
181 npairs = neighbor_kind_pair%npairs
182 IF (npairs == 0) cycle
183 list => neighbor_kind_pair%list
184 cvi = neighbor_kind_pair%cell_vector
185 cell_v = matmul(cell%hmat, cvi)
186 kind_group_loop:
DO igrp = 1, neighbor_kind_pair%ngrp_kind
187 istart = neighbor_kind_pair%grp_kind_start(igrp)
188 iend = neighbor_kind_pair%grp_kind_end(igrp)
208 IF (use_virial) pv_thread(:, :) = 0.0_dp
210 pairs:
DO ipair = istart, iend
211 atom_a =
list(1, ipair)
212 atom_b =
list(2, ipair)
215 kind_a = particle_set(atom_a)%atomic_kind%kind_number
216 kind_b = particle_set(atom_b)%atomic_kind%kind_number
218 fac_kind = ij_kind_full_fac(kind_a, kind_b)
220 pot => potparm%pot(kind_a, kind_b)%pot
221 IF (ipair <= neighbor_kind_pair%nscale)
THEN
222 IF (neighbor_kind_pair%is_onfo(ipair))
THEN
223 pot => potparm14%pot(kind_a, kind_b)%pot
234 IF ((.NOT. full_nl) .AND. (atom_a == atom_b))
THEN
235 fac_ei = 0.5_dp*fac_ei
236 fac_vdw = 0.5_dp*fac_vdw
239 IF (do_multipoles .OR. (.NOT. fist_nonbond_env%do_electrostatics))
THEN
242 IF (ipair <= neighbor_kind_pair%nscale)
THEN
243 fac_ei = fac_ei*neighbor_kind_pair%ei_scale(ipair)
244 fac_vdw = fac_vdw*neighbor_kind_pair%vdw_scale(ipair)
247 IF (fac_ei > 0.0_dp)
THEN
249 mm_radius_a = mm_radius(kind_a)
250 mm_radius_b = mm_radius(kind_b)
251 IF (
ASSOCIATED(fist_nonbond_env%charges))
THEN
252 qeff_a = fist_nonbond_env%charges(atom_a)
253 qeff_b = fist_nonbond_env%charges(atom_b)
255 qeff_a = qeff(kind_a)
256 qeff_b = qeff(kind_b)
258 IF (is_shell_kind(kind_a))
THEN
259 qcore_a = qcore(kind_a)
260 qshell_a = qshell(kind_a)
261 IF ((qcore_a == 0.0_dp) .AND. (qshell_a == 0.0_dp)) fac_ei = 0.0_dp
264 qshell_a = huge(0.0_dp)
265 IF (qeff_a == 0.0_dp) fac_ei = 0.0_dp
267 IF (is_shell_kind(kind_b))
THEN
268 qcore_b = qcore(kind_b)
269 qshell_b = qshell(kind_b)
270 IF ((qcore_b == 0.0_dp) .AND. (qshell_b == 0.0_dp)) fac_ei = 0.0_dp
273 qshell_b = huge(0.0_dp)
274 IF (qeff_b == 0.0_dp) fac_ei = 0.0_dp
280 IF (mm_radius_a > 0)
THEN
283 IF (mm_radius_b > 0)
THEN
286 IF ((mm_radius_a > 0) .OR. (mm_radius_b > 0))
THEN
287 beta =
sqrthalf/sqrt(mm_radius_a*mm_radius_a + mm_radius_b*mm_radius_b)
293 IF (pot%no_pp .AND. (fac_ei == 0.0)) cycle
297 spline_data => pot%pair_spline_data
298 shell_type = pot%shell_type
300 cpassert(.NOT. do_multipoles)
301 cpassert(shell_present)
303 rab2_max = pot%rcutsq
309 IF (shell_type ==
sh_sh)
THEN
310 shell_a = particle_set(atom_a)%shell_index
311 shell_b = particle_set(atom_b)%shell_index
312 rab_cc = rcore_last_update_pbc(shell_b)%r - rcore_last_update_pbc(shell_a)%r
313 rab_cs = rshell_last_update_pbc(shell_b)%r - rcore_last_update_pbc(shell_a)%r
314 rab_sc = rcore_last_update_pbc(shell_b)%r - rshell_last_update_pbc(shell_a)%r
315 rab_ss = rshell_last_update_pbc(shell_b)%r - rshell_last_update_pbc(shell_a)%r
316 rab_list(1:3, 1) = rab_cc(1:3) + cell_v(1:3)
317 rab_list(1:3, 2) = rab_cs(1:3) + cell_v(1:3)
318 rab_list(1:3, 3) = rab_sc(1:3) + cell_v(1:3)
319 rab_list(1:3, 4) = rab_ss(1:3) + cell_v(1:3)
320 ELSE IF ((shell_type ==
nosh_sh) .AND. (particle_set(atom_a)%shell_index /= 0))
THEN
321 shell_a = particle_set(atom_a)%shell_index
323 rab_cc = r_last_update_pbc(atom_b)%r - rcore_last_update_pbc(shell_a)%r
326 rab_ss = r_last_update_pbc(atom_b)%r - rshell_last_update_pbc(shell_a)%r
327 rab_list(1:3, 1) = rab_cc(1:3) + cell_v(1:3)
328 rab_list(1:3, 2) = 0.0_dp
329 rab_list(1:3, 3) = 0.0_dp
330 rab_list(1:3, 4) = rab_ss(1:3) + cell_v(1:3)
331 ELSE IF ((shell_type ==
nosh_sh) .AND. (particle_set(atom_b)%shell_index /= 0))
THEN
332 shell_b = particle_set(atom_b)%shell_index
334 rab_cc = rcore_last_update_pbc(shell_b)%r - r_last_update_pbc(atom_a)%r
337 rab_ss = rshell_last_update_pbc(shell_b)%r - r_last_update_pbc(atom_a)%r
338 rab_list(1:3, 1) = rab_cc(1:3) + cell_v(1:3)
339 rab_list(1:3, 2) = 0.0_dp
340 rab_list(1:3, 3) = 0.0_dp
341 rab_list(1:3, 4) = rab_ss(1:3) + cell_v(1:3)
343 rab_list(:, :) = 0.0_dp
346 check_terms:
DO i = 1, 4
347 rab2_list(i) = rab_list(1, i)**2 + rab_list(2, i)**2 + rab_list(3, i)**2
348 IF (rab2_list(i) >= rab2_max)
THEN
353 rab_com = r_last_update_pbc(atom_b)%r - r_last_update_pbc(atom_a)%r
356 rab_cc = r_last_update_pbc(atom_b)%r - r_last_update_pbc(atom_a)%r
360 rab_list(:, :) = 0.0_dp
362 rab_com = rab_com + cell_v
363 rab2_com = rab_com(1)**2 + rab_com(2)**2 + rab_com(3)**2
373 IF (use_virial) pv(:, :) = 0.0_dp
376 IF ((rab2_com <= rab2_max) .AND. all_terms)
THEN
382 IF (shell_a == 0)
THEN
385 ewald_type, alpha, beta_a, &
386 ei_interaction_cutoffs(2, kind_a, kind_b))
387 CALL add_force_nonbond(fatom_a, fcore_b, pv, fscalar, rab, use_virial)
388 ELSE IF (shell_b == 0)
THEN
391 ewald_type, alpha, beta_b, &
392 ei_interaction_cutoffs(2, kind_b, kind_a))
393 CALL add_force_nonbond(fcore_a, fatom_b, pv, fscalar, rab, use_virial)
397 ewald_type, alpha, 0.0_dp, &
398 ei_interaction_cutoffs(1, kind_a, kind_b))
399 CALL add_force_nonbond(fcore_a, fcore_b, pv, fscalar, rab, use_virial)
404 IF (shell_type ==
sh_sh)
THEN
409 IF (fac_vdw > 0)
THEN
410 energy =
potential_s(spline_data, rab2, fscalar, spl_f, logger)
411 etot = etot + energy*fac_vdw
412 fscalar = fscalar*fac_vdw
417 ewald_type, alpha, beta, &
418 ei_interaction_cutoffs(3, kind_a, kind_b))
421 CALL add_force_nonbond(fshell_a, fshell_b, pv, fscalar, rab, use_virial)
430 ewald_type, alpha, beta_b, &
431 ei_interaction_cutoffs(2, kind_b, kind_a))
433 CALL add_force_nonbond(fcore_a, fshell_b, pv, fscalar, rab, use_virial)
440 ewald_type, alpha, beta_a, &
441 ei_interaction_cutoffs(2, kind_a, kind_b))
443 CALL add_force_nonbond(fshell_a, fcore_b, pv, fscalar, rab, use_virial)
445 ELSE IF ((shell_type ==
nosh_sh) .AND. (shell_a == 0))
THEN
450 IF (fac_vdw > 0)
THEN
451 energy =
potential_s(spline_data, rab2, fscalar, spl_f, logger)
452 etot = etot + energy*fac_vdw
453 fscalar = fscalar*fac_vdw
458 ewald_type, alpha, beta, &
459 ei_interaction_cutoffs(3, kind_a, kind_b))
462 CALL add_force_nonbond(fatom_a, fshell_b, pv, fscalar, rab, use_virial)
463 ELSE IF ((shell_type ==
nosh_sh) .AND. (shell_b == 0))
THEN
468 IF (fac_vdw > 0)
THEN
469 energy =
potential_s(spline_data, rab2, fscalar, spl_f, logger)
470 etot = etot + energy*fac_vdw
471 fscalar = fscalar*fac_vdw
476 ewald_type, alpha, beta, &
477 ei_interaction_cutoffs(3, kind_a, kind_b))
480 CALL add_force_nonbond(fshell_a, fatom_b, pv, fscalar, rab, use_virial)
484 IF (rab2_com <= rab2_max)
THEN
490 IF (fac_vdw > 0)
THEN
491 energy =
potential_s(spline_data, rab2, fscalar, spl_f, logger)
492 etot = etot + energy*fac_vdw
493 fscalar = fscalar*fac_vdw
498 ewald_type, alpha, beta, &
499 ei_interaction_cutoffs(3, kind_a, kind_b))
502 CALL add_force_nonbond(fatom_a, fatom_b, pv, fscalar, rab, use_virial)
507 pot_nonbond = pot_nonbond + etot
508 IF (atprop_env%energy)
THEN
511 atprop_env%atener(atom_a) = atprop_env%atener(atom_a) + 0.5_dp*etot
513 atprop_env%atener(atom_b) = atprop_env%atener(atom_b) + 0.5_dp*etot
518 f_nonbond(i, atom_a) = f_nonbond(i, atom_a) + fatom_a(i)
520 f_nonbond(i, atom_b) = f_nonbond(i, atom_b) + fatom_b(i)
522 IF (shell_a > 0)
THEN
525 fcore_nonbond(i, shell_a) = fcore_nonbond(i, shell_a) + fcore_a(i)
527 fshell_nonbond(i, shell_a) = fshell_nonbond(i, shell_a) + fshell_a(i)
530 IF (shell_b > 0)
THEN
533 fcore_nonbond(i, shell_b) = fcore_nonbond(i, shell_b) + fcore_b(i)
535 fshell_nonbond(i, shell_b) = fshell_nonbond(i, shell_b) + fshell_b(i)
542 pv_thread(j, i) = pv_thread(j, i) + pv(j, i)
544 IF (atprop_env%stress)
THEN
546 atprop_env%atstress(j, i, atom_a) = atprop_env%atstress(j, i, atom_a) + &
549 atprop_env%atstress(j, i, atom_b) = atprop_env%atstress(j, i, atom_b) + &
561 pv_nonbond(j, i) = pv_nonbond(j, i) + pv_thread(j, i)
566 END DO kind_group_loop
572 DEALLOCATE (mm_radius)
576 DEALLOCATE (is_shell_kind)
578 CALL timestop(handle)
595 SUBROUTINE add_force_nonbond(f_nonbond_a, f_nonbond_b, pv, fscalar, rab, use_virial)
597 REAL(kind=
dp),
DIMENSION(3),
INTENT(INOUT) :: f_nonbond_a, f_nonbond_b
598 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT) :: pv
599 REAL(kind=
dp),
INTENT(IN) :: fscalar
600 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: rab
601 LOGICAL,
INTENT(IN) :: use_virial
603 REAL(kind=
dp),
DIMENSION(3) :: fr
605 fr(1) = fscalar*rab(1)
606 fr(2) = fscalar*rab(2)
607 fr(3) = fscalar*rab(3)
608 f_nonbond_a(1) = f_nonbond_a(1) - fr(1)
609 f_nonbond_a(2) = f_nonbond_a(2) - fr(2)
610 f_nonbond_a(3) = f_nonbond_a(3) - fr(3)
611 f_nonbond_b(1) = f_nonbond_b(1) + fr(1)
612 f_nonbond_b(2) = f_nonbond_b(2) + fr(2)
613 f_nonbond_b(3) = f_nonbond_b(3) + fr(3)
615 pv(1, 1) = pv(1, 1) + rab(1)*fr(1)
616 pv(1, 2) = pv(1, 2) + rab(1)*fr(2)
617 pv(1, 3) = pv(1, 3) + rab(1)*fr(3)
618 pv(2, 1) = pv(2, 1) + rab(2)*fr(1)
619 pv(2, 2) = pv(2, 2) + rab(2)*fr(2)
620 pv(2, 3) = pv(2, 3) + rab(2)*fr(3)
621 pv(3, 1) = pv(3, 1) + rab(3)*fr(1)
622 pv(3, 2) = pv(3, 2) + rab(3)*fr(2)
623 pv(3, 3) = pv(3, 3) + rab(3)*fr(3)
647 local_particles, particle_set, ewald_env, v_bonded_corr, pv_bc, &
648 shell_particle_set, core_particle_set, atprop_env, cell, use_virial)
650 TYPE(fist_nonbond_env_type),
POINTER :: fist_nonbond_env
651 TYPE(atomic_kind_type),
POINTER :: atomic_kind_set(:)
652 TYPE(distribution_1d_type),
POINTER :: local_particles
653 TYPE(particle_type),
POINTER :: particle_set(:)
654 TYPE(ewald_environment_type),
POINTER :: ewald_env
655 REAL(kind=
dp),
INTENT(OUT) :: v_bonded_corr
656 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(OUT) :: pv_bc
657 TYPE(particle_type),
OPTIONAL,
POINTER :: shell_particle_set(:), &
659 TYPE(atprop_type),
POINTER :: atprop_env
660 TYPE(cell_type),
POINTER :: cell
661 LOGICAL,
INTENT(IN) :: use_virial
663 CHARACTER(LEN=*),
PARAMETER :: routinen =
'bonded_correct_gaussian'
665 INTEGER :: atom_a, atom_b, handle, iatom, iend, igrp, ilist, ipair, istart, kind_a, kind_b, &
666 natoms_per_kind, nkind, npairs, shell_a, shell_b
667 INTEGER,
DIMENSION(:, :),
POINTER ::
list
668 LOGICAL :: a_is_shell, b_is_shell, do_multipoles, &
669 full_nl, shell_adiabatic
670 REAL(kind=
dp) :: alpha, const, fac_cor, fac_ei, qcore_a, &
671 qcore_b, qeff_a, qeff_b, qshell_a, &
673 REAL(kind=
dp),
DIMENSION(3) :: rca, rcb, rsa, rsb
674 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: ij_kind_full_fac
675 TYPE(atomic_kind_type),
POINTER :: atomic_kind
676 TYPE(fist_neighbor_type),
POINTER :: nonbonded
677 TYPE(mp_comm_type) :: group
678 TYPE(neighbor_kind_pairs_type),
POINTER :: neighbor_kind_pair
679 TYPE(pair_potential_pp_type),
POINTER :: potparm, potparm14
680 TYPE(pair_potential_single_type),
POINTER :: pot
681 TYPE(shell_kind_type),
POINTER :: shell_kind
683 CALL timeset(routinen, handle)
686 IF (use_virial) pv_bc = 0.0_dp
687 v_bonded_corr = 0.0_dp
690 potparm14=potparm14, potparm=potparm, &
691 ij_kind_full_fac=ij_kind_full_fac)
692 CALL ewald_env_get(ewald_env, alpha=alpha, do_multipoles=do_multipoles, &
698 shell_adiabatic=shell_adiabatic)
700 lists:
DO ilist = 1, nonbonded%nlists
701 neighbor_kind_pair => nonbonded%neighbor_kind_pairs(ilist)
702 npairs = neighbor_kind_pair%nscale
703 IF (npairs == 0) cycle
704 list => neighbor_kind_pair%list
705 kind_group_loop:
DO igrp = 1, neighbor_kind_pair%ngrp_kind
706 istart = neighbor_kind_pair%grp_kind_start(igrp)
707 IF (istart > npairs)
THEN
710 iend = min(npairs, neighbor_kind_pair%grp_kind_end(igrp))
712 pairs:
DO ipair = istart, iend
713 atom_a =
list(1, ipair)
714 atom_b =
list(2, ipair)
717 kind_a = particle_set(atom_a)%atomic_kind%kind_number
718 kind_b = particle_set(atom_b)%atomic_kind%kind_number
721 pot => potparm%pot(kind_a, kind_b)%pot
722 IF (ipair <= neighbor_kind_pair%nscale)
THEN
723 IF (neighbor_kind_pair%is_onfo(ipair))
THEN
724 pot => potparm14%pot(kind_a, kind_b)%pot
729 fac_ei = ij_kind_full_fac(kind_a, kind_b)
734 IF ((.NOT. full_nl) .AND. (atom_a == atom_b))
THEN
735 fac_ei = fac_ei*0.5_dp
737 IF (ipair <= neighbor_kind_pair%nscale)
THEN
738 fac_ei = fac_ei*neighbor_kind_pair%ei_scale(ipair)
742 fac_cor = 1.0_dp - fac_ei
743 IF (fac_cor <= 0.0_dp) cycle
746 atomic_kind => atomic_kind_set(kind_a)
748 IF (
ASSOCIATED(fist_nonbond_env%charges)) qeff_a = fist_nonbond_env%charges(atom_a)
749 a_is_shell =
ASSOCIATED(shell_kind)
751 CALL get_shell(shell=shell_kind, charge_core=qcore_a, &
752 charge_shell=qshell_a)
753 shell_a = particle_set(atom_a)%shell_index
754 rca = core_particle_set(shell_a)%r
755 rsa = shell_particle_set(shell_a)%r
758 qshell_a = huge(0.0_dp)
760 rca = particle_set(atom_a)%r
765 atomic_kind => atomic_kind_set(kind_b)
767 IF (
ASSOCIATED(fist_nonbond_env%charges)) qeff_b = fist_nonbond_env%charges(atom_b)
768 b_is_shell =
ASSOCIATED(shell_kind)
770 CALL get_shell(shell=shell_kind, charge_core=qcore_b, &
771 charge_shell=qshell_b)
772 shell_b = particle_set(atom_b)%shell_index
773 rcb = core_particle_set(shell_b)%r
774 rsb = shell_particle_set(shell_b)%r
777 qshell_b = huge(0.0_dp)
779 rcb = particle_set(atom_b)%r
784 IF (a_is_shell .AND. b_is_shell)
THEN
786 CALL bonded_correct_gaussian_low(rca, rcb, cell, &
787 v_bonded_corr, core_particle_set, core_particle_set, &
788 shell_a, shell_b, .true., alpha, qcore_a, qcore_b, &
789 const, fac_cor, pv_bc, atprop_env, use_virial)
790 ELSE IF (a_is_shell)
THEN
792 CALL bonded_correct_gaussian_low(rca, rcb, cell, &
793 v_bonded_corr, core_particle_set, particle_set, &
794 shell_a, atom_b, .true., alpha, qcore_a, qcore_b, &
795 const, fac_cor, pv_bc, atprop_env, use_virial)
796 ELSE IF (b_is_shell)
THEN
798 CALL bonded_correct_gaussian_low(rca, rcb, cell, &
799 v_bonded_corr, particle_set, core_particle_set, &
800 atom_a, shell_b, .true., alpha, qcore_a, qcore_b, &
801 const, fac_cor, pv_bc, atprop_env, use_virial)
804 CALL bonded_correct_gaussian_low(rca, rcb, cell, &
805 v_bonded_corr, particle_set, particle_set, &
806 atom_a, atom_b, .true., alpha, qcore_a, qcore_b, &
807 const, fac_cor, pv_bc, atprop_env, use_virial)
812 IF (a_is_shell .AND. b_is_shell)
THEN
814 CALL bonded_correct_gaussian_low(rsa, rsa, cell, &
815 v_bonded_corr, shell_particle_set, shell_particle_set, &
816 shell_a, shell_b, shell_adiabatic, alpha, qshell_a, &
817 qshell_b, const, fac_cor, pv_bc, atprop_env, use_virial)
822 CALL bonded_correct_gaussian_low(rsa, rcb, cell, &
823 v_bonded_corr, shell_particle_set, core_particle_set, &
824 shell_a, shell_b, shell_adiabatic, alpha, qshell_a, qcore_b, &
825 const, fac_cor, pv_bc, atprop_env, use_virial)
828 CALL bonded_correct_gaussian_low(rsa, rcb, cell, &
829 v_bonded_corr, shell_particle_set, particle_set, &
830 shell_a, atom_b, shell_adiabatic, alpha, qshell_a, qcore_b, &
831 const, fac_cor, pv_bc, atprop_env, use_virial)
837 CALL bonded_correct_gaussian_low(rca, rsb, cell, &
838 v_bonded_corr, core_particle_set, shell_particle_set, &
839 shell_a, shell_b, shell_adiabatic, alpha, qcore_a, qshell_b, &
840 const, fac_cor, pv_bc, atprop_env, use_virial)
843 CALL bonded_correct_gaussian_low(rca, rsb, cell, &
844 v_bonded_corr, particle_set, shell_particle_set, &
845 atom_a, shell_b, shell_adiabatic, alpha, qcore_a, qshell_b, &
846 const, fac_cor, pv_bc, atprop_env, use_virial)
850 END DO kind_group_loop
854 nkind =
SIZE(atomic_kind_set)
857 atomic_kind => atomic_kind_set(kind_a)
859 IF (
ASSOCIATED(shell_kind))
THEN
860 CALL get_shell(shell=shell_kind, charge_core=qcore_a, &
861 charge_shell=qshell_a)
863 natoms_per_kind = local_particles%n_el(kind_a)
864 DO iatom = 1, natoms_per_kind
867 atom_a = local_particles%list(kind_a)%array(iatom)
868 shell_a = particle_set(atom_a)%shell_index
869 rca = core_particle_set(shell_a)%r
870 rsa = shell_particle_set(shell_a)%r
872 CALL bonded_correct_gaussian_low_sh(rca, rsa, cell, &
873 v_bonded_corr, core_particle_set, shell_particle_set, &
874 shell_a, shell_adiabatic, alpha, qcore_a, qshell_a, &
875 const, pv_bc, atprop_env, use_virial)
881 CALL group%sum(v_bonded_corr)
883 CALL timestop(handle)
911 SUBROUTINE bonded_correct_gaussian_low(r1, r2, cell, v_bonded_corr, &
912 particle_set1, particle_set2, i, j, shell_adiabatic, alpha, q1, q2, &
913 const, fac_cor, pv_bc, atprop_env, use_virial)
914 REAL(kind=
dp),
DIMENSION(3) :: r1, r2
915 TYPE(cell_type),
POINTER :: cell
916 REAL(kind=
dp),
INTENT(INOUT) :: v_bonded_corr
917 TYPE(particle_type),
POINTER :: particle_set1(:), particle_set2(:)
918 INTEGER,
INTENT(IN) :: i, j
919 LOGICAL,
INTENT(IN) :: shell_adiabatic
920 REAL(kind=
dp),
INTENT(IN) :: alpha, q1, q2, const, fac_cor
921 REAL(kind=
dp),
INTENT(INOUT) :: pv_bc(3, 3)
922 TYPE(atprop_type),
POINTER :: atprop_env
923 LOGICAL,
INTENT(IN) :: use_virial
925 REAL(kind=
dp),
PARAMETER :: ac1 = 0.254829592_dp, ac2 = -0.284496736_dp, &
926 ac3 = 1.421413741_dp, ac4 = -1.453152027_dp, ac5 = 1.061405429_dp, pc = 0.3275911_dp
928 INTEGER :: iatom, jatom
929 REAL(kind=
dp) :: arg, dij, e_arg_arg, errf, fscalar, &
931 REAL(kind=
dp),
DIMENSION(3) :: fij_com, rij
932 REAL(kind=
dp),
DIMENSION(3, 3) :: fbc
936 rijsq = rij(1)*rij(1) + rij(2)*rij(2) + rij(3)*rij(3)
937 idij = 1.0_dp/sqrt(rijsq)
940 e_arg_arg = exp(-arg**2)
941 tc = 1.0_dp/(1.0_dp + pc*arg)
944 errf = 1.0_dp - ((((ac5*tc + ac4)*tc + ac3)*tc + ac2)*tc + ac1)*tc*e_arg_arg
947 vbc = -q1*q2*idij*errf*fac_cor
948 v_bonded_corr = v_bonded_corr + vbc
949 IF (atprop_env%energy)
THEN
950 iatom = particle_set1(i)%atom_index
951 atprop_env%atener(iatom) = atprop_env%atener(iatom) + 0.5_dp*vbc
952 jatom = particle_set2(j)%atom_index
953 atprop_env%atener(jatom) = atprop_env%atener(jatom) + 0.5_dp*vbc
957 fscalar = q1*q2*idij**2*(idij*errf - const*e_arg_arg)*fac_cor
959 particle_set1(i)%f(1) = particle_set1(i)%f(1) - fscalar*rij(1)
960 particle_set1(i)%f(2) = particle_set1(i)%f(2) - fscalar*rij(2)
961 particle_set1(i)%f(3) = particle_set1(i)%f(3) - fscalar*rij(3)
963 particle_set2(j)%f(1) = particle_set2(j)%f(1) + fscalar*rij(1)
964 particle_set2(j)%f(2) = particle_set2(j)%f(2) + fscalar*rij(2)
965 particle_set2(j)%f(3) = particle_set2(j)%f(3) + fscalar*rij(3)
967 IF (use_virial .AND. shell_adiabatic)
THEN
968 fij_com = fscalar*rij
969 fbc(1, 1) = -fij_com(1)*rij(1)
970 fbc(1, 2) = -fij_com(1)*rij(2)
971 fbc(1, 3) = -fij_com(1)*rij(3)
972 fbc(2, 1) = -fij_com(2)*rij(1)
973 fbc(2, 2) = -fij_com(2)*rij(2)
974 fbc(2, 3) = -fij_com(2)*rij(3)
975 fbc(3, 1) = -fij_com(3)*rij(1)
976 fbc(3, 2) = -fij_com(3)*rij(2)
977 fbc(3, 3) = -fij_com(3)*rij(3)
978 pv_bc(:, :) = pv_bc(:, :) + fbc(:, :)
979 IF (atprop_env%stress)
THEN
981 iatom = particle_set1(i)%atom_index
982 atprop_env%atstress(:, :, iatom) = atprop_env%atstress(:, :, iatom) + 0.5_dp*fbc(:, :)
983 jatom = particle_set2(j)%atom_index
984 atprop_env%atstress(:, :, jatom) = atprop_env%atstress(:, :, jatom) + 0.5_dp*fbc(:, :)
988 END SUBROUTINE bonded_correct_gaussian_low
1013 SUBROUTINE bonded_correct_gaussian_low_sh(r1, r2, cell, v_bonded_corr, &
1014 core_particle_set, shell_particle_set, i, shell_adiabatic, alpha, q1, q2, &
1015 const, pv_bc, atprop_env, use_virial)
1016 REAL(kind=
dp),
DIMENSION(3) :: r1, r2
1017 TYPE(cell_type),
POINTER :: cell
1018 REAL(kind=
dp),
INTENT(INOUT) :: v_bonded_corr
1019 TYPE(particle_type),
POINTER :: core_particle_set(:), &
1020 shell_particle_set(:)
1021 INTEGER,
INTENT(IN) :: i
1022 LOGICAL,
INTENT(IN) :: shell_adiabatic
1023 REAL(kind=
dp),
INTENT(IN) :: alpha, q1, q2, const
1024 REAL(kind=
dp),
INTENT(INOUT) :: pv_bc(3, 3)
1025 TYPE(atprop_type),
POINTER :: atprop_env
1026 LOGICAL,
INTENT(IN) :: use_virial
1028 REAL(kind=
dp),
PARAMETER :: ac1 = 0.254829592_dp, ac2 = -0.284496736_dp, &
1029 ac3 = 1.421413741_dp, ac4 = -1.453152027_dp, ac5 = 1.061405429_dp, pc = 0.3275911_dp
1032 REAL(kind=
dp) :: arg, dij, e_arg_arg, efac, errf, ffac, &
1033 fscalar, idij, rijsq, tc, tc2, tc4, vbc
1034 REAL(kind=
dp),
DIMENSION(3) :: fr, rij
1035 REAL(kind=
dp),
DIMENSION(3, 3) :: fbc
1038 rij =
pbc(rij, cell)
1039 rijsq = rij(1)*rij(1) + rij(2)*rij(2) + rij(3)*rij(3)
1045 IF (arg > 0.355_dp)
THEN
1047 e_arg_arg = exp(-arg*arg)
1048 tc = 1.0_dp/(1.0_dp + pc*arg)
1050 errf = 1.0_dp - ((((ac5*tc + ac4)*tc + ac3)*tc + ac2)*tc + ac1)*tc*e_arg_arg
1052 ffac = idij**2*(efac - const*e_arg_arg)
1057 efac = const*(1.0_dp - tc/3.0_dp + tc2/10.0_dp - tc*tc2/42.0_dp + tc4/216.0_dp - &
1058 tc*tc4/1320.0_dp + tc2*tc4/9360.0_dp)
1059 ffac = const*alpha**2*(2.0_dp/3.0_dp - 2.0_dp*tc/5.0_dp + tc2/7.0_dp - tc*tc2/27.0_dp + &
1060 tc4/132.0_dp - tc*tc4/780.0_dp)
1065 v_bonded_corr = v_bonded_corr + vbc
1066 IF (atprop_env%energy)
THEN
1067 iatom = shell_particle_set(i)%atom_index
1068 atprop_env%atener(iatom) = atprop_env%atener(iatom) + vbc
1072 fscalar = q1*q2*ffac
1073 fr(:) = fscalar*rij(:)
1075 core_particle_set(i)%f(1) = core_particle_set(i)%f(1) - fr(1)
1076 core_particle_set(i)%f(2) = core_particle_set(i)%f(2) - fr(2)
1077 core_particle_set(i)%f(3) = core_particle_set(i)%f(3) - fr(3)
1079 shell_particle_set(i)%f(1) = shell_particle_set(i)%f(1) + fr(1)
1080 shell_particle_set(i)%f(2) = shell_particle_set(i)%f(2) + fr(2)
1081 shell_particle_set(i)%f(3) = shell_particle_set(i)%f(3) + fr(3)
1083 IF (use_virial .AND. shell_adiabatic)
THEN
1084 fbc(1, 1) = -fr(1)*rij(1)
1085 fbc(1, 2) = -fr(1)*rij(2)
1086 fbc(1, 3) = -fr(1)*rij(3)
1087 fbc(2, 1) = -fr(2)*rij(1)
1088 fbc(2, 2) = -fr(2)*rij(2)
1089 fbc(2, 3) = -fr(2)*rij(3)
1090 fbc(3, 1) = -fr(3)*rij(1)
1091 fbc(3, 2) = -fr(3)*rij(2)
1092 fbc(3, 3) = -fr(3)*rij(3)
1093 pv_bc(:, :) = pv_bc(:, :) + fbc(:, :)
1094 IF (atprop_env%stress)
THEN
1096 iatom = shell_particle_set(i)%atom_index
1097 atprop_env%atstress(:, :, iatom) = atprop_env%atstress(:, :, iatom) + fbc(:, :)
1101 END SUBROUTINE bonded_correct_gaussian_low_sh
subroutine pbc(r, r_pbc, s, s_pbc, a, b, c, alpha, beta, gamma, debug, info, pbc0, h, hinv)
...
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Holds information on atomic properties.
Handles all functions related to the CELL.
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
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public ewald_env_get(ewald_env, ewald_type, alpha, eps_pol, epsilon, gmax, ns_max, o_spline, group, para_env, poisson_section, precs, rcut, do_multipoles, max_multipole, do_ipol, max_ipol_iter, interaction_cutoffs, cell_hmat)
Purpose: Get the EWALD environment.
Define the neighbor list data types and the corresponding functionality.
subroutine, public fist_nonbond_env_get(fist_nonbond_env, potparm14, potparm, nonbonded, rlist_cut, rlist_lowsq, aup, lup, ei_scale14, vdw_scale14, shift_cutoff, do_electrostatics, r_last_update, r_last_update_pbc, rshell_last_update_pbc, rcore_last_update_pbc, cell_last_update, num_update, last_update, counter, natom_types, long_range_correction, ij_kind_full_fac, eam_data, quip_data, nequip_data, allegro_data, deepmd_data, charges)
sets a fist_nonbond_env
subroutine, public force_nonbond(fist_nonbond_env, ewald_env, particle_set, cell, pot_nonbond, f_nonbond, pv_nonbond, fshell_nonbond, fcore_nonbond, atprop_env, atomic_kind_set, use_virial)
Calculates the force and the potential of the minimum image, and the pressure tensor.
subroutine, public bonded_correct_gaussian(fist_nonbond_env, atomic_kind_set, local_particles, particle_set, ewald_env, v_bonded_corr, pv_bc, shell_particle_set, core_particle_set, atprop_env, cell, use_virial)
corrects electrostatics for bonded terms
Defines the basic variable types.
integer, parameter, public dp
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_memory(mem)
Returns the total amount of memory [bytes] in use, if known, zero otherwise.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public oorootpi
real(kind=dp), parameter, public sqrthalf
Interface to the message passing library MPI.
real(kind=dp) function, public potential_coulomb(r2, fscalar, qfac, ewald_type, alpha, beta, interaction_cutoff)
Evaluates the electrostatic energy and force.
integer, parameter, public sh_sh
integer, parameter, public nosh_nosh
integer, parameter, public allegro_type
integer, parameter, public gal_type
integer, parameter, public nequip_type
integer, parameter, public deepmd_type
integer, parameter, public siepmann_type
integer, parameter, public nosh_sh
integer, parameter, public gal21_type
integer, parameter, public tersoff_type
Define the data structure for the particle information.
elemental subroutine, public get_shell(shell, charge, charge_core, charge_shell, mass_core, mass_shell, k2_spring, k4_spring, max_dist, shell_cutoff)
...
routines for handling splines
real(kind=dp) function, public potential_s(spl_p, xxi, y1, spl_f, logger)
calculates the potential interpolated with splines value at a given point and the first derivative....
routines for handling splines_types