22 use,
intrinsic :: iso_fortran_env, only: real64
60 integer,
private,
parameter :: ik = 1
68 type(exchange_operator_t),
intent(in ) :: exxop
70 type(namespace_t),
intent(in ) :: namespace
71 class(space_t),
intent(in ) :: space
72 class(mesh_t),
intent(in ) :: mesh
73 type(states_elec_t),
intent(in ) :: st
74 type(kpoints_t),
intent(in ) :: kpoints
76 type(states_elec_t),
intent(out) :: Vx_on_st
78 real(real64),
allocatable :: psi_mu(:, :), P_r_mu(:, :), isdf_vectors(:, :)
80 type(distributed_t) :: isdf_dist
85 assert(kpoints%gamma_only())
86 assert(.not. space%is_periodic())
87 nstates = exxop%isdf%n_ks_states
93 call distributed_init(isdf_dist,
size(isdf_vectors, 2), st%st_kpt_mpi_grp%comm)
96 safe_deallocate_a(psi_mu)
97 safe_deallocate_a(p_r_mu)
98 safe_deallocate_a(isdf_vectors)
107 type(isdf_options_t),
intent(in ) :: isdf
108 type(namespace_t),
intent(in ) :: namespace
109 class(mesh_t),
intent(in ) :: mesh
110 type(states_elec_t),
intent(in ) :: st
111 type(centroids_t),
intent(in ) :: centroids
113 real(real64),
allocatable,
intent(out) :: psi_mu(:, :)
115 real(real64),
allocatable,
intent(out) :: P_r_mu(:, :)
117 real(real64),
allocatable,
intent(out) :: isdf_vectors(:, :)
119 character(len=6) :: np_char
120 integer :: nocc, n_int_g, rank, i, j
121 real(real64),
allocatable :: zct(:, :)
122 real(real64),
allocatable :: p_mu_nu(:, :)
124 real(real64),
allocatable :: cct(:, :)
130 if (st%d%nspin > 1)
then
148 n_int_g = centroids%npoints_global()
151 nocc = isdf%n_ks_states
153 if (st%st_start <= nocc .and. nocc <= st%st_end)
then
154 write(
message(1),
'(a, 1x, I3, 1x, a, 1x, I3)')
"ISDF: Computing ISDF vectors up to state", &
155 & nocc,
" on process", st%mpi_grp%rank
163 safe_allocate(p_r_mu(1:mesh%np, 1:n_int_g))
165 if (
debug%info)
call output_matrix(namespace,
"p_r_mu_np"//trim(adjustl(np_char))//
".txt", p_r_mu)
167 safe_allocate(zct(1:mesh%np, 1:n_int_g))
169 if (
debug%info)
call output_matrix(namespace,
"zct_np"//trim(adjustl(np_char))//
".txt", zct)
172 safe_allocate(p_mu_nu(1:n_int_g, 1:n_int_g))
175 call lalg_gemm(psi_mu, psi_mu, p_mu_nu, transa=
'T')
181 p_mu_nu(i, j) = 0.0_real64
188 if (
debug%info)
call output_matrix(namespace,
"p_mu_nu_np"//trim(adjustl(np_char))//
".txt", p_mu_nu)
190 safe_allocate(cct(1:n_int_g, 1:n_int_g))
193 call output_matrix(namespace,
"cct_np"//trim(adjustl(np_char))//
".txt", cct)
196 safe_deallocate_a(p_mu_nu)
201 write(
message(1),
'(a)')
"ISDF: Inverting [CC^T]"
206 if (isdf%check_n_interp)
then
208 write(
message(1),
'(a, I7)')
"ISDF: Rank of CC^T is ", rank
209 if (rank < n_int_g)
then
210 write(
message(2),
'(a)')
" - This rank is the optimal ISDFNpoints to run the calculation with"
212 write(
message(2),
'(a)')
" - This suggests that ISDFNpoints is either optimal, or could be larger"
218 safe_allocate(isdf_vectors(1:mesh%np, 1:n_int_g))
219 call lalg_gemm(mesh%np, n_int_g, n_int_g, 1.0_real64, zct, cct, 0.0_real64, isdf_vectors)
222 if (
debug%info .and. .not. mesh%parallel_in_domains)
then
223 call output_matrix(namespace,
"isdf_np"//trim(adjustl(np_char))//
".txt", isdf_vectors)
226 safe_deallocate_a(zct)
227 safe_deallocate_a(cct)
245 real(real64),
target,
contiguous,
intent(in ) :: p_phi(:, :)
247 real(real64),
target,
optional,
contiguous,
intent(in ) :: p_psi(:, :)
250 real(real64),
contiguous,
intent(out) :: zct(:, :)
252 integer :: np, n_int_g, ip, i_mu
253 real(real64),
pointer,
contiguous :: p_2(:, :)
257 write(
message(1),
'(a)')
"ISDF: Constructing Z C^T"
260 if (
present(p_psi))
then
267 assert(all(shape(p_phi) == shape(p_2)))
269 assert(all(shape(p_phi) == shape(zct)))
272 n_int_g =
size(p_phi, 2)
279 zct(ip, i_mu) = p_phi(ip, i_mu) * p_2(ip, i_mu)
303 real(real64),
target,
contiguous,
intent(in ) :: p_phi(:, :)
305 real(real64),
target,
contiguous,
optional,
intent(in ) :: p_psi(:, :)
308 real(real64),
contiguous,
intent(out) :: cct(:, :)
311 integer :: n_int_g, i_mu, i_nu
312 real(real64),
contiguous,
pointer :: p_2(:, :)
316 write(
message(1),
'(a)')
"ISDF: Construct CC^T"
319 if (
present(p_psi))
then
326 assert(all(shape(p_phi) == shape(p_2)))
328 assert(all(shape(p_phi) == shape(cct)))
329 n_int_g =
size(p_phi, 1)
335 cct(i_mu, i_nu) = p_phi(i_mu, i_nu) * p_2(i_mu, i_nu)
352 class(
mesh_t),
intent(in) :: mesh
353 real(real64),
contiguous,
intent(in ) :: isdf_vectors(:, :)
354 real(real64),
contiguous,
intent(out) :: gram_matrix(:, :)
356 integer :: n_int, i, j
360 assert(mesh%np ==
size(isdf_vectors, 1))
361 n_int =
size(isdf_vectors, 2)
362 assert(all(shape(gram_matrix) == [n_int, n_int]))
368 gram_matrix(i, i) =
dmf_dotp(mesh, isdf_vectors(:, i), isdf_vectors(:, i), reduce=.false.)
374 gram_matrix(i, j) =
dmf_dotp(mesh, isdf_vectors(:, i), isdf_vectors(:, j), reduce=.false.)
376 gram_matrix(j, i) = gram_matrix(i, j)
380 call mesh%allreduce(gram_matrix)
387#include "isdf_inc.F90"
There are several ways how to call batch_set_state and batch_get_state:
Matrix-matrix multiplication plus matrix.
pure logical function, public accel_is_enabled()
This module implements batches of mesh functions.
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
This module implements common operations on batches of mesh functions.
type(debug_t), save, public debug
subroutine, public distributed_init(this, total, comm, tag, scalapack_compat)
Distribute N instances across M processes of communicator comm
Interoperable Separable Density Fitting (ISDF) molecular implementation.
subroutine, public isdf_interpolation_vectors(isdf, namespace, mesh, st, centroids, psi_mu, P_r_mu, isdf_vectors)
Top-level routine for computing ISDF vectors.
subroutine, public isdf_ace_compute_potentials(exxop, namespace, space, mesh, st, Vx_on_st, kpoints)
ISDF wrapper computing interpolation points and vectors, which are used to build the potential used ...
subroutine dquasi_density_matrix_at_mesh_centroid_points(st, max_state, psi_mu, p_r_mu)
Compute the quasi-density matrix where one spatial coordinate is defined at grid points and the is de...
subroutine dphi_at_interpolation_points(mesh, st, centroids, max_state, psi_mu)
Construct a 2D array of states, defined only at a specific subset of grid points.
subroutine disdf_ace_apply_exchange_op(exxop, namespace, mesh, st, psi_mu, P_r_mu, isdf_vectors, isdf_dist, Vx_on_st)
Compute the action of the exchange potential on KS states for adaptively-compressed exchange.
subroutine coefficient_product_matrix(p_phi, cct, p_psi)
Construct the coefficient product matrix .
subroutine, public isdf_gram_matrix(mesh, isdf_vectors, gram_matrix)
Compute the Gram matrix for the ISDF interpolation vectors.
subroutine pair_product_coefficient_matrix(p_phi, zct, p_psi)
Construct the matrix-matrix product .
subroutine, public output_matrix(namespace, fname, matrix)
Helper routine to output a 2D matrix.
integer function, public local_number_of_states(st, max_state)
Number of states contributing to the expansion, local to current process.
subroutine, public output_psi_mu_for_all_states(namespace, st, max_state, psi_mu)
Output the gathered psi_mu for all states, such that the matrix is the same irregardless of state par...
This module is intended to contain "only mathematical" functions and procedures.
logical function, public is_symmetric(a, tol)
Check if a 2D array is symmetric.
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_not_implemented(feature, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_grp_t), public mpi_world
pure logical function, public states_are_real(st)
Distribution of N instances over mpi_grpsize processes, for the local rank mpi_grprank....
Describes mesh distribution to nodes.
Coulomb-attenuating method parameters, used in the partitioning of the Coulomb potential into a short...