Octopus
stress_oct_m Module Reference

This module implements the calculation of the stress tensor. More...

Detailed Description

This module implements the calculation of the stress tensor.

Functions/Subroutines

subroutine, public stress_calculate (namespace, gr, hm, st, ions, ks, ext_partners)
 This computes the total stress on the lattice. More...
 
subroutine stress_from_kinetic (gr, space, hm, st, symm, rcell_volume, stress_kin)
 Computes the contribution to the stress tensor from the kinetic energy. More...
 
subroutine stress_from_hartree (gr, space, volume, grad_vh, ehartree, stress_Hartree)
 Computes the contribution to the stress tensor from the Hartree energy. More...
 
subroutine stress_from_xc (gr, hm, st, space, rcell_volume, stress_xc)
 Computes the contribution to the stress tensor from the xc energy. More...
 
subroutine stress_from_xc_nlcc (rcell_volume, gr, st, ions, vxc, stress_xc_nlcc)
 Computes the NLCC contribution to the stress tensor from the xc energy. More...
 
subroutine stress_from_pseudo_nonloc (gr, st, hm, ions, stress_ps_nl)
 Computes the contribution to the stress tensor from the nonlocal part of the pseudopotentials. More...
 
subroutine stress_from_pseudo_local (gr, hm, ions, rho_total, grad_vh, stress_ps_local)
 Computes the contribution from the local part of the pseudopotential. More...
 
subroutine epot_local_pseudopotential_sr (mesh, ions, iatom, vpsl, rvpsl)
 
subroutine stress_from_hubbard (namespace, gr, st, hm, space, rcell_volume, stress_hubbard)
 Computes the contribution to the stress tensor from the Hubbard energy. More...
 
subroutine, public output_stress (iunit, space_dim, stress_tensors, all_terms)
 
subroutine, public output_pressure (iunit, space_dim, total_stress_tensor)
 
subroutine print_stress_tensor (ounit, space_dim, tensor)
 

Function/Subroutine Documentation

◆ stress_calculate()

subroutine, public stress_oct_m::stress_calculate ( type(namespace_t), intent(in)  namespace,
type(grid_t), intent(inout)  gr,
type(hamiltonian_elec_t), intent(inout)  hm,
type(states_elec_t), intent(inout), target  st,
type(ions_t), intent(inout)  ions,
type(v_ks_t), intent(in)  ks,
type(partner_list_t), intent(in)  ext_partners 
)

This computes the total stress on the lattice.

Parameters
[in,out]grgrid
[in,out]hmthe Hamiltonian
[in,out]stthe electronic states
[in,out]ionsgeometry
[in]ksthe Kohn-Sham system
[in]ext_partnersexternal interaction partners

Definition at line 187 of file stress.F90.

◆ stress_from_kinetic()

subroutine stress_oct_m::stress_from_kinetic ( type(grid_t), intent(in)  gr,
class(space_t), intent(in)  space,
type(hamiltonian_elec_t), intent(in)  hm,
type(states_elec_t), intent(in)  st,
type(symmetries_t), intent(in)  symm,
real(real64), intent(in)  rcell_volume,
real(real64), dimension(3, 3), intent(out)  stress_kin 
)
private

Computes the contribution to the stress tensor from the kinetic energy.

We use the real space formula from Sharma and Suryanarayana On the calculation of the stress tensor in real-space Kohn-Sham density functional theory J. Chem. Phys. 149, 194104 (2018)

More precisely, this routines computes

\[ \sigma_{ij} = \frac{1}{V}\sum_n\sum_k^{BZ} w_kf_{n,k}\int d^3r \partial_i \psi^*_{n,k}(r) \partial_j \psi_{n,k}(r)\, \]

where \(V\) is the cell volume, \( w_k\) is the weight of the k-point k, \( f_{n,k}\) is the occupation number of the band with a k-point index k, and \( \psi_{n,k}\) is the corresponding Bloch state.

Definition at line 444 of file stress.F90.

◆ stress_from_hartree()

subroutine stress_oct_m::stress_from_hartree ( type(grid_t), intent(in)  gr,
class(space_t), intent(in)  space,
real(real64), intent(in)  volume,
real(real64), dimension(:,:), intent(in), contiguous  grad_vh,
real(real64), intent(in)  ehartree,
real(real64), dimension(3, 3), intent(out)  stress_Hartree 
)
private

Computes the contribution to the stress tensor from the Hartree energy.

We use the real space formula from Sharma and Suryanarayana On the calculation of the stress tensor in real-space Kohn-Sham density functional theory J. Chem. Phys. 149, 194104 (2018)

More precisely, this routines computes

\[ \sigma_{ij} = \frac{1}{4\pi V}\int d^3r \partial_i v_{\rm H}(r) \partial_j v_{\rm H}(r) - \delta_{ij} \frac{1}{V}E_{\rm H}\, \]

where \(V\) is the cell volume, \( v_{\rm H}(r) \) is the Hartree potential, and \( E_{\rm H} \) is the Hartree energy defined as

\[ E_{\rm H} = \frac{1}{2} \int d^3r n(r) v_{\rm H}(r) \,. \]

Parameters
[in]grad_vhGradient of the Hartree potential
[in]ehartreeHartree U = (1/2)*Int [n v_Hartree]

Definition at line 533 of file stress.F90.

◆ stress_from_xc()

subroutine stress_oct_m::stress_from_xc ( type(grid_t), intent(in)  gr,
type(hamiltonian_elec_t), intent(in)  hm,
type(states_elec_t), intent(in)  st,
class(space_t), intent(in)  space,
real(real64), intent(in)  rcell_volume,
real(real64), dimension(3, 3), intent(out)  stress_xc 
)
private

Computes the contribution to the stress tensor from the xc energy.

This routines computes the xc stress tensor assuming an LDA functional

\[ \sigma_{ij} = \frac{1}{V}\delta_{ij}(-\int d^3r n(r) v_{\rm xc}(r) + E_{\rm xc})\, \]

where \(V\) is the cell volume, \(n(r) \) is the electronic density, \( v_{\rm xc}(r) \) is the exchange-correlation potential, and \( E_{\rm xc} \) is the exchange-correlation energy.

The GGA extra term is computed alongside with the calculation of the xc potential, in the routine xc_get_vxc.

For mGGAs, the term coming from the Laplacian of the density is also computed in xc_get_vxc. The term coming from the kinetic energy density \(\tau\) is computed here,

\[ \sigma_{ij} = \frac{2}{V}\sum_{nk} w_k f_{nk} {\rm Re}\int d^3r\, v_\tau(r) \partial_i\psi^*_{nk}(r) \partial_j\psi_{nk}(r)\, \]

where \( v_\tau = \partial e_{\rm xc}/\partial\tau \) with the Octopus convention \( \tau = \sum_{nk} w_k f_{nk} |\nabla\psi_{nk}|^2 \). The corresponding diagonal term \( \delta_{ij}\int d^3r\, v_\tau \tau \) is not added here: it is already part of energyintnvxc at the generalized Kohn-Sham level.

Definition at line 592 of file stress.F90.

◆ stress_from_xc_nlcc()

subroutine stress_oct_m::stress_from_xc_nlcc ( real(real64), intent(in)  rcell_volume,
type(grid_t), intent(in)  gr,
type(states_elec_t), intent(in)  st,
type(ions_t), intent(in)  ions,
real(real64), dimension(:,:), intent(in), contiguous  vxc,
real(real64), dimension(3, 3), intent(out)  stress_xc_nlcc 
)
private

Computes the NLCC contribution to the stress tensor from the xc energy.

The nonlinear core correction term is given by

\[ \sigma_{\alpha\beta} = \frac{1}{V} \sum_I \int d^3r [\partial_\alpha \rho_{NLCC}^I(r)] (r-R_I)_\beta v_{xc}(r) \]

Note that the formula given by the integration by parts

\[ \sigma_{ij}^{\rm NLCC} = \frac{1}{V}\int d^3r v_{xc}(r) \frac{\partial \rho_{\rm NLCC}(\epsilon r)}{\partial \epsilon_{ij}}\Bigg|_{\epsilon=I}\,. \]

was previously used to avoid the gradient of the NLCC. However, this was found to be much less stable that analytic radial derivative of the core density (species_get_nlcc_grad), which both avoids the ill-defined gradient of the sharp core at the ionic center and treats the periodic images of the (r-R_I) factor consistently.

Definition at line 712 of file stress.F90.

◆ stress_from_pseudo_nonloc()

subroutine stress_oct_m::stress_from_pseudo_nonloc ( type(grid_t), intent(in), target  gr,
type(states_elec_t), intent(inout)  st,
type(hamiltonian_elec_t), intent(in)  hm,
type(ions_t), intent(in)  ions,
real(real64), dimension(3, 3), intent(out)  stress_ps_nl 
)
private

Computes the contribution to the stress tensor from the nonlocal part of the pseudopotentials.

More precisely, this routines computes

\[ \sigma_{ij} = \frac{2}{V}\sum_n\sum_k^{BZ} \sum_I w_kf_{n,k} \langle \partial_i \psi_{n,k}| (r_j-R_j) \hat{V}_{\rm NL,I}| \psi_{n,k}\rangle + \delta_{ij} \frac{1}{V}E_{\rm NL} \]

where \(V\) is the cell volume, \( w_k\) is the weight of the k-point k, \( f_{n,k}\) is the occupation number of the band with a k-point index k, \( \psi_{n,k}\) is the corresponding Bloch state, and \( \hat{V}_{\rm NL, I}\) is the pseudopotential non-local operator from atom I, centered on the position \(R_I\). \( E_{\rm NL} \) is the nonlocal energy from the nonlocal pseudopotential.

See Sharma and Suryanarayana, On the calculation of the stress tensor in real-space Kohn-Sham density functional theory, J. Chem. Phys. 149, 194104 (2018) for more details

Parameters
[in]grgrid

Definition at line 786 of file stress.F90.

◆ stress_from_pseudo_local()

subroutine stress_oct_m::stress_from_pseudo_local ( type(grid_t), intent(in), target  gr,
type(hamiltonian_elec_t), intent(in)  hm,
type(ions_t), intent(in)  ions,
real(real64), dimension(:), intent(inout), contiguous  rho_total,
real(real64), dimension(:,:), intent(in), contiguous  grad_vh,
real(real64), dimension(3, 3), intent(out)  stress_ps_local 
)
private

Computes the contribution from the local part of the pseudopotential.

We use a real space formulation, which computes two parts. One short range (SR)

\[ \sigma_{ij} =\frac{1}{V} \sum_I\int d^3r [\partial_i \rho(r)] (x_j-R_{I,j}) v_{\rm SR, I}(r) + \delta_{ij} \frac{1}{V}E_{\rm loc, SR}\, \]

and a long range part

\[ \sigma_{ij} = \frac{1}{V}\int d\vec{x} \sum_I n_{\rm LR}^{I}(|\vec{x}-\vec{R}_I|) (x_j-R_{I,j}) [\partial_i v_H(\vec{x})] + \delta_{ij} \frac{1}{V} E_{\rm loc, LR} -\frac{2}{4\pi V}\int d\vec{r} [\partial_i v_{\rm H}(\vec{r})][\partial_j v_{\rm LR}(\vec{r})] \]

where \(V\) is the cell volume, \( v_{\rm H}(r) \) is the Hartree potential, \(\vec{R}_I\) refers to the position of the atom \(I\), and \(n_{\rm LR}^{I}\) is the long-range density associated with the long-range potential \(v_{\rm LR}^I\).

Parameters
[in]grgrid
[in]grad_vhGradient of the Hartree potential

Definition at line 895 of file stress.F90.

◆ epot_local_pseudopotential_sr()

subroutine stress_oct_m::epot_local_pseudopotential_sr ( class(mesh_t), intent(in)  mesh,
type(ions_t), intent(in)  ions,
integer, intent(in)  iatom,
real(real64), dimension(:), intent(inout), contiguous  vpsl,
real(real64), dimension(:,:), intent(inout), contiguous  rvpsl 
)
private

Definition at line 1027 of file stress.F90.

◆ stress_from_hubbard()

subroutine stress_oct_m::stress_from_hubbard ( type(namespace_t), intent(in)  namespace,
type(grid_t), intent(in), target  gr,
type(states_elec_t), intent(in)  st,
type(hamiltonian_elec_t), intent(in)  hm,
type(space_t), intent(in)  space,
real(real64), intent(in)  rcell_volume,
real(real64), dimension(3, 3), intent(out)  stress_hubbard 
)
private

Computes the contribution to the stress tensor from the Hubbard energy.

More precisely, this routine computes

\[ \sigma^{U}_{\alpha\beta} = \delta_{\alpha\beta} E_{\rm Hubbard} - \frac{2}{V} \sum_{n} \sum_{\mathbf{k}}^{BZ} w_k \Re\Bigg\{ \langle [\partial_\alpha \psi^*_{n\mathbf{k}}(\mathbf{r})] | (\mathbf{r}-\mathbf{R}_J)_\beta \hat{V}_U n_\mathbf{k}\rangle\Bigg\} \]

where \(V\) is the cell volume, \( w_k\) is the weight of the k-point k, \( \psi_{n,\mathbf{k}}\) is the corresponding Bloch state, and \( \hat{V}_{U}\) is the Hubbard potential and \( E_{\rm Hubbard} \) is the Hubbard energy.

Parameters
[in]grgrid

Definition at line 1092 of file stress.F90.

◆ output_stress()

subroutine, public stress_oct_m::output_stress ( integer, intent(in)  iunit,
integer, intent(in)  space_dim,
type(stress_t), intent(in)  stress_tensors,
logical, intent(in), optional  all_terms 
)
Parameters
[in]all_termsif yes, writes each contributing term separately

Definition at line 1186 of file stress.F90.

◆ output_pressure()

subroutine, public stress_oct_m::output_pressure ( integer, intent(in)  iunit,
integer, intent(in)  space_dim,
real(real64), dimension(3,3), intent(in)  total_stress_tensor 
)

Definition at line 1251 of file stress.F90.

◆ print_stress_tensor()

subroutine stress_oct_m::print_stress_tensor ( integer, intent(in)  ounit,
integer, intent(in)  space_dim,
real(real64), dimension(3,3), intent(in)  tensor 
)
private

Definition at line 1278 of file stress.F90.