Octopus
electrons.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!! Copyright (C) 2009 X. Andrade
3!! Copyright (C) 2020 M. Oliveira
4!!
5!! This program is free software; you can redistribute it and/or modify
6!! it under the terms of the GNU General Public License as published by
7!! the Free Software Foundation; either version 2, or (at your option)
8!! any later version.
9!!
10!! This program is distributed in the hope that it will be useful,
11!! but WITHOUT ANY WARRANTY; without even the implied warranty of
12!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!! GNU General Public License for more details.
14!!
15!! You should have received a copy of the GNU General Public License
16!! along with this program; if not, write to the Free Software
17!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18!! 02110-1301, USA.
19!!
20
21#include "global.h"
22
23
24module electrons_oct_m
25 use accel_oct_m
33 use debug_oct_m
35 use dipole_oct_m
39 use elf_oct_m
43 use forces_oct_m
45 use global_oct_m
46 use grid_oct_m
56 use ions_oct_m
57 use kick_oct_m
62 use lasers_oct_m
63 use lda_u_oct_m
64 use loct_oct_m
65 use mesh_oct_m
68 use mpi_oct_m
73 use output_oct_m
75 use parser_oct_m
76 use pes_oct_m
91 use rdmft_oct_m
93 use scf_oct_m
94 use space_oct_m
98 use stress_oct_m
99 use sort_oct_m
101 use system_oct_m
102 use td_oct_m
105 use v_ks_oct_m
106 use wannier_oct_m, only: wannier_t
108 use xc_oct_m
109 use xc_f03_lib_m
110 use xc_oep_oct_m
114
115 implicit none
116
117 private
118 public :: &
120
121
127 type, extends(system_t) :: electrons_t
128 ! Components are public by default
129 type(electron_space_t) :: space
130 class(ions_t), pointer :: ions => null()
131 type(photons_t), pointer :: photons => null()
132 type(grid_t) :: gr
133 type(states_elec_t) :: st
134 type(v_ks_t) :: ks
135 type(output_t) :: outp
136 type(multicomm_t) :: mc
137 type(hamiltonian_elec_t) :: hm
138 type(td_t) :: td
139 type(current_t) :: current_calculator
140 type(dipole_t) :: dipole
141 type(scf_t) :: scf
142 type(rdm_t) :: rdm
143
144 type(kpoints_t) :: kpoints
145
146 logical :: generate_epot
147
148 type(states_elec_t) :: st_copy
149
150 ! At the moment this is not treated as an external potential
151 class(lasers_t), pointer :: lasers => null()
152 class(gauge_field_t), pointer :: gfield => null()
153
154 ! List with all the external partners
155 ! This will become a list of interactions in the future
156 type(partner_list_t) :: ext_partners
157
158 !TODO: have a list of self interactions
159 type(xc_interaction_t), pointer :: xc_interaction => null()
160
161 type(dmp_t) :: dmp
162
163 logical :: ions_propagated = .false.
164
165 ! everything related to wannier functions
166 type(wannier_t) :: wannier
167
168 contains
169 procedure :: init_interaction => electrons_init_interaction
170 procedure :: new_algorithm => electrons_new_algorithm
171 procedure :: initialize => electrons_initialize
172 procedure :: do_algorithmic_operation => electrons_do_algorithmic_operation
173 procedure :: is_tolerance_reached => electrons_is_tolerance_reached
174 procedure :: update_quantity => electrons_update_quantity
175 procedure :: init_interaction_as_partner => electrons_init_interaction_as_partner
176 procedure :: copy_quantities_to_interaction => electrons_copy_quantities_to_interaction
177 procedure :: output_start => electrons_output_start
178 procedure :: output_write => electrons_output_write
179 procedure :: output_finish => electrons_output_finish
180 procedure :: process_is_slave => electrons_process_is_slave
181 procedure :: restart_write_data => electrons_restart_write_data
182 procedure :: restart_read_data => electrons_restart_read_data
183 procedure :: update_kinetic_energy => electrons_update_kinetic_energy
184 procedure :: algorithm_start => electrons_algorithm_start
185 procedure :: ground_state_run => electrons_ground_state_run_system
186 final :: electrons_finalize
187 end type electrons_t
188
189 interface electrons_t
190 procedure electrons_constructor
191 end interface electrons_t
192
193contains
194
199 function electrons_constructor(namespace, grp, calc_mode_id) result(sys)
200 class(electrons_t), pointer :: sys
201 type(namespace_t), intent(in) :: namespace
202 type(mpi_grp_t), intent(in) :: grp
203 integer, optional, intent(in) :: calc_mode_id
204
205 integer :: iatom
206 integer(int64) :: go_type
207 type(lattice_vectors_t) :: latt_inp
208 logical :: has_photons, variable_cell, cell_dynamics
209
210 push_sub_with_profile(electrons_constructor)
211
212 allocate(sys)
213
214 sys%namespace = namespace
215
216 call sys%init_parallelization(grp)
217
218 call messages_obsolete_variable(sys%namespace, 'SystemName')
219
220 sys%space = electron_space_t(sys%namespace)
221 call sys%space%write_info(sys%namespace)
222 if (sys%space%has_mixed_periodicity()) then
223 call messages_experimental('Support for mixed periodicity systems')
224 end if
226 sys%ions => ions_t(sys%namespace, grp=sys%grp, latt_inp=latt_inp, shared_namespace=.true.)
228 ! We first determine whether the cell is varying or not, as this affects the generation of
229 ! the boundary points (a varying cell needs the full cube stencil, see grid_init_stage_1).
230 variable_cell = .false.
231 if (present(calc_mode_id)) then
232 if (calc_mode_id == option__calculationmode__go) then
233 call parse_variable(sys%namespace, 'GOType', option__gotype__ion_positions, go_type)
234 variable_cell = bitand(go_type, option__gotype__cell_shape) /= 0 &
235 .or. bitand(go_type, option__gotype__cell_volume) /= 0
236 end if
237 end if
238 call parse_variable(sys%namespace, 'CellDynamics', .false., cell_dynamics)
239 variable_cell = variable_cell .or. cell_dynamics
240
241 call grid_init_stage_1(sys%gr, sys%namespace, sys%space, sys%grp, &
242 sys%ions%symm, latt_inp, sys%ions%natoms, sys%ions%pos, variable_cell)
244 if (sys%space%is_periodic()) then
245 call sys%ions%latt%write_info(sys%namespace)
246 end if
248 ! Sanity check for atomic coordinates
249 do iatom = 1, sys%ions%natoms
250 ! Using the same tolerance of fold_into_cell to avoid problems with mixed periodicities
251 ! as the default tolerance of contains_point is too tight
252 if (.not. sys%gr%box%contains_point(sys%ions%pos(:, iatom), tol=1.0e-6_real64)) then
253 if (sys%space%periodic_dim /= sys%space%dim) then
254 write(message(1), '(a,i5,a)') "Atom ", iatom, " is outside the box."
255 call messages_warning(1, namespace=sys%namespace)
256 end if
257 end if
258 end do
259
260 ! Find possible non-symmorphic symmetries compatible with the real-space grid
261 if (sys%space%dim == 3) then
262 call symmetries_use_compatible_nonsymmorphic(sys%gr%symm, sys%gr%idx%ll, namespace)
263 end if
265 ! we need k-points for periodic systems
266 call kpoints_init(sys%kpoints, sys%namespace, sys%gr%symm, sys%space%dim, sys%space%periodic_dim, sys%ions%latt)
268 call states_elec_init(sys%st, sys%namespace, sys%space, sys%ions%val_charge(), sys%kpoints, calc_mode_id)
269 call sys%st%write_info(sys%namespace)
271 ! if independent particles in N dimensions are being used, need to initialize them
272 ! after masses are set to 1 in grid_init_stage_1 -> derivatives_init
273 call sys%st%modelmbparticles%copy_masses(sys%gr%der%masses)
275 call elf_init(sys%namespace)
277 if (present(calc_mode_id)) then
278 sys%generate_epot = calc_mode_id /= option__calculationmode__dummy
279 else
280 sys%generate_epot = .true.
281 end if
282
283 call sys%dipole%init(sys%space)
284
285 sys%supported_interactions_as_partner = [current_to_mxll_field]
286
287 call sys%quantities%add(quantity_t("wavefunctions", updated_on_demand = .false.))
288 call sys%quantities%add(quantity_t("current", updated_on_demand = .true., parents=["wavefunctions"]))
289 call sys%quantities%add(quantity_t("dipole", updated_on_demand = .true., parents=["wavefunctions"]))
290 call current_init(sys%current_calculator, sys%namespace)
291
292 !%Variable EnablePhotons
293 !%Type logical
294 !%Default no
295 !%Section Hamiltonian
296 !%Description
297 !% This variable can be used to enable photons in several types of calculations.
298 !% It can be used to activate the one-photon OEP formalism.
299 !% In the case of CalculationMode = casida, it enables photon modes as
300 !% described in ACS Photonics 2019, 6, 11, 2757-2778.
301 !% Finally, if set to yes when solving the ferquency-dependent Sternheimer
302 !% equation, the photons are coupled to the electronic subsystem.
303 !%End
304 call messages_obsolete_variable(namespace, 'OEPPtX', 'EnablePhotons')
305 call parse_variable(namespace, 'EnablePhotons', .false., has_photons)
306 if (has_photons) then
307 call messages_experimental("EnablePhotons = yes")
308 sys%photons => photons_t(sys%namespace)
309 else
310 nullify(sys%photons)
311 end if
312
313 call sys%wannier%init_from_input(sys%namespace, sys%kpoints)
314
316
317 pop_sub_with_profile(electrons_constructor)
318 end function electrons_constructor
319
320 ! ---------------------------------------------------------
321 subroutine electrons_init_interaction(this, interaction)
322 class(electrons_t), target, intent(inout) :: this
323 class(interaction_t), intent(inout) :: interaction
324
325 real(real64) :: dmin
326 integer :: rankmin, depth
327 logical :: mxll_interaction_present
328 logical :: calc_dipole
329
330 push_sub(electrons_init_interactions)
331
332 mxll_interaction_present = .false.
333 select type (interaction)
335 call interaction%init(this%gr, 3)
336 mxll_interaction_present = .true.
337 interaction%type = mxll_field_trans
339 call interaction%init(this%gr, 3)
340 mxll_interaction_present = .true.
342 call interaction%init(this%gr, 3)
343 mxll_interaction_present = .true.
344 class default
345 message(1) = "Trying to initialize an unsupported interaction by the electrons."
346 call messages_fatal(1, namespace=this%namespace)
347 end select
348
349 if (mxll_interaction_present) then
350 calc_dipole = any(this%hm%mxll%coupling_mode == &
352
353 if (calc_dipole) then
354 assert(this%space%periodic_dim == 0)
355 this%hm%mxll%calc_field_dip = .true.
356 this%hm%mxll%center_of_mass(1:3) = this%ions%center_of_mass()
357 this%hm%mxll%center_of_mass_ip = mesh_nearest_point(this%gr, this%hm%mxll%center_of_mass, dmin, rankmin)
358 this%hm%mxll%center_of_mass_rankmin = rankmin
359 end if
360 end if
361
362 ! set interpolation depth for field-transfer interactions
363 select type (interaction)
364 class is (field_transfer_t)
365 ! interpolation depth depends on the propagator
366 select type (algo => this%algo)
367 type is (propagator_exp_mid_t)
368 depth = 3
369 type is (propagator_aetrs_t)
370 depth = 3
371 type is (propagator_bomd_t)
372 depth = 1
373 class default
374 message(1) = "The chosen algorithm does not yet support interaction interpolation"
375 call messages_fatal(1, namespace=this%namespace)
376 end select
377
378 call interaction%init_interpolation(depth, interaction%label)
379 end select
380
381 pop_sub(electrons_init_interactions)
382 end subroutine electrons_init_interaction
383
384 ! ---------------------------------------------------------
385 subroutine electrons_init_parallelization(this)
386 class(electrons_t), intent(inout) :: this
387
388 integer(int64) :: index_range(4)
389 real(real64) :: mesh_global, mesh_local, wfns
390 integer :: idir
391 real(real64) :: spiral_q(3), spiral_q_red(3)
392 type(block_t) :: blk
393
395
396 ! store the ranges for these two indices (serves as initial guess
397 ! for parallelization strategy)
398 index_range(1) = this%gr%np_global ! Number of points in mesh
399 index_range(2) = this%st%nst ! Number of states
400 index_range(3) = this%st%nik ! Number of k-points
401 index_range(4) = 100000 ! Some large number
402
403 ! create index and domain communicators
404 call multicomm_init(this%mc, this%namespace, this%grp, calc_mode_par, &
405 this%grp%size, index_range, (/ 5000, 1, 1, 1 /))
406
407 call this%ions%partition(this%mc)
408 call kpoints_distribute(this%st, this%mc)
409 call states_elec_distribute_nodes(this%st, this%namespace, this%mc)
410
411
412 if (parse_is_defined(this%namespace, 'TDMomentumTransfer') .or. &
413 parse_is_defined(this%namespace, 'TDReducedMomentumTransfer')) then
414 spiral_q = m_zero
415 if (parse_block(this%namespace, 'TDMomentumTransfer', blk) == 0) then
416 do idir = 1, this%space%dim
417 call parse_block_float(blk, 0, idir - 1, spiral_q(idir))
418 end do
419 else if(parse_block(this%namespace, 'TDReducedMomentumTransfer', blk) == 0) then
420 do idir = 1, this%space%dim
421 call parse_block_float(blk, 0, idir - 1, spiral_q_red(idir))
422 end do
423 call kpoints_to_absolute(this%kpoints%latt, spiral_q_red(1:this%space%dim), spiral_q(1:this%space%dim))
424 end if
425 call parse_block_end(blk)
426 call grid_init_stage_2(this%gr, this%namespace, this%space, this%mc, spiral_q)
427 else
428 call grid_init_stage_2(this%gr, this%namespace, this%space, this%mc)
429 end if
430
431 if (this%st%symmetrize_density) then
432 call mesh_check_symmetries(this%gr, this%gr%symm, this%ions%space%periodic_dim)
433 end if
434
435 call output_init(this%outp, this%namespace, this%space, this%st, this%gr, this%st%nst, this%ks)
436 call states_elec_densities_init(this%st, this%gr)
437 call states_elec_exec_init(this%st, this%namespace, this%mc)
438
439 if (associated(this%photons)) then
440 call this%ks%v_ks_photons%set_active(.true.)
441 end if
442
443 call v_ks_init(this%ks, this%namespace, this%gr, this%st, this%ions, this%mc, this%space, &
444 this%kpoints)
445 if (this%ks%theory_level == kohn_sham_dft .or. this%ks%theory_level == generalized_kohn_sham_dft) then
446 this%xc_interaction => xc_interaction_t(this)
447 end if
448
449 ! For the moment the photons are initialized here
450 if (this%ks%v_ks_photons%active()) then
451 call this%ks%v_ks_photons%setup(this%namespace, this%photons%modes, this%gr, this%st, this%ions, &
452 this%mc, this%space, this%ks%xc, this%ks%xc_family, this%ks%oep%level)
453 end if
454
455
456 ! Temporary place for the initialization of the lasers
457 this%lasers => lasers_t(this%namespace)
458 call lasers_parse_external_fields(this%lasers)
459 call lasers_generate_potentials(this%lasers, this%gr, this%space, this%ions%latt)
460 if(this%lasers%no_lasers > 0) then
461 call this%ext_partners%add(this%lasers)
462 call lasers_check_symmetries(this%lasers, this%kpoints)
463 else
464 deallocate(this%lasers)
465 end if
466
467 ! Temporary place for the initialization of the gauge field
468 this%gfield => gauge_field_t(this%namespace, this%ions%latt%rcell_volume)
469 if(gauge_field_is_used(this%gfield)) then
470 call this%ext_partners%add(this%gfield)
471 call gauge_field_check_symmetries(this%gfield, this%kpoints)
472 else
473 deallocate(this%gfield)
474 end if
475
476 call hamiltonian_elec_init(this%hm, this%namespace, this%space, this%gr, this%ions, this%ext_partners, &
477 this%st, this%ks%theory_level, this%ks%xc, this%mc, this%kpoints, &
478 need_exchange = output_need_exchange(this%outp) .or. this%ks%oep%level /= oep_level_none, &
479 xc_photons = this%ks%v_ks_photons%get_xc_photons() )
481 if (this%hm%pcm%run_pcm .and. this%mc%par_strategy /= p_strategy_serial .and. this%mc%par_strategy /= p_strategy_states) then
482 call messages_experimental('Parallel in domain calculations with PCM')
483 end if
484
485 ! Print memory requirements
486 call messages_print_with_emphasis(msg='Approximate memory requirements', namespace=this%namespace)
487
488 mesh_global = mesh_global_memory(this%gr)
489 mesh_local = mesh_local_memory(this%gr)
490
491 call messages_write('Mesh')
492 call messages_new_line()
493 call messages_write(' global :')
494 call messages_write(mesh_global, units = unit_megabytes, fmt = '(f10.1)')
495 call messages_new_line()
496 call messages_write(' local :')
497 call messages_write(mesh_local, units = unit_megabytes, fmt = '(f10.1)')
498 call messages_new_line()
499 call messages_write(' total :')
500 call messages_write(mesh_global + mesh_local, units = unit_megabytes, fmt = '(f10.1)')
501 call messages_new_line()
502 call messages_info(namespace=this%namespace)
503
504 wfns = states_elec_wfns_memory(this%st, this%gr)
505 call messages_write('States')
506 call messages_new_line()
507 call messages_write(' real :')
508 call messages_write(wfns, units = unit_megabytes, fmt = '(f10.1)')
509 call messages_write(' (par_kpoints + par_states + par_domains)')
510 call messages_new_line()
511 call messages_write(' complex :')
512 call messages_write(2.0_8*wfns, units = unit_megabytes, fmt = '(f10.1)')
513 call messages_write(' (par_kpoints + par_states + par_domains)')
514 call messages_new_line()
515 call messages_info(namespace=this%namespace)
516
517 call messages_print_with_emphasis(namespace=this%namespace)
518
519 if (this%generate_epot) then
520 message(1) = "Info: Generating external potential"
521 call messages_info(1, namespace=this%namespace)
522 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
523 this%ext_partners, this%st)
524 message(1) = " done."
525 call messages_info(1, namespace=this%namespace)
526 end if
527
528 if (this%ks%theory_level /= independent_particles) then
529 call poisson_async_init(this%hm%psolver, this%mc)
530 ! slave nodes do not call the calculation routine
531 if (multicomm_is_slave(this%mc)) then
532 !for the moment we only have one type of slave
533 call poisson_slave_work(this%hm%psolver, this%namespace)
534 end if
535 end if
536
537 allocate(this%supported_interactions(0))
538 select case (this%hm%mxll%coupling_mode)
540 this%supported_interactions = [this%supported_interactions, mxll_e_field_to_matter]
542 this%supported_interactions = [this%supported_interactions, mxll_vec_pot_to_matter]
543 if (this%hm%mxll%add_zeeman) then
544 this%supported_interactions = [this%supported_interactions, mxll_b_field_to_matter]
545 end if
547 if (this%hm%mxll%add_electric_dip .or. this%hm%mxll%add_electric_quad) then
548 this%supported_interactions = [this%supported_interactions, mxll_e_field_to_matter]
549 end if
550 if (this%hm%mxll%add_magnetic_dip) then
551 this%supported_interactions = [this%supported_interactions, mxll_b_field_to_matter]
552 end if
554 ! Do not initialize any interaction with Maxwell
555 case default
556 message(1) = "Unknown maxwell-matter coupling"
557 call messages_fatal(1, namespace=this%namespace)
558 end select
559
560 call this%wannier%init_parallelization(this%namespace, this%st, this%ions, this%kpoints)
561
563 end subroutine electrons_init_parallelization
564
565 ! ---------------------------------------------------------
566 subroutine electrons_new_algorithm(this, factory)
567 class(electrons_t), intent(inout) :: this
568 class(algorithm_factory_t), intent(in) :: factory
569
571
572 call system_new_algorithm(this, factory)
573
574 select type (algo => this%algo)
575 class is (propagator_t)
576
577 call td_init(this%td, this%namespace, this%space, this%gr, this%ions, this%st, this%ks, &
578 this%hm, this%ext_partners, this%outp, this%dmp)
579
580 ! this corresponds to the first part of td_init_run
581 call td_allocate_wavefunctions(this%td, this%namespace, this%mc, this%gr, this%ions, this%st, &
582 this%hm, this%space)
583 call td_init_gaugefield(this%td, this%namespace, this%gr, this%st, this%ks, this%hm, &
584 this%ext_partners, this%space)
585
586 class is (minimizer_algorithm_t)
587
588 call electrons_gs_allocate_wavefunctions(this%namespace, this%gr, this%st, this%hm, this%scf, this%ks, &
589 this%ions)
590
591 class default
592 assert(.false.)
593 end select
594
596 end subroutine electrons_new_algorithm
597
598 ! ---------------------------------------------------------
599 subroutine electrons_initialize(this)
600 class(electrons_t), intent(inout) :: this
601
602 push_sub(electrons_initialize)
603
604 if (associated(this%ions)) call this%ions%initialize()
605
606 select type (algo => this%algo)
607 class is (propagator_t)
608 call td_set_from_scratch(this%td, .true.)
609 call td_load_restart_from_gs(this%td, this%namespace, this%space, this%mc, this%gr, &
610 this%ext_partners, this%st, this%ks, this%hm)
611 call this%wannier%init_data_from_file(this%kpoints, this%space)
612
613 class is (minimizer_algorithm_t)
614
615 call electrons_gs_initialize(this%namespace, this%scf, this%rdm, this%gr, this%mc, this%st, &
616 this%hm, this%ions, this%ks, this%space, this%ext_partners, fromscratch=.true.)
617 class default
618 assert(.false.)
619 end select
620
621 pop_sub(electrons_initialize)
622 end subroutine electrons_initialize
623
624 ! ---------------------------------------------------------
625 subroutine electrons_algorithm_start(this)
626 class(electrons_t), intent(inout) :: this
627
629
630 call system_algorithm_start(this)
631
632 select type (algo => this%algo)
633 class is (propagator_t)
634
635 ! additional initialization needed for electrons
636 call td_init_with_wavefunctions(this%td, this%namespace, this%space, this%mc, this%gr, this%ions, &
637 this%ext_partners, this%st, this%ks, this%hm, this%outp, this%dmp, td_get_from_scratch(this%td))
638
639 end select
640
642 end subroutine electrons_algorithm_start
643
644 ! ---------------------------------------------------------
645 logical function electrons_do_algorithmic_operation(this, operation, updated_quantities) result(done)
646 class(electrons_t), intent(inout) :: this
647 class(algorithmic_operation_t), intent(in) :: operation
648 character(len=:), allocatable, intent(out) :: updated_quantities(:)
649
650 logical :: update_energy_
651 type(gauge_field_t), pointer :: gfield
652 real(real64) :: time
653 integer :: iter
654
656 call profiling_in(trim(this%namespace%get())//":"//trim(operation%id))
657
658 update_energy_ = .true.
659
660 ! kick at t > 0 still missing!
662 done = .true.
663 select type (algo => this%algo)
664 class is (propagator_t)
665 time = algo%iteration%value()
666 select case (operation%id)
667 case (aetrs_first_half)
668 ! propagate half of the time step with H(time)
669 call get_fields_from_interaction(this, time)
670 call propagation_ops_elec_update_hamiltonian(this%namespace, this%space, this%st, this%gr, &
671 this%hm, this%ext_partners, time)
672 call propagation_ops_elec_exp_apply(this%td%tr%te, this%namespace, this%st, this%gr, this%hm, m_half*algo%dt)
673
674 case (aetrs_extrapolate)
675 ! Do the extrapolation of the Hamiltonian
676 ! First the extrapolation of the potential
677 call this%hm%ks_pot%interpolation_new(this%td%tr%vks_old, time+algo%dt, algo%dt)
678
679 !Get the potentials from the interpolator
680 call propagation_ops_elec_interpolate_get(this%hm, this%td%tr%vks_old)
681
682 ! Second the ions and gauge field which later on will be treated as extrapolation
683 ! of interactions, but this is not yet possible
684
685 ! move the ions to time t
686 call propagation_ops_elec_move_ions(this%td%tr%propagation_ops_elec, this%gr, this%hm, &
687 this%st, this%namespace, this%space, this%td%ions_dyn, this%ions, this%ext_partners, &
688 this%mc, time+algo%dt, algo%dt)
689
690 !Propagate gauge field
691 gfield => list_get_gauge_field(this%ext_partners)
692 if(associated(gfield)) then
693 call propagation_ops_elec_propagate_gauge_field(this%td%tr%propagation_ops_elec, gfield, &
694 algo%dt, time+algo%dt)
695 end if
696
697 !Update Hamiltonian and current
698 call get_fields_from_interaction(this, time+algo%dt)
699 call propagation_ops_elec_update_hamiltonian(this%namespace, this%space, this%st, this%gr, &
700 this%hm, this%ext_partners, time+algo%dt)
701
702 case (aetrs_second_half)
703 !Do the time propagation for the second half of the time step
704 call propagation_ops_elec_fuse_density_exp_apply(this%td%tr%te, this%namespace, this%st, &
705 this%gr, this%hm, m_half*algo%dt)
706
707 updated_quantities = ["wavefunctions"]
708
709 case (expmid_extrapolate)
710 ! the half step of this propagator screws with the gauge field kick
711 gfield => list_get_gauge_field(this%ext_partners)
712 if(associated(gfield)) then
713 assert(gauge_field_is_propagated(gfield) .eqv. .false.)
714 end if
715
716 ! Do the extrapolation of the Hamiltonian
717 ! First the extrapolation of the potential
718 call this%hm%ks_pot%interpolation_new(this%td%tr%vks_old, time+algo%dt, algo%dt)
719
720 ! get the potentials from the interpolator
721 call this%hm%ks_pot%interpolate_potentials(this%td%tr%vks_old, 3, time+algo%dt, algo%dt, time + algo%dt/m_two)
722
723 ! Second the ions which later on will be treated as extrapolation of interactions,
724 ! but this is not yet possible
725 ! move the ions to the half step
726 call propagation_ops_elec_move_ions(this%td%tr%propagation_ops_elec, this%gr, this%hm, this%st, &
727 this%namespace, this%space, this%td%ions_dyn, this%ions, this%ext_partners, &
728 this%mc, time + m_half*algo%dt, m_half*algo%dt, save_pos=.true.)
729
730 call get_fields_from_interaction(this, time + m_half*algo%dt)
731 call propagation_ops_elec_update_hamiltonian(this%namespace, this%space, this%st, this%gr, &
732 this%hm, this%ext_partners, time + m_half*algo%dt)
733
734 case (expmid_propagate)
735 ! Do the actual propagation step
736 call propagation_ops_elec_fuse_density_exp_apply(this%td%tr%te, this%namespace, this%st, &
737 this%gr, this%hm, algo%dt)
738
739 ! restore to previous time
740 call propagation_ops_elec_restore_ions(this%td%tr%propagation_ops_elec, this%td%ions_dyn, this%ions)
741
742 updated_quantities = ["wavefunctions"]
743
744 case (bomd_start)
745 call scf_init(this%scf, this%namespace, this%gr, this%ions, this%st, this%mc, this%hm, this%space)
746 ! the ions are propagated inside the propagation step already, so no need to do it at the end
747 this%ions_propagated = .true.
748
749 case (verlet_update_pos)
750 ! move the ions to time t
751 call propagation_ops_elec_propagate_ions_and_cell(this%gr, this%hm, this%st, this%namespace, this%space, &
752 this%td%ions_dyn, this%ions, this%mc, time+algo%dt, algo%dt)
753
754 case (bomd_elec_scf)
755 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
756 this%ext_partners, this%st, time = time+algo%dt)
757 ! now calculate the eigenfunctions
758 call scf_run(this%scf, this%namespace, this%space, this%mc, this%gr, this%ions, &
759 this%ext_partners, this%st, this%ks, this%hm, verbosity = verb_compact)
760 ! TODO: Check if this call is realy needed. - NTD
761 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
762 this%ext_partners, this%st, time = time+algo%dt)
763
764 ! update Hamiltonian and eigenvalues (fermi is *not* called)
765 call v_ks_calc(this%ks, this%namespace, this%space, this%hm, this%st, this%ions, this%ext_partners, &
766 calc_eigenval = .true., time = time+algo%dt, calc_energy = .true.)
767
768 ! Get the energies.
769 call energy_calc_total(this%namespace, this%space, this%hm, this%gr, this%st, this%ext_partners, iunit = -1)
770
771 updated_quantities = ["wavefunctions"]
772
773 case (verlet_compute_acc)
774 ! Do nothing, forces are computing in scf_run
775 if (this%td%ions_dyn%cell_relax()) then
776 assert(this%scf%calc_stress)
777 call this%td%ions_dyn%update_stress(this%ions%space, this%st%stress_tensors%total, &
778 this%ions%latt%rlattice, this%ions%latt%rcell_volume)
779 end if
780
781 case (verlet_compute_vel)
782 call ion_dynamics_propagate_vel(this%td%ions_dyn, this%ions)
783 ! TODO: Check if this call is realy needed. - NTD
784 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
785 this%ext_partners, this%st, time = time+algo%dt)
786 call this%ions%update_kinetic_energy()
787
788 case (expmid_start)
789 this%ions_propagated = .false.
790
791 case (aetrs_start)
792 ! the ions are propagated inside the propagation step already, so no need to do it at the end
793 this%ions_propagated = .true.
794
795 case (iteration_done)
797 done = .false.
798
799 case (bomd_finish)
800 call scf_end(this%scf)
801
803 case default
804 done = .false.
805 end select
806
807 class is(minimizer_algorithm_t)
808
809 ! Clocks starts at 0....
810 iter = nint(this%iteration%value()) + 1
811
812 select case(operation%id)
813 case (gs_scf_start)
814 call scf_start(this%scf, this%namespace, this%gr, this%ions, this%st, this%ks, this%hm, this%outp)
815
816 case (gs_scf_iteration)
817
818 call scf_iter(this%scf, this%namespace, this%space, this%mc, this%gr, this%ions, &
819 this%ext_partners, this%st, this%ks, this%hm, iter, outp = this%outp, &
820 restart_dump=this%scf%restart_dump)
821
822 algo%converged = scf_iter_finish(this%scf, this%namespace, this%space, this%gr, this%ions,&
823 this%st, this%ks, this%hm, iter, outp = this%outp)
824
825 updated_quantities = ["wavefunctions"]
826
827 case (gs_scf_finish)
828
829 ! Here iteration is iter-1, as the clock ticked before SCF_FINISH
830 call scf_finish(this%scf, this%namespace, this%space, this%gr, this%ions, &
831 this%ext_partners, this%st, this%ks, this%hm, iter-1, outp = this%outp)
832
833 case default
834 done = .false.
835 end select
836 class default
837 done = .false.
838 end select
839
840 call profiling_out(trim(this%namespace%get())//":"//trim(operation%id))
843
844 ! ---------------------------------------------------------
845 logical function electrons_is_tolerance_reached(this, tol) result(converged)
846 class(electrons_t), intent(in) :: this
847 real(real64), intent(in) :: tol
848
850
851 converged = .false.
852
855
856 ! ---------------------------------------------------------
857 subroutine electrons_update_quantity(this, label)
858 class(electrons_t), intent(inout) :: this
859 character(len=*), intent(in) :: label
860
861 class(quantity_t), pointer :: quantity
862
864 call profiling_in(trim(this%namespace%get())//":"//"UPDATE_QUANTITY")
865
866 quantity => this%quantities%get(label)
867 if(associated(quantity)) then
868 assert(quantity%updated_on_demand)
869 endif
870
871 select case (label)
872 case ("current")
873 call states_elec_allocate_current(this%st, this%space, this%gr)
874 call current_calculate(this%current_calculator, this%namespace, this%gr, &
875 this%hm, this%space, this%st)
876 case ("dipole")
877 call this%dipole%calculate(this%gr, this%ions, this%st)
878 case default
879 message(1) = "Incompatible quantity: "//trim(label)//"."
880 call messages_fatal(1, namespace=this%namespace)
881 end select
882
883 call profiling_out(trim(this%namespace%get())//":"//"UPDATE_QUANTITY")
885 end subroutine electrons_update_quantity
886
887 ! ---------------------------------------------------------
888 subroutine electrons_init_interaction_as_partner(partner, interaction)
889 class(electrons_t), intent(in) :: partner
890 class(interaction_surrogate_t), intent(inout) :: interaction
891
893
894 select type (interaction)
896 call interaction%init_from_partner(partner%gr, partner%space, partner%namespace)
897 class default
898 message(1) = "Unsupported interaction."
899 call messages_fatal(1, namespace=partner%namespace)
900 end select
901
904
905 ! ---------------------------------------------------------
906 subroutine electrons_copy_quantities_to_interaction(partner, interaction)
907 class(electrons_t), intent(inout) :: partner
908 class(interaction_surrogate_t), intent(inout) :: interaction
909
911 call profiling_in(trim(partner%namespace%get())//":"//"COPY_QUANTITY_INTER")
912
913 select type (interaction)
915 assert(allocated(partner%st%current))
916 interaction%partner_field(:,:) = partner%st%current(1:partner%gr%np,:,1)
917 call interaction%do_mapping()
918 class default
919 message(1) = "Unsupported interaction."
920 call messages_fatal(1, namespace=partner%namespace)
921 end select
922
923 call profiling_out(trim(partner%namespace%get())//":"//"COPY_QUANTITY_INTER")
926
927 ! ---------------------------------------------------------
928 subroutine electrons_output_start(this)
929 class(electrons_t), intent(inout) :: this
930
931 push_sub(electrons_output_start)
932
934 end subroutine electrons_output_start
935
936 ! ---------------------------------------------------------
937 subroutine electrons_output_write(this)
938 class(electrons_t), intent(inout) :: this
939
940 integer :: iter
941
942 push_sub(electrons_output_write)
943 call profiling_in(trim(this%namespace%get())//":"//"OUTPUT_WRITE")
944
945 select type (algo => this%algo)
946 class is (propagator_t)
947 iter = this%iteration%counter()
948
949 call td_write_iter(this%td%write_handler, this%namespace, this%space, this%outp, this%gr, &
950 this%st, this%hm, this%ions, this%ext_partners, this%hm%kick, this%ks, algo%dt, iter, this%mc, &
951 this%td%recalculate_gs, this%dmp%adiabatic_st)
953 if (this%outp%anything_now(iter)) then ! output
954 call td_write_output(this%namespace, this%space, this%gr, this%st, this%hm, this%ks, &
955 this%outp, this%ions, this%ext_partners, iter, algo%dt)
956 end if
957 ! This is written as an exception to avoid modifying the args of `td_write_output`
958 ! TODO(Alex) Implement IO registry class
959 if (this%wannier%options%td_method /= td_wannier_method_none) then
960 call this%wannier%write_iter(this%namespace, this%outp, iter, this%ions, this%kpoints)
961 end if
962 end select
963
964 call profiling_out(trim(this%namespace%get())//":"//"OUTPUT_WRITE")
966 end subroutine electrons_output_write
967
968 ! ---------------------------------------------------------
969 subroutine electrons_output_finish(this)
970 class(electrons_t), intent(inout) :: this
971
973
975 end subroutine electrons_output_finish
976
977 ! ---------------------------------------------------------
978 logical function electrons_process_is_slave(this) result(is_slave)
979 class(electrons_t), intent(in) :: this
980
982
983 is_slave = multicomm_is_slave(this%mc)
984
986 end function electrons_process_is_slave
987
988 ! ---------------------------------------------------------
989 subroutine electrons_exec_end_of_timestep_tasks(this, prop)
990 class(electrons_t), intent(inout) :: this
991 class(propagator_t), intent(in) :: prop
992
993 logical :: stopping
994 logical :: generate
995 logical :: update_energy_
996 integer :: nt
997 real(real64) :: time
998 type(gauge_field_t), pointer :: gfield
999
1001 call profiling_in(trim(this%namespace%get())//":"//"END_OF_TIMESTEP")
1002
1003 stopping = .false.
1004
1005 nt = this%td%iter
1006 ! this is the time at the end of the timestep, as required in all routines here
1007 time = prop%dt*nt
1008 update_energy_ = .true.
1009
1010 !Apply mask absorbing boundaries
1011 if (this%hm%abs_boundaries%abtype == mask_absorbing) call zvmask(this%gr, this%hm, this%st)
1012
1013 !Photoelectron stuff
1014 if (this%td%pesv%calc_spm .or. this%td%pesv%calc_mask .or. this%td%pesv%calc_flux) then
1015 call pes_calc(this%td%pesv, this%namespace, this%space, this%gr, this%st, &
1016 prop%dt, nt, this%gr%der, this%hm%kpoints, this%ext_partners, stopping)
1017 end if
1018
1019 ! For BOMD, we do not want the lines below to be executed
1020 select type(prop)
1021 type is(propagator_bomd_t)
1022 call profiling_out(trim(this%namespace%get())//":"//"END_OF_TIMESTEP")
1024 return
1025 end select
1026
1027 ! The propagation of the ions and the gauge field is currently done here.
1028 ! TODO: this code is to be moved to their own systems at some point
1029 generate = .false.
1030 if (this%td%ions_dyn%is_active()) then
1031 if (.not. this%ions_propagated) then
1032 call propagation_ops_elec_propagate_ions_and_cell(this%gr, this%hm, this%st, this%namespace, this%space, &
1033 this%td%ions_dyn, this%ions, this%mc, abs(nt*prop%dt), this%td%ions_dyn%ionic_scale*prop%dt)
1034 generate = .true.
1035 end if
1036 end if
1037
1038 gfield => list_get_gauge_field(this%ext_partners)
1039 if(associated(gfield)) then
1040 if (gauge_field_is_propagated(gfield) .and. .not. this%ions_propagated) then
1042 end if
1043 end if
1044
1045 if (generate .or. this%ions%has_time_dependent_species()) then
1046 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
1047 this%ext_partners, this%st, time = abs(nt*prop%dt))
1048 end if
1049
1050 call v_ks_calc(this%ks, this%namespace, this%space, this%hm, this%st, this%ions, this%ext_partners, &
1051 calc_eigenval = update_energy_, time = abs(nt*prop%dt), calc_energy = update_energy_)
1052
1053 if (update_energy_) then
1054 call energy_calc_total(this%namespace, this%space, this%hm, this%gr, this%st, this%ext_partners, iunit = -1)
1055 end if
1056
1057 ! Recalculate forces, update velocities...
1058 if (this%td%ions_dyn%ions_move() .or. this%outp%what(option__output__forces) &
1059 .or. this%td%write_handler%out(out_separate_forces)%write) then
1060 call forces_calculate(this%gr, this%namespace, this%ions, this%hm, this%ext_partners, &
1061 this%st, this%ks, t = abs(nt*prop%dt), dt = prop%dt)
1062 end if
1063
1064 if (this%td%ions_dyn%cell_relax() .or. this%outp%what(option__output__stress)) then
1065 call stress_calculate(this%namespace, this%gr, this%hm, this%st, this%ions, this%ks, this%ext_partners)
1066 end if
1067
1068 if(this%td%ions_dyn%is_active()) then
1069 call ion_dynamics_propagate_vel(this%td%ions_dyn, this%ions, atoms_moved = generate)
1070 call this%ions%update_kinetic_energy()
1071 end if
1072
1073 if(associated(gfield)) then
1074 if(gauge_field_is_propagated(gfield)) then
1075 call gauge_field_get_force(gfield, this%gr, this%st%d%spin_channels, this%st%current, this%ks%xc%lrc)
1077 end if
1078 end if
1079
1080 !We update the occupation matrices
1081 call lda_u_update_occ_matrices(this%hm%lda_u, this%namespace, this%gr, this%st, this%hm%phase, this%hm%energy)
1082
1083 ! this is needed to be compatible with the code in td_*
1084 this%td%iter = this%td%iter + 1
1085
1086 call profiling_out(trim(this%namespace%get())//":"//"END_OF_TIMESTEP")
1089
1090 ! ---------------------------------------------------------
1091 subroutine electrons_restart_write_data(this)
1092 class(electrons_t), intent(inout) :: this
1093
1094 integer :: ierr
1095
1097 call profiling_in(trim(this%namespace%get())//":"//"RESTART_WRITE")
1098
1099 select type (algo => this%algo)
1100 class is (propagator_t)
1101 call td_write_data(this%td%write_handler)
1102 call td_dump(this%td, this%namespace, this%space, this%gr, this%st, this%hm, &
1103 this%ks, this%ext_partners, this%iteration%counter(), ierr)
1104 if (ierr /= 0) then
1105 message(1) = "Unable to write time-dependent restart information."
1106 call messages_warning(1, namespace=this%namespace)
1107 end if
1108
1109 ! TODO: this is here because of legacy reasons and should be moved to the output framework
1110 call pes_output(this%td%pesv, this%namespace, this%space, this%gr, this%st, this%iteration%counter(), &
1111 this%outp, algo%dt, this%ions)
1112
1113 if (this%wannier%options%td_method /= td_wannier_method_none) then
1114 call this%wannier%restart_write_data(this%namespace, this%mc, this%gr)
1115 end if
1116 end select
1117
1118 call profiling_out(trim(this%namespace%get())//":"//"RESTART_WRITE")
1120 end subroutine electrons_restart_write_data
1121
1122 ! ---------------------------------------------------------
1123 ! this function returns true if restart data could be read
1124 logical function electrons_restart_read_data(this)
1125 class(electrons_t), intent(inout) :: this
1126
1127 logical :: from_scratch
1128
1130 call profiling_in(trim(this%namespace%get())//":"//"RESTART_READ")
1131
1132 select type (algo => this%algo)
1133 class is (propagator_t)
1134 from_scratch = .false.
1135 call td_load_restart_from_td(this%td, this%namespace, this%space, this%mc, this%gr, &
1136 this%ext_partners, this%st, this%ks, this%hm, from_scratch)
1137
1138 if (.not. from_scratch .and. this%wannier%options%td_method /= td_wannier_method_none) then
1139 call this%wannier%restart_read_data(this%namespace, this%mc, this%gr)
1140 end if
1141
1142 call td_set_from_scratch(this%td, from_scratch)
1143
1144 class is (minimizer_algorithm_t)
1145 from_scratch = .false.
1146 call electrons_gs_load_from_restart(this%namespace, this%scf, this%gr, this%mc, this%st, this%hm, &
1147 this%ks, this%space, this%ions, this%ext_partners,from_scratch)
1148
1149 ! electrons_gs_initialize still knows about fromScratch.
1150 assert(.false.)
1151 end select
1152
1153 if (from_scratch) then
1154 ! restart data could not be loaded
1156 else
1157 ! restart data could be loaded
1159 end if
1160
1161 call profiling_out(trim(this%namespace%get())//":"//"RESTART_READ")
1163 end function electrons_restart_read_data
1164
1165 !----------------------------------------------------------
1166 subroutine electrons_update_kinetic_energy(this)
1167 class(electrons_t), intent(inout) :: this
1168
1170
1171 if (states_are_real(this%st)) then
1172 this%kinetic_energy = denergy_calc_electronic(this%namespace, this%hm, this%gr%der, this%st, terms = term_kinetic)
1173 else
1174 this%kinetic_energy = zenergy_calc_electronic(this%namespace, this%hm, this%gr%der, this%st, terms = term_kinetic)
1175 end if
1176
1178
1179 end subroutine electrons_update_kinetic_energy
1180
1181 ! ---------------------------------------------------------
1182 subroutine get_fields_from_interaction(this, time)
1183 class(electrons_t), intent(inout) :: this
1184 real(real64), intent(in) :: time
1185
1187 real(real64), allocatable :: field_tmp(:, :)
1188
1190
1191 if (this%hm%mxll%coupling_mode == no_maxwell_coupling) then
1193 return
1194 end if
1195
1196 assert(this%gr%box%dim == 3)
1197
1198 safe_allocate(field_tmp(1:this%gr%np, 1:this%gr%box%dim))
1199 this%hm%mxll%e_field = m_zero
1200 this%hm%mxll%b_field = m_zero
1201 this%hm%mxll%vec_pot = m_zero
1202
1203 ! interpolate field from interaction
1204 call iter%start(this%interactions)
1205 do while (iter%has_next())
1206 select type (interaction => iter%get_next())
1207 class is (mxll_e_field_to_matter_t)
1208 call interaction%interpolate(time, field_tmp)
1209 call lalg_axpy(this%gr%np, 3, m_one, field_tmp, this%hm%mxll%e_field)
1210 class is (mxll_vec_pot_to_matter_t)
1211 call interaction%interpolate(time, field_tmp)
1212 call lalg_axpy(this%gr%np, 3, m_one, field_tmp, this%hm%mxll%vec_pot)
1213 class is (mxll_b_field_to_matter_t)
1214 call interaction%interpolate(time, field_tmp)
1215 call lalg_axpy(this%gr%np, 3, m_one, field_tmp, this%hm%mxll%b_field)
1216 end select
1217 end do
1218
1219 safe_deallocate_a(field_tmp)
1221
1222 end subroutine get_fields_from_interaction
1223
1224
1226 subroutine electrons_ground_state_run_system(sys, from_scratch)
1227 class(electrons_t), intent(inout) :: sys
1228 logical, intent(inout) :: from_scratch
1229
1231
1232 call electrons_ground_state_run(sys%namespace, sys%mc, sys%gr, sys%ions, &
1233 sys%ext_partners, sys%st, sys%ks, sys%hm, sys%outp, sys%space, from_scratch)
1234
1236
1238
1239
1240 subroutine electrons_finalize(sys)
1241 type(electrons_t), intent(inout) :: sys
1242
1243 type(partner_iterator_t) :: iter
1244 class(interaction_partner_t), pointer :: partner
1245
1246 push_sub(electrons_finalize)
1247
1248 if (associated(sys%algo)) then
1249 select type (algo => sys%algo)
1250 class is (propagator_t)
1251 call td_end_run(sys%td, sys%st, sys%hm, sys%dmp)
1252 call td_end(sys%td)
1253 class is(minimizer_algorithm_t)
1254 call electrons_gs_cleanup(sys%ks, sys%scf, sys%rdm, sys%st, sys%hm)
1255 end select
1256 end if
1257
1258 if (sys%ks%theory_level /= independent_particles) then
1259 call poisson_async_end(sys%hm%psolver, sys%mc)
1260 end if
1262 call iter%start(sys%ext_partners)
1263 do while (iter%has_next())
1264 partner => iter%get_next()
1265 safe_deallocate_p(partner)
1266 end do
1267 call sys%ext_partners%empty()
1268
1269 safe_deallocate_p(sys%xc_interaction)
1270
1271 call hamiltonian_elec_end(sys%hm)
1272
1273 nullify(sys%gfield)
1274 nullify(sys%lasers)
1275
1276 call multicomm_end(sys%mc)
1278 call sys%dipole%end()
1279
1280 call v_ks_end(sys%ks)
1281
1282 call states_elec_end(sys%st)
1283
1284 deallocate(sys%ions)
1285 safe_deallocate_p(sys%photons)
1286
1287 call kpoints_end(sys%kpoints)
1288
1289 call grid_end(sys%gr)
1290
1291 call system_end(sys)
1292
1293 pop_sub(electrons_finalize)
1294 end subroutine electrons_finalize
1295
1296
1297end module electrons_oct_m
1298
1299!! Local Variables:
1300!! mode: f90
1301!! coding: utf-8
1302!! End:
constant times a vector plus a vector
Definition: lalg_basic.F90:173
integer, parameter, public mask_absorbing
This module defines the abstract interfact for algorithm factories.
This module implements the basic elements defining algorithms.
Definition: algorithm.F90:143
character(len=algo_label_len), parameter, public iteration_done
Definition: algorithm.F90:174
This module handles the calculation mode.
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
integer, parameter, public p_strategy_serial
single domain, all states, k-points on a single processor
integer, parameter, public p_strategy_states
parallelization in states
subroutine, public current_calculate(this, namespace, gr, hm, space, st)
Compute total electronic current density.
Definition: current.F90:372
subroutine, public current_init(this, namespace)
Definition: current.F90:180
This module implements a calculator for the density and defines related functions.
Definition: density.F90:122
This modules implements the dipole moment of the matter system.
Definition: dipole.F90:110
A set of subroutines for performing the parts of a ground state calculation with an electrons system....
subroutine, public electrons_ground_state_run(namespace, mc, gr, ions, ext_partners, st, ks, hm, outp, space, fromScratch)
Run a ground state calculation for a system of electrons.
subroutine, public electrons_gs_allocate_wavefunctions(namespace, gr, st, hm, scf, ks, ions)
subroutine, public electrons_gs_initialize(namespace, scf, rdm, gr, mc, st, hm, ions, ks, space, ext_partners, fromScratch)
subroutine, public electrons_gs_load_from_restart(namespace, scf, gr, mc, st, hm, ks, space, ions, ext_partners, fromScratch)
subroutine, public electrons_gs_cleanup(ks, scf, rdm, st, hm)
subroutine electrons_initialize(this)
Definition: electrons.F90:695
logical function electrons_restart_read_data(this)
Definition: electrons.F90:1220
logical function electrons_process_is_slave(this)
Definition: electrons.F90:1074
subroutine electrons_init_interaction(this, interaction)
Definition: electrons.F90:417
subroutine electrons_finalize(sys)
Definition: electrons.F90:1336
subroutine electrons_exec_end_of_timestep_tasks(this, prop)
Definition: electrons.F90:1085
logical function electrons_do_algorithmic_operation(this, operation, updated_quantities)
Definition: electrons.F90:741
subroutine electrons_new_algorithm(this, factory)
Definition: electrons.F90:662
subroutine electrons_output_write(this)
Definition: electrons.F90:1033
subroutine get_fields_from_interaction(this, time)
Definition: electrons.F90:1278
subroutine electrons_algorithm_start(this)
Definition: electrons.F90:721
subroutine electrons_output_finish(this)
Definition: electrons.F90:1065
subroutine electrons_output_start(this)
Definition: electrons.F90:1024
subroutine electrons_init_parallelization(this)
Definition: electrons.F90:481
subroutine electrons_init_interaction_as_partner(partner, interaction)
Definition: electrons.F90:984
subroutine electrons_ground_state_run_system(sys, from_scratch)
Run a ground state calculation for a system of electrons.
Definition: electrons.F90:1322
subroutine electrons_update_kinetic_energy(this)
Definition: electrons.F90:1262
logical function electrons_is_tolerance_reached(this, tol)
Definition: electrons.F90:941
class(electrons_t) function, pointer electrons_constructor(namespace, grp, calc_mode_id)
@ brief Instantiate an instance of an electrons system
Definition: electrons.F90:295
subroutine electrons_copy_quantities_to_interaction(partner, interaction)
Definition: electrons.F90:1002
subroutine electrons_restart_write_data(this)
Definition: electrons.F90:1187
subroutine electrons_update_quantity(this, label)
Definition: electrons.F90:953
subroutine, public elf_init(namespace)
Definition: elf.F90:146
subroutine, public energy_calc_total(namespace, space, hm, gr, st, ext_partners, iunit, full)
This subroutine calculates the total energy of the system. Basically, it adds up the KS eigenvalues,...
real(real64) function, public zenergy_calc_electronic(namespace, hm, der, st, terms)
real(real64) function, public denergy_calc_electronic(namespace, hm, der, st, terms)
type(gauge_field_t) function, pointer, public list_get_gauge_field(partners)
This module implements the field transfer.
subroutine, public forces_calculate(gr, namespace, ions, hm, ext_partners, st, ks, vhxc_old, t, dt)
Definition: forces.F90:341
subroutine, public gauge_field_get_force(this, gr, spin_channels, current, lrc)
subroutine, public gauge_field_do_algorithmic_operation(this, operation, dt, time)
subroutine, public gauge_field_check_symmetries(this, kpoints)
logical pure function, public gauge_field_is_propagated(this)
logical pure function, public gauge_field_is_used(this)
real(real64), parameter, public m_two
Definition: global.F90:202
real(real64), parameter, public m_zero
Definition: global.F90:200
integer, parameter, public independent_particles
Theory level.
Definition: global.F90:250
integer, parameter, public generalized_kohn_sham_dft
Definition: global.F90:250
integer, parameter, public kohn_sham_dft
Definition: global.F90:250
real(real64), parameter, public m_half
Definition: global.F90:206
real(real64), parameter, public m_one
Definition: global.F90:201
This module implements the underlying real-space grid.
Definition: grid.F90:119
subroutine, public grid_init_stage_1(gr, namespace, space, grp, symm, latt, n_sites, site_position, variable_cell)
First stage of the grid initialization.
Definition: grid.F90:197
subroutine, public grid_init_stage_2(gr, namespace, space, mc, qvector)
Second stage of the grid initialization.
Definition: grid.F90:483
subroutine, public grid_end(gr)
finalize a grid object
Definition: grid.F90:510
integer, parameter, public term_kinetic
subroutine, public zvmask(mesh, hm, st)
subroutine, public hamiltonian_elec_end(hm)
subroutine, public hamiltonian_elec_epot_generate(this, namespace, space, gr, ions, ext_partners, st, time)
subroutine, public hamiltonian_elec_init(hm, namespace, space, gr, ions, ext_partners, st, theory_level, xc, mc, kpoints, need_exchange, xc_photons)
integer, parameter, public mxll_vec_pot_to_matter
integer, parameter, public mxll_b_field_to_matter
integer, parameter, public mxll_e_field_to_matter
integer, parameter, public current_to_mxll_field
This module defines the abstract interaction_t class, and some auxiliary classes for interactions.
This module defines classes and functions for interaction partners.
subroutine, public ion_dynamics_propagate_vel(this, ions, atoms_moved)
subroutine, public kpoints_end(this)
Definition: kpoints.F90:1059
subroutine, public kpoints_init(this, namespace, symm, dim, periodic_dim, latt)
Definition: kpoints.F90:416
subroutine, public kpoints_to_absolute(latt, kin, kout)
Definition: kpoints.F90:1137
A module to handle KS potential, without the external potential.
subroutine, public lasers_check_symmetries(this, kpoints)
Definition: lasers.F90:558
subroutine, public lasers_parse_external_fields(this)
Definition: lasers.F90:247
subroutine, public lasers_generate_potentials(this, mesh, space, latt)
Definition: lasers.F90:446
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, phase, energy)
Definition: lda_u.F90:894
System information (time, memory, sysname)
Definition: loct.F90:117
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine, public mesh_check_symmetries(mesh, symm, periodic_dim)
Definition: mesh.F90:836
integer function, public mesh_nearest_point(mesh, pos, dmin, rankmin)
Returns the index of the point which is nearest to a given vector position pos.
Definition: mesh.F90:387
real(real64) pure function, public mesh_global_memory(mesh)
Definition: mesh.F90:792
real(real64) pure function, public mesh_local_memory(mesh)
Definition: mesh.F90:803
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
Definition: messages.F90:898
character(len=512), private msg
Definition: messages.F90:167
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:525
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1000
subroutine, public messages_new_line()
Definition: messages.F90:1089
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:162
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:410
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1040
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
Definition: messages.F90:594
This module implements the basic minimizer framework.
character(len=algo_label_len), parameter, public gs_scf_start
character(len=algo_label_len), parameter, public gs_scf_finish
character(len=algo_label_len), parameter, public gs_scf_iteration
general module for modelmb particles
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
subroutine, public multicomm_end(mc)
Definition: multicomm.F90:706
subroutine, public multicomm_init(mc, namespace, base_grp, mode_para, n_processes, index_range, min_range)
create index and domain communicators
Definition: multicomm.F90:273
logical pure function, public multicomm_is_slave(this)
Definition: multicomm.F90:846
integer, parameter, public length_gauge_dipole
integer, parameter, public no_maxwell_coupling
integer, parameter, public velocity_gauge_dipole
integer, parameter, public multipolar_expansion
integer, parameter, public full_minimal_coupling
Maxwell-field-to-matter interactions.
integer, parameter, public mxll_field_trans
this module contains the low-level part of the output system
Definition: output_low.F90:117
this module contains the output system
Definition: output.F90:117
logical function, public output_need_exchange(outp)
Definition: output.F90:855
subroutine, public output_init(outp, namespace, space, st, gr, nst, ks)
Definition: output.F90:206
logical function, public parse_is_defined(namespace, name)
Definition: parser.F90:463
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:623
subroutine, public pes_calc(pes, namespace, space, mesh, st, dt, iter, der, kpoints, ext_partners, stopping)
Definition: pes.F90:271
subroutine, public pes_output(pes, namespace, space, gr, st, iter, outp, dt, ions)
Definition: pes.F90:297
subroutine, public poisson_async_init(this, mc)
Definition: poisson.F90:1238
subroutine, public poisson_slave_work(this, namespace)
Definition: poisson.F90:1266
subroutine, public poisson_async_end(this, mc)
Definition: poisson.F90:1250
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
subroutine, public propagation_ops_elec_restore_ions(wo, ions_dyn, ions)
subroutine, public propagation_ops_elec_propagate_gauge_field(wo, gfield, dt, time, save_gf)
subroutine, public propagation_ops_elec_propagate_ions_and_cell(gr, hm, st, namespace, space, ions_dyn, ions, mc, time, dt_ions)
subroutine, public propagation_ops_elec_update_hamiltonian(namespace, space, st, mesh, hm, ext_partners, time)
subroutine, public propagation_ops_elec_interpolate_get(hm, vks_old)
subroutine, public propagation_ops_elec_fuse_density_exp_apply(te, namespace, st, gr, hm, dt, dt2, op)
subroutine, public propagation_ops_elec_move_ions(wo, gr, hm, st, namespace, space, ions_dyn, ions, ext_partners, mc, time, dt, save_pos)
subroutine, public propagation_ops_elec_exp_apply(te, namespace, st, mesh, hm, dt, op)
character(len=algo_label_len), parameter, public aetrs_start
character(len=algo_label_len), parameter, public aetrs_finish
character(len=algo_label_len), parameter, public aetrs_extrapolate
character(len=algo_label_len), parameter, public aetrs_first_half
character(len=algo_label_len), parameter, public aetrs_second_half
character(len=algo_label_len), parameter, public bomd_start
character(len=algo_label_len), parameter, public bomd_elec_scf
character(len=algo_label_len), parameter, public bomd_finish
character(len=algo_label_len), parameter, public expmid_extrapolate
character(len=algo_label_len), parameter, public expmid_finish
character(len=algo_label_len), parameter, public expmid_start
character(len=algo_label_len), parameter, public expmid_propagate
This module implements the basic propagator framework.
Definition: propagator.F90:119
character(len=30), parameter, public verlet_compute_acc
type(algorithmic_operation_t), parameter, public op_verlet_compute_acc
character(len=30), parameter, public verlet_update_pos
type(algorithmic_operation_t), parameter, public op_verlet_compute_vel
character(len=30), parameter, public verlet_compute_vel
This module defines the quantity_t class and the IDs for quantities, which can be exposed by a system...
Definition: quantity.F90:140
Implementation details for regridding.
Definition: regridding.F90:172
subroutine, public scf_finish(scf, namespace, space, gr, ions, ext_partners, st, ks, hm, iter, outp)
Definition: scf.F90:1305
subroutine, public scf_start(scf, namespace, gr, ions, st, ks, hm, outp, verbosity)
Preparation of the SCF cycle.
Definition: scf.F90:698
integer, parameter, public verb_compact
Definition: scf.F90:206
subroutine, public scf_init(scf, namespace, gr, ions, st, mc, hm, space)
Definition: scf.F90:259
subroutine, public scf_end(scf)
Definition: scf.F90:562
subroutine, public scf_run(scf, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, verbosity, iters_done, restart_dump)
Legacy version of the SCF code.
Definition: scf.F90:843
subroutine, public scf_iter(scf, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, iter, outp, restart_dump)
Definition: scf.F90:889
logical function, public scf_iter_finish(scf, namespace, space, gr, ions, st, ks, hm, iter, outp, iters_done)
Definition: scf.F90:1226
This module is intended to contain "only mathematical" functions and procedures.
Definition: sort.F90:119
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
real(real64) function, public states_elec_wfns_memory(st, mesh)
return the memory usage of a states_elec_t object
subroutine, public states_elec_distribute_nodes(st, namespace, mc)
Distribute states over the processes for states parallelization.
subroutine, public states_elec_densities_init(st, gr)
subroutine, public states_elec_end(st)
finalize the states_elec_t object
subroutine, public kpoints_distribute(this, mc)
distribute k-points over the nodes in the corresponding communicator
subroutine, public states_elec_exec_init(st, namespace, mc)
Further initializations.
subroutine, public states_elec_init(st, namespace, space, valence_charge, kpoints, calc_mode_id)
Initialize a new states_elec_t object.
subroutine, public states_elec_allocate_current(st, space, mesh)
This module implements the calculation of the stress tensor.
Definition: stress.F90:120
subroutine, public stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
This computes the total stress on the lattice.
Definition: stress.F90:188
subroutine, public symmetries_use_compatible_nonsymmorphic(this, ll, namespace)
Detect if some non-symmorphic operations are compatible with the real-space grid If yes,...
Definition: symmetries.F90:811
This module implements the abstract system type.
Definition: system.F90:120
subroutine, public system_algorithm_start(this)
Definition: system.F90:1023
subroutine, public system_end(this)
Definition: system.F90:1152
subroutine, public system_new_algorithm(this, factory)
Definition: system.F90:948
Definition: td.F90:116
subroutine, public td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, dmp, from_scratch)
Definition: td.F90:929
subroutine, public td_end(td)
Definition: td.F90:650
subroutine, public td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
Definition: td.F90:1250
subroutine, public td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
Definition: td.F90:585
subroutine, public td_init(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp, dmp)
Definition: td.F90:239
logical function, public td_get_from_scratch(td)
Definition: td.F90:1585
subroutine, public td_set_from_scratch(td, from_scratch)
Definition: td.F90:1596
subroutine, public td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
Definition: td.F90:1389
subroutine, public td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
Definition: td.F90:619
subroutine, public td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, from_scratch)
Definition: td.F90:1214
subroutine, public td_end_run(td, st, hm, dmp)
Definition: td.F90:665
subroutine, public td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
Definition: td_write.F90:1286
subroutine, public td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs, dmp_st)
Definition: td_write.F90:1069
subroutine, public td_write_data(writ)
Definition: td_write.F90:1252
integer, parameter, public out_separate_forces
Definition: td_write.F90:204
This module defines the unit system, used for input and output.
type(unit_t), public unit_megabytes
For large amounts of data (natural code units are bytes)
subroutine, public v_ks_end(ks)
Definition: v_ks.F90:599
subroutine, public v_ks_calc(ks, namespace, space, hm, st, ions, ext_partners, calc_eigenval, time, calc_energy, calc_current, force_semilocal)
Definition: v_ks.F90:719
subroutine, public v_ks_init(ks, namespace, gr, st, ions, mc, space, kpoints)
Definition: v_ks.F90:251
Wannier module.
Definition: wannier.F90:108
Wannier options module.
integer, parameter, public td_wannier_method_none
Definition: xc.F90:120
integer, parameter, public oep_level_none
the OEP levels
Definition: xc_oep.F90:174
Abstract class for the algorithm factories.
Descriptor of one algorithmic operation.
Definition: algorithm.F90:165
Class to transfer a current to a Maxwell field.
Extension of space that contains the knowledge of the spin dimension.
Class describing the electron system.
Definition: electrons.F90:222
class defining the field_transfer interaction
These class extend the list and list iterator to make an interaction list.
abstract interaction class
abstract class for general interaction partners
surrogate interaction class to avoid circular dependencies between modules.
Abstract class implementing minimizers.
class to transfer a Maxwell B field to a matter system
class to transfer a Maxwell electric field to a medium
class to transfer a Maxwell vector potential to a medium
Implements a propagator for Approximate ETRS.
Implements a propagator for Born-Oppenheimer molecular dynamics.
Implements the explicit exponential midpoint propagator (without predictor-corrector)
Abstract class implementing propagators.
Definition: propagator.F90:144
Systems (system_t) can expose quantities that can be used to calculate interactions with other system...
Definition: quantity.F90:173
Abstract class for systems.
Definition: system.F90:175
Main object containing all Wannier-related data and methods.
Definition: wannier.F90:150
int true(void)