atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
grfft.F90
Go to the documentation of this file.
1! This file is part of the 'atomes' software.
2!
3! 'atomes' is free software: you can redistribute it and/or modify it under the terms
4! of the GNU Affero General Public License as published by the Free Software Foundation,
5! either version 3 of the License, or (at your option) any later version.
6!
7! 'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8! without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9! See the GNU General Public License for more details.
10!
11! You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12! If not, see <https://www.gnu.org/licenses/>
13!
14! Copyright (C) 2022-2024 by CNRS and University of Strasbourg
15!
20
21INTEGER (KIND=c_int) FUNCTION g_of_r_fft (NDR, DTR, MMX) bind (c,name='g_of_r_fft_')
22
23USE parameters
24
25IMPLICIT NONE
26
27INTEGER (KIND=c_int), INTENT(IN) :: ndr
28real(kind=c_double), INTENT(IN) :: dtr, mmx
29INTERFACE
30 INTEGER FUNCTION recup_data (i, j)
31 INTEGER, INTENT(IN) :: i, j
32 END FUNCTION
33 LOGICAL FUNCTION grbt(GrToBT, NDTR)
34 USE parameters
35 INTEGER, INTENT(IN) :: ndtr
36 DOUBLE PRECISION, DIMENSION(NDTR,NSP,NSP), INTENT(IN) :: grtobt
37 END FUNCTION
38END INTERFACE
39
40qvmax = mmx
41number_of_i = ndr
42
43if (allocated(gfft)) deallocate(gfft)
44allocate(gfft(ndr), stat=err)
45if (err .ne. 0) then
46 call show_error ("Impossible to allocate memory"//char(0), &
47 "Function: g_of_r_fft"//char(0), "Table: GFFT"//char(0))
49 goto 001
50endif
51if (allocated(dfft)) deallocate(dfft)
52allocate(dfft(ndr), stat=err)
53if (err .ne. 0) then
54 call show_error ("Impossible to allocate memory"//char(0), &
55 "Function: g_of_r_fft"//char(0), "Table: DFFT"//char(0))
57 goto 001
58endif
59if (allocated(tdfft)) deallocate(tdfft)
60allocate(tdfft(ndr), stat=err)
61if (err .ne. 0) then
62 call show_error ("Impossible to allocate memory"//char(0), &
63 "Function: g_of_r_fft"//char(0), "Table: TDFFT"//char(0))
65 goto 001
66endif
67
68if (allocated(r_pfft)) deallocate(r_pfft)
69allocate(r_pfft(ndr), stat=err)
70if (err .ne. 0) then
71 call show_error ("Impossible to allocate memory"//char(0), &
72 "Function: g_of_r_fft"//char(0), "Table: R_PFFT"//char(0))
74 goto 001
75endif
76
77do i=1, ndr
78 r_pfft(i)= 0.0d0
79 r_pfft(i)= 1.0 / (2.0*pi*pi*na/meanvol*(i-0.5)*dtr)
80enddo
81
82j=0
83l=0
84if (recup_data(j, idsk) .ne. 1) then
86 goto 001
87endif
88
89j=4
90if (recup_data(j, idsk) .ne. 1) then
92 goto 001
93endif
94
95if (nsp .eq. 2) then
96 if (allocated(gqbt)) deallocate(gqbt)
97 allocate(gqbt(ndr,nsp,nsp), stat=err)
98 if (err .ne. 0) then
99 call show_error ("Impossible to allocate memory"//char(0), &
100 "Function: g_of_r_fft"//char(0), "Table: GQBT"//char(0))
101 g_of_r_fft=0
102 goto 001
103 endif
104endif
105
106j=j+nsp*nsp*2+2
107do n=1, nsp
108do m=1, nsp
109 j=j+2
110 if (recup_data(j, idsk) .ne. 1) then
111 g_of_r_fft=0
112 goto 001
113 endif
114enddo
115enddo
116
117if (nsp .eq. 2) then
118 if (grbt(gqbt, ndr)) then
119 do k=1, ndr
120 gfft(k)=btij(k,1)
121 enddo
122 call save_curve (ndr, gfft, l, idgrfft)
123 l = l+2
124 do k=1, ndr
125 gfft(k)=btij(k,2)
126 enddo
127 call save_curve (ndr, gfft, l, idgrfft)
128 l = l+2
129 do k=1, ndr
130 gfft(k)=btij(k,3)
131 enddo
132 call save_curve (ndr, gfft, l, idgrfft)
133 endif
134 if (allocated(btij)) deallocate(btij)
135endif
136
138
139001 continue
140
141if (allocated(gfft)) deallocate(gfft)
142if (allocated(dfft)) deallocate(dfft)
143if (allocated(tdfft)) deallocate(tdfft)
144if (allocated(r_pfft)) deallocate(r_pfft)
145if (allocated(gqbt)) deallocate(gqbt)
146
147END FUNCTION
148
149INTEGER FUNCTION send_sq (IC, VAL, DTR, KDATA, SDATA)
150
151USE parameters
152
153IMPLICIT NONE
154
155INTEGER, INTENT(IN) :: ic, val
156DOUBLE PRECISION, INTENT(IN) :: dtr
157DOUBLE PRECISION, DIMENSION(VAL), INTENT(IN) :: kdata, sdata
158DOUBLE PRECISION :: suml
159
160j = ic
161
162call fft_to_gr (val, kdata, sdata, gfft)
163
164call save_curve (number_of_i, gfft, l, idgrfft)
165l=l+2
166
167if (j.gt.4) then
168
169 if (nsp .eq. 2) then
170 do i=1, number_of_i
171 gqbt(i,n,m) = gfft(i)
172 enddo
173 endif
174 do i=1, number_of_i
175 dfft(i)= 4.0*pi*(((i-0.5)*dtr)**2)*dtr*gfft(i)/meanvol
176 if (i .gt. 1) dfft(i)= dfft(i) + dfft(i-1)
177 enddo
178 if (n .eq. m) then
179 k = (nbspbs(n)-1)
180 else
181 k = nbspbs(m)
182 endif
183 do i=1, number_of_i
184 dfft(i)= dfft(i)*k
185 enddo
186 do i=1, number_of_i
187 gfft(i)=(gfft(i)-1.0)*4.0*pi*(na/meanvol)*(i-0.5)*dtr
188 enddo
189 call save_curve (number_of_i, gfft, l, idgrfft)
190 l=l+2
191 call save_curve (number_of_i, dfft, l, idgrfft)
192 l=l+1
193
194else
195
196 suml=0.0d0
197 do k=1, nsp
198 if (j .eq. 0) then
199 suml=suml+nscattl(k)*xi(k)
200 else
201 suml=suml+xscattl(k)*xi(k)
202 endif
203 enddo
204 suml=suml*suml
205 do i=1, number_of_i
206 gfft(i)=(gfft(i)-1.0)*4.0*pi*(na/meanvol)*(i-0.5)*dtr
207 enddo
208 call save_curve (number_of_i, gfft, l, idgrfft)
209 l=l+2
210 do i=1, number_of_i
211 tdfft(i) = gfft(i)*suml
212 enddo
213 call save_curve (number_of_i, tdfft, l, idgrfft)
214 l=l+2
215 do i=1, number_of_i
216 tdfft(i) = tdfft(i) + 4.0*pi*(na/meanvol)*(i-0.5)*dtr*suml
217 enddo
218 call save_curve (number_of_i, tdfft, l, idgrfft)
219 l=l+2
220
221endif
222
223send_sq = 1
224
225CONTAINS
226
227SUBROUTINE fft_to_gr (LTAB, KTAB, TAB, RTAB)
228
229USE parameters
230
231INTEGER, INTENT(IN) :: LTAB
232DOUBLE PRECISION, DIMENSION(LTAB), INTENT(IN) :: KTAB, TAB
233DOUBLE PRECISION, DIMENSION(NUMBER_OF_I), INTENT(INOUT) :: RTAB
234
235do i=1, number_of_i
236 rtab(i)= 0.0d0
237 do k=1, ltab-1
238 phi = ktab(k)*(i-0.5)*dtr
239 rtab(i) = rtab(i) + ktab(k)*(tab(k) - 1.0)*sin(phi)*(ktab(k+1) - ktab(k))
240 enddo
241 rtab(i) = 1.0 + r_pfft(i) * rtab(i)
242enddo
243
244END SUBROUTINE
245
246END FUNCTION
logical function grbt(grtobt, ndtr)
Definition fzbt.F90:114
subroutine fft_to_gr(ltab, ktab, tab, rtab)
Definition grfft.F90:228
integer function send_sq(ic, val, dtr, kdata, sdata)
Definition grfft.F90:150
integer(kind=c_int) function g_of_r_fft(ndr, dtr, mmx)
Definition grfft.F90:22
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
double precision, dimension(:), allocatable nscattl
double precision, dimension(:), allocatable r_pfft
double precision, dimension(:), allocatable xi
integer, dimension(:), allocatable nbspbs
double precision phi
double precision, dimension(:), allocatable tdfft
double precision, dimension(:), allocatable xscattl
integer idgrfft
double precision meanvol
double precision, dimension(:), allocatable dfft
double precision, dimension(:), allocatable gfft
double precision, dimension(:,:,:), allocatable gqbt
integer nsp
double precision, parameter pi
integer number_of_i