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 Type for the canonical sampling through velocity rescaling 10 : !> \author Teodoro Laino - 09.2007 University of Zurich [tlaino] 11 : ! ************************************************************************************************** 12 : MODULE al_system_types 13 : USE bibliography, ONLY: Jones2011,& 14 : cite_reference 15 : USE extended_system_types, ONLY: create_map_info_type,& 16 : map_info_type,& 17 : release_map_info_type 18 : USE input_section_types, ONLY: section_vals_type,& 19 : section_vals_val_get 20 : USE kinds, ONLY: dp 21 : USE simpar_types, ONLY: simpar_type 22 : #include "./base/base_uses.f90" 23 : 24 : IMPLICIT NONE 25 : 26 : PRIVATE 27 : PUBLIC :: al_system_type, & 28 : al_init, & 29 : al_dealloc, & 30 : al_thermo_create 31 : 32 : ! ************************************************************************************************** 33 : TYPE al_thermo_type 34 : INTEGER :: degrees_of_freedom = 0 35 : REAL(KIND=dp) :: nkt = 0.0_dp 36 : REAL(KIND=dp) :: chi = 0.0_dp 37 : REAL(KIND=dp) :: mass = 0.0_dp 38 : REAL(KIND=dp) :: region_kin_energy = 0.0_dp 39 : END TYPE al_thermo_type 40 : 41 : ! ************************************************************************************************** 42 : TYPE al_system_type 43 : INTEGER :: region = 0, glob_num_al = 0, loc_num_al = 0 44 : REAL(KIND=dp) :: tau_nh = 0.0_dp, tau_langevin = 0.0_dp, dt_fact = 0.0_dp 45 : REAL(KIND=dp) :: dt = 0.0_dp 46 : TYPE(al_thermo_type), POINTER :: nvt(:) => NULL() 47 : TYPE(map_info_type), POINTER :: map_info => NULL() 48 : END TYPE al_system_type 49 : 50 : ! *** Global parameters *** 51 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'al_system_types' 52 : 53 : CONTAINS 54 : 55 : ! ************************************************************************************************** 56 : !> \brief Initialize type for Adaptive Langevin (AD_LANGEVIN) 57 : !> \param al ... 58 : !> \param simpar ... 59 : !> \param section ... 60 : !> \author Noam Bernstein [noamb] 02.2012 61 : ! ************************************************************************************************** 62 4 : SUBROUTINE al_init(al, simpar, section) 63 : TYPE(al_system_type), POINTER :: al 64 : TYPE(simpar_type), POINTER :: simpar 65 : TYPE(section_vals_type), POINTER :: section 66 : 67 4 : NULLIFY (al%nvt) 68 4 : NULLIFY (al%map_info) 69 4 : al%loc_num_al = 0 70 4 : al%glob_num_al = 0 71 4 : al%dt_fact = 1.0_dp 72 4 : al%dt = simpar%dt 73 4 : CALL cite_reference(Jones2011) 74 4 : CALL section_vals_val_get(section, "TIMECON_NH", r_val=al%tau_nh) 75 4 : CALL section_vals_val_get(section, "TIMECON_LANGEVIN", r_val=al%tau_langevin) 76 4 : CALL create_map_info_type(al%map_info) 77 : 78 4 : END SUBROUTINE al_init 79 : 80 : ! ************************************************************************************************** 81 : !> \brief Initialize NVT type for AD_LANGEVIN thermostat 82 : !> \param al ... 83 : !> \author Noam Bernstein [noamb] 02.2012 84 : ! ************************************************************************************************** 85 4 : SUBROUTINE al_thermo_create(al) 86 : TYPE(al_system_type), POINTER :: al 87 : 88 : INTEGER :: i 89 4 : REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: seed 90 : 91 4 : CPASSERT(ASSOCIATED(al)) 92 4 : CPASSERT(.NOT. ASSOCIATED(al%nvt)) 93 : 94 49605 : ALLOCATE (al%nvt(al%loc_num_al)) 95 49597 : DO i = 1, al%loc_num_al 96 49597 : al%nvt(i)%chi = 0.0_dp 97 : END DO 98 : ! Initialize the gaussian stream random number 99 12 : ALLOCATE (seed(3, 2, al%glob_num_al)) 100 : 101 4 : END SUBROUTINE al_thermo_create 102 : 103 : ! ************************************************************************************************** 104 : !> \brief Deallocate type for AD_LANGEVIN thermostat 105 : !> \param al ... 106 : !> \author Noam Bernstein [noamb] 02.2012 107 : ! ************************************************************************************************** 108 4 : SUBROUTINE al_dealloc(al) 109 : TYPE(al_system_type), POINTER :: al 110 : 111 4 : IF (ASSOCIATED(al)) THEN 112 4 : CALL al_thermo_dealloc(al%nvt) 113 4 : CALL release_map_info_type(al%map_info) 114 4 : DEALLOCATE (al) 115 : END IF 116 : 117 4 : END SUBROUTINE al_dealloc 118 : 119 : ! ************************************************************************************************** 120 : !> \brief Deallocate NVT type for AD_LANGEVIN thermostat 121 : !> \param nvt ... 122 : !> \author Noam Bernstein [noamb] 02.2012 123 : ! ************************************************************************************************** 124 4 : SUBROUTINE al_thermo_dealloc(nvt) 125 : TYPE(al_thermo_type), DIMENSION(:), POINTER :: nvt 126 : 127 4 : IF (ASSOCIATED(nvt)) THEN 128 4 : DEALLOCATE (nvt) 129 : END IF 130 4 : END SUBROUTINE al_thermo_dealloc 131 : 132 0 : END MODULE al_system_types 133 :