32#include "./base/base_uses.f90"
37 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
38 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qmmmx_update'
53 LOGICAL :: force_mixing_active, labels_changed
59 qmmm_extended_section, &
60 qmmm_force_mixing, qmmm_section, &
65 IF (.NOT.
ASSOCIATED(force_env))
RETURN
66 IF (.NOT.
ASSOCIATED(force_env%force_env_section))
RETURN
69 IF (.NOT.
ASSOCIATED(qmmm_section))
RETURN
71 IF (.NOT.
ASSOCIATED(qmmm_force_mixing))
RETURN
73 IF (.NOT. force_mixing_active)
RETURN
74 IF (.NOT.
ASSOCIATED(force_env%qmmmx_env)) cpabort(
"force_env%qmmmx not associated")
78 IF (.NOT. labels_changed)
RETURN
79 cpwarn(
"Adaptive force-mixing labels changed, rebuilding QM/MM calculations!")
88 ALLOCATE (new_qmmmx_env%core)
90 force_env%root_section, force_env%para_env, force_env%globenv, &
91 force_env%force_env_section, qmmm_core_section, subsys_section, use_motion_section=.true., &
92 prev_subsys=subsys, ignore_outside_box=.true.)
93 ALLOCATE (new_qmmmx_env%ext)
95 force_env%root_section, force_env%para_env, force_env%globenv, &
96 force_env%force_env_section, qmmm_extended_section, subsys_section, use_motion_section=.true., &
97 prev_subsys=subsys, ignore_outside_box=.true.)
101 CALL qmmm_env_get(force_env%qmmmx_env%core, subsys=subsys)
102 CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds, local_particles=local_particles)
103 CALL qmmm_env_get(new_qmmmx_env%core, subsys=subsys_new)
104 CALL cp_subsys_get(subsys_new, atomic_kinds=new_atomic_kinds, local_particles=new_local_particles)
105 IF (
ASSOCIATED(local_particles%local_particle_set))
THEN
106 CALL copy_wiener_process(atomic_kinds, local_particles, new_atomic_kinds, new_local_particles)
109 CALL qmmm_env_get(force_env%qmmmx_env%ext, subsys=subsys)
110 CALL cp_subsys_get(subsys, atomic_kinds=atomic_kinds, local_particles=local_particles)
112 CALL cp_subsys_get(subsys_new, atomic_kinds=new_atomic_kinds, local_particles=new_local_particles)
113 IF (
ASSOCIATED(local_particles%local_particle_set))
THEN
114 CALL copy_wiener_process(atomic_kinds, local_particles, new_atomic_kinds, new_local_particles)
122 force_env%qmmmx_env = new_qmmmx_env
133 SUBROUTINE copy_wiener_process(from_local_particle_kinds, from_local_particles, &
134 to_local_particle_kinds, to_local_particles)
140 CHARACTER(LEN=*),
PARAMETER :: routinen =
'copy_wiener_process'
142 INTEGER :: from_iparticle_kind, from_iparticle_local(1), from_nparticle_kind, &
143 from_nparticle_local, handle, to_iparticle_global, to_iparticle_kind, to_iparticle_local, &
144 to_nparticle_kind, to_nparticle_local, tot_from_nparticle_local, tot_to_nparticle_local
147 CALL timeset(routinen, handle)
148 cpassert(
ASSOCIATED(from_local_particles))
149 cpassert(
ASSOCIATED(to_local_particles))
151 IF (.NOT.
ASSOCIATED(from_local_particles%local_particle_set))
RETURN
152 cpassert(.NOT.
ASSOCIATED(to_local_particles%local_particle_set))
154 from_nparticle_kind = from_local_particle_kinds%n_els
155 to_nparticle_kind = to_local_particle_kinds%n_els
158 tot_from_nparticle_local = 0
159 DO from_iparticle_kind = 1, from_nparticle_kind
160 tot_from_nparticle_local = tot_from_nparticle_local + from_local_particles%n_el(from_iparticle_kind)
162 tot_to_nparticle_local = 0
163 DO to_iparticle_kind = 1, to_nparticle_kind
164 tot_to_nparticle_local = tot_to_nparticle_local + to_local_particles%n_el(to_iparticle_kind)
166 cpassert(tot_from_nparticle_local == tot_to_nparticle_local)
168 ALLOCATE (to_local_particles%local_particle_set(to_nparticle_kind))
169 DO to_iparticle_kind = 1, to_nparticle_kind
171 to_nparticle_local = to_local_particles%n_el(to_iparticle_kind)
172 ALLOCATE (to_local_particles%local_particle_set(to_iparticle_kind)%rng(to_nparticle_local))
174 DO to_iparticle_local = 1, to_nparticle_local
175 to_iparticle_global = to_local_particles%list(to_iparticle_kind)%array(to_iparticle_local)
176 ALLOCATE (to_local_particles%local_particle_set(to_iparticle_kind)%rng(to_iparticle_local)%stream)
180 DO from_iparticle_kind = 1, from_nparticle_kind
181 from_nparticle_local = from_local_particles%n_el(from_iparticle_kind)
182 IF (minval(abs(from_local_particles%list(from_iparticle_kind)%array(1:from_nparticle_local) - &
183 to_iparticle_global)) == 0)
THEN
184 from_iparticle_local = &
185 minloc(abs(from_local_particles%list(from_iparticle_kind)%array(1:from_nparticle_local) - &
186 to_iparticle_global))
187 to_local_particles%local_particle_set(to_iparticle_kind)%rng(to_iparticle_local)%stream = &
188 from_local_particles%local_particle_set(from_iparticle_kind)%rng(from_iparticle_local(1))%stream
198 CALL timestop(handle)
200 END SUBROUTINE copy_wiener_process
represent a simple array based list of the given type
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
Initialize a QM/MM calculation.
subroutine, public qmmm_env_create(qmmm_env, root_section, para_env, globenv, force_env_section, qmmm_section, subsys_section, use_motion_section, prev_subsys, ignore_outside_box)
...
Basic container type for QM/MM.
subroutine, public qmmm_env_get(qmmm_env, subsys, potential_energy, kinetic_energy)
...
Basic container type for QM/MM with force mixing.
subroutine, public qmmmx_env_release(qmmmx_env)
releases the given qmmmx_env (see doc/ReferenceCounting.html)
Update a QM/MM calculations with force mixing.
subroutine, public qmmmx_update_force_env(force_env, root_section)
...
Routines used for force-mixing QM/MM calculations.
subroutine, public setup_force_mixing_qmmm_sections(subsys, qmmm_section, qmmm_core_section, qmmm_extended_section)
...
subroutine, public update_force_mixing_labels(subsys, qmmm_section, labels_changed)
...
represent a list of objects
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