LCOV - code coverage report
Current view: top level - src - mixed_environment.F (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 38 38 100.0 %
Date: 2024-12-21 06:28:57 Functions: 2 2 100.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 initialize mixed environment
      10             : !> \author fschiff
      11             : ! **************************************************************************************************
      12             : MODULE mixed_environment
      13             :    USE atomic_kind_types,               ONLY: atomic_kind_type
      14             :    USE cell_methods,                    ONLY: read_cell,&
      15             :                                               write_cell
      16             :    USE cell_types,                      ONLY: cell_release,&
      17             :                                               cell_type,&
      18             :                                               get_cell
      19             :    USE cp_subsys_methods,               ONLY: cp_subsys_create
      20             :    USE cp_subsys_types,                 ONLY: cp_subsys_set,&
      21             :                                               cp_subsys_type
      22             :    USE distribution_1d_types,           ONLY: distribution_1d_release,&
      23             :                                               distribution_1d_type
      24             :    USE distribution_methods,            ONLY: distribute_molecules_1d
      25             :    USE input_section_types,             ONLY: section_vals_get_subs_vals,&
      26             :                                               section_vals_type
      27             :    USE kinds,                           ONLY: dp
      28             :    USE message_passing,                 ONLY: mp_para_env_type
      29             :    USE mixed_energy_types,              ONLY: allocate_mixed_energy,&
      30             :                                               mixed_energy_type
      31             :    USE mixed_environment_types,         ONLY: mixed_environment_type,&
      32             :                                               set_mixed_env
      33             :    USE molecule_kind_types,             ONLY: molecule_kind_type,&
      34             :                                               write_molecule_kind_set
      35             :    USE molecule_types,                  ONLY: molecule_type
      36             :    USE particle_types,                  ONLY: particle_type
      37             : #include "./base/base_uses.f90"
      38             : 
      39             :    IMPLICIT NONE
      40             : 
      41             :    PRIVATE
      42             : 
      43             :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'mixed_environment'
      44             :    PUBLIC :: mixed_init
      45             : 
      46             : CONTAINS
      47             : 
      48             : ! **************************************************************************************************
      49             : !> \brief reads the input and database file for mixed
      50             : !> \param mixed_env ...
      51             : !> \param root_section ...
      52             : !> \param para_env ...
      53             : !> \param force_env_section ...
      54             : !> \param use_motion_section ...
      55             : !> \par Used By
      56             : !>      mixed_main
      57             : !> \author fschiff
      58             : ! **************************************************************************************************
      59         130 :    SUBROUTINE mixed_init(mixed_env, root_section, para_env, force_env_section, &
      60             :                          use_motion_section)
      61             : 
      62             :       TYPE(mixed_environment_type), INTENT(INOUT)        :: mixed_env
      63             :       TYPE(section_vals_type), POINTER                   :: root_section
      64             :       TYPE(mp_para_env_type), POINTER                    :: para_env
      65             :       TYPE(section_vals_type), POINTER                   :: force_env_section
      66             :       LOGICAL, INTENT(IN)                                :: use_motion_section
      67             : 
      68             :       CHARACTER(len=*), PARAMETER                        :: routineN = 'mixed_init'
      69             : 
      70             :       INTEGER                                            :: handle
      71             :       LOGICAL                                            :: use_ref_cell
      72             :       REAL(KIND=dp), DIMENSION(3)                        :: abc
      73             :       TYPE(cell_type), POINTER                           :: cell, cell_ref
      74             :       TYPE(cp_subsys_type), POINTER                      :: subsys
      75             :       TYPE(section_vals_type), POINTER                   :: cell_section, subsys_section
      76             : 
      77         130 :       CALL timeset(routineN, handle)
      78             : 
      79         130 :       NULLIFY (subsys, cell, cell_ref)
      80         130 :       NULLIFY (cell_section)
      81             : 
      82         130 :       subsys_section => section_vals_get_subs_vals(force_env_section, "SUBSYS")
      83         130 :       cell_section => section_vals_get_subs_vals(subsys_section, "CELL")
      84             : 
      85         130 :       CALL set_mixed_env(mixed_env, input=force_env_section)
      86             :       CALL cp_subsys_create(subsys, para_env, root_section, &
      87             :                             force_env_section=force_env_section, &
      88         130 :                             use_motion_section=use_motion_section)
      89             : 
      90             :       CALL read_cell(cell, cell_ref, use_ref_cell=use_ref_cell, &
      91         130 :                      cell_section=cell_section, para_env=para_env)
      92         130 :       CALL get_cell(cell, abc=abc)
      93             : 
      94             :       ! Print the cell parameters ***
      95         130 :       CALL write_cell(cell, subsys_section)
      96         130 :       CALL write_cell(cell_ref, subsys_section)
      97             : 
      98             :       CALL mixed_init_subsys(mixed_env, subsys, cell, cell_ref, &
      99         130 :                              force_env_section, subsys_section)
     100             : 
     101         130 :       CALL cell_release(cell)
     102         130 :       CALL cell_release(cell_ref)
     103             : 
     104         130 :       CALL timestop(handle)
     105             : 
     106         130 :    END SUBROUTINE mixed_init
     107             : 
     108             : ! **************************************************************************************************
     109             : !> \brief   Read the input and the database files for the setup of the
     110             : !>          mixed environment.
     111             : !> \param mixed_env ...
     112             : !> \param subsys ...
     113             : !> \param cell ...
     114             : !> \param cell_ref ...
     115             : !> \param force_env_section ...
     116             : !> \param subsys_section ...
     117             : !> \date    11.06
     118             : !> \author  fschiff
     119             : !> \version 1.0
     120             : ! **************************************************************************************************
     121         130 :    SUBROUTINE mixed_init_subsys(mixed_env, subsys, cell, cell_ref, &
     122             :                                 force_env_section, subsys_section)
     123             : 
     124             :       TYPE(mixed_environment_type), INTENT(INOUT)        :: mixed_env
     125             :       TYPE(cp_subsys_type), POINTER                      :: subsys
     126             :       TYPE(cell_type), POINTER                           :: cell, cell_ref
     127             :       TYPE(section_vals_type), POINTER                   :: force_env_section, subsys_section
     128             : 
     129             :       CHARACTER(len=*), PARAMETER                        :: routineN = 'mixed_init_subsys'
     130             : 
     131             :       INTEGER                                            :: handle
     132         130 :       TYPE(atomic_kind_type), DIMENSION(:), POINTER      :: atomic_kind_set
     133             :       TYPE(distribution_1d_type), POINTER                :: local_molecules, local_particles
     134             :       TYPE(mixed_energy_type), POINTER                   :: mixed_energy
     135         130 :       TYPE(molecule_kind_type), DIMENSION(:), POINTER    :: molecule_kind_set
     136         130 :       TYPE(molecule_type), DIMENSION(:), POINTER         :: molecule_set
     137         130 :       TYPE(particle_type), DIMENSION(:), POINTER         :: particle_set
     138             : 
     139         130 :       CALL timeset(routineN, handle)
     140         130 :       NULLIFY (mixed_energy, local_molecules, local_particles)
     141         130 :       particle_set => subsys%particles%els
     142         130 :       atomic_kind_set => subsys%atomic_kinds%els
     143         130 :       molecule_set => subsys%molecules%els
     144         130 :       molecule_kind_set => subsys%molecule_kinds%els
     145             : 
     146             :       ! Create the mixed_energy_type
     147         130 :       CALL allocate_mixed_energy(mixed_energy)
     148             : 
     149             :       ! Print the molecule kind set
     150         130 :       CALL write_molecule_kind_set(molecule_kind_set, subsys_section)
     151             : 
     152             :       ! Distribute molecules and atoms using the new data structures ***
     153             :       CALL distribute_molecules_1d(atomic_kind_set=atomic_kind_set, &
     154             :                                    particle_set=particle_set, &
     155             :                                    local_particles=local_particles, &
     156             :                                    molecule_kind_set=molecule_kind_set, &
     157             :                                    molecule_set=molecule_set, &
     158             :                                    local_molecules=local_molecules, &
     159         130 :                                    force_env_section=force_env_section)
     160             : 
     161         130 :       CALL cp_subsys_set(subsys, cell=cell)
     162             : 
     163             :       ! set the mixed_env
     164         130 :       CALL set_mixed_env(mixed_env=mixed_env, subsys=subsys)
     165             :       CALL set_mixed_env(mixed_env=mixed_env, &
     166             :                          cell_ref=cell_ref, &
     167             :                          local_molecules=local_molecules, &
     168             :                          local_particles=local_particles, &
     169         130 :                          mixed_energy=mixed_energy)
     170             : 
     171         130 :       CALL distribution_1d_release(local_particles)
     172         130 :       CALL distribution_1d_release(local_molecules)
     173             : 
     174         130 :       CALL timestop(handle)
     175             : 
     176         130 :    END SUBROUTINE mixed_init_subsys
     177             : 
     178             : END MODULE mixed_environment

Generated by: LCOV version 1.15