Octopus
ks_potential_oct_m Module Reference

A module to handle KS potential, without the external potential. More...

Detailed Description

A module to handle KS potential, without the external potential.

The object knows how to dump, load, and interpolate its potentials. The main motivation is to hide the data behind some getters/setters, to avoid data getting out of scope

Data Types

type  ks_potential_t
 
type  xc_copied_potentials_t
 

Functions/Subroutines

subroutine ks_potential_init (this, np, np_part, nspin, theory_level, needs_vtau)
 Allocate the memory for the KS potentials. More...
 
subroutine ks_potential_end (this)
 Releases the memory for the KS potentials. More...
 
subroutine ks_potential_set_vtau (this, vtau)
 Set vtau and update the corresponding GPU buffer. More...
 
subroutine ks_potential_update_vtau_buffer (this)
 Update vtau GPU buffer. More...
 
subroutine ks_potential_add_vhxc (this, pot, nspin)
 Adds vHxc to the potential. More...
 
subroutine ks_potential_dump_vhxc (this, restart, space, mesh, ierr)
 Dumps the vhxc potentials. More...
 
subroutine ks_potential_load_vhxc (this, restart, space, mesh, ierr)
 Loads the vhxc potentials. More...
 
subroutine ks_potential_init_interpolation (this, vksold, order)
 Initialize the potential interpolation. More...
 
subroutine ks_potential_run_zero_iter (this, vksold)
 Run zero iter for the interpolation. More...
 
subroutine ks_potential_interpolation_new (this, vksold, current_time, dt)
 New interpolation point for the interpolation. More...
 
subroutine ks_potential_get_interpolated_potentials (this, vksold, history, storage)
 Get the interpolated potentials from history. More...
 
subroutine ks_potential_set_interpolated_potentials (this, vksold, history)
 Set the interpolated potentials to history. More...
 
subroutine ks_potential_interpolate_potentials (this, vksold, order, current_time, dt, interpolation_time)
 Interpolate potentials to a new time. More...
 
subroutine, public vtau_set_vout (field, this)
 
subroutine, public vtau_set_vin (field, this)
 
subroutine, public vtau_get_vnew (field, this)
 
subroutine ks_potential_output_potentials (this, namespace, how, dir, space, mesh, pos, atoms, grp)
 Outputs vh, vxc, and vtau potentials. More...
 
subroutine ks_potential_storage_allocate (this, copy)
 Copy the potentials to a storage object. More...
 
subroutine ks_potential_store_copy (this, copy)
 Copy the potentials to a storage object. More...
 
subroutine ks_potential_restore_copy (this, copy)
 Copy the potentials from a storage object. More...
 
subroutine xc_copied_potentials_copy_vhxc_to_buffer (this, np, nspin, pnp, buffer)
 Copy the vhxc potential to a gpu buffer. More...
 
subroutine, public xc_copied_potentials_end (this)
 Finalizer for the copied potentials. More...
 
real(real64) function ks_potential_check_convergence (this, copy, mesh, rho, qtot)
 Check the convergence of a vhxc for predictor-corrector. More...
 
subroutine ks_potential_perform_interpolation (this, vksold, times, current_time)
 Perform a time interpolation of the potentials. More...
 
subroutine ks_potential_mix_potentials (this, vold, dt)
 Replace vold potentials by 0.5*dt(vold + vhxc) More...
 
subroutine zks_potential_mult_vhxc (this, mf, ispin)
 Multiply a mesh function by vHxc. More...
 
subroutine zks_potential_apply_vtau_psi (this, mesh, d, ispin, psib, vpsib)
 Wrapper to hamiltonian_elec_base_local_sub to hide the data of vtau. More...
 
subroutine zks_potential_current_mass_renormalization (this, gpsi, space_dim, ndim, ispin)
 Nonlocal contribution of vtau for the current. More...
 
subroutine dks_potential_mult_vhxc (this, mf, ispin)
 Multiply a mesh function by vHxc. More...
 
subroutine dks_potential_apply_vtau_psi (this, mesh, d, ispin, psib, vpsib)
 Wrapper to hamiltonian_elec_base_local_sub to hide the data of vtau. More...
 
subroutine dks_potential_current_mass_renormalization (this, gpsi, space_dim, ndim, ispin)
 Nonlocal contribution of vtau for the current. More...
 

Variables

integer, parameter, public independent_particles = 2
 
integer, parameter, public hartree = 1
 
integer, parameter, public hartree_fock = 3
 
integer, parameter, public kohn_sham_dft = 4
 
integer, parameter, public generalized_kohn_sham_dft = 5
 
integer, parameter, public rdmft = 7
 

Function/Subroutine Documentation

◆ ks_potential_init()

subroutine ks_potential_oct_m::ks_potential_init ( class(ks_potential_t), intent(inout)  this,
integer, intent(in)  np,
integer, intent(in)  np_part,
integer, intent(in)  nspin,
integer, intent(in)  theory_level,
logical, intent(in)  needs_vtau 
)
private

Allocate the memory for the KS potentials.

Definition at line 222 of file ks_potential.F90.

◆ ks_potential_end()

subroutine ks_potential_oct_m::ks_potential_end ( class(ks_potential_t), intent(inout)  this)
private

Releases the memory for the KS potentials.

Definition at line 263 of file ks_potential.F90.

◆ ks_potential_set_vtau()

subroutine ks_potential_oct_m::ks_potential_set_vtau ( class(ks_potential_t), intent(inout)  this,
real(real64), dimension(:,:), intent(in)  vtau 
)
private

Set vtau and update the corresponding GPU buffer.

Definition at line 281 of file ks_potential.F90.

◆ ks_potential_update_vtau_buffer()

subroutine ks_potential_oct_m::ks_potential_update_vtau_buffer ( class(ks_potential_t), intent(inout)  this)
private

Update vtau GPU buffer.

Definition at line 297 of file ks_potential.F90.

◆ ks_potential_add_vhxc()

subroutine ks_potential_oct_m::ks_potential_add_vhxc ( class(ks_potential_t), intent(in)  this,
real(real64), dimension(:,:), intent(inout)  pot,
integer, intent(in), optional  nspin 
)
private

Adds vHxc to the potential.

Parameters
[in,out]potOn exit, vHxc has been added

Definition at line 318 of file ks_potential.F90.

◆ ks_potential_dump_vhxc()

subroutine ks_potential_oct_m::ks_potential_dump_vhxc ( class(ks_potential_t), intent(in)  this,
type(restart_t), intent(in)  restart,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
integer, intent(out)  ierr 
)
private

Dumps the vhxc potentials.

Definition at line 349 of file ks_potential.F90.

◆ ks_potential_load_vhxc()

subroutine ks_potential_oct_m::ks_potential_load_vhxc ( class(ks_potential_t), intent(inout)  this,
type(restart_t), intent(in)  restart,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
integer, intent(out)  ierr 
)
private

Loads the vhxc potentials.

Definition at line 438 of file ks_potential.F90.

◆ ks_potential_init_interpolation()

subroutine ks_potential_oct_m::ks_potential_init_interpolation ( class(ks_potential_t), intent(in)  this,
type(potential_interpolation_t), intent(inout)  vksold,
integer, intent(in), optional  order 
)
private

Initialize the potential interpolation.

Definition at line 496 of file ks_potential.F90.

◆ ks_potential_run_zero_iter()

subroutine ks_potential_oct_m::ks_potential_run_zero_iter ( class(ks_potential_t), intent(in)  this,
type(potential_interpolation_t), intent(inout)  vksold 
)
private

Run zero iter for the interpolation.

Definition at line 509 of file ks_potential.F90.

◆ ks_potential_interpolation_new()

subroutine ks_potential_oct_m::ks_potential_interpolation_new ( class(ks_potential_t), intent(inout)  this,
type(potential_interpolation_t), intent(inout)  vksold,
real(real64), intent(in)  current_time,
real(real64), intent(in)  dt 
)
private

New interpolation point for the interpolation.

Definition at line 521 of file ks_potential.F90.

◆ ks_potential_get_interpolated_potentials()

subroutine ks_potential_oct_m::ks_potential_get_interpolated_potentials ( class(ks_potential_t), intent(inout)  this,
type(potential_interpolation_t), intent(inout)  vksold,
integer, intent(in)  history,
type(xc_copied_potentials_t), intent(inout), optional  storage 
)
private

Get the interpolated potentials from history.

If the optional argument storage is present, the data are copied to this one instead

Definition at line 537 of file ks_potential.F90.

◆ ks_potential_set_interpolated_potentials()

subroutine ks_potential_oct_m::ks_potential_set_interpolated_potentials ( class(ks_potential_t), intent(inout)  this,
type(potential_interpolation_t), intent(inout)  vksold,
integer, intent(in)  history 
)
private

Set the interpolated potentials to history.

Definition at line 567 of file ks_potential.F90.

◆ ks_potential_interpolate_potentials()

subroutine ks_potential_oct_m::ks_potential_interpolate_potentials ( class(ks_potential_t), intent(inout)  this,
type(potential_interpolation_t), intent(inout)  vksold,
integer, intent(in)  order,
real(real64), intent(in)  current_time,
real(real64), intent(in)  dt,
real(real64), intent(in)  interpolation_time 
)
private

Interpolate potentials to a new time.

Definition at line 587 of file ks_potential.F90.

◆ vtau_set_vout()

subroutine, public ks_potential_oct_m::vtau_set_vout ( type(mixfield_t), intent(inout)  field,
type(ks_potential_t), intent(in)  this 
)

Definition at line 612 of file ks_potential.F90.

◆ vtau_set_vin()

subroutine, public ks_potential_oct_m::vtau_set_vin ( type(mixfield_t), intent(inout)  field,
type(ks_potential_t), intent(in)  this 
)

Definition at line 624 of file ks_potential.F90.

◆ vtau_get_vnew()

subroutine, public ks_potential_oct_m::vtau_get_vnew ( type(mixfield_t), intent(in)  field,
type(ks_potential_t), intent(inout)  this 
)

Definition at line 636 of file ks_potential.F90.

◆ ks_potential_output_potentials()

subroutine ks_potential_oct_m::ks_potential_output_potentials ( class(ks_potential_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
integer(int64), intent(in)  how,
character(len=*), intent(in)  dir,
class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
real(real64), dimension(:,:), intent(in), optional  pos,
type(atom_t), dimension(:), intent(in), optional  atoms,
type(mpi_grp_t), intent(in), optional  grp 
)
private

Outputs vh, vxc, and vtau potentials.

Parameters
[in]grpthe group that shares the same data, must contain the domains group

Definition at line 650 of file ks_potential.F90.

◆ ks_potential_storage_allocate()

subroutine ks_potential_oct_m::ks_potential_storage_allocate ( class(ks_potential_t), intent(in)  this,
type(xc_copied_potentials_t), intent(inout)  copy 
)
private

Copy the potentials to a storage object.

Definition at line 685 of file ks_potential.F90.

◆ ks_potential_store_copy()

subroutine ks_potential_oct_m::ks_potential_store_copy ( class(ks_potential_t), intent(in)  this,
type(xc_copied_potentials_t), intent(inout)  copy 
)
private

Copy the potentials to a storage object.

Definition at line 704 of file ks_potential.F90.

◆ ks_potential_restore_copy()

subroutine ks_potential_oct_m::ks_potential_restore_copy ( class(ks_potential_t), intent(inout)  this,
type(xc_copied_potentials_t), intent(in)  copy 
)
private

Copy the potentials from a storage object.

Definition at line 722 of file ks_potential.F90.

◆ xc_copied_potentials_copy_vhxc_to_buffer()

subroutine ks_potential_oct_m::xc_copied_potentials_copy_vhxc_to_buffer ( class(xc_copied_potentials_t), intent(in)  this,
integer(int64), intent(in)  np,
integer, intent(in)  nspin,
integer(int64), intent(in)  pnp,
type(accel_mem_t), intent(inout)  buffer 
)
private

Copy the vhxc potential to a gpu buffer.

Definition at line 741 of file ks_potential.F90.

◆ xc_copied_potentials_end()

subroutine, public ks_potential_oct_m::xc_copied_potentials_end ( type(xc_copied_potentials_t), intent(inout)  this)

Finalizer for the copied potentials.

Definition at line 760 of file ks_potential.F90.

◆ ks_potential_check_convergence()

real(real64) function ks_potential_oct_m::ks_potential_check_convergence ( class(ks_potential_t), intent(in)  this,
type(xc_copied_potentials_t), intent(in)  copy,
class(mesh_t), intent(in)  mesh,
real(real64), dimension(:,:), intent(in)  rho,
real(real64), intent(in)  qtot 
)
private

Check the convergence of a vhxc for predictor-corrector.

now check how much the potential changed We multiply by the density to compute the first moment This avoids spurious effects for post-LDA functionals when at the border of the box for isolated systems.

Definition at line 773 of file ks_potential.F90.

◆ ks_potential_perform_interpolation()

subroutine ks_potential_oct_m::ks_potential_perform_interpolation ( class(ks_potential_t), intent(inout)  this,
type(potential_interpolation_t), intent(inout)  vksold,
real(real64), dimension(:), intent(in)  times,
real(real64), intent(in)  current_time 
)
private

Perform a time interpolation of the potentials.

Definition at line 807 of file ks_potential.F90.

◆ ks_potential_mix_potentials()

subroutine ks_potential_oct_m::ks_potential_mix_potentials ( class(ks_potential_t), intent(in)  this,
type(xc_copied_potentials_t), intent(inout)  vold,
real(real64), intent(in)  dt 
)
private

Replace vold potentials by 0.5*dt(vold + vhxc)

Definition at line 826 of file ks_potential.F90.

◆ zks_potential_mult_vhxc()

subroutine ks_potential_oct_m::zks_potential_mult_vhxc ( class(ks_potential_t), intent(in)  this,
complex(real64), dimension(:), intent(inout)  mf,
integer  ispin 
)
private

Multiply a mesh function by vHxc.

Parameters
[in,out]mfOn exit, vHxc has been added

Definition at line 925 of file ks_potential.F90.

◆ zks_potential_apply_vtau_psi()

subroutine ks_potential_oct_m::zks_potential_apply_vtau_psi ( class(ks_potential_t), intent(in)  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  d,
integer, intent(in)  ispin,
type(wfs_elec_t), intent(inout)  psib,
type(wfs_elec_t), intent(inout)  vpsib 
)
private

Wrapper to hamiltonian_elec_base_local_sub to hide the data of vtau.

Definition at line 945 of file ks_potential.F90.

◆ zks_potential_current_mass_renormalization()

subroutine ks_potential_oct_m::zks_potential_current_mass_renormalization ( class(ks_potential_t), intent(in)  this,
complex(real64), dimension(:,:,:), intent(inout)  gpsi,
integer, intent(in)  space_dim,
integer, intent(in)  ndim,
integer, intent(in)  ispin 
)
private

Nonlocal contribution of vtau for the current.

A nonlocal contribution from the MGGA potential must be included This must be done first, as this is like a position-dependent mass as a renormalization of the gradient

Parameters
[in,out]gpsiGradient of psi (np, spacedim, ndim)

Definition at line 966 of file ks_potential.F90.

◆ dks_potential_mult_vhxc()

subroutine ks_potential_oct_m::dks_potential_mult_vhxc ( class(ks_potential_t), intent(in)  this,
real(real64), dimension(:), intent(inout)  mf,
integer  ispin 
)
private

Multiply a mesh function by vHxc.

Parameters
[in,out]mfOn exit, vHxc has been added

Definition at line 1069 of file ks_potential.F90.

◆ dks_potential_apply_vtau_psi()

subroutine ks_potential_oct_m::dks_potential_apply_vtau_psi ( class(ks_potential_t), intent(in)  this,
class(mesh_t), intent(in)  mesh,
type(states_elec_dim_t), intent(in)  d,
integer, intent(in)  ispin,
type(wfs_elec_t), intent(inout)  psib,
type(wfs_elec_t), intent(inout)  vpsib 
)
private

Wrapper to hamiltonian_elec_base_local_sub to hide the data of vtau.

Definition at line 1089 of file ks_potential.F90.

◆ dks_potential_current_mass_renormalization()

subroutine ks_potential_oct_m::dks_potential_current_mass_renormalization ( class(ks_potential_t), intent(in)  this,
real(real64), dimension(:,:,:), intent(inout)  gpsi,
integer, intent(in)  space_dim,
integer, intent(in)  ndim,
integer, intent(in)  ispin 
)
private

Nonlocal contribution of vtau for the current.

A nonlocal contribution from the MGGA potential must be included This must be done first, as this is like a position-dependent mass as a renormalization of the gradient

Parameters
[in,out]gpsiGradient of psi (np, spacedim, ndim)

Definition at line 1110 of file ks_potential.F90.

Variable Documentation

◆ independent_particles

integer, parameter, public ks_potential_oct_m::independent_particles = 2

Definition at line 157 of file ks_potential.F90.

◆ hartree

integer, parameter, public ks_potential_oct_m::hartree = 1

Definition at line 157 of file ks_potential.F90.

◆ hartree_fock

integer, parameter, public ks_potential_oct_m::hartree_fock = 3

Definition at line 157 of file ks_potential.F90.

◆ kohn_sham_dft

integer, parameter, public ks_potential_oct_m::kohn_sham_dft = 4

Definition at line 157 of file ks_potential.F90.

◆ generalized_kohn_sham_dft

integer, parameter, public ks_potential_oct_m::generalized_kohn_sham_dft = 5

Definition at line 157 of file ks_potential.F90.

◆ rdmft

integer, parameter, public ks_potential_oct_m::rdmft = 7

Definition at line 157 of file ks_potential.F90.