143#include "../base/base_uses.f90" 
  148   LOGICAL, 
PARAMETER, 
PRIVATE :: debug_this_module = .true.
 
  149   CHARACTER(len=*), 
PARAMETER, 
PRIVATE :: moduleN = 
'pint_methods' 
  171   SUBROUTINE pint_create(pint_env, input, input_declaration, para_env)
 
  173      TYPE(pint_env_type), 
INTENT(OUT)                   :: pint_env
 
  174      TYPE(section_vals_type), 
POINTER                   :: input
 
  175      TYPE(section_type), 
POINTER                        :: input_declaration
 
  176      TYPE(mp_para_env_type), 
POINTER                    :: para_env
 
  178      CHARACTER(len=*), 
PARAMETER                        :: routineN = 
'pint_create' 
  180      CHARACTER(len=2*default_string_length)             :: msg
 
  181      CHARACTER(len=default_path_length)                 :: output_file_name, project_name
 
  182      INTEGER                                            :: handle, iat, ibead, icont, idim, idir, &
 
  183                                                            ierr, ig, itmp, nrep, prep, stat
 
  184      LOGICAL                                            :: explicit, ltmp
 
  185      REAL(kind=
dp)                                      :: dt, mass, omega
 
  186      TYPE(cp_subsys_type), 
POINTER                      :: subsys
 
  187      TYPE(f_env_type), 
POINTER                          :: f_env
 
  188      TYPE(global_constraint_type), 
POINTER              :: gci
 
  189      TYPE(particle_list_type), 
POINTER                  :: particles
 
  190      TYPE(replica_env_type), 
POINTER                    :: rep_env
 
  191      TYPE(section_vals_type), 
POINTER :: constraint_section, gle_section, nose_section, &
 
  192         piglet_section, pile_section, pint_section, qtb_section, transform_section
 
  194      CALL timeset(routinen, handle)
 
  196      NULLIFY (f_env, subsys, particles, nose_section, gle_section, gci)
 
  198      cpassert(
ASSOCIATED(input))
 
  199      cpassert(input%ref_count > 0)
 
  207      IF ((prep < 1) .OR. (prep > para_env%num_pe) .OR. &
 
  208          (mod(prep*nrep, para_env%num_pe) /= 0)) 
THEN 
  209         prep = para_env%num_pe/
gcd(para_env%num_pe, nrep)
 
  210         IF (para_env%is_source()) 
THEN 
  211            WRITE (unit=msg, fmt=*) 
"PINT WARNING: Adjusting number of processors per replica to ", prep
 
  226                          input_declaration=input_declaration, nrep=nrep, prep=prep, row_force=.true.)
 
  228      IF (len_trim(output_file_name) .GT. 0) 
THEN 
  233      IF (.NOT. 
ASSOCIATED(rep_env)) 
RETURN 
  235      NULLIFY (pint_env%logger)
 
  239      NULLIFY (pint_env%replicas, pint_env%input, pint_env%staging_env, &
 
  240               pint_env%normalmode_env, pint_env%propagator)
 
  242      pint_env%replicas => rep_env
 
  243      pint_env%ndim = rep_env%ndim
 
  244      pint_env%input => input
 
  251      pint_env%first_step = itmp
 
  257         pint_env%last_step = itmp
 
  258         pint_env%num_steps = pint_env%last_step - pint_env%first_step
 
  262         pint_env%num_steps = itmp
 
  263         pint_env%last_step = pint_env%first_step + pint_env%num_steps
 
  268      pint_env%t = pint_env%first_step*pint_env%dt
 
  273                                r_val=pint_env%t_tol)
 
  277      ALLOCATE (pint_env%propagator)
 
  279                                i_val=pint_env%propagator%prop_kind)
 
  283         pint_env%propagator%temp_phys2sim = real(pint_env%p, 
dp)
 
  284         pint_env%propagator%physpotscale = 1.0_dp
 
  286         pint_env%propagator%temp_phys2sim = 1.0_dp
 
  287         pint_env%propagator%physpotscale = 1.0_dp/real(pint_env%p, 
dp)
 
  289      pint_env%propagator%temp_sim2phys = 1.0_dp/pint_env%propagator%temp_phys2sim
 
  290      pint_env%kT = pint_env%kT*pint_env%propagator%temp_phys2sim
 
  293                                i_val=pint_env%transform)
 
  297         cpabort(
"CMD Propagator without normal modes not implemented!")
 
  300      NULLIFY (pint_env%tx, pint_env%tv, pint_env%tv_t, pint_env%tv_old, pint_env%tv_new, pint_env%tf)
 
  308            cpabort(
"RPMD Propagator with Nose-thermostat not implemented!")
 
  311         IF (pint_env%nnos > 0) 
THEN 
  314               pint_env%tx(pint_env%nnos, pint_env%p, pint_env%ndim), &
 
  315               pint_env%tv(pint_env%nnos, pint_env%p, pint_env%ndim), &
 
  316               pint_env%tv_t(pint_env%nnos, pint_env%p, pint_env%ndim), &
 
  317               pint_env%tv_old(pint_env%nnos, pint_env%p, pint_env%ndim), &
 
  318               pint_env%tv_new(pint_env%nnos, pint_env%p, pint_env%ndim), &
 
  319               pint_env%tf(pint_env%nnos, pint_env%p, pint_env%ndim))
 
  322            pint_env%tv_t = 0._dp
 
  323            pint_env%tv_old = 0._dp
 
  324            pint_env%tv_new = 0._dp
 
  329      pint_env%beta = 1._dp/(pint_env%kT*pint_env%propagator%temp_sim2phys)
 
  335      pint_env%v_tol = 0.0_dp 
 
  338                         name=
"pint_randomG", &
 
  340                         extended_precision=.true.)
 
  342      ALLOCATE (pint_env%e_pot_bead(pint_env%p))
 
  343      pint_env%e_pot_bead = 0._dp
 
  344      pint_env%e_pot_h = 0._dp
 
  345      pint_env%e_kin_beads = 0._dp
 
  346      pint_env%e_pot_t = 0._dp
 
  347      pint_env%e_gle = 0._dp
 
  348      pint_env%e_pile = 0._dp
 
  349      pint_env%e_piglet = 0._dp
 
  350      pint_env%e_qtb = 0._dp
 
  351      pint_env%e_kin_t = 0._dp
 
  352      pint_env%energy(:) = 0.0_dp
 
  357         pint_env%x(pint_env%p, pint_env%ndim), &
 
  358         pint_env%v(pint_env%p, pint_env%ndim), &
 
  359         pint_env%f(pint_env%p, pint_env%ndim), &
 
  360         pint_env%external_f(pint_env%p, pint_env%ndim), &
 
  361         pint_env%ux(pint_env%p, pint_env%ndim), &
 
  362         pint_env%ux_t(pint_env%p, pint_env%ndim), &
 
  363         pint_env%uv(pint_env%p, pint_env%ndim), &
 
  364         pint_env%uv_t(pint_env%p, pint_env%ndim), &
 
  365         pint_env%uv_new(pint_env%p, pint_env%ndim), &
 
  366         pint_env%uf(pint_env%p, pint_env%ndim), &
 
  367         pint_env%uf_h(pint_env%p, pint_env%ndim), &
 
  368         pint_env%centroid(pint_env%ndim), &
 
  369         pint_env%rtmp_ndim(pint_env%ndim), &
 
  370         pint_env%rtmp_natom(pint_env%ndim/3), &
 
  376      pint_env%external_f = 0._dp
 
  378      pint_env%ux_t = 0._dp
 
  380      pint_env%uv_t = 0._dp
 
  381      pint_env%uv_new = 0._dp
 
  383      pint_env%uf_h = 0._dp
 
  384      pint_env%centroid(:) = 0.0_dp
 
  385      pint_env%rtmp_ndim = 0._dp
 
  386      pint_env%rtmp_natom = 0._dp
 
  387      pint_env%time_per_step = 0.0_dp
 
  391                                                         "MOTION%PINT%STAGING")
 
  392         ALLOCATE (pint_env%staging_env)
 
  394                                 p=pint_env%p, kt=pint_env%kT)
 
  397                                                         "MOTION%PINT%NORMALMODE")
 
  398         ALLOCATE (pint_env%normalmode_env)
 
  400                                    transform_section, p=pint_env%p, kt=pint_env%kT, propagator=pint_env%propagator%prop_kind)
 
  401         IF (para_env%is_source()) 
THEN 
  403               IF (10.0_dp*pint_env%dt/real(pint_env%nrespa, 
dp) > &
 
  404                   twopi/(pint_env%p*sqrt(maxval(pint_env%normalmode_env%lambda))* &
 
  405                          pint_env%normalmode_env%modefactor)) 
THEN 
  406                  msg = 
"PINT WARNING| Number of RESPA steps to small "// &
 
  407                        "to integrate the harmonic springs." 
  413      ALLOCATE (pint_env%mass(pint_env%ndim))
 
  421      DO iat = 1, pint_env%ndim/3
 
  425            pint_env%mass(idim) = mass
 
  431      ALLOCATE (pint_env%Q(pint_env%p), &
 
  432                pint_env%mass_beads(pint_env%p, pint_env%ndim), &
 
  433                pint_env%mass_fict(pint_env%p, pint_env%ndim))
 
  436                                  mass_beads=pint_env%mass_beads, mass_fict=pint_env%mass_fict, &
 
  440                                     mass=pint_env%mass, mass_beads=pint_env%mass_beads, &
 
  441                                     mass_fict=pint_env%mass_fict, q=pint_env%Q)
 
  444      NULLIFY (pint_env%gle)
 
  448         ALLOCATE (pint_env%gle)
 
  449         CALL gle_init(pint_env%gle, dt=pint_env%dt/pint_env%nrespa, temp=pint_env%kT, &
 
  451         IF (pint_env%pimd_thermostat == 
thermostat_none .AND. pint_env%gle%ndim .GT. 0) 
THEN 
  456            pint_env%gle%loc_num_gle = pint_env%p*pint_env%ndim
 
  457            pint_env%gle%glob_num_gle = pint_env%gle%loc_num_gle
 
  458            ALLOCATE (pint_env%gle%map_info%index(pint_env%gle%loc_num_gle))
 
  460            DO itmp = 1, pint_env%gle%loc_num_gle
 
  461               pint_env%gle%map_info%index(itmp) = itmp
 
  468            CALL gle_matrix_exp((-pint_env%dt/pint_env%nrespa*0.5_dp)*pint_env%gle%a_mat, &
 
  469                                pint_env%gle%ndim, 15, 15, pint_env%gle%gle_t)
 
  472                                                               matmul(pint_env%gle%c_mat, transpose(pint_env%gle%gle_t))), &
 
  473                                   pint_env%gle%gle_s, pint_env%gle%ndim)
 
  480      NULLIFY (pint_env%pile_therm)
 
  486                                   "MOTION%PINT%INIT%THERMOSTAT_SEED", &
 
  487                                   i_val=pint_env%thermostat_rng_seed)
 
  490            ALLOCATE (pint_env%pile_therm)
 
  493                                normalmode_env=pint_env%normalmode_env, &
 
  494                                section=pile_section)
 
  496            cpabort(
"PILE thermostat can't be used with another thermostat.")
 
  501      NULLIFY (pint_env%piglet_therm)
 
  507                                   "MOTION%PINT%INIT%THERMOSTAT_SEED", &
 
  508                                   i_val=pint_env%thermostat_rng_seed)
 
  511            ALLOCATE (pint_env%piglet_therm)
 
  518                                  dt=pint_env%dt, para_env=para_env)
 
  520            cpabort(
"PILE thermostat can't be used with another thermostat.")
 
  525      NULLIFY (pint_env%qtb_therm)
 
  531                                   "MOTION%PINT%INIT%THERMOSTAT_SEED", &
 
  532                                   i_val=pint_env%thermostat_rng_seed)
 
  537                               normalmode_env=pint_env%normalmode_env, &
 
  540            cpabort(
"QTB thermostat can't be used with another thermostat.")
 
  548            WRITE (unit=msg, fmt=*) 
"PINT WARNING| Nose Thermostat only available in "// &
 
  549               "the numeric harmonic integrator. Switching to numeric harmonic integrator." 
  554            WRITE (unit=msg, fmt=*) 
"PINT WARNING| GLE Thermostat only available in "// &
 
  555               "the numeric harmonic integrator. Switching to numeric harmonic integrator." 
  561            WRITE (unit=msg, fmt=*) 
"PINT WARNING| PILE Thermostat only available in "// &
 
  562               "the exact harmonic integrator. Switching to exact harmonic integrator." 
  567            WRITE (unit=msg, fmt=*) 
"PINT WARNING| PIGLET Thermostat only available in "// &
 
  568               "the exact harmonic integrator. Switching to exact harmonic integrator." 
  573            WRITE (unit=msg, fmt=*) 
"PINT WARNING| QTB Thermostat only available in "// &
 
  574               "the exact harmonic integrator. Switching to exact harmonic integrator." 
  581         IF (pint_env%nrespa /= 1) 
THEN 
  583            WRITE (unit=msg, fmt=*) 
"PINT WARNING| Adjusting NRESPA to 1 for exact harmonic integration." 
  586         NULLIFY (pint_env%wsinex)
 
  587         ALLOCATE (pint_env%wsinex(pint_env%p))
 
  588         NULLIFY (pint_env%iwsinex)
 
  589         ALLOCATE (pint_env%iwsinex(pint_env%p))
 
  590         NULLIFY (pint_env%cosex)
 
  591         ALLOCATE (pint_env%cosex(pint_env%p))
 
  592         dt = pint_env%dt/real(pint_env%nrespa, kind=
dp)
 
  594         pint_env%wsinex(1) = 0.0_dp
 
  595         pint_env%iwsinex(1) = dt
 
  596         pint_env%cosex(1) = 1.0_dp
 
  597         DO ibead = 2, pint_env%p
 
  598            omega = sqrt(pint_env%normalmode_env%lambda(ibead))
 
  599            pint_env%wsinex(ibead) = sin(omega*dt)*omega
 
  600            pint_env%iwsinex(ibead) = sin(omega*dt)/omega
 
  601            pint_env%cosex(ibead) = cos(omega*dt)
 
  608         pint_env%first_propagated_mode = 2
 
  610         pint_env%first_propagated_mode = 1
 
  614      NULLIFY (pint_env%simpar)
 
  619      pint_env%simpar%constraint = explicit
 
  620      pint_env%kTcorr = 1.0_dp
 
  623      pint_env%beadwise_constraints = .false.
 
  625                                l_val=pint_env%beadwise_constraints)
 
  626      IF (pint_env%simpar%constraint) 
THEN 
  627         IF (pint_env%beadwise_constraints) 
THEN 
  638            cpabort(
"Constraints are not supported for staging transformation")
 
  643            WRITE (unit=msg, fmt=*) 
"GLE Thermostat not supported for "// &
 
  644               "constraints. Switch to NOSE for numeric integration." 
  650            IF (pint_env%beadwise_constraints) 
THEN 
  651               cpabort(
"Beadwise constraints are not supported for NOSE Thermostat.")
 
  654               WRITE (unit=msg, fmt=*) 
"PINT WARNING| Nose Thermostat set to "// &
 
  655                  "zero for constrained atoms. Careful interpretation of temperature." 
  657               WRITE (unit=msg, fmt=*) 
"PINT WARNING| Lagrange multipliers are "// &
 
  658                  "are printed every RESPA step and need to be treated carefully." 
  664                                   r_val=pint_env%simpar%shake_tol)
 
  666                                                                constraint_section, &
 
  668                                                                extension=
".shakeLog", &
 
  669                                                                log_filename=.false.)
 
  671                                                                     constraint_section, &
 
  672                                                                     "LAGRANGE_MULTIPLIERS", &
 
  673                                                                     extension=
".LagrangeMultLog", &
 
  674                                                                     log_filename=.false.)
 
  675         pint_env%simpar%dump_lm = &
 
  677                                             constraint_section, &
 
  681         pint_env%n_atoms_constraints = 0
 
  682         DO ig = 1, gci%ncolv%ntot
 
  684            pint_env%n_atoms_constraints = pint_env%n_atoms_constraints + 
SIZE(gci%colv_list(ig)%i_atoms)
 
  687         ALLOCATE (pint_env%atoms_constraints(pint_env%n_atoms_constraints))
 
  689         DO ig = 1, gci%ncolv%ntot
 
  690            DO iat = 1, 
SIZE(gci%colv_list(ig)%i_atoms)
 
  692               pint_env%atoms_constraints(icont) = gci%colv_list(ig)%i_atoms(iat)
 
  700            pint_env%kTcorr = 1.0_dp + real(3*pint_env%n_atoms_constraints, 
dp)/(real(pint_env%ndim, 
dp)*real(pint_env%p, 
dp))
 
  704      CALL timestop(handle)
 
  706   END SUBROUTINE pint_create
 
  715   SUBROUTINE pint_release(pint_env)
 
  716      TYPE(pint_env_type), 
INTENT(INOUT)                 :: pint_env
 
  720      IF (
ASSOCIATED(pint_env%staging_env)) 
THEN 
  722         DEALLOCATE (pint_env%staging_env)
 
  724      IF (
ASSOCIATED(pint_env%normalmode_env)) 
THEN 
  726         DEALLOCATE (pint_env%normalmode_env)
 
  729      DEALLOCATE (pint_env%mass)
 
  730      DEALLOCATE (pint_env%e_pot_bead)
 
  732      DEALLOCATE (pint_env%x)
 
  733      DEALLOCATE (pint_env%v)
 
  734      DEALLOCATE (pint_env%f)
 
  735      DEALLOCATE (pint_env%external_f)
 
  736      DEALLOCATE (pint_env%mass_beads)
 
  737      DEALLOCATE (pint_env%mass_fict)
 
  738      DEALLOCATE (pint_env%ux)
 
  739      DEALLOCATE (pint_env%ux_t)
 
  740      DEALLOCATE (pint_env%uv)
 
  741      DEALLOCATE (pint_env%uv_t)
 
  742      DEALLOCATE (pint_env%uv_new)
 
  743      DEALLOCATE (pint_env%uf)
 
  744      DEALLOCATE (pint_env%uf_h)
 
  745      DEALLOCATE (pint_env%centroid)
 
  746      DEALLOCATE (pint_env%rtmp_ndim)
 
  747      DEALLOCATE (pint_env%rtmp_natom)
 
  748      DEALLOCATE (pint_env%propagator)
 
  750      IF (pint_env%simpar%constraint) 
THEN 
  751         DEALLOCATE (pint_env%atoms_constraints)
 
  756         DEALLOCATE (pint_env%wsinex)
 
  757         DEALLOCATE (pint_env%iwsinex)
 
  758         DEALLOCATE (pint_env%cosex)
 
  761      SELECT CASE (pint_env%pimd_thermostat)
 
  763         DEALLOCATE (pint_env%tx)
 
  764         DEALLOCATE (pint_env%tv)
 
  765         DEALLOCATE (pint_env%tv_t)
 
  766         DEALLOCATE (pint_env%tv_old)
 
  767         DEALLOCATE (pint_env%tv_new)
 
  768         DEALLOCATE (pint_env%tf)
 
  773         DEALLOCATE (pint_env%pile_therm)
 
  776         DEALLOCATE (pint_env%piglet_therm)
 
  779         DEALLOCATE (pint_env%qtb_therm)
 
  782      DEALLOCATE (pint_env%Q)
 
  784   END SUBROUTINE pint_release
 
  793   SUBROUTINE pint_test(para_env, input, input_declaration)
 
  794      TYPE(mp_para_env_type), 
POINTER                    :: para_env
 
  795      TYPE(section_vals_type), 
POINTER                   :: input
 
  796      TYPE(section_type), 
POINTER                        :: input_declaration
 
  798      INTEGER                                            :: i, ib, idim, unit_nr
 
  799      REAL(kind=
dp)                                      :: c, e_h, err
 
  800      REAL(kind=
dp), 
ALLOCATABLE, 
DIMENSION(:, :)        :: x1
 
  801      TYPE(pint_env_type)                                :: pint_env
 
  803      cpassert(
ASSOCIATED(para_env))
 
  804      cpassert(
ASSOCIATED(input))
 
  805      cpassert(para_env%is_valid())
 
  806      cpassert(input%ref_count > 0)
 
  808      CALL pint_create(pint_env, input, input_declaration, para_env)
 
  809      ALLOCATE (x1(pint_env%ndim, pint_env%p))
 
  810      x1(:, :) = pint_env%x
 
  815      DO i = 1, pint_env%ndim
 
  816         err = max(err, abs(x1(1, i) - pint_env%x(1, i)))
 
  818      IF (unit_nr > 0) 
WRITE (unit_nr, *) 
"diff_r1="//
cp_to_string(err)
 
  820      CALL pint_calc_uf_h(pint_env, e_h=e_h)
 
  821      c = -pint_env%staging_env%w_p**2
 
  823      DO idim = 1, pint_env%ndim
 
  824         DO ib = 1, pint_env%p
 
  825            pint_env%f(ib, idim) = pint_env%f(ib, idim) + &
 
  826                                   c*(2._dp*pint_env%x(ib, idim) &
 
  827                                      - pint_env%x(
modulo(ib - 2, pint_env%p) + 1, idim) &
 
  828                                      - pint_env%x(
modulo(ib, pint_env%p) + 1, idim))
 
  833      DO idim = 1, pint_env%ndim
 
  834         DO ib = 1, pint_env%p
 
  835            err = max(err, abs(pint_env%uf(ib, idim) - pint_env%uf_h(ib, idim)))
 
  838      IF (unit_nr > 0) 
WRITE (unit_nr, *) 
"diff_f_h="//
cp_to_string(err)
 
  840   END SUBROUTINE pint_test
 
  855   SUBROUTINE do_pint_run(para_env, input, input_declaration, globenv)
 
  861      CHARACTER(len=*), 
PARAMETER                        :: routinen = 
'do_pint_run' 
  862      INTEGER, 
PARAMETER                                 :: helium_only_mid = 1, &
 
  863                                                            int_pot_scan_mid = 4, &
 
  864                                                            solute_only_mid = 2, &
 
  865                                                            solute_with_helium_mid = 3
 
  867      CHARACTER(len=default_string_length)               :: stmp
 
  868      INTEGER                                            :: handle, mode
 
  869      LOGICAL                                            :: explicit, helium_only, int_pot_scan, &
 
  875      CALL timeset(routinen, handle)
 
  877      cpassert(
ASSOCIATED(para_env))
 
  878      cpassert(
ASSOCIATED(input))
 
  879      cpassert(para_env%is_valid())
 
  880      cpassert(input%ref_count > 0)
 
  883      NULLIFY (helium_section)
 
  885                                                   "MOTION%PINT%HELIUM")
 
  889                                   l_val=solvent_present)
 
  891         solvent_present = .false.
 
  895      IF (solvent_present) 
THEN 
  899         helium_only = .false.
 
  903      IF (solvent_present) 
THEN 
  907         int_pot_scan = .false.
 
  911      IF (helium_only .AND. int_pot_scan) 
THEN 
  912         stmp = 
"Options HELIUM_ONLY and INTERACTION_POT_SCAN are exclusive" 
  918      IF (solvent_present) 
THEN 
  919         IF (helium_only) 
THEN 
  920            mode = helium_only_mid
 
  922            IF (int_pot_scan) 
THEN 
  923               mode = int_pot_scan_mid
 
  925               mode = solute_with_helium_mid
 
  929         mode = solute_only_mid
 
  935      CASE (helium_only_mid)
 
  941      CASE (solute_only_mid)
 
  942         CALL pint_create(pint_env, input, input_declaration, para_env)
 
  943         CALL pint_init(pint_env)
 
  944         CALL pint_do_run(pint_env, globenv)
 
  945         CALL pint_release(pint_env)
 
  947      CASE (int_pot_scan_mid)
 
  948         CALL pint_create(pint_env, input, input_declaration, para_env)
 
  952         CALL pint_init(pint_env)
 
  954         CALL pint_run_scan(pint_env, helium_env)
 
  956         CALL pint_release(pint_env)
 
  958      CASE (solute_with_helium_mid)
 
  959         CALL pint_create(pint_env, input, input_declaration, para_env)
 
  961         CALL pint_init(pint_env)
 
  966         CALL pint_init_f(pint_env, helium_env=helium_env)
 
  968         CALL pint_do_run(pint_env, globenv, helium_env=helium_env)
 
  970         CALL pint_release(pint_env)
 
  973         cpabort(
"Unknown mode ("//trim(adjustl(
cp_to_string(mode)))//
")")
 
  976      CALL timestop(handle)
 
 
  989   SUBROUTINE pint_init(pint_env)
 
  993      CALL pint_init_x(pint_env)
 
  994      CALL pint_init_v(pint_env)
 
  995      CALL pint_init_t(pint_env)
 
  996      CALL pint_init_f(pint_env)
 
  998   END SUBROUTINE pint_init
 
 1015   SUBROUTINE pint_init_x(pint_env)
 
 1019      CHARACTER(len=5*default_string_length)             :: msg, tmp
 
 1020      INTEGER                                            :: ia, ib, ic, idim, input_seed, n_rep_val
 
 1021      LOGICAL                                            :: done_init, done_levy, done_rand, &
 
 1022                                                            explicit, levycorr, ltmp
 
 1023      REAL(kind=
dp)                                      :: tcorr, var
 
 1024      REAL(kind=
dp), 
DIMENSION(3)                        :: x0
 
 1025      REAL(kind=
dp), 
DIMENSION(3, 2)                     :: seed
 
 1026      REAL(kind=
dp), 
DIMENSION(:), 
POINTER               :: bx, r_vals
 
 1030      DO idim = 1, pint_env%ndim
 
 1031         DO ib = 1, pint_env%p
 
 1032            pint_env%x(ib, idim) = pint_env%replicas%r(idim, ib)
 
 1038                                "MOTION%PINT%INIT%LEVY_POS_SAMPLE", &
 
 1041                                "MOTION%PINT%INIT%LEVY_TEMP_FACTOR", &
 
 1045         IF (pint_env%beadwise_constraints) 
THEN 
 1046            WRITE (unit=msg, fmt=*) 
"Beadwise constraints are not supported for "// &
 
 1047               "the initialization of the beads as free particles. "// &
 
 1048               "Please use hot start (default)." 
 1053         ALLOCATE (bx(3*pint_env%p))
 
 1055                                   "MOTION%PINT%INIT%LEVY_SEED", i_val=input_seed)
 
 1056         seed(:, :) = real(input_seed, kind=
dp)
 
 1059                        name=
"tmp_rng_gaussian", &
 
 1061                        extended_precision=.true., &
 
 1065                                   "MOTION%PINT%INIT%LEVY_CORRELATED", &
 
 1071            x0 = (/0.0_dp, 0.0_dp, 0.0_dp/)
 
 1074            DO ia = 1, pint_env%ndim/3
 
 1075               var = sqrt(1.0_dp/(pint_env%kT*tcorr*pint_env%mass(3*ia)))
 
 1078                  DO ib = 1, pint_env%p
 
 1079                     pint_env%x(ib, idim) = pint_env%x(ib, idim) + bx(3*(ib - 1) + ic)*var
 
 1088            DO ia = 1, pint_env%ndim/3
 
 1089               x0(1) = pint_env%x(1, 3*(ia - 1) + 1)
 
 1090               x0(2) = pint_env%x(1, 3*(ia - 1) + 2)
 
 1091               x0(3) = pint_env%x(1, 3*(ia - 1) + 3)
 
 1092               var = sqrt(1.0_dp/(pint_env%kT*tcorr*pint_env%mass(3*ia)))
 
 1096                  DO ib = 1, pint_env%p
 
 1097                     pint_env%x(ib, idim) = pint_env%x(ib, idim) + bx(3*(ib - 1) + ic)
 
 1109      NULLIFY (input_section)
 
 1111                                                  "MOTION%PINT%BEADS%COORD")
 
 1115                                   n_rep_val=n_rep_val)
 
 1116         IF (n_rep_val > 0) 
THEN 
 1117            cpassert(n_rep_val == 1)
 
 1120            IF (
SIZE(r_vals) /= pint_env%p*pint_env%ndim) &
 
 1121               cpabort(
"Invalid size of MOTION%PINT%BEADS%COORD")
 
 1123            DO idim = 1, pint_env%ndim
 
 1124               DO ib = 1, pint_env%p
 
 1126                  pint_env%x(ib, idim) = r_vals(ic)
 
 1135                                "MOTION%PINT%INIT%RANDOMIZE_POS", &
 
 1139         IF (pint_env%beadwise_constraints) 
THEN 
 1140            WRITE (unit=msg, fmt=*) 
"Beadwise constraints are not supported if "// &
 
 1141               "a random noise is applied to the initialization of the bead positions. "// &
 
 1142               "Please use hot start (default)." 
 1146         DO idim = 1, pint_env%ndim
 
 1147            DO ib = 1, pint_env%p
 
 1148               pint_env%x(ib, idim) = pint_env%x(ib, idim) + &
 
 1149                                      pint_env%randomG%next(variance=pint_env%beta/ &
 
 1150                                                            sqrt(12.0_dp*pint_env%mass(idim)))
 
 1156      WRITE (tmp, 
'(A)') 
"Bead positions initialization:" 
 1158         WRITE (msg, 
'(A,A)') trim(tmp), 
" input structure" 
 1159      ELSE IF (done_levy) 
THEN 
 1160         WRITE (msg, 
'(A,A)') trim(tmp), 
" Levy random walk" 
 1162         WRITE (msg, 
'(A,A)') trim(tmp), 
" hot start" 
 1167         WRITE (msg, 
'(A,F6.3)') 
"Levy walk at effective temperature: ", tcorr
 
 1171         WRITE (msg, 
'(A)') 
"Added gaussian noise to the positions of the beads." 
 1175   END SUBROUTINE pint_init_x
 
 1198   SUBROUTINE pint_init_v(pint_env)
 
 1201      CHARACTER(len=default_string_length)               :: msg, stmp, stmp1, stmp2, unit_str
 
 1202      INTEGER                                            :: first_mode, i, ia, ib, ic, idim, ierr, &
 
 1203                                                            itmp, j, n_rep_val, nparticle, &
 
 1205      LOGICAL                                            :: done_init, done_quench, done_scale, &
 
 1206                                                            done_sped, explicit, ltmp, vels_present
 
 1207      REAL(kind=
dp)                                      :: actual_t, ek, factor, rtmp, target_t, &
 
 1209      REAL(kind=
dp), 
ALLOCATABLE, 
DIMENSION(:, :)        :: vel
 
 1210      REAL(kind=
dp), 
DIMENSION(:), 
POINTER               :: r_vals
 
 1233      IF (pint_env%simpar%constraint) 
THEN 
 1234         NULLIFY (subsys, cell)
 
 1235         NULLIFY (atomic_kinds, local_particles, particles)
 
 1236         NULLIFY (local_molecules, molecules, molecule_kinds, gci)
 
 1237         NULLIFY (atomic_kind_set, molecule_kind_set, particle_set, molecule_set)
 
 1240         CALL force_env_get(force_env=f_env%force_env, subsys=subsys)
 
 1247                            atomic_kinds=atomic_kinds, &
 
 1248                            local_particles=local_particles, &
 
 1249                            particles=particles, &
 
 1250                            local_molecules=local_molecules, &
 
 1251                            molecules=molecules, &
 
 1252                            molecule_kinds=molecule_kinds, &
 
 1255         nparticle_kind = atomic_kinds%n_els
 
 1256         atomic_kind_set => atomic_kinds%els
 
 1257         molecule_kind_set => molecule_kinds%els
 
 1258         nparticle = particles%n_els
 
 1259         particle_set => particles%els
 
 1260         molecule_set => molecules%els
 
 1263         ALLOCATE (vel(3, nparticle))
 
 1265         CALL getold(gci, local_molecules, molecule_set, &
 
 1266                     molecule_kind_set, particle_set, cell)
 
 1270      vels_present = .false.
 
 1271      NULLIFY (input_section)
 
 1273                                                  "FORCE_EVAL%SUBSYS%VELOCITY")
 
 1284                                   n_rep_val=n_rep_val)
 
 1286         WRITE (stmp, *) n_rep_val
 
 1287         msg = 
"Invalid number of atoms in FORCE_EVAL%SUBSYS%VELOCITY ("// &
 
 1288               trim(adjustl(stmp))//
")." 
 1289         IF (3*n_rep_val /= pint_env%ndim) &
 
 1291         DO ia = 1, pint_env%ndim/3
 
 1293                                      i_rep_val=ia, r_vals=r_vals)
 
 1296            WRITE (stmp, *) itmp
 
 1297            msg = 
"Number of coordinates != 3 in FORCE_EVAL%SUBSYS%VELOCITY ("// &
 
 1298                  trim(adjustl(stmp))//
")." 
 1301            DO ib = 1, pint_env%p
 
 1303                  idim = 3*(ia - 1) + ic
 
 1304                  pint_env%v(ib, idim) = r_vals(ic)*unit_conv
 
 1309         vels_present = .true.
 
 1313      IF (vels_present) 
THEN 
 1316         DO ia = 1, pint_env%ndim/3
 
 1319               idim = 3*(ia - 1) + ic
 
 1320               rtmp = rtmp + pint_env%v(1, idim)*pint_env%v(1, idim)
 
 1322            ek = ek + 0.5_dp*pint_env%mass(idim)*rtmp
 
 1324         actual_t = 2.0_dp*ek/pint_env%ndim
 
 1327         actual_t = pint_env%kT
 
 1331      target_t = pint_env%kT
 
 1333                                "MOTION%PINT%INIT%VELOCITY_SCALE", &
 
 1335      IF (vels_present) 
THEN 
 1336         IF (done_scale) 
THEN 
 1338            rtmp = sqrt(target_t/actual_t)
 
 1339            DO ia = 1, pint_env%ndim/3
 
 1340               DO ib = 1, pint_env%p
 
 1342                     idim = 3*(ia - 1) + ic
 
 1343                     pint_env%v(ib, idim) = rtmp*pint_env%v(ib, idim)
 
 1353      IF (vels_present) 
THEN 
 1355         CALL pint_x2u(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 1361      DO idim = 1, 
SIZE(pint_env%uv, 2)
 
 1362         DO ib = first_mode, 
SIZE(pint_env%uv, 1)
 
 1363            pint_env%uv(ib, idim) = &
 
 1364               pint_env%randomG%next(variance=target_t/pint_env%mass_fict(ib, idim))
 
 1371                                "MOTION%PINT%INIT%CENTROID_SPEED", &
 
 1374         CALL pint_u2x(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 1375         DO idim = 1, pint_env%ndim
 
 1376            rtmp = pint_env%randomG%next(variance=pint_env%mass(idim)*pint_env%kT) &
 
 1377                   /pint_env%mass(idim)
 
 1378            DO ib = 1, pint_env%p
 
 1379               pint_env%v(ib, idim) = pint_env%v(ib, idim) + rtmp
 
 1382         CALL pint_x2u(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 1388      done_quench = .false.
 
 1390                                "MOTION%PINT%INIT%VELOCITY_QUENCH", &
 
 1393         DO idim = 1, pint_env%ndim
 
 1394            DO ib = 1, pint_env%p
 
 1395               pint_env%v(ib, idim) = 0.0_dp
 
 1398         CALL pint_x2u(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 1399         done_quench = .true.
 
 1405      NULLIFY (input_section)
 
 1407                                                  "MOTION%PINT%BEADS%VELOCITY")
 
 1411                                   n_rep_val=n_rep_val)
 
 1412         IF (n_rep_val > 0) 
THEN 
 1413            cpassert(n_rep_val == 1)
 
 1416            IF (
SIZE(r_vals) /= pint_env%p*pint_env%ndim) &
 
 1417               cpabort(
"Invalid size of MOTION%PINT%BEAD%VELOCITY")
 
 1419            DO idim = 1, pint_env%ndim
 
 1420               DO ib = 1, pint_env%p
 
 1422                  pint_env%v(ib, idim) = r_vals(itmp)
 
 1425            CALL pint_x2u(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 1431      WRITE (stmp1, 
'(F10.2)') target_t*pint_env%propagator%temp_sim2phys*unit_conv
 
 1432      msg = 
"Bead velocities initialization:" 
 1434         msg = trim(msg)//
" input structure" 
 1435      ELSE IF (done_quench) 
THEN 
 1436         msg = trim(msg)//
" quenching (set to 0.0)" 
 1438         IF (vels_present) 
THEN 
 1439            msg = trim(adjustl(msg))//
" centroid +" 
 1441         msg = trim(adjustl(msg))//
" Maxwell-Boltzmann at "//trim(adjustl(stmp1))//
" K." 
 1445      IF (done_init .AND. done_quench) 
THEN 
 1446         msg = 
"WARNING: exclusive options requested (velocity restart and quenching)" 
 1448         msg = 
"WARNING: velocity restart took precedence" 
 1452      IF ((.NOT. done_init) .AND. (.NOT. done_quench)) 
THEN 
 1453         IF (vels_present .AND. done_scale) 
THEN 
 1454            WRITE (stmp1, 
'(F10.2)') actual_t*unit_conv
 
 1455            WRITE (stmp2, 
'(F10.2)') target_t*unit_conv
 
 1456            msg = 
"Scaled initial velocities from "//trim(adjustl(stmp1))// &
 
 1457                  " to "//trim(adjustl(stmp2))//
" K as requested." 
 1461            msg = 
"Added random component to the initial centroid velocities." 
 1467      IF (pint_env%simpar%constraint) 
THEN 
 1470            factor = sqrt(real(pint_env%p, 
dp))
 
 1476         IF (pint_env%beadwise_constraints) 
THEN 
 1477            IF (pint_env%logger%para_env%is_source()) 
THEN 
 1478               CALL pint_u2x(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 1479               DO ib = 1, pint_env%p
 
 1485                        particle_set(i)%r(j) = pint_env%x(1, j + (i - 1)*3)/factor
 
 1486                        vel(j, i) = pint_env%v(ib, j + (i - 1)*3)
 
 1491                                            molecule_kind_set, pint_env%dt, &
 
 1492                                            f_env%force_env%root_section)
 
 1494                                      molecule_kind_set, particle_set, &
 
 1495                                      vel, pint_env%dt, pint_env%simpar%shake_tol, &
 
 1496                                      pint_env%simpar%info_constraint, &
 
 1497                                      pint_env%simpar%lagrange_multipliers, &
 
 1503                        pint_env%v(ib, j + (i - 1)*3) = vel(j, i)
 
 1508               CALL pint_x2u(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 1511            CALL pint_env%logger%para_env%bcast(pint_env%uv)
 
 1515            IF (pint_env%logger%para_env%is_source()) 
THEN 
 1518                     particle_set(i)%r(j) = pint_env%x(1, j + (i - 1)*3)/factor
 
 1519                     vel(j, i) = pint_env%uv(1, j + (i - 1)*3)/factor
 
 1524                                         molecule_kind_set, pint_env%dt, &
 
 1525                                         f_env%force_env%root_section)
 
 1527                                   molecule_kind_set, particle_set, &
 
 1528                                   vel, pint_env%dt, pint_env%simpar%shake_tol, &
 
 1529                                   pint_env%simpar%info_constraint, &
 
 1530                                   pint_env%simpar%lagrange_multipliers, &
 
 1536            CALL pint_env%logger%para_env%bcast(vel)
 
 1540                  pint_env%uv(1, j + (i - 1)*3) = vel(j, i)*factor
 
 1546   END SUBROUTINE pint_init_v
 
 1556   SUBROUTINE pint_init_t(pint_env, kT)
 
 1559      REAL(kind=
dp), 
INTENT(in), 
OPTIONAL                :: kt
 
 1561      INTEGER                                            :: ib, idim, ii, inos, n_rep_val
 
 1562      LOGICAL                                            :: explicit, gle_restart
 
 1563      REAL(kind=
dp)                                      :: mykt
 
 1564      REAL(kind=
dp), 
DIMENSION(:), 
POINTER               :: r_vals
 
 1570         IF (
PRESENT(kt)) mykt = kt
 
 1571         DO idim = 1, 
SIZE(pint_env%tv, 3)
 
 1572            DO ib = 1, 
SIZE(pint_env%tv, 2)
 
 1573               DO inos = 1, 
SIZE(pint_env%tv, 1)
 
 1574                  pint_env%tv(inos, ib, idim) = &
 
 1575                     pint_env%randomG%next(variance=mykt/pint_env%Q(ib))
 
 1580            pint_env%tv(:, 1, :) = 0.0_dp
 
 1583         NULLIFY (input_section)
 
 1585                                                     "MOTION%PINT%NOSE%COORD")
 
 1589                                      n_rep_val=n_rep_val)
 
 1590            IF (n_rep_val > 0) 
THEN 
 1591               cpassert(n_rep_val == 1)
 
 1594               IF (
SIZE(r_vals) /= pint_env%p*pint_env%ndim*pint_env%nnos) &
 
 1595                  cpabort(
"Invalid size of MOTION%PINT%NOSE%COORD")
 
 1597               DO idim = 1, pint_env%ndim
 
 1598                  DO ib = 1, pint_env%p
 
 1599                     DO inos = 1, pint_env%nnos
 
 1601                        pint_env%tx(inos, ib, idim) = r_vals(ii)
 
 1608            pint_env%tx(:, 1, :) = 0.0_dp
 
 1611         NULLIFY (input_section)
 
 1613                                                     "MOTION%PINT%NOSE%VELOCITY")
 
 1617                                      n_rep_val=n_rep_val)
 
 1618            IF (n_rep_val > 0) 
THEN 
 1619               cpassert(n_rep_val == 1)
 
 1622               IF (
SIZE(r_vals) /= pint_env%p*pint_env%ndim*pint_env%nnos) &
 
 1623                  cpabort(
"Invalid size of MOTION%PINT%NOSE%VELOCITY")
 
 1625               DO idim = 1, pint_env%ndim
 
 1626                  DO ib = 1, pint_env%p
 
 1627                     DO inos = 1, pint_env%nnos
 
 1629                        pint_env%tv(inos, ib, idim) = r_vals(ii)
 
 1635               pint_env%tv(:, 1, :) = 0.0_dp
 
 1640         NULLIFY (input_section)
 
 1645            CALL restart_gle(pint_env%gle, input_section, save_mem=.false., &
 
 1646                             restart=gle_restart)
 
 1650   END SUBROUTINE pint_init_t
 
 1662   SUBROUTINE pint_init_f(pint_env, helium_env)
 
 1665         OPTIONAL, 
POINTER                               :: helium_env
 
 1667      INTEGER                                            :: ib, idim, inos
 
 1668      REAL(kind=
dp)                                      :: e_h
 
 1675      CALL cp_iterate(logger%iter_info, iter_nr=pint_env%first_step)
 
 1676      CALL cp_iterate(pint_env%logger%iter_info, iter_nr=pint_env%first_step)
 
 1679      CALL pint_calc_uf_h(pint_env=pint_env, e_h=e_h)
 
 1680      CALL pint_calc_f(pint_env)
 
 1685      IF (
PRESENT(helium_env)) 
THEN 
 1686         IF (logger%para_env%is_source()) 
THEN 
 1687            pint_env%f(:, :) = pint_env%f(:, :) + helium_env(1)%helium%force_avrg(:, :)
 
 1689         CALL logger%para_env%bcast(pint_env%f)
 
 1694      IF (pint_env%first_propagated_mode .EQ. 2) 
THEN 
 1695         pint_env%uf(1, :) = 0.0_dp
 
 1698      CALL pint_calc_e_kin_beads_u(pint_env)
 
 1699      CALL pint_calc_e_vir(pint_env)
 
 1700      DO idim = 1, 
SIZE(pint_env%uf_h, 2)
 
 1701         DO ib = pint_env%first_propagated_mode, 
SIZE(pint_env%uf_h, 1)
 
 1702            pint_env%uf(ib, idim) = real(pint_env%nrespa, 
dp)*pint_env%uf(ib, idim)
 
 1706      IF (pint_env%nnos > 0) 
THEN 
 1707         DO idim = 1, 
SIZE(pint_env%uf_h, 2)
 
 1708            DO ib = 1, 
SIZE(pint_env%uf_h, 1)
 
 1709               pint_env%tf(1, ib, idim) = (pint_env%mass_fict(ib, idim)* &
 
 1710                                           pint_env%uv(ib, idim)**2 - pint_env%kT)/pint_env%Q(ib)
 
 1714         DO idim = 1, pint_env%ndim
 
 1715            DO ib = 1, pint_env%p
 
 1716               DO inos = 1, pint_env%nnos - 1
 
 1717                  pint_env%tf(inos + 1, ib, idim) = pint_env%tv(inos, ib, idim)**2 - &
 
 1718                                                    pint_env%kT/pint_env%Q(ib)
 
 1720               DO inos = 1, pint_env%nnos - 1
 
 1721                  pint_env%tf(inos, ib, idim) = pint_env%tf(inos, ib, idim) &
 
 1722                                                - pint_env%tv(inos, ib, idim)*pint_env%tv(inos + 1, ib, idim)
 
 1726         CALL pint_calc_nh_energy(pint_env)
 
 1729   END SUBROUTINE pint_init_f
 
 1746   SUBROUTINE pint_do_run(pint_env, globenv, helium_env)
 
 1750         OPTIONAL, 
POINTER                               :: helium_env
 
 1753      LOGICAL                                            :: should_stop
 
 1754      REAL(kind=
dp)                                      :: scal
 
 1759      CALL cp_iterate(pint_env%logger%iter_info, iter_nr=pint_env%first_step)
 
 1769                      iter_nr=pint_env%first_step)
 
 1772      pint_env%iter = pint_env%first_step
 
 1774      IF (
PRESENT(helium_env)) 
THEN 
 1775         IF (
ASSOCIATED(helium_env)) 
THEN 
 1777            DO k = 1, 
SIZE(helium_env)
 
 1778               helium_env(k)%helium%proarea%accu(:) = 0.0_dp
 
 1779               helium_env(k)%helium%prarea2%accu(:) = 0.0_dp
 
 1780               helium_env(k)%helium%wnmber2%accu(:) = 0.0_dp
 
 1781               helium_env(k)%helium%mominer%accu(:) = 0.0_dp
 
 1782               IF (helium_env(k)%helium%rho_present) 
THEN 
 1783                  helium_env(k)%helium%rho_accu(:, :, :, :) = 0.0_dp
 
 1785               IF (helium_env(k)%helium%rdf_present) 
THEN 
 1786                  helium_env(k)%helium%rdf_accu(:, :) = 0.0_dp
 
 1793      CALL pint_calc_energy(pint_env)
 
 1794      CALL pint_calc_total_action(pint_env)
 
 1803      DO step = 1, pint_env%num_steps
 
 1805         pint_env%iter = pint_env%iter + 1
 
 1807                         last=(step == pint_env%num_steps), &
 
 1808                         iter_nr=pint_env%iter)
 
 1810                         last=(step == pint_env%num_steps), &
 
 1811                         iter_nr=pint_env%iter)
 
 1812         pint_env%t = pint_env%t + pint_env%dt
 
 1814         IF (pint_env%t_tol > 0.0_dp) 
THEN 
 1815            IF (abs(2._dp*pint_env%e_kin_beads/(pint_env%p*pint_env%ndim) &
 
 1816                    - pint_env%kT) > pint_env%t_tol) 
THEN 
 1817               scal = sqrt(pint_env%kT*(pint_env%p*pint_env%ndim)/(2.0_dp*pint_env%e_kin_beads))
 
 1818               pint_env%uv = scal*pint_env%uv
 
 1819               CALL pint_init_f(pint_env, helium_env=helium_env)
 
 1822         CALL pint_step(pint_env, helium_env=helium_env)
 
 1832                            pint_env=pint_env, helium_env=helium_env)
 
 1836         IF (should_stop) 
EXIT 
 1843   END SUBROUTINE pint_do_run
 
 1854   SUBROUTINE pint_run_scan(pint_env, helium_env)
 
 1858      CHARACTER(len=default_string_length)               :: comment
 
 1860      REAL(kind=
dp), 
DIMENSION(:, :, :), 
POINTER         :: 
DATA 
 1863      NULLIFY (pint_env%logger, print_key)
 
 1867      IF (pint_env%logger%para_env%is_source()) 
THEN 
 1869                                                 "MOTION%PINT%HELIUM%PRINT%RHO")
 
 1877      IF (pint_env%logger%para_env%is_source()) 
THEN 
 1882                   middle_name=
"helium-pot", &
 
 1883                   extension=
".cube", &
 
 1884                   file_position=
"REWIND", &
 
 1887         comment = 
"Solute - helium interaction potential" 
 1889         DATA => helium_env(1)%helium%rho_inst(1, :, :, :)
 
 1893            helium_env(1)%helium%center - 0.5_dp* &
 
 1894            (helium_env(1)%helium%rho_maxr - helium_env(1)%helium%rho_delr), &
 
 1895            helium_env(1)%helium%rho_delr, &
 
 1896            helium_env(1)%helium%rho_nbin, &
 
 1908   END SUBROUTINE pint_run_scan
 
 1922   SUBROUTINE pint_step(pint_env, helium_env)
 
 1925         OPTIONAL, 
POINTER                               :: helium_env
 
 1927      CHARACTER(len=*), 
PARAMETER                        :: routinen = 
'pint_step' 
 1929      INTEGER                                            :: handle, i, ia, ib, idim, ierr, inos, &
 
 1930                                                            iresp, j, k, nbeads, nparticle, &
 
 1932      REAL(kind=
dp)                                      :: dt_temp, dti, dti2, dti22, e_h, factor, &
 
 1933                                                            rn, tdti, time_start, time_stop, tol
 
 1934      REAL(kind=
dp), 
ALLOCATABLE, 
DIMENSION(:, :)        :: pos, vel
 
 1935      REAL(kind=
dp), 
DIMENSION(:, :, :), 
POINTER         :: tmp
 
 1950      CALL timeset(routinen, handle)
 
 1953      rn = real(pint_env%nrespa, 
dp)
 
 1954      dti = pint_env%dt/rn
 
 1957      dti22 = dti**2/2._dp
 
 1962      IF (pint_env%simpar%constraint) 
THEN 
 1963         NULLIFY (subsys, cell)
 
 1964         NULLIFY (atomic_kinds, local_particles, particles)
 
 1965         NULLIFY (local_molecules, molecules, molecule_kinds, gci)
 
 1966         NULLIFY (atomic_kind_set, molecule_kind_set, particle_set, molecule_set)
 
 1969         CALL force_env_get(force_env=f_env%force_env, subsys=subsys)
 
 1976                            atomic_kinds=atomic_kinds, &
 
 1977                            local_particles=local_particles, &
 
 1978                            particles=particles, &
 
 1979                            local_molecules=local_molecules, &
 
 1980                            molecules=molecules, &
 
 1981                            molecule_kinds=molecule_kinds, &
 
 1984         nparticle_kind = atomic_kinds%n_els
 
 1985         atomic_kind_set => atomic_kinds%els
 
 1986         molecule_kind_set => molecule_kinds%els
 
 1987         nparticle = particles%n_els
 
 1989         particle_set => particles%els
 
 1990         molecule_set => molecules%els
 
 1993         ALLOCATE (pos(3, nparticle))
 
 1994         ALLOCATE (vel(3, nparticle))
 
 2000            factor = sqrt(real(pint_env%p, 
dp))
 
 2005         CALL getold(gci, local_molecules, molecule_set, &
 
 2006                     molecule_kind_set, particle_set, cell)
 
 2009      SELECT CASE (pint_env%harm_integrator)
 
 2012         DO iresp = 1, pint_env%nrespa
 
 2019               IF (pint_env%simpar%constraint) 
THEN 
 2020                  DO k = 1, pint_env%n_atoms_constraints
 
 2021                     ia = pint_env%atoms_constraints(k)
 
 2022                     DO j = 3*(ia - 1) + 1, 3*ia
 
 2023                        pint_env%tv(:, 1, j) = 0.0_dp
 
 2030                  pint_env%tx(:, 1, :) = 0.0_dp
 
 2031                  pint_env%tv(:, 1, :) = 0.0_dp
 
 2032                  pint_env%tf(:, 1, :) = 0.0_dp
 
 2035               DO i = pint_env%first_propagated_mode, pint_env%p
 
 2036                  pint_env%ux(i, :) = pint_env%ux(i, :) - &
 
 2037                                      dti22*pint_env%uv(i, :)*pint_env%tv(1, i, :)
 
 2039               pint_env%tx = pint_env%tx + dti*pint_env%tv + dti22*pint_env%tf
 
 2042                  pint_env%tx(:, 1, :) = 0.0_dp
 
 2043                  pint_env%tv(:, 1, :) = 0.0_dp
 
 2044                  pint_env%tf(:, 1, :) = 0.0_dp
 
 2050            DO i = pint_env%first_propagated_mode, pint_env%p
 
 2051               pint_env%ux_t(i, :) = pint_env%ux(i, :) + &
 
 2052                                     dti*pint_env%uv(i, :) + &
 
 2053                                     dti22*(pint_env%uf_h(i, :) + &
 
 2058            SELECT CASE (pint_env%pimd_thermostat)
 
 2062                  pint_env%tx(:, 1, :) = 0.0_dp
 
 2063                  pint_env%tv(:, 1, :) = 0.0_dp
 
 2064                  pint_env%tf(:, 1, :) = 0.0_dp
 
 2067               pint_env%uv_t = pint_env%uv - dti2* &
 
 2068                               pint_env%uv*pint_env%tv(1, :, :)
 
 2069               tmp => pint_env%tv_t
 
 2070               pint_env%tv_t => pint_env%tv
 
 2072               pint_env%tv = pint_env%tv_old + tdti*pint_env%tf
 
 2073               pint_env%tv_old = pint_env%tv_t
 
 2074               pint_env%tv_t = pint_env%tv_t + dti2*pint_env%tf
 
 2076               pint_env%uv_t = pint_env%uv
 
 2080            IF (pint_env%simpar%constraint) 
THEN 
 2081               DO k = 1, pint_env%n_atoms_constraints
 
 2082                  ia = pint_env%atoms_constraints(k)
 
 2083                  DO j = 3*(ia - 1) + 1, 3*ia
 
 2084                     pint_env%tv(:, 1, j) = 0.0_dp
 
 2085                     pint_env%tv_t(:, 1, j) = 0.0_dp
 
 2092               pint_env%tx(:, 1, :) = 0.0_dp
 
 2093               pint_env%tv(:, 1, :) = 0.0_dp
 
 2094               pint_env%tf(:, 1, :) = 0.0_dp
 
 2098            pint_env%uv_t = pint_env%uv_t + dti2*(pint_env%uf_h + pint_env%uf)
 
 2101            pint_env%uf = 0.0_dp
 
 2103            pint_env%ux = pint_env%ux_t
 
 2106            IF (pint_env%simpar%constraint) 
THEN 
 2107               IF (pint_env%logger%para_env%is_source()) 
THEN 
 2110                        pos(j, i) = pint_env%ux(1, j + (i - 1)*3)
 
 2111                        vel(j, i) = pint_env%uv_t(1, j + (i - 1)*3)
 
 2117                                            molecule_kind_set, dti, &
 
 2118                                            f_env%force_env%root_section)
 
 2120                                     molecule_kind_set, particle_set, &
 
 2121                                     pos, vel, dti, pint_env%simpar%shake_tol, &
 
 2122                                     pint_env%simpar%info_constraint, &
 
 2123                                     pint_env%simpar%lagrange_multipliers, &
 
 2124                                     pint_env%simpar%dump_lm, cell, &
 
 2128               CALL pint_env%logger%para_env%bcast(pos)
 
 2129               CALL pint_env%logger%para_env%bcast(vel)
 
 2133                     pint_env%ux(1, j + (i - 1)*3) = pos(j, i)
 
 2134                     pint_env%uv_t(1, j + (i - 1)*3) = vel(j, i)
 
 2141               pint_env%tx(:, 1, :) = 0.0_dp
 
 2142               pint_env%tv(:, 1, :) = 0.0_dp
 
 2143               pint_env%tf(:, 1, :) = 0.0_dp
 
 2146            CALL pint_calc_uf_h(pint_env=pint_env, e_h=e_h)
 
 2147            pint_env%uv_t = pint_env%uv_t + dti2*(pint_env%uf_h + pint_env%uf)
 
 2151            IF (iresp == pint_env%nrespa) 
THEN 
 2153               CALL pint_calc_f(pint_env)
 
 2155               IF (
PRESENT(helium_env)) 
THEN 
 2158                  IF (pint_env%logger%para_env%is_source()) 
THEN 
 2159                     pint_env%f(:, :) = pint_env%f(:, :) + helium_env(1)%helium%force_avrg(:, :)
 
 2161                  CALL pint_env%logger%para_env%bcast(pint_env%f)
 
 2166               IF (pint_env%first_propagated_mode .EQ. 2) 
THEN 
 2167                  pint_env%uf(1, :) = 0.0_dp
 
 2171               pint_env%uf = pint_env%uf*rn
 
 2172               pint_env%uv_t = pint_env%uv_t + dti2*pint_env%uf
 
 2177            SELECT CASE (pint_env%pimd_thermostat)
 
 2181                  pint_env%tx(:, 1, :) = 0.0_dp
 
 2182                  pint_env%tv(:, 1, :) = 0.0_dp
 
 2183                  pint_env%tf(:, 1, :) = 0.0_dp
 
 2187                  pint_env%uv_new = pint_env%uv_t/(1.+dti2*pint_env%tv(1, :, :))
 
 2188                  DO idim = 1, pint_env%ndim
 
 2189                     DO ib = 1, pint_env%p
 
 2190                        pint_env%tf(1, ib, idim) = (pint_env%mass_fict(ib, idim)* &
 
 2191                                                    pint_env%uv_new(ib, idim)**2 - pint_env%kT*pint_env%kTcorr)/ &
 
 2197                  IF (pint_env%simpar%constraint) 
THEN 
 2198                     DO k = 1, pint_env%n_atoms_constraints
 
 2199                        ia = pint_env%atoms_constraints(k)
 
 2200                        DO j = 3*(ia - 1) + 1, 3*ia
 
 2201                           pint_env%tf(:, 1, j) = 0.0_dp
 
 2208                     pint_env%tx(:, 1, :) = 0.0_dp
 
 2209                     pint_env%tv(:, 1, :) = 0.0_dp
 
 2210                     pint_env%tf(:, 1, :) = 0.0_dp
 
 2213                  DO idim = 1, pint_env%ndim
 
 2214                     DO ib = 1, pint_env%p
 
 2215                        DO inos = 1, pint_env%nnos - 1
 
 2216                           pint_env%tv_new(inos, ib, idim) = &
 
 2217                              (pint_env%tv_t(inos, ib, idim) + dti2*pint_env%tf(inos, ib, idim))/ &
 
 2218                              (1._dp + dti2*pint_env%tv(inos + 1, ib, idim))
 
 2219                           pint_env%tf(inos + 1, ib, idim) = &
 
 2220                              (pint_env%tv_new(inos, ib, idim)**2 - &
 
 2221                               pint_env%kT*pint_env%kTcorr/pint_env%Q(ib))
 
 2222                           tol = max(tol, abs(pint_env%tv(inos, ib, idim) &
 
 2223                                              - pint_env%tv_new(inos, ib, idim)))
 
 2226                        IF (pint_env%simpar%constraint) 
THEN 
 2227                           DO k = 1, pint_env%n_atoms_constraints
 
 2228                              ia = pint_env%atoms_constraints(k)
 
 2229                              DO j = 3*(ia - 1) + 1, 3*ia
 
 2230                                 pint_env%tv_new(:, 1, j) = 0.0_dp
 
 2231                                 pint_env%tf(:, 1, j) = 0.0_dp
 
 2238                           pint_env%tx(:, 1, :) = 0.0_dp
 
 2239                           pint_env%tv(:, 1, :) = 0.0_dp
 
 2240                           pint_env%tf(:, 1, :) = 0.0_dp
 
 2243                        pint_env%tv_new(pint_env%nnos, ib, idim) = &
 
 2244                           pint_env%tv_t(pint_env%nnos, ib, idim) + &
 
 2245                           dti2*pint_env%tf(pint_env%nnos, ib, idim)
 
 2246                        tol = max(tol, abs(pint_env%tv(pint_env%nnos, ib, idim) &
 
 2247                                           - pint_env%tv_new(pint_env%nnos, ib, idim)))
 
 2248                        tol = max(tol, abs(pint_env%uv(ib, idim) &
 
 2249                                           - pint_env%uv_new(ib, idim)))
 
 2251                        IF (pint_env%simpar%constraint) 
THEN 
 2252                           DO k = 1, pint_env%n_atoms_constraints
 
 2253                              ia = pint_env%atoms_constraints(k)
 
 2254                              DO j = 3*(ia - 1) + 1, 3*ia
 
 2255                                 pint_env%tv_new(:, 1, j) = 0.0_dp
 
 2261                           pint_env%tx(:, 1, :) = 0.0_dp
 
 2262                           pint_env%tv(:, 1, :) = 0.0_dp
 
 2263                           pint_env%tf(:, 1, :) = 0.0_dp
 
 2269                  pint_env%uv = pint_env%uv_new
 
 2270                  pint_env%tv = pint_env%tv_new
 
 2271                  IF (tol <= pint_env%v_tol) 
EXIT 
 2274                     pint_env%tx(:, 1, :) = 0.0_dp
 
 2275                     pint_env%tv(:, 1, :) = 0.0_dp
 
 2276                     pint_env%tf(:, 1, :) = 0.0_dp
 
 2281               IF (pint_env%simpar%constraint) 
THEN 
 2282                  IF (pint_env%logger%para_env%is_source()) 
THEN 
 2286                           vel(j, i) = pint_env%uv(1, j + (i - 1)*3)
 
 2287                           particle_set(i)%r(j) = pint_env%ux(1, j + (i - 1)*3)
 
 2293                     IF (iresp == pint_env%nrespa) 
THEN 
 2299                                         molecule_kind_set, particle_set, &
 
 2300                                         vel, dt_temp, pint_env%simpar%shake_tol, &
 
 2301                                         pint_env%simpar%info_constraint, &
 
 2302                                         pint_env%simpar%lagrange_multipliers, &
 
 2303                                         pint_env%simpar%dump_lm, cell, &
 
 2308                  CALL pint_env%logger%para_env%bcast(vel)
 
 2312                        pint_env%uv(1, j + (i - 1)*3) = vel(j, i)
 
 2317               DO inos = 1, pint_env%nnos - 1
 
 2318                  pint_env%tf(inos, :, :) = pint_env%tf(inos, :, :) &
 
 2319                                            - pint_env%tv(inos, :, :)*pint_env%tv(inos + 1, :, :)
 
 2324                  pint_env%tx(:, 1, :) = 0.0_dp
 
 2325                  pint_env%tv(:, 1, :) = 0.0_dp
 
 2326                  pint_env%tf(:, 1, :) = 0.0_dp
 
 2331               pint_env%uv = pint_env%uv_t
 
 2333               pint_env%uv = pint_env%uv_t
 
 2346         SELECT CASE (pint_env%pimd_thermostat)
 
 2349                                vnew=pint_env%uv_t, &
 
 2351                                ndim=pint_env%ndim, &
 
 2352                                first_mode=pint_env%first_propagated_mode, &
 
 2353                                masses=pint_env%mass_fict, &
 
 2354                                pile_therm=pint_env%pile_therm)
 
 2357                                  vnew=pint_env%uv_t, &
 
 2358                                  first_mode=pint_env%first_propagated_mode, &
 
 2359                                  masses=pint_env%mass_fict, &
 
 2360                                  piglet_therm=pint_env%piglet_therm)
 
 2363                               vnew=pint_env%uv_t, &
 
 2365                               ndim=pint_env%ndim, &
 
 2366                               masses=pint_env%mass_fict, &
 
 2367                               qtb_therm=pint_env%qtb_therm)
 
 2369            pint_env%uv_t = pint_env%uv
 
 2373         pint_env%uv_t = pint_env%uv_t + dti2*pint_env%uf
 
 2376         IF (pint_env%first_propagated_mode == 1) 
THEN 
 2380            pint_env%ux_t(1, :) = pint_env%ux(1, :) + &
 
 2381                                  dti*pint_env%uv_t(1, :) 
 
 2387            pint_env%ux_t(1, :) = pint_env%ux(1, :)
 
 2388            pint_env%uv_t(1, :) = 0.0_dp
 
 2391         DO i = 2, pint_env%p
 
 2392            pint_env%ux_t(i, :) = pint_env%cosex(i)*pint_env%ux(i, :) &
 
 2393                                  + pint_env%iwsinex(i)*pint_env%uv_t(i, :)
 
 2394            pint_env%uv_t(i, :) = pint_env%cosex(i)*pint_env%uv_t(i, :) &
 
 2395                                  - pint_env%wsinex(i)*pint_env%ux(i, :)
 
 2399         IF (pint_env%simpar%constraint) 
THEN 
 2401            IF (pint_env%beadwise_constraints) 
THEN 
 2402               IF (pint_env%logger%para_env%is_source()) 
THEN 
 2404                  CALL pint_u2x(pint_env, ux=pint_env%ux_t, x=pint_env%x)
 
 2405                  CALL pint_u2x(pint_env, ux=pint_env%uv_t, x=pint_env%v)
 
 2409                           pos(j, i) = pint_env%x(ib, j + (i - 1)*3)
 
 2410                           vel(j, i) = pint_env%v(ib, j + (i - 1)*3)
 
 2415                                               molecule_kind_set, dti, &
 
 2416                                               f_env%force_env%root_section)
 
 2418                                        molecule_kind_set, particle_set, &
 
 2419                                        pos, vel, dti, pint_env%simpar%shake_tol, &
 
 2420                                        pint_env%simpar%info_constraint, &
 
 2421                                        pint_env%simpar%lagrange_multipliers, &
 
 2422                                        pint_env%simpar%dump_lm, cell, &
 
 2426                           pint_env%x(ib, j + (i - 1)*3) = pos(j, i)
 
 2427                           pint_env%v(ib, j + (i - 1)*3) = vel(j, i)
 
 2432                  CALL pint_x2u(pint_env, ux=pint_env%ux_t, x=pint_env%x)
 
 2433                  CALL pint_x2u(pint_env, ux=pint_env%uv_t, x=pint_env%v)
 
 2436               CALL pint_env%logger%para_env%bcast(pint_env%ux_t)
 
 2437               CALL pint_env%logger%para_env%bcast(pint_env%uv_t)
 
 2440               IF (pint_env%logger%para_env%is_source()) 
THEN 
 2444                        pos(j, i) = pint_env%ux_t(1, j + (i - 1)*3)/factor
 
 2445                        vel(j, i) = pint_env%uv_t(1, j + (i - 1)*3)/factor
 
 2450                                            molecule_kind_set, dti, &
 
 2451                                            f_env%force_env%root_section)
 
 2453                                     molecule_kind_set, particle_set, &
 
 2454                                     pos, vel, dti, pint_env%simpar%shake_tol, &
 
 2455                                     pint_env%simpar%info_constraint, &
 
 2456                                     pint_env%simpar%lagrange_multipliers, &
 
 2457                                     pint_env%simpar%dump_lm, cell, &
 
 2461               CALL pint_env%logger%para_env%bcast(pos)
 
 2462               CALL pint_env%logger%para_env%bcast(vel)
 
 2466                     pint_env%ux_t(1, j + (i - 1)*3) = pos(j, i)*factor
 
 2467                     pint_env%uv_t(1, j + (i - 1)*3) = vel(j, i)*factor
 
 2474         pint_env%ux = pint_env%ux_t
 
 2477         pint_env%uf = 0.0_dp
 
 2479         CALL pint_calc_f(pint_env)
 
 2481         IF (
PRESENT(helium_env)) 
THEN 
 2484            IF (pint_env%logger%para_env%is_source()) 
THEN 
 2485               pint_env%f(:, :) = pint_env%f(:, :) + helium_env(1)%helium%force_avrg(:, :)
 
 2487            CALL pint_env%logger%para_env%bcast(pint_env%f)
 
 2491         IF (pint_env%first_propagated_mode .EQ. 2) 
THEN 
 2492            pint_env%uf(1, :) = 0.0_dp
 
 2494         pint_env%uv_t = pint_env%uv_t + dti2*pint_env%uf
 
 2497         SELECT CASE (pint_env%pimd_thermostat)
 
 2502                                ndim=pint_env%ndim, &
 
 2503                                first_mode=pint_env%first_propagated_mode, &
 
 2504                                masses=pint_env%mass_fict, &
 
 2505                                pile_therm=pint_env%pile_therm)
 
 2509                                  first_mode=pint_env%first_propagated_mode, &
 
 2510                                  masses=pint_env%mass_fict, &
 
 2511                                  piglet_therm=pint_env%piglet_therm)
 
 2516                               ndim=pint_env%ndim, &
 
 2517                               masses=pint_env%mass_fict, &
 
 2518                               qtb_therm=pint_env%qtb_therm)
 
 2520            pint_env%uv = pint_env%uv_t
 
 2524         IF (pint_env%simpar%constraint) 
THEN 
 2526            IF (pint_env%beadwise_constraints) 
THEN 
 2527               IF (pint_env%logger%para_env%is_source()) 
THEN 
 2530                  CALL pint_u2x(pint_env, ux=pint_env%ux, x=pint_env%x)
 
 2531                  CALL pint_u2x(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 2535                           particle_set(i)%r(j) = pint_env%x(ib, j + (i - 1)*3)
 
 2536                           vel(j, i) = pint_env%v(ib, j + (i - 1)*3)
 
 2540                                         molecule_set, molecule_kind_set, &
 
 2541                                         particle_set, vel, dti, &
 
 2542                                         pint_env%simpar%shake_tol, &
 
 2543                                         pint_env%simpar%info_constraint, &
 
 2544                                         pint_env%simpar%lagrange_multipliers, &
 
 2545                                         pint_env%simpar%dump_lm, cell, &
 
 2549                           pint_env%v(ib, j + (i - 1)*3) = vel(j, i)
 
 2554                  CALL pint_x2u(pint_env, ux=pint_env%uv, x=pint_env%v)
 
 2556               CALL pint_env%logger%para_env%bcast(pint_env%uv)
 
 2559               IF (pint_env%logger%para_env%is_source()) 
THEN 
 2564                        vel(j, i) = pint_env%uv(1, j + (i - 1)*3)/factor
 
 2565                        particle_set(i)%r(j) = pint_env%ux(1, j + (i - 1)*3)/factor
 
 2569                                      molecule_set, molecule_kind_set, &
 
 2570                                      particle_set, vel, dti, &
 
 2571                                      pint_env%simpar%shake_tol, &
 
 2572                                      pint_env%simpar%info_constraint, &
 
 2573                                      pint_env%simpar%lagrange_multipliers, &
 
 2574                                      pint_env%simpar%dump_lm, cell, &
 
 2579               CALL pint_env%logger%para_env%bcast(vel)
 
 2585                     pint_env%uv(1, j + (i - 1)*3) = vel(j, i)*factor
 
 2593      IF (pint_env%simpar%constraint) 
THEN 
 2594         DEALLOCATE (pos, vel)
 
 2598      CALL pint_calc_energy(pint_env)
 
 2599      CALL pint_calc_total_action(pint_env)
 
 2613      pint_env%time_per_step = time_stop - time_start
 
 2615      CALL timestop(handle)
 
 2617   END SUBROUTINE pint_step
 
 2625   SUBROUTINE pint_calc_energy(pint_env)
 
 2629      REAL(kind=
dp)                                      :: e_h
 
 2631      CALL pint_calc_e_kin_beads_u(pint_env)
 
 2632      CALL pint_calc_e_vir(pint_env)
 
 2634      CALL pint_calc_uf_h(pint_env, e_h=e_h)
 
 2635      pint_env%e_pot_h = e_h
 
 2637      SELECT CASE (pint_env%pimd_thermostat)
 
 2639         CALL pint_calc_nh_energy(pint_env)
 
 2651         (0.5_dp*real(pint_env%p, 
dp)*real(pint_env%ndim, 
dp)*pint_env%kT - &
 
 2652          pint_env%e_pot_h)*pint_env%propagator%temp_sim2phys
 
 2657         pint_env%energy(
e_potential_id)*pint_env%propagator%physpotscale + &
 
 2658         pint_env%e_pot_h + &
 
 2659         pint_env%e_kin_beads + &
 
 2660         pint_env%e_pot_t + &
 
 2661         pint_env%e_kin_t + &
 
 2662         pint_env%e_gle + pint_env%e_pile + pint_env%e_piglet + pint_env%e_qtb
 
 2667   END SUBROUTINE pint_calc_energy
 
 2678   SUBROUTINE pint_calc_uf_h(pint_env, e_h)
 
 2680      REAL(kind=
dp), 
INTENT(OUT)                         :: e_h
 
 2684                                pint_env%mass_beads, &
 
 2690                                   pint_env%mass_beads, &
 
 2695      e_h = pint_env%e_pot_h
 
 2696      pint_env%uf_h = pint_env%uf_h/pint_env%mass_fict
 
 2697   END SUBROUTINE pint_calc_uf_h
 
 2711   SUBROUTINE pint_calc_f(pint_env, x, f, e)
 
 2713      REAL(kind=
dp), 
DIMENSION(:, :), 
INTENT(in), &
 
 2714         OPTIONAL, 
TARGET                                :: x
 
 2715      REAL(kind=
dp), 
DIMENSION(:, :), 
INTENT(out), &
 
 2716         OPTIONAL, 
TARGET                                :: f
 
 2717      REAL(kind=
dp), 
DIMENSION(:), 
INTENT(out), &
 
 2718         OPTIONAL, 
TARGET                                :: e
 
 2721      REAL(kind=
dp), 
DIMENSION(:), 
POINTER               :: my_e
 
 2722      REAL(kind=
dp), 
DIMENSION(:, :), 
POINTER            :: my_f, my_x
 
 2725      IF (
PRESENT(x)) my_x => x
 
 2727      IF (
PRESENT(f)) my_f => f
 
 2728      my_e => pint_env%e_pot_bead
 
 2729      IF (
PRESENT(e)) my_e => e
 
 2730      DO idim = 1, pint_env%ndim
 
 2731         DO ib = 1, pint_env%p
 
 2732            pint_env%replicas%r(idim, ib) = my_x(ib, idim)
 
 2736      DO idim = 1, pint_env%ndim
 
 2737         DO ib = 1, pint_env%p
 
 2739            my_f(ib, idim) = pint_env%replicas%f(idim, ib)
 
 2742      my_e = pint_env%replicas%f(
SIZE(pint_env%replicas%f, 1), :)
 
 2744   END SUBROUTINE pint_calc_f
 
 2755   SUBROUTINE pint_calc_e_kin_beads_u(pint_env, uv, e_k)
 
 2757      REAL(kind=
dp), 
DIMENSION(:, :), 
INTENT(in), &
 
 2758         OPTIONAL, 
TARGET                                :: uv
 
 2759      REAL(kind=
dp), 
INTENT(out), 
OPTIONAL               :: e_k
 
 2762      REAL(kind=
dp)                                      :: res
 
 2763      REAL(kind=
dp), 
DIMENSION(:, :), 
POINTER            :: my_uv
 
 2766      my_uv => pint_env%uv
 
 2767      IF (
PRESENT(uv)) my_uv => uv
 
 2769      DO idim = 1, pint_env%ndim
 
 2770         DO ib = 1, pint_env%p
 
 2771            res = res + pint_env%mass_fict(ib, idim)*my_uv(ib, idim)**2
 
 2775      IF (.NOT. 
PRESENT(uv)) pint_env%e_kin_beads = res
 
 2776      IF (
PRESENT(e_k)) e_k = res
 
 2777   END SUBROUTINE pint_calc_e_kin_beads_u
 
 2787   ELEMENTAL SUBROUTINE pint_calc_e_vir(pint_env, e_vir)
 
 2789      REAL(kind=
dp), 
INTENT(out), 
OPTIONAL               :: e_vir
 
 2792      REAL(kind=
dp)                                      :: res, xcentroid
 
 2796      DO idim = 1, pint_env%ndim
 
 2799         DO ib = 1, pint_env%p
 
 2800            xcentroid = xcentroid + pint_env%x(ib, idim)
 
 2802         xcentroid = xcentroid/real(pint_env%p, 
dp)
 
 2803         DO ib = 1, pint_env%p
 
 2804            res = res + (pint_env%x(ib, idim) - xcentroid)*pint_env%f(ib, idim)
 
 2807      res = 0.5_dp*(real(pint_env%ndim, 
dp)* &
 
 2808                    (pint_env%kT*pint_env%propagator%temp_sim2phys) - res/real(pint_env%p, 
dp))
 
 2810      IF (
PRESENT(e_vir)) e_vir = res
 
 2811   END SUBROUTINE pint_calc_e_vir
 
 2819   ELEMENTAL SUBROUTINE pint_calc_nh_energy(pint_env)
 
 2822      INTEGER                                            :: ib, idim, inos
 
 2823      REAL(kind=
dp)                                      :: ekin, epot
 
 2826      DO idim = 1, pint_env%ndim
 
 2827         DO ib = 1, pint_env%p
 
 2828            DO inos = 1, pint_env%nnos
 
 2829               ekin = ekin + pint_env%Q(ib)*pint_env%tv(inos, ib, idim)**2
 
 2833      pint_env%e_kin_t = 0.5_dp*ekin
 
 2835      DO idim = 1, pint_env%ndim
 
 2836         DO ib = 1, pint_env%p
 
 2837            DO inos = 1, pint_env%nnos
 
 2838               epot = epot + pint_env%tx(inos, ib, idim)
 
 2842      pint_env%e_pot_t = pint_env%kT*epot
 
 2843   END SUBROUTINE pint_calc_nh_energy
 
 2851   ELEMENTAL FUNCTION pint_calc_total_link_action(pint_env) 
RESULT(link_action)
 
 2853      REAL(kind=
dp)                                      :: link_action
 
 2855      INTEGER                                            :: iatom, ibead, idim, indx
 
 2856      REAL(kind=
dp)                                      :: hb2m, tau, tmp_link_action
 
 2857      REAL(kind=
dp), 
DIMENSION(3)                        :: r
 
 2860      tau = pint_env%beta/real(pint_env%p, 
dp)
 
 2862      link_action = 0.0_dp
 
 2863      DO iatom = 1, pint_env%ndim/3
 
 2865         hb2m = 1.0_dp/pint_env%mass((iatom - 1)*3 + 1)
 
 2866         tmp_link_action = 0.0_dp
 
 2867         DO ibead = 1, pint_env%p - 1
 
 2869               indx = (iatom - 1)*3 + idim
 
 2870               r(idim) = pint_env%x(ibead, indx) - pint_env%x(ibead + 1, indx)
 
 2872            tmp_link_action = tmp_link_action + (r(1)*r(1) + r(2)*r(2) + r(3)*r(3))
 
 2875            indx = (iatom - 1)*3 + idim
 
 2876            r(idim) = pint_env%x(pint_env%p, indx) - pint_env%x(1, indx)
 
 2878         tmp_link_action = tmp_link_action + (r(1)*r(1) + r(2)*r(2) + r(3)*r(3))
 
 2879         link_action = link_action + tmp_link_action/hb2m
 
 2882      link_action = link_action/(2.0_dp*tau)
 
 2884   END FUNCTION pint_calc_total_link_action
 
 2892   ELEMENTAL FUNCTION pint_calc_total_pot_action(pint_env) 
RESULT(pot_action)
 
 2894      REAL(kind=
dp)                                      :: pot_action
 
 2896      REAL(kind=
dp)                                      :: tau
 
 2898      tau = pint_env%beta/real(pint_env%p, 
dp)
 
 2899      pot_action = tau*sum(pint_env%e_pot_bead)
 
 2901   END FUNCTION pint_calc_total_pot_action
 
 2908   ELEMENTAL SUBROUTINE pint_calc_total_action(pint_env)
 
 2911      pint_env%pot_action = pint_calc_total_pot_action(pint_env)
 
 2912      pint_env%link_action = pint_calc_total_link_action(pint_env)
 
 2914   END SUBROUTINE pint_calc_total_action
 
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
 
represent a simple array based list of the given type
 
Define the atomic kind types and their sub types.
 
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.
 
collects all references to literature in CP2K as new algorithms / method are included from literature...
 
integer, save, public ceriotti2012
 
integer, save, public ceriotti2010
 
integer, save, public brieuc2016
 
Handles all functions related to the CELL.
 
Contains routines useful for the application of constraints during MD.
 
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_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.
 
Routines to handle the external control of CP2K.
 
subroutine, public external_control(should_stop, flag, globenv, target_time, start_time, force_check)
External manipulations during a run : when the <PROJECT_NAME>.EXIT_$runtype command is sent the progr...
 
various routines to log and control the output. The idea is that decisions about where to log should ...
 
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
 
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
 
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
 
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
 
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
 
integer, parameter, public cp_p_file
 
subroutine, public cp_iterate(iteration_info, last, iter_nr, increment, iter_nr_out)
adds one to the actual iteration
 
subroutine, public cp_rm_iter_level(iteration_info, level_name, n_rlevel_att)
Removes an iteration level.
 
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
 
subroutine, public cp_add_iter_level(iteration_info, level_name, n_rlevel_new)
Adds an iteration level.
 
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)
returns information about various attributes of the given subsys
 
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
 
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...
 
interface to use cp2k as library
 
subroutine, public f_env_add_defaults(f_env_id, f_env, handle)
adds the default environments of the f_env to the stack of the defaults, and returns a new error and ...
 
subroutine, public f_env_rm_defaults(f_env, ierr, handle)
removes the default environments of the f_env to the stack of the defaults, and sets ierr accordingly...
 
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
 
subroutine, public restart_gle(gle, gle_section, save_mem, restart)
...
 
subroutine, public gle_matrix_exp(m, n, j, k, em)
...
 
subroutine, public gle_cholesky_stab(sst, s, n)
...
 
subroutine, public gle_dealloc(gle)
Deallocate type for GLE thermostat.
 
subroutine, public gle_thermo_create(gle, mal_size)
...
 
subroutine, public gle_init(gle, dt, temp, section)
...
 
Define type storing the global information of a run. Keep the amount of stored data small....
 
Methods that handle helium-solvent and helium-helium interactions.
 
subroutine, public helium_intpot_scan(pint_env, helium_env)
Scan the helium-solute interaction energy within the periodic cell.
 
I/O subroutines for helium.
 
subroutine, public helium_write_cubefile(unit, comment, origin, deltar, ndim, data)
Write volumetric data to an orthorhombic cubefile.
 
Methods dealing with helium_solvent_type.
 
subroutine, public helium_release(helium_env)
Releases helium_solvent_type.
 
subroutine, public helium_create(helium_env, input, solute)
Data-structure that holds all needed information about (superfluid) helium solvent.
 
subroutine, public helium_init(helium_env, pint_env)
Initialize helium data structures.
 
Methods for sampling helium variables.
 
subroutine, public helium_step(helium_env, pint_env)
Perform MC step for helium.
 
subroutine, public helium_do_run(helium_env, globenv)
Performs MC simulation for helium (only)
 
Data types representing superfluid helium.
 
Defines the basic variable types.
 
integer, parameter, public dp
 
integer, parameter, public default_string_length
 
integer, parameter, public default_path_length
 
Machine interface based on Fortran 2003 and POSIX.
 
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
 
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
 
Definition of mathematical constants and functions.
 
real(kind=dp), parameter, public twopi
 
Collection of simple mathematical functions and subroutines.
 
elemental integer function, public gcd(a, b)
computes the greatest common divisor of two number
 
Interface to the message passing library MPI.
 
type(mp_comm_type), parameter, public mp_comm_self
 
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.
 
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.
 
integer, parameter, public gaussian
 
represent a simple array based list of the given type
 
Define the data structure for the particle information.
 
Methods to apply GLE to PI runs.
 
subroutine, public pint_gle_init(pint_env)
...
 
subroutine, public pint_gle_step(pint_env)
...
 
elemental subroutine, public pint_calc_gle_energy(pint_env)
...
 
I/O subroutines for pint_env.
 
subroutine, public pint_write_action(pint_env)
Writes out the actions according to PINTPRINTACTION.
 
subroutine, public pint_write_centroids(pint_env)
Write out the trajectory of the centroid (positions and velocities)
 
subroutine, public pint_write_rgyr(pint_env)
Write radii of gyration according to PINTPRINTCENTROID_GYR.
 
subroutine, public pint_write_step_info(pint_env)
Write step info to the output file.
 
subroutine, public pint_write_ener(pint_env)
Writes out the energies according to PINTPRINTENERGY.
 
subroutine, public pint_write_line(line)
Writes out a line of text to the default output unit.
 
subroutine, public pint_write_trajectory(pint_env)
Write out the trajectory of the beads (positions and velocities)
 
subroutine, public pint_write_com(pint_env)
Write center of mass (COM) position according to PINTPRINTCOM.
 
Methods to performs a path integral run.
 
subroutine, public do_pint_run(para_env, input, input_declaration, globenv)
Perform a path integral simulation.
 
Data type and methods dealing with PI calcs in normal mode coords.
 
pure subroutine, public normalmode_calc_uf_h(normalmode_env, mass_beads, ux, uf_h, e_h)
calculates the harmonic force in the normal mode basis
 
pure subroutine, public normalmode_release(normalmode_env)
releases the normalmode environment
 
subroutine, public normalmode_env_create(normalmode_env, normalmode_section, p, kt, propagator)
creates the data needed for a normal mode transformation
 
pure subroutine, public normalmode_init_masses(normalmode_env, mass, mass_beads, mass_fict, q)
initializes the masses and fictitious masses compatible with the normal mode information
 
Methods to apply the piglet thermostat to PI runs.
 
elemental subroutine, public pint_calc_piglet_energy(pint_env)
returns the piglet kinetic energy contribution
 
subroutine, public pint_piglet_release(piglet_therm)
releases the piglet environment
 
subroutine, public pint_piglet_create(piglet_therm, pint_env, section)
creates the data structure for a piglet thermostating in PI runs
 
subroutine, public pint_piglet_step(vold, vnew, first_mode, masses, piglet_therm)
...
 
subroutine, public pint_piglet_init(piglet_therm, pint_env, section, dt, para_env)
initializes the data for a piglet run
 
Methods to apply a simple Lagevin thermostat to PI runs. v_new = c1*vold + SQRT(kT/m)*c2*random.
 
subroutine, public pint_pile_step(vold, vnew, p, ndim, first_mode, masses, pile_therm)
...
 
subroutine, public pint_pile_init(pile_therm, pint_env, normalmode_env, section)
initializes the data for a pile run
 
subroutine, public pint_pile_release(pile_therm)
releases the pile environment
 
subroutine, public pint_calc_pile_energy(pint_env)
returns the pile kinetic energy contribution
 
Public path integral routines that can be called from other modules.
 
subroutine, public pint_levy_walk(x0, n, v, x, rng_gaussian)
Perform a Brownian walk of length n around x0 with the variance v.
 
Methods to apply the QTB thermostat to PI runs. Based on the PILE implementation from Felix Uhl (pint...
 
subroutine, public pint_qtb_step(vold, vnew, p, ndim, masses, qtb_therm)
...
 
subroutine, public pint_calc_qtb_energy(pint_env)
returns the qtb kinetic energy contribution
 
subroutine, public pint_qtb_release(qtb_therm)
releases the qtb environment
 
subroutine, public pint_qtb_init(qtb_therm, pint_env, normalmode_env, section)
initializes the data for a QTB run
 
Data type and methods dealing with PI calcs in staging coordinates.
 
elemental subroutine, public staging_release(staging_env)
releases the staging environment, kept for symmetry reasons with staging_env_create
 
subroutine, public staging_env_create(staging_env, staging_section, p, kt)
creates the data needed for a staging transformation
 
pure subroutine, public staging_calc_uf_h(staging_env, mass_beads, ux, uf_h, e_h)
calculates the harmonic force in the staging basis
 
pure subroutine, public staging_init_masses(staging_env, mass, mass_beads, mass_fict, q)
initializes the masses and fictitious masses compatibly with the staging information
 
integer, parameter, public e_kin_thermo_id
 
integer, parameter, public e_conserved_id
 
integer, parameter, public thermostat_none
 
integer, parameter, public thermostat_gle
 
integer, parameter, public e_potential_id
 
integer, parameter, public thermostat_pile
 
integer, parameter, public thermostat_piglet
 
integer, parameter, public thermostat_nose
 
integer, parameter, public e_kin_virial_id
 
integer, parameter, public thermostat_qtb
 
methods to setup replicas of the same system differing only by atom positions and velocities (as used...
 
subroutine, public rep_env_create(rep_env, para_env, input, input_declaration, nrep, prep, sync_v, keep_wf_history, row_force)
creates a replica environment together with its force environment
 
subroutine, public rep_env_calc_e_f(rep_env, calc_f)
evaluates the forces
 
types used to handle many replica of the same system that differ only in atom positions,...
 
subroutine, public rep_env_release(rep_env)
releases the given replica environment
 
Type for storing MD parameters.
 
subroutine, public release_simpar_type(simpar)
Releases the simulation parameters type.
 
subroutine, public create_simpar_type(simpar)
Creates the simulation parameters type.
 
represent a list of objects
 
Provides all information about an atomic kind.
 
Type defining parameters related to the simulation cell.
 
type of a logger, at the moment it contains just a print level starting at which level it should be l...
 
represents a system: atoms, molecules, their pos,vel,...
 
structure to store local (to a processor) ordered lists of integers.
 
contains the initially parsed file and the initial parallel environment
 
data structure for array of solvent helium environments
 
stores all the informations relevant to an mpi environment
 
represent a list of objects
 
represent a list of objects
 
represent a list of objects
 
environment for a path integral run
 
keeps replicated information about the replicas