LCOV - code coverage report
Current view: top level - src - ipi_environment.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:cb5d5fc) Lines: 0.0 % 40 0
Test Date: 2026-04-24 07:01:27 Functions: 0.0 % 2 0

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief Methods and functions on the i–PI environment
      10              : !> \par History
      11              : !>      03.2024 initial create
      12              : !> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
      13              : ! **************************************************************************************************
      14              : MODULE ipi_environment
      15              :    USE atomic_kind_types,               ONLY: atomic_kind_type
      16              :    USE cell_types,                      ONLY: cell_type
      17              :    USE cp_subsys_methods,               ONLY: cp_subsys_create
      18              :    USE cp_subsys_types,                 ONLY: cp_subsys_type
      19              :    USE distribution_1d_types,           ONLY: distribution_1d_release,&
      20              :                                               distribution_1d_type
      21              :    USE distribution_methods,            ONLY: distribute_molecules_1d
      22              :    USE input_section_types,             ONLY: section_vals_get_subs_vals,&
      23              :                                               section_vals_type
      24              :    USE ipi_environment_types,           ONLY: ipi_env_set,&
      25              :                                               ipi_environment_type
      26              :    USE ipi_server,                      ONLY: start_server
      27              :    USE kinds,                           ONLY: dp
      28              :    USE message_passing,                 ONLY: mp_para_env_type
      29              :    USE molecule_kind_types,             ONLY: molecule_kind_type,&
      30              :                                               write_molecule_kind_set
      31              :    USE molecule_types,                  ONLY: molecule_type
      32              :    USE particle_methods,                ONLY: write_fist_particle_coordinates,&
      33              :                                               write_particle_distances,&
      34              :                                               write_structure_data
      35              :    USE particle_types,                  ONLY: particle_type
      36              : #include "./base/base_uses.f90"
      37              : 
      38              :    IMPLICIT NONE
      39              : 
      40              :    PRIVATE
      41              : 
      42              : ! *** Global parameters ***
      43              : 
      44              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ipi_environment'
      45              : 
      46              : ! *** Public subroutines ***
      47              : 
      48              :    PUBLIC :: ipi_init
      49              : 
      50              : CONTAINS
      51              : 
      52              : ! **************************************************************************************************
      53              : !> \brief Initialize the ipi environment
      54              : !> \param ipi_env The ipi environment to retain
      55              : !> \param root_section ...
      56              : !> \param para_env ...
      57              : !> \param force_env_section ...
      58              : !> \param subsys_section ...
      59              : !> \par History
      60              : !>      03.2006 initial create
      61              : !> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
      62              : ! **************************************************************************************************
      63            0 :    SUBROUTINE ipi_init(ipi_env, root_section, para_env, force_env_section, &
      64              :                        subsys_section)
      65              :       TYPE(ipi_environment_type), POINTER                :: ipi_env
      66              :       TYPE(section_vals_type), POINTER                   :: root_section
      67              :       TYPE(mp_para_env_type), POINTER                    :: para_env
      68              :       TYPE(section_vals_type), POINTER                   :: force_env_section, subsys_section
      69              : 
      70              :       CHARACTER(len=*), PARAMETER                        :: routineN = 'ipi_init'
      71              : 
      72              :       INTEGER                                            :: handle
      73              :       TYPE(cp_subsys_type), POINTER                      :: subsys
      74              :       TYPE(section_vals_type), POINTER                   :: driver_section, motion_section
      75              : 
      76            0 :       CALL timeset(routineN, handle)
      77              : 
      78            0 :       CPASSERT(ASSOCIATED(ipi_env))
      79              : 
      80              :       ! nullifying  pointers
      81            0 :       NULLIFY (subsys)
      82              : 
      83            0 :       IF (.NOT. ASSOCIATED(subsys_section)) THEN
      84            0 :          subsys_section => section_vals_get_subs_vals(force_env_section, "SUBSYS")
      85              :       END IF
      86              : 
      87            0 :       CALL ipi_env_set(ipi_env=ipi_env, force_env_input=force_env_section)
      88              : 
      89            0 :       CALL cp_subsys_create(subsys, para_env, root_section)
      90              : 
      91            0 :       CALL ipi_init_subsys(ipi_env=ipi_env, subsys=subsys, subsys_section=subsys_section)
      92              : 
      93            0 :       motion_section => section_vals_get_subs_vals(root_section, "MOTION")
      94            0 :       driver_section => section_vals_get_subs_vals(motion_section, "DRIVER")
      95            0 :       CALL start_server(para_env=para_env, driver_section=driver_section, ipi_env=ipi_env)
      96              : 
      97            0 :       CALL timestop(handle)
      98              : 
      99            0 :    END SUBROUTINE ipi_init
     100              : 
     101              : ! **************************************************************************************************
     102              : !> \brief Initialize the ipi environment
     103              : !> \param ipi_env The ipi environment
     104              : !> \param subsys the subsys
     105              : !> \param subsys_section ...
     106              : !> \par History
     107              : !>      03.2024 initial create
     108              : !> \author Sebastian Seidenath (sebastian.seidenath@uni-jena.de)
     109              : ! **************************************************************************************************
     110            0 :    SUBROUTINE ipi_init_subsys(ipi_env, subsys, subsys_section)
     111              :       TYPE(ipi_environment_type), POINTER                :: ipi_env
     112              :       TYPE(cp_subsys_type), POINTER                      :: subsys
     113              :       TYPE(section_vals_type), POINTER                   :: subsys_section
     114              : 
     115              :       CHARACTER(len=*), PARAMETER                        :: routineN = 'ipi_init_subsys'
     116              : 
     117              :       INTEGER                                            :: handle, natom
     118            0 :       TYPE(atomic_kind_type), DIMENSION(:), POINTER      :: atomic_kind_set
     119              :       TYPE(cell_type), POINTER                           :: my_cell, my_cell_ref
     120              :       TYPE(distribution_1d_type), POINTER                :: local_molecules, local_particles
     121            0 :       TYPE(molecule_kind_type), DIMENSION(:), POINTER    :: molecule_kind_set
     122            0 :       TYPE(molecule_type), DIMENSION(:), POINTER         :: molecule_set
     123            0 :       TYPE(particle_type), DIMENSION(:), POINTER         :: particle_set
     124              : 
     125            0 :       CALL timeset(routineN, handle)
     126              : 
     127              :       NULLIFY (atomic_kind_set, molecule_kind_set, particle_set, molecule_set, &
     128            0 :                local_molecules, local_particles, my_cell, my_cell_ref)
     129              : 
     130            0 :       particle_set => subsys%particles%els
     131            0 :       atomic_kind_set => subsys%atomic_kinds%els
     132            0 :       molecule_kind_set => subsys%molecule_kinds%els
     133            0 :       molecule_set => subsys%molecules%els
     134            0 :       my_cell => subsys%cell
     135            0 :       my_cell_ref => subsys%cell_ref
     136              : 
     137              : !   *** Print the molecule kind set ***
     138            0 :       CALL write_molecule_kind_set(molecule_kind_set, subsys_section)
     139              : 
     140              : !   *** Print the atomic coordinates ***
     141            0 :       CALL write_fist_particle_coordinates(particle_set, subsys_section)
     142              :       CALL write_particle_distances(particle_set, cell=my_cell, &
     143            0 :                                     subsys_section=subsys_section)
     144              :       CALL write_structure_data(particle_set, cell=my_cell, &
     145            0 :                                 input_section=subsys_section)
     146              : 
     147              : !   *** Distribute molecules and atoms using the new data structures ***
     148              :       CALL distribute_molecules_1d(atomic_kind_set=atomic_kind_set, &
     149              :                                    particle_set=particle_set, &
     150              :                                    local_particles=local_particles, &
     151              :                                    molecule_kind_set=molecule_kind_set, &
     152              :                                    molecule_set=molecule_set, &
     153              :                                    local_molecules=local_molecules, &
     154            0 :                                    force_env_section=ipi_env%force_env_input)
     155              : 
     156            0 :       natom = SIZE(particle_set)
     157              : 
     158            0 :       ALLOCATE (ipi_env%ipi_forces(3, natom))
     159            0 :       ipi_env%ipi_forces(:, :) = 0.0_dp
     160              : 
     161              :       CALL ipi_env_set(ipi_env=ipi_env, subsys=subsys, &
     162              :                        cell_ref=my_cell_ref, &
     163              :                        local_molecules=local_molecules, &
     164            0 :                        local_particles=local_particles)
     165              : 
     166            0 :       CALL distribution_1d_release(local_particles)
     167            0 :       CALL distribution_1d_release(local_molecules)
     168              : 
     169            0 :       CALL timestop(handle)
     170              : 
     171            0 :    END SUBROUTINE ipi_init_subsys
     172              : 
     173              : END MODULE ipi_environment
        

Generated by: LCOV version 2.0-1