Octopus
nlcc.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!! Copyright (C) 2021 Nicolas Tancogne-Dejean
3!!
4!! This program is free software; you can redistribute it and/or modify
5!! it under the terms of the GNU General Public License as published by
6!! the Free Software Foundation; either version 2, or (at your option)
7!! any later version.
8!!
9!! This program is distributed in the hope that it will be useful,
10!! but WITHOUT ANY WARRANTY; without even the implied warranty of
11!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!! GNU General Public License for more details.
13!!
14!! You should have received a copy of the GNU General Public License
15!! along with this program; if not, write to the Free Software
16!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17!! 02110-1301, USA.
18!!
19
20#include "global.h"
21
22module nlcc_oct_m
23 use atom_oct_m
24 use comm_oct_m
25 use debug_oct_m
28 use global_oct_m
31 use ions_oct_m
33 use mesh_oct_m
38 use ps_oct_m
41 use space_oct_m
46
47 implicit none
48
49 private
50 public :: &
51 nlcc_t
52
53 type, extends(density_interaction_t) :: nlcc_t
54 private
55
56 type(mesh_t), pointer :: mesh => null()
57 type(space_t), pointer :: space => null()
58
59 ! This information should be copied, and not obtained thanks to pointer
60 ! This is a temporary change here
61 type(distributed_t), pointer, public :: atoms_dist => null()
62 type(atom_t), pointer, public :: atom(:) => null()
63 real(real64), pointer, public :: pos(:,:) => null()
64 type(lattice_vectors_t), pointer :: latt => null()
65
66 contains
67 procedure :: init => nlcc_init
68 procedure :: bind => nlcc_bind
69 procedure :: calculate => nlcc_calculate
70 procedure :: calculate_energy => nlcc_calculate_energy
71 procedure :: end => nlcc_end
72 final :: nlcc_finalize
73 end type nlcc_t
74
75 interface nlcc_t
76 module procedure nlcc_constructor
77 end interface nlcc_t
78
79contains
80
81 ! ---------------------------------------------------------
82 function nlcc_constructor(partner) result(this)
83 class(interaction_partner_t), target, intent(inout) :: partner
84 class(nlcc_t), pointer :: this
85
86 push_sub(nlcc_constructor)
87
88 allocate(this)
89
90 this%label = "nlcc"
91
92 this%partner => partner
93
94 pop_sub(nlcc_constructor)
95 end function nlcc_constructor
96
97 ! ---------------------------------------------------------
98 subroutine nlcc_init(this, mesh, ions)
99 class(nlcc_t), intent(inout) :: this
100 class(mesh_t), target, intent(in) :: mesh
101 type(ions_t), target, intent(in) :: ions
102
103
104 push_sub(nlcc_init)
105
106 this%mesh => mesh
107
108 safe_allocate(this%density(1:mesh%np,1))
109
110 this%atoms_dist => ions%atoms_dist
111 this%atom => ions%atom
112 this%space => ions%space
113 this%pos => ions%pos
114 this%latt => ions%latt
115
116 pop_sub(nlcc_init)
117 end subroutine nlcc_init
118
119 ! ---------------------------------------------------------
122 subroutine nlcc_bind(this, ions)
123 class(nlcc_t), intent(inout) :: this
124 type(ions_t), target, intent(in) :: ions
125
126 push_sub(nlcc_bind)
127
128 this%atoms_dist => ions%atoms_dist
129 this%atom => ions%atom
130 this%space => ions%space
131 this%pos => ions%pos
132 this%latt => ions%latt
133
134 pop_sub(nlcc_bind)
135 end subroutine nlcc_bind
136
137 ! ---------------------------------------------------------
138 subroutine nlcc_calculate(this)
139 class(nlcc_t), intent(inout) :: this
140
141 integer :: ia
142
143 push_sub(nlcc_calculate)
144
145 call profiling_in("NLCC_INTER")
146
147 this%density(:,:) = m_zero
149 do ia = this%atoms_dist%start, this%atoms_dist%end
150 if (this%atom(ia)%species%is_ps_with_nlcc()) then
151 call species_get_nlcc(this%atom(ia)%species, this%space, this%latt, this%pos(:, ia), this%mesh, &
152 this%density(:,1), accumulate=.true.)
153 end if
154 end do
155
156 ! reduce over atoms if required
157 if (this%atoms_dist%parallel) then
158 call comm_allreduce(this%atoms_dist%mpi_grp, this%density(:,1))
159 end if
160
161 call profiling_out("NLCC_INTER")
164 end subroutine nlcc_calculate
166 ! ---------------------------------------------------------
167 subroutine nlcc_end(this)
168 class(nlcc_t), intent(inout) :: this
169
170 push_sub(nlcc_end)
171
172 safe_deallocate_a(this%density)
173 nullify(this%mesh)
174
175 call interaction_end(this)
176
177 pop_sub(nlcc_end)
178 end subroutine nlcc_end
179
180
181 ! ---------------------------------------------------------
182 subroutine nlcc_finalize(this)
183 type(nlcc_t), intent(inout) :: this
184
185 push_sub(nlcc_finalize)
186
187 call nlcc_end(this)
188
189 pop_sub(nlcc_finalize)
190 end subroutine nlcc_finalize
191
192 ! ---------------------------------------------------------
193 subroutine nlcc_calculate_energy(this)
194 class(nlcc_t), intent(inout) :: this
195
196 push_sub(nlcc_calculate_energy)
197
198 !NLCC has no energy by itself. The energy is obtained through exchange and correlation
199
200 this%energy = m_zero
201
202 pop_sub(nlcc_calculate_energy)
203 end subroutine nlcc_calculate_energy
204
205end module nlcc_oct_m
206
207!! Local Variables:
208!! mode: f90
209!! coding: utf-8
210!! End:
real(real64), parameter, public m_zero
Definition: global.F90:200
This module defines the abstract interaction_t class, and some auxiliary classes for interactions.
subroutine, public interaction_end(this)
This module defines classes and functions for interaction partners.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine nlcc_end(this)
Definition: nlcc.F90:263
subroutine nlcc_calculate(this)
Definition: nlcc.F90:234
subroutine nlcc_finalize(this)
Definition: nlcc.F90:278
subroutine nlcc_init(this, mesh, ions)
Definition: nlcc.F90:194
class(nlcc_t) function, pointer nlcc_constructor(partner)
Definition: nlcc.F90:178
subroutine nlcc_calculate_energy(this)
Definition: nlcc.F90:289
subroutine nlcc_bind(this, ions)
Rebind NLCC helper pointers after copying the ionic geometry. The movers in NLCC reference ionic arra...
Definition: nlcc.F90:218
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
Definition: profiling.F90:631
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
Definition: profiling.F90:554
Definition: ps.F90:116
This module defines the quantity_t class and the IDs for quantities, which can be exposed by a system...
Definition: quantity.F90:140
subroutine, public species_get_nlcc(species, space, latt, pos, mesh, rho_core, accumulate)
int true(void)