(git:ccc2433)
multipole_types.F
Go to the documentation of this file.
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 Multipole structure: for multipole (fixed and induced) in FF based MD
10 !> \author Teodoro Laino [tlaino] - University of Zurich - 12.2007
11 ! **************************************************************************************************
14  USE external_potential_types, ONLY: fist_potential_type,&
15  get_potential
18  section_vals_type,&
20  USE kinds, ONLY: dp
21  USE particle_types, ONLY: particle_type
22 #include "../base/base_uses.f90"
23 
24  IMPLICIT NONE
25 
26  PRIVATE
27  PUBLIC :: multipole_type, &
30 
31  INTEGER, PARAMETER, PUBLIC :: do_multipole_none = -1, &
32  do_multipole_charge = 0, &
33  do_multipole_dipole = 1, &
35 
36 ! **************************************************************************************************
37 !> \brief Define multipole type
38 !> \param error variable to control error logging, stopping,...
39 !> see module cp_error_handling
40 !> \par History
41 !> 12.2007 created [tlaino] - Teodoro Laino - University of Zurich
42 !> \author Teodoro Laino
43 ! **************************************************************************************************
44  TYPE multipole_type
45  LOGICAL, DIMENSION(3) :: task = .false.
46  REAL(kind=dp), DIMENSION(:), POINTER :: charges => null()
47  REAL(kind=dp), DIMENSION(:), POINTER :: radii => null()
48  REAL(kind=dp), DIMENSION(:, :), POINTER :: dipoles => null()
49  REAL(kind=dp), DIMENSION(:, :, :), POINTER :: quadrupoles => null()
50  END TYPE multipole_type
51 
52  CHARACTER(len=*), PARAMETER, PRIVATE :: modulen = 'multipole_types'
53 
54 CONTAINS
55 
56 ! **************************************************************************************************
57 !> \brief Create a multipole type
58 !> \param multipoles ...
59 !> \param particle_set ...
60 !> \param subsys_section ...
61 !> \param max_multipole ...
62 !> \par History
63 !> 12.2007 created [tlaino] - Teodoro Laino - University of Zurich
64 !> \author Teodoro Laino
65 ! **************************************************************************************************
66  SUBROUTINE create_multipole_type(multipoles, particle_set, subsys_section, max_multipole)
67  TYPE(multipole_type), INTENT(OUT) :: multipoles
68  TYPE(particle_type), DIMENSION(:), INTENT(IN) :: particle_set
69  TYPE(section_vals_type), POINTER :: subsys_section
70  INTEGER, INTENT(IN) :: max_multipole
71 
72  INTEGER :: i, ind2, iparticle, j, n_rep, nparticles
73  LOGICAL :: explicit
74  REAL(kind=dp), DIMENSION(:), POINTER :: work
75  TYPE(fist_potential_type), POINTER :: fist_potential
76  TYPE(section_vals_type), POINTER :: work_section
77 
78  SELECT CASE (max_multipole)
79  CASE (do_multipole_none)
80  ! Do nothing..
81  CASE (do_multipole_charge)
82  multipoles%task(1:1) = .true.
83  CASE (do_multipole_dipole)
84  multipoles%task(1:2) = .true.
86  multipoles%task(1:3) = .true.
87  CASE DEFAULT
88  cpabort("")
89  END SELECT
90  nparticles = SIZE(particle_set)
91  IF (multipoles%task(1)) THEN
92  ALLOCATE (multipoles%charges(nparticles))
93  ALLOCATE (multipoles%radii(nparticles))
94  ! Fill in charge array
95  DO iparticle = 1, nparticles
96  !atomic_kind =>
97  CALL get_atomic_kind(particle_set(iparticle)%atomic_kind, &
98  fist_potential=fist_potential)
99  CALL get_potential(fist_potential, qeff=multipoles%charges(iparticle), &
100  mm_radius=multipoles%radii(iparticle))
101  END DO
102  END IF
103  IF (multipoles%task(2)) THEN
104  ALLOCATE (multipoles%dipoles(3, nparticles))
105  ! Fill in dipole array (if specified)
106  work_section => section_vals_get_subs_vals(subsys_section, "MULTIPOLES%DIPOLES")
107  CALL section_vals_get(work_section, explicit=explicit)
108  IF (explicit) THEN
109  CALL section_vals_val_get(work_section, "_DEFAULT_KEYWORD_", n_rep_val=n_rep)
110  cpassert(n_rep == nparticles)
111  DO iparticle = 1, n_rep
112  CALL section_vals_val_get(work_section, "_DEFAULT_KEYWORD_", i_rep_val=iparticle, r_vals=work)
113  multipoles%dipoles(1:3, iparticle) = work
114  END DO
115  ELSE
116  multipoles%dipoles = 0.0_dp
117  END IF
118  END IF
119  IF (multipoles%task(3)) THEN
120  ALLOCATE (multipoles%quadrupoles(3, 3, nparticles))
121  ! Fill in quadrupole array (if specified)
122  work_section => section_vals_get_subs_vals(subsys_section, "MULTIPOLES%QUADRUPOLES")
123  CALL section_vals_get(work_section, explicit=explicit)
124  IF (explicit) THEN
125  CALL section_vals_val_get(work_section, "_DEFAULT_KEYWORD_", n_rep_val=n_rep)
126  cpassert(n_rep == nparticles)
127  DO iparticle = 1, n_rep
128  CALL section_vals_val_get(work_section, "_DEFAULT_KEYWORD_", i_rep_val=iparticle, r_vals=work)
129  DO i = 1, 3
130  DO j = 1, 3
131  ind2 = 3*(min(i, j) - 1) - (min(i, j)*(min(i, j) - 1))/2 + max(i, j)
132  multipoles%quadrupoles(i, j, iparticle) = work(ind2)
133  END DO
134  END DO
135  END DO
136  ELSE
137  multipoles%quadrupoles = 0.0_dp
138  END IF
139  END IF
140  END SUBROUTINE create_multipole_type
141 
142 ! **************************************************************************************************
143 !> \brief ...
144 !> \param multipoles ...
145 !> \par History
146 !> 12.2007 created [tlaino] - Teodoro Laino - University of Zurich
147 !> \author Teodoro Laino
148 ! **************************************************************************************************
149  SUBROUTINE release_multipole_type(multipoles)
150  TYPE(multipole_type), INTENT(INOUT) :: multipoles
151 
152  IF (ASSOCIATED(multipoles%charges)) THEN
153  DEALLOCATE (multipoles%charges)
154  END IF
155  IF (ASSOCIATED(multipoles%radii)) THEN
156  DEALLOCATE (multipoles%radii)
157  END IF
158  IF (ASSOCIATED(multipoles%dipoles)) THEN
159  DEALLOCATE (multipoles%dipoles)
160  END IF
161  IF (ASSOCIATED(multipoles%quadrupoles)) THEN
162  DEALLOCATE (multipoles%quadrupoles)
163  END IF
164 
165  END SUBROUTINE release_multipole_type
166 
167 END MODULE multipole_types
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.
Definition of the atomic potential types.
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_get(section_vals, ref_count, n_repetition, n_subs_vals_rep, section, explicit)
returns various attributes about the section_vals
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
Multipole structure: for multipole (fixed and induced) in FF based MD.
integer, parameter, public do_multipole_quadrupole
subroutine, public release_multipole_type(multipoles)
...
integer, parameter, public do_multipole_dipole
subroutine, public create_multipole_type(multipoles, particle_set, subsys_section, max_multipole)
Create a multipole type.
integer, parameter, public do_multipole_charge
integer, parameter, public do_multipole_none
Define the data structure for the particle information.