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) &
130 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
131 "MASS section (or none) in the BAROSTAT section")
132 restart = explicit .AND. restart
138 DO i = 1,
SIZE(npt_info, 1)
139 DO j = 1,
SIZE(npt_info, 2)
141 npt_info(i, j)%v = buffer(ind)
146 DO i = 1,
SIZE(npt_info, 1)
147 DO j = 1,
SIZE(npt_info, 2)
149 npt_info(i, j)%mass = buffer(ind)
153 CALL init_barostat_variables(npt_info, simpar%tau_cell, temp, &
154 simpar%nfree, simpar%ensemble, simpar%cmass, &
160 CALL timestop(handle)
181 LOGICAL,
INTENT(IN) :: save_mem
183 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_baro'
187 REAL(kind=
dp) :: temp
189 CALL timeset(routinen, handle)
196 IF (nhc%nyosh > 0)
THEN
197 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
198 CALL set_yoshida_coef(nhc, simpar%dt)
201 CALL restart_nose(nhc, nose_section, save_mem, restart,
"",
"", para_env)
203 IF (.NOT. restart)
THEN
206 SELECT CASE (simpar%ensemble)
208 temp = simpar%temp_baro_ext
210 IF (nhc%nhc_len /= 0)
THEN
211 CALL init_nhc_variables(nhc, temp, para_env, globenv)
215 CALL init_nhc_forces(nhc)
217 CALL timestop(handle)
237 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
250 LOGICAL,
INTENT(IN) :: save_mem
252 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_slow'
257 CALL timeset(routinen, handle)
263 molecule, molecule_kind_set, nhc, para_env, gci)
266 IF (nhc%nyosh > 0)
THEN
267 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
268 CALL set_yoshida_coef(nhc, simpar%dt)
271 CALL restart_nose(nhc, nose_section, save_mem, restart,
"",
"", para_env)
273 IF (.NOT. restart)
THEN
276 IF (nhc%nhc_len /= 0)
THEN
277 CALL init_nhc_variables(nhc, simpar%temp_slow, para_env, globenv)
281 CALL init_nhc_forces(nhc)
283 CALL timestop(handle)
303 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
316 LOGICAL,
INTENT(IN) :: save_mem
318 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_fast'
323 CALL timeset(routinen, handle)
329 molecule, molecule_kind_set, nhc, para_env, gci)
332 IF (nhc%nyosh > 0)
THEN
333 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
334 CALL set_yoshida_coef(nhc, simpar%dt)
337 CALL restart_nose(nhc, nose_section, save_mem, restart,
"",
"", para_env)
339 IF (.NOT. restart)
THEN
342 IF (nhc%nhc_len /= 0)
THEN
343 CALL init_nhc_variables(nhc, simpar%temp_fast, para_env, globenv)
347 CALL init_nhc_forces(nhc)
349 CALL timestop(handle)
370 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
371 gci, save_mem, binary_restart_file_name)
383 LOGICAL,
INTENT(IN) :: save_mem
384 CHARACTER(LEN=*),
INTENT(IN) :: binary_restart_file_name
386 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_part'
391 CALL timeset(routinen, handle)
397 molecule, molecule_kind_set, nhc, para_env, gci)
400 IF (nhc%nyosh > 0)
THEN
401 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
402 CALL set_yoshida_coef(nhc, simpar%dt)
405 CALL restart_nose(nhc, nose_section, save_mem, restart, binary_restart_file_name, &
406 "PARTICLE", para_env)
408 IF (.NOT. restart)
THEN
411 IF (nhc%nhc_len /= 0)
THEN
412 CALL init_nhc_variables(nhc, simpar%temp_ext, para_env, globenv)
416 CALL init_nhc_forces(nhc)
418 CALL timestop(handle)
439 molecule, molecule_kind_set, para_env, globenv, nhc, nose_section, &
440 gci, save_mem, binary_restart_file_name)
452 LOGICAL,
INTENT(IN) :: save_mem
453 CHARACTER(LEN=*),
INTENT(IN) :: binary_restart_file_name
455 CHARACTER(len=*),
PARAMETER :: routinen =
'initialize_nhc_shell'
460 CALL timeset(routinen, handle)
463 molecule, molecule_kind_set, nhc, para_env, gci)
467 IF (nhc%nyosh > 0)
THEN
468 ALLOCATE (nhc%dt_yosh(1:nhc%nyosh))
469 CALL set_yoshida_coef(nhc, simpar%dt)
472 CALL restart_nose(nhc, nose_section, save_mem, restart, binary_restart_file_name, &
475 IF (.NOT. restart)
THEN
478 IF (nhc%nhc_len /= 0)
THEN
479 CALL init_nhc_variables(nhc, simpar%temp_sh_ext, para_env, globenv)
483 CALL init_nhc_forces(nhc)
485 CALL timestop(handle)
498 SUBROUTINE set_yoshida_coef(nhc, dt)
501 REAL(kind=
dp),
INTENT(IN) :: dt
503 REAL(kind=
dp),
DIMENSION(nhc%nyosh) :: yosh_wt
505 SELECT CASE (nhc%nyosh)
507 cpabort(
'Value not available.')
511 yosh_wt(1) = 1.0_dp/(2.0_dp - (2.0_dp)**(1.0_dp/3.0_dp))
512 yosh_wt(2) = 1.0_dp - 2.0_dp*yosh_wt(1)
513 yosh_wt(3) = yosh_wt(1)
515 yosh_wt(1) = 1.0_dp/(4.0_dp - (4.0_dp)**(1.0_dp/3.0_dp))
516 yosh_wt(2) = yosh_wt(1)
517 yosh_wt(4) = yosh_wt(1)
518 yosh_wt(5) = yosh_wt(1)
519 yosh_wt(3) = 1.0_dp - 4.0_dp*yosh_wt(1)
521 yosh_wt(1) = .78451361047756_dp
522 yosh_wt(2) = .235573213359357_dp
523 yosh_wt(3) = -1.17767998417887_dp
524 yosh_wt(4) = 1.0_dp - 2.0_dp*(yosh_wt(1) + yosh_wt(2) + yosh_wt(3))
525 yosh_wt(5) = yosh_wt(3)
526 yosh_wt(6) = yosh_wt(2)
527 yosh_wt(7) = yosh_wt(1)
529 yosh_wt(1) = 0.192_dp
530 yosh_wt(2) = 0.554910818409783619692725006662999_dp
531 yosh_wt(3) = 0.124659619941888644216504240951585_dp
532 yosh_wt(4) = -0.843182063596933505315033808282941_dp
533 yosh_wt(5) = 1.0_dp - 2.0_dp*(yosh_wt(1) + yosh_wt(2) + &
534 yosh_wt(3) + yosh_wt(4))
535 yosh_wt(6) = yosh_wt(4)
536 yosh_wt(7) = yosh_wt(3)
537 yosh_wt(8) = yosh_wt(2)
538 yosh_wt(9) = yosh_wt(1)
540 yosh_wt(1) = 0.102799849391985_dp
541 yosh_wt(2) = -0.196061023297549e1_dp
542 yosh_wt(3) = 0.193813913762276e1_dp
543 yosh_wt(4) = -0.158240635368243_dp
544 yosh_wt(5) = -0.144485223686048e1_dp
545 yosh_wt(6) = 0.253693336566229_dp
546 yosh_wt(7) = 0.914844246229740_dp
547 yosh_wt(8) = 1.0_dp - 2.0_dp*(yosh_wt(1) + yosh_wt(2) + &
548 yosh_wt(3) + yosh_wt(4) + yosh_wt(5) + yosh_wt(6) + yosh_wt(7))
549 yosh_wt(9) = yosh_wt(7)
550 yosh_wt(10) = yosh_wt(6)
551 yosh_wt(11) = yosh_wt(5)
552 yosh_wt(12) = yosh_wt(4)
553 yosh_wt(13) = yosh_wt(3)
554 yosh_wt(14) = yosh_wt(2)
555 yosh_wt(15) = yosh_wt(1)
557 nhc%dt_yosh = dt*yosh_wt/real(nhc%nc, kind=
dp)
559 END SUBROUTINE set_yoshida_coef
575 SUBROUTINE restart_nose(nhc, nose_section, save_mem, restart, &
576 binary_restart_file_name, thermostat_name, &
581 LOGICAL,
INTENT(IN) :: save_mem
582 LOGICAL,
INTENT(OUT) :: restart
583 CHARACTER(LEN=*),
INTENT(IN) :: binary_restart_file_name, thermostat_name
586 CHARACTER(len=*),
PARAMETER :: routinen =
'restart_nose'
588 INTEGER :: handle, i, ind, j
590 REAL(kind=
dp),
DIMENSION(:),
POINTER :: buffer
594 CALL timeset(routinen, handle)
597 NULLIFY (work_section)
599 IF (len_trim(binary_restart_file_name) > 0)
THEN
613 IF (
ASSOCIATED(nose_section))
THEN
619 IF (.NOT. restart .AND. explicit) &
620 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
621 "COORD and MASS and FORCE section (or none) in the NOSE section")
622 restart = explicit .AND. restart
625 IF (.NOT. restart .AND. explicit) &
626 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
627 "COORD and MASS and FORCE section (or none) in the NOSE section")
628 restart = explicit .AND. restart
631 IF (.NOT. restart .AND. explicit) &
632 CALL cp_abort(__location__,
"You need to define both VELOCITY and "// &
633 "COORD and MASS and FORCE section (or none) in the NOSE section")
634 restart = explicit .AND. restart
638 map_info => nhc%map_info
640 DO i = 1,
SIZE(nhc%nvt, 2)
641 ind = map_info%index(i)
642 ind = (ind - 1)*nhc%nhc_len
643 DO j = 1,
SIZE(nhc%nvt, 1)
645 nhc%nvt(j, i)%eta = buffer(ind)
649 DO i = 1,
SIZE(nhc%nvt, 2)
650 ind = map_info%index(i)
651 ind = (ind - 1)*nhc%nhc_len
652 DO j = 1,
SIZE(nhc%nvt, 1)
654 nhc%nvt(j, i)%v = buffer(ind)
658 DO i = 1,
SIZE(nhc%nvt, 2)
659 ind = map_info%index(i)
660 ind = (ind - 1)*nhc%nhc_len
661 DO j = 1,
SIZE(nhc%nvt, 1)
663 nhc%nvt(j, i)%mass = buffer(ind)
667 DO i = 1,
SIZE(nhc%nvt, 2)
668 ind = map_info%index(i)
669 ind = (ind - 1)*nhc%nhc_len
670 DO j = 1,
SIZE(nhc%nvt, 1)
672 nhc%nvt(j, i)%f = buffer(ind)
678 NULLIFY (work_section)
681 NULLIFY (work_section)
684 NULLIFY (work_section)
687 NULLIFY (work_section)
694 CALL timestop(handle)
696 END SUBROUTINE restart_nose
708 SUBROUTINE init_nhc_variables(nhc, temp_ext, para_env, globenv)
710 REAL(kind=
dp),
INTENT(IN) :: temp_ext
714 CHARACTER(len=*),
PARAMETER :: routinen =
'init_nhc_variables'
716 INTEGER :: handle, i, icount, j, number, tot_rn
717 REAL(kind=
dp) :: akin, dum, temp
718 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: array_of_rn
721 CALL timeset(routinen, handle)
726 nhc%nvt(:, :)%mass = nhc%nvt(:, :)%nkt*nhc%tau_nhc**2
727 nhc%nvt(:, :)%eta = 0._dp
728 nhc%nvt(:, :)%v = 0._dp
729 nhc%nvt(:, :)%f = 0._dp
731 map_info => nhc%map_info
732 SELECT CASE (map_info%dis_type)
735 tot_rn = nhc%glob_num_nhc*nhc%nhc_len
737 ALLOCATE (array_of_rn(tot_rn))
738 array_of_rn(:) = 0.0_dp
741 SELECT CASE (map_info%dis_type)
744 DO i = 1, nhc%loc_num_nhc
745 DO j = 1, nhc%nhc_len
746 nhc%nvt(j, i)%v = globenv%gaussian_rng_stream%next()
751 DO i = 1, nhc%loc_num_nhc
752 DO j = 1, nhc%nhc_len
753 akin = akin + 0.5_dp*(nhc%nvt(j, i)%mass* &
758 number = nhc%loc_num_nhc
761 temp = 2.0_dp*akin/real(number, kind=
dp)
762 IF (temp > 0.0_dp) temp = sqrt(temp_ext/temp)
763 DO i = 1, nhc%loc_num_nhc
764 DO j = 1, nhc%nhc_len
765 nhc%nvt(j, i)%v = temp*nhc%nvt(j, i)%v
766 nhc%nvt(j, i)%eta = 0.0_dp
771 DO i = 1, nhc%loc_num_nhc
772 DO j = 2, nhc%nhc_len
773 nhc%nvt(j, i)%f = nhc%nvt(j - 1, i)%mass*nhc%nvt(j - 1, i)%v* &
774 nhc%nvt(j - 1, i)%v - nhc%nvt(j, i)%nkt
775 IF (nhc%nvt(j, i)%mass > 0.0_dp)
THEN
776 nhc%nvt(j, i)%f = nhc%nvt(j, i)%f/nhc%nvt(j, i)%mass
783 array_of_rn(i) = globenv%gaussian_rng_stream%next()
786 DO i = 1, nhc%loc_num_nhc
787 icount = map_info%index(i)
788 icount = (icount - 1)*nhc%nhc_len
789 DO j = 1, nhc%nhc_len
791 nhc%nvt(j, i)%v = array_of_rn(icount)
793 nhc%nvt(j, i)%eta = 0.0_dp
796 DEALLOCATE (array_of_rn)
798 number = nhc%glob_num_nhc
802 temp = 2.0_dp*akin/real(number, kind=
dp)
803 IF (temp > 0.0_dp) temp = sqrt(temp_ext/temp)
804 DO i = 1, nhc%loc_num_nhc
805 DO j = 1, nhc%nhc_len
806 nhc%nvt(j, i)%v = temp*nhc%nvt(j, i)%v
811 DO i = 1, nhc%loc_num_nhc
812 DO j = 2, nhc%nhc_len
813 nhc%nvt(j, i)%f = nhc%nvt(j - 1, i)%mass*nhc%nvt(j - 1, i)%v* &
814 nhc%nvt(j - 1, i)%v - nhc%nvt(j, i)%nkt
815 IF (nhc%nvt(j, i)%mass > 0.0_dp)
THEN
816 nhc%nvt(j, i)%f = nhc%nvt(j, i)%f/nhc%nvt(j, i)%mass
823 CALL timestop(handle)
825 END SUBROUTINE init_nhc_variables
840 SUBROUTINE init_barostat_variables(npt, tau_cell, temp_ext, nfree, ensemble, &
845 REAL(kind=
dp),
INTENT(IN) :: tau_cell, temp_ext
846 INTEGER,
INTENT(IN) :: nfree, ensemble
847 REAL(kind=
dp),
INTENT(IN) :: cmass
850 CHARACTER(len=*),
PARAMETER :: routinen =
'init_barostat_variables'
852 INTEGER :: handle, i, j, number
853 REAL(kind=
dp) :: akin, temp, v
855 CALL timeset(routinen, handle)
861 npt(:, :)%eps = 0.0_dp
864 SELECT CASE (ensemble)
866 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2
868 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2/3.0_dp
870 npt(:, :)%mass = cmass
872 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2/3.0_dp
874 npt(:, :)%mass = real(nfree + 3, kind=
dp)*temp_ext*tau_cell**2
877 DO i = 1,
SIZE(npt, 1)
878 DO j = i,
SIZE(npt, 2)
879 v = globenv%gaussian_rng_stream%next()
888 DO i = 1,
SIZE(npt, 1)
889 DO j = 1,
SIZE(npt, 2)
890 akin = akin + 0.5_dp*(npt(j, i)%mass*npt(j, i)%v*npt(j, i)%v)
894 number =
SIZE(npt, 1)*
SIZE(npt, 2)
897 IF (number /= 0)
THEN
898 temp = 2.0_dp*akin/real(number, kind=
dp)
899 IF (temp > 0.0_dp) temp = sqrt(temp_ext/temp)
901 DO i = 1,
SIZE(npt, 1)
902 DO j = i,
SIZE(npt, 2)
903 npt(j, i)%v = temp*npt(j, i)%v
904 npt(i, j)%v = npt(j, i)%v
908 WRITE (*, *)
'DEBUG ISOTROPIC LIMIT| INITIAL v_eps', npt(j, i)%v
914 SELECT CASE (ensemble)
920 CALL timestop(handle)
922 END SUBROUTINE init_barostat_variables
929 SUBROUTINE init_nhc_forces(nhc)
933 CHARACTER(len=*),
PARAMETER :: routinen =
'init_nhc_forces'
935 INTEGER :: handle, i, j
937 CALL timeset(routinen, handle)
939 cpassert(
ASSOCIATED(nhc))
941 DO i = 1,
SIZE(nhc%nvt, 2)
942 DO j = 2,
SIZE(nhc%nvt, 1)
943 nhc%nvt(j, i)%f = nhc%nvt(j - 1, i)%mass* &
944 nhc%nvt(j - 1, i)%v**2 - &
946 IF (nhc%nvt(j, i)%mass > 0.0_dp)
THEN
947 nhc%nvt(j, i)%f = nhc%nvt(j, i)%f/nhc%nvt(j, i)%mass
952 CALL timestop(handle)
954 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.