31#include "./base/base_uses.f90"
40 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'constraint_vsite'
55 INTEGER :: i, ikind, imol, nconstraint, nkind, &
56 nmol_per_kind, nvsitecon
57 LOGICAL :: do_ext_constraint
70 NULLIFY (gci, subsys, local_molecules, local_particles, &
75 CALL cp_subsys_get(subsys=subsys, local_particles=local_particles, &
76 particles=particles, local_molecules=local_molecules, &
77 molecule_kinds=molecule_kinds, gci=gci, molecules=molecules)
79 molecule_kind_set => molecule_kinds%els
80 molecule_set => molecules%els
81 particle_set => particles%els
82 nkind =
SIZE(molecule_kind_set)
84 do_ext_constraint = .false.
85 IF (
ASSOCIATED(gci))
THEN
86 do_ext_constraint = (gci%ntot /= 0)
89 mol:
DO ikind = 1, nkind
90 nmol_per_kind = local_molecules%n_el(ikind)
91 DO imol = 1, nmol_per_kind
92 i = local_molecules%list(ikind)%array(imol)
93 molecule => molecule_set(i)
94 molecule_kind => molecule%molecule_kind
96 IF (nconstraint == 0) cycle
98 CALL force_vsite_int(molecule, particle_set)
102 IF (do_ext_constraint)
THEN
103 IF (gci%nvsite /= 0) &
104 CALL force_vsite_ext(gci, particle_set)
118 REAL(kind=
dp),
INTENT(INOUT) :: pos(:, :)
120 INTEGER :: first_atom, nvsite
124 molecule_kind => molecule%molecule_kind
128 CALL shake_vsite_low(vsite_list, nvsite, first_atom, pos)
142 REAL(kind=
dp),
INTENT(INOUT) :: pos(:, :)
144 INTEGER :: first_atom, nvsite
149 vsite_list => gci%vsite_list
151 CALL shake_vsite_low(vsite_list, nvsite, first_atom, pos)
164 SUBROUTINE shake_vsite_low(vsite_list, nvsite, first_atom, pos)
166 INTEGER,
INTENT(IN) :: nvsite, first_atom
167 REAL(kind=
dp),
INTENT(INOUT) :: pos(:, :)
169 INTEGER :: iconst, index_a, index_b, index_c, &
171 REAL(kind=
dp),
DIMENSION(3) :: r1, r2
173 DO iconst = 1, nvsite
174 IF (vsite_list(iconst)%restraint%active) cycle
175 index_a = vsite_list(iconst)%a + first_atom - 1
176 index_b = vsite_list(iconst)%b + first_atom - 1
177 index_c = vsite_list(iconst)%c + first_atom - 1
178 index_d = vsite_list(iconst)%d + first_atom - 1
180 r1(:) = pos(:, index_b) - pos(:, index_c)
181 r2(:) = pos(:, index_d) - pos(:, index_c)
182 pos(:, index_a) = pos(:, index_c) + vsite_list(iconst)%wbc*r1(:) + &
183 vsite_list(iconst)%wdc*r2(:)
185 END SUBROUTINE shake_vsite_low
194 SUBROUTINE force_vsite_int(molecule, particle_set)
198 INTEGER :: first_atom, iconst, index_a, index_b, &
199 index_c, index_d, nvsite
200 REAL(kind=
dp) :: wb, wc, wd
204 molecule_kind => molecule%molecule_kind
208 DO iconst = 1, nvsite
209 IF (vsite_list(iconst)%restraint%active) cycle
210 index_a = vsite_list(iconst)%a + first_atom - 1
211 index_b = vsite_list(iconst)%b + first_atom - 1
212 index_c = vsite_list(iconst)%c + first_atom - 1
213 index_d = vsite_list(iconst)%d + first_atom - 1
215 wb = vsite_list(iconst)%wbc
216 wd = vsite_list(iconst)%wdc
217 wc = 1.0_dp - vsite_list(iconst)%wbc - vsite_list(iconst)%wdc
219 particle_set(index_b)%f(:) = particle_set(index_b)%f(:) + wb*particle_set(index_a)%f(:)
220 particle_set(index_c)%f(:) = particle_set(index_c)%f(:) + wc*particle_set(index_a)%f(:)
221 particle_set(index_d)%f(:) = particle_set(index_d)%f(:) + wd*particle_set(index_a)%f(:)
222 particle_set(index_a)%f(:) = 0.0_dp
225 END SUBROUTINE force_vsite_int
234 SUBROUTINE force_vsite_ext(gci, particle_set)
238 INTEGER :: first_atom, iconst, index_a, index_b, &
239 index_c, index_d, nvsite
240 REAL(kind=
dp) :: wb, wc, wd
245 vsite_list => gci%vsite_list
248 DO iconst = 1, nvsite
249 IF (vsite_list(iconst)%restraint%active) cycle
250 index_a = vsite_list(iconst)%a + first_atom - 1
251 index_b = vsite_list(iconst)%b + first_atom - 1
252 index_c = vsite_list(iconst)%c + first_atom - 1
253 index_d = vsite_list(iconst)%d + first_atom - 1
255 wb = vsite_list(iconst)%wbc
256 wd = vsite_list(iconst)%wdc
257 wc = 1.0_dp - vsite_list(iconst)%wbc - vsite_list(iconst)%wdc
259 particle_set(index_b)%f(:) = particle_set(index_b)%f(:) + wb*particle_set(index_a)%f(:)
260 particle_set(index_c)%f(:) = particle_set(index_c)%f(:) + wc*particle_set(index_a)%f(:)
261 particle_set(index_d)%f(:) = particle_set(index_d)%f(:) + wd*particle_set(index_a)%f(:)
262 particle_set(index_a)%f(:) = 0.0_dp
264 END SUBROUTINE force_vsite_ext
Routines to handle the virtual site constraint/restraint.
subroutine, public shake_vsite_ext(gci, pos)
Intramolecular virtual site.
subroutine, public shake_vsite_int(molecule, pos)
Intramolecular virtual site.
subroutine, public vsite_force_control(force_env)
control force distribution for virtual sites
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell)
returns information about various attributes of the given subsys
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env, ipi_env)
returns various attributes about the force environment
Defines the basic variable types.
integer, parameter, public dp
represent a simple array based list of the given type
Define the molecule kind structure types and the corresponding functionality.
subroutine, public get_molecule_kind(molecule_kind, atom_list, bond_list, bend_list, ub_list, impr_list, opbend_list, colv_list, fixd_list, g3x3_list, g4x6_list, vsite_list, torsion_list, shell_list, name, mass, charge, kind_number, natom, nbend, nbond, nub, nimpr, nopbend, nconstraint, nconstraint_fixd, nfixd, ncolv, ng3x3, ng4x6, nvsite, nfixd_restraint, ng3x3_restraint, ng4x6_restraint, nvsite_restraint, nrestraints, nmolecule, nsgf, nshell, ntorsion, molecule_list, nelectron, nelectron_alpha, nelectron_beta, bond_kind_set, bend_kind_set, ub_kind_set, impr_kind_set, opbend_kind_set, torsion_kind_set, molname_generated)
Get informations about a molecule kind.
represent a simple array based list of the given type
Define the data structure for the molecule information.
subroutine, public get_molecule(molecule, molecule_kind, lmi, lci, lg3x3, lg4x6, lcolv, first_atom, last_atom, first_shell, last_shell)
Get components from a molecule data set.
represent a simple array based list of the given type
Define the data structure for the particle information.
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.
wrapper to abstract the force evaluation of the various methods
represent a list of objects
represent a list of objects
represent a list of objects