50#include "../base/base_uses.f90"
57 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'md_conserved_quantities'
86 LOGICAL,
INTENT(IN) :: tkind, tshell
87 INTEGER,
INTENT(IN) :: natom
89 INTEGER :: ikind, nfree_qm, nkind
90 INTEGER,
POINTER :: itimes
92 REAL(kind=
dp),
POINTER :: constant
96 NULLIFY (itimes, para_env, simpar)
107 CALL get_part_ke(md_env, md_ener, tkind, tshell, para_env)
109 IF (md_ener%nfree /= 0)
THEN
110 md_ener%temp_part = 2.0_dp*md_ener%ekin/real(simpar%nfree, kind=
dp)
111 md_ener%temp_part = md_ener%temp_part*
kelvin
115 IF (nfree_qm > 0)
THEN
116 md_ener%temp_qm = 2.0_dp*md_ener%ekin_qm/real(nfree_qm, kind=
dp)
117 md_ener%temp_qm = md_ener%temp_qm*
kelvin
120 IF (md_ener%nfree_shell > 0)
THEN
121 md_ener%temp_shell = 2.0_dp*md_ener%ekin_shell/real(md_ener%nfree_shell, kind=
dp)
122 md_ener%temp_shell = md_ener%temp_shell*
kelvin
126 nkind =
SIZE(md_ener%temp_kind)
128 md_ener%temp_kind(ikind) = 2.0_dp* &
129 md_ener%ekin_kind(ikind)/real(md_ener%nfree_kind(ikind), kind=
dp)
130 md_ener%temp_kind(ikind) = md_ener%temp_kind(ikind)*
kelvin
134 md_ener%temp_shell_kind(ikind) = 2.0_dp* &
135 md_ener%ekin_shell_kind(ikind)/real(md_ener%nfree_shell_kind(ikind), kind=
dp)
136 md_ener%temp_shell_kind(ikind) = md_ener%temp_shell_kind(ikind)*
kelvin
141 SELECT CASE (simpar%ensemble)
143 cpabort(
'Unknown ensemble')
145 md_ener%constant = md_ener%ekin
147 md_ener%constant = md_ener%epot
149 CALL get_econs_nve(md_env, md_ener, para_env)
151 CALL get_econs_nvt(md_env, md_ener, para_env)
153 CALL get_econs_npt(md_env, md_ener, para_env)
154 md_ener%temp_baro = md_ener%temp_baro*
kelvin
156 CALL get_econs_nph_uniaxial(md_env, md_ener)
157 md_ener%temp_baro = md_ener%temp_baro*
kelvin
159 CALL get_econs_nph_uniaxial(md_env, md_ener)
160 md_ener%temp_baro = md_ener%temp_baro*
kelvin
162 md_ener%constant = md_ener%ekin + md_ener%epot
164 CALL get_econs_npe(md_env, md_ener, para_env)
165 md_ener%temp_baro = md_ener%temp_baro*
kelvin
167 CALL get_econs_nvt_adiabatic(md_env, md_ener, para_env)
172 IF (constant == 0.0_dp)
THEN
173 constant = md_ener%constant
174 CALL set_md_env(md_env=md_env, constant=constant)
177 CALL get_md_env(md_env=md_env, constant=constant)
178 md_ener%delta_cons = (md_ener%constant - constant)/real(natom, kind=
dp)*
kelvin
195 INTEGER,
POINTER :: cur_indices(:), cur_labels(:)
203 NULLIFY (qmmm_env, qmmmx_env, subsys, particles, force_env, force_env_section)
210 qmmmx_env=qmmmx_env, &
211 force_env_section=force_env_section)
213 IF (
ASSOCIATED(qmmm_env))
THEN
220 nfree_qm = 3*
SIZE(qmmm_env%qm%qm_atom_index)
221 IF (nfree_qm == 3*(particles%n_els)) nfree_qm = md_ener%nfree
224 IF (
ASSOCIATED(qmmmx_env))
THEN
225 CALL section_vals_val_get(force_env_section,
"QMMM%FORCE_MIXING%RESTART_INFO%INDICES", i_vals=cur_indices)
226 CALL section_vals_val_get(force_env_section,
"QMMM%FORCE_MIXING%RESTART_INFO%LABELS", i_vals=cur_labels)
228 DO ip = 1,
SIZE(cur_indices)
230 nfree_qm = nfree_qm + 3
235 cpassert(.NOT. (
ASSOCIATED(qmmm_env) .AND.
ASSOCIATED(qmmmx_env)))
247 SUBROUTINE get_econs_nve(md_env, md_ener, para_env)
255 NULLIFY (force_env, thermostat_coeff, thermostat_shell)
257 CALL get_md_env(md_env, force_env=force_env, thermostat_coeff=thermostat_coeff, &
258 thermostat_shell=thermostat_shell)
259 md_ener%constant = md_ener%ekin + md_ener%epot + md_ener%ekin_shell
262 md_ener%thermostat_shell_kin, para_env)
263 md_ener%constant = md_ener%constant + md_ener%thermostat_shell_kin + md_ener%thermostat_shell_pot
265 END SUBROUTINE get_econs_nve
276 SUBROUTINE get_econs_nvt_adiabatic(md_env, md_ener, para_env)
284 NULLIFY (force_env, thermostat_fast, thermostat_slow)
285 CALL get_md_env(md_env, force_env=force_env, thermostat_fast=thermostat_fast, &
286 thermostat_slow=thermostat_slow)
288 md_ener%thermostat_fast_kin, para_env)
289 md_ener%constant = md_ener%ekin + md_ener%epot + &
290 md_ener%thermostat_fast_kin + md_ener%thermostat_fast_pot
292 md_ener%thermostat_slow_kin, para_env)
293 md_ener%constant = md_ener%constant + &
294 md_ener%thermostat_slow_kin + md_ener%thermostat_slow_pot
296 END SUBROUTINE get_econs_nvt_adiabatic
307 SUBROUTINE get_econs_nvt(md_env, md_ener, para_env)
316 NULLIFY (force_env, thermostat_part, thermostat_coeff, thermostat_shell)
317 CALL get_md_env(md_env, force_env=force_env, thermostat_part=thermostat_part, &
318 thermostat_coeff=thermostat_coeff, thermostat_shell=thermostat_shell)
320 md_ener%thermostat_part_kin, para_env)
321 md_ener%constant = md_ener%ekin + md_ener%epot + md_ener%ekin_shell + &
322 md_ener%thermostat_part_kin + md_ener%thermostat_part_pot
325 md_ener%thermostat_shell_kin, para_env)
326 md_ener%constant = md_ener%constant + md_ener%thermostat_shell_kin + md_ener%thermostat_shell_pot
328 END SUBROUTINE get_econs_nvt
339 SUBROUTINE get_econs_npe(md_env, md_ener, para_env)
350 NULLIFY (thermostat_baro, thermostat_shell, npt)
351 CALL get_md_env(md_env, thermostat_baro=thermostat_baro, &
352 simpar=simpar, npt=npt, cell=box, &
353 thermostat_shell=thermostat_shell)
356 nfree =
SIZE(npt, 1)*
SIZE(npt, 2)
357 md_ener%temp_baro = 2.0_dp*md_ener%baro_kin/nfree
359 md_ener%constant = md_ener%ekin + md_ener%epot + md_ener%ekin_shell &
360 + md_ener%baro_kin + md_ener%baro_pot
363 md_ener%thermostat_shell_kin, para_env)
364 md_ener%constant = md_ener%constant + md_ener%thermostat_shell_kin + &
365 md_ener%thermostat_shell_pot
367 END SUBROUTINE get_econs_npe
378 SUBROUTINE get_econs_npt(md_env, md_ener, para_env)
390 NULLIFY (thermostat_baro, thermostat_part, thermostat_shell, npt, simpar, box)
391 CALL get_md_env(md_env, thermostat_part=thermostat_part, thermostat_baro=thermostat_baro, &
392 simpar=simpar, npt=npt, cell=box, thermostat_shell=thermostat_shell)
394 md_ener%thermostat_part_kin, para_env)
396 md_ener%thermostat_baro_kin, para_env)
398 nfree =
SIZE(npt, 1)*
SIZE(npt, 2)
399 md_ener%temp_baro = 2.0_dp*md_ener%baro_kin/nfree
401 md_ener%constant = md_ener%ekin + md_ener%epot + md_ener%ekin_shell &
402 + md_ener%thermostat_part_kin + md_ener%thermostat_part_pot &
403 + md_ener%thermostat_baro_kin + md_ener%thermostat_baro_pot &
404 + md_ener%baro_kin + md_ener%baro_pot
407 md_ener%thermostat_shell_kin, para_env)
408 md_ener%constant = md_ener%constant + md_ener%thermostat_shell_kin + md_ener%thermostat_shell_pot
410 END SUBROUTINE get_econs_npt
420 SUBROUTINE get_econs_nph_uniaxial(md_env, md_ener)
428 CALL get_md_env(md_env, simpar=simpar, npt=npt, cell=box)
431 md_ener%temp_baro = 2.0_dp*md_ener%baro_kin
432 md_ener%constant = md_ener%ekin + md_ener%epot + md_ener%baro_kin + md_ener%baro_pot
433 END SUBROUTINE get_econs_nph_uniaxial
446 SUBROUTINE get_part_ke(md_env, md_ener, tkind, tshell, group)
449 LOGICAL,
INTENT(IN) :: tkind, tshell
453 INTEGER :: i, iparticle, iparticle_kind, &
454 iparticle_local, nparticle_kind, &
455 nparticle_local, shell_index
456 INTEGER,
POINTER :: cur_indices(:), cur_labels(:)
458 REAL(kind=
dp) :: ekin_c, ekin_com, ekin_s, mass
467 TYPE(
particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
474 NULLIFY (force_env, qmmm_env, qmmmx_env, subsys, force_env_section)
479 qmmmx_env=qmmmx_env, &
480 force_env_section=force_env_section)
483 atomic_kinds=atomic_kinds, &
484 local_particles=local_particles, &
485 particles=particles, shell_particles=shell_particles, &
486 core_particles=core_particles)
488 nparticle_kind = atomic_kinds%n_els
489 atomic_kind_set => atomic_kinds%els
495 md_ener%nfree_kind = 0
497 md_ener%nfree_shell_kind = 0
501 particle_set => particles%els
503 shell_particle_set => shell_particles%els
504 core_particle_set => core_particles%els
505 DO iparticle_kind = 1, nparticle_kind
506 atomic_kind => atomic_kind_set(iparticle_kind)
508 shell_active=is_shell, shell=shell)
509 nparticle_local = local_particles%n_el(iparticle_kind)
511 DO iparticle_local = 1, nparticle_local
512 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
513 shell_index = particle_set(iparticle)%shell_index
515 ekin_com = 0.5_dp*mass* &
516 (particle_set(iparticle)%v(1)*particle_set(iparticle)%v(1) &
517 + particle_set(iparticle)%v(2)*particle_set(iparticle)%v(2) &
518 + particle_set(iparticle)%v(3)*particle_set(iparticle)%v(3))
520 md_ener%vcom(1) = md_ener%vcom(1) + particle_set(iparticle)%v(1)*mass
521 md_ener%vcom(2) = md_ener%vcom(2) + particle_set(iparticle)%v(2)*mass
522 md_ener%vcom(3) = md_ener%vcom(3) + particle_set(iparticle)%v(3)*mass
523 md_ener%total_mass = md_ener%total_mass + mass
525 md_ener%ekin = md_ener%ekin + ekin_com
526 ekin_c = 0.5_dp*shell%mass_core* &
527 (core_particle_set(shell_index)%v(1)*core_particle_set(shell_index)%v(1) &
528 + core_particle_set(shell_index)%v(2)*core_particle_set(shell_index)%v(2) &
529 + core_particle_set(shell_index)%v(3)*core_particle_set(shell_index)%v(3))
530 ekin_s = 0.5_dp*shell%mass_shell* &
531 (shell_particle_set(shell_index)%v(1)*shell_particle_set(shell_index)%v(1) &
532 + shell_particle_set(shell_index)%v(2)*shell_particle_set(shell_index)%v(2) &
533 + shell_particle_set(shell_index)%v(3)*shell_particle_set(shell_index)%v(3))
534 md_ener%ekin_shell = md_ener%ekin_shell + ekin_c + ekin_s - ekin_com
537 md_ener%ekin_kind(iparticle_kind) = md_ener%ekin_kind(iparticle_kind) + ekin_com
538 md_ener%nfree_kind(iparticle_kind) = md_ener%nfree_kind(iparticle_kind) + 3
539 md_ener%ekin_shell_kind(iparticle_kind) = md_ener%ekin_shell_kind(iparticle_kind) + &
540 ekin_c + ekin_s - ekin_com
541 md_ener%nfree_shell_kind(iparticle_kind) = md_ener%nfree_shell_kind(iparticle_kind) + 3
546 DO iparticle_local = 1, nparticle_local
547 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
548 ekin_com = 0.5_dp*mass* &
549 (particle_set(iparticle)%v(1)*particle_set(iparticle)%v(1) &
550 + particle_set(iparticle)%v(2)*particle_set(iparticle)%v(2) &
551 + particle_set(iparticle)%v(3)*particle_set(iparticle)%v(3))
553 md_ener%vcom(1) = md_ener%vcom(1) + particle_set(iparticle)%v(1)*mass
554 md_ener%vcom(2) = md_ener%vcom(2) + particle_set(iparticle)%v(2)*mass
555 md_ener%vcom(3) = md_ener%vcom(3) + particle_set(iparticle)%v(3)*mass
556 md_ener%total_mass = md_ener%total_mass + mass
558 md_ener%ekin = md_ener%ekin + ekin_com
560 md_ener%ekin_kind(iparticle_kind) = md_ener%ekin_kind(iparticle_kind) + ekin_com
561 md_ener%nfree_kind(iparticle_kind) = md_ener%nfree_kind(iparticle_kind) + 3
567 CALL group%sum(md_ener%ekin_kind)
568 CALL group%sum(md_ener%nfree_kind)
569 CALL group%sum(md_ener%ekin_shell_kind)
570 CALL group%sum(md_ener%nfree_shell_kind)
573 CALL group%sum(md_ener%ekin_shell)
575 DO iparticle_kind = 1, nparticle_kind
576 atomic_kind => atomic_kind_set(iparticle_kind)
578 nparticle_local = local_particles%n_el(iparticle_kind)
579 DO iparticle_local = 1, nparticle_local
580 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
582 ekin_com = 0.5_dp*mass* &
583 (particle_set(iparticle)%v(1)*particle_set(iparticle)%v(1) &
584 + particle_set(iparticle)%v(2)*particle_set(iparticle)%v(2) &
585 + particle_set(iparticle)%v(3)*particle_set(iparticle)%v(3))
588 md_ener%vcom(1) = md_ener%vcom(1) + particle_set(iparticle)%v(1)*mass
589 md_ener%vcom(2) = md_ener%vcom(2) + particle_set(iparticle)%v(2)*mass
590 md_ener%vcom(3) = md_ener%vcom(3) + particle_set(iparticle)%v(3)*mass
591 md_ener%total_mass = md_ener%total_mass + mass
593 md_ener%ekin = md_ener%ekin + ekin_com
595 md_ener%ekin_kind(iparticle_kind) = md_ener%ekin_kind(iparticle_kind) + ekin_com
596 md_ener%nfree_kind(iparticle_kind) = md_ener%nfree_kind(iparticle_kind) + 3
601 CALL group%sum(md_ener%ekin_kind)
602 CALL group%sum(md_ener%nfree_kind)
607 CALL group%sum(md_ener%ekin)
608 CALL group%sum(md_ener%vcom)
609 CALL group%sum(md_ener%total_mass)
610 md_ener%vcom = md_ener%vcom/md_ener%total_mass
614 IF (
ASSOCIATED(qmmm_env))
THEN
615 DO i = 1,
SIZE(qmmm_env%qm%qm_atom_index)
616 iparticle = qmmm_env%qm%qm_atom_index(i)
617 mass = particle_set(iparticle)%atomic_kind%mass
618 md_ener%ekin_qm = md_ener%ekin_qm + 0.5_dp*mass* &
619 (particle_set(iparticle)%v(1)*particle_set(iparticle)%v(1) &
620 + particle_set(iparticle)%v(2)*particle_set(iparticle)%v(2) &
621 + particle_set(iparticle)%v(3)*particle_set(iparticle)%v(3))
625 IF (
ASSOCIATED(qmmmx_env))
THEN
626 CALL section_vals_val_get(force_env_section,
"QMMM%FORCE_MIXING%RESTART_INFO%INDICES", i_vals=cur_indices)
627 CALL section_vals_val_get(force_env_section,
"QMMM%FORCE_MIXING%RESTART_INFO%LABELS", i_vals=cur_labels)
628 DO i = 1,
SIZE(cur_indices)
630 iparticle = cur_indices(i)
631 mass = particle_set(iparticle)%atomic_kind%mass
632 md_ener%ekin_qm = md_ener%ekin_qm + 0.5_dp*mass* &
633 (particle_set(iparticle)%v(1)*particle_set(iparticle)%v(1) &
634 + particle_set(iparticle)%v(2)*particle_set(iparticle)%v(2) &
635 + particle_set(iparticle)%v(3)*particle_set(iparticle)%v(3))
640 IF (
ASSOCIATED(qmmm_env) .AND.
ASSOCIATED(qmmmx_env)) &
641 cpabort(
"get_part_ke: qmmm bug")
642 END SUBROUTINE get_part_ke
represent a simple array based list of the given type
Define the atomic kind types and their sub types.
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.
subroutine, public get_baro_energies(cell, simpar, npt, baro_kin, baro_pot)
Calculates kinetic energy and potential of barostat.
Handles all functions related to the CELL.
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...
Lumps all possible extended system variables into one type for easy access and passing.
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
Definition of mathematical constants and functions.
real(kind=dp), parameter, public zero
computes the conserved quantities for a given md ensemble and also kinetic energies,...
integer function, public calc_nfree_qm(md_env, md_ener)
Calculates the number of QM degress of freedom.
subroutine, public compute_conserved_quantity(md_env, md_ener, tkind, tshell, natom)
calculates conserved quantity.
Split md_ener module from md_environment_type.
subroutine, public zero_md_ener(md_ener, tkind, tshell)
initialize to zero energies and temperatures
subroutine, public set_md_env(md_env, itimes, constant, cell, simpar, fe_env, force_env, para_env, init, first_time, thermostats, barostat, reftraj, md_ener, averages, thermal_regions, ehrenfest_md)
Set the integrator environment to the correct program.
subroutine, public get_md_env(md_env, itimes, constant, used_time, cell, simpar, npt, force_env, para_env, reftraj, t, init, first_time, fe_env, thermostats, barostat, thermostat_coeff, thermostat_part, thermostat_shell, thermostat_baro, thermostat_fast, thermostat_slow, md_ener, averages, thermal_regions, ehrenfest_md)
get components of MD environment type
Interface to the message passing library MPI.
represent a simple array based list of the given type
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public kelvin
integer, parameter, public force_mixing_label_qm_dynamics
Basic container type for QM/MM.
Basic container type for QM/MM with force mixing.
Type for storing MD parameters.
Thermostat structure: module containing thermostat available for MD.
Utilities for thermostats.
subroutine, public get_thermostat_energies(thermostat, thermostat_pot, thermostat_kin, para_env, array_pot, array_kin)
Calculates energy associated with a thermostat.
represent a list of objects
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
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
stores all the informations relevant to an mpi environment
represent a list of objects
Simulation parameter type for molecular dynamics.