21 use,
intrinsic :: iso_fortran_env, only: real64, int64
47 integer,
private,
parameter :: ik = 1
53 type(namespace_t),
intent(in) :: namespace
54 character(len=*),
intent(in) :: fname
55 real(real64),
contiguous,
intent(in) :: matrix(:, :)
61 write(
message(1),
'(a)')
"ISDF. Outputting: " // trim(adjustl(fname))
66 open(newunit=unit, file=trim(adjustl(fname)))
67 do j = 1,
size(matrix, 2)
68 do i = 1,
size(matrix, 1)
69 write(unit, *) matrix(i, j)
86 subroutine isdf_potential(namespace, poisson_solver, isdf_vectors, V_r_nu)
87 type(namespace_t),
intent(in ) :: namespace
88 type(poisson_t),
intent(in ) :: poisson_solver
89 real(real64),
intent(in ),
contiguous :: isdf_vectors(:, :)
91 real(real64),
intent(out),
contiguous :: V_r_nu(:, :)
98 do i_nu = 1,
size(v_r_nu, 2)
99 call dpoisson_solve(poisson_solver, namespace, v_r_nu(:, i_nu), isdf_vectors(:, i_nu), all_nodes=.false.)
113 type(states_elec_t),
intent(in) :: st
114 integer,
intent(in) :: max_state
116 integer :: minst, maxst
137 type(states_elec_t),
intent(in ) :: st
138 real(real64),
contiguous,
intent(in ) :: psi_mu(:, :)
139 real(real64),
contiguous,
intent(out) :: psi_global(:, :)
141 integer :: max_state, n_int_g, ic, ist, st_end, ist_local
145 if (st%group%psib(st%group%block_start, ik)%status() /=
batch_packed)
then
146 message(1) =
"Developer Error: Trying to output psi_mu when not BATCH_PACKED"
151 n_int_g =
size(psi_global, 2)
152 assert(
size(psi_mu, 2) ==
size(psi_global, 2))
155 max_state =
size(psi_global, 1)
160 do ist = 1, max_state
161 psi_global(ist, ic) = 0.0_real64
167 st_end = min(st%st_end, max_state)
170 if (
size(psi_mu, 1) > 0)
then
171 assert(st_end - st%st_start + 1 ==
size(psi_mu, 1))
176 do ist = st%st_start, st_end
177 ist_local = ist - st%st_start + 1
178 psi_global(ist, ic) = psi_mu(ist_local, ic)
194 integer,
intent(in) :: max_state
195 real(real64),
contiguous,
intent(in) :: psi_mu(:, :)
197 real(real64),
allocatable :: psi_global(:, :)
198 integer :: n_int_g, ic, ist, unit
199 character(len=2) :: np_char
203 if (st%group%psib(st%group%block_start, ik)%status() /=
batch_packed)
then
204 message(1) =
"Trying to output psi_mu when not BATCH_PACKED"
208 write(
message(1),
'(a)')
"ISDF: Writing psi_mu (all states/DD)"
211 n_int_g =
size(psi_mu, 2)
212 safe_allocate(psi_global(1:max_state, 1:n_int_g))
216 write(np_char,
'(I2)') st%mpi_grp%size
217 unit =
io_open(
"global_psi_mu_np"//trim(adjustl(np_char))//
".txt", namespace, action=
'write')
220 do ist = 1, max_state
221 write(unit, *) psi_global(ist, ic)
227 safe_deallocate_a(psi_global)
This module implements batches of mesh functions.
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
subroutine, public io_close(iunit, grp)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public output_matrix(namespace, fname, matrix)
Helper routine to output a 2D matrix.
subroutine, public isdf_potential(namespace, poisson_solver, isdf_vectors, V_r_nu)
Compute the effective potential in the ISDF vector basis.
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...
subroutine, public gather_psi_mu_over_states(st, psi_mu, psi_global)
Gather state-distributed psi from multiple processes.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_grp_t), public mpi_world
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel, reset)
Calculates the Poisson equation. Given the density returns the corresponding potential.
integer pure function, public states_elec_block_max(st, ib)
return index of last state in block ib
integer pure function, public states_elec_block_min(st, ib)
return index of first state in block ib
The states_elec_t class contains all electronic wave functions.