107#include "../base/base_uses.f90"
113 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'integrator'
138 INTEGER :: iparticle, iparticle_kind, iparticle_local, iparticle_reg, ireg, nparticle, &
139 nparticle_kind, nparticle_local, nshell
140 INTEGER,
POINTER :: itimes
141 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: do_langevin
142 REAL(kind=
dp) :: c, c1, c2, c3, c4, dm, dt, gam, mass, &
143 noisy_gamma_region, reg_temp, sigma
144 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: var_w
145 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pos, vel, w
166 NULLIFY (cell, para_env, gci, force_env)
167 NULLIFY (atomic_kinds, local_particles, subsys, local_molecules, molecule_kinds, molecules)
168 NULLIFY (molecule_kind_set, molecule_set, particles, particle_set, simpar, virial)
169 NULLIFY (thermal_region, thermal_regions, itimes)
171 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
172 para_env=para_env, thermal_regions=thermal_regions, &
176 gam = simpar%gamma + simpar%shadow_gamma
179 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
185 atomic_kinds=atomic_kinds, &
187 local_particles=local_particles, &
188 local_molecules=local_molecules, &
189 molecules=molecules, &
190 molecule_kinds=molecule_kinds, &
192 particles=particles, &
195 cpabort(
"Langevin dynamics is not yet implemented for core-shell models")
197 nparticle_kind = atomic_kinds%n_els
198 atomic_kind_set => atomic_kinds%els
199 molecule_kind_set => molecule_kinds%els
201 nparticle = particles%n_els
202 particle_set => particles%els
203 molecule_set => molecules%els
206 ALLOCATE (do_langevin(nparticle))
207 IF (simpar%do_thermal_region)
THEN
208 DO iparticle = 1, nparticle
209 do_langevin(iparticle) = thermal_regions%do_langevin(iparticle)
212 do_langevin(1:nparticle) = .true.
223 ALLOCATE (var_w(nparticle))
224 var_w(1:nparticle) = simpar%var_w
225 IF (simpar%do_thermal_region)
THEN
226 DO ireg = 1, thermal_regions%nregions
227 thermal_region => thermal_regions%thermal_region(ireg)
228 noisy_gamma_region = thermal_region%noisy_gamma_region
229 DO iparticle_reg = 1, thermal_region%npart
230 iparticle = thermal_region%part_index(iparticle_reg)
231 reg_temp = thermal_region%temp_expected
232 var_w(iparticle) = 2.0_dp*reg_temp*simpar%dt*(simpar%gamma + noisy_gamma_region)
238 ALLOCATE (pos(3, nparticle))
241 ALLOCATE (vel(3, nparticle))
244 ALLOCATE (w(3, nparticle))
247 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
248 molecule_kind_set, particle_set, cell)
251 DO iparticle_kind = 1, nparticle_kind
252 atomic_kind => atomic_kind_set(iparticle_kind)
254 nparticle_local = local_particles%n_el(iparticle_kind)
255 DO iparticle_local = 1, nparticle_local
256 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
257 IF (do_langevin(iparticle))
THEN
258 sigma = var_w(iparticle)*mass
259 associate(rng_stream => local_particles%local_particle_set(iparticle_kind)% &
260 rng(iparticle_local))
261 w(1, iparticle) = rng_stream%stream%next(variance=sigma)
262 w(2, iparticle) = rng_stream%stream%next(variance=sigma)
263 w(3, iparticle) = rng_stream%stream%next(variance=sigma)
275 c = exp(-0.25_dp*dt*gam)
280 DO iparticle_kind = 1, nparticle_kind
281 atomic_kind => atomic_kind_set(iparticle_kind)
283 nparticle_local = local_particles%n_el(iparticle_kind)
286 DO iparticle_local = 1, nparticle_local
287 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
288 IF (do_langevin(iparticle))
THEN
289 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
290 c3*particle_set(iparticle)%f(:)
291 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
292 c1*particle_set(iparticle)%v(:) + &
293 c*dm*(dt*particle_set(iparticle)%f(:) + &
296 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
297 dm*particle_set(iparticle)%f(:)
298 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
299 dt*particle_set(iparticle)%v(:) + &
300 dm*dt*particle_set(iparticle)%f(:)
305 IF (simpar%constraint)
THEN
308 molecule_kind_set, dt, force_env%root_section)
310 CALL shake_control(gci, local_molecules, molecule_set, molecule_kind_set, &
311 particle_set, pos, vel, dt, simpar%shake_tol, &
312 simpar%info_constraint, simpar%lagrange_multipliers, &
313 simpar%dump_lm, cell, para_env, local_particles)
328 DO iparticle_kind = 1, nparticle_kind
329 atomic_kind => atomic_kind_set(iparticle_kind)
333 nparticle_local = local_particles%n_el(iparticle_kind)
334 DO iparticle_local = 1, nparticle_local
335 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
336 IF (do_langevin(iparticle))
THEN
337 vel(1, iparticle) = vel(1, iparticle) + c3*particle_set(iparticle)%f(1)
338 vel(2, iparticle) = vel(2, iparticle) + c3*particle_set(iparticle)%f(2)
339 vel(3, iparticle) = vel(3, iparticle) + c3*particle_set(iparticle)%f(3)
340 vel(1, iparticle) = c4*vel(1, iparticle) + c2*w(1, iparticle)/mass
341 vel(2, iparticle) = c4*vel(2, iparticle) + c2*w(2, iparticle)/mass
342 vel(3, iparticle) = c4*vel(3, iparticle) + c2*w(3, iparticle)/mass
344 vel(1, iparticle) = vel(1, iparticle) + dm*particle_set(iparticle)%f(1)
345 vel(2, iparticle) = vel(2, iparticle) + dm*particle_set(iparticle)%f(2)
346 vel(3, iparticle) = vel(3, iparticle) + dm*particle_set(iparticle)%f(3)
351 IF (simpar%temperature_annealing)
THEN
352 simpar%temp_ext = simpar%temp_ext*simpar%f_temperature_annealing
353 simpar%var_w = simpar%var_w*simpar%f_temperature_annealing
356 IF (simpar%constraint)
THEN
357 CALL rattle_control(gci, local_molecules, molecule_set, molecule_kind_set, &
358 particle_set, vel, dt, simpar%shake_tol, &
359 simpar%info_constraint, simpar%lagrange_multipliers, &
360 simpar%dump_lm, cell, para_env, local_particles)
370 DEALLOCATE (do_langevin)
373 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, molecule_set, &
374 molecule_kind_set, particle_set, virial, para_env)
390 SUBROUTINE nve(md_env, globenv)
392 TYPE(md_environment_type),
POINTER :: md_env
393 TYPE(global_environment_type),
POINTER :: globenv
395 INTEGER :: i_iter, n_iter, nparticle, &
396 nparticle_kind, nshell
397 INTEGER,
POINTER :: itimes
398 LOGICAL :: deallocate_vel, ehrenfest_md, &
399 shell_adiabatic, shell_check_distance, &
402 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: v_old
403 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
404 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
405 TYPE(cell_type),
POINTER :: cell
406 TYPE(cp_subsys_type),
POINTER :: subsys
407 TYPE(dft_control_type),
POINTER :: dft_control
408 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
409 TYPE(force_env_type),
POINTER :: force_env
410 TYPE(global_constraint_type),
POINTER :: gci
411 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
412 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
413 TYPE(molecule_list_type),
POINTER :: molecules
414 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
415 TYPE(mp_para_env_type),
POINTER :: para_env
416 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
418 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
420 TYPE(rt_prop_type),
POINTER :: rtp
421 TYPE(simpar_type),
POINTER :: simpar
422 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_shell
423 TYPE(tmp_variables_type),
POINTER :: tmp
424 TYPE(virial_type),
POINTER :: virial
426 NULLIFY (thermostat_coeff, tmp)
427 NULLIFY (subsys, simpar, para_env, cell, gci, force_env, virial)
428 NULLIFY (atomic_kinds, local_particles, molecules, molecule_kind_set, molecule_set, particle_set)
429 NULLIFY (shell_particles, shell_particle_set, core_particles, &
430 core_particle_set, thermostat_shell, dft_control, itimes)
431 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
432 thermostat_coeff=thermostat_coeff, thermostat_shell=thermostat_shell, &
433 para_env=para_env, ehrenfest_md=ehrenfest_md, itimes=itimes)
435 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
438 CALL apply_qmmm_walls_reflective(force_env)
440 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
441 particles=particles, local_molecules=local_molecules, molecules=molecules, &
442 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
444 nparticle_kind = atomic_kinds%n_els
445 atomic_kind_set => atomic_kinds%els
446 molecule_kind_set => molecule_kinds%els
448 nparticle = particles%n_els
449 particle_set => particles%els
450 molecule_set => molecules%els
452 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
453 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
454 shell_check_distance=shell_check_distance)
456 IF (shell_present)
THEN
457 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
458 core_particles=core_particles)
459 shell_particle_set => shell_particles%els
460 nshell =
SIZE(shell_particles%els)
462 IF (shell_adiabatic)
THEN
463 core_particle_set => core_particles%els
467 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
470 IF (shell_adiabatic)
THEN
471 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
472 local_particles, para_env, shell_particle_set=shell_particle_set, &
473 core_particle_set=core_particle_set)
476 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
477 molecule_kind_set, particle_set, cell)
480 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
481 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
483 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
484 local_particles, particle_set, core_particle_set, shell_particle_set, &
485 nparticle_kind, shell_adiabatic)
487 IF (simpar%constraint)
THEN
489 CALL shake_update_targets(gci, local_molecules, molecule_set, &
490 molecule_kind_set, dt, force_env%root_section)
492 CALL shake_control(gci, local_molecules, molecule_set, &
493 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
494 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
495 cell, para_env, local_particles)
499 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
500 core_particle_set, para_env, shell_adiabatic, pos=.true.)
502 IF (shell_adiabatic .AND. shell_check_distance)
THEN
503 CALL optimize_shell_core(force_env, particle_set, &
504 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
509 IF (ehrenfest_md)
THEN
510 ALLOCATE (v_old(3,
SIZE(tmp%vel, 2)))
511 v_old(:, :) = tmp%vel
512 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
513 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
514 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
515 core_particle_set, para_env, shell_adiabatic, vel=.true., &
516 should_deall_vel=.false.)
518 CALL get_qs_env(force_env%qs_env, dft_control=dft_control)
519 n_iter = dft_control%rtp_control%max_iter
524 DO i_iter = 1, n_iter
526 IF (ehrenfest_md)
THEN
527 CALL get_qs_env(qs_env=force_env%qs_env, rtp=rtp)
530 CALL propagation_step(force_env%qs_env, rtp, dft_control%rtp_control)
534 CALL force_env_calc_energy_force(force_env, require_consistent_energy_force=.false.)
536 IF (ehrenfest_md)
THEN
537 CALL rt_prop_output(force_env%qs_env, ehrenfest, delta_iter=force_env%qs_env%rtp%delta_iter)
541 CALL metadyn_integrator(force_env, itimes, tmp%vel)
544 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
545 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
547 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
548 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
549 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
550 cell, para_env, local_particles)
553 IF (shell_adiabatic)
THEN
554 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
555 local_particles, para_env, vel=tmp%vel, &
556 shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
559 IF (simpar%annealing)
THEN
560 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
561 IF (shell_adiabatic)
THEN
562 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
563 tmp%vel, tmp%shell_vel, tmp%core_vel)
567 IF (ehrenfest_md) deallocate_vel = force_env%qs_env%rtp%converged
568 IF (i_iter == n_iter) deallocate_vel = .true.
570 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
571 core_particle_set, para_env, shell_adiabatic, vel=.true., &
572 should_deall_vel=deallocate_vel)
573 IF (ehrenfest_md)
THEN
574 IF (force_env%qs_env%rtp%converged)
EXIT
580 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
581 molecule_set, molecule_kind_set, particle_set, virial, para_env)
583 CALL virial_evaluate(atomic_kind_set, particle_set, &
584 local_particles, virial, para_env)
604 TYPE(md_environment_type),
POINTER :: md_env
606 INTEGER :: nparticle, nparticle_kind, nshell
607 INTEGER,
POINTER :: itimes
608 LOGICAL :: shell_adiabatic, shell_present
610 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
611 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
612 TYPE(cp_subsys_type),
POINTER :: subsys
613 TYPE(distribution_1d_type),
POINTER :: local_particles
614 TYPE(force_env_type),
POINTER :: force_env
615 TYPE(mp_para_env_type),
POINTER :: para_env
616 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
618 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
620 TYPE(simpar_type),
POINTER :: simpar
621 TYPE(tmp_variables_type),
POINTER :: tmp
623 NULLIFY (force_env, tmp, simpar, itimes)
624 NULLIFY (atomic_kinds, para_env, subsys, local_particles)
625 NULLIFY (core_particles, particles, shell_particles)
626 NULLIFY (core_particle_set, particle_set, shell_particle_set)
628 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
629 para_env=para_env, itimes=itimes)
633 CALL force_env_get(force_env=force_env, subsys=subsys)
636 CALL apply_qmmm_walls_reflective(force_env)
638 IF (simpar%constraint)
THEN
639 cpabort(
"Constraints not yet implemented")
642 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, &
643 local_particles=local_particles, &
646 nparticle_kind = atomic_kinds%n_els
647 atomic_kind_set => atomic_kinds%els
648 nparticle = particles%n_els
649 particle_set => particles%els
651 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
652 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
654 IF (shell_present)
THEN
655 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
656 core_particles=core_particles)
657 shell_particle_set => shell_particles%els
658 nshell =
SIZE(shell_particles%els)
660 IF (shell_adiabatic)
THEN
661 core_particle_set => core_particles%els
665 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
668 CALL get_s_ds(tmp, nparticle_kind, atomic_kind_set, local_particles, particle_set, &
672 tmp%scale_v(1:3) = sqrt(1.0_dp/tmp%ds)
673 tmp%poly_v(1:3) = 2.0_dp*tmp%s/sqrt(tmp%ds)/dt
674 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
675 core_particle_set, shell_particle_set, nparticle_kind, &
678 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
679 local_particles, particle_set, core_particle_set, shell_particle_set, &
680 nparticle_kind, shell_adiabatic)
683 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
684 core_particle_set, para_env, shell_adiabatic, pos=.true.)
686 CALL force_env_calc_energy_force(force_env)
689 CALL metadyn_integrator(force_env, itimes, tmp%vel)
692 CALL get_s_ds(tmp, nparticle_kind, atomic_kind_set, local_particles, particle_set, &
693 dt, para_env, tmpv=.true.)
696 tmp%scale_v(1:3) = sqrt(1.0_dp/tmp%ds)
697 tmp%poly_v(1:3) = 2.0_dp*tmp%s/sqrt(tmp%ds)/dt
698 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
699 core_particle_set, shell_particle_set, nparticle_kind, &
702 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
705 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
706 core_particle_set, para_env, shell_adiabatic, vel=.true.)
720 TYPE(md_environment_type),
POINTER :: md_env
721 TYPE(global_environment_type),
POINTER :: globenv
723 INTEGER :: ivar, nparticle, nparticle_kind, nshell
724 INTEGER,
POINTER :: itimes
725 LOGICAL :: shell_adiabatic, shell_check_distance, &
728 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
729 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
730 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
731 TYPE(cell_type),
POINTER :: cell
732 TYPE(cp_subsys_type),
POINTER :: subsys
733 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
734 TYPE(force_env_type),
POINTER :: force_env
735 TYPE(global_constraint_type),
POINTER :: gci
736 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
737 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
738 TYPE(molecule_list_type),
POINTER :: molecules
739 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
740 TYPE(mp_para_env_type),
POINTER :: para_env
741 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
743 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
745 TYPE(simpar_type),
POINTER :: simpar
746 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_fast, &
747 thermostat_shell, thermostat_slow
748 TYPE(tmp_variables_type),
POINTER :: tmp
749 TYPE(virial_type),
POINTER :: virial
751 NULLIFY (gci, force_env, thermostat_coeff, tmp, &
752 thermostat_fast, thermostat_slow, thermostat_shell, cell, shell_particles, &
753 shell_particle_set, core_particles, core_particle_set, rand)
754 NULLIFY (para_env, subsys, local_molecules, local_particles, molecule_kinds, &
755 molecules, molecule_kind_set, molecule_set, atomic_kinds, particles)
756 NULLIFY (simpar, itimes)
758 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
759 thermostat_fast=thermostat_fast, thermostat_slow=thermostat_slow, &
760 thermostat_coeff=thermostat_coeff, thermostat_shell=thermostat_shell, &
761 para_env=para_env, itimes=itimes)
764 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
767 CALL apply_qmmm_walls_reflective(force_env)
769 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
770 particles=particles, local_molecules=local_molecules, molecules=molecules, &
771 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
773 nparticle_kind = atomic_kinds%n_els
774 atomic_kind_set => atomic_kinds%els
775 molecule_kind_set => molecule_kinds%els
777 nparticle = particles%n_els
778 particle_set => particles%els
779 molecule_set => molecules%els
781 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
782 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
783 shell_check_distance=shell_check_distance)
785 IF (
ASSOCIATED(force_env%meta_env))
THEN
787 IF (force_env%meta_env%langevin)
THEN
788 ALLOCATE (rand(force_env%meta_env%n_colvar))
794 IF (shell_present)
THEN
795 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
796 core_particles=core_particles)
797 shell_particle_set => shell_particles%els
798 nshell =
SIZE(shell_particles%els)
800 IF (shell_adiabatic)
THEN
801 core_particle_set => core_particles%els
805 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
808 IF (shell_adiabatic)
THEN
813 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
814 local_particles, para_env, shell_particle_set=shell_particle_set, &
815 core_particle_set=core_particle_set)
817 CALL apply_thermostat_particles(thermostat_fast, force_env, molecule_kind_set, molecule_set, &
818 particle_set, local_molecules, local_particles, para_env)
820 CALL apply_thermostat_particles(thermostat_slow, force_env, molecule_kind_set, molecule_set, &
821 particle_set, local_molecules, local_particles, para_env)
824 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
825 molecule_kind_set, particle_set, cell)
828 IF (
ASSOCIATED(force_env%meta_env))
THEN
829 IF (force_env%meta_env%langevin)
THEN
830 DO ivar = 1, force_env%meta_env%n_colvar
831 rand(ivar) = force_env%meta_env%rng(ivar)%next()
833 CALL metadyn_velocities_colvar(force_env, rand)
838 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
839 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
841 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
842 local_particles, particle_set, core_particle_set, shell_particle_set, &
843 nparticle_kind, shell_adiabatic)
845 IF (simpar%constraint)
THEN
847 CALL shake_update_targets(gci, local_molecules, molecule_set, &
848 molecule_kind_set, dt, force_env%root_section)
850 CALL shake_control(gci, local_molecules, molecule_set, &
851 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
852 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
853 cell, para_env, local_particles)
857 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
858 core_particle_set, para_env, shell_adiabatic, pos=.true.)
860 IF (shell_adiabatic .AND. shell_check_distance)
THEN
861 CALL optimize_shell_core(force_env, particle_set, &
862 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
866 CALL force_env_calc_energy_force(force_env)
869 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
872 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
873 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
875 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
876 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
877 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
878 cell, para_env, local_particles)
881 IF (shell_adiabatic)
THEN
886 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
887 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
888 core_vel=tmp%core_vel)
890 CALL apply_thermostat_particles(thermostat_slow, force_env, molecule_kind_set, molecule_set, &
891 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
893 CALL apply_thermostat_particles(thermostat_fast, force_env, molecule_kind_set, molecule_set, &
894 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
898 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
899 core_particle_set, para_env, shell_adiabatic, vel=.true.)
901 IF (
ASSOCIATED(force_env%meta_env))
THEN
902 IF (force_env%meta_env%langevin)
THEN
908 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
909 molecule_set, molecule_kind_set, particle_set, virial, para_env)
912 CALL virial_evaluate(atomic_kind_set, particle_set, &
913 local_particles, virial, para_env)
926 SUBROUTINE nvt(md_env, globenv)
928 TYPE(md_environment_type),
POINTER :: md_env
929 TYPE(global_environment_type),
POINTER :: globenv
931 INTEGER :: ivar, nparticle, nparticle_kind, nshell
932 INTEGER,
POINTER :: itimes
933 LOGICAL :: shell_adiabatic, shell_check_distance, &
936 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
937 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
938 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
939 TYPE(cell_type),
POINTER :: cell
940 TYPE(cp_subsys_type),
POINTER :: subsys
941 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
942 TYPE(force_env_type),
POINTER :: force_env
943 TYPE(global_constraint_type),
POINTER :: gci
944 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
945 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
946 TYPE(molecule_list_type),
POINTER :: molecules
947 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
948 TYPE(mp_para_env_type),
POINTER :: para_env
949 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
951 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
953 TYPE(simpar_type),
POINTER :: simpar
954 TYPE(thermostat_type),
POINTER :: thermostat_coeff, thermostat_part, &
956 TYPE(tmp_variables_type),
POINTER :: tmp
957 TYPE(virial_type),
POINTER :: virial
959 NULLIFY (gci, force_env, thermostat_coeff, tmp, &
960 thermostat_part, thermostat_shell, cell, shell_particles, &
961 shell_particle_set, core_particles, core_particle_set, rand)
962 NULLIFY (para_env, subsys, local_molecules, local_particles, molecule_kinds, &
963 molecules, molecule_kind_set, molecule_set, atomic_kinds, particles)
964 NULLIFY (simpar, thermostat_coeff, thermostat_part, thermostat_shell, itimes)
966 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
967 thermostat_part=thermostat_part, thermostat_coeff=thermostat_coeff, &
968 thermostat_shell=thermostat_shell, para_env=para_env, &
972 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
975 CALL apply_qmmm_walls_reflective(force_env)
977 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
978 particles=particles, local_molecules=local_molecules, molecules=molecules, &
979 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
981 nparticle_kind = atomic_kinds%n_els
982 atomic_kind_set => atomic_kinds%els
983 molecule_kind_set => molecule_kinds%els
985 nparticle = particles%n_els
986 particle_set => particles%els
987 molecule_set => molecules%els
989 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
990 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
991 shell_check_distance=shell_check_distance)
993 IF (
ASSOCIATED(force_env%meta_env))
THEN
995 IF (force_env%meta_env%langevin)
THEN
996 ALLOCATE (rand(force_env%meta_env%n_colvar))
1002 IF (shell_present)
THEN
1003 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
1004 core_particles=core_particles)
1005 shell_particle_set => shell_particles%els
1006 nshell =
SIZE(shell_particles%els)
1008 IF (shell_adiabatic)
THEN
1009 core_particle_set => core_particles%els
1013 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1016 IF (shell_adiabatic)
THEN
1017 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1018 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1019 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
1021 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1022 local_particles, para_env, shell_particle_set=shell_particle_set, &
1023 core_particle_set=core_particle_set)
1025 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1026 particle_set, local_molecules, local_particles, para_env)
1029 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
1030 molecule_kind_set, particle_set, cell)
1033 IF (
ASSOCIATED(force_env%meta_env))
THEN
1034 IF (force_env%meta_env%langevin)
THEN
1035 DO ivar = 1, force_env%meta_env%n_colvar
1036 rand(ivar) = force_env%meta_env%rng(ivar)%next()
1038 CALL metadyn_velocities_colvar(force_env, rand)
1043 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1044 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
1046 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, atomic_kind_set, &
1047 local_particles, particle_set, core_particle_set, shell_particle_set, &
1048 nparticle_kind, shell_adiabatic)
1050 IF (simpar%constraint)
THEN
1052 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1053 molecule_kind_set, dt, force_env%root_section)
1055 CALL shake_control(gci, local_molecules, molecule_set, &
1056 molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar%shake_tol, &
1057 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
1058 cell, para_env, local_particles)
1062 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1063 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1065 IF (shell_adiabatic .AND. shell_check_distance)
THEN
1066 CALL optimize_shell_core(force_env, particle_set, &
1067 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
1071 CALL qmmmx_update_force_env(force_env, force_env%root_section)
1076 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
1078 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1079 particles=particles, local_molecules=local_molecules, molecules=molecules, &
1080 molecule_kinds=molecule_kinds, gci=gci, virial=virial)
1082 nparticle_kind = atomic_kinds%n_els
1083 atomic_kind_set => atomic_kinds%els
1084 molecule_kind_set => molecule_kinds%els
1086 nparticle = particles%n_els
1087 particle_set => particles%els
1088 molecule_set => molecules%els
1090 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1091 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
1092 shell_check_distance=shell_check_distance)
1095 IF (shell_present)
THEN
1096 CALL cp_subsys_get(subsys=subsys, shell_particles=shell_particles, &
1097 core_particles=core_particles)
1098 shell_particle_set => shell_particles%els
1099 nshell =
SIZE(shell_particles%els)
1101 IF (shell_adiabatic)
THEN
1102 core_particle_set => core_particles%els
1109 CALL force_env_calc_energy_force(force_env, require_consistent_energy_force=.false.)
1112 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
1115 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1116 core_particle_set, shell_particle_set, nparticle_kind, shell_adiabatic, dt)
1118 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
1119 molecule_kind_set, particle_set, tmp%vel, dt, simpar%shake_tol, &
1120 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, &
1121 cell, para_env, local_particles)
1124 IF (shell_adiabatic)
THEN
1125 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1126 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1127 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
1129 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1130 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
1131 core_vel=tmp%core_vel)
1133 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1134 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
1138 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1139 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1141 IF (
ASSOCIATED(force_env%meta_env))
THEN
1142 IF (force_env%meta_env%langevin)
THEN
1148 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1149 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1152 CALL virial_evaluate(atomic_kind_set, particle_set, &
1153 local_particles, virial, para_env)
1168 TYPE(md_environment_type),
POINTER :: md_env
1169 TYPE(global_environment_type),
POINTER :: globenv
1171 REAL(kind=dp),
PARAMETER :: e2 = 1.0_dp/6.0_dp, e4 = e2/20.0_dp, &
1172 e6 = e4/42.0_dp, e8 = e6/72.0_dp
1174 INTEGER :: iroll, ivar, nkind, nparticle, &
1175 nparticle_kind, nshell
1176 INTEGER,
POINTER :: itimes
1177 LOGICAL :: first, first_time, shell_adiabatic, &
1178 shell_check_distance, shell_present
1179 REAL(kind=dp) :: dt, infree, kin, roll_tol, roll_tol_thrs
1180 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
1181 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
1182 REAL(kind=dp),
DIMENSION(:),
POINTER :: rand
1183 REAL(kind=dp),
SAVE :: eps_0
1184 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1185 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1186 TYPE(cell_type),
POINTER :: cell
1187 TYPE(cp_subsys_type),
POINTER :: subsys
1188 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
1189 TYPE(force_env_type),
POINTER :: force_env
1190 TYPE(global_constraint_type),
POINTER :: gci
1191 TYPE(local_fixd_constraint_type),
DIMENSION(:), &
1192 POINTER :: lfixd_list
1193 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
1194 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
1195 TYPE(molecule_list_type),
POINTER :: molecules
1196 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1197 TYPE(mp_para_env_type),
POINTER :: para_env
1198 TYPE(npt_info_type),
POINTER :: npt(:, :)
1199 TYPE(old_variables_type),
POINTER :: old
1200 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1202 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
1204 TYPE(simpar_type),
POINTER :: simpar
1205 TYPE(thermostat_type),
POINTER :: thermostat_baro, thermostat_part, &
1207 TYPE(tmp_variables_type),
POINTER :: tmp
1208 TYPE(virial_type),
POINTER :: virial
1210 NULLIFY (gci, thermostat_baro, thermostat_part, thermostat_shell, force_env)
1211 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
1212 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
1213 NULLIFY (core_particles, particles, shell_particles, tmp, old)
1214 NULLIFY (core_particle_set, particle_set, shell_particle_set)
1215 NULLIFY (simpar, virial, rand, itimes, lfixd_list)
1217 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
1218 thermostat_part=thermostat_part, thermostat_baro=thermostat_baro, &
1219 thermostat_shell=thermostat_shell, npt=npt, first_time=first_time, &
1220 para_env=para_env, itimes=itimes)
1222 infree = 1.0_dp/real(simpar%nfree, kind=dp)
1224 CALL force_env_get(force_env=force_env, subsys=subsys, cell=cell)
1227 CALL apply_qmmm_walls_reflective(force_env)
1229 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1230 particles=particles, local_molecules=local_molecules, molecules=molecules, &
1231 gci=gci, molecule_kinds=molecule_kinds, virial=virial)
1233 nparticle_kind = atomic_kinds%n_els
1234 nkind = molecule_kinds%n_els
1235 atomic_kind_set => atomic_kinds%els
1236 molecule_kind_set => molecule_kinds%els
1238 nparticle = particles%n_els
1239 particle_set => particles%els
1240 molecule_set => molecules%els
1242 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1243 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
1244 shell_check_distance=shell_check_distance)
1246 IF (first_time)
THEN
1247 CALL virial_evaluate(atomic_kind_set, particle_set, &
1248 local_particles, virial, para_env)
1252 CALL allocate_old(old, particle_set, npt)
1254 IF (
ASSOCIATED(force_env%meta_env))
THEN
1256 IF (force_env%meta_env%langevin)
THEN
1257 ALLOCATE (rand(force_env%meta_env%n_colvar))
1262 IF (shell_present)
THEN
1263 CALL cp_subsys_get(subsys=subsys, &
1264 shell_particles=shell_particles, core_particles=core_particles)
1265 shell_particle_set => shell_particles%els
1266 nshell =
SIZE(shell_particles%els)
1267 IF (shell_adiabatic)
THEN
1268 core_particle_set => core_particles%els
1272 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1275 IF (first_time) eps_0 = npt(1, 1)%eps
1278 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
1281 IF (simpar%ensemble /= npe_i_ensemble)
THEN
1282 IF (shell_adiabatic)
THEN
1283 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1284 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1285 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
1288 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1289 particle_set, local_molecules, local_particles, para_env)
1294 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1295 local_particles, para_env, shell_particle_set=shell_particle_set, &
1296 core_particle_set=core_particle_set)
1298 IF (simpar%constraint)
THEN
1300 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1301 molecule_kind_set, dt, force_env%root_section)
1305 IF (simpar%constraint)
THEN
1306 roll_tol_thrs = simpar%roll_tol
1308 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
1309 CALL getold(gci, local_molecules, molecule_set, &
1310 molecule_kind_set, particle_set, cell)
1312 roll_tol_thrs = epsilon(0.0_dp)
1314 roll_tol = -roll_tol_thrs
1317 IF (
ASSOCIATED(force_env%meta_env))
THEN
1318 IF (force_env%meta_env%langevin)
THEN
1319 DO ivar = 1, force_env%meta_env%n_colvar
1320 rand(ivar) = force_env%meta_env%rng(ivar)%next()
1322 CALL metadyn_velocities_colvar(force_env, rand)
1326 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1328 IF (simpar%constraint)
THEN
1329 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
1332 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
1333 local_molecules, molecule_set, molecule_kind_set, &
1334 local_particles, kin, pv_kin, virial, para_env)
1335 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1337 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
1338 (0.5_dp*npt(1, 1)%v*dt)
1339 tmp%poly_r(1:3) = 1.0_dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
1340 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
1342 tmp%arg_v(1) = (0.25_dp*npt(1, 1)%v*dt* &
1343 (1.0_dp + 3.0_dp*infree))*(0.25_dp*npt(1, 1)%v* &
1344 dt*(1.0_dp + 3.0_dp*infree))
1345 tmp%poly_v(1:3) = 1.0_dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
1346 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
1348 tmp%scale_r(1:3) = exp(0.5_dp*dt*npt(1, 1)%v)
1349 tmp%scale_v(1:3) = exp(-0.25_dp*dt*npt(1, 1)%v* &
1350 (1.0_dp + 3.0_dp*infree))
1353 IF (simpar%ensemble == npt_ia_ensemble)
THEN
1354 CALL create_local_fixd_list(lfixd_list, nkind, molecule_kind_set, local_particles)
1355 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1356 core_particle_set, shell_particle_set, nparticle_kind, &
1357 shell_adiabatic, dt, lfixd_list=lfixd_list)
1358 CALL release_local_fixd_list(lfixd_list)
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)
1365 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
1366 atomic_kind_set, local_particles, particle_set, core_particle_set, &
1367 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
1370 vector_r(:) = tmp%scale_r(:)*tmp%poly_r(:)
1371 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
1373 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
1374 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
1375 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
1376 local_particles=local_particles)
1380 npt(:, :)%eps = npt(:, :)%eps + dt*npt(:, :)%v
1383 cell%hmat(:, :) = cell%hmat(:, :)*exp(npt(1, 1)%eps - eps_0)
1385 eps_0 = npt(1, 1)%eps
1388 CALL init_cell(cell)
1391 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1392 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1394 IF (shell_adiabatic .AND. shell_check_distance)
THEN
1395 CALL optimize_shell_core(force_env, particle_set, &
1396 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
1400 CALL force_env_calc_energy_force(force_env)
1403 CALL metadyn_integrator(force_env, itimes, tmp%vel, rand=rand)
1406 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1407 core_particle_set, shell_particle_set, nparticle_kind, &
1408 shell_adiabatic, dt)
1410 IF (simpar%constraint)
THEN
1411 roll_tol_thrs = simpar%roll_tol
1414 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
1416 roll_tol_thrs = epsilon(0.0_dp)
1418 roll_tol = -roll_tol_thrs
1420 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1422 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
1423 particle_set, local_particles, molecule_kind_set, molecule_set, &
1424 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
1425 roll_tol, iroll, infree, first, para_env)
1427 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
1428 local_molecules, molecule_set, molecule_kind_set, &
1429 local_particles, kin, pv_kin, virial, para_env)
1430 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1434 IF (simpar%ensemble /= npe_i_ensemble)
THEN
1435 IF (shell_adiabatic)
THEN
1436 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1437 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
1438 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
1440 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
1441 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
1446 IF (
ASSOCIATED(thermostat_shell))
THEN
1447 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
1448 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
1449 core_vel=tmp%core_vel)
1453 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
1456 IF (simpar%ensemble == npe_i_ensemble .AND. simpar%annealing)
THEN
1457 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
1458 IF (shell_adiabatic)
THEN
1459 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
1460 tmp%vel, tmp%shell_vel, tmp%core_vel)
1464 IF (simpar%ensemble == npe_i_ensemble .AND. simpar%annealing_cell)
THEN
1465 npt(1, 1)%v = npt(1, 1)%v*simpar%f_annealing_cell
1469 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1470 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1473 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1474 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1476 CALL virial_evaluate(atomic_kind_set, particle_set, &
1477 local_particles, virial, para_env)
1480 CALL deallocate_old(old)
1482 IF (
ASSOCIATED(force_env%meta_env))
THEN
1483 IF (force_env%meta_env%langevin)
THEN
1488 IF (first_time)
THEN
1489 first_time = .false.
1490 CALL set_md_env(md_env, first_time=first_time)
1493 END SUBROUTINE npt_i
1505 TYPE(md_environment_type),
POINTER :: md_env
1507 CHARACTER(LEN=2) :: element_kind_ref0, element_symbol, &
1509 CHARACTER(LEN=max_line_length) :: errmsg
1510 INTEGER :: cell_itimes, i, nparticle, nread, &
1512 INTEGER,
POINTER :: itimes
1513 LOGICAL :: init, my_end, test_ok, traj_has_cell_info
1514 REAL(kind=dp) :: cell_time, h(3, 3), trj_epot, trj_time, &
1516 REAL(kind=dp),
DIMENSION(3) :: abc, albega
1517 REAL(kind=dp),
POINTER :: time
1518 TYPE(cell_type),
POINTER :: cell
1519 TYPE(cp_subsys_type),
POINTER :: subsys
1520 TYPE(force_env_type),
POINTER :: force_env
1521 TYPE(mp_para_env_type),
POINTER :: para_env
1522 TYPE(particle_list_type),
POINTER :: particles
1523 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
1524 TYPE(reftraj_type),
POINTER :: reftraj_env
1525 TYPE(simpar_type),
POINTER :: simpar
1527 NULLIFY (reftraj_env, particle_set, particles, force_env, subsys, simpar, para_env, cell, itimes, time)
1528 CALL get_md_env(md_env=md_env, init=init,
reftraj=reftraj_env, force_env=force_env, &
1529 para_env=para_env, simpar=simpar)
1531 CALL force_env_get(force_env=force_env, cell=cell, subsys=subsys)
1532 reftraj_env%isnap = reftraj_env%isnap + reftraj_env%info%stride
1535 CALL apply_qmmm_walls_reflective(force_env)
1536 CALL cp_subsys_get(subsys=subsys, particles=particles)
1537 nparticle = particles%n_els
1538 particle_set => particles%els
1544 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1545 READ (reftraj_env%info%traj_parser%input_line, fmt=
"(I8)") nread
1546 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1548 IF (index(reftraj_env%info%traj_parser%input_line,
", a = ") > 60)
THEN
1549 traj_has_cell_info = .true.
1550 READ (reftraj_env%info%traj_parser%input_line, &
1551 fmt=
"(T6,I8,T23,F12.3,T41,F20.10,T67,F14.6,T87,F14.6,T107,F14.6,T131,F8.3,T149,F8.3,T167,F8.3)", &
1552 err=999) trj_itimes, trj_time, trj_epot, abc(1:3), albega(1:3)
1555 abc(i) = cp_unit_to_cp2k(abc(i),
"angstrom")
1556 albega(i) = cp_unit_to_cp2k(albega(i),
"deg")
1559 traj_has_cell_info = .false.
1560 READ (reftraj_env%info%traj_parser%input_line, fmt=
"(T6,I8,T23,F12.3,T41,F20.10)", err=999) &
1561 trj_itimes, trj_time, trj_epot
1564999
IF (.NOT. test_ok)
THEN
1566 CALL get_md_env(md_env, itimes=itimes)
1572 IF (nread /= nparticle)
THEN
1573 errmsg =
"Number of atoms for step "//trim(adjustl(cp_to_string(trj_itimes)))// &
1574 " in the trajectory file does not match the reference configuration: "// &
1575 trim(adjustl(cp_to_string(nread)))//
" != "//trim(adjustl(cp_to_string(nparticle)))
1579 CALL parser_read_line(reftraj_env%info%traj_parser, 1)
1580 READ (unit=reftraj_env%info%traj_parser%input_line(1:len_trim(reftraj_env%info%traj_parser%input_line)), fmt=*) &
1581 element_symbol, particle_set(i)%r
1582 CALL uppercase(element_symbol)
1583 element_symbol_ref0 = particle_set(i)%atomic_kind%element_symbol
1584 element_kind_ref0 = particle_set(i)%atomic_kind%name(1:2)
1585 CALL uppercase(element_symbol_ref0)
1586 CALL uppercase(element_kind_ref0)
1587 IF (element_symbol /= element_symbol_ref0)
THEN
1589 IF (element_symbol /= element_kind_ref0)
THEN
1590 errmsg =
"Atomic configuration from trajectory file does not match the reference configuration: "// &
1591 "Check atom "//trim(adjustl(cp_to_string(i)))//
" of step "// &
1592 trim(adjustl(cp_to_string(trj_itimes)))//
". Found trajectory label '"// &
1593 trim(element_symbol)//
"', expected element '"//trim(element_symbol_ref0)// &
1594 "' or kind label '"//trim(element_kind_ref0)// &
1595 "'. REFTRAJ trajectories usually contain element labels; check whether the "// &
1596 "trajectory was modified to contain kind aliases instead."
1600 particle_set(i)%r(1) = cp_unit_to_cp2k(particle_set(i)%r(1),
"angstrom")
1601 particle_set(i)%r(2) = cp_unit_to_cp2k(particle_set(i)%r(2),
"angstrom")
1602 particle_set(i)%r(3) = cp_unit_to_cp2k(particle_set(i)%r(3),
"angstrom")
1607 CALL parser_read_line(reftraj_env%info%traj_parser, 1, at_end=my_end)
1608 READ (unit=reftraj_env%info%traj_parser%input_line, fmt=*) element_symbol, particle_set(i)%r
1609 CALL uppercase(element_symbol)
1610 element_symbol_ref0 = particle_set(i)%atomic_kind%element_symbol
1611 element_kind_ref0 = particle_set(i)%atomic_kind%name(1:2)
1612 CALL uppercase(element_symbol_ref0)
1613 CALL uppercase(element_kind_ref0)
1614 IF (element_symbol /= element_symbol_ref0)
THEN
1616 IF (element_symbol /= element_kind_ref0)
THEN
1617 errmsg =
"Atomic configuration from trajectory file does not match the reference configuration: "// &
1618 "Check atom "//trim(adjustl(cp_to_string(i)))//
" of step "// &
1619 trim(adjustl(cp_to_string(trj_itimes)))//
". Found trajectory label '"// &
1620 trim(element_symbol)//
"', expected element '"//trim(element_symbol_ref0)// &
1621 "' or kind label '"//trim(element_kind_ref0)// &
1622 "'. REFTRAJ trajectories usually contain element labels; check whether the "// &
1623 "trajectory was modified to contain kind aliases instead."
1627 particle_set(i)%r(1) = cp_unit_to_cp2k(particle_set(i)%r(1),
"angstrom")
1628 particle_set(i)%r(2) = cp_unit_to_cp2k(particle_set(i)%r(2),
"angstrom")
1629 particle_set(i)%r(3) = cp_unit_to_cp2k(particle_set(i)%r(3),
"angstrom")
1633 IF (reftraj_env%isnap /= (simpar%nsteps - 1)) &
1634 CALL cp_abort(__location__, &
1635 "Reached the end of the Trajectory frames in the TRAJECTORY file. Number of "// &
1636 "missing frames ("//cp_to_string((simpar%nsteps - 1) - reftraj_env%isnap)//
").")
1640 IF (reftraj_env%info%variable_volume .AND. (.NOT. traj_has_cell_info))
THEN
1641 CALL parser_get_next_line(reftraj_env%info%cell_parser, 1, at_end=my_end)
1642 CALL parse_cell_line(reftraj_env%info%cell_parser%input_line, cell_itimes, cell_time, h, vol)
1643 cpassert(trj_itimes == cell_itimes)
1646 IF (reftraj_env%isnap /= (simpar%nsteps - 1)) &
1647 CALL cp_abort(__location__, &
1648 "Reached the end of the cell info frames in the CELL file. Number of "// &
1649 "missing frames ("//cp_to_string((simpar%nsteps - 1) - reftraj_env%isnap)//
").")
1654 reftraj_env%time0 = trj_time
1655 reftraj_env%epot0 = trj_epot
1656 reftraj_env%itimes0 = trj_itimes
1659 IF (trj_itimes /= 0.0_dp .AND. trj_time /= 0.0_dp) simpar%dt = (trj_time/femtoseconds)/real(trj_itimes, kind=dp)
1661 reftraj_env%epot = trj_epot
1662 reftraj_env%itimes = trj_itimes
1663 reftraj_env%time = trj_time/femtoseconds
1664 CALL get_md_env(md_env, t=time)
1665 time = reftraj_env%time
1667 IF (traj_has_cell_info)
THEN
1668 CALL set_cell_param(cell, cell_length=abc, cell_angle=albega, do_init_cell=.true.)
1669 ELSE IF (reftraj_env%info%variable_volume)
THEN
1671 CALL init_cell(cell)
1675 CALL qmmmx_update_force_env(force_env, force_env%root_section)
1681 CALL force_env_calc_energy_force(force_env, &
1682 calc_force=(reftraj_env%info%eval == reftraj_eval_energy_forces), &
1683 eval_energy_forces=(reftraj_env%info%eval /= reftraj_eval_none), &
1684 require_consistent_energy_force=.false.)
1687 CALL metadyn_integrator(force_env, trj_itimes)
1690 IF (reftraj_env%info%msd)
THEN
1691 CALL compute_msd_reftraj(reftraj_env, md_env, particle_set)
1695 CALL parser_get_next_line(reftraj_env%info%traj_parser, (reftraj_env%info%stride - 1)*(nparticle + 2))
1696 IF (reftraj_env%info%variable_volume)
THEN
1697 CALL parser_get_next_line(reftraj_env%info%cell_parser, (reftraj_env%info%stride - 1))
1714 TYPE(md_environment_type),
POINTER :: md_env
1716 REAL(dp),
PARAMETER :: e2 = 1._dp/6._dp, e4 = e2/20._dp, &
1717 e6 = e4/42._dp, e8 = e6/72._dp
1719 INTEGER :: iroll, nparticle, nparticle_kind, nshell
1720 INTEGER,
POINTER :: itimes
1721 LOGICAL :: first, first_time, shell_adiabatic, &
1723 REAL(kind=dp) :: dt, infree, kin, roll_tol, roll_tol_thrs
1724 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
1725 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
1726 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1727 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1728 TYPE(cell_type),
POINTER :: cell
1729 TYPE(cp_subsys_type),
POINTER :: subsys
1730 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
1731 TYPE(force_env_type),
POINTER :: force_env
1732 TYPE(global_constraint_type),
POINTER :: gci
1733 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
1734 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
1735 TYPE(molecule_list_type),
POINTER :: molecules
1736 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1737 TYPE(mp_para_env_type),
POINTER :: para_env
1738 TYPE(npt_info_type),
POINTER :: npt(:, :)
1739 TYPE(old_variables_type),
POINTER :: old
1740 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1742 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
1744 TYPE(simpar_type),
POINTER :: simpar
1745 TYPE(tmp_variables_type),
POINTER :: tmp
1746 TYPE(virial_type),
POINTER :: virial
1748 NULLIFY (gci, force_env)
1749 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
1750 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
1751 NULLIFY (core_particles, particles, shell_particles, tmp, old)
1752 NULLIFY (core_particle_set, particle_set, shell_particle_set)
1753 NULLIFY (simpar, virial, itimes)
1755 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, npt=npt, &
1756 first_time=first_time, para_env=para_env, itimes=itimes)
1758 infree = 1.0_dp/real(simpar%nfree, dp)
1760 CALL force_env_get(force_env, subsys=subsys, cell=cell)
1763 CALL apply_qmmm_walls_reflective(force_env)
1765 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
1766 particles=particles, local_molecules=local_molecules, molecules=molecules, gci=gci, &
1767 molecule_kinds=molecule_kinds, virial=virial)
1769 nparticle_kind = atomic_kinds%n_els
1770 atomic_kind_set => atomic_kinds%els
1771 molecule_kind_set => molecule_kinds%els
1773 nparticle = particles%n_els
1774 particle_set => particles%els
1775 molecule_set => molecules%els
1777 IF (first_time)
THEN
1778 CALL virial_evaluate(atomic_kind_set, particle_set, &
1779 local_particles, virial, para_env)
1782 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
1783 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
1786 CALL allocate_old(old, particle_set, npt)
1788 IF (shell_present)
THEN
1789 CALL cp_subsys_get(subsys=subsys, &
1790 shell_particles=shell_particles, core_particles=core_particles)
1791 shell_particle_set => shell_particles%els
1792 nshell =
SIZE(shell_particles%els)
1793 IF (shell_adiabatic)
THEN
1794 core_particle_set => core_particles%els
1798 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
1800 IF (simpar%constraint)
THEN
1802 CALL shake_update_targets(gci, local_molecules, molecule_set, &
1803 molecule_kind_set, dt, force_env%root_section)
1807 IF (simpar%constraint)
THEN
1808 roll_tol_thrs = simpar%roll_tol
1810 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
1811 CALL getold(gci, local_molecules, molecule_set, &
1812 molecule_kind_set, particle_set, cell)
1814 roll_tol_thrs = epsilon(0.0_dp)
1816 roll_tol = -roll_tol_thrs
1818 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1820 IF (simpar%constraint)
THEN
1821 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
1823 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
1824 local_molecules, molecule_set, molecule_kind_set, &
1825 local_particles, kin, pv_kin, virial, para_env)
1826 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1828 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
1829 (0.5_dp*npt(1, 1)%v*dt)
1830 tmp%poly_r(1) = 1._dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
1831 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
1832 tmp%poly_r(2) = 1.0_dp
1833 tmp%poly_r(3) = 1.0_dp
1835 tmp%arg_v(1) = (0.25_dp*npt(1, 1)%v*dt* &
1836 (1._dp + infree))*(0.25_dp*npt(1, 1)%v* &
1837 dt*(1._dp + infree))
1838 tmp%arg_v(2) = (0.25_dp*npt(1, 1)%v*dt*infree)* &
1839 (0.25_dp*npt(1, 1)%v*dt*infree)
1840 tmp%poly_v(1) = 1._dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
1841 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
1842 tmp%poly_v(2) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
1843 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
1844 tmp%poly_v(3) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
1845 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
1847 tmp%scale_r(1) = exp(0.5_dp*dt*npt(1, 1)%v)
1848 tmp%scale_r(2) = 1.0_dp
1849 tmp%scale_r(3) = 1.0_dp
1851 tmp%scale_v(1) = exp(-0.25_dp*dt*npt(1, 1)%v* &
1853 tmp%scale_v(2) = exp(-0.25_dp*dt*npt(1, 1)%v*infree)
1854 tmp%scale_v(3) = exp(-0.25_dp*dt*npt(1, 1)%v*infree)
1857 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
1858 core_particle_set, shell_particle_set, nparticle_kind, &
1859 shell_adiabatic, dt)
1861 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
1862 atomic_kind_set, local_particles, particle_set, core_particle_set, &
1863 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
1867 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
1868 vector_r(1) = tmp%scale_r(1)*tmp%poly_r(1)
1870 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
1871 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
1872 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
1873 local_particles=local_particles)
1877 cell%hmat(1, 1) = cell%hmat(1, 1)*tmp%scale_r(1)*tmp%scale_r(1)
1880 CALL init_cell(cell)
1883 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1884 core_particle_set, para_env, shell_adiabatic, pos=.true.)
1887 CALL force_env_calc_energy_force(force_env)
1890 CALL metadyn_integrator(force_env, itimes, tmp%vel)
1893 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
1894 core_particle_set, shell_particle_set, nparticle_kind, &
1895 shell_adiabatic, dt)
1897 IF (simpar%constraint)
THEN
1898 roll_tol_thrs = simpar%roll_tol
1901 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
1903 roll_tol_thrs = epsilon(0.0_dp)
1905 roll_tol = -roll_tol_thrs
1907 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
1909 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
1910 particle_set, local_particles, molecule_kind_set, molecule_set, &
1911 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
1912 roll_tol, iroll, infree, first, para_env)
1914 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
1915 local_molecules, molecule_set, molecule_kind_set, &
1916 local_particles, kin, pv_kin, virial, para_env)
1917 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
1920 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
1923 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
1924 core_particle_set, para_env, shell_adiabatic, vel=.true.)
1927 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
1928 molecule_set, molecule_kind_set, particle_set, virial, para_env)
1930 CALL virial_evaluate(atomic_kind_set, particle_set, &
1931 local_particles, virial, para_env)
1934 CALL deallocate_old(old)
1936 IF (first_time)
THEN
1937 first_time = .false.
1938 CALL set_md_env(md_env, first_time=first_time)
1957 TYPE(md_environment_type),
POINTER :: md_env
1959 REAL(dp),
PARAMETER :: e2 = 1._dp/6._dp, e4 = e2/20._dp, &
1960 e6 = e4/42._dp, e8 = e6/72._dp
1962 INTEGER :: iroll, nparticle, nparticle_kind, nshell
1963 INTEGER,
POINTER :: itimes
1964 LOGICAL :: first, first_time, shell_adiabatic, &
1966 REAL(kind=dp) :: aa, aax, dt, gamma1, infree, kin, &
1967 roll_tol, roll_tol_thrs
1968 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
1969 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin
1970 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
1971 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
1972 TYPE(cell_type),
POINTER :: cell
1973 TYPE(cp_subsys_type),
POINTER :: subsys
1974 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
1975 TYPE(force_env_type),
POINTER :: force_env
1976 TYPE(global_constraint_type),
POINTER :: gci
1977 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
1978 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
1979 TYPE(molecule_list_type),
POINTER :: molecules
1980 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
1981 TYPE(mp_para_env_type),
POINTER :: para_env
1982 TYPE(npt_info_type),
POINTER :: npt(:, :)
1983 TYPE(old_variables_type),
POINTER :: old
1984 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
1986 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
1988 TYPE(simpar_type),
POINTER :: simpar
1989 TYPE(tmp_variables_type),
POINTER :: tmp
1990 TYPE(virial_type),
POINTER :: virial
1992 NULLIFY (gci, force_env)
1993 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
1994 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt)
1995 NULLIFY (core_particles, particles, shell_particles, tmp, old)
1996 NULLIFY (core_particle_set, particle_set, shell_particle_set)
1997 NULLIFY (simpar, virial, itimes)
1999 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, npt=npt, &
2000 first_time=first_time, para_env=para_env, itimes=itimes)
2002 infree = 1.0_dp/real(simpar%nfree, dp)
2003 gamma1 = simpar%gamma_nph
2005 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2007 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2008 particles=particles, local_molecules=local_molecules, molecules=molecules, gci=gci, &
2009 molecule_kinds=molecule_kinds, virial=virial)
2011 nparticle_kind = atomic_kinds%n_els
2012 atomic_kind_set => atomic_kinds%els
2013 molecule_kind_set => molecule_kinds%els
2015 nparticle = particles%n_els
2016 particle_set => particles%els
2017 molecule_set => molecules%els
2019 IF (first_time)
THEN
2020 CALL virial_evaluate(atomic_kind_set, particle_set, &
2021 local_particles, virial, para_env)
2024 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
2025 shell_present=shell_present, shell_adiabatic=shell_adiabatic)
2028 CALL allocate_old(old, particle_set, npt)
2030 IF (shell_present)
THEN
2031 CALL cp_subsys_get(subsys=subsys, &
2032 shell_particles=shell_particles, core_particles=core_particles)
2033 shell_particle_set => shell_particles%els
2034 nshell =
SIZE(shell_particles%els)
2035 IF (shell_adiabatic)
THEN
2036 core_particle_set => core_particles%els
2040 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
2043 CALL damp_v(molecule_kind_set, molecule_set, particle_set, local_molecules, &
2044 gamma1, npt(1, 1), dt, para_env)
2046 IF (simpar%constraint)
THEN
2048 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2049 molecule_kind_set, dt, force_env%root_section)
2053 IF (simpar%constraint)
THEN
2054 roll_tol_thrs = simpar%roll_tol
2056 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
2057 CALL getold(gci, local_molecules, molecule_set, &
2058 molecule_kind_set, particle_set, cell)
2060 roll_tol_thrs = epsilon(0.0_dp)
2062 roll_tol = -roll_tol_thrs
2064 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2067 CALL damp_veps(npt(1, 1), gamma1, dt)
2069 IF (simpar%constraint)
THEN
2070 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
2072 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
2073 local_molecules, molecule_set, molecule_kind_set, &
2074 local_particles, kin, pv_kin, virial, para_env)
2075 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
2078 CALL damp_veps(npt(1, 1), gamma1, dt)
2080 tmp%arg_r(1) = (0.5_dp*npt(1, 1)%v*dt)* &
2081 (0.5_dp*npt(1, 1)%v*dt)
2082 tmp%poly_r(1) = 1._dp + e2*tmp%arg_r(1) + e4*tmp%arg_r(1)*tmp%arg_r(1) + &
2083 e6*tmp%arg_r(1)**3 + e8*tmp%arg_r(1)**4
2085 aax = npt(1, 1)%v*(1.0_dp + infree)
2086 tmp%arg_v(1) = (0.25_dp*dt*aax)*(0.25_dp*dt*aax)
2087 tmp%poly_v(1) = 1._dp + e2*tmp%arg_v(1) + e4*tmp%arg_v(1)*tmp%arg_v(1) + &
2088 e6*tmp%arg_v(1)**3 + e8*tmp%arg_v(1)**4
2090 aa = npt(1, 1)%v*infree
2091 tmp%arg_v(2) = (0.25_dp*dt*aa)*(0.25_dp*dt*aa)
2092 tmp%poly_v(2) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
2093 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
2094 tmp%poly_v(3) = 1._dp + e2*tmp%arg_v(2) + e4*tmp%arg_v(2)*tmp%arg_v(2) + &
2095 e6*tmp%arg_v(2)**3 + e8*tmp%arg_v(2)**4
2097 tmp%scale_r(1) = exp(0.5_dp*dt*npt(1, 1)%v)
2098 tmp%scale_v(1) = exp(-0.25_dp*dt*aax)
2099 tmp%scale_v(2) = exp(-0.25_dp*dt*aa)
2100 tmp%scale_v(3) = exp(-0.25_dp*dt*aa)
2103 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
2104 core_particle_set, shell_particle_set, nparticle_kind, &
2105 shell_adiabatic, dt)
2107 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
2108 atomic_kind_set, local_particles, particle_set, core_particle_set, &
2109 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
2113 vector_v(:) = tmp%scale_v(:)*tmp%poly_v(:)
2114 vector_r(1) = tmp%scale_r(1)*tmp%poly_r(1)
2116 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
2117 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, simpar, &
2118 roll_tol, iroll, vector_r, vector_v, para_env, cell=cell, &
2119 local_particles=local_particles)
2123 cell%hmat(1, 1) = cell%hmat(1, 1)*tmp%scale_r(1)*tmp%scale_r(1)
2126 CALL init_cell(cell)
2129 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2130 core_particle_set, para_env, shell_adiabatic, pos=.true.)
2133 CALL force_env_calc_energy_force(force_env)
2136 CALL metadyn_integrator(force_env, itimes, tmp%vel)
2139 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
2140 core_particle_set, shell_particle_set, nparticle_kind, &
2141 shell_adiabatic, dt)
2143 IF (simpar%constraint)
THEN
2144 roll_tol_thrs = simpar%roll_tol
2147 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
2149 roll_tol_thrs = epsilon(0.0_dp)
2151 roll_tol = -roll_tol_thrs
2153 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2155 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
2156 particle_set, local_particles, molecule_kind_set, molecule_set, local_molecules, &
2157 tmp%vel, dt, cell, npt, simpar, virial, vector_v, roll_tol, iroll, infree, first, &
2160 CALL damp_veps(npt(1, 1), gamma1, dt)
2162 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
2163 local_molecules, molecule_set, molecule_kind_set, &
2164 local_particles, kin, pv_kin, virial, para_env)
2165 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree)
2168 CALL damp_veps(npt(1, 1), gamma1, dt)
2173 CALL damp_v(molecule_kind_set, molecule_set, particle_set, local_molecules, &
2174 tmp%vel, gamma1, npt(1, 1), dt, para_env)
2176 IF (simpar%annealing) tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
2179 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2180 core_particle_set, para_env, shell_adiabatic, vel=.true.)
2183 IF (simpar%constraint)
CALL pv_constraint(gci, local_molecules, &
2184 molecule_set, molecule_kind_set, particle_set, virial, para_env)
2186 CALL virial_evaluate(atomic_kind_set, particle_set, &
2187 local_particles, virial, para_env)
2190 CALL deallocate_old(old)
2192 IF (first_time)
THEN
2193 first_time = .false.
2194 CALL set_md_env(md_env, first_time=first_time)
2209 TYPE(md_environment_type),
POINTER :: md_env
2210 TYPE(global_environment_type),
POINTER :: globenv
2212 REAL(kind=dp),
PARAMETER :: e2 = 1.0_dp/6.0_dp, e4 = e2/20.0_dp, &
2213 e6 = e4/42.0_dp, e8 = e6/72.0_dp
2215 INTEGER :: i, iroll, j, nparticle, nparticle_kind, &
2217 INTEGER,
POINTER :: itimes
2218 LOGICAL :: first, first_time, shell_adiabatic, &
2219 shell_check_distance, shell_present
2220 REAL(kind=dp) :: dt, infree, kin, roll_tol, &
2222 REAL(kind=dp),
DIMENSION(3) :: vector_r, vector_v
2223 REAL(kind=dp),
DIMENSION(3, 3) :: pv_kin, uh
2224 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2225 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2226 TYPE(barostat_type),
POINTER :: barostat
2227 TYPE(cell_type),
POINTER :: cell
2228 TYPE(cp_subsys_type),
POINTER :: subsys
2229 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2230 TYPE(force_env_type),
POINTER :: force_env
2231 TYPE(global_constraint_type),
POINTER :: gci
2232 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2233 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2234 TYPE(molecule_list_type),
POINTER :: molecules
2235 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2236 TYPE(mp_para_env_type),
POINTER :: para_env
2237 TYPE(npt_info_type),
POINTER :: npt(:, :)
2238 TYPE(old_variables_type),
POINTER :: old
2239 TYPE(particle_list_type),
POINTER :: core_particles, particles, &
2241 TYPE(particle_type),
DIMENSION(:),
POINTER :: core_particle_set, particle_set, &
2243 TYPE(simpar_type),
POINTER :: simpar
2244 TYPE(thermostat_type),
POINTER :: thermostat_baro, thermostat_part, &
2246 TYPE(tmp_variables_type),
POINTER :: tmp
2247 TYPE(virial_type),
POINTER :: virial
2249 NULLIFY (gci, thermostat_baro, thermostat_part, thermostat_shell, force_env)
2250 NULLIFY (atomic_kinds, cell, para_env, subsys, local_molecules, local_particles)
2251 NULLIFY (molecule_kinds, molecules, molecule_kind_set, npt, barostat)
2252 NULLIFY (core_particles, particles, shell_particles, tmp, old)
2253 NULLIFY (core_particle_set, particle_set, shell_particle_set)
2254 NULLIFY (simpar, virial, itimes)
2256 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
2257 thermostat_part=thermostat_part, thermostat_baro=thermostat_baro, &
2258 thermostat_shell=thermostat_shell, npt=npt, first_time=first_time, &
2259 para_env=para_env, barostat=barostat, itimes=itimes)
2261 infree = 1.0_dp/real(simpar%nfree, kind=dp)
2263 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2266 CALL apply_qmmm_walls_reflective(force_env)
2268 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2269 particles=particles, local_molecules=local_molecules, molecules=molecules, &
2270 gci=gci, molecule_kinds=molecule_kinds, virial=virial)
2272 nparticle_kind = atomic_kinds%n_els
2273 atomic_kind_set => atomic_kinds%els
2274 molecule_kind_set => molecule_kinds%els
2276 nparticle = particles%n_els
2277 particle_set => particles%els
2278 molecule_set => molecules%els
2280 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, &
2281 shell_present=shell_present, shell_adiabatic=shell_adiabatic, &
2282 shell_check_distance=shell_check_distance)
2284 IF (first_time)
THEN
2285 CALL virial_evaluate(atomic_kind_set, particle_set, &
2286 local_particles, virial, para_env)
2290 CALL allocate_old(old, particle_set, npt)
2292 IF (shell_present)
THEN
2293 CALL cp_subsys_get(subsys=subsys, &
2294 shell_particles=shell_particles, core_particles=core_particles)
2295 shell_particle_set => shell_particles%els
2296 nshell =
SIZE(shell_particles%els)
2297 IF (shell_adiabatic)
THEN
2298 core_particle_set => core_particles%els
2302 CALL allocate_tmp(md_env, tmp, nparticle, nshell, shell_adiabatic)
2305 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
2308 IF (simpar%ensemble /= npe_f_ensemble)
THEN
2309 IF (shell_adiabatic)
THEN
2310 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2311 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
2312 shell_particle_set=shell_particle_set, core_particle_set=core_particle_set)
2314 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2315 particle_set, local_molecules, local_particles, para_env)
2320 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
2321 local_particles, para_env, shell_particle_set=shell_particle_set, &
2322 core_particle_set=core_particle_set)
2324 IF (simpar%constraint)
THEN
2326 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2327 molecule_kind_set, dt, force_env%root_section)
2331 IF (simpar%constraint)
THEN
2332 roll_tol_thrs = simpar%roll_tol
2334 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'F')
2335 CALL getold(gci, local_molecules, molecule_set, &
2336 molecule_kind_set, particle_set, cell)
2338 roll_tol_thrs = epsilon(0.0_dp)
2340 roll_tol = -roll_tol_thrs
2342 sr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2344 IF (simpar%constraint)
THEN
2345 CALL set(old, atomic_kind_set, particle_set, local_particles, cell, npt,
'B')
2347 CALL update_pv(gci, simpar, atomic_kind_set, particle_set, &
2348 local_molecules, molecule_set, molecule_kind_set, &
2349 local_particles, kin, pv_kin, virial, para_env)
2350 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree, &
2351 virial_components=barostat%virial_components)
2353 trvg = npt(1, 1)%v + npt(2, 2)%v + npt(3, 3)%v
2358 CALL diagonalise(matrix=npt(:, :)%v, mysize=3, &
2359 uplo=
"U", eigenvalues=tmp%e_val, eigenvectors=tmp%u)
2361 tmp%arg_r(:) = 0.5_dp*tmp%e_val(:)*dt* &
2362 0.5_dp*tmp%e_val(:)*dt
2363 tmp%poly_r = 1.0_dp + e2*tmp%arg_r + e4*tmp%arg_r*tmp%arg_r + &
2364 e6*tmp%arg_r**3 + e8*tmp%arg_r**4
2365 tmp%scale_r(:) = exp(0.5_dp*dt*tmp%e_val(:))
2367 tmp%arg_v(:) = 0.25_dp*dt*(tmp%e_val(:) + trvg*infree)* &
2368 0.25_dp*dt*(tmp%e_val(:) + trvg*infree)
2369 tmp%poly_v = 1.0_dp + e2*tmp%arg_v + e4*tmp%arg_v*tmp%arg_v + &
2370 e6*tmp%arg_v**3 + e8*tmp%arg_v**4
2371 tmp%scale_v(:) = exp(-0.25_dp*dt*(tmp%e_val(:) + trvg*infree))
2373 CALL vv_first(tmp, atomic_kind_set, local_particles, particle_set, &
2374 core_particle_set, shell_particle_set, nparticle_kind, &
2375 shell_adiabatic, dt, u=tmp%u)
2377 IF (simpar%variable_dt)
CALL variable_timestep(md_env, tmp, dt, simpar, para_env, &
2378 atomic_kind_set, local_particles, particle_set, core_particle_set, &
2379 shell_particle_set, nparticle_kind, shell_adiabatic, npt=npt)
2382 vector_r = tmp%scale_r*tmp%poly_r
2383 vector_v = tmp%scale_v*tmp%poly_v
2385 IF (simpar%constraint)
CALL shake_roll_control(gci, local_molecules, &
2386 molecule_set, molecule_kind_set, particle_set, tmp%pos, tmp%vel, dt, &
2387 simpar, roll_tol, iroll, vector_r, vector_v, &
2388 para_env, u=tmp%u, cell=cell, &
2389 local_particles=local_particles)
2393 uh = matmul(transpose(tmp%u), cell%hmat)
2397 uh(i, j) = uh(i, j)*tmp%scale_r(i)*tmp%scale_r(i)
2401 cell%hmat = matmul(tmp%u, uh)
2403 CALL init_cell(cell)
2406 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2407 core_particle_set, para_env, shell_adiabatic, pos=.true.)
2409 IF (shell_adiabatic .AND. shell_check_distance)
THEN
2410 CALL optimize_shell_core(force_env, particle_set, &
2411 shell_particle_set, core_particle_set, globenv, tmp=tmp, check=.true.)
2415 CALL force_env_calc_energy_force(force_env)
2418 CALL metadyn_integrator(force_env, itimes, tmp%vel)
2421 CALL vv_second(tmp, atomic_kind_set, local_particles, particle_set, &
2422 core_particle_set, shell_particle_set, nparticle_kind, &
2423 shell_adiabatic, dt, tmp%u)
2425 IF (simpar%constraint)
THEN
2426 roll_tol_thrs = simpar%roll_tol
2429 CALL set(old, atomic_kind_set, particle_set, tmp%vel, local_particles, cell, npt,
'F')
2431 roll_tol_thrs = epsilon(0.0_dp)
2433 roll_tol = -roll_tol_thrs
2435 rr:
DO WHILE (abs(roll_tol) >= roll_tol_thrs)
2437 IF (simpar%constraint)
CALL rattle_roll_setup(old, gci, atomic_kind_set, &
2438 particle_set, local_particles, molecule_kind_set, molecule_set, &
2439 local_molecules, tmp%vel, dt, cell, npt, simpar, virial, vector_v, &
2440 roll_tol, iroll, infree, first, para_env, u=tmp%u)
2442 CALL update_pv(gci, simpar, atomic_kind_set, tmp%vel, particle_set, &
2443 local_molecules, molecule_set, molecule_kind_set, &
2444 local_particles, kin, pv_kin, virial, para_env)
2445 CALL update_veps(cell, npt, simpar, pv_kin, kin, virial, infree, &
2446 virial_components=barostat%virial_components)
2450 IF (simpar%ensemble /= npe_f_ensemble)
THEN
2451 IF (shell_adiabatic)
THEN
2452 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2453 particle_set, local_molecules, local_particles, para_env, shell_adiabatic=shell_adiabatic, &
2454 vel=tmp%vel, shell_vel=tmp%shell_vel, core_vel=tmp%core_vel)
2457 CALL apply_thermostat_particles(thermostat_part, force_env, molecule_kind_set, molecule_set, &
2458 particle_set, local_molecules, local_particles, para_env, vel=tmp%vel)
2463 IF (
ASSOCIATED(thermostat_shell))
THEN
2464 CALL apply_thermostat_shells(thermostat_shell, atomic_kind_set, particle_set, &
2465 local_particles, para_env, vel=tmp%vel, shell_vel=tmp%shell_vel, &
2466 core_vel=tmp%core_vel)
2470 CALL apply_thermostat_baro(thermostat_baro, npt, para_env)
2473 IF (simpar%ensemble == npe_f_ensemble .AND. simpar%annealing)
THEN
2474 tmp%vel(:, :) = tmp%vel(:, :)*simpar%f_annealing
2475 IF (shell_adiabatic)
THEN
2476 CALL shell_scale_comv(atomic_kind_set, local_particles, particle_set, &
2477 tmp%vel, tmp%shell_vel, tmp%core_vel)
2481 IF (simpar%ensemble == npe_f_ensemble .AND. simpar%annealing_cell)
THEN
2482 npt(:, :)%v = npt(:, :)%v*simpar%f_annealing_cell
2486 CALL update_dealloc_tmp(tmp, particle_set, shell_particle_set, &
2487 core_particle_set, para_env, shell_adiabatic, vel=.true.)
2490 IF (simpar%constraint) &
2491 CALL pv_constraint(gci, local_molecules, molecule_set, &
2492 molecule_kind_set, particle_set, virial, para_env)
2494 CALL virial_evaluate(atomic_kind_set, particle_set, &
2495 local_particles, virial, para_env)
2498 CALL deallocate_old(old)
2500 IF (first_time)
THEN
2501 first_time = .false.
2502 CALL set_md_env(md_env, first_time=first_time)
2505 END SUBROUTINE npt_f
2514 TYPE(md_environment_type),
POINTER :: md_env
2516 INTEGER :: i_step, iparticle, iparticle_kind, &
2517 iparticle_local, n_time_steps, &
2518 nparticle, nparticle_kind, &
2520 INTEGER,
POINTER :: itimes
2521 REAL(kind=dp) :: dm, dt, mass
2522 REAL(kind=dp),
ALLOCATABLE,
DIMENSION(:, :) :: pos, vel
2523 TYPE(atomic_kind_list_type),
POINTER :: atomic_kinds
2524 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
2525 TYPE(atomic_kind_type),
POINTER :: atomic_kind
2526 TYPE(cell_type),
POINTER :: cell
2527 TYPE(cp_subsys_type),
POINTER :: subsys, subsys_respa
2528 TYPE(distribution_1d_type),
POINTER :: local_molecules, local_particles
2529 TYPE(force_env_type),
POINTER :: force_env
2530 TYPE(global_constraint_type),
POINTER :: gci
2531 TYPE(molecule_kind_list_type),
POINTER :: molecule_kinds
2532 TYPE(molecule_kind_type),
DIMENSION(:),
POINTER :: molecule_kind_set
2533 TYPE(molecule_list_type),
POINTER :: molecules
2534 TYPE(molecule_type),
DIMENSION(:),
POINTER :: molecule_set
2535 TYPE(mp_para_env_type),
POINTER :: para_env
2536 TYPE(particle_list_type),
POINTER :: particles, particles_respa
2537 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set, particle_set_respa
2538 TYPE(simpar_type),
POINTER :: simpar
2540 NULLIFY (para_env, cell, subsys_respa, particles_respa, particle_set_respa, gci, force_env, atomic_kinds)
2541 NULLIFY (atomic_kind_set, simpar, subsys, particles, particle_set)
2542 NULLIFY (local_molecules, molecule_kinds, molecules, molecule_kind_set, local_particles, itimes)
2543 CALL get_md_env(md_env=md_env, simpar=simpar, force_env=force_env, &
2544 para_env=para_env, itimes=itimes)
2547 n_time_steps = simpar%n_time_steps
2549 CALL force_env_get(force_env, subsys=subsys, cell=cell)
2550 CALL force_env_get(force_env%sub_force_env(1)%force_env, subsys=subsys_respa)
2553 CALL apply_qmmm_walls_reflective(force_env)
2555 CALL cp_subsys_get(subsys=subsys, atomic_kinds=atomic_kinds, local_particles=local_particles, &
2556 particles=particles, local_molecules=local_molecules, molecules=molecules, &
2557 gci=gci, molecule_kinds=molecule_kinds)
2559 CALL cp_subsys_get(subsys=subsys_respa, particles=particles_respa)
2560 particle_set_respa => particles_respa%els
2562 nparticle_kind = atomic_kinds%n_els
2563 atomic_kind_set => atomic_kinds%els
2564 molecule_kind_set => molecule_kinds%els
2566 nparticle = particles%n_els
2567 particle_set => particles%els
2568 molecule_set => molecules%els
2571 ALLOCATE (pos(3, nparticle))
2572 ALLOCATE (vel(3, nparticle))
2575 IF (simpar%constraint)
CALL getold(gci, local_molecules, molecule_set, &
2576 molecule_kind_set, particle_set, cell)
2579 DO iparticle_kind = 1, nparticle_kind
2580 atomic_kind => atomic_kind_set(iparticle_kind)
2581 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2583 nparticle_local = local_particles%n_el(iparticle_kind)
2584 DO iparticle_local = 1, nparticle_local
2585 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2586 vel(:, iparticle) = particle_set(iparticle)%v(:) + &
2587 dm*(particle_set(iparticle)%f(:) - &
2588 particle_set_respa(iparticle)%f(:))
2593 DO i_step = 1, n_time_steps
2595 DO iparticle_kind = 1, nparticle_kind
2596 atomic_kind => atomic_kind_set(iparticle_kind)
2597 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2598 dm = 0.5_dp*dt/(n_time_steps*mass)
2599 nparticle_local = local_particles%n_el(iparticle_kind)
2600 DO iparticle_local = 1, nparticle_local
2601 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2602 vel(:, iparticle) = vel(:, iparticle) + &
2603 dm*particle_set_respa(iparticle)%f(:)
2604 pos(:, iparticle) = particle_set(iparticle)%r(:) + &
2605 (dt/n_time_steps)*vel(:, iparticle)
2609 IF (simpar%constraint)
THEN
2611 CALL shake_update_targets(gci, local_molecules, molecule_set, &
2612 molecule_kind_set, dt, force_env%root_section)
2614 CALL shake_control(gci, local_molecules, molecule_set, &
2615 molecule_kind_set, particle_set, pos, vel, dt, simpar%shake_tol, &
2616 simpar%info_constraint, simpar%lagrange_multipliers, simpar%dump_lm, cell, &
2617 para_env, local_particles)
2621 CALL update_particle_set(particle_set, para_env, pos=pos)
2622 DO iparticle = 1,
SIZE(particle_set)
2623 particle_set_respa(iparticle)%r = particle_set(iparticle)%r
2627 CALL force_env_calc_energy_force(force_env%sub_force_env(1)%force_env)
2630 CALL metadyn_integrator(force_env, itimes, vel)
2633 DO iparticle_kind = 1, nparticle_kind
2634 atomic_kind => atomic_kind_set(iparticle_kind)
2635 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2636 dm = 0.5_dp*dt/(n_time_steps*mass)
2637 nparticle_local = local_particles%n_el(iparticle_kind)
2638 DO iparticle_local = 1, nparticle_local
2639 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2640 vel(1, iparticle) = vel(1, iparticle) + dm*particle_set_respa(iparticle)%f(1)
2641 vel(2, iparticle) = vel(2, iparticle) + dm*particle_set_respa(iparticle)%f(2)
2642 vel(3, iparticle) = vel(3, iparticle) + dm*particle_set_respa(iparticle)%f(3)
2646 IF (simpar%constraint)
CALL rattle_control(gci, local_molecules, molecule_set, &
2647 molecule_kind_set, particle_set, vel, dt, simpar%shake_tol, &
2648 simpar%info_constraint, simpar%lagrange_multipliers, &
2649 simpar%dump_lm, cell, para_env, local_particles)
2651 IF (simpar%annealing) vel(:, :) = vel(:, :)*simpar%f_annealing
2657 CALL force_env_calc_energy_force(force_env)
2660 CALL metadyn_integrator(force_env, itimes, vel)
2662 DO iparticle_kind = 1, nparticle_kind
2663 atomic_kind => atomic_kind_set(iparticle_kind)
2664 CALL get_atomic_kind(atomic_kind=atomic_kind, mass=mass)
2666 nparticle_local = local_particles%n_el(iparticle_kind)
2667 DO iparticle_local = 1, nparticle_local
2668 iparticle = local_particles%list(iparticle_kind)%array(iparticle_local)
2669 vel(1, iparticle) = vel(1, iparticle) + dm*(particle_set(iparticle)%f(1) - particle_set_respa(iparticle)%f(1))
2670 vel(2, iparticle) = vel(2, iparticle) + dm*(particle_set(iparticle)%f(2) - particle_set_respa(iparticle)%f(2))
2671 vel(3, iparticle) = vel(3, iparticle) + dm*(particle_set(iparticle)%f(3) - particle_set_respa(iparticle)%f(3))
2676 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 set_cell_param(cell, cell_length, cell_angle, periodic, do_init_cell)
Sets the cell using the internal parameters (a,b,c) (alpha,beta,gamma) using the convention: a parall...
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_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.