Octopus
ks_potential.F90
Go to the documentation of this file.
1!! Copyright (C) 2024 N. Tancogne-Dejean
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
27 use accel_oct_m
28 use atom_oct_m
29 use debug_oct_m
30 use global_oct_m
33 use, intrinsic :: iso_fortran_env
35 use math_oct_m
36 use mesh_oct_m
39 use mpi_oct_m
40 use mix_oct_m
46 use space_oct_m
48 use types_oct_m
49 use unit_oct_m
52
53 implicit none
54
55 private
56 public :: &
63
64 integer, public, parameter :: &
65 INDEPENDENT_PARTICLES = 2, &
66 hartree = 1, &
67 hartree_fock = 3, &
68 kohn_sham_dft = 4, &
70 rdmft = 7
71
72
74 private
75 integer :: np, nspin
76 integer :: theory_level = independent_particles
77 logical :: needs_vtau = .false.
78
79 real(real64), public, allocatable :: vhartree(:)
80 real(real64), public, allocatable :: vxc(:,:)
81 real(real64), public, allocatable :: vhxc(:,:)
82 ! !! other contributions: photon xc potential, constrained DFT, ...
83 ! !! Check v_ks_calc for more details
84 real(real64), allocatable :: vtau(:,:)
85
86 type(accel_mem_t) :: vtau_accel
87
88 contains
89 procedure :: init => ks_potential_init
90 procedure :: end => ks_potential_end
91 procedure :: set_vtau => ks_potential_set_vtau
92 procedure :: add_vhxc => ks_potential_add_vhxc
93 procedure :: dmult_vhxc => dks_potential_mult_vhxc
94 procedure :: zmult_vhxc => zks_potential_mult_vhxc
95 procedure :: load => ks_potential_load_vhxc
96 procedure :: dump => ks_potential_dump_vhxc
97 procedure :: init_interpolation => ks_potential_init_interpolation
98 procedure :: run_zero_iter => ks_potential_run_zero_iter
99 procedure :: interpolation_new => ks_potential_interpolation_new
100 procedure :: get_interpolated_potentials => ks_potential_get_interpolated_potentials
101 procedure :: set_interpolated_potentials => ks_potential_set_interpolated_potentials
102 procedure :: interpolate_potentials => ks_potential_interpolate_potentials
103 procedure :: dapply_vtau_psi => dks_potential_apply_vtau_psi
104 procedure :: zapply_vtau_psi => zks_potential_apply_vtau_psi
105 procedure :: dcurrent_mass_renormalization => dks_potential_current_mass_renormalization
106 procedure :: zcurrent_mass_renormalization => zks_potential_current_mass_renormalization
107 procedure :: output_potentials => ks_potential_output_potentials
108 procedure :: store_potentials => ks_potential_store_copy
109 procedure :: restore_potentials => ks_potential_restore_copy
110 procedure :: check_convergence => ks_potential_check_convergence
111 procedure :: perform_interpolation => ks_potential_perform_interpolation
112 procedure :: mix_potentials => ks_potential_mix_potentials
113 end type ks_potential_t
114
115 ! We sometimes need to store a copy of the potentials, say for interpolation
116 ! This is used to store the corresponding data, still keeping them private
118 private
119 real(real64), public, allocatable :: vhxc(:,:)
120 real(real64), allocatable :: vtau(:,:)
121 contains
122 procedure :: copy_vhxc_to_buffer => xc_copied_potentials_copy_vhxc_to_buffer
125
126contains
127
129 subroutine ks_potential_init(this, np, np_part, nspin, theory_level, needs_vtau)
130 class(ks_potential_t), intent(inout) :: this
131 integer, intent(in) :: np, np_part
132 integer, intent(in) :: nspin
133 integer, intent(in) :: theory_level
134 logical, intent(in) :: needs_vtau
135
136 push_sub(ks_potential_init)
137
138 this%theory_level = theory_level
139 this%needs_vtau = needs_vtau
140 this%np = np
141 this%nspin = nspin
142
143 ! In the case of spinors, vxc_11 = hm%vxc(:, 1), vxc_22 = hm%vxc(:, 2), Re(vxc_12) = hm%vxc(:. 3);
144 ! Im(vxc_12) = hm%vxc(:, 4)
145 safe_allocate(this%vhxc(1:np, 1:nspin))
146 this%vhxc(1:np, 1:nspin) = m_zero
147
148 if (theory_level /= independent_particles) then
149
150 safe_allocate(this%vhartree(1:np_part))
151 this%vhartree=m_zero
152
153 safe_allocate(this%vxc(1:np, 1:nspin))
154 this%vxc=m_zero
155
156 if (needs_vtau) then
157 safe_allocate(this%vtau(1:np, 1:nspin))
158 this%vtau=m_zero
159 if (accel_is_enabled()) then
161 end if
162
163 end if
164 end if
165
167 end subroutine ks_potential_init
170 subroutine ks_potential_end(this)
171 class(ks_potential_t), intent(inout) :: this
175 safe_deallocate_a(this%vhxc)
176 safe_deallocate_a(this%vhartree)
177 safe_deallocate_a(this%vxc)
178 safe_deallocate_a(this%vtau)
180 if (this%needs_vtau .and. accel_is_enabled()) then
181 call accel_release_buffer(this%vtau_accel)
182 end if
185 end subroutine ks_potential_end
188 subroutine ks_potential_set_vtau(this, vtau)
189 class(ks_potential_t), intent(inout) :: this
190 real(real64), intent(in) :: vtau(:,:)
194 assert(this%needs_vtau)
196 call lalg_copy(this%np, this%nspin, vtau, this%vtau)
205 class(ks_potential_t), intent(inout) :: this
206
207 integer :: offset, ispin
208
211 assert(this%needs_vtau)
214 offset = 0
215 do ispin = 1, this%nspin
216 call accel_write_buffer(this%vtau_accel, this%np, this%vtau(:, ispin), offset = offset)
217 offset = offset + accel_padded_size(this%np)
218 end do
219 end if
220
223
225 subroutine ks_potential_add_vhxc(this, pot, nspin)
226 class(ks_potential_t), intent(in) :: this
227 real(real64), intent(inout) :: pot(:,:)
228 integer, optional, intent(in) :: nspin
229
230 integer :: ispin, ip, nspin_
231
232 push_sub(ks_potential_add_vhxc)
233
234 assert(not_in_openmp())
235 nspin_ = optional_default(nspin, this%nspin)
236 assert(size(pot, dim=1) >= this%np)
237 assert(size(pot, dim=2) >= nspin_)
238
239 !TODO: We could skip this for IPA, and also use axpy here
240
241 !$omp parallel private(ip, ispin)
242 do ispin = 1, nspin_
243 !$omp do simd schedule(static)
244 do ip = 1, this%np
245 pot(ip, ispin) = pot(ip, ispin) + this%vhxc(ip, ispin)
246 end do
247 !$omp end do simd nowait
248 end do
249 !$omp end parallel
250
251 pop_sub(ks_potential_add_vhxc)
252 end subroutine ks_potential_add_vhxc
253
254 ! -----------------------------------------------------------------
256 subroutine ks_potential_dump_vhxc(this, restart, space, mesh, ierr)
257 class(ks_potential_t), intent(in) :: this
258 type(restart_t), intent(in) :: restart
259 class(space_t), intent(in) :: space
260 class(mesh_t), intent(in) :: mesh
261 integer, intent(out) :: ierr
262
263 integer :: iunit, err, err2(2), isp
264 character(len=MAX_PATH_LEN) :: filename
265 character(len=100) :: lines(2)
266
267 push_sub(ks_potential_dump_vhxc)
268
269 ierr = 0
270
271 if (restart_skip(restart) .or. this%theory_level == independent_particles) then
273 return
274 end if
275
276 if (debug%info) then
277 message(1) = "Debug: Writing Vhxc restart."
278 call messages_info(1)
279 end if
280
281 !write the different components of the Hartree+XC potential
282 iunit = restart_open(restart, 'vhxc')
283 lines(1) = '# #spin #nspin filename'
284 lines(2) = '%vhxc'
285 call restart_write(restart, iunit, lines, 2, err)
286 if (err /= 0) ierr = ierr + 1
287
288 err2 = 0
289 do isp = 1, this%nspin
290 filename = get_filename_with_spin('vhxc', this%nspin, isp)
291 write(lines(1), '(i8,a,i8,a)') isp, ' | ', this%nspin, ' | "'//trim(adjustl(filename))//'"'
292 call restart_write(restart, iunit, lines, 1, err)
293 if (err /= 0) err2(1) = err2(1) + 1
294
295 call restart_write_mesh_function(restart, space, filename, mesh, this%vhxc(:,isp), err)
296 if (err /= 0) err2(2) = err2(2) + 1
298 end do
299 if (err2(1) /= 0) ierr = ierr + 2
300 if (err2(2) /= 0) ierr = ierr + 4
301
302 lines(1) = '%'
303 call restart_write(restart, iunit, lines, 1, err)
304 if (err /= 0) ierr = ierr + 4
305
306 ! MGGAs and hybrid MGGAs have an extra term that also needs to be dumped
307 if (this%needs_vtau) then
308 lines(1) = '# #spin #nspin filename'
309 lines(2) = '%vtau'
310 call restart_write(restart, iunit, lines, 2, err)
311 if (err /= 0) ierr = ierr + 8
312
313 err2 = 0
314 do isp = 1, this%nspin
315 filename = get_filename_with_spin('vtau', this%nspin, isp)
316 write(lines(1), '(i8,a,i8,a)') isp, ' | ', this%nspin, ' | "'//trim(adjustl(filename))//'"'
317 call restart_write(restart, iunit, lines, 1, err)
318 if (err /= 0) err2(1) = err2(1) + 16
319
320 call restart_write_mesh_function(restart, space, filename, mesh, this%vtau(:,isp), err)
321 if (err /= 0) err2(1) = err2(1) + 1
322
323 end do
324 if (err2(1) /= 0) ierr = ierr + 32
325 if (err2(2) /= 0) ierr = ierr + 64
326
327 lines(1) = '%'
328 call restart_write(restart, iunit, lines, 1, err)
329 if (err /= 0) ierr = ierr + 128
330 end if
331
332 call restart_close(restart, iunit)
333
334 if (debug%info) then
335 message(1) = "Debug: Writing Vhxc restart done."
336 call messages_info(1)
337 end if
338
340 end subroutine ks_potential_dump_vhxc
341
342
343 ! ---------------------------------------------------------
345 subroutine ks_potential_load_vhxc(this, restart, space, mesh, ierr)
346 class(ks_potential_t), intent(inout) :: this
347 type(restart_t), intent(in) :: restart
348 class(space_t), intent(in) :: space
349 class(mesh_t), intent(in) :: mesh
350 integer, intent(out) :: ierr
351
352 integer :: err, err2, isp
353 character(len=MAX_PATH_LEN) :: filename
354
355 push_sub(ks_potential_load_vhxc)
356
357 ierr = 0
358
359 if (restart_skip(restart) .or. this%theory_level == independent_particles) then
360 ierr = -1
362 return
363 end if
364
365 if (debug%info) then
366 message(1) = "Debug: Reading Vhxc restart."
367 call messages_info(1)
368 end if
369
370 err2 = 0
371 do isp = 1, this%nspin
372 filename = get_filename_with_spin('vhxc', this%nspin, isp)
373
374 call restart_read_mesh_function(restart, space, filename, mesh, this%vhxc(:,isp), err)
375 if (err /= 0) err2 = err2 + 1
376
377 end do
378 if (err2 /= 0) ierr = ierr + 1
379
380 ! MGGAs and hybrid MGGAs have an extra term that also needs to be read
381 err2 = 0
382 if (this%needs_vtau) then
383 do isp = 1, this%nspin
384 filename = get_filename_with_spin('vtau', this%nspin, isp)
385
386 call restart_read_mesh_function(restart, space, filename, mesh, this%vtau(:,isp), err)
387 if (err /= 0) err2 = err2 + 1
388
389 end do
390
391 if (err2 /= 0) ierr = ierr + 2
392 end if
393
394 if (debug%info) then
395 message(1) = "Debug: Reading Vhxc restart done."
396 call messages_info(1)
397 end if
398
400 end subroutine ks_potential_load_vhxc
401
403 subroutine ks_potential_init_interpolation(this, vksold, order)
404 class(ks_potential_t), intent(in) :: this
405 type(potential_interpolation_t), intent(inout) :: vksold
406 integer, optional, intent(in) :: order
407
409
410 call potential_interpolation_init(vksold, this%np, this%nspin, this%needs_vtau, order=order)
411
414
416 subroutine ks_potential_run_zero_iter(this, vksold)
417 class(ks_potential_t), intent(in) :: this
418 type(potential_interpolation_t), intent(inout) :: vksold
419
421
422 call potential_interpolation_run_zero_iter(vksold, this%np, this%nspin, this%vhxc, vtau=this%vtau)
423
425 end subroutine ks_potential_run_zero_iter
426
428 subroutine ks_potential_interpolation_new(this, vksold, current_time, dt)
429 class(ks_potential_t), intent(inout) :: this
430 type(potential_interpolation_t), intent(inout) :: vksold
431 real(real64), intent(in) :: current_time
432 real(real64), intent(in) :: dt
433
435
436 call potential_interpolation_new(vksold, this%np, this%nspin, current_time, dt, this%vhxc, vtau=this%vtau)
437
439 end subroutine ks_potential_interpolation_new
440
444 subroutine ks_potential_get_interpolated_potentials(this, vksold, history, storage)
445 class(ks_potential_t), intent(inout) :: this
446 type(potential_interpolation_t), intent(inout) :: vksold
447 integer, intent(in) :: history
448 type(xc_copied_potentials_t), optional, intent(inout) :: storage
449
450 if (this%theory_level == independent_particles) return
451
453
454 if (.not. present(storage)) then
455 if (this%needs_vtau) then
456 call potential_interpolation_get(vksold, this%np, this%nspin, history, this%vhxc, vtau = this%vtau)
458 else
459 call potential_interpolation_get(vksold, this%np, this%nspin, history, this%vhxc)
460 end if
461 else
462 call ks_potential_storage_allocate(this, storage)
463 if (this%needs_vtau) then
464 call potential_interpolation_get(vksold, this%np, this%nspin, history, storage%vhxc, vtau = storage%vtau)
465 else
466 call potential_interpolation_get(vksold, this%np, this%nspin, history, storage%vhxc)
467 end if
468 end if
469
472
474 subroutine ks_potential_set_interpolated_potentials(this, vksold, history)
475 class(ks_potential_t), intent(inout) :: this
476 type(potential_interpolation_t), intent(inout) :: vksold
477 integer, intent(in) :: history
478
479 if (this%theory_level == independent_particles) return
480
482
483 if (this%needs_vtau) then
484 call potential_interpolation_set(vksold, this%np, this%nspin, history, this%vhxc, vtau = this%vtau)
485 else
486 call potential_interpolation_set(vksold, this%np, this%nspin, history, this%vhxc)
487 end if
488
491
492
494 subroutine ks_potential_interpolate_potentials(this, vksold, order, current_time, dt, interpolation_time)
495 class(ks_potential_t), intent(inout) :: this
496 type(potential_interpolation_t), intent(inout) :: vksold
497 integer, intent(in) :: order
498 real(real64), intent(in) :: current_time
499 real(real64), intent(in) :: dt
500 real(real64), intent(in) :: interpolation_time
501
502 if (this%theory_level == independent_particles) return
503
505
506 if (this%needs_vtau) then
507 call potential_interpolation_interpolate(vksold, order, current_time, dt, interpolation_time, &
508 this%vhxc, vtau = this%vtau)
510 else
511 call potential_interpolation_interpolate(vksold, order, current_time, dt, interpolation_time, &
512 this%vhxc)
513 end if
514
517
518 ! ---------------------------------------------------------
519 subroutine vtau_set_vout(field, this)
520 type(mixfield_t), intent(inout) :: field
521 type(ks_potential_t), intent(in) :: this
522
523 push_sub(vtau_set_vout)
524
525 call mixfield_set_vout(field, this%vtau)
526
527 pop_sub(vtau_set_vout)
528 end subroutine vtau_set_vout
529
530 ! ---------------------------------------------------------
531 subroutine vtau_set_vin(field, this)
532 type(mixfield_t), intent(inout) :: field
533 type(ks_potential_t), intent(in) :: this
534
535 push_sub(vtau_set_vin)
536
537 call mixfield_set_vin(field, this%vtau)
538
539 pop_sub(vtau_set_vin)
540 end subroutine vtau_set_vin
541
542 ! ---------------------------------------------------------
543 subroutine vtau_get_vnew(field, this)
544 type(mixfield_t), intent(in) :: field
545 type(ks_potential_t), intent(inout) :: this
546
547 push_sub(vtau_get_vnew)
548
549 call mixfield_get_vnew(field, this%vtau)
550
552
553 pop_sub(vtau_get_vnew)
554 end subroutine vtau_get_vnew
555
557 subroutine ks_potential_output_potentials(this, namespace, how, dir, space, mesh, pos, atoms, grp)
558 class(ks_potential_t), intent(in) :: this
559 type(namespace_t), intent(in) :: namespace
560 integer(int64), intent(in) :: how
561 character(len=*), intent(in) :: dir
562 class(space_t), intent(in) :: space
563 class(mesh_t), intent(in) :: mesh
564 real(real64), optional, intent(in) :: pos(:,:)
565 type(atom_t), optional, intent(in) :: atoms(:)
566 type(mpi_grp_t), optional, intent(in) :: grp
568 character(len=MAX_PATH_LEN) :: fname
569 integer :: is, err
570
572
573 call dio_function_output(how, dir, 'vh', namespace, &
574 space, mesh, this%vhartree, units_out%energy, err, pos=pos, atoms=atoms, grp = grp)
575
576 do is = 1, this%nspin
577 fname = get_filename_with_spin('vxc', this%nspin, is)
578 call dio_function_output(how, dir, fname, namespace, space, &
579 mesh, this%vxc(:, is), units_out%energy, err, pos=pos, atoms=atoms, grp = grp)
580
581 if (this%needs_vtau) then
582 fname = get_filename_with_spin('vtau', this%nspin, is)
583 call dio_function_output(how, dir, fname, namespace, space, &
584 mesh, this%vtau(:, is), units_out%energy, err, pos=pos, atoms=atoms, grp = grp)
585 end if
586 end do
589 end subroutine ks_potential_output_potentials
590
592 subroutine ks_potential_storage_allocate(this, copy)
593 class(ks_potential_t), intent(in) :: this
594 type(xc_copied_potentials_t), intent(inout) :: copy
595
597
598 if (.not. allocated(copy%vhxc)) then
599 safe_allocate(copy%vhxc(1:this%np, 1:this%nspin))
600 end if
601 if (this%needs_vtau) then
602 if (.not. allocated(copy%vtau)) then
603 safe_allocate(copy%vtau(1:this%np, 1:this%nspin))
604 end if
605 end if
606
608 end subroutine ks_potential_storage_allocate
609
611 subroutine ks_potential_store_copy(this, copy)
612 class(ks_potential_t), intent(in) :: this
613 type(xc_copied_potentials_t), intent(inout) :: copy
614
615 if (this%theory_level == independent_particles) return
616
618
619 call ks_potential_storage_allocate(this, copy)
620 call lalg_copy(this%np, this%nspin, this%vhxc, copy%vhxc)
621 if (this%needs_vtau) then
622 call lalg_copy(this%np, this%nspin, this%vtau, copy%vtau)
623 end if
626 end subroutine ks_potential_store_copy
627
629 subroutine ks_potential_restore_copy(this, copy)
630 class(ks_potential_t), intent(inout) :: this
631 type(xc_copied_potentials_t), intent(in) :: copy
632
633 if (this%theory_level == independent_particles) return
634
637 assert(allocated(copy%vhxc))
638 call lalg_copy(this%np, this%nspin, copy%vhxc, this%vhxc)
639 if (this%needs_vtau) then
640 assert(allocated(copy%vtau))
641 call this%set_vtau(copy%vtau)
642 end if
643
645 end subroutine ks_potential_restore_copy
646
648 subroutine xc_copied_potentials_copy_vhxc_to_buffer(this, np, nspin, pnp, buffer)
649 class(xc_copied_potentials_t), intent(in) :: this
650 integer(int64), intent(in) :: np
651 integer, intent(in) :: nspin
652 integer(int64), intent(in) :: pnp
653 type(accel_mem_t), intent(inout) :: buffer
654
655 integer :: ispin
656
658
659 do ispin = 1, nspin
660 call accel_write_buffer(buffer, np, this%vhxc(:, ispin), offset = (ispin - 1)*pnp)
661 end do
662
665
667 subroutine xc_copied_potentials_end(this)
668 type(xc_copied_potentials_t), intent(inout) :: this
669
670 safe_deallocate_a(this%vhxc)
671 safe_deallocate_a(this%vtau)
672 end subroutine xc_copied_potentials_end
673
680 real(real64) function ks_potential_check_convergence(this, copy, mesh, rho, qtot) result(diff)
681 class(ks_potential_t), intent(in) :: this
682 type(xc_copied_potentials_t), intent(in) :: copy
683 class(mesh_t), intent(in) :: mesh
684 real(real64), intent(in) :: rho(:,:)
685 real(real64), intent(in) :: qtot
686
687 real(real64), allocatable :: diff_pot(:)
688 integer :: ip, is
689
690 push_sub(ks_potential_check_convergence)
691
692 safe_allocate(diff_pot(1:this%np))
693
694 !$omp parallel
695 !$omp do
696 do ip = 1, this%np
697 diff_pot(ip) = abs(copy%vhxc(ip, 1) - this%vhxc(ip, 1))*rho(ip, 1)
698 end do
699 do is = 2, this%nspin
700 !$omp do
701 do ip = 1, this%np
702 diff_pot(ip) = diff_pot(ip) + abs(copy%vhxc(ip, is) - this%vhxc(ip, is))*rho(ip, is)
703 end do
704 end do
705 !$omp end parallel
706 diff = dmf_integrate(mesh, diff_pot) / qtot
707
708 safe_deallocate_a(diff_pot)
709
710 pop_sub(ks_potential_check_convergence)
712
714 subroutine ks_potential_perform_interpolation(this, vksold, times, current_time)
715 class(ks_potential_t), intent(inout) :: this
716 type(potential_interpolation_t), intent(inout) :: vksold
717 real(real64), intent(in) :: times(:)
718 real(real64), intent(in) :: current_time
719
721
722 assert(size(times) == 3)
723
724 call interpolate(times, vksold%v_old(:, :, 1:3), current_time, vksold%v_old(:, :, 0))
725 if (this%needs_vtau) then
726 call interpolate(times, vksold%vtau_old(:, :, 1:3), current_time, vksold%vtau_old(:, :, 0))
727 end if
728
731
733 subroutine ks_potential_mix_potentials(this, vold, dt)
734 class(ks_potential_t), intent(in) :: this
735 type(xc_copied_potentials_t), intent(inout) :: vold
736 real(real64), intent(in) :: dt
737
738 integer :: ispin, ip
739
742 assert(not_in_openmp())
743
744 !$omp parallel private(ip)
745 do ispin = 1, this%nspin
746 !$omp do simd
747 do ip = 1, this%np
748 vold%vhxc(ip, ispin) = m_half*dt*(this%vhxc(ip, ispin) - vold%vhxc(ip, ispin))
749 end do
750
751 if (this%needs_vtau) then
752 !$omp do simd
753 do ip = 1, this%np
754 vold%vtau(ip, ispin) = m_half*dt*(this%vtau(ip, ispin) - vold%vtau(ip, ispin))
755 end do
756 end if
757 end do
758 !$omp end parallel
759
761 end subroutine ks_potential_mix_potentials
762
763
764#include "undef.F90"
765#include "complex.F90"
766#include "ks_potential_inc.F90"
767
768#include "undef.F90"
769#include "real.F90"
770#include "ks_potential_inc.F90"
771
772end module ks_potential_oct_m
774!! Local Variables:
775!! mode: f90
776!! coding: utf-8
777!! End:
Copies a vector x, to a vector y.
Definition: lalg_basic.F90:186
subroutine, public accel_release_buffer(this)
Definition: accel.F90:1246
pure logical function, public accel_is_enabled()
Definition: accel.F90:400
integer, parameter, public accel_mem_read_only
Definition: accel.F90:183
type(debug_t), save, public debug
Definition: debug.F90:156
real(real64), parameter, public m_zero
Definition: global.F90:188
logical pure function, public not_in_openmp()
Definition: global.F90:454
subroutine, public dio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
A module to handle KS potential, without the external potential.
subroutine ks_potential_set_interpolated_potentials(this, vksold, history)
Set the interpolated potentials to history.
subroutine zks_potential_current_mass_renormalization(this, gpsi, space_dim, ndim, ispin)
Nonlocal contribution of vtau for the current.
subroutine ks_potential_add_vhxc(this, pot, nspin)
Adds vHxc to the potential.
subroutine dks_potential_current_mass_renormalization(this, gpsi, space_dim, ndim, ispin)
Nonlocal contribution of vtau for the current.
subroutine ks_potential_load_vhxc(this, restart, space, mesh, ierr)
Loads the vhxc potentials.
subroutine, public vtau_set_vin(field, this)
subroutine ks_potential_get_interpolated_potentials(this, vksold, history, storage)
Get the interpolated potentials from history.
subroutine zks_potential_apply_vtau_psi(this, mesh, d, ispin, psib, vpsib)
Wrapper to hamiltonian_elec_base_local_sub to hide the data of vtau.
integer, parameter, public rdmft
subroutine, public vtau_set_vout(field, this)
subroutine zks_potential_mult_vhxc(this, mf, ispin)
Multiply a mesh function by vHxc.
integer, parameter, public hartree
subroutine ks_potential_interpolate_potentials(this, vksold, order, current_time, dt, interpolation_time)
Interpolate potentials to a new time.
integer, parameter, public hartree_fock
subroutine ks_potential_update_vtau_buffer(this)
Update vtau GPU buffer.
subroutine ks_potential_run_zero_iter(this, vksold)
Run zero iter for the interpolation.
subroutine ks_potential_store_copy(this, copy)
Copy the potentials to a storage object.
subroutine ks_potential_mix_potentials(this, vold, dt)
Replace vold potentials by 0.5*dt(vold + vhxc)
subroutine ks_potential_perform_interpolation(this, vksold, times, current_time)
Perform a time interpolation of the potentials.
subroutine, public vtau_get_vnew(field, this)
subroutine ks_potential_init_interpolation(this, vksold, order)
Initialize the potential interpolation.
real(real64) function ks_potential_check_convergence(this, copy, mesh, rho, qtot)
Check the convergence of a vhxc for predictor-corrector.
subroutine ks_potential_restore_copy(this, copy)
Copy the potentials from a storage object.
subroutine ks_potential_storage_allocate(this, copy)
Copy the potentials to a storage object.
subroutine ks_potential_interpolation_new(this, vksold, current_time, dt)
New interpolation point for the interpolation.
integer, parameter, public generalized_kohn_sham_dft
subroutine ks_potential_end(this)
Releases the memory for the KS potentials.
subroutine dks_potential_mult_vhxc(this, mf, ispin)
Multiply a mesh function by vHxc.
subroutine, public xc_copied_potentials_end(this)
Finalizer for the copied potentials.
integer, parameter, public kohn_sham_dft
subroutine ks_potential_dump_vhxc(this, restart, space, mesh, ierr)
Dumps the vhxc potentials.
subroutine dks_potential_apply_vtau_psi(this, mesh, d, ispin, psib, vpsib)
Wrapper to hamiltonian_elec_base_local_sub to hide the data of vtau.
subroutine ks_potential_init(this, np, np_part, nspin, theory_level, needs_vtau)
Allocate the memory for the KS potentials.
subroutine ks_potential_set_vtau(this, vtau)
Set vtau and update the corresponding GPU buffer.
subroutine xc_copied_potentials_copy_vhxc_to_buffer(this, np, nspin, pnp, buffer)
Copy the vhxc potential to a gpu buffer.
subroutine ks_potential_output_potentials(this, namespace, how, dir, space, mesh, pos, atoms, grp)
Outputs vh, vxc, and vtau potentials.
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:115
This module defines various routines, operating on mesh functions.
real(real64) function, public dmf_integrate(mesh, ff, mask, reduce)
Integrate a function on the mesh.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:616
this module contains the low-level part of the output system
Definition: output_low.F90:115
character(len=max_path_len) function, public get_filename_with_spin(output, nspin, spin_index)
Returns the filame as output, or output-spX is spin polarized.
Definition: output_low.F90:232
subroutine, public potential_interpolation_interpolate(potential_interpolation, order, time, dt, t, vhxc, vtau)
subroutine, public potential_interpolation_set(potential_interpolation, np, nspin, i, vhxc, vtau)
subroutine, public potential_interpolation_new(potential_interpolation, np, nspin, time, dt, vhxc, vtau)
subroutine, public potential_interpolation_run_zero_iter(potential_interpolation, np, nspin, vhxc, vtau)
subroutine, public potential_interpolation_get(potential_interpolation, np, nspin, i, vhxc, vtau)
subroutine, public potential_interpolation_init(potential_interpolation, np, nspin, mgga_with_exc, order)
subroutine, public restart_close(restart, iunit)
Close a file previously opened with restart_open.
Definition: restart.F90:952
subroutine, public restart_write(restart, iunit, lines, nlines, ierr)
Definition: restart.F90:908
logical pure function, public restart_skip(restart)
Returns true if the restart information should neither be read nor written. This might happen because...
Definition: restart.F90:969
integer function, public restart_open(restart, filename, status, position, silent)
Open file "filename" found inside the current restart directory. Depending on the type of restart,...
Definition: restart.F90:861
This module handles spin dimensions of the states and the k-point distribution.
type(type_t), public type_float
Definition: types.F90:133
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:132
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
Describes mesh distribution to nodes.
Definition: mesh.F90:186
Quantities used in mixing: Input, output and new potentials, and the residuals.
Definition: mix.F90:171
This is defined even when running serial.
Definition: mpi.F90:142