Octopus
output_berkeleygw.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use cube_oct_m
24 use debug_oct_m
27 use fft_oct_m
30 use global_oct_m
31 use grid_oct_m
33 use io_oct_m
34 use ions_oct_m
38 use mpi_oct_m
41 use parser_oct_m
43 use space_oct_m
50 use v_ks_oct_m
51#if defined(HAVE_BERKELEYGW)
52 use wfn_rho_vxc_io_m
53#endif
54 use xc_cam_oct_m
55 use xc_oct_m
56 use xc_vxc_oct_m
57
58 implicit none
59
60 private
61 public :: &
64
65contains
66
67 ! ---------------------------------------------------------
68 subroutine output_berkeleygw_init(nst, namespace, bgw, periodic_dim)
69 integer, intent(in) :: nst
70 type(namespace_t), intent(in) :: namespace
71 type(output_bgw_t), intent(out) :: bgw
72 integer, intent(in) :: periodic_dim
73
74 integer :: idir
75 real(real64) :: norm
76 type(block_t) :: blk
77
79
80 call messages_experimental("BerkeleyGW output", namespace=namespace)
81
82#ifndef HAVE_BERKELEYGW
83 message(1) = "Cannot do BerkeleyGW output: the library was not linked."
84 call messages_fatal(1, namespace=namespace)
85#endif
86
87 !%Variable BerkeleyGW_NumberBands
88 !%Type integer
89 !%Default all states
90 !%Section Output::BerkeleyGW
91 !%Description
92 !% Wavefunctions for bands up to this number will be output. Must be between <= number of states.
93 !% If < 1, no wavefunction file will be output.
94 !%End
95 call parse_variable(namespace, 'BerkeleyGW_NumberBands', nst, bgw%nbands)
96
97 ! these cannot be checked earlier, since output is initialized before unocc determines nst
98 if (bgw%nbands > nst) then
99 message(1) = "BerkeleyGW_NumberBands must be <= number of states."
100 call messages_fatal(1, only_root_writes = .true., namespace=namespace)
101 end if
102
103 !%Variable BerkeleyGW_Vxc_diag_nmin
104 !%Type integer
105 !%Default 1
106 !%Section Output::BerkeleyGW
107 !%Description
108 !% Lowest band for which to write diagonal exchange-correlation matrix elements. Must be <= number of states.
109 !% If < 1, diagonals will be skipped.
110 !%End
111 call parse_variable(namespace, 'BerkeleyGW_Vxc_diag_nmin', 1, bgw%vxc_diag_nmin)
112
113 if (bgw%vxc_diag_nmin > nst) then
114 message(1) = "BerkeleyGW_Vxc_diag_nmin must be <= number of states."
115 call messages_fatal(1, only_root_writes = .true., namespace=namespace)
116 end if
117
118 !%Variable BerkeleyGW_Vxc_diag_nmax
119 !%Type integer
120 !%Default nst
121 !%Section Output::BerkeleyGW
122 !%Description
123 !% Highest band for which to write diagonal exchange-correlation matrix elements. Must be between <= number of states.
124 !% If < 1, diagonals will be skipped.
125 !%End
126 call parse_variable(namespace, 'BerkeleyGW_Vxc_diag_nmax', nst, bgw%vxc_diag_nmax)
127
128 if (bgw%vxc_diag_nmax > nst) then
129 message(1) = "BerkeleyGW_Vxc_diag_nmax must be <= number of states."
130 call messages_fatal(1, only_root_writes = .true., namespace=namespace)
131 end if
132
133 if (bgw%vxc_diag_nmin <= 0 .or. bgw%vxc_diag_nmax <= 0) then
134 bgw%vxc_diag_nmin = 0
135 bgw%vxc_diag_nmax = 0
136 end if
137
138 !%Variable BerkeleyGW_Vxc_offdiag_nmin
139 !%Type integer
140 !%Default 1
141 !%Section Output::BerkeleyGW
142 !%Description
143 !% Lowest band for which to write off-diagonal exchange-correlation matrix elements. Must be <= number of states.
144 !% If < 1, off-diagonals will be skipped.
145 !%End
146 call parse_variable(namespace, 'BerkeleyGW_Vxc_offdiag_nmin', 1, bgw%vxc_offdiag_nmin)
147
148 if (bgw%vxc_offdiag_nmin > nst) then
149 message(1) = "BerkeleyGW_Vxc_offdiag_nmin must be <= number of states."
150 call messages_fatal(1, only_root_writes = .true., namespace=namespace)
151 end if
152
153 !%Variable BerkeleyGW_Vxc_offdiag_nmax
154 !%Type integer
155 !%Default nst
156 !%Section Output::BerkeleyGW
157 !%Description
158 !% Highest band for which to write off-diagonal exchange-correlation matrix elements. Must be <= number of states.
159 !% If < 1, off-diagonals will be skipped.
160 !%End
161 call parse_variable(namespace, 'BerkeleyGW_Vxc_offdiag_nmax', nst, bgw%vxc_offdiag_nmax)
162
163 if (bgw%vxc_offdiag_nmax > nst) then
164 message(1) = "BerkeleyGW_Vxc_offdiag_nmax must be <= number of states."
165 call messages_fatal(1, only_root_writes = .true., namespace=namespace)
166 end if
167
168 if (bgw%vxc_offdiag_nmin <= 0 .or. bgw%vxc_offdiag_nmax <= 0) then
169 bgw%vxc_offdiag_nmin = 0
170 bgw%vxc_offdiag_nmax = 0
171 end if
172
173 !!%Variable BerkeleyGW_Complex
174 !!%Type logical
175 !!%Default false
176 !!%Section Output::BerkeleyGW
177 !!%Description
178 !!% Even when wavefunctions, density, and XC potential could be real in reciprocal space,
179 !!% they will be output as complex.
180 !!%End
181 !call parse_variable(namespace, 'BerkeleyGW_Complex', .false., bgw%complex)
182
183 bgw%complex = .true.
184 ! real output not implemented, so currently this is always true
185
186 !%Variable BerkeleyGW_WFN_filename
187 !%Type string
188 !%Default WFN
189 !%Section Output::BerkeleyGW
190 !%Description
191 !% Filename for the wavefunctions.
192 !%End
193 call parse_variable(namespace, 'BerkeleyGW_WFN_filename', 'WFN', bgw%wfn_filename)
194
195 !%Variable BerkeleyGW_CalcExchange
196 !%Type logical
197 !%Default false
198 !%Section Output::BerkeleyGW
199 !%Description
200 !% Whether to calculate exchange matrix elements, to be written in <tt>x.dat</tt>.
201 !% These will be calculated anyway by BerkeleyGW <tt>Sigma</tt>, so this is useful
202 !% mainly for comparison and testing.
203 !%End
204 call parse_variable(namespace, 'BerkeleyGW_CalcExchange', .false., bgw%calc_exchange)
205
206 !%Variable BerkeleyGW_CalcDipoleMtxels
207 !%Type logical
208 !%Default false
209 !%Section Output::BerkeleyGW
210 !%Description
211 !% Whether to calculate dipole matrix elements, to be written in <tt>vmtxel</tt>.
212 !% This should be done when calculating <tt>WFN_fi</tt> for Bethe-Salpeter calculations
213 !% with light polarization in a finite direction. In that case, a shifted grid
214 !% <tt>WFNq_fi</tt> cannot be calculated, but we can instead use matrix elements of
215 !% <math>r</math> in a more exact scheme. In <tt>absorption.inp</tt>, set <tt>read_vmtxel</tt>
216 !% and <tt>use_momentum</tt>. Specify the number of conduction and valence bands you will
217 !% use in BSE here with <tt>BerkeleyGW_VmtxelNumCondBands</tt> and <tt>BerkeleyGW_VmtxelNumValBands</tt>.
218 !%End
219 call parse_variable(namespace, 'BerkeleyGW_CalcDipoleMtxels', .false., bgw%calc_vmtxel)
220
221 !%Variable BerkeleyGW_VmtxelPolarization
222 !%Type block
223 !%Default (1, 0, 0)
224 !%Section Output::BerkeleyGW
225 !%Description
226 !% Polarization, <i>i.e.</i> direction vector, for which to calculate <tt>vmtxel</tt>, if you have set
227 !% <tt>BerkeleyGW_CalcDipoleMtxels = yes</tt>. May not have any component in a periodic direction.
228 !% The vector will be normalized.
229 !%End
230
231 bgw%vmtxel_polarization(1:3) = m_zero
232 bgw%vmtxel_polarization(1) = m_one
233
234 if (bgw%calc_vmtxel .and. parse_block(namespace, 'BerkeleyGW_VmtxelPolarization', blk) == 0) then
235 do idir = 1, 3
236 call parse_block_float(blk, 0, idir - 1, bgw%vmtxel_polarization(idir))
237
238 if (idir <= periodic_dim .and. abs(bgw%vmtxel_polarization(idir)) > m_epsilon) then
239 message(1) = "You cannot calculate vmtxel with polarization in a periodic direction. Use WFNq_fi instead."
240 call messages_fatal(1, only_root_writes = .true., namespace=namespace)
241 end if
242 end do
243 call parse_block_end(blk)
244 norm = sum(abs(bgw%vmtxel_polarization(1:3))**2)
245 if (norm < m_epsilon) then
246 message(1) = "A non-zero value must be set for BerkeleyGW_VmtxelPolarization when BerkeleyGW_CalcDipoleMtxels = yes."
247 call messages_fatal(1, namespace=namespace)
248 end if
249 bgw%vmtxel_polarization(1:3) = bgw%vmtxel_polarization(1:3) / sqrt(norm)
250 end if
251
252 !%Variable BerkeleyGW_VmtxelNumCondBands
253 !%Type integer
254 !%Default 0
255 !%Section Output::BerkeleyGW
256 !%Description
257 !% Number of conduction bands for which to calculate <tt>vmtxel</tt>, if you have set
258 !% <tt>BerkeleyGW_CalcDipoleMtxels = yes</tt>. This should be equal to the number to be
259 !% used in BSE.
260 !%End
261 if (bgw%calc_vmtxel) call parse_variable(namespace, 'BerkeleyGW_VmtxelNumCondBands', 0, bgw%vmtxel_ncband)
262 ! The default should be the minimum number of occupied states on any k-point or spin.
263
264 !%Variable BerkeleyGW_VmtxelNumValBands
265 !%Type integer
266 !%Default 0
267 !%Section Output::BerkeleyGW
268 !%Description
269 !% Number of valence bands for which to calculate <tt>vmtxel</tt>, if you have set
270 !% <tt>BerkeleyGW_CalcDipoleMtxels = yes</tt>. This should be equal to the number to be
271 !% used in BSE.
272 !%End
273 if (bgw%calc_vmtxel) call parse_variable(namespace, 'BerkeleyGW_VmtxelNumValBands', 0, bgw%vmtxel_nvband)
274 ! The default should be the minimum number of unoccupied states on any k-point or spin.
275
277 end subroutine output_berkeleygw_init
278
279
280 ! ---------------------------------------------------------
281 subroutine output_berkeleygw(bgw, namespace, space, dir, st, gr, ks, hm, ions)
282 type(output_bgw_t), intent(in) :: bgw
283 type(namespace_t), intent(in) :: namespace
284 class(space_t), intent(in) :: space
285 character(len=*), intent(in) :: dir
286 type(states_elec_t), intent(in) :: st
287 type(grid_t), target, intent(in) :: gr
288 type(v_ks_t), intent(inout) :: ks
289 type(hamiltonian_elec_t), intent(inout) :: hm
290 type(ions_t), intent(in) :: ions
291
292#ifdef HAVE_BERKELEYGW
293 integer :: ik, is, ikk, ist, itran, iunit, iatom, mtrx(3, 3, 48), fftgrid(3), ngkmax
294 integer, pointer :: atyp(:)
295 integer, allocatable :: ifmin(:,:), ifmax(:,:), ngk(:)
296 character(len=3) :: sheader
297 real(real64) :: adot(3,3), bdot(3,3), recvol, tnp(3, 48), ecutrho, ecutwfc
298 real(real64), allocatable :: energies(:,:,:), occupations(:,:,:)
299 real(real64), pointer :: apos(:,:)
300 real(real64), allocatable :: vxc(:,:), dpsi(:,:)
301 complex(real64), allocatable :: field_g(:,:), zpsi(:,:)
302 type(cube_t) :: cube
303 type(cube_function_t) :: cf
304 type(fourier_shell_t) :: shell_density, shell_wfn
305#endif
306
307 push_sub(output_berkeleygw)
308
309 if (space%dim /= 3) then
310 message(1) = "BerkeleyGW output only available in 3D."
311 call messages_fatal(1, namespace=namespace)
312 end if
313
314 if (st%d%ispin == spinors) call messages_not_implemented("BerkeleyGW output for spinors", namespace=namespace)
315
316 if (st%parallel_in_states) call messages_not_implemented("BerkeleyGW output parallel in states", namespace=namespace)
317
318 if (st%d%kpt%parallel) call messages_not_implemented("BerkeleyGW output parallel in k-points", namespace=namespace)
319
320 if (ks%theory_level == hartree .or. ks%theory_level == hartree_fock .or. xc_is_orbital_dependent(ks%xc)) then
321 call messages_not_implemented("BerkeleyGW output with orbital-dependent functionals", namespace=namespace)
322 end if
323
324 if (hm%ep%nlcc) call messages_not_implemented("BerkeleyGW output with NLCC", namespace=namespace)
325
326#ifdef HAVE_BERKELEYGW
327
328 safe_allocate(vxc(1:gr%np, 1:st%d%nspin))
329 vxc(:,:) = m_zero
330 ! we should not include core rho here. that is why we do not just use hm%vxc
331 call xc_get_vxc(gr, ks%xc, st, hm%kpoints, hm%psolver, namespace, space, st%rho, st%d%ispin, &
332 hm%ions%latt%rcell_volume, vxc)
333
334 message(1) = "BerkeleyGW output: vxc.dat"
335 if (bgw%calc_exchange) message(1) = trim(message(1)) // ", x.dat"
336 call messages_info(1, namespace=namespace)
337
338 if (states_are_real(st)) then
339 call dbgw_vxc_dat(bgw, namespace, space, dir, st, gr, hm, vxc)
340 else
341 call zbgw_vxc_dat(bgw, namespace, space, dir, st, gr, hm, vxc)
342 end if
343
344 call cube_init(cube, gr%idx%ll, namespace, space, gr%spacing, gr%coord_system, &
345 fft_type = fft_complex, dont_optimize = .true., nn_out = fftgrid)
346 call cube_init_cube_map(cube, gr)
347 if (any(gr%idx%ll(1:3) /= fftgrid(1:3))) then ! paranoia check
348 message(1) = "Cannot do BerkeleyGW output: FFT grid has been modified."
349 call messages_fatal(1, namespace=namespace)
350 end if
351 call zcube_function_alloc_rs(cube, cf)
352 call cube_function_alloc_fs(cube, cf)
353
354 ! NOTE: in BerkeleyGW, no G-vector may have coordinate equal to the half the FFT grid size.
355 call fourier_shell_init(shell_density, namespace, space, cube, gr)
356 ecutrho = shell_density%ekin_cutoff
357 safe_allocate(field_g(1:shell_density%ngvectors, 1:st%d%nspin))
358
359 call bgw_setup_header()
360
361
362 if (bgw%calc_vmtxel) then
363 write(message(1),'(a,3f12.6)') "BerkeleyGW output: vmtxel. Polarization = ", bgw%vmtxel_polarization(1:3)
364 call messages_info(1, namespace=namespace)
365
366 if (states_are_real(st)) then
367 call dbgw_vmtxel(bgw, namespace, dir, st, gr, ifmax)
368 else
369 call zbgw_vmtxel(bgw, namespace, dir, st, gr, ifmax)
370 end if
371 end if
372
373 message(1) = "BerkeleyGW output: VXC"
374 call messages_info(1, namespace=namespace)
375
376 sheader = 'VXC'
377 if (st%system_grp%is_root()) then
378 iunit = io_open(trim(dir) // 'VXC', namespace, form = 'unformatted', action = 'write')
379 call bgw_write_header(sheader, iunit)
380 end if
381 ! convert from Ha to Ry, make usable with same processing as RHO
382 vxc(:,:) = vxc(:,:) * m_two / (product(cube%rs_n_global(1:3)) * gr%volume_element)
383 call dbgw_write_fs(namespace, iunit, vxc, field_g, shell_density, st%d%nspin, gr, cube, cf, is_wfn = .false., &
384 is_root=st%system_grp%is_root())
385 if (st%system_grp%is_root()) call io_close(iunit)
386 safe_deallocate_a(vxc)
387
388
389 message(1) = "BerkeleyGW output: RHO"
390 call messages_info(1, namespace=namespace)
391
392 sheader = 'RHO'
393 if (st%system_grp%is_root()) then
394 iunit = io_open(trim(dir) // 'RHO', namespace, form = 'unformatted', action = 'write')
395 call bgw_write_header(sheader, iunit)
396 end if
397 call dbgw_write_fs(namespace, iunit, st%rho, field_g, shell_density, st%d%nspin, gr, cube, cf, is_wfn = .false., &
398 is_root=st%system_grp%is_root())
399 if (st%system_grp%is_root()) call io_close(iunit)
400
401 message(1) = "BerkeleyGW output: WFN"
402 write(message(2),'(a,f12.6,a)') "Wavefunction cutoff for BerkeleyGW: ", &
403 fourier_shell_cutoff(space, cube, gr, .true.) * m_two, " Ry"
404 call messages_info(2, namespace=namespace)
405
406 if (states_are_real(st)) then
407 safe_allocate(dpsi(1:gr%np, 1:st%d%nspin))
408 else
409 safe_allocate(zpsi(1:gr%np, 1:st%d%nspin))
410 end if
411
412 sheader = 'WFN'
413 if (st%system_grp%is_root()) then
414 iunit = io_open(trim(dir) // bgw%wfn_filename, namespace, form = 'unformatted', action = 'write')
415 call bgw_write_header(sheader, iunit)
416 end if
417
418 call fourier_shell_end(shell_density)
419
420 ! FIXME: is parallelization over k-points possible?
421 do ik = st%d%kpt%start, st%d%kpt%end, st%d%nspin
422 call fourier_shell_init(shell_wfn, namespace, space, cube, gr, kk = hm%kpoints%reduced%red_point(:, ik))
423
424 if (st%system_grp%is_root()) then
425 call write_binary_gvectors(iunit, shell_wfn%ngvectors, shell_wfn%ngvectors, shell_wfn%red_gvec)
426 end if
427 do ist = 1, st%nst
428 do is = 1, st%d%nspin
429 ikk = ik + is - 1
430 if (states_are_real(st)) then
431 call states_elec_get_state(st, gr, 1, ist, ikk, dpsi(:, is))
432 else
433 call states_elec_get_state(st, gr, 1, ist, ikk, zpsi(:, is))
434 end if
435 end do
436 if (states_are_real(st)) then
437 call dbgw_write_fs(namespace, iunit, dpsi, field_g, shell_wfn, st%d%nspin, gr, cube, cf, is_wfn = .true., &
438 is_root=st%system_grp%is_root())
439 else
440 call zbgw_write_fs(namespace, iunit, zpsi, field_g, shell_wfn, st%d%nspin, gr, cube, cf, is_wfn = .true., &
441 is_root=st%system_grp%is_root())
442 end if
443 end do
444 call fourier_shell_end(shell_wfn)
445 end do
446
447 if (st%system_grp%is_root()) call io_close(iunit)
448
449 ! deallocate everything
450 call cube_function_free_fs(cube, cf)
451 call zcube_function_free_rs(cube, cf)
452 call cube_end(cube)
453
454 if (states_are_real(st)) then
455 safe_deallocate_a(dpsi)
456 else
457 safe_deallocate_a(zpsi)
458 end if
459 safe_deallocate_a(vxc)
460 safe_deallocate_a(field_g)
461 safe_deallocate_a(ifmin)
462 safe_deallocate_a(ifmax)
463 safe_deallocate_a(ngk)
464 safe_deallocate_a(energies)
465 safe_deallocate_a(occupations)
466 safe_deallocate_p(atyp)
467 safe_deallocate_p(apos)
468
469#else
470 message(1) = "Cannot do BerkeleyGW output: the library was not linked."
471 call messages_fatal(1, namespace=namespace)
472#endif
473
474 pop_sub(output_berkeleygw)
475
476#ifdef HAVE_BERKELEYGW
477 contains
478
479 subroutine bgw_setup_header()
480 push_sub(output_berkeleygw.bgw_setup_header)
481
482 if (space%periodic_dim /= 0 .and. space%periodic_dim /= 3) then
483 message(1) = "BerkeleyGW for mixed-periodicity is currently not implemented."
484 call messages_fatal(1, namespace=namespace)
485 end if
486
487 ! The rlattice, klattice and rcell_volume used here are not correct for
488 ! mixid periodicity. Note also that the BerkeleyGW treats the z direction
489 ! as periodic for wires, while in Octopus it is the x direction that is
490 ! periodic.
491 adot(1:3, 1:3) = matmul(ions%latt%rlattice(1:3, 1:3), ions%latt%rlattice(1:3, 1:3))
492 bdot(1:3, 1:3) = matmul(ions%latt%klattice(1:3, 1:3), ions%latt%klattice(1:3, 1:3))
493 recvol = (m_two * m_pi)**3 / ions%latt%rcell_volume
494
495 ! symmetry is not analyzed by Octopus for finite systems, but we only need it for periodic ones
496 do itran = 1, symmetries_number(gr%symm)
497 mtrx(:,:, itran) = symm_op_rotation_matrix_red(gr%symm%ops(itran))
498 tnp(:, itran) = symm_op_translation_vector_red(gr%symm%ops(itran))
499 end do
500 ! some further work on conventions of mtrx and tnp is required!
501
502 safe_allocate(ifmin(1:hm%kpoints%reduced%npoints, 1:st%d%nspin))
503 safe_allocate(ifmax(1:hm%kpoints%reduced%npoints, 1:st%d%nspin))
504 safe_allocate(energies(1:st%nst, 1:hm%kpoints%reduced%npoints, 1:st%d%nspin))
505 safe_allocate(occupations(1:st%nst, 1:hm%kpoints%reduced%npoints, 1:st%d%nspin))
506
507 ifmin(:,:) = 1
508! This is how semiconducting smearing "should" work, but not in our implementation.
509! if (smear_is_semiconducting(st%smear)) then
510! ifmax(:,:) = nint(st%qtot / st%smear%el_per_state)
511! end if
512 do ik = 1, st%nik
513 is = st%d%get_spin_index(ik)
514 ikk = st%d%get_kpoint_index(ik)
515 energies(1:st%nst, ikk, is) = st%eigenval(1:st%nst,ik) * m_two
516 occupations(1:st%nst, ikk, is) = st%occ(1:st%nst, ik) / st%smear%el_per_state
517 do ist = 1, st%nst
518 ! M_EPSILON needed since e_fermi is top of valence band for fixed_occ and semiconducting smearing
519 if (st%eigenval(ist, ik) < st%smear%e_fermi + m_epsilon) then
520 ifmax(ikk, is) = ist
521 else
522 exit
523 end if
524 end do
525 end do
526
527 safe_allocate(ngk(1:hm%kpoints%reduced%npoints))
528 do ik = 1, st%nik, st%d%nspin
529 call fourier_shell_init(shell_wfn, namespace, space, cube, gr, kk = hm%kpoints%reduced%red_point(:, ik))
530 if (ik == 1) ecutwfc = shell_wfn%ekin_cutoff ! should be the same for all, anyway
531 ngk(ik) = shell_wfn%ngvectors
532 call fourier_shell_end(shell_wfn)
533 end do
534 ngkmax = maxval(ngk)
535
536 safe_allocate(atyp(1:ions%natoms))
537 safe_allocate(apos(1:3, 1:ions%natoms))
538 do iatom = 1, ions%natoms
539 atyp(iatom) = ions%atom(iatom)%species%get_index()
540 apos(1:3, iatom) = ions%pos(1:3, iatom)
541 end do
542
543 if (any(hm%kpoints%nik_axis(1:3) == 0)) then
544 message(1) = "KPointsGrid has a zero component. Set KPointsGrid appropriately,"
545 message(2) = "or this WFN will only be usable in BerkeleyGW's inteqp."
546 call messages_warning(1, namespace=namespace)
547 end if
548
549 pop_sub(output_berkeleygw.bgw_setup_header)
550 end subroutine bgw_setup_header
551
552 ! ---------------------------------------------------------
553 subroutine bgw_write_header(sheader, iunit)
554 character(len=3), intent(inout) :: sheader
555 integer, intent(in) :: iunit
556
557 push_sub(output_berkeleygw.bgw_write_header)
558
559 call write_binary_header(iunit, sheader, 2, st%d%nspin, shell_density%ngvectors, &
560 symmetries_number(gr%symm), 0, ions%natoms, &
561 hm%kpoints%reduced%npoints, st%nst, ngkmax, ecutrho * m_two, &
562 ecutwfc * m_two, fftgrid, hm%kpoints%nik_axis, hm%kpoints%full%shifts, &
563 ions%latt%rcell_volume, m_one, ions%latt%rlattice, adot, recvol, &
564 m_one, ions%latt%klattice, bdot, mtrx, tnp, atyp, &
565 apos, ngk, hm%kpoints%reduced%weight, hm%kpoints%reduced%red_point, &
566 ifmin, ifmax, energies, occupations, warn = .false.)
567
568 call write_binary_gvectors(iunit, shell_density%ngvectors, shell_density%ngvectors, shell_density%red_gvec)
569
570 pop_sub(output_berkeleygw.bgw_write_header)
571 end subroutine bgw_write_header
572
573#endif
574
575 end subroutine output_berkeleygw
576
577#include "undef.F90"
578#include "complex.F90"
579#ifdef HAVE_BERKELEYGW
580#include "output_berkeleygw_inc.F90"
581#endif
582
583#include "undef.F90"
584#include "real.F90"
585#ifdef HAVE_BERKELEYGW
586#include "output_berkeleygw_inc.F90"
587#endif
588
590
591!! Local Variables:
592!! mode: f90
593!! coding: utf-8
594!! End:
double sqrt(double __x) __attribute__((__nothrow__
subroutine, public zcube_function_free_rs(cube, cf)
Deallocates the real space grid.
subroutine, public zcube_function_alloc_rs(cube, cf, in_device, force_alloc)
Allocates locally the real space grid, if PFFT library is not used. Otherwise, it assigns the PFFT re...
subroutine, public cube_init(cube, nn, namespace, space, spacing, coord_system, fft_type, fft_library, dont_optimize, nn_out, mpi_grp, need_partition, tp_enlarge, blocksize)
Definition: cube.F90:204
subroutine, public cube_end(cube)
Definition: cube.F90:387
subroutine, public cube_init_cube_map(cube, mesh)
Definition: cube.F90:824
integer, parameter, public spinors
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
Definition: fft.F90:120
integer, parameter, public fft_complex
Definition: fft.F90:174
real(real64) function, public fourier_shell_cutoff(space, cube, mesh, is_wfn, dg)
subroutine, public fourier_shell_init(this, namespace, space, cube, mesh, kk)
subroutine, public fourier_shell_end(this)
subroutine, public cube_function_free_fs(cube, cf)
Deallocates the Fourier space grid.
subroutine, public cube_function_alloc_fs(cube, cf, force_alloc)
Allocates locally the Fourier space grid, if PFFT library is not used. Otherwise, it assigns the PFFT...
real(real64), parameter, public m_two
Definition: global.F90:193
real(real64), parameter, public m_zero
Definition: global.F90:191
real(real64), parameter, public m_pi
some mathematical constants
Definition: global.F90:189
integer, parameter, public hartree_fock
Definition: global.F90:241
real(real64), parameter, public m_epsilon
Definition: global.F90:207
real(real64), parameter, public m_one
Definition: global.F90:192
integer, parameter, public hartree
Definition: global.F90:241
This module implements the underlying real-space grid.
Definition: grid.F90:119
Definition: io.F90:116
subroutine, public io_close(iunit, grp)
Definition: io.F90:467
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:402
A module to handle KS potential, without the external potential.
This module defines various routines, operating on mesh functions.
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1067
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:524
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:161
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:409
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1039
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:593
subroutine, public output_berkeleygw(bgw, namespace, space, dir, st, gr, ks, hm, ions)
subroutine, public output_berkeleygw_init(nst, namespace, bgw, periodic_dim)
this module contains the low-level part of the output system
Definition: output_low.F90:117
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:615
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
real(real64) function, dimension(1:this%dim), public symm_op_translation_vector_red(this)
Definition: symm_op.F90:326
integer function, dimension(1:this%dim, 1:this%dim), public symm_op_rotation_matrix_red(this)
Definition: symm_op.F90:305
integer pure function, public symmetries_number(this)
Definition: symmetries.F90:553
Definition: xc.F90:116
logical pure function, public xc_is_orbital_dependent(xcs)
Is the xc family orbital dependent.
Definition: xc.F90:542
subroutine, public xc_get_vxc(gr, xcs, st, kpoints, psolver, namespace, space, rho, ispin, rcell_volume, vxc, ex, ec, deltaxc, vtau, ex_density, ec_density, stress_xc, force_orbitalfree)
Definition: xc_vxc.F90:185
Description of the grid, containing information on derivatives, stencil, and symmetries.
Definition: grid.F90:171
Output information for BerkeleyGW.
Definition: output_low.F90:147
The states_elec_t class contains all electronic wave functions.
int true(void)