(git:374b731)
Loading...
Searching...
No Matches
qs_period_efield_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 type for berry phase efield matrices. At the moment only used for
10!> cosmat and sinmat
11!> \par History
12!> none
13!> \author fschiff (06.2010)
14! **************************************************************************************************
15
17
19 USE dbcsr_api, ONLY: dbcsr_p_type
20 USE kinds, ONLY: dp
21#include "./base/base_uses.f90"
22
23 IMPLICIT NONE
24
25 PRIVATE
26
27 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_period_efield_types'
28
31
33 REAL(kind=dp) :: field_energy
34 REAL(kind=dp), DIMENSION(3) :: polarisation
35 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: cosmat
36 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: sinmat
37 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: dipmat
38 END TYPE efield_berry_type
39
40CONTAINS
41
42! **************************************************************************************************
43!> \brief ...
44!> \param efield ...
45! **************************************************************************************************
46 SUBROUTINE init_efield_matrices(efield)
47 TYPE(efield_berry_type), POINTER :: efield
48
49 REAL(kind=dp) :: field_energy
50 REAL(kind=dp), DIMENSION(3) :: polarisation
51
52! retain possible values for energy and polarisation
53
54 IF (ASSOCIATED(efield)) THEN
55 field_energy = efield%field_energy
56 polarisation = efield%polarisation
57 CALL efield_berry_release(efield)
58 ELSE
59 field_energy = 0.0_dp
60 polarisation = 0.0_dp
61 END IF
62
63 ALLOCATE (efield)
64 NULLIFY (efield%cosmat)
65 NULLIFY (efield%sinmat)
66 NULLIFY (efield%dipmat)
67
68 efield%field_energy = field_energy
69 efield%polarisation = polarisation
70
71 END SUBROUTINE init_efield_matrices
72
73! **************************************************************************************************
74!> \brief ...
75!> \param efield ...
76!> \param sinmat ...
77!> \param cosmat ...
78!> \param dipmat ...
79! **************************************************************************************************
80 SUBROUTINE set_efield_matrices(efield, sinmat, cosmat, dipmat)
81
82 TYPE(efield_berry_type), POINTER :: efield
83 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
84 POINTER :: sinmat, cosmat, dipmat
85
86 IF (PRESENT(cosmat)) efield%cosmat => cosmat
87 IF (PRESENT(sinmat)) efield%sinmat => sinmat
88 IF (PRESENT(dipmat)) efield%dipmat => dipmat
89
90 END SUBROUTINE set_efield_matrices
91
92! **************************************************************************************************
93!> \brief ...
94!> \param efield ...
95! **************************************************************************************************
96 SUBROUTINE efield_berry_release(efield)
97 TYPE(efield_berry_type), POINTER :: efield
98
99 IF (ASSOCIATED(efield)) THEN
100 IF (ASSOCIATED(efield%sinmat) .AND. ASSOCIATED(efield%cosmat)) THEN
101 CALL dbcsr_deallocate_matrix_set(efield%cosmat)
102 CALL dbcsr_deallocate_matrix_set(efield%sinmat)
103 END IF
104 IF (ASSOCIATED(efield%dipmat)) THEN
105 CALL dbcsr_deallocate_matrix_set(efield%dipmat)
106 END IF
107 DEALLOCATE (efield)
108 END IF
109 END SUBROUTINE efield_berry_release
110
111END MODULE qs_period_efield_types
DBCSR operations in CP2K.
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
type for berry phase efield matrices. At the moment only used for cosmat and sinmat
subroutine, public efield_berry_release(efield)
...
subroutine, public set_efield_matrices(efield, sinmat, cosmat, dipmat)
...
subroutine, public init_efield_matrices(efield)
...