Octopus
stress.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2016 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!! Copyright (C) 2023 N. Tancogne-Dejean
3!!
4!! This program is free software; you can redistribute it and/or modify
5!! it under the terms of the GNU General Public License as published by
6!! the Free Software Foundation; either version 2, or (at your option)
7!! any later version.
8!!
9!! This program is distributed in the hope that it will be useful,
10!! but WITHOUT ANY WARRANTY; without even the implied warranty of
11!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!! GNU General Public License for more details.
13!!
14!! You should have received a copy of the GNU General Public License
15!! along with this program; if not, write to the Free Software
16!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17!! 02110-1301, USA.
18!!
19
20#include "global.h"
21
22! ---------------------------------------------------------
25module stress_oct_m
28 use comm_oct_m
29 use debug_oct_m
33 use energy_oct_m
35 use epot_oct_m
36 use global_oct_m
37 use grid_oct_m
39 use io_oct_m
41 use ions_oct_m
43 use, intrinsic :: iso_fortran_env
47 use lda_u_oct_m
50 use math_oct_m
51 use mesh_oct_m
55 use mpi_oct_m
60 use ps_oct_m
62 use space_oct_m
72 use types_oct_m
73 use unit_oct_m
75 use v_ks_oct_m
77 use xc_oct_m
78 use xc_f03_lib_m
80 implicit none
81
82 private
83 public :: &
87
88contains
89
90 ! ---------------------------------------------------------
92 subroutine stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
93 type(namespace_t), intent(in) :: namespace
94 type(grid_t), intent(inout) :: gr
95 type(hamiltonian_elec_t), intent(inout) :: hm
96 type(states_elec_t), target, intent(inout) :: st
97 type(ions_t), intent(inout) :: ions
98 type(v_ks_t), intent(in) :: ks
99 type(partner_list_t), intent(in) :: ext_partners
100
101 real(real64), allocatable :: rho_total(:)
102 real(real64) :: stress(3,3) ! stress tensor in Cartesian coordinate
103 real(real64) :: stress_kin(3,3), stress_Hartree(3,3), stress_xc(3,3), stress_xc_nlcc(3,3)
104 real(real64) :: stress_ps(3,3), stress_ps_nl(3,3), stress_ps_local(3,3), stress_ii(3,3)
105 real(real64) :: stress_hubbard(3,3)
106 integer :: ip
107 real(real64), allocatable :: vh(:)
108 real(real64), allocatable :: grad_vh(:,:)
109 real(real64) :: ehartree
110 real(real64), contiguous, pointer :: rho(:)
111
112 call profiling_in("STRESS_CALCULATE")
113 push_sub(stress_calculate)
114
115 if (st%wfs_type /= type_cmplx) then
116 write(message(1),'(a)') 'The stress tensors for real wavefunctions has not been implemented!'
117
118 if (hm%kpoints%full%npoints == 1) then
119 write(message(2),'(a)') 'For testing this feature, you can add ForceComplex=yes to the input file'
120 call messages_fatal(2, namespace=namespace)
121 end if
122
123 call messages_fatal(1, namespace=namespace)
124 end if
125
126 if (ions%space%periodic_dim == 1) then
127 call messages_not_implemented("Stress tensor for 1D periodic systems", namespace=namespace)
128 end if
129
130 if (.not. ions%space%is_periodic()) then
131 write(message(1),'(a)') 'The stress tensor cannot be computed for isolated systems'
132 call messages_fatal(1, namespace=namespace)
133 end if
134
135 if (ks%vdw%vdw_correction /= option__vdwcorrection__none .and. .not. any(ks%vdw%vdw_correction == d3_lib_options)) then
136 write(message(1),'(a)') 'The stress tensor is currently only implemented with DFT-D3 vdW correction'
137 call messages_fatal(1, namespace=namespace)
138 end if
139
140 if (hm%pcm%run_pcm) then
141 call messages_not_implemented('Stress tensor with PCM', namespace=namespace)
142 end if
143
144 if (allocated(hm%v_static)) then
145 call messages_not_implemented('Stress tensor with static electric fields', namespace=namespace)
146 end if
147
148 if (ks%v_ks_photons%active()) then
149 call messages_not_implemented('Stress tensor with photon modes', namespace=namespace)
150 end if
151
152 if (.not. hm%vnl%apply_projector_matrices) then
153 call messages_not_implemented('Stress tensor with relativistic Kleinman-Bylander pseudopotential', namespace=namespace)
154 end if
155
156 if (hm%ep%reltype == scalar_relativistic_zora .or. hm%ep%reltype == fully_relativistic_zora) then
157 call messages_not_implemented('Stress tensor with ZORA', namespace=namespace)
158 end if
159
160 ! Checks for the xc part of KS-DFT and GKS-DFT
161 if (ks%theory_level == kohn_sham_dft .or. ks%theory_level == generalized_kohn_sham_dft) then
162 if (.not. xc_is_energy_functional(hm%xc)) then
163 call messages_not_implemented("Stress tensor with xc functionals that are not energy functionals")
164 end if
165
166 if ( .not. in_family(hm%xc%family, [xc_family_lda, xc_family_gga, xc_family_mgga])) then
167 write(message(1),'(a)') 'The stress tensor computation is currently only possible at the Kohn-Sham DFT level'
168 write(message(2),'(a)') 'with LDA, GGA and mGGA functionals or for independent particles.'
169 call messages_fatal(2, namespace=namespace)
170 end if
171
172 if (in_family(hm%xc%family, [xc_family_gga, xc_family_mgga]) .and. st%d%ispin == spinors) then
173 call messages_not_implemented("Stress tensor for GGAs and mGGAs with spinors", namespace=namespace)
174 end if
175
176 if (family_is_mgga_with_exc(hm%xc)) then
177 ! The diagonal tau term is taken from hm%energy%intnvxc, which only contains the
178 ! mGGA operator expectation value at the generalized Kohn-Sham level.
179 if (ks%theory_level /= generalized_kohn_sham_dft) then
180 call messages_not_implemented("Stress tensor for mGGAs outside of the generalized Kohn-Sham scheme", &
181 namespace=namespace)
182 end if
183
184 ! The strain derivative of the gauge-invariant kinetic energy density has an extra
185 ! current-dependent term, which is not implemented.
186 if (hm%xc%use_gi_ked) then
187 call messages_not_implemented("Stress tensor for mGGAs with XCUseGaugeIndependentKED = yes", &
188 namespace=namespace)
189 end if
190 end if
191 end if
192
193 if (hm%magnetic_constrain%level /= constrain_none) then
194 call messages_not_implemented("Stress tensor with MagneticConstrain /= constrain_none")
195 end if
196
197 stress(:,:) = m_zero
198
199 safe_allocate(rho_total(1:gr%np_part))
200 do ip = 1, gr%np
201 rho_total(ip) = sum(st%rho(ip, 1:st%d%nspin))
202 end do
203
204 ! As we rely on some of the full energy components, we need to recompute it first
205 ! TODO: We should restrict the components of the energy needed to be computed
206 call energy_calc_total(namespace, ions%space, hm, gr, st, ext_partners, iunit = -1, full = .true.)
207
208 ! In order to get the electrostatic part (Hartree and local pseudopotential part),
209 ! we need to get the Hartree potential and its gradient
210 safe_allocate(vh(1:gr%np_part))
211 safe_allocate(grad_vh(1:gr%np, 1:gr%der%dim))
212 if (ks%theory_level /= independent_particles) then
213 call lalg_copy(gr%np, hm%ks_pot%vhartree, vh)
214 else
215 if (hm%d%spin_channels > 1) then
216 safe_allocate(rho(1:gr%np_part))
217 call lalg_copy(gr%np, st%rho(:,1), rho)
218 call lalg_axpy(gr%np, m_one, st%rho(:,2), rho)
219 else
220 rho => st%rho(:,1)
221 end if
222 ! In the case of independent particles, we use the electron density without NLCC
223 call dpoisson_solve(hm%psolver, ions%namespace, vh, rho, all_nodes = .true.)
224 if (hm%d%spin_channels > 1) then
225 safe_deallocate_p(rho)
226 else
227 nullify(rho)
228 end if
229 end if
230 ehartree = hm%energy%hartree
231 ! We also compute the gradient here
232 call dderivatives_grad(gr%der, vh, grad_vh)
233
234 ! We now compute the various contributions to the stress tensor
235
236 ! Stress from kinetic energy of electrons
237 call stress_from_kinetic(gr, ions%space, hm, st, gr%symm, ions%latt%rcell_volume, stress_kin)
238 stress = stress + stress_kin
239
240 if (ks%theory_level == independent_particles) then
241 stress_hartree = m_zero
242 stress_xc = m_zero
243 stress_xc_nlcc = m_zero
244 else
245 call stress_from_hartree(gr, ions%space, ions%latt%rcell_volume, grad_vh, ehartree, stress_hartree)
246 stress = stress + stress_hartree
247
248 call stress_from_xc(gr, hm, st, ions%space, ions%latt%rcell_volume, stress_xc)
249
250 ! Nonlinear core correction contribution
251 if (allocated(st%rho_core)) then
252 call stress_from_xc_nlcc(ions%latt%rcell_volume, gr, st, ions, hm%ks_pot%vxc, stress_xc_nlcc)
253 else
254 stress_xc_nlcc = m_zero
255 end if
256 ! Adds the beyond LDA contribution to the stress tensor
257 stress_xc = stress_xc + ks%stress_xc / ions%latt%rcell_volume
258 stress = stress + stress_xc + stress_xc_nlcc
259 end if
260
261 call stress_from_pseudo_local(gr, hm, ions, rho_total, grad_vh, stress_ps_local)
262 stress_ps = stress_ps_local
263 stress = stress + stress_ps_local
264
265 safe_deallocate_a(vh)
266 safe_deallocate_a(grad_vh)
267
268 call stress_from_pseudo_nonloc(gr, st, hm, ions, stress_ps_nl)
269 stress_ps = stress_ps + stress_ps_nl
270 stress = stress + stress_ps_nl
271
272 call stress_from_hubbard(namespace, gr, st, hm, ions%space, ions%latt%rcell_volume, stress_hubbard)
273 stress = stress + stress_hubbard
274
275 call ion_interaction_stress(ions%ion_interaction, ions%space, ions%latt, ions%atom, ions%natoms, ions%pos, stress_ii)
276 stress = stress + stress_ii
277 ! Stress from kinetic energy of ion
278 ! Stress from ion-field interaction
279
280 ! Sign changed to fit conventional definition
281 stress = -stress
282 st%stress_tensors%kinetic = -stress_kin
283 st%stress_tensors%Hartree = -stress_hartree
284 st%stress_tensors%xc = -stress_xc
285 st%stress_tensors%xc_nlcc = -stress_xc_nlcc
286 st%stress_tensors%ps_local = -stress_ps_local
287 st%stress_tensors%ps_nl = -stress_ps_nl
288 st%stress_tensors%hubbard = -stress_hubbard
289 st%stress_tensors%ion_ion = -stress_ii
290
291 ! Stress contribution from vdW D3
292 if (ks%vdw%vdw_correction /= option__vdwcorrection__none) then
293 st%stress_tensors%vdw = hm%ep%vdw_stress
294 else
295 st%stress_tensors%vdw = m_zero
296 end if
297 stress = stress + st%stress_tensors%vdw
298
299 ! Symmetrize the stress tensor if we use k-point symmetries
300 if (hm%kpoints%use_symmetries) then
301 call dsymmetrize_tensor_cart(gr%symm, stress, use_non_symmorphic=.true.)
302 end if
303 ! We guarantee that the matrix is truly symmetric. There could be small numerical asymmetries after symmetrization
304 call symmetrize_matrix(ions%space%periodic_dim, stress)
305
306 st%stress_tensors%total = stress
307
308 ! Some sumrule for validation
309 ! Sumrule is -3P_{kin}\Omega = 2 E_{kin}
310 st%stress_tensors%kinetic_sumrule = m_zero
311 ! Sumrule is -3P_{Hartree}\Omega = E_{Hartree}
312 st%stress_tensors%Hartree_sumrule = m_zero
313 if(ions%space%periodic_dim == 3) then
314 st%stress_tensors%kinetic_sumrule = (stress_kin(1,1) + stress_kin(2,2) + stress_kin(3,3))*ions%latt%rcell_volume
315 st%stress_tensors%kinetic_sumrule = st%stress_tensors%kinetic_sumrule - m_two * hm%energy%kinetic
316
317 st%stress_tensors%hartree_sumrule = (stress_hartree(1,1) + stress_hartree(2,2) + stress_hartree(3,3))*ions%latt%rcell_volume
318 st%stress_tensors%hartree_sumrule = st%stress_tensors%hartree_sumrule - hm%energy%hartree
319 end if
320
321 safe_deallocate_a(rho_total)
322
323 pop_sub(stress_calculate)
324 call profiling_out("STRESS_CALCULATE")
325 end subroutine stress_calculate
326
327 ! -------------------------------------------------------
342 subroutine stress_from_kinetic(gr, space, hm, st, symm, rcell_volume, stress_kin)
343 type(grid_t), intent(in) :: gr
344 class(space_t), intent(in) :: space
345 type(hamiltonian_elec_t), intent(in) :: hm
346 type(states_elec_t), intent(in) :: st
347 type(symmetries_t), intent(in) :: symm
348 real(real64), intent(in) :: rcell_volume
349 real(real64), intent(out) :: stress_kin(3, 3)
350
351 integer :: ik, ist, idir, jdir, ib, minst, maxst
352 complex(real64), allocatable :: stress_l_block(:)
353 type(wfs_elec_t) :: psib, gpsib(space%dim)
354
355 call profiling_in("STRESS_FROM_KINETIC")
356 push_sub(stress_from_kinetic)
357
358 stress_kin(:,:) = m_zero
359
360 safe_allocate(stress_l_block(1:st%block_size))
361
362 do ik = st%d%kpt%start, st%d%kpt%end
363 if (st%kweights(ik) <= m_epsilon) cycle
364
365 do ib = st%group%block_start, st%group%block_end
366 minst = states_elec_block_min(st, ib)
367 maxst = states_elec_block_max(st, ib)
368
369 call hm%phase%copy_and_set_phase(gr, st%d%kpt, st%group%psib(ib, ik), psib)
370
371 ! calculate the gradient
372 call zderivatives_batch_grad(gr%der, psib, gpsib, set_bc=.false.)
373
374 ! Accumulate the result
375 do idir = 1, space%periodic_dim
376 do jdir = idir, space%periodic_dim
377 call zmesh_batch_dotp_vector(gr, gpsib(idir), gpsib(jdir), stress_l_block)
378
379 do ist = minst, maxst
380 stress_kin(idir,jdir) = stress_kin(idir,jdir) &
381 + st%kweights(ik) * st%occ(ist, ik) &
382 * real(stress_l_block(ist - minst + 1), real64)
383 end do
384 end do
385 end do
386
387 do idir = 1, space%dim
388 call gpsib(idir)%end()
389 end do
390 call psib%end()
391
392 end do
393 end do
394
395 if (st%parallel_in_states .or. st%d%kpt%parallel) then
396 call comm_allreduce(st%st_kpt_mpi_grp, stress_kin)
397 end if
398
399
400 ! Symmetrize the kinetic stress tensor
401 call upper_triangular_to_hermitian(space%periodic_dim, stress_kin)
402
403 ! Symmetrize the stress tensor if we use k-point symmetries
404 if (hm%kpoints%use_symmetries) then
405 call dsymmetrize_tensor_cart(symm, stress_kin, use_non_symmorphic=.true.)
406 end if
407
408 stress_kin = stress_kin / rcell_volume
409
410 call profiling_out("STRESS_FROM_KINETIC")
411 pop_sub(stress_from_kinetic)
412 end subroutine stress_from_kinetic
413
414 ! -------------------------------------------------------
431 subroutine stress_from_hartree(gr, space, volume, grad_vh, ehartree, stress_Hartree)
432 type(grid_t), intent(in) :: gr
433 class(space_t), intent(in) :: space
434 real(real64), intent(in) :: volume
435 real(real64), intent(in) :: grad_vh(:,:)
436 real(real64), intent(in) :: ehartree
437 real(real64), intent(out) :: stress_Hartree(3, 3)
438
439 integer :: idir, jdir
440
441 call profiling_in("STRESS_FROM_HARTREE")
442 push_sub(stress_from_hartree)
443
444 stress_hartree(:,:) = m_zero
445
446 do idir = 1, space%periodic_dim
447 do jdir = idir, space%periodic_dim
448 stress_hartree(idir, jdir) = -dmf_dotp(gr, grad_vh(:,idir), grad_vh(:, jdir))/m_four/m_pi
449 end do
450 stress_hartree(idir, idir) = stress_hartree(idir, idir) + ehartree
451 end do
452
453 call upper_triangular_to_hermitian(space%periodic_dim, stress_hartree)
454
455 stress_hartree = stress_hartree/volume
456
457 call profiling_out("STRESS_FROM_HARTREE")
458 pop_sub(stress_from_hartree)
459 end subroutine stress_from_hartree
460
461
462 ! -------------------------------------------------------
487 !
488 ! Note: We assume hm%energy%echange, correlation, and intnvxc
489 ! have already been calculated somewhere else.
490 subroutine stress_from_xc(gr, hm, st, space, rcell_volume, stress_xc)
491 type(grid_t), intent(in) :: gr
492 type(hamiltonian_elec_t), intent(in) :: hm
493 type(states_elec_t), intent(in) :: st
494 class(space_t), intent(in) :: space
495 real(real64), intent(in) :: rcell_volume
496 real(real64), intent(out) :: stress_xc(3, 3)
497
498 integer :: ik, ist, idir, jdir, ib, minst, maxst, ispin
499 real(real64) :: stress_tau(3,3)
500 complex(real64), allocatable :: stress_l_block(:)
501 type(wfs_elec_t) :: psib, gpsib(space%dim), vtau_gpsib(space%dim)
502
503 call profiling_in("STRESS_FROM_XC")
504 push_sub(stress_from_xc)
505
506 ! LDA part
507 stress_xc = m_zero
508 do idir = 1, space%periodic_dim
509 stress_xc(idir, idir) = - hm%energy%exchange - hm%energy%correlation + hm%energy%intnvxc
510 end do
511
512 ! tau-mGGA part.
513 ! Only the term involving the gradients of the orbitals is computed here. The diagonal term
514 ! \f$ \delta_{ij}\int d^3r v_\tau \tau \f$ is not added: it is already contained in
515 ! energy%intnvxc above, where v_ks_calc adds the expectation value of the mGGA operator
516 ! (TERM_MGGA) at the generalized Kohn-Sham level.
517 if (family_is_mgga_with_exc(hm%xc)) then
518 stress_tau = m_zero
519
520 safe_allocate(stress_l_block(1:st%block_size))
521
522 ! TODO: This mostly duplicates the kinetic term. Stress_from_kinetic could return the tau part,
523 ! if performances are critical
524 do ik = st%d%kpt%start, st%d%kpt%end
525 if (st%kweights(ik) <= m_epsilon) cycle
527 ispin = st%d%get_spin_index(ik)
528
529 do ib = st%group%block_start, st%group%block_end
530 minst = states_elec_block_min(st, ib)
531 maxst = states_elec_block_max(st, ib)
532
533 call hm%phase%copy_and_set_phase(gr, st%d%kpt, st%group%psib(ib, ik), psib)
534
535 ! calculate the gradient
536 call zderivatives_batch_grad(gr%der, psib, gpsib, set_bc=.false.)
537
538 ! vtau \nabla \psi
539 do idir = 1, space%periodic_dim
540 call psib%copy_to(vtau_gpsib(idir))
541 call batch_set_zero(vtau_gpsib(idir))
542 call hm%ks_pot%zapply_vtau_psi(gr, hm%d, ispin, gpsib(idir), vtau_gpsib(idir))
543 end do
544
545 ! Accumulate the result
546 do idir = 1, space%periodic_dim
547 do jdir = idir, space%periodic_dim
548 call zmesh_batch_dotp_vector(gr, vtau_gpsib(idir), gpsib(jdir), stress_l_block)
549
550 do ist = minst, maxst
551 stress_tau(idir, jdir) = stress_tau(idir, jdir) &
552 + m_two * st%kweights(ik) * st%occ(ist, ik) * real(stress_l_block(ist - minst + 1), real64)
553 end do
554 end do
555 end do
556
557 do idir = 1, space%dim
558 call gpsib(idir)%end()
559 end do
560 do idir = 1, space%periodic_dim
561 call vtau_gpsib(idir)%end()
562 end do
563 call psib%end()
564
565 end do
566 end do
567
568 safe_deallocate_a(stress_l_block)
569
570 if (st%parallel_in_states .or. st%d%kpt%parallel) then
571 call comm_allreduce(st%st_kpt_mpi_grp, stress_tau)
572 end if
573
574 ! Symmetrize the tau stress tensor
575 call upper_triangular_to_hermitian(space%periodic_dim, stress_tau)
576
577 ! Symmetrize the stress tensor if we use k-point symmetries
578 if (hm%kpoints%use_symmetries) then
579 call dsymmetrize_tensor_cart(gr%symm, stress_tau, use_non_symmorphic=.true.)
580 end if
581
582 stress_xc(:,:) = stress_xc(:,:) + stress_tau(:,:)
583
584 end if
586 stress_xc(:,:) = stress_xc(:,:) / rcell_volume
587
588 call profiling_out("STRESS_FROM_XC")
589 pop_sub(stress_from_xc)
590 end subroutine stress_from_xc
591
592
593 ! -------------------------------------------------------
610 subroutine stress_from_xc_nlcc(rcell_volume, gr, st, ions, vxc, stress_xc_nlcc)
611 real(real64), intent(in) :: rcell_volume
612 type(grid_t), intent(in) :: gr
613 type(states_elec_t), intent(in) :: st
614 type(ions_t), intent(in) :: ions
615 real(real64), intent(in) :: vxc(:,:)
616 real(real64), intent(out) :: stress_xc_nlcc(3, 3)
617
618 integer :: idir, jdir, iat
619 real(real64), allocatable :: vxc_tot(:), nlcc_grad_x(:,:,:)
620
621 call profiling_in("STRESS_FROM_XC_NLCC")
622 push_sub(stress_from_xc_nlcc)
623
624 assert(allocated(st%rho_core))
625
626 stress_xc_nlcc = m_zero
627
628 safe_allocate(vxc_tot(1:gr%np))
629 safe_allocate(nlcc_grad_x(1:gr%np, 1:gr%der%dim, 1:gr%der%dim))
630
631 ! Sum over spin of the xc potential
632 call lalg_copy(gr%np, vxc(:, 1), vxc_tot)
633 if(st%d%nspin > 1) call lalg_axpy(gr%np, m_one, vxc(:, 2), vxc_tot)
634
635 do iat = ions%atoms_dist%start, ions%atoms_dist%end
636 call species_get_nlcc_grad(ions%atom(iat)%species, ions%space, ions%latt, &
637 ions%pos(:,iat), gr, nlcc_grad_x)
638
639 do idir = 1, ions%space%periodic_dim
640 do jdir = idir, ions%space%periodic_dim
641 stress_xc_nlcc(idir, jdir) = stress_xc_nlcc(idir, jdir) &
642 - dmf_dotp(gr, nlcc_grad_x(:, idir, jdir), vxc_tot)
643 end do
644 end do
645 end do
646 safe_deallocate_a(nlcc_grad_x)
647 safe_deallocate_a(vxc_tot)
648
649 if (ions%atoms_dist%parallel) then
650 call comm_allreduce(ions%atoms_dist%mpi_grp, stress_xc_nlcc)
651 end if
652
653 call upper_triangular_to_hermitian(ions%space%periodic_dim, stress_xc_nlcc)
654
655 stress_xc_nlcc(:,:) = stress_xc_nlcc(:,:) / rcell_volume
656
657 call profiling_out("STRESS_FROM_XC_NLCC")
658 pop_sub(stress_from_xc_nlcc)
659 end subroutine stress_from_xc_nlcc
660
661 ! -------------------------------------------------------
681 subroutine stress_from_pseudo_nonloc(gr, st, hm, ions, stress_ps_nl)
682 type(grid_t), target, intent(in) :: gr
683 type(states_elec_t), intent(inout) :: st
684 type(hamiltonian_elec_t), intent(in) :: hm
685 type(ions_t), intent(in) :: ions
686 real(real64), intent(out) :: stress_ps_nl(3, 3)
687
688 integer :: ik, ist, idir, jdir
689 integer :: ib, minst, maxst
690 type(wfs_elec_t) :: psib, rvnl_psib(3), gpsib(3)
691 complex(real64), allocatable :: stress_tmp(:)
692
693 call profiling_in("STRESS_FROM_PSEUDO_NL")
695
696 assert(st%wfs_type == type_cmplx)
697
698 safe_allocate(stress_tmp(1:st%block_size))
699
700 stress_ps_nl = m_zero
701
702 do ik = st%d%kpt%start, st%d%kpt%end
703
704 if (st%kweights(ik) <= m_epsilon) cycle
706 do ib = st%group%block_start, st%group%block_end
707 minst = states_elec_block_min(st, ib)
708 maxst = states_elec_block_max(st, ib)
709
710 call hm%phase%copy_and_set_phase(gr, st%d%kpt, st%group%psib(ib, ik), psib)
711
712 ! calculate the gradient
713 call zderivatives_batch_grad(gr%der, psib, gpsib, set_bc=.false.)
714
715
716 ! Get rV_NL |\psi> for all atoms
717 do idir = 1, gr%der%dim
718 call psib%copy_to(rvnl_psib(idir))
719 call batch_set_zero(rvnl_psib(idir))
720 end do
721 call hm%vnl%zr_vn_local(gr, st%d, gr%der%boundaries%spiral, psib, rvnl_psib)
722
723 do idir = 1, ions%space%periodic_dim
724 do jdir = idir, ions%space%periodic_dim
725 call zmesh_batch_dotp_vector(gr, gpsib(idir), rvnl_psib(jdir), stress_tmp)
726
727 do ist = minst, maxst
728 stress_ps_nl(idir, jdir) = stress_ps_nl(idir, jdir) &
729 + m_two * st%kweights(ik) * st%occ(ist, ik) * real(stress_tmp(ist-minst+1), real64)
730 end do
731
732 end do
733 end do
734
735 do idir = 1, gr%der%dim
736 call rvnl_psib(idir)%end()
737 call gpsib(idir)%end()
738 end do
739 call psib%end()
740 end do
741 end do
742
743 safe_deallocate_a(stress_tmp)
744
745 if (st%parallel_in_states .or. st%d%kpt%parallel) then
746 call comm_allreduce(st%st_kpt_mpi_grp, stress_ps_nl)
747 end if
748
749 ! Symmetrize the kinetic stress tensor
750 call upper_triangular_to_hermitian(ions%space%periodic_dim, stress_ps_nl)
751
752 ! Symmetrize the stress tensor if we use k-point symmetries
753 if (hm%kpoints%use_symmetries) then
754 call dsymmetrize_tensor_cart(gr%symm, stress_ps_nl, use_non_symmorphic=.true.)
755 end if
756
757 ! Add the nonlocal energy
758 do idir = 1, ions%space%periodic_dim
759 stress_ps_nl(idir, idir) = stress_ps_nl(idir, idir) + hm%energy%extern_non_local
760 end do
761
762 stress_ps_nl = stress_ps_nl/ions%latt%rcell_volume
763
764 call profiling_out("STRESS_FROM_PSEUDO_NL")
766
767 end subroutine stress_from_pseudo_nonloc
768
769
770 ! -------------------------------------------------------
790 subroutine stress_from_pseudo_local(gr, hm, ions, rho_total, grad_vh, stress_ps_local)
791 type(grid_t), target, intent(in) :: gr
792 type(hamiltonian_elec_t), intent(in) :: hm
793 type(ions_t), intent(in) :: ions
794 real(real64), contiguous, intent(inout) :: rho_total(:)
795 real(real64), intent(in) :: grad_vh(:,:)
796 real(real64), intent(out) :: stress_ps_local(3, 3)
797
798
799 real(real64) :: stress_SR(3, 3), stress_LR(3, 3)
800 real(real64) :: energy_ps_SR, charge, zi
801 real(real64), allocatable :: vloc(:), rvloc(:,:), rho_local_lr(:), rho_lr(:)
802 real(real64), allocatable :: grad_rho(:,:), rho_lr_x(:,:), vlr(:), grad_vlr(:,:)
803 integer :: idir, jdir, iatom
804 type(ps_t), pointer :: spec_ps
805
806 call profiling_in("STRESS_FROM_PSEUDO_LOC")
808
809 ! calculate stress from short-range local pseudopotentials
810 stress_sr = m_zero
811
812 safe_allocate(vloc(1:gr%np))
813 vloc = m_zero
814 safe_allocate(rvloc(1:gr%np, 1:gr%der%dim))
815 rvloc = m_zero
816 do iatom = 1, ions%natoms
817 call epot_local_pseudopotential_sr(gr, ions, iatom, vloc, rvloc)
818 end do
819 safe_deallocate_a(vloc)
820
821 safe_allocate(grad_rho(1:gr%np,1:gr%der%dim))
822 call dderivatives_grad(gr%der, rho_total, grad_rho)
823
824 energy_ps_sr = hm%energy%extern_local
825 do idir = 1, ions%space%periodic_dim
826 do jdir = idir, ions%space%periodic_dim
827 stress_sr(idir, jdir) = stress_sr(idir, jdir) &
828 +dmf_dotp(gr, rvloc(:, jdir), grad_rho(:, idir))
829 end do
830 stress_sr(idir,idir) = stress_sr(idir,idir) + energy_ps_sr
831 end do
832
833 call upper_triangular_to_hermitian(ions%space%periodic_dim, stress_sr)
834
835 stress_sr = stress_sr/ions%latt%rcell_volume
836
837 safe_deallocate_a(rvloc)
838 safe_deallocate_a(grad_rho)
839
840
841 ! calculate stress from long-range local pseudopotentials
842 stress_lr = m_zero
843
844 ! We treat the long-range part of the local potential as the Hartree term
845 ! We first sum the long range densities from atoms
846 safe_allocate(rho_lr(1:gr%np_part))
847 safe_allocate(rho_lr_x(1:gr%np, 1:gr%der%dim))
848 rho_lr = m_zero
849 rho_lr_x = m_zero
850 safe_allocate(rho_local_lr(1:gr%np))
851 do iatom = ions%atoms_dist%start, ions%atoms_dist%end
852 assert(ions%atom(iatom)%species%is_ps())
853 call species_get_long_range_density(ions%atom(iatom)%species, ions%namespace, ions%space, ions%latt, &
854 ions%pos(:, iatom), gr, rho_local_lr, nlr_x=rho_lr_x)
855
856 call lalg_axpy(gr%np, m_one, rho_local_lr, rho_lr)
857 end do
858 safe_deallocate_a(rho_local_lr)
859
860 if (ions%atoms_dist%parallel) then
861 call comm_allreduce(ions%atoms_dist%mpi_grp, rho_lr)
862 call comm_allreduce(ions%atoms_dist%mpi_grp, rho_lr_x)
863 end if
864
865 do idir = 1, ions%space%periodic_dim
866 do jdir = idir, ions%space%periodic_dim
867 stress_lr(idir, jdir) = stress_lr(idir, jdir) + dmf_dotp(gr, rho_lr_x(:,jdir), grad_vh(:, idir))
868 end do
869 end do
870 safe_deallocate_a(rho_lr_x)
871
872 safe_allocate(vlr(1:gr%np_part))
873 call dpoisson_solve(hm%psolver, ions%namespace, vlr, rho_lr, all_nodes = .true.)
874 safe_deallocate_a(rho_lr)
875
876 safe_allocate(grad_vlr(1:gr%np, 1:gr%der%dim))
877 call dderivatives_grad(gr%der, vlr, grad_vlr)
878 safe_deallocate_a(vlr)
879
880 do idir = 1, ions%space%periodic_dim
881 do jdir = idir, ions%space%periodic_dim
882 stress_lr(idir, jdir) = stress_lr(idir, jdir) - dmf_dotp(gr, grad_vh(:,idir), grad_vlr(:, jdir))/m_two/m_pi
883 end do
884 end do
886 call upper_triangular_to_hermitian(ions%space%periodic_dim, stress_lr)
887
888 safe_deallocate_a(grad_vlr)
889
890 ! Contribution from G=0 component of the long-range part
891 !
892 if (ions%space%periodic_dim == 3) then
893 charge = m_zero
894 do iatom = 1, ions%natoms
895 charge = charge + ions%atom(iatom)%species%get_zval()
896 end do
897
898 do iatom = 1, ions%natoms
899 select type(spec => ions%atom(iatom)%species)
900 type is(pseudopotential_t)
901 zi = spec%get_zval()
902 spec_ps => spec%ps
903
904 do idir = 1, ions%space%periodic_dim
905 stress_lr(idir, idir) = stress_lr(idir, idir) &
906 + m_two*m_pi*spec_ps%sigma_erf**2*charge*zi /ions%latt%rcell_volume
907 end do
908 end select
909 end do
910 end if
911
912 stress_lr = stress_lr/ions%latt%rcell_volume
913
914 stress_ps_local = stress_sr + stress_lr
915
916 call profiling_out("STRESS_FROM_PSEUDO_LOC")
918
919 end subroutine stress_from_pseudo_local
920
921 ! -------------------------------------------------------
922 subroutine epot_local_pseudopotential_sr(mesh, ions, iatom, vpsl, rvpsl)
923 class(mesh_t), intent(in) :: mesh
924 type(ions_t), intent(in) :: ions
925 integer, intent(in) :: iatom
926 real(real64), intent(inout) :: vpsl(:)
927 real(real64), intent(inout) :: rvpsl(:,:)
928
929 integer :: ip
930 real(real64) :: radius, vl_ip
931 type(submesh_t) :: sphere
932 type(ps_t), pointer :: ps
933
935
936 if (.not. ions%atom(iatom)%species%is_ps()) then
938 return
939 endif
940
941 call profiling_in("EPOT_LOCAL_PS_SR")
942
943 select type(spec=>ions%atom(iatom)%species)
944 type is(pseudopotential_t)
945
946 ps => spec%ps
947
948 radius = ps%vl%x_threshold*1.05_real64
949
950 call submesh_init(sphere, ions%space, mesh, ions%latt, ions%pos(:, iatom), radius)
951
952 ! Cannot be written (correctly) as a vector expression since for periodic systems,
953 ! there can be values ip, jp such that sphere%map(ip) == sphere%map(jp).
954 do ip = 1, sphere%np
955 vl_ip = spline_eval(ps%vl, sphere%r(ip))
956 vpsl(sphere%map(ip)) = vpsl(sphere%map(ip)) + vl_ip
957 rvpsl(sphere%map(ip), 1:ions%space%periodic_dim) = rvpsl(sphere%map(ip), 1:ions%space%periodic_dim) &
958 + sphere%rel_x(1:ions%space%periodic_dim, ip) * vl_ip
959 end do
960
961 call submesh_end(sphere)
962
963 nullify(ps)
964
965 end select
966
967 call profiling_out("EPOT_LOCAL_PS_SR")
969 end subroutine epot_local_pseudopotential_sr
970
971
972 ! -------------------------------------------------------
987 subroutine stress_from_hubbard(namespace, gr, st, hm, space, rcell_volume, stress_hubbard)
988 type(namespace_t), intent(in) :: namespace
989 type(grid_t), target, intent(in) :: gr
990 type(states_elec_t), intent(in) :: st
991 type(hamiltonian_elec_t), intent(in) :: hm
992 type(space_t), intent(in) :: space
993 real(real64), intent(in) :: rcell_volume
994 real(real64), intent(out) :: stress_hubbard(3, 3)
995
996 integer :: ik, ist, idir, jdir
997 integer :: ib, minst, maxst
998 type(wfs_elec_t) :: psib, rvu_psib(3), gpsib(3)
999 complex(real64), allocatable :: stress_tmp(:)
1000
1001 if (hm%lda_u%level == dft_u_none) then
1002 stress_hubbard = m_zero
1003 return
1004 end if
1005
1006 push_sub_with_profile(stress_from_hubbard)
1007
1008 assert(st%wfs_type == type_cmplx)
1009
1010 safe_allocate(stress_tmp(1:st%block_size))
1011
1012 stress_hubbard = m_zero
1013
1014 do ik = st%d%kpt%start, st%d%kpt%end
1015
1016 if (st%kweights(ik) <= m_epsilon) cycle
1018 do ib = st%group%block_start, st%group%block_end
1019 minst = states_elec_block_min(st, ib)
1020 maxst = states_elec_block_max(st, ib)
1021
1022 call hm%phase%copy_and_set_phase(gr, st%d%kpt, st%group%psib(ib, ik), psib)
1023
1024 ! calculate the gradient
1025 call zderivatives_batch_grad(gr%der, psib, gpsib, set_bc=.false.)
1026
1027 ! Get rV_U |\psi> for all atoms
1028 do idir = 1, gr%der%dim
1029 call psib%copy_to(rvu_psib(idir))
1030 call batch_set_zero(rvu_psib(idir))
1031 end do
1032
1033 call zlda_u_rvu(hm%lda_u, gr, space, hm%d, namespace, psib, rvu_psib)
1034
1035 do idir = 1,3
1036 do jdir = idir,3
1037 call zmesh_batch_dotp_vector(gr, gpsib(idir), rvu_psib(jdir), stress_tmp)
1038
1039 do ist = minst, maxst
1040 stress_hubbard(idir, jdir) = stress_hubbard(idir, jdir) &
1041 + m_two * st%kweights(ik) * st%occ(ist, ik) * real(stress_tmp(ist-minst+1), real64)
1042 end do
1043
1044 end do
1045 end do
1046
1047 do idir = 1, gr%der%dim
1048 call rvu_psib(idir)%end()
1049 call gpsib(idir)%end()
1050 end do
1051 call psib%end()
1052 end do
1053 end do
1054
1055 safe_deallocate_a(stress_tmp)
1056
1057 if (st%parallel_in_states .or. st%d%kpt%parallel) then
1058 call comm_allreduce(st%st_kpt_mpi_grp, stress_hubbard)
1059 end if
1060
1061 ! Symmetrize the kinetic stress tensor
1062 call upper_triangular_to_hermitian(gr%der%dim, stress_hubbard)
1063
1064 ! Symmetrize the stress tensor if we use k-point symmetries
1065 if (hm%kpoints%use_symmetries) then
1066 call dsymmetrize_tensor_cart(gr%symm, stress_hubbard)
1067 end if
1068
1069 ! Add the Hubbard energy
1070 do idir = 1,3
1071 stress_hubbard(idir, idir) = stress_hubbard(idir, idir) + hm%energy%int_dft_u
1072 end do
1073
1074 stress_hubbard = stress_hubbard/rcell_volume
1075
1076 pop_sub_with_profile(stress_from_hubbard)
1077 end subroutine stress_from_hubbard
1078
1079
1080 ! -------------------------------------------------------
1081 subroutine output_stress(iunit, space_dim, stress_tensors, all_terms)
1082 integer, intent(in) :: iunit
1083 integer, intent(in) :: space_dim
1084 type(stress_t), intent(in) :: stress_tensors
1085 logical, optional, intent(in) :: all_terms
1086
1087 logical :: write_all_terms
1088 character(len=16) :: stress_unit
1089
1090 write_all_terms = optional_default(all_terms, .true.)
1091
1092 write(stress_unit, '(4a,i1)') trim(units_abbrev(units_out%energy)), '/', &
1093 trim(units_abbrev(units_out%length)), '^', space_dim
1094
1095 if (mpi_world%is_root()) then
1096
1097 if (write_all_terms) then
1098 write(iunit, '(3a)') 'Kinetic stress tensor [', trim(stress_unit), '] ='
1099 call print_stress_tensor(iunit, space_dim, stress_tensors%kinetic)
1100 if (space_dim == 3) then
1101 write(iunit, '(a, es15.6, 3a)') 'Kinetic pressure sumrule violation: ', &
1102 units_from_atomic(units_out%energy, stress_tensors%kinetic_sumrule), &
1103 ' [', trim(units_abbrev(units_out%energy)), ']'
1104 write(iunit,*)
1105 end if
1106
1107
1108 write(iunit, '(3a)') 'Hartree stress tensor [', trim(stress_unit), '] ='
1109 call print_stress_tensor(iunit, space_dim, stress_tensors%Hartree)
1110 if (space_dim == 3) then
1111 write(iunit, '(a, es15.6, 3a)') 'Hartree pressure sumrule violation: ', &
1112 units_from_atomic(units_out%energy, stress_tensors%hartree_sumrule), &
1113 ' [', trim(units_abbrev(units_out%energy)), ']'
1114 write(iunit,*)
1115 end if
1116
1117 write(iunit, '(3a)') 'XC stress tensor [', trim(stress_unit), '] ='
1118 call print_stress_tensor(iunit, space_dim, stress_tensors%xc)
1119
1120 write(iunit, '(3a)') 'XC NLCC stress tensor [', trim(stress_unit), '] ='
1121 call print_stress_tensor(iunit, space_dim, stress_tensors%xc_nlcc)
1122
1123 write(iunit, '(3a)') 'Local pseudo. stress tensor [', trim(stress_unit), '] ='
1124 call print_stress_tensor(iunit, space_dim, stress_tensors%ps_local)
1125
1126 write(iunit, '(3a)') 'Nonlocal pseudo. stress tensor [', trim(stress_unit), '] ='
1127 call print_stress_tensor(iunit, space_dim, stress_tensors%ps_nl)
1128
1129 write(iunit, '(3a)') 'Ion-ion stress tensor [', trim(stress_unit), '] ='
1130 call print_stress_tensor(iunit, space_dim, stress_tensors%ion_ion)
1131
1132 write(iunit, '(3a)') 'vdW stress tensor [', trim(stress_unit), '] ='
1133 call print_stress_tensor(iunit, space_dim, stress_tensors%vdw)
1134
1135 write(iunit, '(3a)') 'Hubbard stress tensor [', trim(stress_unit), '] ='
1136 call print_stress_tensor(iunit, space_dim, stress_tensors%hubbard)
1137 end if
1138
1139 write(iunit, '(3a)') 'Total stress tensor [', trim(stress_unit), '] ='
1140 call print_stress_tensor(iunit, space_dim, stress_tensors%total)
1141
1142 end if
1143 end subroutine output_stress
1144
1145
1146 subroutine output_pressure(iunit, space_dim, total_stress_tensor)
1147 integer, intent(in) :: iunit
1148 integer, intent(in) :: space_dim
1149 real(real64), intent(in) :: total_stress_tensor(3,3)
1150
1151 integer :: idim
1152 real(real64) :: pressure
1153 character(len=16) :: stress_unit
1154
1155 write(stress_unit, '(4a,i1)') trim(units_abbrev(units_out%energy)), '/', &
1156 trim(units_abbrev(units_out%length)), '^', space_dim
1157
1158 pressure = m_zero
1159 do idim = 1, space_dim
1160 pressure = pressure - total_stress_tensor(idim, idim) / real(space_dim, real64)
1161 end do
1162
1163 write(iunit,'(3a,es16.8)', advance="no") 'Pressure [', trim(stress_unit), '] = ', &
1164 units_from_atomic(units_out%energy/units_out%length**space_dim, pressure)
1165 if (space_dim == 3) then
1166 write(iunit,'(2x,a,f16.8)') 'Pressure [GPa] = ', units_from_atomic(unit_gpa, pressure)
1167 else
1168 write(iunit,*)
1169 end if
1170
1171 end subroutine output_pressure
1172
1173 subroutine print_stress_tensor(ounit, space_dim, tensor)
1174 integer, intent(in) :: ounit
1175 integer, intent(in) :: space_dim
1176 real(real64), intent(in) :: tensor(3,3)
1177
1178 real(real64) :: tensor_with_unit(3,3)
1179 integer :: idim, jdim
1180
1181 tensor_with_unit = units_from_atomic(units_out%energy/units_out%length**space_dim, tensor)
1182
1183 write(ounit,'(a9,2x)', advance="no")"T_{ij}"
1184 do jdim = 1, space_dim
1185 write(ounit,'(i18)', advance="no") jdim
1186 end do
1187 write(ounit,*)
1188 do idim = 1, space_dim
1189 write(ounit,'(i9,2x)', advance="no") idim
1190 do jdim = 1, space_dim
1191 write(ounit,'(es18.9)', advance="no") tensor_with_unit(idim, jdim)
1192 end do
1193 write(ounit,*)
1194 end do
1195 write(ounit,*)
1196
1197 end subroutine print_stress_tensor
1198
1199
1200end module stress_oct_m
1201
1202!! Local Variables:
1203!! mode: f90
1204!! coding: utf-8
1205!! End:
constant times a vector plus a vector
Definition: lalg_basic.F90:173
Copies a vector x, to a vector y.
Definition: lalg_basic.F90:188
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:118
subroutine, public batch_set_zero(this, np, async)
fill all mesh functions of the batch with zero
Definition: batch_ops.F90:265
Module implementing boundary conditions in Octopus.
Definition: boundaries.F90:124
This module implements a calculator for the density and defines related functions.
Definition: density.F90:122
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dderivatives_grad(der, ff, op_ff, ghost_update, set_bc, to_cartesian)
apply the gradient to a mesh function
subroutine, public zderivatives_batch_grad(der, ffb, opffb, ghost_update, set_bc, to_cartesian, factor)
apply the gradient to a batch of mesh functions
integer, parameter, public spinors
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,...
integer, parameter, public scalar_relativistic_zora
Definition: epot.F90:168
integer, parameter, public fully_relativistic_zora
Definition: epot.F90:168
real(real64), parameter, public m_two
Definition: global.F90:202
real(real64), parameter, public m_zero
Definition: global.F90:200
real(real64), parameter, public m_four
Definition: global.F90:204
real(real64), parameter, public m_pi
some mathematical constants
Definition: global.F90:198
integer, parameter, public independent_particles
Theory level.
Definition: global.F90:250
integer, parameter, public generalized_kohn_sham_dft
Definition: global.F90:250
integer, parameter, public kohn_sham_dft
Definition: global.F90:250
real(real64), parameter, public m_epsilon
Definition: global.F90:216
real(real64), parameter, public m_one
Definition: global.F90:201
This module implements the underlying real-space grid.
Definition: grid.F90:119
This module defines classes and functions for interaction partners.
Definition: io.F90:116
subroutine, public ion_interaction_stress(this, space, latt, atom, natoms, pos, stress_ii)
Computes the contribution to the stress tensor the ion-ion energy.
A module to handle KS potential, without the external potential.
integer, parameter, public dft_u_none
Definition: lda_u.F90:205
subroutine, public zlda_u_rvu(this, mesh, space, d, namespace, psib, gpsib)
This routine computes .
Definition: lda_u.F90:5413
This modules implements the routines for doing constrain DFT for noncollinear magnetism.
integer, parameter, public constrain_none
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:117
This module defines functions over batches of mesh functions.
Definition: mesh_batch.F90:118
subroutine, public zmesh_batch_dotp_vector(mesh, aa, bb, dot, reduce, cproduct)
A simple switch between specialized kernels and generic kernels.
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:120
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1068
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
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:272
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel, reset)
Calculates the Poisson equation. Given the density returns the corresponding potential.
Definition: poisson.F90:1019
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
Definition: ps.F90:116
subroutine, public species_get_long_range_density(species, namespace, space, latt, pos, mesh, rho, sphere_inout, nlr_x)
subroutine, public species_get_nlcc_grad(species, space, latt, pos, mesh, rho_core_grad_x)
Returns the (r-R_I)-weighted analytic gradient of the NLCC core density.
real(real64) function, public spline_eval(spl, x)
Definition: splines.F90:441
This module handles spin dimensions of the states and the k-point distribution.
integer pure function, public states_elec_block_max(st, ib)
return index of last state in block ib
integer pure function, public states_elec_block_min(st, ib)
return index of first state in block ib
This module implements the calculation of the stress tensor.
Definition: stress.F90:120
subroutine stress_from_hartree(gr, space, volume, grad_vh, ehartree, stress_Hartree)
Computes the contribution to the stress tensor from the Hartree energy.
Definition: stress.F90:527
subroutine stress_from_kinetic(gr, space, hm, st, symm, rcell_volume, stress_kin)
Computes the contribution to the stress tensor from the kinetic energy.
Definition: stress.F90:438
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.
Definition: stress.F90:886
subroutine print_stress_tensor(ounit, space_dim, tensor)
Definition: stress.F90:1269
subroutine, public output_pressure(iunit, space_dim, total_stress_tensor)
Definition: stress.F90:1242
subroutine epot_local_pseudopotential_sr(mesh, ions, iatom, vpsl, rvpsl)
Definition: stress.F90:1018
subroutine, public stress_calculate(namespace, gr, hm, st, ions, ks, ext_partners)
This computes the total stress on the lattice.
Definition: stress.F90:188
subroutine stress_from_hubbard(namespace, gr, st, hm, space, rcell_volume, stress_hubbard)
Computes the contribution to the stress tensor from the Hubbard energy.
Definition: stress.F90:1083
subroutine stress_from_xc(gr, hm, st, space, rcell_volume, stress_xc)
Computes the contribution to the stress tensor from the xc energy.
Definition: stress.F90:586
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.
Definition: stress.F90:706
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.
Definition: stress.F90:777
subroutine, public output_stress(iunit, space_dim, stress_tensors, all_terms)
Definition: stress.F90:1177
subroutine, public submesh_end(this)
Definition: submesh.F90:680
subroutine, public submesh_init(this, space, mesh, latt, center, rc)
Definition: submesh.F90:226
subroutine, public dsymmetrize_tensor_cart(symm, tensor, use_non_symmorphic)
Symmetric a rank-2 tensor defined in Cartesian space.
type(type_t), parameter, public type_cmplx
Definition: types.F90:136
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:134
character(len=20) pure function, public units_abbrev(this)
Definition: unit.F90:225
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
type(unit_t), public unit_gpa
For output pressure in GPa.
Definition: xc.F90:120
logical pure function, public family_is_mgga_with_exc(xcs)
Is the xc function part of the mGGA family with an energy functional.
Definition: xc.F90:734
logical pure function, public xc_is_energy_functional(xcs)
Is one of the x or c functional is not an energy functional.
Definition: xc.F90:844
pure logical function, public in_family(family, xc_families)
Definition: xc.F90:762
A module that takes care of xc contribution from vdW interactions.
Definition: xc_vdw.F90:118
integer(int64), dimension(5), parameter, public d3_lib_options
VDWCORRECTION options that correspond to the DFT-D3 library.
Definition: xc_vdw.F90:171
Description of the grid, containing information on derivatives, stencil, and symmetries.
Definition: grid.F90:171
Describes mesh distribution to nodes.
Definition: mesh.F90:187
A type storing the information and data about a pseudopotential.
Definition: ps.F90:188
The states_elec_t class contains all electronic wave functions.
A submesh is a type of mesh, used for the projectors in the pseudopotentials It contains points on a ...
Definition: submesh.F90:174
batches of electronic states
Definition: wfs_elec.F90:141
int true(void)