40#include "./base/base_uses.f90"
52 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'constraint_fxd'
66 REAL(kind=
dp),
DIMENSION(:, :),
OPTIONAL :: w
68 CHARACTER(len=*),
PARAMETER :: routinen =
'fix_atom_control'
70 INTEGER :: handle, i, ifixd, ii, ikind, iparticle, iparticle_local, my_atm_fixed, natom, &
71 ncore, nfixed_atoms, nkind, nparticle, nparticle_local, nshell, shell_index
72 LOGICAL :: shell_present
73 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: force
84 TYPE(
particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
87 CALL timeset(routinen, handle)
89 NULLIFY (atomic_kinds)
90 NULLIFY (core_particles)
92 NULLIFY (shell_particles)
93 shell_present = .false.
99 atomic_kinds=atomic_kinds, &
100 core_particles=core_particles, &
101 local_particles=local_particles, &
102 molecule_kinds=molecule_kinds, &
106 particles=particles, &
107 shell_particles=shell_particles)
109 shell_present=shell_present)
111 particle_set => particles%els
112 cpassert((
SIZE(particle_set) == natom))
113 IF (shell_present)
THEN
114 core_particle_set => core_particles%els
115 cpassert((
SIZE(core_particle_set) == ncore))
116 shell_particle_set => shell_particles%els
117 cpassert((
SIZE(shell_particle_set) == nshell))
119 nparticle = natom + nshell
120 molecule_kind_set => molecule_kinds%els
122 nkind = molecule_kinds%n_els
125 molecule_kind => molecule_kind_set(ikind)
127 my_atm_fixed = my_atm_fixed + nfixed_atoms
130 IF (my_atm_fixed /= 0)
THEN
131 IF (.NOT.
PRESENT(w))
THEN
133 ALLOCATE (force(3, nparticle))
135 DO i = 1,
SIZE(local_particles%n_el)
136 nparticle_local = local_particles%n_el(i)
137 DO iparticle_local = 1, nparticle_local
138 iparticle = local_particles%list(i)%array(iparticle_local)
139 shell_index = particle_set(iparticle)%shell_index
140 IF (shell_index == 0)
THEN
141 force(:, iparticle) = particle_set(iparticle)%f(:)
143 force(:, iparticle) = core_particle_set(shell_index)%f(:)
144 force(:, natom + shell_index) = shell_particle_set(shell_index)%f(:)
154 DO ifixd = 1,
SIZE(lfixd_list)
155 ikind = lfixd_list(ifixd)%ikind
156 ii = lfixd_list(ifixd)%ifixd_index
157 molecule_kind => molecule_kind_set(ikind)
159 IF (.NOT. fixd_list(ii)%restraint%active)
THEN
160 iparticle = fixd_list(ii)%fixd
161 shell_index = particle_set(iparticle)%shell_index
164 SELECT CASE (fixd_list(ii)%itype)
166 w(1, iparticle) = 0.0_dp
168 w(2, iparticle) = 0.0_dp
170 w(3, iparticle) = 0.0_dp
172 w(1, iparticle) = 0.0_dp
173 w(2, iparticle) = 0.0_dp
175 w(1, iparticle) = 0.0_dp
176 w(3, iparticle) = 0.0_dp
178 w(2, iparticle) = 0.0_dp
179 w(3, iparticle) = 0.0_dp
181 w(:, iparticle) = 0.0_dp
184 SELECT CASE (fixd_list(ii)%itype)
186 force(1, iparticle) = 0.0_dp
187 IF (shell_index /= 0)
THEN
188 force(1, natom + shell_index) = 0.0_dp
191 force(2, iparticle) = 0.0_dp
192 IF (shell_index /= 0)
THEN
193 force(2, natom + shell_index) = 0.0_dp
196 force(3, iparticle) = 0.0_dp
197 IF (shell_index /= 0)
THEN
198 force(3, natom + shell_index) = 0.0_dp
201 force(1, iparticle) = 0.0_dp
202 force(2, iparticle) = 0.0_dp
203 IF (shell_index /= 0)
THEN
204 force(1, natom + shell_index) = 0.0_dp
205 force(2, natom + shell_index) = 0.0_dp
208 force(1, iparticle) = 0.0_dp
209 force(3, iparticle) = 0.0_dp
210 IF (shell_index /= 0)
THEN
211 force(1, natom + shell_index) = 0.0_dp
212 force(3, natom + shell_index) = 0.0_dp
215 force(2, iparticle) = 0.0_dp
216 force(3, iparticle) = 0.0_dp
217 IF (shell_index /= 0)
THEN
218 force(2, natom + shell_index) = 0.0_dp
219 force(3, natom + shell_index) = 0.0_dp
222 force(:, iparticle) = 0.0_dp
223 IF (shell_index /= 0)
THEN
224 force(:, natom + shell_index) = 0.0_dp
232 IF (.NOT.
PRESENT(w))
THEN
233 CALL force_env%para_env%sum(force)
234 DO iparticle = 1, natom
235 shell_index = particle_set(iparticle)%shell_index
236 IF (shell_index == 0)
THEN
237 particle_set(iparticle)%f(:) = force(:, iparticle)
239 core_particle_set(shell_index)%f(:) = force(:, iparticle)
240 shell_particle_set(shell_index)%f(:) = force(:, natom + shell_index)
247 CALL timestop(handle)
265 index_a, index_b, index_c, fixd_list, lg3x3)
266 REAL(kind=
dp),
INTENT(INOUT) :: imass1, imass2, imass3
267 INTEGER,
INTENT(IN) :: index_a, index_b, index_c
274 imass1 = lg3x3%imass1
275 imass2 = lg3x3%imass2
276 imass3 = lg3x3%imass3
278 IF (
ASSOCIATED(fixd_list))
THEN
279 IF (
SIZE(fixd_list) > 0)
THEN
280 DO i = 1,
SIZE(fixd_list)
281 IF (fixd_list(i)%fixd == index_a)
THEN
283 IF (.NOT. fixd_list(i)%restraint%active) imass1 = 0.0_dp
287 DO i = 1,
SIZE(fixd_list)
288 IF (fixd_list(i)%fixd == index_b)
THEN
290 IF (.NOT. fixd_list(i)%restraint%active) imass2 = 0.0_dp
294 DO i = 1,
SIZE(fixd_list)
295 IF (fixd_list(i)%fixd == index_c)
THEN
297 IF (.NOT. fixd_list(i)%restraint%active) imass3 = 0.0_dp
303 lg3x3%imass1 = imass1
304 lg3x3%imass2 = imass2
305 lg3x3%imass3 = imass3
326 index_a, index_b, index_c, index_d, fixd_list, lg4x6)
327 REAL(kind=
dp),
INTENT(INOUT) :: imass1, imass2, imass3, imass4
328 INTEGER,
INTENT(IN) :: index_a, index_b, index_c, index_d
335 imass1 = lg4x6%imass1
336 imass2 = lg4x6%imass2
337 imass3 = lg4x6%imass3
338 imass4 = lg4x6%imass4
340 IF (
ASSOCIATED(fixd_list))
THEN
341 IF (
SIZE(fixd_list) > 0)
THEN
342 DO i = 1,
SIZE(fixd_list)
343 IF (fixd_list(i)%fixd == index_a)
THEN
345 IF (.NOT. fixd_list(i)%restraint%active) imass1 = 0.0_dp
349 DO i = 1,
SIZE(fixd_list)
350 IF (fixd_list(i)%fixd == index_b)
THEN
352 IF (.NOT. fixd_list(i)%restraint%active) imass2 = 0.0_dp
356 DO i = 1,
SIZE(fixd_list)
357 IF (fixd_list(i)%fixd == index_c)
THEN
359 IF (.NOT. fixd_list(i)%restraint%active) imass3 = 0.0_dp
363 DO i = 1,
SIZE(fixd_list)
364 IF (fixd_list(i)%fixd == index_d)
THEN
366 IF (.NOT. fixd_list(i)%restraint%active) imass4 = 0.0_dp
372 lg4x6%imass1 = imass1
373 lg4x6%imass2 = imass2
374 lg4x6%imass3 = imass3
375 lg4x6%imass4 = imass4
393 IF (
ASSOCIATED(fixd_list))
THEN
394 IF (
ASSOCIATED(fixd_list))
THEN
395 IF (
SIZE(fixd_list) > 0)
THEN
396 DO i = 1,
SIZE(colvar%i_atom)
398 DO k = 1,
SIZE(fixd_list)
399 IF (fixd_list(k)%fixd == j)
THEN
401 IF (.NOT. fixd_list(k)%restraint%active) &
402 colvar%dsdr(:, i) = 0.0_dp
424 INTEGER,
INTENT(IN) :: nkind
428 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_local_fixd_list'
430 INTEGER :: handle, i, ikind, iparticle, &
431 iparticle_local, isize, jsize, ncnst, &
432 nparticle_local, nparticle_local_all, &
434 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: fixed_atom_all, kind_index_all, &
435 local_particle_all, work0, work1, work2
439 CALL timeset(routinen, handle)
440 cpassert(.NOT.
ASSOCIATED(lfixd_list))
443 molecule_kind => molecule_kind_set(ikind)
445 IF (
ASSOCIATED(fixd_list))
THEN
446 nsize = nsize +
SIZE(fixd_list)
450 ALLOCATE (fixed_atom_all(nsize))
451 ALLOCATE (work0(nsize))
452 ALLOCATE (work1(nsize))
453 ALLOCATE (kind_index_all(nsize))
456 molecule_kind => molecule_kind_set(ikind)
458 IF (
ASSOCIATED(fixd_list))
THEN
459 DO i = 1,
SIZE(fixd_list)
462 kind_index_all(nsize) = ikind
463 fixed_atom_all(nsize) = fixd_list(i)%fixd
468 CALL sort(fixed_atom_all, nsize, work1)
471 nparticle_local_all = 0
472 DO i = 1,
SIZE(local_particles%n_el)
473 nparticle_local_all = nparticle_local_all + local_particles%n_el(i)
475 ALLOCATE (local_particle_all(nparticle_local_all))
476 ALLOCATE (work2(nparticle_local_all))
477 nparticle_local_all = 0
478 DO i = 1,
SIZE(local_particles%n_el)
479 nparticle_local = local_particles%n_el(i)
480 DO iparticle_local = 1, nparticle_local
481 nparticle_local_all = nparticle_local_all + 1
482 iparticle = local_particles%list(i)%array(iparticle_local)
483 local_particle_all(nparticle_local_all) = iparticle
486 CALL sort(local_particle_all, nparticle_local_all, work2)
491 loop_count:
DO isize = 1, nparticle_local_all
492 DO WHILE (local_particle_all(isize) > fixed_atom_all(jsize))
494 IF (jsize > nsize)
THEN
499 IF (local_particle_all(isize) == fixed_atom_all(jsize)) ncnst = ncnst + 1
503 ALLOCATE (lfixd_list(ncnst))
508 loop_fill:
DO isize = 1, nparticle_local_all
509 DO WHILE (local_particle_all(isize) > fixed_atom_all(jsize))
511 IF (jsize > nsize)
THEN
516 IF (local_particle_all(isize) == fixed_atom_all(jsize))
THEN
518 lfixd_list(ncnst)%ifixd_index = work0(work1(jsize))
519 lfixd_list(ncnst)%ikind = kind_index_all(work1(jsize))
524 DEALLOCATE (local_particle_all)
526 DEALLOCATE (fixed_atom_all)
528 DEALLOCATE (kind_index_all)
531 ALLOCATE (lfixd_list(0))
533 CALL timestop(handle)
544 cpassert(
ASSOCIATED(lfixd_list))
545 DEALLOCATE (lfixd_list)
represent a simple array based list of the given type
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.
Handles all functions related to the CELL.
integer, parameter, public use_perd_xyz
integer, parameter, public use_perd_y
integer, parameter, public use_perd_xz
integer, parameter, public use_perd_x
integer, parameter, public use_perd_z
integer, parameter, public use_perd_yz
integer, parameter, public use_perd_xy
Initialize the collective variables types.
subroutine, public check_fixed_atom_cns_colv(fixd_list, colvar)
...
subroutine, public check_fixed_atom_cns_g4x6(imass1, imass2, imass3, imass4, index_a, index_b, index_c, index_d, fixd_list, lg4x6)
...
subroutine, public fix_atom_control(force_env, w)
allows for fix atom constraints
subroutine, public release_local_fixd_list(lfixd_list)
destroy the list of local atoms on which to apply constraints/restraints Teodoro Laino [tlaino] - 11....
subroutine, public create_local_fixd_list(lfixd_list, nkind, molecule_kind_set, local_particles)
setup a list of local atoms on which to apply constraints/restraints
subroutine, public check_fixed_atom_cns_g3x3(imass1, imass2, imass3, index_a, index_b, index_c, fixd_list, lg3x3)
...
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.
Define the data structure for the molecule information.
represent a simple array based list of the given type
Define the data structure for the particle information.
All kind of helpful little routines.
represent a list of objects
parameters for a collective variable
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