111#include "../base/base_uses.f90"
117 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'integrator'
142 INTEGER :: iparticle, iparticle_kind, iparticle_local, iparticle_reg, ireg, nparticle, &
143 nparticle_kind, nparticle_local, nshell
144 INTEGER,
POINTER :: itimes
145 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: do_langevin
146 REAL(kind=
dp) :: c, c1, c2, c3, c4, dm, dt, gam, mass, &
147 noisy_gamma_region, reg_temp, sigma
148 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: var_w
149 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pos, vel, w
170 NULLIFY (cell, para_env, gci, force_env)
171 NULLIFY (atomic_kinds, local_particles, subsys, local_molecules, molecule_kinds, molecules)
172 NULLIFY (molecule_kind_set, molecule_set, particles, particle_set, simpar, virial)
173 NULLIFY (thermal_region, thermal_regions, itimes)
175 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
176 para_env=para_env, thermal_regions=thermal_regions, &
180 gam = simpar%gamma + simpar%shadow_gamma
183 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
189 atomic_kinds=atomic_kinds, &
191 local_particles=local_particles, &
192 local_molecules=local_molecules, &
193 molecules=molecules, &
194 molecule_kinds=molecule_kinds, &
196 particles=particles, &
198 IF (nshell /= 0)
THEN
199 cpabort(
"Langevin dynamics is not yet implemented for core-shell models")
202 nparticle_kind = atomic_kinds%n_els
203 atomic_kind_set => atomic_kinds%els
204 molecule_kind_set => molecule_kinds%els
206 nparticle = particles%n_els
207 particle_set => particles%els
208 molecule_set => molecules%els
211 ALLOCATE (do_langevin(nparticle))
212 IF (simpar%do_thermal_region)
THEN
213 DO iparticle = 1, nparticle
214 do_langevin(iparticle) = thermal_regions%do_langevin(iparticle)
217 do_langevin(1:nparticle) = .true.
228 ALLOCATE (var_w(nparticle))
229 var_w(1:nparticle) = simpar%var_w
230 IF (simpar%do_thermal_region)
THEN
231 DO ireg = 1, thermal_regions%nregions
232 thermal_region => thermal_regions%thermal_region(ireg)
233 noisy_gamma_region = thermal_region%noisy_gamma_region
234 DO iparticle_reg = 1, thermal_region%npart
235 iparticle = thermal_region%part_index(iparticle_reg)
236 reg_temp = thermal_region%temp_expected
237 var_w(iparticle) = 2.0_dp*reg_temp*simpar%dt*(simpar%gamma + noisy_gamma_region)
243 ALLOCATE (pos(3, nparticle))
246 ALLOCATE (vel(3, nparticle))
249 ALLOCATE (w(3, nparticle))
252 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
253 molecule_kind_set, particle_set, cell)
256 DO iparticle_kind = 1, nparticle_kind
257 atomic_kind => atomic_kind_set(iparticle_kind)
259 nparticle_local = local_particles%n_el(iparticle_kind)
260 DO iparticle_local = 1, nparticle_local
261 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
262 IF (do_langevin(iparticle))
THEN
263 sigma = var_w(iparticle)*mass
264 associate(rng_stream => local_particles%local_particle_set(iparticle_kind)% &
265 rng(iparticle_local))
266 w(1, iparticle) = rng_stream%stream%next(variance=sigma)
267 w(2, iparticle) = rng_stream%stream%next(variance=sigma)
268 w(3, iparticle) = rng_stream%stream%next(variance=sigma)
280 c = exp(-0.25_dp*dt*gam)
285 DO iparticle_kind = 1, nparticle_kind
286 atomic_kind => atomic_kind_set(iparticle_kind)
288 nparticle_local = local_particles%n_el(iparticle_kind)
291 DO iparticle_local = 1, nparticle_local
292 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
293 IF (do_langevin(iparticle))
THEN
294 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
295 c3*particle_set(iparticle)%f(:)
296 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
297 c1*particle_set(iparticle)%v(:) + &
298 c*dm*(dt*particle_set(iparticle)%f(:) + &
301 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
302 dm*particle_set(iparticle)%f(:)
303 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
304 dt*particle_set(iparticle)%v(:) + &
305 dm*dt*particle_set(iparticle)%f(:)
310 IF (simpar%constraint)
THEN
313 molecule_kind_set, dt, force_env%root_section)
315 CALL shake_control(gci, local_molecules, molecule_set, molecule_kind_set, &
316 particle_set, pos, vel, dt, simpar%shake_tol, &
317 simpar%info_constraint, simpar%lagrange_multipliers, &
318 simpar%dump_lm, cell, para_env, local_particles)
333 DO iparticle_kind = 1, nparticle_kind
334 atomic_kind => atomic_kind_set(iparticle_kind)
338 nparticle_local = local_particles%n_el(iparticle_kind)
339 DO iparticle_local = 1, nparticle_local
340 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
341 IF (do_langevin(iparticle))
THEN
342 vel(1, iparticle) = vel(1, iparticle) + c3*particle_set(iparticle)%f(1)
343 vel(2, iparticle) = vel(2, iparticle) + c3*particle_set(iparticle)%f(2)
344 vel(3, iparticle) = vel(3, iparticle) + c3*particle_set(iparticle)%f(3)
345 vel(1, iparticle) = c4*vel(1, iparticle) + c2*w(1, iparticle)/mass
346 vel(2, iparticle) = c4*vel(2, iparticle) + c2*w(2, iparticle)/mass
347 vel(3, iparticle) = c4*vel(3, iparticle) + c2*w(3, iparticle)/mass
349 vel(1, iparticle) = vel(1, iparticle) + dm*particle_set(iparticle)%f(1)
350 vel(2, iparticle) = vel(2, iparticle) + dm*particle_set(iparticle)%f(2)
351 vel(3, iparticle) = vel(3, iparticle) + dm*particle_set(iparticle)%f(3)
356 IF (simpar%temperature_annealing)
THEN
357 simpar%temp_ext = simpar%temp_ext*simpar%f_temperature_annealing
358 simpar%var_w = simpar%var_w*simpar%f_temperature_annealing
361 IF (simpar%constraint)
THEN
362 CALL rattle_control(gci, local_molecules, molecule_set, molecule_kind_set, &
363 particle_set, vel, dt, simpar%shake_tol, &
364 simpar%info_constraint, simpar%lagrange_multipliers, &
365 simpar%dump_lm, cell, para_env, local_particles)
375 DEALLOCATE (do_langevin)
378 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, molecule_set, &
379 molecule_kind_set, particle_set, virial, para_env)
395 SUBROUTINE nve(md_env, globenv)
397 TYPE(md_environment_type),
POINTER :: md_env
398 TYPE(global_environment_type),
POINTER :: globenv
400 INTEGER :: i_iter, n_iter, nparticle, &
401 nparticle_kind, nshell
402 INTEGER,
POINTER :: itimes
403 LOGICAL :: deallocate_vel, ehrenfest_md, &
404 shell_adiabatic, shell_check_distance, &
407 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: v_old
408 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
409 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
410 TYPE(cell_type),
POINTER :: cell
411 TYPE(cp_subsys_type),
POINTER :: subsys
412 TYPE(dft_control_type),
POINTER :: dft_control
413 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
414 TYPE(force_env_type),
POINTER :: force_env
415 TYPE(global_constraint_type),
POINTER :: gci
416 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
417 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
418 TYPE(molecule_list_type),
POINTER :: molecules
419 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
420 TYPE(mp_para_env_type),
POINTER :: para_env
421 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
423 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
425 TYPE(rt_prop_type),
POINTER :: rtp
426 TYPE(simpar_type),
POINTER :: simpar
427 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_shell
428 TYPE(tmp_variables_type),
POINTER :: tmp
429 TYPE(virial_type),
POINTER :: virial
431 NULLIFY (thermostat_coeff, tmp)
432 NULLIFY (subsys, simpar, para_env, cell, gci, force_env, virial)
433 NULLIFY (atomic_kinds, local_particles, molecules, molecule_kind_set, molecule_set, particle_set)
434 NULLIFY (shell_particles, shell_particle_set, core_particles, &
435 core_particle_set, thermostat_shell, dft_control, itimes)
436 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
437 thermostat_coeff=thermostat_coeff, thermostat_shell=thermostat_shell, &
438 para_env=para_env, ehrenfest_md=ehrenfest_md, itimes=itimes)
440 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
443 CALL apply_qmmm_walls_reflective(force_env)
445 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
446 particles=particles, local_molecules=local_molecules, molecules=molecules, &
447 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
449 nparticle_kind = atomic_kinds%n_els
450 atomic_kind_set => atomic_kinds%els
451 molecule_kind_set => molecule_kinds%els
453 nparticle = particles%n_els
454 particle_set => particles%els
455 molecule_set => molecules%els
457 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
458 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
459 shell_check_distance=shell_check_distance)
461 IF (shell_present)
THEN
462 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
463 core_particles=core_particles)
464 shell_particle_set => shell_particles%els
465 nshell =
SIZE(shell_particles%els)
467 IF (shell_adiabatic)
THEN
468 core_particle_set => core_particles%els
472 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
475 IF (shell_adiabatic)
THEN
476 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
477 local_particles, para_env, shell_particle_set=shell_particle_set, &
478 core_particle_set=core_particle_set)
481 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
482 molecule_kind_set, particle_set, cell)
485 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
486 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
488 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
489 local_particles, particle_set, core_particle_set, shell_particle_set, &
490 nparticle_kind, shell_adiabatic)
492 IF (simpar%constraint)
THEN
494 CALL shake_update_targets(gci, local_molecules, molecule_set, &
495 molecule_kind_set, dt, force_env%root_section)
497 CALL shake_control(gci, local_molecules, molecule_set, &
498 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
499 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
500 cell, para_env, local_particles)
504 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
505 core_particle_set, para_env, shell_adiabatic, pos=.true.)
507 IF (shell_adiabatic .AND. shell_check_distance)
THEN
508 CALL optimize_shell_core(force_env, particle_set, &
509 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
514 IF (ehrenfest_md)
THEN
515 ALLOCATE (v_old(3,
SIZE(tmp%vel, 2)))
516 v_old(:, :) = tmp%vel
517 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
518 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
519 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
520 core_particle_set, para_env, shell_adiabatic, vel=.true., &
521 should_deall_vel=.false.)
523 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
524 n_iter = dft_control%rtp_control%max_iter
529 DO i_iter = 1, n_iter
531 IF (ehrenfest_md)
THEN
532 CALL get_qs_env(qs_env=force_env%qs_env, rtp=rtp)
535 CALL propagation_step(force_env%qs_env, rtp, dft_control%rtp_control)
539 CALL force_env_calc_energy_force(force_env, require_consistent_energy_force=.false.)
541 IF (ehrenfest_md)
THEN
542 CALL rt_prop_output(force_env%qs_env, ehrenfest, delta_iter=force_env%qs_env%rtp%delta_iter)
546 CALL metadyn_integrator(force_env, itimes, tmp%vel)
549 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
550 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
552 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
553 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
554 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
555 cell, para_env, local_particles)
558 IF (shell_adiabatic)
THEN
559 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
560 local_particles, para_env, vel=tmp%vel, &
561 shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
564 IF (simpar%annealing)
THEN
565 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
566 IF (shell_adiabatic)
THEN
567 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
568 tmp%vel, tmp%shell_vel, tmp%core_vel)
572 IF (ehrenfest_md) deallocate_vel = force_env%qs_env%rtp%converged
573 IF (i_iter == n_iter) deallocate_vel = .true.
575 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
576 core_particle_set, para_env, shell_adiabatic, vel=.true., &
577 should_deall_vel=deallocate_vel)
578 IF (ehrenfest_md)
THEN
579 IF (force_env%qs_env%rtp%converged)
EXIT
585 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
586 molecule_set, molecule_kind_set, particle_set, virial, para_env)
588 CALL virial_evaluate(atomic_kind_set, particle_set, &
589 local_particles, virial, para_env)
609 TYPE(md_environment_type),
POINTER :: md_env
611 INTEGER :: nparticle, nparticle_kind, nshell
612 INTEGER,
POINTER :: itimes
613 LOGICAL :: shell_adiabatic, shell_present
615 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
616 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
617 TYPE(cp_subsys_type),
POINTER :: subsys
618 TYPE(distribution_1d_type),
POINTER :: local_particles
619 TYPE(force_env_type),
POINTER :: force_env
620 TYPE(mp_para_env_type),
POINTER :: para_env
621 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
623 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
625 TYPE(simpar_type),
POINTER :: simpar
626 TYPE(tmp_variables_type),
POINTER :: tmp
628 NULLIFY (force_env, tmp, simpar, itimes)
629 NULLIFY (atomic_kinds, para_env, subsys, local_particles)
630 NULLIFY (core_particles, particles, shell_particles)
631 NULLIFY (core_particle_set, particle_set, shell_particle_set)
633 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
634 para_env=para_env, itimes=itimes)
638 CALL force_env_get(force_env=force_env, subsys=subsys)
641 CALL apply_qmmm_walls_reflective(force_env)
643 IF (simpar%constraint)
THEN
644 cpabort(
"Constraints not yet implemented")
647 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, &
648 local_particles=local_particles, &
651 nparticle_kind = atomic_kinds%n_els
652 atomic_kind_set => atomic_kinds%els
653 nparticle = particles%n_els
654 particle_set => particles%els
656 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
657 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
659 IF (shell_present)
THEN
660 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
661 core_particles=core_particles)
662 shell_particle_set => shell_particles%els
663 nshell =
SIZE(shell_particles%els)
665 IF (shell_adiabatic)
THEN
666 core_particle_set => core_particles%els
670 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
673 CALL get_s_ds(tmp, nparticle_kind, atomic_kind_set, local_particles, particle_set, &
677 tmp%scale_v(1:3) = sqrt(1.0_dp/tmp%ds)
678 tmp%poly_v(1:3) = 2.0_dp*tmp%s/sqrt(tmp%ds)/dt
679 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
680 core_particle_set, shell_particle_set, nparticle_kind, &
683 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
684 local_particles, particle_set, core_particle_set, shell_particle_set, &
685 nparticle_kind, shell_adiabatic)
688 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
689 core_particle_set, para_env, shell_adiabatic, pos=.true.)
691 CALL force_env_calc_energy_force(force_env)
694 CALL metadyn_integrator(force_env, itimes, tmp%vel)
697 CALL get_s_ds(tmp, nparticle_kind, atomic_kind_set, local_particles, particle_set, &
698 dt, para_env, tmpv=.true.)
701 tmp%scale_v(1:3) = sqrt(1.0_dp/tmp%ds)
702 tmp%poly_v(1:3) = 2.0_dp*tmp%s/sqrt(tmp%ds)/dt
703 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
704 core_particle_set, shell_particle_set, nparticle_kind, &
707 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
710 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
711 core_particle_set, para_env, shell_adiabatic, vel=.true.)
725 TYPE(md_environment_type),
POINTER :: md_env
726 TYPE(global_environment_type),
POINTER :: globenv
728 INTEGER :: ivar, nparticle, nparticle_kind, nshell
729 INTEGER,
POINTER :: itimes
730 LOGICAL :: shell_adiabatic, shell_check_distance, &
733 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
734 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
735 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
736 TYPE(cell_type),
POINTER :: cell
737 TYPE(cp_subsys_type),
POINTER :: subsys
738 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
739 TYPE(force_env_type),
POINTER :: force_env
740 TYPE(global_constraint_type),
POINTER :: gci
741 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
742 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
743 TYPE(molecule_list_type),
POINTER :: molecules
744 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
745 TYPE(mp_para_env_type),
POINTER :: para_env
746 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
748 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
750 TYPE(simpar_type),
POINTER :: simpar
751 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_fast, &
752 thermostat_shell, thermostat_slow
753 TYPE(tmp_variables_type),
POINTER :: tmp
754 TYPE(virial_type),
POINTER :: virial
756 NULLIFY (gci, force_env, thermostat_coeff, tmp, &
757 thermostat_fast, thermostat_slow, thermostat_shell, cell, shell_particles, &
758 shell_particle_set, core_particles, core_particle_set, rand)
759 NULLIFY (para_env, subsys, local_molecules, local_particles, molecule_kinds, &
760 molecules, molecule_kind_set, molecule_set, atomic_kinds, particles)
761 NULLIFY (simpar, itimes)
763 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
764 thermostat_fast=thermostat_fast, thermostat_slow=thermostat_slow, &
765 thermostat_coeff=thermostat_coeff, thermostat_shell=thermostat_shell, &
766 para_env=para_env, itimes=itimes)
769 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
772 CALL apply_qmmm_walls_reflective(force_env)
774 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
775 particles=particles, local_molecules=local_molecules, molecules=molecules, &
776 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
778 nparticle_kind = atomic_kinds%n_els
779 atomic_kind_set => atomic_kinds%els
780 molecule_kind_set => molecule_kinds%els
782 nparticle = particles%n_els
783 particle_set => particles%els
784 molecule_set => molecules%els
786 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
787 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
788 shell_check_distance=shell_check_distance)
790 IF (
ASSOCIATED(force_env%meta_env))
THEN
792 IF (force_env%meta_env%langevin)
THEN
793 ALLOCATE (rand(force_env%meta_env%n_colvar))
799 IF (shell_present)
THEN
800 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
801 core_particles=core_particles)
802 shell_particle_set => shell_particles%els
803 nshell =
SIZE(shell_particles%els)
805 IF (shell_adiabatic)
THEN
806 core_particle_set => core_particles%els
810 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
813 IF (shell_adiabatic)
THEN
818 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
819 local_particles, para_env, shell_particle_set=shell_particle_set, &
820 core_particle_set=core_particle_set)
822 CALL apply_thermostat_particles(thermostat_fast, force_env, molecule_kind_set, molecule_set, &
823 particle_set, local_molecules, local_particles, para_env)
825 CALL apply_thermostat_particles(thermostat_slow, force_env, molecule_kind_set, molecule_set, &
826 particle_set, local_molecules, local_particles, para_env)
829 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
830 molecule_kind_set, particle_set, cell)
833 IF (
ASSOCIATED(force_env%meta_env))
THEN
834 IF (force_env%meta_env%langevin)
THEN
835 DO ivar = 1, force_env%meta_env%n_colvar
836 rand(ivar) = force_env%meta_env%rng(ivar)%next()
838 CALL metadyn_velocities_colvar(force_env, rand)
843 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
844 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
846 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
847 local_particles, particle_set, core_particle_set, shell_particle_set, &
848 nparticle_kind, shell_adiabatic)
850 IF (simpar%constraint)
THEN
852 CALL shake_update_targets(gci, local_molecules, molecule_set, &
853 molecule_kind_set, dt, force_env%root_section)
855 CALL shake_control(gci, local_molecules, molecule_set, &
856 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
857 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
858 cell, para_env, local_particles)
862 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
863 core_particle_set, para_env, shell_adiabatic, pos=.true.)
865 IF (shell_adiabatic .AND. shell_check_distance)
THEN
866 CALL optimize_shell_core(force_env, particle_set, &
867 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
871 CALL force_env_calc_energy_force(force_env)
874 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
877 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
878 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
880 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
881 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
882 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
883 cell, para_env, local_particles)
886 IF (shell_adiabatic)
THEN
891 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
892 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
893 core_vel=tmp%core_vel)
895 CALL apply_thermostat_particles(thermostat_slow, force_env, molecule_kind_set, molecule_set, &
896 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
898 CALL apply_thermostat_particles(thermostat_fast, force_env, molecule_kind_set, molecule_set, &
899 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
903 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
904 core_particle_set, para_env, shell_adiabatic, vel=.true.)
906 IF (
ASSOCIATED(force_env%meta_env))
THEN
907 IF (force_env%meta_env%langevin)
THEN
913 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
914 molecule_set, molecule_kind_set, particle_set, virial, para_env)
917 CALL virial_evaluate(atomic_kind_set, particle_set, &
918 local_particles, virial, para_env)
931 SUBROUTINE nvt(md_env, globenv)
933 TYPE(md_environment_type),
POINTER :: md_env
934 TYPE(global_environment_type),
POINTER :: globenv
936 INTEGER :: ivar, nparticle, nparticle_kind, nshell
937 INTEGER,
POINTER :: itimes
938 LOGICAL :: shell_adiabatic, shell_check_distance, &
941 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
942 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
943 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
944 TYPE(cell_type),
POINTER :: cell
945 TYPE(cp_subsys_type),
POINTER :: subsys
946 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
947 TYPE(force_env_type),
POINTER :: force_env
948 TYPE(global_constraint_type),
POINTER :: gci
949 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
950 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
951 TYPE(molecule_list_type),
POINTER :: molecules
952 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
953 TYPE(mp_para_env_type),
POINTER :: para_env
954 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
956 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
958 TYPE(simpar_type),
POINTER :: simpar
959 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_part, &
961 TYPE(tmp_variables_type),
POINTER :: tmp
962 TYPE(virial_type),
POINTER :: virial
964 NULLIFY (gci, force_env, thermostat_coeff, tmp, &
965 thermostat_part, thermostat_shell, cell, shell_particles, &
966 shell_particle_set, core_particles, core_particle_set, rand)
967 NULLIFY (para_env, subsys, local_molecules, local_particles, molecule_kinds, &
968 molecules, molecule_kind_set, molecule_set, atomic_kinds, particles)
969 NULLIFY (simpar, thermostat_coeff, thermostat_part, thermostat_shell, itimes)
971 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
972 thermostat_part=thermostat_part, thermostat_coeff=thermostat_coeff, &
973 thermostat_shell=thermostat_shell, para_env=para_env, &
977 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
980 CALL apply_qmmm_walls_reflective(force_env)
982 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
983 particles=particles, local_molecules=local_molecules, molecules=molecules, &
984 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
986 nparticle_kind = atomic_kinds%n_els
987 atomic_kind_set => atomic_kinds%els
988 molecule_kind_set => molecule_kinds%els
990 nparticle = particles%n_els
991 particle_set => particles%els
992 molecule_set => molecules%els
994 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
995 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
996 shell_check_distance=shell_check_distance)
998 IF (
ASSOCIATED(force_env%meta_env))
THEN
1000 IF (force_env%meta_env%langevin)
THEN
1001 ALLOCATE (rand(force_env%meta_env%n_colvar))
1007 IF (shell_present)
THEN
1008 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
1009 core_particles=core_particles)
1010 shell_particle_set => shell_particles%els
1011 nshell =
SIZE(shell_particles%els)
1013 IF (shell_adiabatic)
THEN
1014 core_particle_set => core_particles%els
1018 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1021 IF (shell_adiabatic)
THEN
1022 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1023 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1024 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
1026 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1027 local_particles, para_env, shell_particle_set=shell_particle_set, &
1028 core_particle_set=core_particle_set)
1030 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1031 particle_set, local_molecules, local_particles, para_env)
1034 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
1035 molecule_kind_set, particle_set, cell)
1038 IF (
ASSOCIATED(force_env%meta_env))
THEN
1039 IF (force_env%meta_env%langevin)
THEN
1040 DO ivar = 1, force_env%meta_env%n_colvar
1041 rand(ivar) = force_env%meta_env%rng(ivar)%next()
1043 CALL metadyn_velocities_colvar(force_env, rand)
1048 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1049 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
1051 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
1052 local_particles, particle_set, core_particle_set, shell_particle_set, &
1053 nparticle_kind, shell_adiabatic)
1055 IF (simpar%constraint)
THEN
1057 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1058 molecule_kind_set, dt, force_env%root_section)
1060 CALL shake_control(gci, local_molecules, molecule_set, &
1061 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
1062 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
1063 cell, para_env, local_particles)
1067 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1068 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1070 IF (shell_adiabatic .AND. shell_check_distance)
THEN
1071 CALL optimize_shell_core(force_env, particle_set, &
1072 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
1076 CALL qmmmx_update_force_env(force_env, force_env%root_section)
1081 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
1083 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1084 particles=particles, local_molecules=local_molecules, molecules=molecules, &
1085 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
1087 nparticle_kind = atomic_kinds%n_els
1088 atomic_kind_set => atomic_kinds%els
1089 molecule_kind_set => molecule_kinds%els
1091 nparticle = particles%n_els
1092 particle_set => particles%els
1093 molecule_set => molecules%els
1095 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1096 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
1097 shell_check_distance=shell_check_distance)
1100 IF (shell_present)
THEN
1101 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
1102 core_particles=core_particles)
1103 shell_particle_set => shell_particles%els
1104 nshell =
SIZE(shell_particles%els)
1106 IF (shell_adiabatic)
THEN
1107 core_particle_set => core_particles%els
1114 CALL force_env_calc_energy_force(force_env, require_consistent_energy_force=.false.)
1117 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
1120 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1121 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
1123 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
1124 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
1125 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
1126 cell, para_env, local_particles)
1129 IF (shell_adiabatic)
THEN
1130 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1131 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1132 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
1134 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1135 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
1136 core_vel=tmp%core_vel)
1138 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1139 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
1143 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1144 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1146 IF (
ASSOCIATED(force_env%meta_env))
THEN
1147 IF (force_env%meta_env%langevin)
THEN
1153 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1154 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1157 CALL virial_evaluate(atomic_kind_set, particle_set, &
1158 local_particles, virial, para_env)
1173 TYPE(md_environment_type),
POINTER :: md_env
1174 TYPE(global_environment_type),
POINTER :: globenv
1176 REAL(kind=dp),
PARAMETER :: e2 = 1.0_dp/6.0_dp, e4 = e2/20.0_dp, &
1177 e6 = e4/42.0_dp, e8 = e6/72.0_dp
1179 INTEGER :: iroll, ivar, nkind, nparticle, &
1180 nparticle_kind, nshell
1181 INTEGER,
POINTER :: itimes
1182 LOGICAL :: first, first_time, shell_adiabatic, &
1183 shell_check_distance, shell_present
1184 REAL(kind=dp) :: dt, infree, kin, roll_tol, roll_tol_thrs
1185 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
1186 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
1187 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
1188 REAL(kind=dp),
SAVE :: eps_0
1189 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1190 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1191 TYPE(cell_type),
POINTER :: cell
1192 TYPE(cp_subsys_type),
POINTER :: subsys
1193 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
1194 TYPE(force_env_type),
POINTER :: force_env
1195 TYPE(global_constraint_type),
POINTER :: gci
1196 TYPE(local_fixd_constraint_type),
DIMENSION(:), &
1197 POINTER :: lfixd_list
1198 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
1199 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
1200 TYPE(molecule_list_type),
POINTER :: molecules
1201 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1202 TYPE(mp_para_env_type),
POINTER :: para_env
1203 TYPE(npt_info_type),
POINTER :: npt(:, :)
1204 TYPE(old_variables_type),
POINTER :: old
1205 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1207 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
1209 TYPE(simpar_type),
POINTER :: simpar
1210 TYPE(thermostat_type),
POINTER :: thermostat_baro, thermostat_part, &
1212 TYPE(tmp_variables_type),
POINTER :: tmp
1213 TYPE(virial_type),
POINTER :: virial
1215 NULLIFY (gci, thermostat_baro, thermostat_part, thermostat_shell, force_env)
1216 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
1217 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
1218 NULLIFY (core_particles, particles, shell_particles, tmp, old)
1219 NULLIFY (core_particle_set, particle_set, shell_particle_set)
1220 NULLIFY (simpar, virial, rand, itimes, lfixd_list)
1222 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
1223 thermostat_part=thermostat_part, thermostat_baro=thermostat_baro, &
1224 thermostat_shell=thermostat_shell, npt=npt, first_time=first_time, &
1225 para_env=para_env, itimes=itimes)
1227 infree = 1.0_dp/real(simpar%nfree, kind=dp)
1229 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
1232 CALL apply_qmmm_walls_reflective(force_env)
1234 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1235 particles=particles, local_molecules=local_molecules, molecules=molecules, &
1236 gci=gci, molecule_kinds=molecule_kinds, virial=virial)
1238 nparticle_kind = atomic_kinds%n_els
1239 nkind = molecule_kinds%n_els
1240 atomic_kind_set => atomic_kinds%els
1241 molecule_kind_set => molecule_kinds%els
1243 nparticle = particles%n_els
1244 particle_set => particles%els
1245 molecule_set => molecules%els
1247 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1248 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
1249 shell_check_distance=shell_check_distance)
1251 IF (first_time)
THEN
1252 CALL virial_evaluate(atomic_kind_set, particle_set, &
1253 local_particles, virial, para_env)
1257 CALL allocate_old(old, particle_set, npt)
1259 IF (
ASSOCIATED(force_env%meta_env))
THEN
1261 IF (force_env%meta_env%langevin)
THEN
1262 ALLOCATE (rand(force_env%meta_env%n_colvar))
1267 IF (shell_present)
THEN
1268 CALL cp_subsys_get(subsys=subsys, &
1269 shell_particles=shell_particles, core_particles=core_particles)
1270 shell_particle_set => shell_particles%els
1271 nshell =
SIZE(shell_particles%els)
1272 IF (shell_adiabatic)
THEN
1273 core_particle_set => core_particles%els
1277 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1280 IF (first_time) eps_0 = npt(1, 1)%eps
1283 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
1286 IF (simpar%ensemble /= npe_i_ensemble)
THEN
1287 IF (shell_adiabatic)
THEN
1288 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1289 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1290 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
1293 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1294 particle_set, local_molecules, local_particles, para_env)
1299 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1300 local_particles, para_env, shell_particle_set=shell_particle_set, &
1301 core_particle_set=core_particle_set)
1303 IF (simpar%constraint)
THEN
1305 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1306 molecule_kind_set, dt, force_env%root_section)
1310 IF (simpar%constraint)
THEN
1311 roll_tol_thrs = simpar%roll_tol
1313 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
1314 CALL getold(gci, local_molecules, molecule_set, &
1315 molecule_kind_set, particle_set, cell)
1317 roll_tol_thrs = epsilon(0.0_dp)
1319 roll_tol = -roll_tol_thrs
1322 IF (
ASSOCIATED(force_env%meta_env))
THEN
1323 IF (force_env%meta_env%langevin)
THEN
1324 DO ivar = 1, force_env%meta_env%n_colvar
1325 rand(ivar) = force_env%meta_env%rng(ivar)%next()
1327 CALL metadyn_velocities_colvar(force_env, rand)
1331 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1333 IF (simpar%constraint)
THEN
1334 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
1337 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
1338 local_molecules, molecule_set, molecule_kind_set, &
1339 local_particles, kin, pv_kin, virial, para_env)
1340 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1342 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
1343 (0.5_dp*npt(1, 1)%v*dt)
1344 tmp%poly_r(1:3) = 1.0_dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
1345 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
1347 tmp%arg_v(1) = (0.25_dp*npt(1, 1)%v*dt* &
1348 (1.0_dp + 3.0_dp*infree))*(0.25_dp*npt(1, 1)%v* &
1349 dt*(1.0_dp + 3.0_dp*infree))
1350 tmp%poly_v(1:3) = 1.0_dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
1351 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
1353 tmp%scale_r(1:3) = exp(0.5_dp*dt*npt(1, 1)%v)
1354 tmp%scale_v(1:3) = exp(-0.25_dp*dt*npt(1, 1)%v* &
1355 (1.0_dp + 3.0_dp*infree))
1358 IF (simpar%ensemble == npt_ia_ensemble)
THEN
1359 CALL create_local_fixd_list(lfixd_list, nkind, molecule_kind_set, local_particles)
1360 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1361 core_particle_set, shell_particle_set, nparticle_kind, &
1362 shell_adiabatic, dt, lfixd_list=lfixd_list)
1363 CALL release_local_fixd_list(lfixd_list)
1365 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1366 core_particle_set, shell_particle_set, nparticle_kind, &
1367 shell_adiabatic, dt)
1370 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
1371 atomic_kind_set, local_particles, particle_set, core_particle_set, &
1372 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
1375 vector_r(:) = tmp%scale_r(:)*tmp%poly_r(:)
1376 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
1378 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
1379 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
1380 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
1381 local_particles=local_particles)
1385 npt(:, :)%eps = npt(:, :)%eps + dt*npt(:, :)%v
1388 cell%hmat(:, :) = cell%hmat(:, :)*exp(npt(1, 1)%eps - eps_0)
1390 eps_0 = npt(1, 1)%eps
1393 CALL init_cell(cell)
1396 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1397 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1399 IF (shell_adiabatic .AND. shell_check_distance)
THEN
1400 CALL optimize_shell_core(force_env, particle_set, &
1401 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
1405 CALL force_env_calc_energy_force(force_env)
1408 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
1411 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1412 core_particle_set, shell_particle_set, nparticle_kind, &
1413 shell_adiabatic, dt)
1415 IF (simpar%constraint)
THEN
1416 roll_tol_thrs = simpar%roll_tol
1419 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
1421 roll_tol_thrs = epsilon(0.0_dp)
1423 roll_tol = -roll_tol_thrs
1425 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1427 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
1428 particle_set, local_particles, molecule_kind_set, molecule_set, &
1429 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
1430 roll_tol, iroll, infree, first, para_env)
1432 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
1433 local_molecules, molecule_set, molecule_kind_set, &
1434 local_particles, kin, pv_kin, virial, para_env)
1435 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1439 IF (simpar%ensemble /= npe_i_ensemble)
THEN
1440 IF (shell_adiabatic)
THEN
1441 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1442 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1443 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
1445 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1446 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
1451 IF (
ASSOCIATED(thermostat_shell))
THEN
1452 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1453 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
1454 core_vel=tmp%core_vel)
1458 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
1461 IF (simpar%ensemble == npe_i_ensemble .AND. simpar%annealing)
THEN
1462 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
1463 IF (shell_adiabatic)
THEN
1464 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
1465 tmp%vel, tmp%shell_vel, tmp%core_vel)
1469 IF (simpar%ensemble == npe_i_ensemble .AND. simpar%annealing_cell)
THEN
1470 npt(1, 1)%v = npt(1, 1)%v*simpar%f_annealing_cell
1474 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1475 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1478 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1479 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1481 CALL virial_evaluate(atomic_kind_set, particle_set, &
1482 local_particles, virial, para_env)
1485 CALL deallocate_old(old)
1487 IF (
ASSOCIATED(force_env%meta_env))
THEN
1488 IF (force_env%meta_env%langevin)
THEN
1493 IF (first_time)
THEN
1494 first_time = .false.
1495 CALL set_md_env(md_env, first_time=first_time)
1498 END SUBROUTINE npt_i
1510 TYPE(md_environment_type),
POINTER :: md_env
1512 CHARACTER(LEN=2) :: element_kind_ref0, element_symbol, &
1514 CHARACTER(LEN=max_line_length) :: errmsg
1515 INTEGER :: cell_itimes, i, nparticle, nread, &
1517 INTEGER,
POINTER :: itimes
1518 LOGICAL :: init, my_end, traj_has_cell_info
1519 REAL(kind=dp) :: cell_time, h(3, 3), trj_epot, trj_time, &
1521 REAL(kind=dp),
POINTER :: time
1522 TYPE(cell_type),
POINTER :: cell
1523 TYPE(cp_subsys_type),
POINTER :: subsys
1524 TYPE(force_env_type),
POINTER :: force_env
1525 TYPE(mp_para_env_type),
POINTER :: para_env
1526 TYPE(particle_list_type),
POINTER :: particles
1527 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1528 TYPE(reftraj_type),
POINTER :: reftraj_env
1529 TYPE(simpar_type),
POINTER :: simpar
1531 NULLIFY (reftraj_env, particle_set, particles, force_env, subsys, simpar, para_env, cell, itimes, time)
1532 CALL get_md_env(md_env=md_env, init=init,
reftraj=reftraj_env, force_env=force_env, &
1533 para_env=para_env, simpar=simpar)
1535 CALL force_env_get(force_env=force_env, cell=cell, subsys=subsys)
1536 reftraj_env%isnap = reftraj_env%isnap + reftraj_env%info%stride
1539 CALL apply_qmmm_walls_reflective(force_env)
1540 CALL cp_subsys_get(subsys=subsys, particles=particles)
1541 nparticle = particles%n_els
1542 particle_set => particles%els
1546 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1547 READ (reftraj_env%info%traj_parser%input_line, fmt=
"(I8)") nread
1548 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1551 CALL read_xyz_comment(reftraj_env%info%traj_parser%input_line, cell, &
1552 traj_has_cell_info, trj_itimes, trj_time, trj_epot)
1553 IF (trj_itimes == huge(0))
THEN
1554 CALL get_md_env(md_env, itimes=itimes)
1557 IF (trj_time == huge(0.0_dp)) trj_time = 0.0_dp
1558 IF (trj_epot == huge(0.0_dp)) trj_epot = 0.0_dp
1594 IF (nread /= nparticle)
THEN
1595 errmsg =
"Number of atoms for step "//trim(adjustl(cp_to_string(trj_itimes)))// &
1596 " in the trajectory file does not match the reference configuration: "// &
1597 trim(adjustl(cp_to_string(nread)))//
" != "//trim(adjustl(cp_to_string(nparticle)))
1601 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1602 READ (unit=reftraj_env%info%traj_parser%input_line(1:len_trim(reftraj_env%info%traj_parser%input_line)), fmt=*) &
1603 element_symbol, particle_set(i)%r
1604 CALL uppercase(element_symbol)
1605 element_symbol_ref0 = particle_set(i)%atomic_kind%element_symbol
1606 element_kind_ref0 = particle_set(i)%atomic_kind%name(1:2)
1607 CALL uppercase(element_symbol_ref0)
1608 CALL uppercase(element_kind_ref0)
1609 IF (element_symbol /= element_symbol_ref0)
THEN
1611 IF (element_symbol /= element_kind_ref0)
THEN
1612 errmsg =
"Atomic configuration from trajectory file does not match the reference configuration: "// &
1613 "Check atom "//trim(adjustl(cp_to_string(i)))//
" of step "// &
1614 trim(adjustl(cp_to_string(trj_itimes)))//
". Found trajectory label '"// &
1615 trim(element_symbol)//
"', expected element '"//trim(element_symbol_ref0)// &
1616 "' or kind label '"//trim(element_kind_ref0)// &
1617 "'. REFTRAJ trajectories usually contain element labels; check whether the "// &
1618 "trajectory was modified to contain kind aliases instead."
1622 particle_set(i)%r(1) = cp_unit_to_cp2k(particle_set(i)%r(1),
"angstrom")
1623 particle_set(i)%r(2) = cp_unit_to_cp2k(particle_set(i)%r(2),
"angstrom")
1624 particle_set(i)%r(3) = cp_unit_to_cp2k(particle_set(i)%r(3),
"angstrom")
1629 CALL parser_read_line(reftraj_env%info%traj_parser, 1, at_end=my_end)
1630 READ (unit=reftraj_env%info%traj_parser%input_line, fmt=*) element_symbol, particle_set(i)%r
1631 CALL uppercase(element_symbol)
1632 element_symbol_ref0 = particle_set(i)%atomic_kind%element_symbol
1633 element_kind_ref0 = particle_set(i)%atomic_kind%name(1:2)
1634 CALL uppercase(element_symbol_ref0)
1635 CALL uppercase(element_kind_ref0)
1636 IF (element_symbol /= element_symbol_ref0)
THEN
1638 IF (element_symbol /= element_kind_ref0)
THEN
1639 errmsg =
"Atomic configuration from trajectory file does not match the reference configuration: "// &
1640 "Check atom "//trim(adjustl(cp_to_string(i)))//
" of step "// &
1641 trim(adjustl(cp_to_string(trj_itimes)))//
". Found trajectory label '"// &
1642 trim(element_symbol)//
"', expected element '"//trim(element_symbol_ref0)// &
1643 "' or kind label '"//trim(element_kind_ref0)// &
1644 "'. REFTRAJ trajectories usually contain element labels; check whether the "// &
1645 "trajectory was modified to contain kind aliases instead."
1649 particle_set(i)%r(1) = cp_unit_to_cp2k(particle_set(i)%r(1),
"angstrom")
1650 particle_set(i)%r(2) = cp_unit_to_cp2k(particle_set(i)%r(2),
"angstrom")
1651 particle_set(i)%r(3) = cp_unit_to_cp2k(particle_set(i)%r(3),
"angstrom")
1655 IF (reftraj_env%isnap /= (simpar%nsteps - 1))
THEN
1656 CALL cp_abort(__location__, &
1657 "Reached the end of the Trajectory frames in the TRAJECTORY file. Number of "// &
1658 "missing frames ("//cp_to_string((simpar%nsteps - 1) - reftraj_env%isnap)//
").")
1663 IF (reftraj_env%info%variable_volume .AND. (.NOT. traj_has_cell_info))
THEN
1664 CALL parser_get_next_line(reftraj_env%info%cell_parser, 1, at_end=my_end)
1665 CALL parse_cell_line(reftraj_env%info%cell_parser%input_line, cell_itimes, cell_time, h, vol)
1666 cpassert(trj_itimes == cell_itimes)
1669 IF (reftraj_env%isnap /= (simpar%nsteps - 1))
THEN
1670 CALL cp_abort(__location__, &
1671 "Reached the end of the cell info frames in the CELL file. Number of "// &
1672 "missing frames ("//cp_to_string((simpar%nsteps - 1) - reftraj_env%isnap)//
").")
1678 reftraj_env%time0 = trj_time
1679 reftraj_env%epot0 = trj_epot
1680 reftraj_env%itimes0 = trj_itimes
1683 IF (trj_itimes /= 0.0_dp .AND. trj_time /= 0.0_dp) simpar%dt = (trj_time/femtoseconds)/real(trj_itimes, kind=dp)
1685 reftraj_env%epot = trj_epot
1686 reftraj_env%itimes = trj_itimes
1687 reftraj_env%time = trj_time/femtoseconds
1688 CALL get_md_env(md_env, t=time)
1689 time = reftraj_env%time
1691 IF (traj_has_cell_info)
THEN
1692 CALL init_cell(cell)
1693 ELSE IF (reftraj_env%info%variable_volume)
THEN
1695 CALL init_cell(cell)
1699 SELECT CASE (reftraj_env%info%wrap)
1700 CASE (reftraj_wrap_none)
1702 CASE (reftraj_wrap_positive)
1705 particle_set(i)%r(1:3) = pbc(particle_set(i)%r(1:3), cell, positive_range=.true.)
1707 CASE (reftraj_wrap_central)
1710 particle_set(i)%r(1:3) = pbc(particle_set(i)%r(1:3), cell)
1714 cpabort(
"Option invalid or unavailable for reftraj_env%info%wrap")
1718 CALL qmmmx_update_force_env(force_env, force_env%root_section)
1724 CALL force_env_calc_energy_force(force_env, &
1725 calc_force=(reftraj_env%info%eval == reftraj_eval_energy_forces), &
1726 eval_energy_forces=(reftraj_env%info%eval /= reftraj_eval_none), &
1727 require_consistent_energy_force=.false.)
1730 CALL metadyn_integrator(force_env, trj_itimes)
1733 IF (reftraj_env%info%msd)
THEN
1734 CALL compute_msd_reftraj(reftraj_env, md_env, particle_set)
1738 CALL parser_get_next_line(reftraj_env%info%traj_parser, (reftraj_env%info%stride - 1)*(nparticle + 2))
1739 IF (reftraj_env%info%variable_volume)
THEN
1740 CALL parser_get_next_line(reftraj_env%info%cell_parser, (reftraj_env%info%stride - 1))
1757 TYPE(md_environment_type),
POINTER :: md_env
1759 REAL(dp),
PARAMETER :: e2 = 1._dp/6._dp, e4 = e2/20._dp, &
1760 e6 = e4/42._dp, e8 = e6/72._dp
1762 INTEGER :: iroll, nparticle, nparticle_kind, nshell
1763 INTEGER,
POINTER :: itimes
1764 LOGICAL :: first, first_time, shell_adiabatic, &
1766 REAL(kind=dp) :: dt, infree, kin, roll_tol, roll_tol_thrs
1767 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
1768 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
1769 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1770 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1771 TYPE(cell_type),
POINTER :: cell
1772 TYPE(cp_subsys_type),
POINTER :: subsys
1773 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
1774 TYPE(force_env_type),
POINTER :: force_env
1775 TYPE(global_constraint_type),
POINTER :: gci
1776 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
1777 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
1778 TYPE(molecule_list_type),
POINTER :: molecules
1779 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1780 TYPE(mp_para_env_type),
POINTER :: para_env
1781 TYPE(npt_info_type),
POINTER :: npt(:, :)
1782 TYPE(old_variables_type),
POINTER :: old
1783 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1785 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
1787 TYPE(simpar_type),
POINTER :: simpar
1788 TYPE(tmp_variables_type),
POINTER :: tmp
1789 TYPE(virial_type),
POINTER :: virial
1791 NULLIFY (gci, force_env)
1792 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
1793 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
1794 NULLIFY (core_particles, particles, shell_particles, tmp, old)
1795 NULLIFY (core_particle_set, particle_set, shell_particle_set)
1796 NULLIFY (simpar, virial, itimes)
1798 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, npt=npt, &
1799 first_time=first_time, para_env=para_env, itimes=itimes)
1801 infree = 1.0_dp/real(simpar%nfree, dp)
1803 CALL force_env_get(force_env, subsys=subsys, cell=cell)
1806 CALL apply_qmmm_walls_reflective(force_env)
1808 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1809 particles=particles, local_molecules=local_molecules, molecules=molecules, gci=gci, &
1810 molecule_kinds=molecule_kinds, virial=virial)
1812 nparticle_kind = atomic_kinds%n_els
1813 atomic_kind_set => atomic_kinds%els
1814 molecule_kind_set => molecule_kinds%els
1816 nparticle = particles%n_els
1817 particle_set => particles%els
1818 molecule_set => molecules%els
1820 IF (first_time)
THEN
1821 CALL virial_evaluate(atomic_kind_set, particle_set, &
1822 local_particles, virial, para_env)
1825 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1826 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
1829 CALL allocate_old(old, particle_set, npt)
1831 IF (shell_present)
THEN
1832 CALL cp_subsys_get(subsys=subsys, &
1833 shell_particles=shell_particles, core_particles=core_particles)
1834 shell_particle_set => shell_particles%els
1835 nshell =
SIZE(shell_particles%els)
1836 IF (shell_adiabatic)
THEN
1837 core_particle_set => core_particles%els
1841 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1843 IF (simpar%constraint)
THEN
1845 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1846 molecule_kind_set, dt, force_env%root_section)
1850 IF (simpar%constraint)
THEN
1851 roll_tol_thrs = simpar%roll_tol
1853 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
1854 CALL getold(gci, local_molecules, molecule_set, &
1855 molecule_kind_set, particle_set, cell)
1857 roll_tol_thrs = epsilon(0.0_dp)
1859 roll_tol = -roll_tol_thrs
1861 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1863 IF (simpar%constraint)
THEN
1864 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
1866 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
1867 local_molecules, molecule_set, molecule_kind_set, &
1868 local_particles, kin, pv_kin, virial, para_env)
1869 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1871 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
1872 (0.5_dp*npt(1, 1)%v*dt)
1873 tmp%poly_r(1) = 1._dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
1874 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
1875 tmp%poly_r(2) = 1.0_dp
1876 tmp%poly_r(3) = 1.0_dp
1878 tmp%arg_v(1) = (0.25_dp*npt(1, 1)%v*dt* &
1879 (1._dp + infree))*(0.25_dp*npt(1, 1)%v* &
1880 dt*(1._dp + infree))
1881 tmp%arg_v(2) = (0.25_dp*npt(1, 1)%v*dt*infree)* &
1882 (0.25_dp*npt(1, 1)%v*dt*infree)
1883 tmp%poly_v(1) = 1._dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
1884 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
1885 tmp%poly_v(2) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
1886 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
1887 tmp%poly_v(3) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
1888 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
1890 tmp%scale_r(1) = exp(0.5_dp*dt*npt(1, 1)%v)
1891 tmp%scale_r(2) = 1.0_dp
1892 tmp%scale_r(3) = 1.0_dp
1894 tmp%scale_v(1) = exp(-0.25_dp*dt*npt(1, 1)%v* &
1896 tmp%scale_v(2) = exp(-0.25_dp*dt*npt(1, 1)%v*infree)
1897 tmp%scale_v(3) = exp(-0.25_dp*dt*npt(1, 1)%v*infree)
1900 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1901 core_particle_set, shell_particle_set, nparticle_kind, &
1902 shell_adiabatic, dt)
1904 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
1905 atomic_kind_set, local_particles, particle_set, core_particle_set, &
1906 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
1910 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
1911 vector_r(1) = tmp%scale_r(1)*tmp%poly_r(1)
1913 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
1914 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
1915 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
1916 local_particles=local_particles)
1920 cell%hmat(1, 1) = cell%hmat(1, 1)*tmp%scale_r(1)*tmp%scale_r(1)
1923 CALL init_cell(cell)
1926 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1927 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1930 CALL force_env_calc_energy_force(force_env)
1933 CALL metadyn_integrator(force_env, itimes, tmp%vel)
1936 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1937 core_particle_set, shell_particle_set, nparticle_kind, &
1938 shell_adiabatic, dt)
1940 IF (simpar%constraint)
THEN
1941 roll_tol_thrs = simpar%roll_tol
1944 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
1946 roll_tol_thrs = epsilon(0.0_dp)
1948 roll_tol = -roll_tol_thrs
1950 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1952 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
1953 particle_set, local_particles, molecule_kind_set, molecule_set, &
1954 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
1955 roll_tol, iroll, infree, first, para_env)
1957 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
1958 local_molecules, molecule_set, molecule_kind_set, &
1959 local_particles, kin, pv_kin, virial, para_env)
1960 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1963 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
1966 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1967 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1970 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1971 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1973 CALL virial_evaluate(atomic_kind_set, particle_set, &
1974 local_particles, virial, para_env)
1977 CALL deallocate_old(old)
1979 IF (first_time)
THEN
1980 first_time = .false.
1981 CALL set_md_env(md_env, first_time=first_time)
2000 TYPE(md_environment_type),
POINTER :: md_env
2002 REAL(dp),
PARAMETER :: e2 = 1._dp/6._dp, e4 = e2/20._dp, &
2003 e6 = e4/42._dp, e8 = e6/72._dp
2005 INTEGER :: iroll, nparticle, nparticle_kind, nshell
2006 INTEGER,
POINTER :: itimes
2007 LOGICAL :: first, first_time, shell_adiabatic, &
2009 REAL(kind=dp) :: aa, aax, dt, gamma1, infree, kin, &
2010 roll_tol, roll_tol_thrs
2011 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
2012 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
2013 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2014 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2015 TYPE(cell_type),
POINTER :: cell
2016 TYPE(cp_subsys_type),
POINTER :: subsys
2017 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2018 TYPE(force_env_type),
POINTER :: force_env
2019 TYPE(global_constraint_type),
POINTER :: gci
2020 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2021 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2022 TYPE(molecule_list_type),
POINTER :: molecules
2023 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2024 TYPE(mp_para_env_type),
POINTER :: para_env
2025 TYPE(npt_info_type),
POINTER :: npt(:, :)
2026 TYPE(old_variables_type),
POINTER :: old
2027 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
2029 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
2031 TYPE(simpar_type),
POINTER :: simpar
2032 TYPE(tmp_variables_type),
POINTER :: tmp
2033 TYPE(virial_type),
POINTER :: virial
2035 NULLIFY (gci, force_env)
2036 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
2037 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
2038 NULLIFY (core_particles, particles, shell_particles, tmp, old)
2039 NULLIFY (core_particle_set, particle_set, shell_particle_set)
2040 NULLIFY (simpar, virial, itimes)
2042 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, npt=npt, &
2043 first_time=first_time, para_env=para_env, itimes=itimes)
2045 infree = 1.0_dp/real(simpar%nfree, dp)
2046 gamma1 = simpar%gamma_nph
2048 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2050 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2051 particles=particles, local_molecules=local_molecules, molecules=molecules, gci=gci, &
2052 molecule_kinds=molecule_kinds, virial=virial)
2054 nparticle_kind = atomic_kinds%n_els
2055 atomic_kind_set => atomic_kinds%els
2056 molecule_kind_set => molecule_kinds%els
2058 nparticle = particles%n_els
2059 particle_set => particles%els
2060 molecule_set => molecules%els
2062 IF (first_time)
THEN
2063 CALL virial_evaluate(atomic_kind_set, particle_set, &
2064 local_particles, virial, para_env)
2067 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
2068 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
2071 CALL allocate_old(old, particle_set, npt)
2073 IF (shell_present)
THEN
2074 CALL cp_subsys_get(subsys=subsys, &
2075 shell_particles=shell_particles, core_particles=core_particles)
2076 shell_particle_set => shell_particles%els
2077 nshell =
SIZE(shell_particles%els)
2078 IF (shell_adiabatic)
THEN
2079 core_particle_set => core_particles%els
2083 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
2086 CALL damp_v(molecule_kind_set, molecule_set, particle_set, local_molecules, &
2087 gamma1, npt(1, 1), dt, para_env)
2089 IF (simpar%constraint)
THEN
2091 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2092 molecule_kind_set, dt, force_env%root_section)
2096 IF (simpar%constraint)
THEN
2097 roll_tol_thrs = simpar%roll_tol
2099 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
2100 CALL getold(gci, local_molecules, molecule_set, &
2101 molecule_kind_set, particle_set, cell)
2103 roll_tol_thrs = epsilon(0.0_dp)
2105 roll_tol = -roll_tol_thrs
2107 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2110 CALL damp_veps(npt(1, 1), gamma1, dt)
2112 IF (simpar%constraint)
THEN
2113 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
2115 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
2116 local_molecules, molecule_set, molecule_kind_set, &
2117 local_particles, kin, pv_kin, virial, para_env)
2118 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
2121 CALL damp_veps(npt(1, 1), gamma1, dt)
2123 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
2124 (0.5_dp*npt(1, 1)%v*dt)
2125 tmp%poly_r(1) = 1._dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
2126 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
2128 aax = npt(1, 1)%v*(1.0_dp + infree)
2129 tmp%arg_v(1) = (0.25_dp*dt*aax)*(0.25_dp*dt*aax)
2130 tmp%poly_v(1) = 1._dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
2131 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
2133 aa = npt(1, 1)%v*infree
2134 tmp%arg_v(2) = (0.25_dp*dt*aa)*(0.25_dp*dt*aa)
2135 tmp%poly_v(2) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
2136 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
2137 tmp%poly_v(3) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
2138 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
2140 tmp%scale_r(1) = exp(0.5_dp*dt*npt(1, 1)%v)
2141 tmp%scale_v(1) = exp(-0.25_dp*dt*aax)
2142 tmp%scale_v(2) = exp(-0.25_dp*dt*aa)
2143 tmp%scale_v(3) = exp(-0.25_dp*dt*aa)
2146 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
2147 core_particle_set, shell_particle_set, nparticle_kind, &
2148 shell_adiabatic, dt)
2150 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
2151 atomic_kind_set, local_particles, particle_set, core_particle_set, &
2152 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
2156 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
2157 vector_r(1) = tmp%scale_r(1)*tmp%poly_r(1)
2159 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
2160 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
2161 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
2162 local_particles=local_particles)
2166 cell%hmat(1, 1) = cell%hmat(1, 1)*tmp%scale_r(1)*tmp%scale_r(1)
2169 CALL init_cell(cell)
2172 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2173 core_particle_set, para_env, shell_adiabatic, pos=.true.)
2176 CALL force_env_calc_energy_force(force_env)
2179 CALL metadyn_integrator(force_env, itimes, tmp%vel)
2182 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
2183 core_particle_set, shell_particle_set, nparticle_kind, &
2184 shell_adiabatic, dt)
2186 IF (simpar%constraint)
THEN
2187 roll_tol_thrs = simpar%roll_tol
2190 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
2192 roll_tol_thrs = epsilon(0.0_dp)
2194 roll_tol = -roll_tol_thrs
2196 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2198 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
2199 particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, &
2200 tmp%vel, dt, cell, npt, simpar, virial, vector_v, roll_tol, iroll, infree, first, &
2203 CALL damp_veps(npt(1, 1), gamma1, dt)
2205 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
2206 local_molecules, molecule_set, molecule_kind_set, &
2207 local_particles, kin, pv_kin, virial, para_env)
2208 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
2211 CALL damp_veps(npt(1, 1), gamma1, dt)
2216 CALL damp_v(molecule_kind_set, molecule_set, particle_set, local_molecules, &
2217 tmp%vel, gamma1, npt(1, 1), dt, para_env)
2219 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
2222 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2223 core_particle_set, para_env, shell_adiabatic, vel=.true.)
2226 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
2227 molecule_set, molecule_kind_set, particle_set, virial, para_env)
2229 CALL virial_evaluate(atomic_kind_set, particle_set, &
2230 local_particles, virial, para_env)
2233 CALL deallocate_old(old)
2235 IF (first_time)
THEN
2236 first_time = .false.
2237 CALL set_md_env(md_env, first_time=first_time)
2252 TYPE(md_environment_type),
POINTER :: md_env
2253 TYPE(global_environment_type),
POINTER :: globenv
2255 REAL(kind=dp),
PARAMETER :: e2 = 1.0_dp/6.0_dp, e4 = e2/20.0_dp, &
2256 e6 = e4/42.0_dp, e8 = e6/72.0_dp
2258 INTEGER :: i, iroll, j, nparticle, nparticle_kind, &
2260 INTEGER,
POINTER :: itimes
2261 LOGICAL :: first, first_time, shell_adiabatic, &
2262 shell_check_distance, shell_present
2263 REAL(kind=dp) :: dt, infree, kin, roll_tol, &
2265 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
2266 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin, uh
2267 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2268 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2269 TYPE(barostat_type),
POINTER :: barostat
2270 TYPE(cell_type),
POINTER :: cell
2271 TYPE(cp_subsys_type),
POINTER :: subsys
2272 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2273 TYPE(force_env_type),
POINTER :: force_env
2274 TYPE(global_constraint_type),
POINTER :: gci
2275 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2276 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2277 TYPE(molecule_list_type),
POINTER :: molecules
2278 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2279 TYPE(mp_para_env_type),
POINTER :: para_env
2280 TYPE(npt_info_type),
POINTER :: npt(:, :)
2281 TYPE(old_variables_type),
POINTER :: old
2282 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
2284 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
2286 TYPE(simpar_type),
POINTER :: simpar
2287 TYPE(thermostat_type),
POINTER :: thermostat_baro, thermostat_part, &
2289 TYPE(tmp_variables_type),
POINTER :: tmp
2290 TYPE(virial_type),
POINTER :: virial
2292 NULLIFY (gci, thermostat_baro, thermostat_part, thermostat_shell, force_env)
2293 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
2294 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt, barostat)
2295 NULLIFY (core_particles, particles, shell_particles, tmp, old)
2296 NULLIFY (core_particle_set, particle_set, shell_particle_set)
2297 NULLIFY (simpar, virial, itimes)
2299 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
2300 thermostat_part=thermostat_part, thermostat_baro=thermostat_baro, &
2301 thermostat_shell=thermostat_shell, npt=npt, first_time=first_time, &
2302 para_env=para_env, barostat=barostat, itimes=itimes)
2304 infree = 1.0_dp/real(simpar%nfree, kind=dp)
2306 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2309 CALL apply_qmmm_walls_reflective(force_env)
2311 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2312 particles=particles, local_molecules=local_molecules, molecules=molecules, &
2313 gci=gci, molecule_kinds=molecule_kinds, virial=virial)
2315 nparticle_kind = atomic_kinds%n_els
2316 atomic_kind_set => atomic_kinds%els
2317 molecule_kind_set => molecule_kinds%els
2319 nparticle = particles%n_els
2320 particle_set => particles%els
2321 molecule_set => molecules%els
2323 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
2324 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
2325 shell_check_distance=shell_check_distance)
2327 IF (first_time)
THEN
2328 CALL virial_evaluate(atomic_kind_set, particle_set, &
2329 local_particles, virial, para_env)
2333 CALL allocate_old(old, particle_set, npt)
2335 IF (shell_present)
THEN
2336 CALL cp_subsys_get(subsys=subsys, &
2337 shell_particles=shell_particles, core_particles=core_particles)
2338 shell_particle_set => shell_particles%els
2339 nshell =
SIZE(shell_particles%els)
2340 IF (shell_adiabatic)
THEN
2341 core_particle_set => core_particles%els
2345 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
2348 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
2351 IF (simpar%ensemble /= npe_f_ensemble)
THEN
2352 IF (shell_adiabatic)
THEN
2353 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2354 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
2355 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
2357 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2358 particle_set, local_molecules, local_particles, para_env)
2363 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
2364 local_particles, para_env, shell_particle_set=shell_particle_set, &
2365 core_particle_set=core_particle_set)
2367 IF (simpar%constraint)
THEN
2369 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2370 molecule_kind_set, dt, force_env%root_section)
2374 IF (simpar%constraint)
THEN
2375 roll_tol_thrs = simpar%roll_tol
2377 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
2378 CALL getold(gci, local_molecules, molecule_set, &
2379 molecule_kind_set, particle_set, cell)
2381 roll_tol_thrs = epsilon(0.0_dp)
2383 roll_tol = -roll_tol_thrs
2385 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2387 IF (simpar%constraint)
THEN
2388 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
2390 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
2391 local_molecules, molecule_set, molecule_kind_set, &
2392 local_particles, kin, pv_kin, virial, para_env)
2393 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree, &
2394 virial_components=barostat%virial_components)
2396 trvg = npt(1, 1)%v + npt(2, 2)%v + npt(3, 3)%v
2401 CALL diagonalise(matrix=npt(:, :)%v, mysize=3, &
2402 uplo=
"U", eigenvalues=tmp%e_val, eigenvectors=tmp%u)
2404 tmp%arg_r(:) = 0.5_dp*tmp%e_val(:)*dt* &
2405 0.5_dp*tmp%e_val(:)*dt
2406 tmp%poly_r = 1.0_dp + e2*tmp%arg_r + e4*tmp%arg_r*tmp%arg_r + &
2407 e6*tmp%arg_r**3 + e8*tmp%arg_r**4
2408 tmp%scale_r(:) = exp(0.5_dp*dt*tmp%e_val(:))
2410 tmp%arg_v(:) = 0.25_dp*dt*(tmp%e_val(:) + trvg*infree)* &
2411 0.25_dp*dt*(tmp%e_val(:) + trvg*infree)
2412 tmp%poly_v = 1.0_dp + e2*tmp%arg_v + e4*tmp%arg_v*tmp%arg_v + &
2413 e6*tmp%arg_v**3 + e8*tmp%arg_v**4
2414 tmp%scale_v(:) = exp(-0.25_dp*dt*(tmp%e_val(:) + trvg*infree))
2416 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
2417 core_particle_set, shell_particle_set, nparticle_kind, &
2418 shell_adiabatic, dt, u=tmp%u)
2420 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
2421 atomic_kind_set, local_particles, particle_set, core_particle_set, &
2422 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
2425 vector_r = tmp%scale_r*tmp%poly_r
2426 vector_v = tmp%scale_v*tmp%poly_v
2428 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
2429 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, &
2430 simpar, roll_tol, iroll, vector_r, vector_v, &
2431 para_env, u=tmp%u, cell=cell, &
2432 local_particles=local_particles)
2436 uh = matmul(transpose(tmp%u), cell%hmat)
2440 uh(i, j) = uh(i, j)*tmp%scale_r(i)*tmp%scale_r(i)
2444 cell%hmat = matmul(tmp%u, uh)
2446 CALL init_cell(cell)
2449 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2450 core_particle_set, para_env, shell_adiabatic, pos=.true.)
2452 IF (shell_adiabatic .AND. shell_check_distance)
THEN
2453 CALL optimize_shell_core(force_env, particle_set, &
2454 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
2458 CALL force_env_calc_energy_force(force_env)
2461 CALL metadyn_integrator(force_env, itimes, tmp%vel)
2464 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
2465 core_particle_set, shell_particle_set, nparticle_kind, &
2466 shell_adiabatic, dt, tmp%u)
2468 IF (simpar%constraint)
THEN
2469 roll_tol_thrs = simpar%roll_tol
2472 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
2474 roll_tol_thrs = epsilon(0.0_dp)
2476 roll_tol = -roll_tol_thrs
2478 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2480 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
2481 particle_set, local_particles, molecule_kind_set, molecule_set, &
2482 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
2483 roll_tol, iroll, infree, first, para_env, u=tmp%u)
2485 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
2486 local_molecules, molecule_set, molecule_kind_set, &
2487 local_particles, kin, pv_kin, virial, para_env)
2488 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree, &
2489 virial_components=barostat%virial_components)
2493 IF (simpar%ensemble /= npe_f_ensemble)
THEN
2494 IF (shell_adiabatic)
THEN
2495 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2496 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
2497 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
2500 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2501 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
2506 IF (
ASSOCIATED(thermostat_shell))
THEN
2507 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
2508 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
2509 core_vel=tmp%core_vel)
2513 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
2516 IF (simpar%ensemble == npe_f_ensemble .AND. simpar%annealing)
THEN
2517 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
2518 IF (shell_adiabatic)
THEN
2519 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
2520 tmp%vel, tmp%shell_vel, tmp%core_vel)
2524 IF (simpar%ensemble == npe_f_ensemble .AND. simpar%annealing_cell)
THEN
2525 npt(:, :)%v = npt(:, :)%v*simpar%f_annealing_cell
2529 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2530 core_particle_set, para_env, shell_adiabatic, vel=.true.)
2533 IF (simpar%constraint)
THEN
2534 CALL pv_constraint(gci, local_molecules, molecule_set, &
2535 molecule_kind_set, particle_set, virial, para_env)
2538 CALL virial_evaluate(atomic_kind_set, particle_set, &
2539 local_particles, virial, para_env)
2542 CALL deallocate_old(old)
2544 IF (first_time)
THEN
2545 first_time = .false.
2546 CALL set_md_env(md_env, first_time=first_time)
2549 END SUBROUTINE npt_f
2558 TYPE(md_environment_type),
POINTER :: md_env
2560 INTEGER :: i_step, iparticle, iparticle_kind, &
2561 iparticle_local, n_time_steps, &
2562 nparticle, nparticle_kind, &
2564 INTEGER,
POINTER :: itimes
2565 REAL(kind=dp) :: dm, dt, mass
2566 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: pos, vel
2567 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2568 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2569 TYPE(atomic_kind_type),
POINTER :: atomic_kind
2570 TYPE(cell_type),
POINTER :: cell
2571 TYPE(cp_subsys_type),
POINTER :: subsys, subsys_respa
2572 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2573 TYPE(force_env_type),
POINTER :: force_env
2574 TYPE(global_constraint_type),
POINTER :: gci
2575 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2576 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2577 TYPE(molecule_list_type),
POINTER :: molecules
2578 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2579 TYPE(mp_para_env_type),
POINTER :: para_env
2580 TYPE(particle_list_type),
POINTER :: particles, particles_respa
2581 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set, particle_set_respa
2582 TYPE(simpar_type),
POINTER :: simpar
2584 NULLIFY (para_env, cell, subsys_respa, particles_respa, particle_set_respa, gci, force_env, atomic_kinds)
2585 NULLIFY (atomic_kind_set, simpar, subsys, particles, particle_set)
2586 NULLIFY (local_molecules, molecule_kinds, molecules, molecule_kind_set, local_particles, itimes)
2587 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
2588 para_env=para_env, itimes=itimes)
2591 n_time_steps = simpar%n_time_steps
2593 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2594 CALL force_env_get(force_env%sub_force_env(1)%force_env, subsys=subsys_respa)
2597 CALL apply_qmmm_walls_reflective(force_env)
2599 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2600 particles=particles, local_molecules=local_molecules, molecules=molecules, &
2601 gci=gci, molecule_kinds=molecule_kinds)
2603 CALL cp_subsys_get(subsys=subsys_respa, particles=particles_respa)
2604 particle_set_respa => particles_respa%els
2606 nparticle_kind = atomic_kinds%n_els
2607 atomic_kind_set => atomic_kinds%els
2608 molecule_kind_set => molecule_kinds%els
2610 nparticle = particles%n_els
2611 particle_set => particles%els
2612 molecule_set => molecules%els
2615 ALLOCATE (pos(3, nparticle))
2616 ALLOCATE (vel(3, nparticle))
2619 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
2620 molecule_kind_set, particle_set, cell)
2623 DO iparticle_kind = 1, nparticle_kind
2624 atomic_kind => atomic_kind_set(iparticle_kind)
2625 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2627 nparticle_local = local_particles%n_el(iparticle_kind)
2628 DO iparticle_local = 1, nparticle_local
2629 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2630 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
2631 dm*(particle_set(iparticle)%f(:) - &
2632 particle_set_respa(iparticle)%f(:))
2637 DO i_step = 1, n_time_steps
2639 DO iparticle_kind = 1, nparticle_kind
2640 atomic_kind => atomic_kind_set(iparticle_kind)
2641 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2642 dm = 0.5_dp*dt/(n_time_steps*mass)
2643 nparticle_local = local_particles%n_el(iparticle_kind)
2644 DO iparticle_local = 1, nparticle_local
2645 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2646 vel(:, iparticle) = vel(:, iparticle) + &
2647 dm*particle_set_respa(iparticle)%f(:)
2648 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
2649 (dt/n_time_steps)*vel(:, iparticle)
2653 IF (simpar%constraint)
THEN
2655 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2656 molecule_kind_set, dt, force_env%root_section)
2658 CALL shake_control(gci, local_molecules, molecule_set, &
2659 molecule_kind_set, particle_set, pos, vel, dt, simpar%shake_tol, &
2660 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, cell, &
2661 para_env, local_particles)
2665 CALL update_particle_set(particle_set, para_env, pos=pos)
2666 DO iparticle = 1,
SIZE(particle_set)
2667 particle_set_respa(iparticle)%r = particle_set(iparticle)%r
2671 CALL force_env_calc_energy_force(force_env%sub_force_env(1)%force_env)
2674 CALL metadyn_integrator(force_env, itimes, vel)
2677 DO iparticle_kind = 1, nparticle_kind
2678 atomic_kind => atomic_kind_set(iparticle_kind)
2679 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2680 dm = 0.5_dp*dt/(n_time_steps*mass)
2681 nparticle_local = local_particles%n_el(iparticle_kind)
2682 DO iparticle_local = 1, nparticle_local
2683 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2684 vel(1, iparticle) = vel(1, iparticle) + dm*particle_set_respa(iparticle)%f(1)
2685 vel(2, iparticle) = vel(2, iparticle) + dm*particle_set_respa(iparticle)%f(2)
2686 vel(3, iparticle) = vel(3, iparticle) + dm*particle_set_respa(iparticle)%f(3)
2690 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
2691 molecule_kind_set, particle_set, vel, dt, simpar%shake_tol, &
2692 simpar%info_constraint, simpar%lagrange_multipliers, &
2693 simpar%dump_lm, cell, para_env, local_particles)
2695 IF (simpar%annealing) vel(:, :) = vel(:, :)*simpar%f_annealing
2701 CALL force_env_calc_energy_force(force_env)
2704 CALL metadyn_integrator(force_env, itimes, vel)
2706 DO iparticle_kind = 1, nparticle_kind
2707 atomic_kind => atomic_kind_set(iparticle_kind)
2708 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2710 nparticle_local = local_particles%n_el(iparticle_kind)
2711 DO iparticle_local = 1, nparticle_local
2712 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2713 vel(1, iparticle) = vel(1, iparticle) + dm*(particle_set(iparticle)%f(1) - particle_set_respa(iparticle)%f(1))
2714 vel(2, iparticle) = vel(2, iparticle) + dm*(particle_set(iparticle)%f(2) - particle_set_respa(iparticle)%f(2))
2715 vel(3, iparticle) = vel(3, iparticle) + dm*(particle_set(iparticle)%f(3) - particle_set_respa(iparticle)%f(3))
2720 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 ...
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, 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.
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.