Line data Source code
1 : !!****m* ABINIT/m_lattice_lwf_map
2 : !! NAME
3 : !! m_lattice_lwf_map
4 : !!
5 : !! FUNCTION
6 : !! This module contains the functions to map between Lattice and lwf, including the amplitude, and the force.
7 : !!
8 : !!
9 : !! Subroutines:
10 : !!
11 : !! COPYRIGHT
12 : !! Copyright (C) 2001-2026 ABINIT group (hexu)
13 : !! This file is distributed under the terms of the
14 : !! GNU General Public License, see ~abinit/COPYING
15 : !! or http://www.gnu.org/copyleft/gpl.txt .
16 : !! For the initials of contributors, see ~abinit/doc/developers/contributors.txt .
17 : !!
18 : !! SOURCE
19 :
20 :
21 : #if defined HAVE_CONFIG_H
22 : #include "config.h"
23 : #endif
24 : #include "abi_common.h"
25 :
26 : module m_lattice_lwf_map
27 : use, intrinsic :: iso_c_binding
28 : !use m_dynamic_array, only: int_array_type, real_array_type, int2d_array_type
29 : use defs_basis
30 : use m_abicore
31 : use m_errors
32 : use m_nctk
33 : !use m_spmat_spvec, only: sp_real_vec
34 : use m_spmat_coo, only: COO_mat_t
35 : use netcdf
36 : implicit none
37 : private
38 : !!***
39 :
40 : type, public :: lwf_latt_coeff_t
41 : type(COO_mat_t), public :: coeffs
42 : contains
43 : procedure :: initialize
44 : procedure :: finalize
45 : procedure :: lattice_to_lwf_projection
46 : procedure :: lwf_force_to_lattice
47 : procedure :: lwf_amp_to_displacements
48 : end type lwf_latt_coeff_t
49 :
50 : contains
51 :
52 1 : subroutine initialize(self, nlwf, natom)
53 : class(lwf_latt_coeff_t), intent(inout) :: self
54 : integer, intent(in) :: nlwf, natom
55 3 : call self%coeffs%initialize([natom, nlwf])
56 1 : end subroutine initialize
57 :
58 12 : subroutine finalize(self)
59 : class(lwf_latt_coeff_t), intent(inout) :: self
60 12 : call self%coeffs%finalize()
61 12 : end subroutine finalize
62 :
63 :
64 : !===============================================================
65 : ! Project lattice distortion amplitudes to lwf amplitudes
66 : !> @
67 : !===============================================================
68 0 : subroutine lattice_to_lwf_projection(self, latt_amp, lwf_amp)
69 : class(lwf_latt_coeff_t), intent(in) :: self
70 : real(dp), intent(in) :: latt_amp(:,:)
71 : real(dp), intent(inout) :: lwf_amp(:)
72 : ! integer :: ilwf, nlwf
73 : ! nlwf=size(coeffs)
74 : ! do ilwf=1, nlwf
75 : ! lwf_amp(ilwf) = coeffs(ilwf)%dot(latt_amp)
76 : ! end do
77 0 : call self%coeffs%mv(latt_amp, lwf_amp)
78 0 : end subroutine lattice_to_lwf_projection
79 :
80 : !===============================================================
81 : ! Map force on lwf to force on lattice
82 : !> @
83 : !===============================================================
84 0 : subroutine lwf_force_to_lattice(self, lwf_force, latt_force)
85 : class(lwf_latt_coeff_t), intent(in) :: self
86 : real(dp), intent(in) :: lwf_force(:)
87 : real(dp), intent(out) :: latt_force(:,:)
88 : !nlwf=size(coeffs)
89 : !do ilwf=1, nlwf
90 : ! call coeffs(ilwf)%plus_Ax(lwf_force(ilwf), latt_force)
91 : !end do
92 0 : call self%coeffs%mv_left(lwf_force, latt_force)
93 0 : end subroutine lwf_force_to_lattice
94 :
95 : !===============================================================
96 : ! Map lwf amplitudes to lattice amplitudes
97 : !> @
98 : !===============================================================
99 0 : subroutine lwf_amp_to_displacements(self, lwf, displacement)
100 : class(lwf_latt_coeff_t), intent(in) :: self
101 : real(dp), intent(in) :: lwf(:)
102 : real(dp), intent(inout) :: displacement(:,:)
103 : ! integer :: ilwf, nlwf
104 : ! nlwf=size(coeffs)
105 : ! do ilwf=1, nlwf
106 : ! call coeffs(ilwf)%plus_Ax(lwf(ilwf), displacement)
107 : ! end do
108 0 : call self%coeffs%mv_left(lwf, displacement)
109 0 : end subroutine lwf_amp_to_displacements
110 :
111 0 : end module m_lattice_lwf_map
112 :
|