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
38 use elf_oct_m
42 use forces_oct_m
44 use global_oct_m
45 use grid_oct_m
55 use ions_oct_m
56 use kick_oct_m
61 use lasers_oct_m
62 use lda_u_oct_m
63 use loct_oct_m
64 use mesh_oct_m
67 use mpi_oct_m
74 use output_oct_m
76 use parser_oct_m
77 use pes_oct_m
92 use rdmft_oct_m
94 use scf_oct_m
95 use space_oct_m
99 use stress_oct_m
100 use sort_oct_m
101 use system_oct_m
102 use td_oct_m
105 use v_ks_oct_m
106 use xc_oct_m
107 use xc_f03_lib_m
108 use xc_oep_oct_m
112
113 implicit none
114
115 private
116 public :: &
118
125 type, extends(system_t) :: electrons_t
126 ! Components are public by default
127 type(electron_space_t) :: space
128 class(ions_t), pointer :: ions => null()
129 type(photons_t), pointer :: photons => null()
130 type(grid_t) :: gr
131 type(states_elec_t) :: st
132 type(v_ks_t) :: ks
133 type(output_t) :: outp
134 type(multicomm_t) :: mc
135 type(hamiltonian_elec_t) :: hm
136 type(td_t) :: td
137 type(current_t) :: current_calculator
138 type(dipole_t) :: dipole
139 type(scf_t) :: scf
140 type(rdm_t) :: rdm
141
142 type(kpoints_t) :: kpoints
143
144 logical :: generate_epot
145
146 type(states_elec_t) :: st_copy
147
148 ! At the moment this is not treated as an external potential
149 class(lasers_t), pointer :: lasers => null()
150 class(gauge_field_t), pointer :: gfield => null()
151
152 ! List with all the external partners
153 ! This will become a list of interactions in the future
154 type(partner_list_t) :: ext_partners
155
156 !TODO: have a list of self interactions
157 type(xc_interaction_t), pointer :: xc_interaction => null()
158
159 logical :: ions_propagated = .false.
160 contains
161 procedure :: init_interaction => electrons_init_interaction
162 procedure :: init_parallelization => electrons_init_parallelization
163 procedure :: new_algorithm => electrons_new_algorithm
164 procedure :: initialize => electrons_initialize
165 procedure :: do_algorithmic_operation => electrons_do_algorithmic_operation
166 procedure :: is_tolerance_reached => electrons_is_tolerance_reached
167 procedure :: update_quantity => electrons_update_quantity
168 procedure :: init_interaction_as_partner => electrons_init_interaction_as_partner
169 procedure :: copy_quantities_to_interaction => electrons_copy_quantities_to_interaction
170 procedure :: output_start => electrons_output_start
171 procedure :: output_write => electrons_output_write
172 procedure :: output_finish => electrons_output_finish
173 procedure :: process_is_slave => electrons_process_is_slave
174 procedure :: restart_write_data => electrons_restart_write_data
175 procedure :: restart_read_data => electrons_restart_read_data
176 procedure :: update_kinetic_energy => electrons_update_kinetic_energy
177 procedure :: algorithm_start => electrons_algorithm_start
178 procedure :: ground_state_run => electrons_ground_state_run_system
179 final :: electrons_finalize
180 end type electrons_t
181
182 interface electrons_t
183 procedure electrons_constructor
184 end interface electrons_t
185
186contains
187
192 function electrons_constructor(namespace, calc_mode_id) result(sys)
193 class(electrons_t), pointer :: sys
194 type(namespace_t), intent(in) :: namespace
195 integer, optional, intent(in) :: calc_mode_id
196
197 integer :: iatom
198 type(lattice_vectors_t) :: latt_inp
199 logical :: has_photons
200
201 push_sub_with_profile(electrons_constructor)
202
203 allocate(sys)
204
205 sys%namespace = namespace
206
207 call messages_obsolete_variable(sys%namespace, 'SystemName')
208
209 sys%space = electron_space_t(sys%namespace)
210 call sys%space%write_info(sys%namespace)
211 if (sys%space%has_mixed_periodicity()) then
212 call messages_experimental('Support for mixed periodicity systems')
213 end if
214
215 sys%ions => ions_t(sys%namespace, latt_inp=latt_inp)
216
217 call grid_init_stage_1(sys%gr, sys%namespace, sys%space, sys%ions%symm, latt_inp, sys%ions%natoms, sys%ions%pos)
218
219 if (sys%space%is_periodic()) then
220 call sys%ions%latt%write_info(sys%namespace)
221 end if
223 ! Sanity check for atomic coordinates
224 do iatom = 1, sys%ions%natoms
225 ! Using the same tolerance of fold_into_cell to avoid problems with mixed periodicities
226 ! as the default tolerance of contains_point is too tight
227 if (.not. sys%gr%box%contains_point(sys%ions%pos(:, iatom), tol=1.0e-6_real64)) then
228 if (sys%space%periodic_dim /= sys%space%dim) then
229 write(message(1), '(a,i5,a)') "Atom ", iatom, " is outside the box."
230 call messages_warning(1, namespace=sys%namespace)
231 end if
232 end if
233 end do
235 ! we need k-points for periodic systems
236 call kpoints_init(sys%kpoints, sys%namespace, sys%gr%symm, sys%space%dim, sys%space%periodic_dim, sys%ions%latt)
238 call states_elec_init(sys%st, sys%namespace, sys%space, sys%ions%val_charge(), sys%kpoints, calc_mode_id)
239 call sys%st%write_info(sys%namespace)
240
241 ! if independent particles in N dimensions are being used, need to initialize them
242 ! after masses are set to 1 in grid_init_stage_1 -> derivatives_init
243 call sys%st%modelmbparticles%copy_masses(sys%gr%der%masses)
245 call elf_init(sys%namespace)
246
247 if (present(calc_mode_id)) then
248 sys%generate_epot = calc_mode_id /= option__calculationmode__dummy
249 else
250 sys%generate_epot = .true.
251 end if
253 call sys%dipole%init(sys%space)
255 sys%supported_interactions_as_partner = [current_to_mxll_field]
257 call sys%quantities%add(quantity_t("wavefunctions", updated_on_demand = .false.))
258 call sys%quantities%add(quantity_t("current", updated_on_demand = .true., parents=["wavefunctions"]))
259 call sys%quantities%add(quantity_t("dipole", updated_on_demand = .true., parents=["wavefunctions"]))
260 call current_init(sys%current_calculator, sys%namespace)
262 !%Variable EnablePhotons
263 !%Type logical
264 !%Default no
265 !%Section Hamiltonian
266 !%Description
267 !% This variable can be used to enable photons in several types of calculations.
268 !% It can be used to activate the one-photon OEP formalism.
269 !% In the case of CalculationMode = casida, it enables photon modes as
270 !% described in ACS Photonics 2019, 6, 11, 2757-2778.
271 !% Finally, if set to yes when solving the ferquency-dependent Sternheimer
272 !% equation, the photons are coupled to the electronic subsystem.
273 !%End
274 call messages_obsolete_variable(namespace, 'OEPPtX', 'EnablePhotons')
275 call parse_variable(namespace, 'EnablePhotons', .false., has_photons)
276 if (has_photons) then
277 call messages_experimental("EnablePhotons = yes")
278 sys%photons => photons_t(sys%namespace)
279 else
280 nullify(sys%photons)
281 end if
282
283 pop_sub_with_profile(electrons_constructor)
284 end function electrons_constructor
285
286 ! ---------------------------------------------------------
287 subroutine electrons_init_interaction(this, interaction)
288 class(electrons_t), target, intent(inout) :: this
289 class(interaction_t), intent(inout) :: interaction
290
291 real(real64) :: dmin
292 integer :: rankmin, depth
293 logical :: mxll_interaction_present
294 logical :: calc_dipole
295
296 push_sub(electrons_init_interactions)
297
298 mxll_interaction_present = .false.
299 select type (interaction)
301 call interaction%init(this%gr, 3)
302 mxll_interaction_present = .true.
303 interaction%type = mxll_field_trans
305 call interaction%init(this%gr, 3)
306 mxll_interaction_present = .true.
308 call interaction%init(this%gr, 3)
309 mxll_interaction_present = .true.
310 class default
311 message(1) = "Trying to initialize an unsupported interaction by the electrons."
312 call messages_fatal(1, namespace=this%namespace)
313 end select
314
315 if (mxll_interaction_present) then
316 calc_dipole = any(this%hm%mxll%coupling_mode == &
318
319 if (calc_dipole) then
320 assert(this%space%periodic_dim == 0)
321 this%hm%mxll%calc_field_dip = .true.
322 this%hm%mxll%center_of_mass(1:3) = this%ions%center_of_mass()
323 this%hm%mxll%center_of_mass_ip = mesh_nearest_point(this%gr, this%hm%mxll%center_of_mass, dmin, rankmin)
324 this%hm%mxll%center_of_mass_rankmin = rankmin
325 end if
326 end if
327
328 ! set interpolation depth for field-transfer interactions
329 select type (interaction)
330 class is (field_transfer_t)
331 ! interpolation depth depends on the propagator
332 select type (algo => this%algo)
333 type is (propagator_exp_mid_t)
334 depth = 3
335 type is (propagator_aetrs_t)
336 depth = 3
337 type is (propagator_bomd_t)
338 depth = 1
339 class default
340 message(1) = "The chosen algorithm does not yet support interaction interpolation"
341 call messages_fatal(1, namespace=this%namespace)
342 end select
343
344 call interaction%init_interpolation(depth, interaction%label)
345 end select
346
347 pop_sub(electrons_init_interactions)
348 end subroutine electrons_init_interaction
349
350 ! ---------------------------------------------------------
351 subroutine electrons_init_parallelization(this, grp)
352 class(electrons_t), intent(inout) :: this
353 type(mpi_grp_t), intent(in) :: grp
354
355 integer(int64) :: index_range(4)
356 real(real64) :: mesh_global, mesh_local, wfns
357 integer :: idir
358 real(real64) :: spiral_q(3), spiral_q_red(3)
359 type(block_t) :: blk
360
362
363 call mpi_grp_copy(this%grp, grp)
364
365 ! store the ranges for these two indices (serves as initial guess
366 ! for parallelization strategy)
367 index_range(1) = this%gr%np_global ! Number of points in mesh
368 index_range(2) = this%st%nst ! Number of states
369 index_range(3) = this%st%nik ! Number of k-points
370 index_range(4) = 100000 ! Some large number
371
372 ! create index and domain communicators
373 call multicomm_init(this%mc, this%namespace, this%grp, calc_mode_par, &
374 mpi_world%size, index_range, (/ 5000, 1, 1, 1 /))
375
376 call this%ions%partition(this%mc)
377 call kpoints_distribute(this%st, this%mc)
378 call states_elec_distribute_nodes(this%st, this%namespace, this%mc)
379
380
381 if (parse_is_defined(this%namespace, 'TDMomentumTransfer') .or. &
382 parse_is_defined(this%namespace, 'TDReducedMomentumTransfer')) then
383 if (parse_block(this%namespace, 'TDMomentumTransfer', blk) == 0) then
384 do idir = 1, this%space%dim
385 call parse_block_float(blk, 0, idir - 1, spiral_q(idir))
386 end do
387 else if(parse_block(this%namespace, 'TDReducedMomentumTransfer', blk) == 0) then
388 do idir = 1, this%space%dim
389 call parse_block_float(blk, 0, idir - 1, spiral_q_red(idir))
390 end do
391 call kpoints_to_absolute(this%kpoints%latt, spiral_q_red(1:this%space%dim), spiral_q(1:this%space%dim))
392 end if
393 call parse_block_end(blk)
394 call grid_init_stage_2(this%gr, this%namespace, this%space, this%mc, spiral_q)
395 else
396 call grid_init_stage_2(this%gr, this%namespace, this%space, this%mc)
397 end if
398
399 if (this%st%symmetrize_density) then
400 call mesh_check_symmetries(this%gr, this%gr%symm, this%ions%space%periodic_dim)
401 end if
402
403 call output_init(this%outp, this%namespace, this%space, this%st, this%gr, this%st%nst, this%ks)
404 call states_elec_densities_init(this%st, this%gr)
405 call states_elec_exec_init(this%st, this%namespace, this%mc)
406
407 if (associated(this%photons)) then
408 this%ks%has_photons = .true.
409 end if
410
411 call v_ks_init(this%ks, this%namespace, this%gr, this%st, this%ions, this%mc, this%space, this%kpoints)
412 if (this%ks%theory_level == kohn_sham_dft .or. this%ks%theory_level == generalized_kohn_sham_dft) then
413 this%xc_interaction => xc_interaction_t(this)
414 end if
415
416 ! For the moment the photons are initialized here
417
418 if(this%ks%has_photons) then
419 this%ks%pt => this%photons%modes
420 ! Temporary creation that should go in the system initialization later
421 call photon_mode_set_n_electrons(this%photons%modes, this%st%qtot)
422 write(message(1), '(a,i5,a)') 'Happy to have ', this%photons%modes%nmodes, ' photon modes with us.'
423 call messages_info(1)
424 call mf_init(this%ks%pt_mx, this%gr, this%st, this%ions, this%ks%pt)
425 ! OEP for photons
426 if(bitand(this%ks%xc_family, xc_family_oep) /= 0 .and. this%ks%xc%functional(func_x,1)%id == xc_oep_x) then
427 this%ks%oep_photon%level = this%ks%oep%level
428 call xc_oep_photon_init(this%ks%oep_photon, this%namespace, this%ks%xc_family, this%gr, this%st, this%mc, this%space)
429 else
430 this%ks%oep_photon%level = oep_level_none
431 end if
432
433 end if
434
435
436 ! Temporary place for the initialization of the lasers
437 this%lasers => lasers_t(this%namespace)
438 call lasers_parse_external_fields(this%lasers)
439 call lasers_generate_potentials(this%lasers, this%gr, this%space, this%ions%latt)
440 if(this%lasers%no_lasers > 0) then
441 call this%ext_partners%add(this%lasers)
442 call lasers_check_symmetries(this%lasers, this%kpoints)
443 else
444 deallocate(this%lasers)
445 end if
447 ! Temporary place for the initialization of the gauge field
448 this%gfield => gauge_field_t(this%namespace, this%ions%latt%rcell_volume)
449 if(gauge_field_is_used(this%gfield)) then
450 call this%ext_partners%add(this%gfield)
451 call gauge_field_check_symmetries(this%gfield, this%kpoints)
452 else
453 deallocate(this%gfield)
454 end if
455
456 call hamiltonian_elec_init(this%hm, this%namespace, this%space, this%gr, this%ions, this%ext_partners, &
457 this%st, this%ks%theory_level, this%ks%xc, this%mc, this%kpoints, &
458 need_exchange = output_need_exchange(this%outp) .or. this%ks%oep%level /= oep_level_none, &
459 xc_photons = this%ks%xc_photons )
460
461 if (this%hm%pcm%run_pcm .and. this%mc%par_strategy /= p_strategy_serial .and. this%mc%par_strategy /= p_strategy_states) then
462 call messages_experimental('Parallel in domain calculations with PCM')
463 end if
464
465 ! Print memory requirements
466 call messages_print_with_emphasis(msg='Approximate memory requirements', namespace=this%namespace)
467
468 mesh_global = mesh_global_memory(this%gr)
469 mesh_local = mesh_local_memory(this%gr)
470
471 call messages_write('Mesh')
472 call messages_new_line()
473 call messages_write(' global :')
474 call messages_write(mesh_global, units = unit_megabytes, fmt = '(f10.1)')
475 call messages_new_line()
476 call messages_write(' local :')
477 call messages_write(mesh_local, units = unit_megabytes, fmt = '(f10.1)')
478 call messages_new_line()
479 call messages_write(' total :')
480 call messages_write(mesh_global + mesh_local, units = unit_megabytes, fmt = '(f10.1)')
481 call messages_new_line()
482 call messages_info(namespace=this%namespace)
483
484 wfns = states_elec_wfns_memory(this%st, this%gr)
485 call messages_write('States')
486 call messages_new_line()
487 call messages_write(' real :')
488 call messages_write(wfns, units = unit_megabytes, fmt = '(f10.1)')
489 call messages_write(' (par_kpoints + par_states + par_domains)')
490 call messages_new_line()
491 call messages_write(' complex :')
492 call messages_write(2.0_8*wfns, units = unit_megabytes, fmt = '(f10.1)')
493 call messages_write(' (par_kpoints + par_states + par_domains)')
494 call messages_new_line()
495 call messages_info(namespace=this%namespace)
496
497 call messages_print_with_emphasis(namespace=this%namespace)
498
499 if (this%generate_epot) then
500 message(1) = "Info: Generating external potential"
501 call messages_info(1, namespace=this%namespace)
502 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
503 this%ext_partners, this%st)
504 message(1) = " done."
505 call messages_info(1, namespace=this%namespace)
506 end if
507
508 if (this%ks%theory_level /= independent_particles) then
509 call poisson_async_init(this%hm%psolver, this%mc)
510 ! slave nodes do not call the calculation routine
511 if (multicomm_is_slave(this%mc)) then
512 !for the moment we only have one type of slave
513 call poisson_slave_work(this%hm%psolver, this%namespace)
514 end if
515 end if
516
517 allocate(this%supported_interactions(0))
518 select case (this%hm%mxll%coupling_mode)
520 this%supported_interactions = [this%supported_interactions, mxll_e_field_to_matter]
522 this%supported_interactions = [this%supported_interactions, mxll_vec_pot_to_matter]
523 if (this%hm%mxll%add_zeeman) then
524 this%supported_interactions = [this%supported_interactions, mxll_b_field_to_matter]
525 end if
527 if (this%hm%mxll%add_electric_dip .or. this%hm%mxll%add_electric_quad) then
528 this%supported_interactions = [this%supported_interactions, mxll_e_field_to_matter]
529 end if
530 if (this%hm%mxll%add_magnetic_dip) then
531 this%supported_interactions = [this%supported_interactions, mxll_b_field_to_matter]
532 end if
534 ! Do not initialize any interaction with Maxwell
535 case default
536 message(1) = "Unknown maxwell-matter coupling"
537 call messages_fatal(1, namespace=this%namespace)
538 end select
539
541 end subroutine electrons_init_parallelization
542
543 ! ---------------------------------------------------------
544 subroutine electrons_new_algorithm(this, factory)
545 class(electrons_t), intent(inout) :: this
546 class(algorithm_factory_t), intent(in) :: factory
547
549
550 call system_new_algorithm(this, factory)
551
552 select type (algo => this%algo)
553 class is (propagator_t)
554
555 call td_init(this%td, this%namespace, this%space, this%gr, this%ions, this%st, this%ks, &
556 this%hm, this%ext_partners, this%outp)
557
558 ! this corresponds to the first part of td_init_run
559 call td_allocate_wavefunctions(this%td, this%namespace, this%mc, this%gr, this%ions, this%st, &
560 this%hm, this%space)
561 call td_init_gaugefield(this%td, this%namespace, this%gr, this%st, this%ks, this%hm, &
562 this%ext_partners, this%space)
563
564 class is (minimizer_algorithm_t)
565
566 call electrons_gs_allocate_wavefunctions(this%namespace, this%gr, this%st, this%hm, this%scf, this%ks, &
567 this%ions)
568
569 class default
570 assert(.false.)
571 end select
572
574 end subroutine electrons_new_algorithm
575
576 ! ---------------------------------------------------------
577 subroutine electrons_initialize(this)
578 class(electrons_t), intent(inout) :: this
579
580 push_sub(electrons_initialize)
581
582 select type (algo => this%algo)
583 class is (propagator_t)
584 call td_set_from_scratch(this%td, .true.)
585 call td_load_restart_from_gs(this%td, this%namespace, this%space, this%mc, this%gr, &
586 this%ext_partners, this%st, this%ks, this%hm)
587
588 class is (minimizer_algorithm_t)
589
590 call electrons_gs_initialize(this%namespace, this%scf, this%rdm, this%gr, this%mc, this%st, &
591 this%hm, this%ions, this%ks, this%space, this%ext_partners, fromscratch=.true.)
592 class default
593 assert(.false.)
594 end select
595
596 pop_sub(electrons_initialize)
597 end subroutine electrons_initialize
598
599 ! ---------------------------------------------------------
600 subroutine electrons_algorithm_start(this)
601 class(electrons_t), intent(inout) :: this
602
604
605 call system_algorithm_start(this)
606
607 select type (algo => this%algo)
608 class is (propagator_t)
609
610 ! additional initialization needed for electrons
611 call td_init_with_wavefunctions(this%td, this%namespace, this%space, this%mc, this%gr, this%ions, &
612 this%ext_partners, this%st, this%ks, this%hm, this%outp, td_get_from_scratch(this%td))
613
614 end select
615
617 end subroutine electrons_algorithm_start
618
619 ! ---------------------------------------------------------
620 logical function electrons_do_algorithmic_operation(this, operation, updated_quantities) result(done)
621 class(electrons_t), intent(inout) :: this
622 class(algorithmic_operation_t), intent(in) :: operation
623 character(len=:), allocatable, intent(out) :: updated_quantities(:)
624
625 logical :: update_energy_
626 type(gauge_field_t), pointer :: gfield
627 real(real64) :: time
628 integer :: iter
629
631 call profiling_in(trim(this%namespace%get())//":"//trim(operation%id))
632
633 update_energy_ = .true.
634
635 ! kick at t > 0 still missing!
636
637 done = .true.
638 select type (algo => this%algo)
639 class is (propagator_t)
640 time = algo%iteration%value()
641 select case (operation%id)
642 case (aetrs_first_half)
643 ! propagate half of the time step with H(time)
644 call get_fields_from_interaction(this, time)
645 call propagation_ops_elec_update_hamiltonian(this%namespace, this%space, this%st, this%gr, &
646 this%hm, this%ext_partners, time)
647 call propagation_ops_elec_exp_apply(this%td%tr%te, this%namespace, this%st, this%gr, this%hm, m_half*algo%dt)
648
649 case (aetrs_extrapolate)
650 ! Do the extrapolation of the Hamiltonian
651 ! First the extrapolation of the potential
652 call this%hm%ks_pot%interpolation_new(this%td%tr%vks_old, time+algo%dt, algo%dt)
653
654 !Get the potentials from the interpolator
655 call propagation_ops_elec_interpolate_get(this%hm, this%td%tr%vks_old)
656
657 ! Second the ions and gauge field which later on will be treated as extrapolation
658 ! of interactions, but this is not yet possible
659
660 ! move the ions to time t
661 call propagation_ops_elec_move_ions(this%td%tr%propagation_ops_elec, this%gr, this%hm, &
662 this%st, this%namespace, this%space, this%td%ions_dyn, this%ions, this%ext_partners, &
663 this%mc, time+algo%dt, algo%dt)
664
665 !Propagate gauge field
666 gfield => list_get_gauge_field(this%ext_partners)
667 if(associated(gfield)) then
668 call propagation_ops_elec_propagate_gauge_field(this%td%tr%propagation_ops_elec, gfield, &
669 algo%dt, time+algo%dt)
670 end if
671
672 !Update Hamiltonian and current
673 call get_fields_from_interaction(this, time+algo%dt)
674 call propagation_ops_elec_update_hamiltonian(this%namespace, this%space, this%st, this%gr, &
675 this%hm, this%ext_partners, time+algo%dt)
676
677 case (aetrs_second_half)
678 !Do the time propagation for the second half of the time step
679 call propagation_ops_elec_fuse_density_exp_apply(this%td%tr%te, this%namespace, this%st, &
680 this%gr, this%hm, m_half*algo%dt)
681
682 updated_quantities = ["wavefunctions"]
683
684 case (expmid_extrapolate)
685 ! the half step of this propagator screws with the gauge field kick
686 gfield => list_get_gauge_field(this%ext_partners)
687 if(associated(gfield)) then
688 assert(gauge_field_is_propagated(gfield) .eqv. .false.)
689 end if
690
691 ! Do the extrapolation of the Hamiltonian
692 ! First the extrapolation of the potential
693 call this%hm%ks_pot%interpolation_new(this%td%tr%vks_old, time+algo%dt, algo%dt)
694
695 ! get the potentials from the interpolator
696 call this%hm%ks_pot%interpolate_potentials(this%td%tr%vks_old, 3, time+algo%dt, algo%dt, time + algo%dt/m_two)
697
698 ! Second the ions which later on will be treated as extrapolation of interactions,
699 ! but this is not yet possible
700 ! move the ions to the half step
701 call propagation_ops_elec_move_ions(this%td%tr%propagation_ops_elec, this%gr, this%hm, this%st, &
702 this%namespace, this%space, this%td%ions_dyn, this%ions, this%ext_partners, &
703 this%mc, time + m_half*algo%dt, m_half*algo%dt, save_pos=.true.)
704
705 call get_fields_from_interaction(this, time + m_half*algo%dt)
706 call propagation_ops_elec_update_hamiltonian(this%namespace, this%space, this%st, this%gr, &
707 this%hm, this%ext_partners, time + m_half*algo%dt)
708
709 case (expmid_propagate)
710 ! Do the actual propagation step
711 call propagation_ops_elec_fuse_density_exp_apply(this%td%tr%te, this%namespace, this%st, &
712 this%gr, this%hm, algo%dt)
713
714 ! restore to previous time
715 call propagation_ops_elec_restore_ions(this%td%tr%propagation_ops_elec, this%td%ions_dyn, this%ions)
716
717 updated_quantities = ["wavefunctions"]
718
719 case (bomd_start)
720 call scf_init(this%scf, this%namespace, this%gr, this%ions, this%st, this%mc, this%hm, this%space)
721 ! the ions are propagated inside the propagation step already, so no need to do it at the end
722 this%ions_propagated = .true.
723
724 case (verlet_update_pos)
725 ! move the ions to time t
726 call propagation_ops_elec_propagate_ions_and_cell(this%gr, this%hm, this%st, this%namespace, this%space, &
727 this%td%ions_dyn, this%ions, this%mc, time+algo%dt, algo%dt)
728
729 case (bomd_elec_scf)
730 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
731 this%ext_partners, this%st, time = time+algo%dt)
732 ! now calculate the eigenfunctions
733 call scf_run(this%scf, this%namespace, this%space, this%mc, this%gr, this%ions, &
734 this%ext_partners, this%st, this%ks, this%hm, verbosity = verb_compact)
735 ! TODO: Check if this call is realy needed. - NTD
736 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
737 this%ext_partners, this%st, time = time+algo%dt)
738
739 ! update Hamiltonian and eigenvalues (fermi is *not* called)
740 call v_ks_calc(this%ks, this%namespace, this%space, this%hm, this%st, this%ions, this%ext_partners, &
741 calc_eigenval = .true., time = time+algo%dt, calc_energy = .true.)
742
743 ! Get the energies.
744 call energy_calc_total(this%namespace, this%space, this%hm, this%gr, this%st, this%ext_partners, iunit = -1)
745
746 updated_quantities = ["wavefunctions"]
747
748 case (verlet_compute_acc)
749 ! Do nothing, forces are computing in scf_run
750 if (this%td%ions_dyn%cell_relax()) then
751 assert(this%scf%calc_stress)
752 call this%td%ions_dyn%update_stress(this%ions%space, this%st%stress_tensors%total, &
753 this%ions%latt%rlattice, this%ions%latt%rcell_volume)
754 end if
755
756 case (verlet_compute_vel)
757 call ion_dynamics_propagate_vel(this%td%ions_dyn, this%ions)
758 ! TODO: Check if this call is realy needed. - NTD
759 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
760 this%ext_partners, this%st, time = time+algo%dt)
761 call this%ions%update_kinetic_energy()
762
763 case (expmid_start)
764 this%ions_propagated = .false.
765
766 case (aetrs_start)
767 ! the ions are propagated inside the propagation step already, so no need to do it at the end
768 this%ions_propagated = .true.
769
770 case (iteration_done)
772 done = .false.
773
774 case (bomd_finish)
775 call scf_end(this%scf)
776
778 case default
779 done = .false.
780 end select
781
782 class is(minimizer_algorithm_t)
783
784 ! Clocks starts at 0....
785 iter = nint(this%iteration%value()) + 1
786
787 select case(operation%id)
788 case (gs_scf_start)
789 call scf_start(this%scf, this%namespace, this%gr, this%ions, this%st, this%ks, this%hm, this%outp)
790
791 case (gs_scf_iteration)
792
793 call scf_iter(this%scf, this%namespace, this%space, this%mc, this%gr, this%ions, &
794 this%ext_partners, this%st, this%ks, this%hm, iter, outp = this%outp, &
795 restart_dump=this%scf%restart_dump)
796
797 algo%converged = scf_iter_finish(this%scf, this%namespace, this%space, this%gr, this%ions,&
798 this%st, this%ks, this%hm, iter, outp = this%outp)
799
800 updated_quantities = ["wavefunctions"]
801
802 case (gs_scf_finish)
803
804 ! Here iteration is iter-1, as the clock ticked before SCF_FINISH
805 call scf_finish(this%scf, this%namespace, this%space, this%gr, this%ions, &
806 this%ext_partners, this%st, this%ks, this%hm, iter-1, outp = this%outp)
807
808 case default
809 done = .false.
810 end select
811 class default
812 done = .false.
813 end select
814
815 call profiling_out(trim(this%namespace%get())//":"//trim(operation%id))
818
819 ! ---------------------------------------------------------
820 logical function electrons_is_tolerance_reached(this, tol) result(converged)
821 class(electrons_t), intent(in) :: this
822 real(real64), intent(in) :: tol
823
825
826 converged = .false.
827
830
831 ! ---------------------------------------------------------
832 subroutine electrons_update_quantity(this, label)
833 class(electrons_t), intent(inout) :: this
834 character(len=*), intent(in) :: label
835
836 class(quantity_t), pointer :: quantity
837
839 call profiling_in(trim(this%namespace%get())//":"//"UPDATE_QUANTITY")
840
841 quantity => this%quantities%get(label)
842 if(associated(quantity)) then
843 assert(quantity%updated_on_demand)
844 endif
845
846 select case (label)
847 case ("current")
848 call states_elec_allocate_current(this%st, this%space, this%gr)
849 call current_calculate(this%current_calculator, this%namespace, this%gr, &
850 this%hm, this%space, this%st)
851 case ("dipole")
852 call this%dipole%calculate(this%gr, this%ions, this%st)
853 case default
854 message(1) = "Incompatible quantity: "//trim(label)//"."
855 call messages_fatal(1, namespace=this%namespace)
856 end select
857
858 call profiling_out(trim(this%namespace%get())//":"//"UPDATE_QUANTITY")
860 end subroutine electrons_update_quantity
861
862 ! ---------------------------------------------------------
863 subroutine electrons_init_interaction_as_partner(partner, interaction)
864 class(electrons_t), intent(in) :: partner
865 class(interaction_surrogate_t), intent(inout) :: interaction
866
868
869 select type (interaction)
871 call interaction%init_from_partner(partner%gr, partner%space, partner%namespace)
872 class default
873 message(1) = "Unsupported interaction."
874 call messages_fatal(1, namespace=partner%namespace)
875 end select
876
879
880 ! ---------------------------------------------------------
881 subroutine electrons_copy_quantities_to_interaction(partner, interaction)
882 class(electrons_t), intent(inout) :: partner
883 class(interaction_surrogate_t), intent(inout) :: interaction
884
886 call profiling_in(trim(partner%namespace%get())//":"//"COPY_QUANTITY_INTER")
887
888 select type (interaction)
890 assert(allocated(partner%st%current))
891 interaction%partner_field(:,:) = partner%st%current(1:partner%gr%np,:,1)
892 call interaction%do_mapping()
893 class default
894 message(1) = "Unsupported interaction."
895 call messages_fatal(1, namespace=partner%namespace)
896 end select
897
898 call profiling_out(trim(partner%namespace%get())//":"//"COPY_QUANTITY_INTER")
901
902 ! ---------------------------------------------------------
903 subroutine electrons_output_start(this)
904 class(electrons_t), intent(inout) :: this
905
906 push_sub(electrons_output_start)
907
909 end subroutine electrons_output_start
910
911 ! ---------------------------------------------------------
912 subroutine electrons_output_write(this)
913 class(electrons_t), intent(inout) :: this
914
915 integer :: iter
916
917 push_sub(electrons_output_write)
918 call profiling_in(trim(this%namespace%get())//":"//"OUTPUT_WRITE")
919
920 select type (algo => this%algo)
921 class is (propagator_t)
922 iter = this%iteration%counter()
923
924 call td_write_iter(this%td%write_handler, this%namespace, this%space, this%outp, this%gr, &
925 this%st, this%hm, this%ions, this%ext_partners, this%hm%kick, this%ks, algo%dt, iter, this%mc, this%td%recalculate_gs)
926
927 if (this%outp%anything_now(iter)) then ! output
928 call td_write_output(this%namespace, this%space, this%gr, this%st, this%hm, this%ks, &
929 this%outp, this%ions, this%ext_partners, iter, algo%dt)
930 end if
931 end select
932
933 call profiling_out(trim(this%namespace%get())//":"//"OUTPUT_WRITE")
935 end subroutine electrons_output_write
936
937 ! ---------------------------------------------------------
938 subroutine electrons_output_finish(this)
939 class(electrons_t), intent(inout) :: this
940
942
944 end subroutine electrons_output_finish
945
946 ! ---------------------------------------------------------
947 logical function electrons_process_is_slave(this) result(is_slave)
948 class(electrons_t), intent(in) :: this
949
951
952 is_slave = multicomm_is_slave(this%mc)
953
955 end function electrons_process_is_slave
956
957 ! ---------------------------------------------------------
959 class(electrons_t), intent(inout) :: this
960 class(propagator_t), intent(in) :: prop
961
962 logical :: stopping
963 logical :: generate
964 logical :: update_energy_
965 integer :: nt
966 real(real64) :: time
967 type(gauge_field_t), pointer :: gfield
968
970 call profiling_in(trim(this%namespace%get())//":"//"END_OF_TIMESTEP")
971
972 stopping = .false.
973
974 nt = this%td%iter
975 ! this is the time at the end of the timestep, as required in all routines here
976 time = prop%dt*nt
977 update_energy_ = .true.
978
979 !Apply mask absorbing boundaries
980 if (this%hm%abs_boundaries%abtype == mask_absorbing) call zvmask(this%gr, this%hm, this%st)
981
982 !Photoelectron stuff
983 if (this%td%pesv%calc_spm .or. this%td%pesv%calc_mask .or. this%td%pesv%calc_flux) then
984 call pes_calc(this%td%pesv, this%namespace, this%space, this%gr, this%st, &
985 prop%dt, nt, this%gr%der, this%hm%kpoints, this%ext_partners, stopping)
986 end if
987
988 ! For BOMD, we do not want the lines below to be executed
989 select type(prop)
990 type is(propagator_bomd_t)
991 call profiling_out(trim(this%namespace%get())//":"//"END_OF_TIMESTEP")
993 return
994 end select
995
996 ! The propagation of the ions and the gauge field is currently done here.
997 ! TODO: this code is to be moved to their own systems at some point
998 generate = .false.
999 if (this%td%ions_dyn%is_active()) then
1000 if (.not. this%ions_propagated) then
1001 call propagation_ops_elec_propagate_ions_and_cell(this%gr, this%hm, this%st, this%namespace, this%space, &
1002 this%td%ions_dyn, this%ions, this%mc, abs(nt*prop%dt), this%td%ions_dyn%ionic_scale*prop%dt)
1003 generate = .true.
1004 end if
1005 end if
1006
1007 gfield => list_get_gauge_field(this%ext_partners)
1008 if(associated(gfield)) then
1009 if (gauge_field_is_propagated(gfield) .and. .not. this%ions_propagated) then
1011 end if
1012 end if
1013
1014 if (generate .or. this%ions%has_time_dependent_species()) then
1015 call hamiltonian_elec_epot_generate(this%hm, this%namespace, this%space, this%gr, this%ions, &
1016 this%ext_partners, this%st, time = abs(nt*prop%dt))
1017 end if
1018
1019 call v_ks_calc(this%ks, this%namespace, this%space, this%hm, this%st, this%ions, this%ext_partners, &
1020 calc_eigenval = update_energy_, time = abs(nt*prop%dt), calc_energy = update_energy_)
1021
1022 if (update_energy_) then
1023 call energy_calc_total(this%namespace, this%space, this%hm, this%gr, this%st, this%ext_partners, iunit = -1)
1024 end if
1025
1026 ! Recalculate forces, update velocities...
1027 if (this%td%ions_dyn%ions_move() .or. this%outp%what(option__output__forces) &
1028 .or. this%td%write_handler%out(out_separate_forces)%write) then
1029 call forces_calculate(this%gr, this%namespace, this%ions, this%hm, this%ext_partners, &
1030 this%st, this%ks, t = abs(nt*prop%dt), dt = prop%dt)
1031 end if
1032
1033 if (this%td%ions_dyn%cell_relax() .or. this%outp%what(option__output__stress)) then
1034 call stress_calculate(this%namespace, this%gr, this%hm, this%st, this%ions, this%ks, this%ext_partners)
1035 end if
1036
1037 if(this%td%ions_dyn%is_active()) then
1038 call ion_dynamics_propagate_vel(this%td%ions_dyn, this%ions, atoms_moved = generate)
1039 call this%ions%update_kinetic_energy()
1040 end if
1041
1042 if(associated(gfield)) then
1043 if(gauge_field_is_propagated(gfield)) then
1044 call gauge_field_get_force(gfield, this%gr, this%st%d%spin_channels, this%st%current, this%ks%xc%lrc)
1046 end if
1047 end if
1048
1049 !We update the occupation matrices
1050 call lda_u_update_occ_matrices(this%hm%lda_u, this%namespace, this%gr, this%st, this%hm%phase, this%hm%energy)
1051
1052 ! this is needed to be compatible with the code in td_*
1053 this%td%iter = this%td%iter + 1
1054
1055 call profiling_out(trim(this%namespace%get())//":"//"END_OF_TIMESTEP")
1058
1059 ! ---------------------------------------------------------
1060 subroutine electrons_restart_write_data(this)
1061 class(electrons_t), intent(inout) :: this
1062
1063 integer :: ierr
1064
1066 call profiling_in(trim(this%namespace%get())//":"//"RESTART_WRITE")
1067
1068 select type (algo => this%algo)
1069 class is (propagator_t)
1070 call td_write_data(this%td%write_handler)
1071 call td_dump(this%td, this%namespace, this%space, this%gr, this%st, this%hm, &
1072 this%ks, this%ext_partners, this%iteration%counter(), ierr)
1073 if (ierr /= 0) then
1074 message(1) = "Unable to write time-dependent restart information."
1075 call messages_warning(1, namespace=this%namespace)
1076 end if
1077
1078 ! TODO: this is here because of legacy reasons and should be moved to the output framework
1079 call pes_output(this%td%pesv, this%namespace, this%space, this%gr, this%st, this%iteration%counter(), &
1080 this%outp, algo%dt, this%ions)
1081 end select
1082
1083 call profiling_out(trim(this%namespace%get())//":"//"RESTART_WRITE")
1085 end subroutine electrons_restart_write_data
1086
1087 ! ---------------------------------------------------------
1088 ! this function returns true if restart data could be read
1089 logical function electrons_restart_read_data(this)
1090 class(electrons_t), intent(inout) :: this
1091
1092 logical :: from_scratch
1093
1095 call profiling_in(trim(this%namespace%get())//":"//"RESTART_READ")
1096
1097 select type (algo => this%algo)
1098 class is (propagator_t)
1099 from_scratch = .false.
1100 call td_load_restart_from_td(this%td, this%namespace, this%space, this%mc, this%gr, &
1101 this%ext_partners, this%st, this%ks, this%hm, from_scratch)
1102 call td_set_from_scratch(this%td, from_scratch)
1103
1104 class is (minimizer_algorithm_t)
1105 from_scratch = .false.
1106 call electrons_gs_load_from_restart(this%namespace, this%scf, this%gr, this%mc, this%st, this%hm, &
1107 this%ks, this%space, this%ions, this%ext_partners,from_scratch)
1108
1109 ! electrons_gs_initialize still knows about fromScratch.
1110 assert(.false.)
1111 end select
1112
1113 if (from_scratch) then
1114 ! restart data could not be loaded
1116 else
1117 ! restart data could be loaded
1119 end if
1120
1121 call profiling_out(trim(this%namespace%get())//":"//"RESTART_READ")
1123 end function electrons_restart_read_data
1124
1125 !----------------------------------------------------------
1126 subroutine electrons_update_kinetic_energy(this)
1127 class(electrons_t), intent(inout) :: this
1128
1130
1131 if (states_are_real(this%st)) then
1132 this%kinetic_energy = denergy_calc_electronic(this%namespace, this%hm, this%gr%der, this%st, terms = term_kinetic)
1133 else
1134 this%kinetic_energy = zenergy_calc_electronic(this%namespace, this%hm, this%gr%der, this%st, terms = term_kinetic)
1135 end if
1136
1138
1139 end subroutine electrons_update_kinetic_energy
1140
1141 ! ---------------------------------------------------------
1142 subroutine get_fields_from_interaction(this, time)
1143 class(electrons_t), intent(inout) :: this
1144 real(real64), intent(in) :: time
1145
1146 type(interaction_iterator_t) :: iter
1147 real(real64), allocatable :: field_tmp(:, :)
1148
1150
1151 if (this%hm%mxll%coupling_mode == no_maxwell_coupling) then
1153 return
1154 end if
1156 safe_allocate(field_tmp(1:this%gr%np, 1:this%gr%box%dim))
1157 this%hm%mxll%e_field = m_zero
1158 this%hm%mxll%b_field = m_zero
1159 this%hm%mxll%vec_pot = m_zero
1160
1161 ! interpolate field from interaction
1162 call iter%start(this%interactions)
1163 do while (iter%has_next())
1164 select type (interaction => iter%get_next())
1165 class is (mxll_e_field_to_matter_t)
1166 call interaction%interpolate(time, field_tmp)
1167 call lalg_axpy(this%gr%np, 3, m_one, field_tmp, this%hm%mxll%e_field)
1168 class is (mxll_vec_pot_to_matter_t)
1169 call interaction%interpolate(time, field_tmp)
1170 call lalg_axpy(this%gr%np, 3, m_one, field_tmp, this%hm%mxll%vec_pot)
1171 class is (mxll_b_field_to_matter_t)
1172 call interaction%interpolate(time, field_tmp)
1173 call lalg_axpy(this%gr%np, 3, m_one, field_tmp, this%hm%mxll%b_field)
1174 end select
1175 end do
1176
1177 safe_deallocate_a(field_tmp)
1179
1180 end subroutine get_fields_from_interaction
1181
1182
1184 subroutine electrons_ground_state_run_system(sys, from_scratch)
1185 class(electrons_t), intent(inout) :: sys
1186 logical, intent(inout) :: from_scratch
1187
1189
1190 call electrons_ground_state_run(sys%namespace, sys%mc, sys%gr, sys%ions, &
1191 sys%ext_partners, sys%st, sys%ks, sys%hm, sys%outp, sys%space, from_scratch)
1192
1194
1196
1197
1198 subroutine electrons_finalize(sys)
1199 type(electrons_t), intent(inout) :: sys
1200
1201 type(partner_iterator_t) :: iter
1202 class(interaction_partner_t), pointer :: partner
1203
1204 push_sub(electrons_finalize)
1205
1206 if (associated(sys%algo)) then
1207 select type (algo => sys%algo)
1208 class is (propagator_t)
1209 call td_end_run(sys%td, sys%st, sys%hm)
1210 call td_end(sys%td)
1211 class is(minimizer_algorithm_t)
1212 call electrons_gs_cleanup(sys%ks, sys%scf, sys%rdm, sys%st, sys%hm)
1213 end select
1214 end if
1215
1216 if (sys%ks%theory_level /= independent_particles) then
1217 call poisson_async_end(sys%hm%psolver, sys%mc)
1218 end if
1219
1220 call iter%start(sys%ext_partners)
1221 do while (iter%has_next())
1222 partner => iter%get_next()
1223 safe_deallocate_p(partner)
1224 end do
1225 call sys%ext_partners%empty()
1226
1227 safe_deallocate_p(sys%xc_interaction)
1228
1229 call hamiltonian_elec_end(sys%hm)
1230
1231 nullify(sys%gfield)
1232 nullify(sys%lasers)
1233
1234 call multicomm_end(sys%mc)
1235
1236 call xc_oep_photon_end(sys%ks%oep_photon)
1237 if (sys%ks%has_photons) then
1238 call mf_end(sys%ks%pt_mx)
1239 end if
1240
1241 call sys%dipole%end()
1242
1243 call v_ks_end(sys%ks)
1244
1245 call states_elec_end(sys%st)
1246
1247 deallocate(sys%ions)
1248 safe_deallocate_p(sys%photons)
1249
1250 call kpoints_end(sys%kpoints)
1251
1252 call grid_end(sys%gr)
1253
1254 call system_end(sys)
1255
1256 pop_sub(electrons_finalize)
1257 end subroutine electrons_finalize
1258
1259
1260end module electrons_oct_m
1261
1262!! Local Variables:
1263!! mode: f90
1264!! coding: utf-8
1265!! 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:371
subroutine, public current_init(this, namespace)
Definition: current.F90:181
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:673
logical function electrons_restart_read_data(this)
Definition: electrons.F90:1185
subroutine electrons_init_parallelization(this, grp)
Definition: electrons.F90:447
logical function electrons_process_is_slave(this)
Definition: electrons.F90:1043
subroutine electrons_init_interaction(this, interaction)
Definition: electrons.F90:383
subroutine electrons_finalize(sys)
Definition: electrons.F90:1294
subroutine electrons_exec_end_of_timestep_tasks(this, prop)
Definition: electrons.F90:1054
logical function electrons_do_algorithmic_operation(this, operation, updated_quantities)
Definition: electrons.F90:716
subroutine electrons_new_algorithm(this, factory)
Definition: electrons.F90:640
subroutine electrons_output_write(this)
Definition: electrons.F90:1008
subroutine get_fields_from_interaction(this, time)
Definition: electrons.F90:1238
subroutine electrons_algorithm_start(this)
Definition: electrons.F90:696
subroutine electrons_output_finish(this)
Definition: electrons.F90:1034
subroutine electrons_output_start(this)
Definition: electrons.F90:999
subroutine electrons_init_interaction_as_partner(partner, interaction)
Definition: electrons.F90:959
subroutine electrons_ground_state_run_system(sys, from_scratch)
Run a ground state calculation for a system of electrons.
Definition: electrons.F90:1280
class(electrons_t) function, pointer electrons_constructor(namespace, calc_mode_id)
@ brief Instantiate an instance of an electrons system
Definition: electrons.F90:288
subroutine electrons_update_kinetic_energy(this)
Definition: electrons.F90:1222
logical function electrons_is_tolerance_reached(this, tol)
Definition: electrons.F90:916
subroutine electrons_copy_quantities_to_interaction(partner, interaction)
Definition: electrons.F90:977
subroutine electrons_restart_write_data(this)
Definition: electrons.F90:1156
subroutine electrons_update_quantity(this, label)
Definition: electrons.F90:928
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:340
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:193
real(real64), parameter, public m_zero
Definition: global.F90:191
integer, parameter, public independent_particles
Theory level.
Definition: global.F90:237
integer, parameter, public generalized_kohn_sham_dft
Definition: global.F90:237
integer, parameter, public kohn_sham_dft
Definition: global.F90:237
real(real64), parameter, public m_half
Definition: global.F90:197
real(real64), parameter, public m_one
Definition: global.F90:192
This module implements the underlying real-space grid.
Definition: grid.F90:119
subroutine, public grid_init_stage_1(gr, namespace, space, symm, latt, n_sites, site_position)
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:471
subroutine, public grid_end(gr)
finalize a grid object
Definition: grid.F90:499
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:1014
subroutine, public kpoints_init(this, namespace, symm, dim, periodic_dim, latt)
Definition: kpoints.F90:324
subroutine, public kpoints_to_absolute(latt, kin, kout)
Definition: kpoints.F90:1033
A module to handle KS potential, without the external potential.
subroutine, public lasers_check_symmetries(this, kpoints)
Definition: lasers.F90:557
subroutine, public lasers_parse_external_fields(this)
Definition: lasers.F90:246
subroutine, public lasers_generate_potentials(this, mesh, space, latt)
Definition: lasers.F90:445
subroutine, public lda_u_update_occ_matrices(this, namespace, mesh, st, phase, energy)
Definition: lda_u.F90:798
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:834
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:385
real(real64) pure function, public mesh_global_memory(mesh)
Definition: mesh.F90:790
real(real64) pure function, public mesh_local_memory(mesh)
Definition: mesh.F90:801
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:1023
subroutine, public messages_new_line()
Definition: messages.F90:1112
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:1063
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
subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
MPI_THREAD_FUNNELED allows for calls to MPI from an OMP region if the thread is the team master.
Definition: mpi.F90:389
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:272
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:147
subroutine, public multicomm_end(mc)
Definition: multicomm.F90:697
logical pure function, public multicomm_is_slave(this)
Definition: multicomm.F90:837
subroutine, public multicomm_init(mc, namespace, base_grp, mode_para, n_node, index_range, min_range)
create index and domain communicators
Definition: multicomm.F90:266
integer, parameter, public mxll_field_trans
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
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:880
subroutine, public output_init(outp, namespace, space, st, gr, nst, ks)
Definition: output.F90:210
logical function, public parse_is_defined(namespace, name)
Definition: parser.F90:455
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:615
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 mf_init(this, gr, st, ions, pt_mode)
subroutine, public mf_end(this)
subroutine, public photon_mode_set_n_electrons(this, qtot)
subroutine, public poisson_async_init(this, mc)
Definition: poisson.F90:1126
subroutine, public poisson_slave_work(this, namespace)
Definition: poisson.F90:1154
subroutine, public poisson_async_end(this, mc)
Definition: poisson.F90:1138
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_exp_apply(te, namespace, st, mesh, hm, dt)
subroutine, public propagation_ops_elec_interpolate_get(hm, vks_old)
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_fuse_density_exp_apply(te, namespace, st, gr, hm, dt, dt2, vmagnus)
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:1259
subroutine, public scf_start(scf, namespace, gr, ions, st, ks, hm, outp, verbosity)
Preparation of the SCF cycle.
Definition: scf.F90:658
integer, parameter, public verb_compact
Definition: scf.F90:206
subroutine, public scf_init(scf, namespace, gr, ions, st, mc, hm, space)
Definition: scf.F90:257
subroutine, public scf_end(scf)
Definition: scf.F90:527
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:801
subroutine, public scf_iter(scf, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, iter, outp, restart_dump)
Definition: scf.F90:847
logical function, public scf_iter_finish(scf, namespace, space, gr, ions, st, ks, hm, iter, outp, iters_done)
Definition: scf.F90:1181
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)
@Brief. 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
This module implements the abstract system type.
Definition: system.F90:120
subroutine, public system_algorithm_start(this)
Definition: system.F90:1022
subroutine, public system_end(this)
Definition: system.F90:1151
subroutine, public system_new_algorithm(this, factory)
Definition: system.F90:947
Definition: td.F90:116
subroutine, public td_end(td)
Definition: td.F90:639
subroutine, public td_load_restart_from_gs(td, namespace, space, mc, gr, ext_partners, st, ks, hm)
Definition: td.F90:1224
subroutine, public td_end_run(td, st, hm)
Definition: td.F90:658
subroutine, public td_init(td, namespace, space, gr, ions, st, ks, hm, ext_partners, outp)
Definition: td.F90:241
subroutine, public td_allocate_wavefunctions(td, namespace, mc, gr, ions, st, hm, space)
Definition: td.F90:574
logical function, public td_get_from_scratch(td)
Definition: td.F90:1566
subroutine, public td_set_from_scratch(td, from_scratch)
Definition: td.F90:1577
subroutine, public td_dump(td, namespace, space, gr, st, hm, ks, ext_partners, iter, ierr)
Definition: td.F90:1355
subroutine, public td_init_gaugefield(td, namespace, gr, st, ks, hm, ext_partners, space)
Definition: td.F90:608
subroutine, public td_init_with_wavefunctions(td, namespace, space, mc, gr, ions, ext_partners, st, ks, hm, outp, from_scratch)
Definition: td.F90:906
subroutine, public td_load_restart_from_td(td, namespace, space, mc, gr, ext_partners, st, ks, hm, from_scratch)
Definition: td.F90:1188
subroutine, public td_write_output(namespace, space, gr, st, hm, ks, outp, ions, ext_partners, iter, dt)
Definition: td_write.F90:1250
subroutine, public td_write_data(writ)
Definition: td_write.F90:1216
subroutine, public td_write_iter(writ, namespace, space, outp, gr, st, hm, ions, ext_partners, kick, ks, dt, iter, mc, recalculate_gs)
Definition: td_write.F90:1043
integer, parameter, public out_separate_forces
Definition: td_write.F90:203
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:631
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:752
subroutine, public v_ks_init(ks, namespace, gr, st, ions, mc, space, kpoints)
Definition: v_ks.F90:254
integer, parameter, public xc_oep_x
Exact exchange.
integer, parameter, public func_x
Definition: xc.F90:116
integer, parameter, public oep_level_none
the OEP levels
Definition: xc_oep.F90:174
subroutine, public xc_oep_photon_init(oep, namespace, family, gr, st, mc, space)
subroutine, public xc_oep_photon_end(oep)
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:220
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.
This is defined even when running serial.
Definition: mpi.F90:144
class to transfer a Maxwell B field to a matter system
class to transfer a Maxwell 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:174
int true(void)