114#include "../base/base_uses.f90"
120 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'integrator'
145 INTEGER :: iparticle, iparticle_kind, iparticle_local, iparticle_reg, ireg, nparticle, &
146 nparticle_kind, nparticle_local, nshell
147 INTEGER,
POINTER :: itimes
148 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: do_langevin
149 REAL(kind=
dp) :: c, c1, c2, c3, c4, dm, dt, gam, mass, &
150 noisy_gamma_region, reg_temp, sigma
151 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: var_w
152 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pos, vel, w
173 NULLIFY (cell, para_env, gci, force_env)
174 NULLIFY (atomic_kinds, local_particles, subsys, local_molecules, molecule_kinds, molecules)
175 NULLIFY (molecule_kind_set, molecule_set, particles, particle_set, simpar, virial)
176 NULLIFY (thermal_region, thermal_regions, itimes)
178 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
179 para_env=para_env, thermal_regions=thermal_regions, &
183 gam = simpar%gamma + simpar%shadow_gamma
186 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
192 atomic_kinds=atomic_kinds, &
194 local_particles=local_particles, &
195 local_molecules=local_molecules, &
196 molecules=molecules, &
197 molecule_kinds=molecule_kinds, &
199 particles=particles, &
201 IF (nshell /= 0)
THEN
202 cpabort(
"Langevin dynamics is not yet implemented for core-shell models")
205 nparticle_kind = atomic_kinds%n_els
206 atomic_kind_set => atomic_kinds%els
207 molecule_kind_set => molecule_kinds%els
209 nparticle = particles%n_els
210 particle_set => particles%els
211 molecule_set => molecules%els
214 ALLOCATE (do_langevin(nparticle))
215 IF (simpar%do_thermal_region)
THEN
216 DO iparticle = 1, nparticle
217 do_langevin(iparticle) = thermal_regions%do_langevin(iparticle)
220 do_langevin(1:nparticle) = .true.
231 ALLOCATE (var_w(nparticle))
232 var_w(1:nparticle) = simpar%var_w
233 IF (simpar%do_thermal_region)
THEN
234 DO ireg = 1, thermal_regions%nregions
235 thermal_region => thermal_regions%thermal_region(ireg)
236 noisy_gamma_region = thermal_region%noisy_gamma_region
237 DO iparticle_reg = 1, thermal_region%npart
238 iparticle = thermal_region%part_index(iparticle_reg)
239 reg_temp = thermal_region%temp_expected
240 var_w(iparticle) = 2.0_dp*reg_temp*simpar%dt*(simpar%gamma + noisy_gamma_region)
246 ALLOCATE (pos(3, nparticle))
249 ALLOCATE (vel(3, nparticle))
252 ALLOCATE (w(3, nparticle))
255 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
256 molecule_kind_set, particle_set, cell)
259 DO iparticle_kind = 1, nparticle_kind
260 atomic_kind => atomic_kind_set(iparticle_kind)
262 nparticle_local = local_particles%n_el(iparticle_kind)
263 DO iparticle_local = 1, nparticle_local
264 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
265 IF (do_langevin(iparticle))
THEN
266 sigma = var_w(iparticle)*mass
267 associate(rng_stream => local_particles%local_particle_set(iparticle_kind)% &
268 rng(iparticle_local))
269 w(1, iparticle) = rng_stream%stream%next(variance=sigma)
270 w(2, iparticle) = rng_stream%stream%next(variance=sigma)
271 w(3, iparticle) = rng_stream%stream%next(variance=sigma)
283 c = exp(-0.25_dp*dt*gam)
288 DO iparticle_kind = 1, nparticle_kind
289 atomic_kind => atomic_kind_set(iparticle_kind)
291 nparticle_local = local_particles%n_el(iparticle_kind)
294 DO iparticle_local = 1, nparticle_local
295 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
296 IF (do_langevin(iparticle))
THEN
297 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
298 c3*particle_set(iparticle)%f(:)
299 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
300 c1*particle_set(iparticle)%v(:) + &
301 c*dm*(dt*particle_set(iparticle)%f(:) + &
304 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
305 dm*particle_set(iparticle)%f(:)
306 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
307 dt*particle_set(iparticle)%v(:) + &
308 dm*dt*particle_set(iparticle)%f(:)
313 IF (simpar%constraint)
THEN
316 molecule_kind_set, dt, force_env%root_section)
318 CALL shake_control(gci, local_molecules, molecule_set, molecule_kind_set, &
319 particle_set, pos, vel, dt, simpar%shake_tol, &
320 simpar%info_constraint, simpar%lagrange_multipliers, &
321 simpar%dump_lm, cell, para_env, local_particles)
336 DO iparticle_kind = 1, nparticle_kind
337 atomic_kind => atomic_kind_set(iparticle_kind)
341 nparticle_local = local_particles%n_el(iparticle_kind)
342 DO iparticle_local = 1, nparticle_local
343 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
344 IF (do_langevin(iparticle))
THEN
345 vel(1, iparticle) = vel(1, iparticle) + c3*particle_set(iparticle)%f(1)
346 vel(2, iparticle) = vel(2, iparticle) + c3*particle_set(iparticle)%f(2)
347 vel(3, iparticle) = vel(3, iparticle) + c3*particle_set(iparticle)%f(3)
348 vel(1, iparticle) = c4*vel(1, iparticle) + c2*w(1, iparticle)/mass
349 vel(2, iparticle) = c4*vel(2, iparticle) + c2*w(2, iparticle)/mass
350 vel(3, iparticle) = c4*vel(3, iparticle) + c2*w(3, iparticle)/mass
352 vel(1, iparticle) = vel(1, iparticle) + dm*particle_set(iparticle)%f(1)
353 vel(2, iparticle) = vel(2, iparticle) + dm*particle_set(iparticle)%f(2)
354 vel(3, iparticle) = vel(3, iparticle) + dm*particle_set(iparticle)%f(3)
359 IF (simpar%temperature_annealing)
THEN
360 simpar%temp_ext = simpar%temp_ext*simpar%f_temperature_annealing
361 simpar%var_w = simpar%var_w*simpar%f_temperature_annealing
364 IF (simpar%constraint)
THEN
365 CALL rattle_control(gci, local_molecules, molecule_set, molecule_kind_set, &
366 particle_set, vel, dt, simpar%shake_tol, &
367 simpar%info_constraint, simpar%lagrange_multipliers, &
368 simpar%dump_lm, cell, para_env, local_particles)
378 DEALLOCATE (do_langevin)
381 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, molecule_set, &
382 molecule_kind_set, particle_set, virial, para_env)
398 SUBROUTINE nve(md_env, globenv)
400 TYPE(md_environment_type),
POINTER :: md_env
401 TYPE(global_environment_type),
POINTER :: globenv
403 INTEGER :: i_iter, n_iter, nparticle, &
404 nparticle_kind, nshell
405 INTEGER,
POINTER :: itimes
406 LOGICAL :: deallocate_vel, ehrenfest_md, &
407 shell_adiabatic, shell_check_distance, &
410 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: v_old
411 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
412 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
413 TYPE(cell_type),
POINTER :: cell
414 TYPE(cp_subsys_type),
POINTER :: subsys
415 TYPE(dft_control_type),
POINTER :: dft_control
416 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
417 TYPE(force_env_type),
POINTER :: force_env
418 TYPE(global_constraint_type),
POINTER :: gci
419 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
420 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
421 TYPE(molecule_list_type),
POINTER :: molecules
422 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
423 TYPE(mp_para_env_type),
POINTER :: para_env
424 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
426 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
428 TYPE(rt_prop_type),
POINTER :: rtp
429 TYPE(simpar_type),
POINTER :: simpar
430 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_shell
431 TYPE(tmp_variables_type),
POINTER :: tmp
432 TYPE(virial_type),
POINTER :: virial
434 NULLIFY (thermostat_coeff, tmp)
435 NULLIFY (subsys, simpar, para_env, cell, gci, force_env, virial)
436 NULLIFY (atomic_kinds, local_particles, molecules, molecule_kind_set, molecule_set, particle_set)
437 NULLIFY (shell_particles, shell_particle_set, core_particles, &
438 core_particle_set, thermostat_shell, dft_control, itimes)
439 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
440 thermostat_coeff=thermostat_coeff, thermostat_shell=thermostat_shell, &
441 para_env=para_env, ehrenfest_md=ehrenfest_md, itimes=itimes)
443 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
446 CALL apply_qmmm_walls_reflective(force_env)
448 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
449 particles=particles, local_molecules=local_molecules, molecules=molecules, &
450 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
452 nparticle_kind = atomic_kinds%n_els
453 atomic_kind_set => atomic_kinds%els
454 molecule_kind_set => molecule_kinds%els
456 nparticle = particles%n_els
457 particle_set => particles%els
458 molecule_set => molecules%els
460 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
461 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
462 shell_check_distance=shell_check_distance)
464 IF (shell_present)
THEN
465 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
466 core_particles=core_particles)
467 shell_particle_set => shell_particles%els
468 nshell =
SIZE(shell_particles%els)
470 IF (shell_adiabatic)
THEN
471 core_particle_set => core_particles%els
475 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
478 IF (shell_adiabatic)
THEN
479 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
480 local_particles, para_env, shell_particle_set=shell_particle_set, &
481 core_particle_set=core_particle_set)
484 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
485 molecule_kind_set, particle_set, cell)
488 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
489 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
491 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
492 local_particles, particle_set, core_particle_set, shell_particle_set, &
493 nparticle_kind, shell_adiabatic)
495 IF (simpar%constraint)
THEN
497 CALL shake_update_targets(gci, local_molecules, molecule_set, &
498 molecule_kind_set, dt, force_env%root_section)
500 CALL shake_control(gci, local_molecules, molecule_set, &
501 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
502 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
503 cell, para_env, local_particles)
507 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
508 core_particle_set, para_env, shell_adiabatic, pos=.true.)
510 IF (shell_adiabatic .AND. shell_check_distance)
THEN
511 CALL optimize_shell_core(force_env, particle_set, &
512 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
517 IF (ehrenfest_md)
THEN
518 ALLOCATE (v_old(3,
SIZE(tmp%vel, 2)))
519 v_old(:, :) = tmp%vel
520 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
521 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
522 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
523 core_particle_set, para_env, shell_adiabatic, vel=.true., &
524 should_deall_vel=.false.)
526 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
527 n_iter = dft_control%rtp_control%max_iter
532 DO i_iter = 1, n_iter
534 IF (ehrenfest_md)
THEN
535 CALL get_qs_env(qs_env=force_env%qs_env, rtp=rtp)
538 CALL propagation_step(force_env%qs_env, rtp, dft_control%rtp_control)
542 CALL force_env_calc_energy_force(force_env, require_consistent_energy_force=.false.)
544 IF (ehrenfest_md)
THEN
545 CALL rt_prop_output(force_env%qs_env, ehrenfest, delta_iter=force_env%qs_env%rtp%delta_iter)
549 CALL metadyn_integrator(force_env, itimes, tmp%vel)
552 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
553 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
555 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
556 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
557 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
558 cell, para_env, local_particles)
561 IF (shell_adiabatic)
THEN
562 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
563 local_particles, para_env, vel=tmp%vel, &
564 shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
567 IF (simpar%annealing)
THEN
568 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
569 IF (shell_adiabatic)
THEN
570 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
571 tmp%vel, tmp%shell_vel, tmp%core_vel)
575 IF (ehrenfest_md) deallocate_vel = force_env%qs_env%rtp%converged
576 IF (i_iter == n_iter) deallocate_vel = .true.
578 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
579 core_particle_set, para_env, shell_adiabatic, vel=.true., &
580 should_deall_vel=deallocate_vel)
581 IF (ehrenfest_md)
THEN
582 IF (force_env%qs_env%rtp%converged)
EXIT
588 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
589 molecule_set, molecule_kind_set, particle_set, virial, para_env)
591 CALL virial_evaluate(atomic_kind_set, particle_set, &
592 local_particles, virial, para_env)
612 TYPE(md_environment_type),
POINTER :: md_env
614 INTEGER :: nparticle, nparticle_kind, nshell
615 INTEGER,
POINTER :: itimes
616 LOGICAL :: shell_adiabatic, shell_present
618 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
619 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
620 TYPE(cp_subsys_type),
POINTER :: subsys
621 TYPE(distribution_1d_type),
POINTER :: local_particles
622 TYPE(force_env_type),
POINTER :: force_env
623 TYPE(mp_para_env_type),
POINTER :: para_env
624 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
626 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
628 TYPE(simpar_type),
POINTER :: simpar
629 TYPE(tmp_variables_type),
POINTER :: tmp
631 NULLIFY (force_env, tmp, simpar, itimes)
632 NULLIFY (atomic_kinds, para_env, subsys, local_particles)
633 NULLIFY (core_particles, particles, shell_particles)
634 NULLIFY (core_particle_set, particle_set, shell_particle_set)
636 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
637 para_env=para_env, itimes=itimes)
641 CALL force_env_get(force_env=force_env, subsys=subsys)
644 CALL apply_qmmm_walls_reflective(force_env)
646 IF (simpar%constraint)
THEN
647 cpabort(
"Constraints not yet implemented")
650 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, &
651 local_particles=local_particles, &
654 nparticle_kind = atomic_kinds%n_els
655 atomic_kind_set => atomic_kinds%els
656 nparticle = particles%n_els
657 particle_set => particles%els
659 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
660 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
662 IF (shell_present)
THEN
663 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
664 core_particles=core_particles)
665 shell_particle_set => shell_particles%els
666 nshell =
SIZE(shell_particles%els)
668 IF (shell_adiabatic)
THEN
669 core_particle_set => core_particles%els
673 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
676 CALL get_s_ds(tmp, nparticle_kind, atomic_kind_set, local_particles, particle_set, &
680 tmp%scale_v(1:3) = sqrt(1.0_dp/tmp%ds)
681 tmp%poly_v(1:3) = 2.0_dp*tmp%s/sqrt(tmp%ds)/dt
682 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
683 core_particle_set, shell_particle_set, nparticle_kind, &
686 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
687 local_particles, particle_set, core_particle_set, shell_particle_set, &
688 nparticle_kind, shell_adiabatic)
691 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
692 core_particle_set, para_env, shell_adiabatic, pos=.true.)
694 CALL force_env_calc_energy_force(force_env)
697 CALL metadyn_integrator(force_env, itimes, tmp%vel)
700 CALL get_s_ds(tmp, nparticle_kind, atomic_kind_set, local_particles, particle_set, &
701 dt, para_env, tmpv=.true.)
704 tmp%scale_v(1:3) = sqrt(1.0_dp/tmp%ds)
705 tmp%poly_v(1:3) = 2.0_dp*tmp%s/sqrt(tmp%ds)/dt
706 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
707 core_particle_set, shell_particle_set, nparticle_kind, &
710 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
713 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
714 core_particle_set, para_env, shell_adiabatic, vel=.true.)
728 TYPE(md_environment_type),
POINTER :: md_env
729 TYPE(global_environment_type),
POINTER :: globenv
731 INTEGER :: ivar, nparticle, nparticle_kind, nshell
732 INTEGER,
POINTER :: itimes
733 LOGICAL :: shell_adiabatic, shell_check_distance, &
736 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
737 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
738 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
739 TYPE(cell_type),
POINTER :: cell
740 TYPE(cp_subsys_type),
POINTER :: subsys
741 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
742 TYPE(force_env_type),
POINTER :: force_env
743 TYPE(global_constraint_type),
POINTER :: gci
744 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
745 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
746 TYPE(molecule_list_type),
POINTER :: molecules
747 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
748 TYPE(mp_para_env_type),
POINTER :: para_env
749 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
751 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
753 TYPE(simpar_type),
POINTER :: simpar
754 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_fast, &
755 thermostat_shell, thermostat_slow
756 TYPE(tmp_variables_type),
POINTER :: tmp
757 TYPE(virial_type),
POINTER :: virial
759 NULLIFY (gci, force_env, thermostat_coeff, tmp, &
760 thermostat_fast, thermostat_slow, thermostat_shell, cell, shell_particles, &
761 shell_particle_set, core_particles, core_particle_set, rand)
762 NULLIFY (para_env, subsys, local_molecules, local_particles, molecule_kinds, &
763 molecules, molecule_kind_set, molecule_set, atomic_kinds, particles)
764 NULLIFY (simpar, itimes)
766 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
767 thermostat_fast=thermostat_fast, thermostat_slow=thermostat_slow, &
768 thermostat_coeff=thermostat_coeff, thermostat_shell=thermostat_shell, &
769 para_env=para_env, itimes=itimes)
772 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
775 CALL apply_qmmm_walls_reflective(force_env)
777 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
778 particles=particles, local_molecules=local_molecules, molecules=molecules, &
779 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
781 nparticle_kind = atomic_kinds%n_els
782 atomic_kind_set => atomic_kinds%els
783 molecule_kind_set => molecule_kinds%els
785 nparticle = particles%n_els
786 particle_set => particles%els
787 molecule_set => molecules%els
789 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
790 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
791 shell_check_distance=shell_check_distance)
793 IF (
ASSOCIATED(force_env%meta_env))
THEN
795 IF (force_env%meta_env%langevin)
THEN
796 ALLOCATE (rand(force_env%meta_env%n_colvar))
802 IF (shell_present)
THEN
803 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
804 core_particles=core_particles)
805 shell_particle_set => shell_particles%els
806 nshell =
SIZE(shell_particles%els)
808 IF (shell_adiabatic)
THEN
809 core_particle_set => core_particles%els
813 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
816 IF (shell_adiabatic)
THEN
821 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
822 local_particles, para_env, shell_particle_set=shell_particle_set, &
823 core_particle_set=core_particle_set)
825 CALL apply_thermostat_particles(thermostat_fast, force_env, molecule_kind_set, molecule_set, &
826 particle_set, local_molecules, local_particles, para_env)
828 CALL apply_thermostat_particles(thermostat_slow, force_env, molecule_kind_set, molecule_set, &
829 particle_set, local_molecules, local_particles, para_env)
832 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
833 molecule_kind_set, particle_set, cell)
836 IF (
ASSOCIATED(force_env%meta_env))
THEN
837 IF (force_env%meta_env%langevin)
THEN
838 DO ivar = 1, force_env%meta_env%n_colvar
839 rand(ivar) = force_env%meta_env%rng(ivar)%next()
841 CALL metadyn_velocities_colvar(force_env, rand)
846 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
847 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
849 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
850 local_particles, particle_set, core_particle_set, shell_particle_set, &
851 nparticle_kind, shell_adiabatic)
853 IF (simpar%constraint)
THEN
855 CALL shake_update_targets(gci, local_molecules, molecule_set, &
856 molecule_kind_set, dt, force_env%root_section)
858 CALL shake_control(gci, local_molecules, molecule_set, &
859 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
860 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
861 cell, para_env, local_particles)
865 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
866 core_particle_set, para_env, shell_adiabatic, pos=.true.)
868 IF (shell_adiabatic .AND. shell_check_distance)
THEN
869 CALL optimize_shell_core(force_env, particle_set, &
870 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
874 CALL force_env_calc_energy_force(force_env)
877 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
880 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
881 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
883 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
884 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
885 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
886 cell, para_env, local_particles)
889 IF (shell_adiabatic)
THEN
894 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
895 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
896 core_vel=tmp%core_vel)
898 CALL apply_thermostat_particles(thermostat_slow, force_env, molecule_kind_set, molecule_set, &
899 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
901 CALL apply_thermostat_particles(thermostat_fast, force_env, molecule_kind_set, molecule_set, &
902 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
906 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
907 core_particle_set, para_env, shell_adiabatic, vel=.true.)
909 IF (
ASSOCIATED(force_env%meta_env))
THEN
910 IF (force_env%meta_env%langevin)
THEN
916 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
917 molecule_set, molecule_kind_set, particle_set, virial, para_env)
920 CALL virial_evaluate(atomic_kind_set, particle_set, &
921 local_particles, virial, para_env)
934 SUBROUTINE nvt(md_env, globenv)
936 TYPE(md_environment_type),
POINTER :: md_env
937 TYPE(global_environment_type),
POINTER :: globenv
939 INTEGER :: ivar, nparticle, nparticle_kind, nshell
940 INTEGER,
POINTER :: itimes
941 LOGICAL :: shell_adiabatic, shell_check_distance, &
944 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
945 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
946 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
947 TYPE(cell_type),
POINTER :: cell
948 TYPE(cp_subsys_type),
POINTER :: subsys
949 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
950 TYPE(force_env_type),
POINTER :: force_env
951 TYPE(global_constraint_type),
POINTER :: gci
952 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
953 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
954 TYPE(molecule_list_type),
POINTER :: molecules
955 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
956 TYPE(mp_para_env_type),
POINTER :: para_env
957 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
959 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
961 TYPE(simpar_type),
POINTER :: simpar
962 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_part, &
964 TYPE(tmp_variables_type),
POINTER :: tmp
965 TYPE(virial_type),
POINTER :: virial
967 NULLIFY (gci, force_env, thermostat_coeff, tmp, &
968 thermostat_part, thermostat_shell, cell, shell_particles, &
969 shell_particle_set, core_particles, core_particle_set, rand)
970 NULLIFY (para_env, subsys, local_molecules, local_particles, molecule_kinds, &
971 molecules, molecule_kind_set, molecule_set, atomic_kinds, particles)
972 NULLIFY (simpar, thermostat_coeff, thermostat_part, thermostat_shell, itimes)
974 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
975 thermostat_part=thermostat_part, thermostat_coeff=thermostat_coeff, &
976 thermostat_shell=thermostat_shell, para_env=para_env, &
980 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
983 CALL apply_qmmm_walls_reflective(force_env)
985 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
986 particles=particles, local_molecules=local_molecules, molecules=molecules, &
987 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
989 nparticle_kind = atomic_kinds%n_els
990 atomic_kind_set => atomic_kinds%els
991 molecule_kind_set => molecule_kinds%els
993 nparticle = particles%n_els
994 particle_set => particles%els
995 molecule_set => molecules%els
997 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
998 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
999 shell_check_distance=shell_check_distance)
1001 IF (
ASSOCIATED(force_env%meta_env))
THEN
1003 IF (force_env%meta_env%langevin)
THEN
1004 ALLOCATE (rand(force_env%meta_env%n_colvar))
1010 IF (shell_present)
THEN
1011 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
1012 core_particles=core_particles)
1013 shell_particle_set => shell_particles%els
1014 nshell =
SIZE(shell_particles%els)
1016 IF (shell_adiabatic)
THEN
1017 core_particle_set => core_particles%els
1021 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1024 IF (shell_adiabatic)
THEN
1025 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1026 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1027 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
1029 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1030 local_particles, para_env, shell_particle_set=shell_particle_set, &
1031 core_particle_set=core_particle_set)
1033 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1034 particle_set, local_molecules, local_particles, para_env)
1037 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
1038 molecule_kind_set, particle_set, cell)
1041 IF (
ASSOCIATED(force_env%meta_env))
THEN
1042 IF (force_env%meta_env%langevin)
THEN
1043 DO ivar = 1, force_env%meta_env%n_colvar
1044 rand(ivar) = force_env%meta_env%rng(ivar)%next()
1046 CALL metadyn_velocities_colvar(force_env, rand)
1051 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1052 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
1054 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
1055 local_particles, particle_set, core_particle_set, shell_particle_set, &
1056 nparticle_kind, shell_adiabatic)
1058 IF (simpar%constraint)
THEN
1060 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1061 molecule_kind_set, dt, force_env%root_section)
1063 CALL shake_control(gci, local_molecules, molecule_set, &
1064 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
1065 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
1066 cell, para_env, local_particles)
1070 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1071 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1073 IF (shell_adiabatic .AND. shell_check_distance)
THEN
1074 CALL optimize_shell_core(force_env, particle_set, &
1075 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
1079 CALL qmmmx_update_force_env(force_env, force_env%root_section)
1084 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
1086 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1087 particles=particles, local_molecules=local_molecules, molecules=molecules, &
1088 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
1090 nparticle_kind = atomic_kinds%n_els
1091 atomic_kind_set => atomic_kinds%els
1092 molecule_kind_set => molecule_kinds%els
1094 nparticle = particles%n_els
1095 particle_set => particles%els
1096 molecule_set => molecules%els
1098 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1099 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
1100 shell_check_distance=shell_check_distance)
1103 IF (shell_present)
THEN
1104 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
1105 core_particles=core_particles)
1106 shell_particle_set => shell_particles%els
1107 nshell =
SIZE(shell_particles%els)
1109 IF (shell_adiabatic)
THEN
1110 core_particle_set => core_particles%els
1117 CALL force_env_calc_energy_force(force_env, require_consistent_energy_force=.false.)
1120 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
1123 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1124 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
1126 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
1127 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
1128 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
1129 cell, para_env, local_particles)
1132 IF (shell_adiabatic)
THEN
1133 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1134 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1135 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
1137 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1138 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
1139 core_vel=tmp%core_vel)
1141 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1142 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
1146 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1147 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1149 IF (
ASSOCIATED(force_env%meta_env))
THEN
1150 IF (force_env%meta_env%langevin)
THEN
1156 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1157 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1160 CALL virial_evaluate(atomic_kind_set, particle_set, &
1161 local_particles, virial, para_env)
1176 TYPE(md_environment_type),
POINTER :: md_env
1177 TYPE(global_environment_type),
POINTER :: globenv
1179 REAL(kind=dp),
PARAMETER :: e2 = 1.0_dp/6.0_dp, e4 = e2/20.0_dp, &
1180 e6 = e4/42.0_dp, e8 = e6/72.0_dp
1182 INTEGER :: iroll, ivar, nkind, nparticle, &
1183 nparticle_kind, nshell
1184 INTEGER,
POINTER :: itimes
1185 LOGICAL :: first, first_time, shell_adiabatic, &
1186 shell_check_distance, shell_present
1187 REAL(kind=dp) :: dt, infree, kin, roll_tol, roll_tol_thrs
1188 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
1189 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
1190 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
1191 REAL(kind=dp),
SAVE :: eps_0
1192 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1193 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1194 TYPE(cell_type),
POINTER :: cell
1195 TYPE(cp_subsys_type),
POINTER :: subsys
1196 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
1197 TYPE(force_env_type),
POINTER :: force_env
1198 TYPE(global_constraint_type),
POINTER :: gci
1199 TYPE(local_fixd_constraint_type),
DIMENSION(:), &
1200 POINTER :: lfixd_list
1201 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
1202 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
1203 TYPE(molecule_list_type),
POINTER :: molecules
1204 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1205 TYPE(mp_para_env_type),
POINTER :: para_env
1206 TYPE(npt_info_type),
POINTER :: npt(:, :)
1207 TYPE(old_variables_type),
POINTER :: old
1208 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1210 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
1212 TYPE(simpar_type),
POINTER :: simpar
1213 TYPE(thermostat_type),
POINTER :: thermostat_baro, thermostat_part, &
1215 TYPE(tmp_variables_type),
POINTER :: tmp
1216 TYPE(virial_type),
POINTER :: virial
1218 NULLIFY (gci, thermostat_baro, thermostat_part, thermostat_shell, force_env)
1219 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
1220 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
1221 NULLIFY (core_particles, particles, shell_particles, tmp, old)
1222 NULLIFY (core_particle_set, particle_set, shell_particle_set)
1223 NULLIFY (simpar, virial, rand, itimes, lfixd_list)
1225 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
1226 thermostat_part=thermostat_part, thermostat_baro=thermostat_baro, &
1227 thermostat_shell=thermostat_shell, npt=npt, first_time=first_time, &
1228 para_env=para_env, itimes=itimes)
1230 infree = 1.0_dp/real(simpar%nfree, kind=dp)
1232 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
1235 CALL apply_qmmm_walls_reflective(force_env)
1237 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1238 particles=particles, local_molecules=local_molecules, molecules=molecules, &
1239 gci=gci, molecule_kinds=molecule_kinds, virial=virial)
1241 nparticle_kind = atomic_kinds%n_els
1242 nkind = molecule_kinds%n_els
1243 atomic_kind_set => atomic_kinds%els
1244 molecule_kind_set => molecule_kinds%els
1246 nparticle = particles%n_els
1247 particle_set => particles%els
1248 molecule_set => molecules%els
1250 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1251 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
1252 shell_check_distance=shell_check_distance)
1254 IF (first_time)
THEN
1255 CALL virial_evaluate(atomic_kind_set, particle_set, &
1256 local_particles, virial, para_env)
1260 CALL allocate_old(old, particle_set, npt)
1262 IF (
ASSOCIATED(force_env%meta_env))
THEN
1264 IF (force_env%meta_env%langevin)
THEN
1265 ALLOCATE (rand(force_env%meta_env%n_colvar))
1270 IF (shell_present)
THEN
1271 CALL cp_subsys_get(subsys=subsys, &
1272 shell_particles=shell_particles, core_particles=core_particles)
1273 shell_particle_set => shell_particles%els
1274 nshell =
SIZE(shell_particles%els)
1275 IF (shell_adiabatic)
THEN
1276 core_particle_set => core_particles%els
1280 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1283 IF (first_time) eps_0 = npt(1, 1)%eps
1286 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
1289 IF (simpar%ensemble /= npe_i_ensemble)
THEN
1290 IF (shell_adiabatic)
THEN
1291 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1292 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1293 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
1296 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1297 particle_set, local_molecules, local_particles, para_env)
1302 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1303 local_particles, para_env, shell_particle_set=shell_particle_set, &
1304 core_particle_set=core_particle_set)
1306 IF (simpar%constraint)
THEN
1308 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1309 molecule_kind_set, dt, force_env%root_section)
1313 IF (simpar%constraint)
THEN
1314 roll_tol_thrs = simpar%roll_tol
1316 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
1317 CALL getold(gci, local_molecules, molecule_set, &
1318 molecule_kind_set, particle_set, cell)
1320 roll_tol_thrs = epsilon(0.0_dp)
1322 roll_tol = -roll_tol_thrs
1325 IF (
ASSOCIATED(force_env%meta_env))
THEN
1326 IF (force_env%meta_env%langevin)
THEN
1327 DO ivar = 1, force_env%meta_env%n_colvar
1328 rand(ivar) = force_env%meta_env%rng(ivar)%next()
1330 CALL metadyn_velocities_colvar(force_env, rand)
1334 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1336 IF (simpar%constraint)
THEN
1337 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
1340 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
1341 local_molecules, molecule_set, molecule_kind_set, &
1342 local_particles, kin, pv_kin, virial, para_env)
1343 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1345 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
1346 (0.5_dp*npt(1, 1)%v*dt)
1347 tmp%poly_r(1:3) = 1.0_dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
1348 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
1350 tmp%arg_v(1) = (0.25_dp*npt(1, 1)%v*dt* &
1351 (1.0_dp + 3.0_dp*infree))*(0.25_dp*npt(1, 1)%v* &
1352 dt*(1.0_dp + 3.0_dp*infree))
1353 tmp%poly_v(1:3) = 1.0_dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
1354 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
1356 tmp%scale_r(1:3) = exp(0.5_dp*dt*npt(1, 1)%v)
1357 tmp%scale_v(1:3) = exp(-0.25_dp*dt*npt(1, 1)%v* &
1358 (1.0_dp + 3.0_dp*infree))
1361 IF (simpar%ensemble == npt_ia_ensemble)
THEN
1362 CALL create_local_fixd_list(lfixd_list, nkind, molecule_kind_set, local_particles)
1363 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1364 core_particle_set, shell_particle_set, nparticle_kind, &
1365 shell_adiabatic, dt, lfixd_list=lfixd_list)
1366 CALL release_local_fixd_list(lfixd_list)
1368 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1369 core_particle_set, shell_particle_set, nparticle_kind, &
1370 shell_adiabatic, dt)
1373 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
1374 atomic_kind_set, local_particles, particle_set, core_particle_set, &
1375 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
1378 vector_r(:) = tmp%scale_r(:)*tmp%poly_r(:)
1379 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
1381 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
1382 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
1383 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
1384 local_particles=local_particles)
1388 npt(:, :)%eps = npt(:, :)%eps + dt*npt(:, :)%v
1391 cell%hmat(:, :) = cell%hmat(:, :)*exp(npt(1, 1)%eps - eps_0)
1393 eps_0 = npt(1, 1)%eps
1396 CALL init_cell(cell)
1399 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1400 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1402 IF (shell_adiabatic .AND. shell_check_distance)
THEN
1403 CALL optimize_shell_core(force_env, particle_set, &
1404 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
1408 CALL force_env_calc_energy_force(force_env)
1411 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
1414 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1415 core_particle_set, shell_particle_set, nparticle_kind, &
1416 shell_adiabatic, dt)
1418 IF (simpar%constraint)
THEN
1419 roll_tol_thrs = simpar%roll_tol
1422 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
1424 roll_tol_thrs = epsilon(0.0_dp)
1426 roll_tol = -roll_tol_thrs
1428 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1430 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
1431 particle_set, local_particles, molecule_kind_set, molecule_set, &
1432 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
1433 roll_tol, iroll, infree, first, para_env)
1435 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
1436 local_molecules, molecule_set, molecule_kind_set, &
1437 local_particles, kin, pv_kin, virial, para_env)
1438 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1442 IF (simpar%ensemble /= npe_i_ensemble)
THEN
1443 IF (shell_adiabatic)
THEN
1444 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1445 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1446 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
1448 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1449 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
1454 IF (
ASSOCIATED(thermostat_shell))
THEN
1455 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1456 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
1457 core_vel=tmp%core_vel)
1461 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
1464 IF (simpar%ensemble == npe_i_ensemble .AND. simpar%annealing)
THEN
1465 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
1466 IF (shell_adiabatic)
THEN
1467 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
1468 tmp%vel, tmp%shell_vel, tmp%core_vel)
1472 IF (simpar%ensemble == npe_i_ensemble .AND. simpar%annealing_cell)
THEN
1473 npt(1, 1)%v = npt(1, 1)%v*simpar%f_annealing_cell
1477 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1478 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1481 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1482 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1484 CALL virial_evaluate(atomic_kind_set, particle_set, &
1485 local_particles, virial, para_env)
1488 CALL deallocate_old(old)
1490 IF (
ASSOCIATED(force_env%meta_env))
THEN
1491 IF (force_env%meta_env%langevin)
THEN
1496 IF (first_time)
THEN
1497 first_time = .false.
1498 CALL set_md_env(md_env, first_time=first_time)
1501 END SUBROUTINE npt_i
1513 TYPE(md_environment_type),
POINTER :: md_env
1515 CHARACTER(LEN=2) :: element_kind_ref0, element_symbol, &
1517 CHARACTER(LEN=max_line_length) :: errmsg
1518 INTEGER :: cell_itimes, i, nparticle, nread, &
1520 INTEGER,
POINTER :: itimes
1521 LOGICAL :: init, my_end, traj_has_cell_info
1522 REAL(kind=dp) :: cell_time, h(3, 3), trj_epot, trj_time, &
1524 REAL(kind=dp),
POINTER :: time
1525 TYPE(cell_type),
POINTER :: cell
1526 TYPE(cp_logger_type),
POINTER :: logger
1527 TYPE(cp_subsys_type),
POINTER :: subsys
1528 TYPE(force_env_type),
POINTER :: force_env
1529 TYPE(mp_para_env_type),
POINTER :: para_env
1530 TYPE(particle_list_type),
POINTER :: particles
1531 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1532 TYPE(reftraj_type),
POINTER :: reftraj_env
1533 TYPE(simpar_type),
POINTER :: simpar
1535 NULLIFY (reftraj_env, particle_set, particles, force_env, subsys, simpar, para_env, cell, logger, itimes, time)
1536 CALL get_md_env(md_env=md_env, init=init,
reftraj=reftraj_env, force_env=force_env, &
1537 para_env=para_env, simpar=simpar)
1538 logger => cp_get_default_logger()
1540 CALL force_env_get(force_env=force_env, cell=cell, subsys=subsys)
1541 reftraj_env%isnap = reftraj_env%isnap + reftraj_env%info%stride
1544 CALL apply_qmmm_walls_reflective(force_env)
1545 CALL cp_subsys_get(subsys=subsys, particles=particles)
1546 nparticle = particles%n_els
1547 particle_set => particles%els
1551 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1552 READ (reftraj_env%info%traj_parser%input_line, fmt=
"(I8)") nread
1553 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1556 CALL read_xyz_comment(reftraj_env%info%traj_parser%input_line, cell, &
1557 traj_has_cell_info, trj_itimes, trj_time, trj_epot)
1558 IF (trj_itimes == huge(0))
THEN
1559 CALL get_md_env(md_env, itimes=itimes)
1562 IF (trj_time == huge(0.0_dp)) trj_time = 0.0_dp
1563 IF (trj_epot == huge(0.0_dp)) trj_epot = 0.0_dp
1599 IF (nread /= nparticle)
THEN
1600 errmsg =
"Number of atoms for step "//trim(adjustl(cp_to_string(trj_itimes)))// &
1601 " in the trajectory file does not match the reference configuration: "// &
1602 trim(adjustl(cp_to_string(nread)))//
" != "//trim(adjustl(cp_to_string(nparticle)))
1606 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1607 READ (unit=reftraj_env%info%traj_parser%input_line(1:len_trim(reftraj_env%info%traj_parser%input_line)), fmt=*) &
1608 element_symbol, particle_set(i)%r
1609 CALL uppercase(element_symbol)
1610 element_symbol_ref0 = particle_set(i)%atomic_kind%element_symbol
1611 element_kind_ref0 = particle_set(i)%atomic_kind%name(1:2)
1612 CALL uppercase(element_symbol_ref0)
1613 CALL uppercase(element_kind_ref0)
1614 IF (element_symbol /= element_symbol_ref0)
THEN
1616 IF (element_symbol /= element_kind_ref0)
THEN
1617 errmsg =
"Atomic configuration from trajectory file does not match the reference configuration: "// &
1618 "Check atom "//trim(adjustl(cp_to_string(i)))//
" of step "// &
1619 trim(adjustl(cp_to_string(trj_itimes)))//
". Found trajectory label '"// &
1620 trim(element_symbol)//
"', expected element '"//trim(element_symbol_ref0)// &
1621 "' or kind label '"//trim(element_kind_ref0)// &
1622 "'. REFTRAJ trajectories usually contain element labels; check whether the "// &
1623 "trajectory was modified to contain kind aliases instead."
1627 particle_set(i)%r(1) = cp_unit_to_cp2k(particle_set(i)%r(1),
"angstrom")
1628 particle_set(i)%r(2) = cp_unit_to_cp2k(particle_set(i)%r(2),
"angstrom")
1629 particle_set(i)%r(3) = cp_unit_to_cp2k(particle_set(i)%r(3),
"angstrom")
1634 CALL parser_read_line(reftraj_env%info%traj_parser, 1, at_end=my_end)
1635 READ (unit=reftraj_env%info%traj_parser%input_line, fmt=*) element_symbol, particle_set(i)%r
1636 CALL uppercase(element_symbol)
1637 element_symbol_ref0 = particle_set(i)%atomic_kind%element_symbol
1638 element_kind_ref0 = particle_set(i)%atomic_kind%name(1:2)
1639 CALL uppercase(element_symbol_ref0)
1640 CALL uppercase(element_kind_ref0)
1641 IF (element_symbol /= element_symbol_ref0)
THEN
1643 IF (element_symbol /= element_kind_ref0)
THEN
1644 errmsg =
"Atomic configuration from trajectory file does not match the reference configuration: "// &
1645 "Check atom "//trim(adjustl(cp_to_string(i)))//
" of step "// &
1646 trim(adjustl(cp_to_string(trj_itimes)))//
". Found trajectory label '"// &
1647 trim(element_symbol)//
"', expected element '"//trim(element_symbol_ref0)// &
1648 "' or kind label '"//trim(element_kind_ref0)// &
1649 "'. REFTRAJ trajectories usually contain element labels; check whether the "// &
1650 "trajectory was modified to contain kind aliases instead."
1654 particle_set(i)%r(1) = cp_unit_to_cp2k(particle_set(i)%r(1),
"angstrom")
1655 particle_set(i)%r(2) = cp_unit_to_cp2k(particle_set(i)%r(2),
"angstrom")
1656 particle_set(i)%r(3) = cp_unit_to_cp2k(particle_set(i)%r(3),
"angstrom")
1660 IF (reftraj_env%isnap /= (simpar%nsteps - 1))
THEN
1661 CALL cp_abort(__location__, &
1662 "Reached the end of the Trajectory frames in the TRAJECTORY file. Number of "// &
1663 "missing frames ("//cp_to_string((simpar%nsteps - 1) - reftraj_env%isnap)//
").")
1668 IF (reftraj_env%info%variable_volume .AND. (.NOT. traj_has_cell_info))
THEN
1669 CALL parser_get_next_line(reftraj_env%info%cell_parser, 1, at_end=my_end)
1670 CALL parse_cell_line(reftraj_env%info%cell_parser%input_line, cell_itimes, cell_time, h, vol)
1671 cpassert(trj_itimes == cell_itimes)
1674 IF (reftraj_env%isnap /= (simpar%nsteps - 1))
THEN
1675 CALL cp_abort(__location__, &
1676 "Reached the end of the cell info frames in the CELL file. Number of "// &
1677 "missing frames ("//cp_to_string((simpar%nsteps - 1) - reftraj_env%isnap)//
").")
1683 reftraj_env%time0 = trj_time
1684 reftraj_env%epot0 = trj_epot
1685 reftraj_env%itimes0 = trj_itimes
1688 IF (trj_itimes /= 0.0_dp .AND. trj_time /= 0.0_dp) simpar%dt = (trj_time/femtoseconds)/real(trj_itimes, kind=dp)
1690 reftraj_env%epot = trj_epot
1691 reftraj_env%itimes = trj_itimes
1692 reftraj_env%time = trj_time/femtoseconds
1693 CALL get_md_env(md_env, itimes=itimes, t=time)
1694 itimes = reftraj_env%itimes
1695 time = reftraj_env%time
1696 CALL cp_iterate(logger%iter_info, &
1697 last=logger%iter_info%last_iter(logger%iter_info%n_rlevel), &
1698 iter_nr=reftraj_env%itimes)
1700 IF (traj_has_cell_info)
THEN
1701 CALL init_cell(cell)
1702 ELSE IF (reftraj_env%info%variable_volume)
THEN
1704 CALL init_cell(cell)
1708 SELECT CASE (reftraj_env%info%wrap)
1709 CASE (reftraj_wrap_none)
1711 CASE (reftraj_wrap_positive)
1714 particle_set(i)%r(1:3) = pbc(particle_set(i)%r(1:3), cell, positive_range=.true.)
1716 CASE (reftraj_wrap_central)
1719 particle_set(i)%r(1:3) = pbc(particle_set(i)%r(1:3), cell)
1723 cpabort(
"Option invalid or unavailable for reftraj_env%info%wrap")
1727 CALL qmmmx_update_force_env(force_env, force_env%root_section)
1733 CALL force_env_calc_energy_force(force_env, &
1734 calc_force=(reftraj_env%info%eval == reftraj_eval_energy_forces), &
1735 eval_energy_forces=(reftraj_env%info%eval /= reftraj_eval_none), &
1736 require_consistent_energy_force=.false.)
1739 CALL metadyn_integrator(force_env, trj_itimes)
1742 IF (reftraj_env%info%msd)
THEN
1743 CALL compute_msd_reftraj(reftraj_env, md_env, particle_set)
1747 CALL parser_get_next_line(reftraj_env%info%traj_parser, (reftraj_env%info%stride - 1)*(nparticle + 2))
1748 IF (reftraj_env%info%variable_volume)
THEN
1749 CALL parser_get_next_line(reftraj_env%info%cell_parser, (reftraj_env%info%stride - 1))
1766 TYPE(md_environment_type),
POINTER :: md_env
1768 REAL(dp),
PARAMETER :: e2 = 1._dp/6._dp, e4 = e2/20._dp, &
1769 e6 = e4/42._dp, e8 = e6/72._dp
1771 INTEGER :: iroll, nparticle, nparticle_kind, nshell
1772 INTEGER,
POINTER :: itimes
1773 LOGICAL :: first, first_time, shell_adiabatic, &
1775 REAL(kind=dp) :: dt, infree, kin, roll_tol, roll_tol_thrs
1776 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
1777 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
1778 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1779 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1780 TYPE(cell_type),
POINTER :: cell
1781 TYPE(cp_subsys_type),
POINTER :: subsys
1782 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
1783 TYPE(force_env_type),
POINTER :: force_env
1784 TYPE(global_constraint_type),
POINTER :: gci
1785 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
1786 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
1787 TYPE(molecule_list_type),
POINTER :: molecules
1788 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1789 TYPE(mp_para_env_type),
POINTER :: para_env
1790 TYPE(npt_info_type),
POINTER :: npt(:, :)
1791 TYPE(old_variables_type),
POINTER :: old
1792 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1794 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
1796 TYPE(simpar_type),
POINTER :: simpar
1797 TYPE(tmp_variables_type),
POINTER :: tmp
1798 TYPE(virial_type),
POINTER :: virial
1800 NULLIFY (gci, force_env)
1801 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
1802 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
1803 NULLIFY (core_particles, particles, shell_particles, tmp, old)
1804 NULLIFY (core_particle_set, particle_set, shell_particle_set)
1805 NULLIFY (simpar, virial, itimes)
1807 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, npt=npt, &
1808 first_time=first_time, para_env=para_env, itimes=itimes)
1810 infree = 1.0_dp/real(simpar%nfree, dp)
1812 CALL force_env_get(force_env, subsys=subsys, cell=cell)
1815 CALL apply_qmmm_walls_reflective(force_env)
1817 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1818 particles=particles, local_molecules=local_molecules, molecules=molecules, gci=gci, &
1819 molecule_kinds=molecule_kinds, virial=virial)
1821 nparticle_kind = atomic_kinds%n_els
1822 atomic_kind_set => atomic_kinds%els
1823 molecule_kind_set => molecule_kinds%els
1825 nparticle = particles%n_els
1826 particle_set => particles%els
1827 molecule_set => molecules%els
1829 IF (first_time)
THEN
1830 CALL virial_evaluate(atomic_kind_set, particle_set, &
1831 local_particles, virial, para_env)
1834 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1835 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
1838 CALL allocate_old(old, particle_set, npt)
1840 IF (shell_present)
THEN
1841 CALL cp_subsys_get(subsys=subsys, &
1842 shell_particles=shell_particles, core_particles=core_particles)
1843 shell_particle_set => shell_particles%els
1844 nshell =
SIZE(shell_particles%els)
1845 IF (shell_adiabatic)
THEN
1846 core_particle_set => core_particles%els
1850 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1852 IF (simpar%constraint)
THEN
1854 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1855 molecule_kind_set, dt, force_env%root_section)
1859 IF (simpar%constraint)
THEN
1860 roll_tol_thrs = simpar%roll_tol
1862 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
1863 CALL getold(gci, local_molecules, molecule_set, &
1864 molecule_kind_set, particle_set, cell)
1866 roll_tol_thrs = epsilon(0.0_dp)
1868 roll_tol = -roll_tol_thrs
1870 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1872 IF (simpar%constraint)
THEN
1873 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
1875 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
1876 local_molecules, molecule_set, molecule_kind_set, &
1877 local_particles, kin, pv_kin, virial, para_env)
1878 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1880 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
1881 (0.5_dp*npt(1, 1)%v*dt)
1882 tmp%poly_r(1) = 1._dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
1883 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
1884 tmp%poly_r(2) = 1.0_dp
1885 tmp%poly_r(3) = 1.0_dp
1887 tmp%arg_v(1) = (0.25_dp*npt(1, 1)%v*dt* &
1888 (1._dp + infree))*(0.25_dp*npt(1, 1)%v* &
1889 dt*(1._dp + infree))
1890 tmp%arg_v(2) = (0.25_dp*npt(1, 1)%v*dt*infree)* &
1891 (0.25_dp*npt(1, 1)%v*dt*infree)
1892 tmp%poly_v(1) = 1._dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
1893 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
1894 tmp%poly_v(2) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
1895 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
1896 tmp%poly_v(3) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
1897 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
1899 tmp%scale_r(1) = exp(0.5_dp*dt*npt(1, 1)%v)
1900 tmp%scale_r(2) = 1.0_dp
1901 tmp%scale_r(3) = 1.0_dp
1903 tmp%scale_v(1) = exp(-0.25_dp*dt*npt(1, 1)%v* &
1905 tmp%scale_v(2) = exp(-0.25_dp*dt*npt(1, 1)%v*infree)
1906 tmp%scale_v(3) = exp(-0.25_dp*dt*npt(1, 1)%v*infree)
1909 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1910 core_particle_set, shell_particle_set, nparticle_kind, &
1911 shell_adiabatic, dt)
1913 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
1914 atomic_kind_set, local_particles, particle_set, core_particle_set, &
1915 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
1919 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
1920 vector_r(1) = tmp%scale_r(1)*tmp%poly_r(1)
1922 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
1923 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
1924 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
1925 local_particles=local_particles)
1929 cell%hmat(1, 1) = cell%hmat(1, 1)*tmp%scale_r(1)*tmp%scale_r(1)
1932 CALL init_cell(cell)
1935 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1936 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1939 CALL force_env_calc_energy_force(force_env)
1942 CALL metadyn_integrator(force_env, itimes, tmp%vel)
1945 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1946 core_particle_set, shell_particle_set, nparticle_kind, &
1947 shell_adiabatic, dt)
1949 IF (simpar%constraint)
THEN
1950 roll_tol_thrs = simpar%roll_tol
1953 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
1955 roll_tol_thrs = epsilon(0.0_dp)
1957 roll_tol = -roll_tol_thrs
1959 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1961 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
1962 particle_set, local_particles, molecule_kind_set, molecule_set, &
1963 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
1964 roll_tol, iroll, infree, first, para_env)
1966 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
1967 local_molecules, molecule_set, molecule_kind_set, &
1968 local_particles, kin, pv_kin, virial, para_env)
1969 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1972 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
1975 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1976 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1979 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1980 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1982 CALL virial_evaluate(atomic_kind_set, particle_set, &
1983 local_particles, virial, para_env)
1986 CALL deallocate_old(old)
1988 IF (first_time)
THEN
1989 first_time = .false.
1990 CALL set_md_env(md_env, first_time=first_time)
2009 TYPE(md_environment_type),
POINTER :: md_env
2011 REAL(dp),
PARAMETER :: e2 = 1._dp/6._dp, e4 = e2/20._dp, &
2012 e6 = e4/42._dp, e8 = e6/72._dp
2014 INTEGER :: iroll, nparticle, nparticle_kind, nshell
2015 INTEGER,
POINTER :: itimes
2016 LOGICAL :: first, first_time, shell_adiabatic, &
2018 REAL(kind=dp) :: aa, aax, dt, gamma1, infree, kin, &
2019 roll_tol, roll_tol_thrs
2020 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
2021 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
2022 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2023 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2024 TYPE(cell_type),
POINTER :: cell
2025 TYPE(cp_subsys_type),
POINTER :: subsys
2026 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2027 TYPE(force_env_type),
POINTER :: force_env
2028 TYPE(global_constraint_type),
POINTER :: gci
2029 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2030 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2031 TYPE(molecule_list_type),
POINTER :: molecules
2032 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2033 TYPE(mp_para_env_type),
POINTER :: para_env
2034 TYPE(npt_info_type),
POINTER :: npt(:, :)
2035 TYPE(old_variables_type),
POINTER :: old
2036 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
2038 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
2040 TYPE(simpar_type),
POINTER :: simpar
2041 TYPE(tmp_variables_type),
POINTER :: tmp
2042 TYPE(virial_type),
POINTER :: virial
2044 NULLIFY (gci, force_env)
2045 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
2046 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
2047 NULLIFY (core_particles, particles, shell_particles, tmp, old)
2048 NULLIFY (core_particle_set, particle_set, shell_particle_set)
2049 NULLIFY (simpar, virial, itimes)
2051 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, npt=npt, &
2052 first_time=first_time, para_env=para_env, itimes=itimes)
2054 infree = 1.0_dp/real(simpar%nfree, dp)
2055 gamma1 = simpar%gamma_nph
2057 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2059 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2060 particles=particles, local_molecules=local_molecules, molecules=molecules, gci=gci, &
2061 molecule_kinds=molecule_kinds, virial=virial)
2063 nparticle_kind = atomic_kinds%n_els
2064 atomic_kind_set => atomic_kinds%els
2065 molecule_kind_set => molecule_kinds%els
2067 nparticle = particles%n_els
2068 particle_set => particles%els
2069 molecule_set => molecules%els
2071 IF (first_time)
THEN
2072 CALL virial_evaluate(atomic_kind_set, particle_set, &
2073 local_particles, virial, para_env)
2076 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
2077 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
2080 CALL allocate_old(old, particle_set, npt)
2082 IF (shell_present)
THEN
2083 CALL cp_subsys_get(subsys=subsys, &
2084 shell_particles=shell_particles, core_particles=core_particles)
2085 shell_particle_set => shell_particles%els
2086 nshell =
SIZE(shell_particles%els)
2087 IF (shell_adiabatic)
THEN
2088 core_particle_set => core_particles%els
2092 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
2095 CALL damp_v(molecule_kind_set, molecule_set, particle_set, local_molecules, &
2096 gamma1, npt(1, 1), dt, para_env)
2098 IF (simpar%constraint)
THEN
2100 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2101 molecule_kind_set, dt, force_env%root_section)
2105 IF (simpar%constraint)
THEN
2106 roll_tol_thrs = simpar%roll_tol
2108 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
2109 CALL getold(gci, local_molecules, molecule_set, &
2110 molecule_kind_set, particle_set, cell)
2112 roll_tol_thrs = epsilon(0.0_dp)
2114 roll_tol = -roll_tol_thrs
2116 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2119 CALL damp_veps(npt(1, 1), gamma1, dt)
2121 IF (simpar%constraint)
THEN
2122 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
2124 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
2125 local_molecules, molecule_set, molecule_kind_set, &
2126 local_particles, kin, pv_kin, virial, para_env)
2127 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
2130 CALL damp_veps(npt(1, 1), gamma1, dt)
2132 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
2133 (0.5_dp*npt(1, 1)%v*dt)
2134 tmp%poly_r(1) = 1._dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
2135 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
2137 aax = npt(1, 1)%v*(1.0_dp + infree)
2138 tmp%arg_v(1) = (0.25_dp*dt*aax)*(0.25_dp*dt*aax)
2139 tmp%poly_v(1) = 1._dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
2140 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
2142 aa = npt(1, 1)%v*infree
2143 tmp%arg_v(2) = (0.25_dp*dt*aa)*(0.25_dp*dt*aa)
2144 tmp%poly_v(2) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
2145 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
2146 tmp%poly_v(3) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
2147 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
2149 tmp%scale_r(1) = exp(0.5_dp*dt*npt(1, 1)%v)
2150 tmp%scale_v(1) = exp(-0.25_dp*dt*aax)
2151 tmp%scale_v(2) = exp(-0.25_dp*dt*aa)
2152 tmp%scale_v(3) = exp(-0.25_dp*dt*aa)
2155 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
2156 core_particle_set, shell_particle_set, nparticle_kind, &
2157 shell_adiabatic, dt)
2159 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
2160 atomic_kind_set, local_particles, particle_set, core_particle_set, &
2161 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
2165 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
2166 vector_r(1) = tmp%scale_r(1)*tmp%poly_r(1)
2168 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
2169 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
2170 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
2171 local_particles=local_particles)
2175 cell%hmat(1, 1) = cell%hmat(1, 1)*tmp%scale_r(1)*tmp%scale_r(1)
2178 CALL init_cell(cell)
2181 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2182 core_particle_set, para_env, shell_adiabatic, pos=.true.)
2185 CALL force_env_calc_energy_force(force_env)
2188 CALL metadyn_integrator(force_env, itimes, tmp%vel)
2191 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
2192 core_particle_set, shell_particle_set, nparticle_kind, &
2193 shell_adiabatic, dt)
2195 IF (simpar%constraint)
THEN
2196 roll_tol_thrs = simpar%roll_tol
2199 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
2201 roll_tol_thrs = epsilon(0.0_dp)
2203 roll_tol = -roll_tol_thrs
2205 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2207 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
2208 particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, &
2209 tmp%vel, dt, cell, npt, simpar, virial, vector_v, roll_tol, iroll, infree, first, &
2212 CALL damp_veps(npt(1, 1), gamma1, dt)
2214 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
2215 local_molecules, molecule_set, molecule_kind_set, &
2216 local_particles, kin, pv_kin, virial, para_env)
2217 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
2220 CALL damp_veps(npt(1, 1), gamma1, dt)
2225 CALL damp_v(molecule_kind_set, molecule_set, particle_set, local_molecules, &
2226 tmp%vel, gamma1, npt(1, 1), dt, para_env)
2228 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
2231 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2232 core_particle_set, para_env, shell_adiabatic, vel=.true.)
2235 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
2236 molecule_set, molecule_kind_set, particle_set, virial, para_env)
2238 CALL virial_evaluate(atomic_kind_set, particle_set, &
2239 local_particles, virial, para_env)
2242 CALL deallocate_old(old)
2244 IF (first_time)
THEN
2245 first_time = .false.
2246 CALL set_md_env(md_env, first_time=first_time)
2261 TYPE(md_environment_type),
POINTER :: md_env
2262 TYPE(global_environment_type),
POINTER :: globenv
2264 REAL(kind=dp),
PARAMETER :: e2 = 1.0_dp/6.0_dp, e4 = e2/20.0_dp, &
2265 e6 = e4/42.0_dp, e8 = e6/72.0_dp
2267 INTEGER :: i, iroll, j, nparticle, nparticle_kind, &
2269 INTEGER,
POINTER :: itimes
2270 LOGICAL :: first, first_time, shell_adiabatic, &
2271 shell_check_distance, shell_present
2272 REAL(kind=dp) :: dt, infree, kin, roll_tol, &
2274 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
2275 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin, uh
2276 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2277 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2278 TYPE(barostat_type),
POINTER :: barostat
2279 TYPE(cell_type),
POINTER :: cell
2280 TYPE(cp_subsys_type),
POINTER :: subsys
2281 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2282 TYPE(force_env_type),
POINTER :: force_env
2283 TYPE(global_constraint_type),
POINTER :: gci
2284 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2285 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2286 TYPE(molecule_list_type),
POINTER :: molecules
2287 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2288 TYPE(mp_para_env_type),
POINTER :: para_env
2289 TYPE(npt_info_type),
POINTER :: npt(:, :)
2290 TYPE(old_variables_type),
POINTER :: old
2291 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
2293 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
2295 TYPE(simpar_type),
POINTER :: simpar
2296 TYPE(thermostat_type),
POINTER :: thermostat_baro, thermostat_part, &
2298 TYPE(tmp_variables_type),
POINTER :: tmp
2299 TYPE(virial_type),
POINTER :: virial
2301 NULLIFY (gci, thermostat_baro, thermostat_part, thermostat_shell, force_env)
2302 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
2303 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt, barostat)
2304 NULLIFY (core_particles, particles, shell_particles, tmp, old)
2305 NULLIFY (core_particle_set, particle_set, shell_particle_set)
2306 NULLIFY (simpar, virial, itimes)
2308 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
2309 thermostat_part=thermostat_part, thermostat_baro=thermostat_baro, &
2310 thermostat_shell=thermostat_shell, npt=npt, first_time=first_time, &
2311 para_env=para_env, barostat=barostat, itimes=itimes)
2313 infree = 1.0_dp/real(simpar%nfree, kind=dp)
2315 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2318 CALL apply_qmmm_walls_reflective(force_env)
2320 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2321 particles=particles, local_molecules=local_molecules, molecules=molecules, &
2322 gci=gci, molecule_kinds=molecule_kinds, virial=virial)
2324 nparticle_kind = atomic_kinds%n_els
2325 atomic_kind_set => atomic_kinds%els
2326 molecule_kind_set => molecule_kinds%els
2328 nparticle = particles%n_els
2329 particle_set => particles%els
2330 molecule_set => molecules%els
2332 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
2333 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
2334 shell_check_distance=shell_check_distance)
2336 IF (first_time)
THEN
2337 CALL virial_evaluate(atomic_kind_set, particle_set, &
2338 local_particles, virial, para_env)
2342 CALL allocate_old(old, particle_set, npt)
2344 IF (shell_present)
THEN
2345 CALL cp_subsys_get(subsys=subsys, &
2346 shell_particles=shell_particles, core_particles=core_particles)
2347 shell_particle_set => shell_particles%els
2348 nshell =
SIZE(shell_particles%els)
2349 IF (shell_adiabatic)
THEN
2350 core_particle_set => core_particles%els
2354 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
2357 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
2360 IF (simpar%ensemble /= npe_f_ensemble)
THEN
2361 IF (shell_adiabatic)
THEN
2362 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2363 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
2364 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
2366 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2367 particle_set, local_molecules, local_particles, para_env)
2372 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
2373 local_particles, para_env, shell_particle_set=shell_particle_set, &
2374 core_particle_set=core_particle_set)
2376 IF (simpar%constraint)
THEN
2378 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2379 molecule_kind_set, dt, force_env%root_section)
2383 IF (simpar%constraint)
THEN
2384 roll_tol_thrs = simpar%roll_tol
2386 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
2387 CALL getold(gci, local_molecules, molecule_set, &
2388 molecule_kind_set, particle_set, cell)
2390 roll_tol_thrs = epsilon(0.0_dp)
2392 roll_tol = -roll_tol_thrs
2394 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2396 IF (simpar%constraint)
THEN
2397 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
2399 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
2400 local_molecules, molecule_set, molecule_kind_set, &
2401 local_particles, kin, pv_kin, virial, para_env)
2402 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree, &
2403 virial_components=barostat%virial_components)
2405 trvg = npt(1, 1)%v + npt(2, 2)%v + npt(3, 3)%v
2410 CALL diagonalise(matrix=npt(:, :)%v, mysize=3, &
2411 uplo=
"U", eigenvalues=tmp%e_val, eigenvectors=tmp%u)
2413 tmp%arg_r(:) = 0.5_dp*tmp%e_val(:)*dt* &
2414 0.5_dp*tmp%e_val(:)*dt
2415 tmp%poly_r = 1.0_dp + e2*tmp%arg_r + e4*tmp%arg_r*tmp%arg_r + &
2416 e6*tmp%arg_r**3 + e8*tmp%arg_r**4
2417 tmp%scale_r(:) = exp(0.5_dp*dt*tmp%e_val(:))
2419 tmp%arg_v(:) = 0.25_dp*dt*(tmp%e_val(:) + trvg*infree)* &
2420 0.25_dp*dt*(tmp%e_val(:) + trvg*infree)
2421 tmp%poly_v = 1.0_dp + e2*tmp%arg_v + e4*tmp%arg_v*tmp%arg_v + &
2422 e6*tmp%arg_v**3 + e8*tmp%arg_v**4
2423 tmp%scale_v(:) = exp(-0.25_dp*dt*(tmp%e_val(:) + trvg*infree))
2425 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
2426 core_particle_set, shell_particle_set, nparticle_kind, &
2427 shell_adiabatic, dt, u=tmp%u)
2429 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
2430 atomic_kind_set, local_particles, particle_set, core_particle_set, &
2431 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
2434 vector_r = tmp%scale_r*tmp%poly_r
2435 vector_v = tmp%scale_v*tmp%poly_v
2437 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
2438 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, &
2439 simpar, roll_tol, iroll, vector_r, vector_v, &
2440 para_env, u=tmp%u, cell=cell, &
2441 local_particles=local_particles)
2445 uh = matmul(transpose(tmp%u), cell%hmat)
2449 uh(i, j) = uh(i, j)*tmp%scale_r(i)*tmp%scale_r(i)
2453 cell%hmat = matmul(tmp%u, uh)
2455 CALL init_cell(cell)
2458 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2459 core_particle_set, para_env, shell_adiabatic, pos=.true.)
2461 IF (shell_adiabatic .AND. shell_check_distance)
THEN
2462 CALL optimize_shell_core(force_env, particle_set, &
2463 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
2467 CALL force_env_calc_energy_force(force_env)
2470 CALL metadyn_integrator(force_env, itimes, tmp%vel)
2473 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
2474 core_particle_set, shell_particle_set, nparticle_kind, &
2475 shell_adiabatic, dt, tmp%u)
2477 IF (simpar%constraint)
THEN
2478 roll_tol_thrs = simpar%roll_tol
2481 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
2483 roll_tol_thrs = epsilon(0.0_dp)
2485 roll_tol = -roll_tol_thrs
2487 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2489 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
2490 particle_set, local_particles, molecule_kind_set, molecule_set, &
2491 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
2492 roll_tol, iroll, infree, first, para_env, u=tmp%u)
2494 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
2495 local_molecules, molecule_set, molecule_kind_set, &
2496 local_particles, kin, pv_kin, virial, para_env)
2497 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree, &
2498 virial_components=barostat%virial_components)
2502 IF (simpar%ensemble /= npe_f_ensemble)
THEN
2503 IF (shell_adiabatic)
THEN
2504 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2505 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
2506 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
2509 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2510 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
2515 IF (
ASSOCIATED(thermostat_shell))
THEN
2516 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
2517 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
2518 core_vel=tmp%core_vel)
2522 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
2525 IF (simpar%ensemble == npe_f_ensemble .AND. simpar%annealing)
THEN
2526 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
2527 IF (shell_adiabatic)
THEN
2528 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
2529 tmp%vel, tmp%shell_vel, tmp%core_vel)
2533 IF (simpar%ensemble == npe_f_ensemble .AND. simpar%annealing_cell)
THEN
2534 npt(:, :)%v = npt(:, :)%v*simpar%f_annealing_cell
2538 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2539 core_particle_set, para_env, shell_adiabatic, vel=.true.)
2542 IF (simpar%constraint)
THEN
2543 CALL pv_constraint(gci, local_molecules, molecule_set, &
2544 molecule_kind_set, particle_set, virial, para_env)
2547 CALL virial_evaluate(atomic_kind_set, particle_set, &
2548 local_particles, virial, para_env)
2551 CALL deallocate_old(old)
2553 IF (first_time)
THEN
2554 first_time = .false.
2555 CALL set_md_env(md_env, first_time=first_time)
2558 END SUBROUTINE npt_f
2567 TYPE(md_environment_type),
POINTER :: md_env
2569 INTEGER :: i_step, iparticle, iparticle_kind, &
2570 iparticle_local, n_time_steps, &
2571 nparticle, nparticle_kind, &
2573 INTEGER,
POINTER :: itimes
2574 REAL(kind=dp) :: dm, dt, mass
2575 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: pos, vel
2576 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2577 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2578 TYPE(atomic_kind_type),
POINTER :: atomic_kind
2579 TYPE(cell_type),
POINTER :: cell
2580 TYPE(cp_subsys_type),
POINTER :: subsys, subsys_respa
2581 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2582 TYPE(force_env_type),
POINTER :: force_env
2583 TYPE(global_constraint_type),
POINTER :: gci
2584 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2585 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2586 TYPE(molecule_list_type),
POINTER :: molecules
2587 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2588 TYPE(mp_para_env_type),
POINTER :: para_env
2589 TYPE(particle_list_type),
POINTER :: particles, particles_respa
2590 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set, particle_set_respa
2591 TYPE(simpar_type),
POINTER :: simpar
2593 NULLIFY (para_env, cell, subsys_respa, particles_respa, particle_set_respa, gci, force_env, atomic_kinds)
2594 NULLIFY (atomic_kind_set, simpar, subsys, particles, particle_set)
2595 NULLIFY (local_molecules, molecule_kinds, molecules, molecule_kind_set, local_particles, itimes)
2596 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
2597 para_env=para_env, itimes=itimes)
2600 n_time_steps = simpar%n_time_steps
2602 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2603 CALL force_env_get(force_env%sub_force_env(1)%force_env, subsys=subsys_respa)
2606 CALL apply_qmmm_walls_reflective(force_env)
2608 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2609 particles=particles, local_molecules=local_molecules, molecules=molecules, &
2610 gci=gci, molecule_kinds=molecule_kinds)
2612 CALL cp_subsys_get(subsys=subsys_respa, particles=particles_respa)
2613 particle_set_respa => particles_respa%els
2615 nparticle_kind = atomic_kinds%n_els
2616 atomic_kind_set => atomic_kinds%els
2617 molecule_kind_set => molecule_kinds%els
2619 nparticle = particles%n_els
2620 particle_set => particles%els
2621 molecule_set => molecules%els
2624 ALLOCATE (pos(3, nparticle))
2625 ALLOCATE (vel(3, nparticle))
2628 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
2629 molecule_kind_set, particle_set, cell)
2632 DO iparticle_kind = 1, nparticle_kind
2633 atomic_kind => atomic_kind_set(iparticle_kind)
2634 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2636 nparticle_local = local_particles%n_el(iparticle_kind)
2637 DO iparticle_local = 1, nparticle_local
2638 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2639 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
2640 dm*(particle_set(iparticle)%f(:) - &
2641 particle_set_respa(iparticle)%f(:))
2646 DO i_step = 1, n_time_steps
2648 DO iparticle_kind = 1, nparticle_kind
2649 atomic_kind => atomic_kind_set(iparticle_kind)
2650 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2651 dm = 0.5_dp*dt/(n_time_steps*mass)
2652 nparticle_local = local_particles%n_el(iparticle_kind)
2653 DO iparticle_local = 1, nparticle_local
2654 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2655 vel(:, iparticle) = vel(:, iparticle) + &
2656 dm*particle_set_respa(iparticle)%f(:)
2657 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
2658 (dt/n_time_steps)*vel(:, iparticle)
2662 IF (simpar%constraint)
THEN
2664 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2665 molecule_kind_set, dt, force_env%root_section)
2667 CALL shake_control(gci, local_molecules, molecule_set, &
2668 molecule_kind_set, particle_set, pos, vel, dt, simpar%shake_tol, &
2669 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, cell, &
2670 para_env, local_particles)
2674 CALL update_particle_set(particle_set, para_env, pos=pos)
2675 DO iparticle = 1,
SIZE(particle_set)
2676 particle_set_respa(iparticle)%r = particle_set(iparticle)%r
2680 CALL force_env_calc_energy_force(force_env%sub_force_env(1)%force_env)
2683 CALL metadyn_integrator(force_env, itimes, vel)
2686 DO iparticle_kind = 1, nparticle_kind
2687 atomic_kind => atomic_kind_set(iparticle_kind)
2688 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2689 dm = 0.5_dp*dt/(n_time_steps*mass)
2690 nparticle_local = local_particles%n_el(iparticle_kind)
2691 DO iparticle_local = 1, nparticle_local
2692 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2693 vel(1, iparticle) = vel(1, iparticle) + dm*particle_set_respa(iparticle)%f(1)
2694 vel(2, iparticle) = vel(2, iparticle) + dm*particle_set_respa(iparticle)%f(2)
2695 vel(3, iparticle) = vel(3, iparticle) + dm*particle_set_respa(iparticle)%f(3)
2699 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
2700 molecule_kind_set, particle_set, vel, dt, simpar%shake_tol, &
2701 simpar%info_constraint, simpar%lagrange_multipliers, &
2702 simpar%dump_lm, cell, para_env, local_particles)
2704 IF (simpar%annealing) vel(:, :) = vel(:, :)*simpar%f_annealing
2710 CALL force_env_calc_energy_force(force_env)
2713 CALL metadyn_integrator(force_env, itimes, vel)
2715 DO iparticle_kind = 1, nparticle_kind
2716 atomic_kind => atomic_kind_set(iparticle_kind)
2717 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2719 nparticle_local = local_particles%n_el(iparticle_kind)
2720 DO iparticle_local = 1, nparticle_local
2721 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2722 vel(1, iparticle) = vel(1, iparticle) + dm*(particle_set(iparticle)%f(1) - particle_set_respa(iparticle)%f(1))
2723 vel(2, iparticle) = vel(2, iparticle) + dm*(particle_set(iparticle)%f(2) - particle_set_respa(iparticle)%f(2))
2724 vel(3, iparticle) = vel(3, iparticle) + dm*(particle_set(iparticle)%f(3) - particle_set_respa(iparticle)%f(3))
2729 CALL update_particle_set(particle_set, para_env, vel=vel)
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.
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.
Barostat structure: module containing barostat available for MD.
Handles all functions related to the CELL.
subroutine, public read_xyz_comment(line, cell, has_cell, step, time, ener)
Reads comment line of XYZ files to get cell, step, time and energy info.
subroutine, public init_cell(cell, hmat, periodic)
Initialise/readjust a simulation cell after hmat has been changed.
Handles all functions related to the CELL.
subroutine, public parse_cell_line(input_line, cell_itimes, cell_time, h, vol)
Read cell info from a line (parsed from a file)
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
Contains routines useful for the application of constraints during MD.
subroutine, public pv_constraint(gci, local_molecules, molecule_set, molecule_kind_set, particle_set, virial, group)
...
subroutine, public getold(gci, local_molecules, molecule_set, molecule_kind_set, particle_set, cell)
saves all of the old variables
subroutine, public rattle_control(gci, local_molecules, molecule_set, molecule_kind_set, particle_set, vel, dt, rattle_tol, log_unit, lagrange_mult, dump_lm, cell, group, local_particles)
...
subroutine, public shake_control(gci, local_molecules, molecule_set, molecule_kind_set, particle_set, pos, vel, dt, shake_tol, log_unit, lagrange_mult, dump_lm, cell, group, local_particles)
...
subroutine, public shake_roll_control(gci, local_molecules, molecule_set, molecule_kind_set, particle_set, pos, vel, dt, simpar, roll_tol, iroll, vector_r, vector_v, group, u, cell, local_particles)
...
subroutine, public shake_update_targets(gci, local_molecules, molecule_set, molecule_kind_set, dt, root_section)
Updates the TARGET of the COLLECTIVE constraints if the growth speed is different from zero.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
subroutine, public cp_iterate(iteration_info, last, iter_nr, increment, iter_nr_out)
adds one to the actual iteration
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_read_line(parser, nline, at_end)
Read the next line from a logical unit "unit" (I/O node only). Skip (nline-1) lines and skip also all...
subroutine, public parser_get_next_line(parser, nline, at_end)
Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all ...
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, cell_ref, use_ref_cell)
returns information about various attributes of the given subsys
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
Provides interfaces to LAPACK eigenvalue/SVD routines.
subroutine, public shell_scale_comv(atomic_kind_set, local_particles, particle_set, com_vel, shell_vel, core_vel)
...
Lumps all possible extended system variables into one type for easy access and passing.
Interface for the force calculations.
recursive subroutine, public force_env_calc_energy_force(force_env, calc_force, consistent_energies, skip_external_control, eval_energy_forces, require_consistent_energy_force, linres, calc_stress_tensor)
Interface routine for force and energy calculations.
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
Define type storing the global information of a run. Keep the amount of stored data small....
Provides integrator utility routines for the integrators.
subroutine, public variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, local_particles, particle_set, core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, npt)
Compute the timestep rescaling factor.
subroutine, public rattle_roll_setup(old, gci, atomic_kind_set, particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, vel, dt, cell, npt, simpar, virial, vector_v, roll_tol, iroll, infree, first, para_env, u)
update veps using multiplier obtained from SHAKE
subroutine, public allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
allocate temporary variables to store positions and velocities used by the velocity-verlet integrator
subroutine, public vv_second(tmp, atomic_kind_set, local_particles, particle_set, core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt, u)
Second half of the velocity-verlet algorithm : update velocity by half step using the new forces.
subroutine, public allocate_old(old, particle_set, npt)
...
subroutine, public update_dealloc_tmp(tmp, particle_set, shell_particle_set, core_particle_set, para_env, shell_adiabatic, pos, vel, should_deall_vel)
update positions and deallocate temporary variable
elemental subroutine, public damp_veps(npt, gamma1, dt)
provides damping for barostat via nph_uniaxial_damped dynamics
subroutine, public update_veps(box, npt, simpar, pv_kin, kin, virial, infree, virial_components)
Routine to compute veps.
subroutine, public get_s_ds(tmp, nparticle_kind, atomic_kind_set, local_particles, particle_set, dt, para_env, tmpv)
...
subroutine, public vv_first(tmp, atomic_kind_set, local_particles, particle_set, core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt, u, lfixd_list)
First half of the velocity-verlet algorithm : update velocity by half step and positions by full step...
subroutine, public deallocate_old(old)
...
Provides integrator routines (velocity verlet) for all the ensemble types.
subroutine, public nvt(md_env, globenv)
nvt integrator for particle positions & momenta
subroutine, public isokin(md_env)
simplest version of the isokinetic gaussian thermostat
subroutine, public reftraj(md_env)
uses coordinates in a file and generates frame after frame of these
subroutine, public nph_uniaxial(md_env)
nph_uniaxial integrator (non-Hamiltonian version) for particle positions & momenta undergoing uniaxia...
subroutine, public nph_uniaxial_damped(md_env)
nph_uniaxial integrator (non-Hamiltonian version) for particle positions & momenta undergoing uniaxia...
subroutine, public langevin(md_env)
Langevin integrator for particle positions & momenta (Brownian dynamics)
subroutine, public npt_f(md_env, globenv)
Velocity Verlet integrator for the NPT ensemble with fully flexible cell.
subroutine, public nve_respa(md_env)
RESPA integrator for nve ensemble for particle positions & momenta.
subroutine, public nvt_adiabatic(md_env, globenv)
nvt adiabatic integrator for particle positions & momenta
subroutine, public nve(md_env, globenv)
nve integrator for particle positions & momenta
subroutine, public npt_i(md_env, globenv)
npt_i integrator for particle positions & momenta isotropic box changes
Defines the basic variable types.
integer, parameter, public max_line_length
integer, parameter, public dp
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 molecule kind structure types and the corresponding functionality.
represent a simple array based list of the given type
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.
subroutine, public update_particle_set(particle_set, int_group, pos, vel, for, add)
...
Definition of physical constants:
real(kind=dp), parameter, public femtoseconds
subroutine, public apply_qmmm_walls_reflective(force_env)
Apply reflective QM walls in order to avoid QM atoms escaping from the QM Box.
Update a QM/MM calculations with force mixing.
subroutine, public qmmmx_update_force_env(force_env, root_section)
...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
initialization of the reftraj structure used to analyse previously generated trajectories
integer, parameter, public reftraj_wrap_central
integer, parameter, public reftraj_wrap_positive
integer, parameter, public reftraj_wrap_none
integer, parameter, public reftraj_eval_energy_forces
integer, parameter, public reftraj_eval_none
Initialize the analysis of trajectories to be done by activating the REFTRAJ ensemble.
subroutine, public compute_msd_reftraj(reftraj, md_env, particle_set)
...
Routines for propagating the orbitals.
subroutine, public propagation_step(qs_env, rtp, rtp_control)
performs a single propagation step a(t+Dt)=U(t+Dt,t)*a(0) and calculates the new exponential
Routine for the real time propagation output.
subroutine, public rt_prop_output(qs_env, run_type, delta_iter, used_time)
...
Types and set_get for real time propagation depending on runtype and diagonalization method different...
subroutine, public optimize_shell_core(force_env, particle_set, shell_particle_set, core_particle_set, globenv, tmp, check)
Optimize shell-core positions along an MD run.
Type for storing MD parameters.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Thermal regions type: to initialize and control the temperature of different regions.
subroutine, public apply_thermostat_baro(thermostat, npt, group)
...
subroutine, public apply_thermostat_shells(thermostat, atomic_kind_set, particle_set, local_particles, group, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
subroutine, public apply_thermostat_particles(thermostat, force_env, molecule_kind_set, molecule_set, particle_set, local_molecules, local_particles, group, shell_adiabatic, shell_particle_set, core_particle_set, vel, shell_vel, core_vel)
...
Thermostat structure: module containing thermostat available for MD.
subroutine, public virial_evaluate(atomic_kind_set, particle_set, local_particles, virial, igroup)
Computes the kinetic part of the pressure tensor and updates the full VIRIAL (PV)
represent a list of objects
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
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
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment
represent a list of objects
represent a list of objects
represent a list of objects
Simulation parameter type for molecular dynamics.