31 #include "./base/base_uses.f90"
37 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mixed_environment_utils'
61 virials, results, factor, iforce_eval, nforce_eval, map_index, &
62 mapping_section, overwrite)
64 TYPE(particle_list_type),
POINTER :: particles_mix
65 TYPE(virial_type),
POINTER :: virial_mix
66 TYPE(cp_result_type),
POINTER :: results_mix
67 TYPE(mixed_force_type),
DIMENSION(:),
POINTER :: global_forces
68 TYPE(virial_p_type),
DIMENSION(:),
POINTER :: virials
69 TYPE(cp_result_p_type),
DIMENSION(:),
POINTER :: results
70 REAL(kind=
dp),
INTENT(IN) :: factor
71 INTEGER,
INTENT(IN) :: iforce_eval, nforce_eval
72 INTEGER,
DIMENSION(:),
POINTER :: map_index
73 TYPE(section_vals_type),
POINTER :: mapping_section
74 LOGICAL,
INTENT(IN) :: overwrite
76 CHARACTER(LEN=default_string_length) :: description
77 INTEGER :: iparticle, jparticle, natom, nres
79 REAL(kind=
dp),
DIMENSION(3) :: dip_mix, dip_tmp
83 natom =
SIZE(global_forces(iforce_eval)%forces, 2)
85 DO iparticle = 1, natom
86 jparticle = map_index(iparticle)
88 particles_mix%els(jparticle)%f(:) = factor*global_forces(iforce_eval)%forces(:, iparticle)
90 particles_mix%els(jparticle)%f(:) = particles_mix%els(jparticle)%f(:) + &
91 factor*global_forces(iforce_eval)%forces(:, iparticle)
95 IF (virial_mix%pv_availability)
THEN
96 IF (overwrite)
CALL zero_virial(virial_mix, reset=.false.)
97 virial_mix%pv_total = virial_mix%pv_total + factor*virials(iforce_eval)%virial%pv_total
98 virial_mix%pv_kinetic = virial_mix%pv_kinetic + factor*virials(iforce_eval)%virial%pv_kinetic
99 virial_mix%pv_virial = virial_mix%pv_virial + factor*virials(iforce_eval)%virial%pv_virial
100 virial_mix%pv_xc = virial_mix%pv_xc + factor*virials(iforce_eval)%virial%pv_xc
101 virial_mix%pv_fock_4c = virial_mix%pv_fock_4c + factor*virials(iforce_eval)%virial%pv_fock_4c
102 virial_mix%pv_constraint = virial_mix%pv_constraint + factor*virials(iforce_eval)%virial%pv_constraint
105 IF (
ASSOCIATED(map_index))
THEN
106 DEALLOCATE (map_index)
110 description =
'[DIPOLE]'
113 dip_exists =
test_for_result(results=results(iforce_eval)%results, description=description)
115 CALL get_results(results=results_mix, description=description, n_rep=nres)
118 IF (nres == 1)
CALL get_results(results=results_mix, description=description, values=dip_mix)
119 CALL get_results(results=results(iforce_eval)%results, description=description, n_rep=nres)
120 CALL get_results(results=results(iforce_eval)%results, description=description, &
121 values=dip_tmp, nval=nres)
122 dip_mix = dip_mix + factor*dip_tmp
124 CALL put_results(results=results_mix, description=description, values=dip_mix)
142 TYPE(section_vals_type),
POINTER :: mapping_section
143 INTEGER,
INTENT(IN) :: natom, iforce_eval, nforce_eval
144 INTEGER,
DIMENSION(:),
POINTER :: map_index
145 LOGICAL,
OPTIONAL :: force_eval_embed
147 INTEGER :: i, iatom, ival, j, jval, k, n_rep, &
148 n_rep_loc, n_rep_map, n_rep_sys, tmp
149 INTEGER,
DIMENSION(:),
POINTER :: index_glo, index_loc,
list
150 LOGICAL :: check, explicit
151 TYPE(section_vals_type),
POINTER :: fragments_loc, fragments_sys, &
152 map_force_ev, map_full_sys
154 cpassert(.NOT.
ASSOCIATED(map_index))
155 ALLOCATE (map_index(natom))
157 IF (.NOT. explicit)
THEN
164 IF (.NOT.
PRESENT(force_eval_embed))
THEN
174 cpassert(n_rep == nforce_eval)
177 IF (ival == iforce_eval)
EXIT
179 cpassert(i <= nforce_eval)
180 mark_used(nforce_eval)
185 CALL section_vals_get(fragments_sys, explicit=explicit, n_repetition=n_rep_sys)
187 cpassert(n_rep_sys >= n_rep_loc)
188 IF (n_rep_loc == 0)
THEN
191 CALL section_vals_val_get(map_force_ev,
"DEFINE_FRAGMENTS", i_rep_section=i, n_rep_val=n_rep_map)
192 check = (n_rep_map /= 0)
195 cpassert(
SIZE(
list) > 0)
201 IF (tmp == jval)
EXIT
203 CALL section_vals_val_get(fragments_sys,
"_DEFAULT_KEYWORD_", i_rep_section=j, i_vals=index_glo)
204 DO k = 0, index_glo(2) - index_glo(1)
206 cpassert(iatom <= natom)
207 map_index(iatom) = index_glo(1) + k
210 check = (iatom == natom)
221 IF (tmp == jval)
EXIT
223 cpassert(j <= n_rep_sys)
224 CALL section_vals_val_get(fragments_loc,
"_DEFAULT_KEYWORD_", i_rep_section=i, i_vals=index_loc)
225 CALL section_vals_val_get(fragments_sys,
"_DEFAULT_KEYWORD_", i_rep_section=j, i_vals=index_glo)
226 check = ((index_loc(2) - index_loc(1)) == (index_glo(2) - index_glo(1)))
229 DO k = 0, index_loc(2) - index_loc(1)
230 map_index(index_loc(1) + k) = index_glo(1) + k
set of type/routines to handle the storage of results in force_envs
subroutine, public cp_results_erase(results, description, nval)
erase a part of result_list
logical function, public test_for_result(results, description)
test for a certain result in the result_list
set of type/routines to handle the storage of results in force_envs
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
subroutine, public get_subsys_map_index(mapping_section, natom, iforce_eval, nforce_eval, map_index, force_eval_embed)
performs mapping of the subsystems of different force_eval
subroutine, public mixed_map_forces(particles_mix, virial_mix, results_mix, global_forces, virials, results, factor, iforce_eval, nforce_eval, map_index, mapping_section, overwrite)
Maps forces between the different force_eval sections/environments.
represent a simple array based list of the given type
subroutine, public zero_virial(virial, reset)
...