Octopus
density_oct_m Module Reference

This module implements a calculator for the density and defines related functions. More...

Detailed Description

This module implements a calculator for the density and defines related functions.

It takes care of accumulating the orbital densities from all occupied states and performs the summation over k-points, if necessary. It also encapsulates the GPU operations.

Data Types

type  density_calc_t
 The calculator object. More...
 

Functions/Subroutines

subroutine, public density_calc_init (this, st, gr, density)
 initialize the density calculator More...
 
subroutine density_calc_pack (this, async)
 prepare the density calculator for GPU use More...
 
subroutine density_calc_state (this, psib, istin)
 Calculate contribution to the density from state istin. More...
 
subroutine, public density_calc_accumulate (this, psib, async)
 Accumulate weighted orbital densities for a batch psib. More...
 
subroutine, public density_calc_end (this, allreduce, symmetrize)
 Finalize the density calculation. More...
 
subroutine, public density_calc (st, gr, density, istin)
 Computes the density from the orbitals in st. More...
 
subroutine, public states_elec_freeze_orbitals (st, namespace, space, gr, mc, kpoints, n, family_is_mgga)
 Calculate partial density for frozen orbitals. More...
 
subroutine, public states_elec_freeze_redistribute_states (st, namespace, mesh, mc, nn)
 
subroutine, public states_elec_freeze_adjust_qtot (st)
 
subroutine, public states_elec_total_density (st, mesh, total_rho)
 This routine calculates the total electronic density. More...
 
subroutine, public ddensity_accumulate_grad (space, mesh, st, psib, grad_psib, grad_rho)
 Accumulate \( \sum_i \psi_i^{*} \nabla \psi_i \) within a batch. More...
 
subroutine, public zdensity_accumulate_grad (space, mesh, st, psib, grad_psib, grad_rho)
 Accumulate \( \sum_i \psi_i^{*} \nabla \psi_i \) within a batch. More...
 

Function/Subroutine Documentation

◆ density_calc_init()

subroutine, public density_oct_m::density_calc_init ( type(density_calc_t), intent(out)  this,
type(states_elec_t), intent(in), target  st,
type(grid_t), intent(in), target  gr,
real(real64), dimension(:, :), intent(out), target  density 
)

initialize the density calculator

Store pointers to the density, states and grid, initialize the density to zero and check that the array sizes are consistant.

Definition at line 185 of file density.F90.

◆ density_calc_pack()

subroutine density_oct_m::density_calc_pack ( type(density_calc_t), intent(inout)  this,
logical, intent(in), optional  async 
)
private

prepare the density calculator for GPU use

Definition at line 222 of file density.F90.

◆ density_calc_state()

subroutine density_oct_m::density_calc_state ( type(density_calc_t), intent(inout)  this,
type(wfs_elec_t), intent(in)  psib,
integer, intent(in)  istin 
)
private

Calculate contribution to the density from state istin.

The orbital density is already multiplied by the weight and occupation

Definition at line 243 of file density.F90.

◆ density_calc_accumulate()

subroutine, public density_oct_m::density_calc_accumulate ( type(density_calc_t), intent(inout)  this,
type(wfs_elec_t), intent(in)  psib,
logical, intent(in), optional  async 
)

Accumulate weighted orbital densities for a batch psib.

Definition at line 389 of file density.F90.

◆ density_calc_end()

subroutine, public density_oct_m::density_calc_end ( type(density_calc_t), intent(inout)  this,
logical, intent(in), optional  allreduce,
logical, intent(in), optional  symmetrize 
)

Finalize the density calculation.

If GPU was used, copy the density back to CPU memory. In case of states or k-point parallelization, perform the reduction (unless specified otherwise), If requested, symmetrize the density

Definition at line 556 of file density.F90.

◆ density_calc()

subroutine, public density_oct_m::density_calc ( type(states_elec_t), intent(in)  st,
type(grid_t), intent(in)  gr,
real(real64), dimension(:, :), intent(out)  density,
integer, intent(in), optional  istin 
)

Computes the density from the orbitals in st.

This routine handles the sum over states, and if present state or k-point parallelization. Optionally, a state resolved density can be calculated.

Parameters
[in]stthe states for which the density is calculated
[in]grthe underlying grid
[out]densitythe resulting density
[in]istinoptional state index for orbital densities

Definition at line 607 of file density.F90.

◆ states_elec_freeze_orbitals()

subroutine, public density_oct_m::states_elec_freeze_orbitals ( type(states_elec_t), intent(inout)  st,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
type(grid_t), intent(in)  gr,
type(multicomm_t), intent(in)  mc,
type(kpoints_t), intent(in)  kpoints,
integer, intent(in)  n,
logical, intent(in)  family_is_mgga 
)

Calculate partial density for frozen orbitals.

Definition at line 650 of file density.F90.

◆ states_elec_freeze_redistribute_states()

subroutine, public density_oct_m::states_elec_freeze_redistribute_states ( type(states_elec_t), intent(inout)  st,
type(namespace_t), intent(in)  namespace,
class(mesh_t), intent(in)  mesh,
type(multicomm_t), intent(in)  mc,
integer, intent(in)  nn 
)

Definition at line 781 of file density.F90.

◆ states_elec_freeze_adjust_qtot()

subroutine, public density_oct_m::states_elec_freeze_adjust_qtot ( type(states_elec_t), intent(inout)  st)

Definition at line 809 of file density.F90.

◆ states_elec_total_density()

subroutine, public density_oct_m::states_elec_total_density ( type(states_elec_t), intent(in)  st,
class(mesh_t), intent(in)  mesh,
real(real64), dimension(:,:), intent(out)  total_rho 
)

This routine calculates the total electronic density.

This is the sum of the part coming from the orbitals, the non-linear core corrections and the frozen orbitals.

Note
The resulting total density should only be used for the calculation of the xc energy or potential, as in other places only the valence density is expected.

Definition at line 848 of file density.F90.

◆ ddensity_accumulate_grad()

subroutine, public density_oct_m::ddensity_accumulate_grad ( class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), dimension(:), intent(in)  grad_psib,
real(real64), dimension(:, :), intent(inout)  grad_rho 
)

Accumulate \( \sum_i \psi_i^{*} \nabla \psi_i \) within a batch.

Definition at line 961 of file density.F90.

◆ zdensity_accumulate_grad()

subroutine, public density_oct_m::zdensity_accumulate_grad ( class(space_t), intent(in)  space,
class(mesh_t), intent(in)  mesh,
type(states_elec_t), intent(in)  st,
type(wfs_elec_t), intent(in)  psib,
type(wfs_elec_t), dimension(:), intent(in)  grad_psib,
real(real64), dimension(:, :), intent(inout)  grad_rho 
)

Accumulate \( \sum_i \psi_i^{*} \nabla \psi_i \) within a batch.

Definition at line 1151 of file density.F90.