LCOV - code coverage report
Current view: top level - src - ipi_environment.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 0 45 0.0 %
Date: 2024-12-21 06:28:57 Functions: 0 2 0.0 %

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

Generated by: LCOV version 1.15