51#include "../../base/base_uses.f90"
57 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'extended_system_init'
81 CHARACTER(LEN=*),
PARAMETER :: routinen =
'initialize_npt'
83 INTEGER :: handle, i, ind, j
84 LOGICAL :: explicit, restart
86 REAL(kind=
dp),
DIMENSION(:),
POINTER :: buffer
89 CALL timeset(routinen, handle)
91 NULLIFY (work_section2)
96 cpassert(.NOT.
ASSOCIATED(npt_info))
99 SELECT CASE (simpar%ensemble)
101 ALLOCATE (npt_info(1, 1))
102 npt_info(:, :)%eps = log(cell%deth)/3.0_dp
103 temp = simpar%temp_baro_ext
106 ALLOCATE (npt_info(3, 3))
107 temp = simpar%temp_baro_ext
110 ALLOCATE (npt_info(1, 1))
111 temp = simpar%temp_baro_ext
114 ALLOCATE (npt_info(1, 1))
115 temp = simpar%temp_baro_ext
122 IF (
ASSOCIATED(npt_info))
THEN
123 IF (
ASSOCIATED(work_section))
THEN
129 IF (restart .NEQV. explicit)
THEN
130 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
131 "MASS section (or none) in the BAROSTAT section")
133 restart = explicit .AND. restart
139 DO i = 1,
SIZE(npt_info, 1)
140 DO j = 1,
SIZE(npt_info, 2)
142 npt_info(i, j)%v = buffer(ind)
147 DO i = 1,
SIZE(npt_info, 1)
148 DO j = 1,
SIZE(npt_info, 2)
150 npt_info(i, j)%mass = buffer(ind)
154 CALL init_barostat_variables(npt_info, simpar%tau_cell, temp, &
155 simpar%nfree, simpar%ensemble, simpar%cmass, &
161 CALL timestop(handle)
182 LOGICAL,
INTENT(IN) :: save_mem
184 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_baro'
188 REAL(kind=
dp) :: temp
190 CALL timeset(routinen, handle)
197 IF (nhc%nyosh > 0)
THEN
198 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
199 CALL set_yoshida_coef(nhc, simpar%dt)
202 CALL restart_nose(nhc, nose_section, save_mem, restart,
"",
"", para_env)
204 IF (.NOT. restart)
THEN
207 SELECT CASE (simpar%ensemble)
209 temp = simpar%temp_baro_ext
211 IF (nhc%nhc_len /= 0)
THEN
212 CALL init_nhc_variables(nhc, temp, para_env, globenv)
216 CALL init_nhc_forces(nhc)
218 CALL timestop(handle)
238 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
251 LOGICAL,
INTENT(IN) :: save_mem
253 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_slow'
258 CALL timeset(routinen, handle)
264 molecule, molecule_kind_set, nhc, para_env, gci)
267 IF (nhc%nyosh > 0)
THEN
268 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
269 CALL set_yoshida_coef(nhc, simpar%dt)
272 CALL restart_nose(nhc, nose_section, save_mem, restart,
"",
"", para_env)
274 IF (.NOT. restart)
THEN
277 IF (nhc%nhc_len /= 0)
THEN
278 CALL init_nhc_variables(nhc, simpar%temp_slow, para_env, globenv)
282 CALL init_nhc_forces(nhc)
284 CALL timestop(handle)
304 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
317 LOGICAL,
INTENT(IN) :: save_mem
319 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_fast'
324 CALL timeset(routinen, handle)
330 molecule, molecule_kind_set, nhc, para_env, gci)
333 IF (nhc%nyosh > 0)
THEN
334 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
335 CALL set_yoshida_coef(nhc, simpar%dt)
338 CALL restart_nose(nhc, nose_section, save_mem, restart,
"",
"", para_env)
340 IF (.NOT. restart)
THEN
343 IF (nhc%nhc_len /= 0)
THEN
344 CALL init_nhc_variables(nhc, simpar%temp_fast, para_env, globenv)
348 CALL init_nhc_forces(nhc)
350 CALL timestop(handle)
371 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
372 gci, save_mem, binary_restart_file_name)
384 LOGICAL,
INTENT(IN) :: save_mem
385 CHARACTER(LEN=*),
INTENT(IN) :: binary_restart_file_name
387 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_part'
392 CALL timeset(routinen, handle)
398 molecule, molecule_kind_set, nhc, para_env, gci)
401 IF (nhc%nyosh > 0)
THEN
402 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
403 CALL set_yoshida_coef(nhc, simpar%dt)
406 CALL restart_nose(nhc, nose_section, save_mem, restart, binary_restart_file_name, &
407 "PARTICLE", para_env)
409 IF (.NOT. restart)
THEN
412 IF (nhc%nhc_len /= 0)
THEN
413 CALL init_nhc_variables(nhc, simpar%temp_ext, para_env, globenv)
417 CALL init_nhc_forces(nhc)
419 CALL timestop(handle)
440 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
441 gci, save_mem, binary_restart_file_name)
453 LOGICAL,
INTENT(IN) :: save_mem
454 CHARACTER(LEN=*),
INTENT(IN) :: binary_restart_file_name
456 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_shell'
461 CALL timeset(routinen, handle)
464 molecule, molecule_kind_set, nhc, para_env, gci)
468 IF (nhc%nyosh > 0)
THEN
469 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
470 CALL set_yoshida_coef(nhc, simpar%dt)
473 CALL restart_nose(nhc, nose_section, save_mem, restart, binary_restart_file_name, &
476 IF (.NOT. restart)
THEN
479 IF (nhc%nhc_len /= 0)
THEN
480 CALL init_nhc_variables(nhc, simpar%temp_sh_ext, para_env, globenv)
484 CALL init_nhc_forces(nhc)
486 CALL timestop(handle)
499 SUBROUTINE set_yoshida_coef(nhc, dt)
502 REAL(kind=
dp),
INTENT(IN) :: dt
504 REAL(kind=
dp),
DIMENSION(nhc%nyosh) :: yosh_wt
506 SELECT CASE (nhc%nyosh)
508 cpabort(
'Value not available.')
512 yosh_wt(1) = 1.0_dp/(2.0_dp - (2.0_dp)**(1.0_dp/3.0_dp))
513 yosh_wt(2) = 1.0_dp - 2.0_dp*yosh_wt(1)
514 yosh_wt(3) = yosh_wt(1)
516 yosh_wt(1) = 1.0_dp/(4.0_dp - (4.0_dp)**(1.0_dp/3.0_dp))
517 yosh_wt(2) = yosh_wt(1)
518 yosh_wt(4) = yosh_wt(1)
519 yosh_wt(5) = yosh_wt(1)
520 yosh_wt(3) = 1.0_dp - 4.0_dp*yosh_wt(1)
522 yosh_wt(1) = .78451361047756_dp
523 yosh_wt(2) = .235573213359357_dp
524 yosh_wt(3) = -1.17767998417887_dp
525 yosh_wt(4) = 1.0_dp - 2.0_dp*(yosh_wt(1) + yosh_wt(2) + yosh_wt(3))
526 yosh_wt(5) = yosh_wt(3)
527 yosh_wt(6) = yosh_wt(2)
528 yosh_wt(7) = yosh_wt(1)
530 yosh_wt(1) = 0.192_dp
531 yosh_wt(2) = 0.554910818409783619692725006662999_dp
532 yosh_wt(3) = 0.124659619941888644216504240951585_dp
533 yosh_wt(4) = -0.843182063596933505315033808282941_dp
534 yosh_wt(5) = 1.0_dp - 2.0_dp*(yosh_wt(1) + yosh_wt(2) + &
535 yosh_wt(3) + yosh_wt(4))
536 yosh_wt(6) = yosh_wt(4)
537 yosh_wt(7) = yosh_wt(3)
538 yosh_wt(8) = yosh_wt(2)
539 yosh_wt(9) = yosh_wt(1)
541 yosh_wt(1) = 0.102799849391985_dp
542 yosh_wt(2) = -0.196061023297549e1_dp
543 yosh_wt(3) = 0.193813913762276e1_dp
544 yosh_wt(4) = -0.158240635368243_dp
545 yosh_wt(5) = -0.144485223686048e1_dp
546 yosh_wt(6) = 0.253693336566229_dp
547 yosh_wt(7) = 0.914844246229740_dp
548 yosh_wt(8) = 1.0_dp - 2.0_dp*(yosh_wt(1) + yosh_wt(2) + &
549 yosh_wt(3) + yosh_wt(4) + yosh_wt(5) + yosh_wt(6) + yosh_wt(7))
550 yosh_wt(9) = yosh_wt(7)
551 yosh_wt(10) = yosh_wt(6)
552 yosh_wt(11) = yosh_wt(5)
553 yosh_wt(12) = yosh_wt(4)
554 yosh_wt(13) = yosh_wt(3)
555 yosh_wt(14) = yosh_wt(2)
556 yosh_wt(15) = yosh_wt(1)
558 nhc%dt_yosh = dt*yosh_wt/real(nhc%nc, kind=
dp)
560 END SUBROUTINE set_yoshida_coef
576 SUBROUTINE restart_nose(nhc, nose_section, save_mem, restart, &
577 binary_restart_file_name, thermostat_name, &
582 LOGICAL,
INTENT(IN) :: save_mem
583 LOGICAL,
INTENT(OUT) :: restart
584 CHARACTER(LEN=*),
INTENT(IN) :: binary_restart_file_name, thermostat_name
587 CHARACTER(len=*),
PARAMETER :: routinen =
'restart_nose'
589 INTEGER :: handle, i, ind, j
591 REAL(kind=
dp),
DIMENSION(:),
POINTER :: buffer
595 CALL timeset(routinen, handle)
598 NULLIFY (work_section)
600 IF (len_trim(binary_restart_file_name) > 0)
THEN
614 IF (
ASSOCIATED(nose_section))
THEN
620 IF (.NOT. restart .AND. explicit)
THEN
621 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
622 "COORD and MASS and FORCE section (or none) in the NOSE section")
624 restart = explicit .AND. restart
627 IF (.NOT. restart .AND. explicit)
THEN
628 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
629 "COORD and MASS and FORCE section (or none) in the NOSE section")
631 restart = explicit .AND. restart
634 IF (.NOT. restart .AND. explicit)
THEN
635 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
636 "COORD and MASS and FORCE section (or none) in the NOSE section")
638 restart = explicit .AND. restart
642 map_info => nhc%map_info
644 DO i = 1,
SIZE(nhc%nvt, 2)
645 ind = map_info%index(i)
646 ind = (ind - 1)*nhc%nhc_len
647 DO j = 1,
SIZE(nhc%nvt, 1)
649 nhc%nvt(j, i)%eta = buffer(ind)
653 DO i = 1,
SIZE(nhc%nvt, 2)
654 ind = map_info%index(i)
655 ind = (ind - 1)*nhc%nhc_len
656 DO j = 1,
SIZE(nhc%nvt, 1)
658 nhc%nvt(j, i)%v = buffer(ind)
662 DO i = 1,
SIZE(nhc%nvt, 2)
663 ind = map_info%index(i)
664 ind = (ind - 1)*nhc%nhc_len
665 DO j = 1,
SIZE(nhc%nvt, 1)
667 nhc%nvt(j, i)%mass = buffer(ind)
671 DO i = 1,
SIZE(nhc%nvt, 2)
672 ind = map_info%index(i)
673 ind = (ind - 1)*nhc%nhc_len
674 DO j = 1,
SIZE(nhc%nvt, 1)
676 nhc%nvt(j, i)%f = buffer(ind)
682 NULLIFY (work_section)
685 NULLIFY (work_section)
688 NULLIFY (work_section)
691 NULLIFY (work_section)
698 CALL timestop(handle)
700 END SUBROUTINE restart_nose
712 SUBROUTINE init_nhc_variables(nhc, temp_ext, para_env, globenv)
714 REAL(kind=
dp),
INTENT(IN) :: temp_ext
718 CHARACTER(len=*),
PARAMETER :: routinen =
'init_nhc_variables'
720 INTEGER :: handle, i, icount, j, number, tot_rn
721 REAL(kind=
dp) :: akin, dum, temp
722 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: array_of_rn
725 CALL timeset(routinen, handle)
730 nhc%nvt(:, :)%mass = nhc%nvt(:, :)%nkt*nhc%tau_nhc**2
731 nhc%nvt(:, :)%eta = 0._dp
732 nhc%nvt(:, :)%v = 0._dp
733 nhc%nvt(:, :)%f = 0._dp
735 map_info => nhc%map_info
736 SELECT CASE (map_info%dis_type)
739 tot_rn = nhc%glob_num_nhc*nhc%nhc_len
741 ALLOCATE (array_of_rn(tot_rn))
742 array_of_rn(:) = 0.0_dp
745 SELECT CASE (map_info%dis_type)
748 DO i = 1, nhc%loc_num_nhc
749 DO j = 1, nhc%nhc_len
750 nhc%nvt(j, i)%v = globenv%gaussian_rng_stream%next()
755 DO i = 1, nhc%loc_num_nhc
756 DO j = 1, nhc%nhc_len
757 akin = akin + 0.5_dp*(nhc%nvt(j, i)%mass* &
762 number = nhc%loc_num_nhc
765 temp = 2.0_dp*akin/real(number, kind=
dp)
766 IF (temp > 0.0_dp) temp = sqrt(temp_ext/temp)
767 DO i = 1, nhc%loc_num_nhc
768 DO j = 1, nhc%nhc_len
769 nhc%nvt(j, i)%v = temp*nhc%nvt(j, i)%v
770 nhc%nvt(j, i)%eta = 0.0_dp
775 DO i = 1, nhc%loc_num_nhc
776 DO j = 2, nhc%nhc_len
777 nhc%nvt(j, i)%f = nhc%nvt(j - 1, i)%mass*nhc%nvt(j - 1, i)%v* &
778 nhc%nvt(j - 1, i)%v - nhc%nvt(j, i)%nkt
779 IF (nhc%nvt(j, i)%mass > 0.0_dp)
THEN
780 nhc%nvt(j, i)%f = nhc%nvt(j, i)%f/nhc%nvt(j, i)%mass
787 array_of_rn(i) = globenv%gaussian_rng_stream%next()
790 DO i = 1, nhc%loc_num_nhc
791 icount = map_info%index(i)
792 icount = (icount - 1)*nhc%nhc_len
793 DO j = 1, nhc%nhc_len
795 nhc%nvt(j, i)%v = array_of_rn(icount)
797 nhc%nvt(j, i)%eta = 0.0_dp
800 DEALLOCATE (array_of_rn)
802 number = nhc%glob_num_nhc
806 temp = 2.0_dp*akin/real(number, kind=
dp)
807 IF (temp > 0.0_dp) temp = sqrt(temp_ext/temp)
808 DO i = 1, nhc%loc_num_nhc
809 DO j = 1, nhc%nhc_len
810 nhc%nvt(j, i)%v = temp*nhc%nvt(j, i)%v
815 DO i = 1, nhc%loc_num_nhc
816 DO j = 2, nhc%nhc_len
817 nhc%nvt(j, i)%f = nhc%nvt(j - 1, i)%mass*nhc%nvt(j - 1, i)%v* &
818 nhc%nvt(j - 1, i)%v - nhc%nvt(j, i)%nkt
819 IF (nhc%nvt(j, i)%mass > 0.0_dp)
THEN
820 nhc%nvt(j, i)%f = nhc%nvt(j, i)%f/nhc%nvt(j, i)%mass
827 CALL timestop(handle)
829 END SUBROUTINE init_nhc_variables
844 SUBROUTINE init_barostat_variables(npt, tau_cell, temp_ext, nfree, ensemble, &
849 REAL(kind=
dp),
INTENT(IN) :: tau_cell, temp_ext
850 INTEGER,
INTENT(IN) :: nfree, ensemble
851 REAL(kind=
dp),
INTENT(IN) :: cmass
854 CHARACTER(len=*),
PARAMETER :: routinen =
'init_barostat_variables'
856 INTEGER :: handle, i, j, number
857 REAL(kind=
dp) :: akin, temp, v
859 CALL timeset(routinen, handle)
865 npt(:, :)%eps = 0.0_dp
868 SELECT CASE (ensemble)
870 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2
872 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2/3.0_dp
874 npt(:, :)%mass = cmass
876 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2/3.0_dp
878 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2
881 DO i = 1,
SIZE(npt, 1)
882 DO j = i,
SIZE(npt, 2)
883 v = globenv%gaussian_rng_stream%next()
892 DO i = 1,
SIZE(npt, 1)
893 DO j = 1,
SIZE(npt, 2)
894 akin = akin + 0.5_dp*(npt(j, i)%mass*npt(j, i)%v*npt(j, i)%v)
898 number =
SIZE(npt, 1)*
SIZE(npt, 2)
901 IF (number /= 0)
THEN
902 temp = 2.0_dp*akin/real(number, kind=
dp)
903 IF (temp > 0.0_dp) temp = sqrt(temp_ext/temp)
905 DO i = 1,
SIZE(npt, 1)
906 DO j = i,
SIZE(npt, 2)
907 npt(j, i)%v = temp*npt(j, i)%v
908 npt(i, j)%v = npt(j, i)%v
912 WRITE (*, *)
'DEBUG ISOTROPIC LIMIT| INITIAL v_eps', npt(j, i)%v
918 SELECT CASE (ensemble)
924 CALL timestop(handle)
926 END SUBROUTINE init_barostat_variables
933 SUBROUTINE init_nhc_forces(nhc)
937 CHARACTER(len=*),
PARAMETER :: routinen =
'init_nhc_forces'
939 INTEGER :: handle, i, j
941 CALL timeset(routinen, handle)
943 cpassert(
ASSOCIATED(nhc))
945 DO i = 1,
SIZE(nhc%nvt, 2)
946 DO j = 2,
SIZE(nhc%nvt, 1)
947 nhc%nvt(j, i)%f = nhc%nvt(j - 1, i)%mass* &
948 nhc%nvt(j - 1, i)%v**2 - &
950 IF (nhc%nvt(j, i)%mass > 0.0_dp)
THEN
951 nhc%nvt(j, i)%f = nhc%nvt(j, i)%f/nhc%nvt(j, i)%mass
956 CALL timestop(handle)
958 END SUBROUTINE init_nhc_forces
Handles all functions related to the CELL.
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
subroutine, public initialize_npt(simpar, globenv, npt_info, cell, work_section)
...
subroutine, public initialize_nhc_baro(simpar, para_env, globenv, nhc, nose_section, save_mem)
fire up the thermostats, if NPT
subroutine, public initialize_nhc_slow(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem)
...
subroutine, public initialize_nhc_shell(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem, binary_restart_file_name)
...
subroutine, public initialize_nhc_fast(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem)
...
subroutine, public initialize_nhc_part(thermostat_info, simpar, local_molecules, molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, gci, save_mem, binary_restart_file_name)
...
subroutine, public nhc_to_particle_mapping_fast(thermostat_info, simpar, local_molecules, molecule_set, molecule_kind_set, nhc, para_env, gci)
Creates the thermostatting maps.
subroutine, public nhc_to_particle_mapping_slow(thermostat_info, simpar, local_molecules, molecule_set, molecule_kind_set, nhc, para_env, gci)
Creates the thermostatting maps.
subroutine, public nhc_to_barostat_mapping(simpar, nhc)
Creates the thermostatting for the barostat.
subroutine, public nhc_to_shell_mapping(thermostat_info, simpar, local_molecules, molecule_set, molecule_kind_set, nhc, para_env, gci)
...
subroutine, public nhc_to_particle_mapping(thermostat_info, simpar, local_molecules, molecule_set, molecule_kind_set, nhc, para_env, gci)
Creates the thermostatting maps.
Lumps all possible extended system variables into one type for easy access and passing.
logical, parameter, public debug_isotropic_limit
Define type storing the global information of a run. Keep the amount of stored data small....
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
Define the data structure for the molecule information.
Type for storing MD parameters.
Thermostat structure: module containing thermostat available for MD.
Utilities for thermostats.
subroutine, public get_nhc_energies(nhc, nhc_pot, nhc_kin, para_env, array_kin, array_pot)
Calculates kinetic energy and potential energy of the nhc variables.
Type defining parameters related to the simulation cell.
structure to store local (to a processor) ordered lists of integers.
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment
Simulation parameter type for molecular dynamics.