System: Electrons
The electron_t
is currently in the process of being refactored. In the end, this class shall describe the electrons alone, which are interacting
with ions, external fields, etc. through interactions. Also the electron-electron interaction, described according to the various theory levels (see TheoryLevel) are implemented through a so-called intra-interaction.
Definition of "electrons_t"
type, extends(system_t) :: electrons_t
! Components are public by default
type(electron_space_t) :: space
class(ions_t), pointer :: ions => NULL() !< the ion component of the system
type(photons_t), pointer :: photons => null()
type(grid_t) :: gr !< the mesh
type(states_elec_t) :: st !< the states
type(v_ks_t) :: ks !< the Kohn-Sham potentials
type(output_t) :: outp !< the output
type(multicomm_t) :: mc !< index and domain communicators
type(hamiltonian_elec_t) :: hm !< the Hamiltonian
type(td_t) :: td !< everything related to time propagation
type(current_t) :: current_calculator
type(dipole_t) :: dipole !< total dipole of electrons and ions
type(scf_t) :: scf !< SCF for BOMD
type(kpoints_t) :: kpoints !< the k-points
logical :: generate_epot
type(states_elec_t) :: st_copy !< copy of the states
! At the moment this is not treated as an external potential
class(lasers_t), pointer :: lasers => null() !< lasers
class(gauge_field_t), pointer :: gfield => null() !< gauge field
! List with all the external partners
! This will become a list of interactions in the future
type(partner_list_t) :: ext_partners
!TODO: have a list of self interactions
type(xc_interaction_t), pointer :: xc_interaction => null()
logical :: ions_propagated = .false.
contains
procedure :: init_interaction => electrons_init_interaction
procedure :: init_parallelization => electrons_init_parallelization
procedure :: init_algorithm => electrons_init_algorithm
procedure :: initial_conditions => electrons_initial_conditions
procedure :: do_algorithmic_operation => electrons_do_algorithmic_operation
procedure :: is_tolerance_reached => electrons_is_tolerance_reached
procedure :: update_quantity => electrons_update_quantity
procedure :: init_interaction_as_partner => electrons_init_interaction_as_partner
procedure :: copy_quantities_to_interaction => electrons_copy_quantities_to_interaction
procedure :: output_start => electrons_output_start
procedure :: output_write => electrons_output_write
procedure :: output_finish => electrons_output_finish
procedure :: process_is_slave => electrons_process_is_slave
procedure :: restart_write_data => electrons_restart_write_data
procedure :: restart_read_data => electrons_restart_read_data
procedure :: update_kinetic_energy => electrons_update_kinetic_energy
procedure :: propagation_start => electrons_propagation_start
final :: electrons_finalize
end type electrons_t
Definition of the constructor
function electrons_constructor(namespace, generate_epot) result(sys)
class(electrons_t), pointer :: sys
type(namespace_t), intent(in) :: namespace
logical, optional, intent(in) :: generate_epot
integer :: iatom
type(lattice_vectors_t) :: latt_inp
logical :: has_photons
PUSH_SUB_WITH_PROFILE(electrons_constructor)
allocate(sys)
sys%namespace = namespace
call messages_obsolete_variable(sys%namespace, 'SystemName')
sys%space = electron_space_t(sys%namespace)
call sys%space%write_info(sys%namespace)
if (sys%space%has_mixed_periodicity()) then
call messages_experimental('Support for mixed periodicity systems')
end if
sys%ions => ions_t(sys%namespace, latt_inp=latt_inp)
call grid_init_stage_1(sys%gr, sys%namespace, sys%space, sys%ions%symm, latt_inp, sys%ions%natoms, sys%ions%pos)
if (sys%space%is_periodic()) then
call sys%ions%latt%write_info(sys%namespace)
end if
! Sanity check for atomic coordinates
do iatom = 1, sys%ions%natoms
if (.not. sys%gr%box%contains_point(sys%ions%pos(:, iatom))) then
if (sys%space%periodic_dim /= sys%space%dim) then
! FIXME: This could fail for partial periodicity systems
! because contains_point is too strict with atoms close to
! the upper boundary to the cell.
write(message(1), '(a,i5,a)') "Atom ", iatom, " is outside the box."
call messages_warning(1, namespace=sys%namespace)
end if
end if
end do
! we need k-points for periodic systems
call kpoints_init(sys%kpoints, sys%namespace, sys%gr%symm, sys%space%dim, sys%space%periodic_dim, sys%ions%latt)
call states_elec_init(sys%st, sys%namespace, sys%space, sys%ions%val_charge(), sys%kpoints)
call sys%st%write_info(sys%namespace)
! if independent particles in N dimensions are being used, need to initialize them
! after masses are set to 1 in grid_init_stage_1 -> derivatives_init
call modelmb_copy_masses (sys%st%modelmbparticles, sys%gr%der%masses)
call elf_init(sys%namespace)
sys%generate_epot = optional_default(generate_epot, .true.)
call sys%dipole%init(sys%space)
sys%supported_interactions_as_partner = [CURRENT_TO_MXLL_FIELD]
sys%quantities(CURRENT)%updated_on_demand = .true.
sys%quantities(DIPOLE)%updated_on_demand = .true.
call current_init(sys%current_calculator, sys%namespace)
!%Variable EnablePhotons
!%Type logical
!%Default no
!%Section Hamiltonian
!%Description
!% This variable can be used to enable photons in several types of calculations.
!% It can be used to activate the one-photon OEP formalism.
!% In the case of CalculationMode = casida, it enables photon modes as
!% described in ACS Photonics 2019, 6, 11, 2757-2778.
!% Finally, if set to yes when solving the ferquency-dependent Sternheimer
!% equation, the photons are coupled to the electronic subsystem.
!%End
call messages_obsolete_variable(namespace, 'OEPPtX', 'EnablePhotons')
call parse_variable(namespace, 'EnablePhotons', .false., has_photons)
if (has_photons) then
call messages_experimental("EnablePhotons = yes")
sys%photons => photons_t(sys%namespace)
else
nullify(sys%photons)
end if
POP_SUB_WITH_PROFILE(electrons_constructor)
end function electrons_constructor