-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModule_Thickness_Inte_GFD_Bercovici.f90
333 lines (263 loc) · 10.5 KB
/
Module_Thickness_Inte_GFD_Bercovici.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
MODULE MODULE_THICKNESS_INTE_GFD_BERCOVICI
CONTAINS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!! SUBROUTINE THICKNESS_NEWTON_SOLVER
SUBROUTINE THICKNESS_INTE_GFD_BERCOVICI(H,P,T,BL,Ts,Dt,Dr,M,dist,ray,el,grav,sigma,nu,delta0,&
&gam,Inter_Q,z,F_err,theta,tmps)
!*****************************************************************
!Solve for the thickness in the thickenss evolution equation using the Newton
! method
!*****************************************************************
IMPLICIT NONE
! Tableaux
DOUBLE PRECISION , DIMENSION(:,:), INTENT(INOUT) :: H,P
DOUBLE PRECISION, DIMENSIOn(:,:), INTENT(IN) :: T,BL,Ts
DOUBLE PRECISION , DIMENSION(:), INTENT(IN) :: dist,ray
!Parametre du model
DOUBLE PRECISION , INTENT(IN) :: Dt,Dr,theta
DOUBLE PRECISION, INTENT(IN) :: tmps
!Nombre sans dimensions
DOUBLE PRECISION , INTENT(IN) :: el,grav,sigma,nu,delta0,gam,Inter_Q
INTEGER, INTENT(IN) :: M, z
DOUBLE PRECISION , INTENT(INOUT) :: F_err
!Variable du sous programmes
DOUBLE PRECISION, DIMENSION(:),ALLOCATABLE :: a,b,c,S
DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: Hm,qa
DOUBLE PRECISION :: U
INTEGER :: ndyke,i,N,Size,code
INTEGER :: err1,col,algo1
LOGICAL :: cho
! Taille de la grille sur laquelle on fait l'inversion
ndyke=sigma/Dr
CHO=COUNT(H(:,1)>0.D0)<ndyke
SELECT CASE (CHO)
CASE(.TRUE.)
N = ndyke+3
CASE(.FALSE.)
N = COUNT(H(:,1)>0.d0)
END SELECT
! Caracterisation du flux
ALLOCATE(qa(1:N),stat=err1)
IF (err1>1) THEN
PRINT*, 'Erreur alloc flux';STOP
END IF
InterInjectionRate:IF (mod(tmps,Inter_Q)<Inter_Q/2D0) THEN
DO i = 1,N,1
U = 2.d0/(sigma)**4.
Flux:IF (i<ndyke+1) THEN
qa(i) = U*(1-gam*H(i,2))*(sigma**2.-dist(i)**2.)
ELSE
qa(i) = 0.d0
END IF Flux
END DO
ELSE
qa(:)=0D0
ENDIF InterInjectionRate
! Remplissage matrix
ALLOCATE(a(1:N),b(1:N),c(1:N),S(1:N),stat=err1)
IF (err1>1) THEN
PRINT*, 'Erreur allocation dans coeff Temperature'; STOP
END IF
CALL THICKNESS_MATRIX_FILL(a,b,c,S,N,M,H,P,T,BL,Ts,Dt,Dr,dist,ray,el,grav,nu,delta0,qa)
a(1)=0
c(N)=0
!Inversion de la matrice
ALLOCATE(Hm(1:N),stat=err1)
IF (err1>1) THEN
PRINT*, 'Erreur d''allocation dans vecteur Hm'; STOP
END IF
CALL TRIDIAG(a,b,c,S,N,Hm)
DO i=1,N,1
H(i,3)=Hm(i)
END DO
H(N+1:M,3) = delta0
! Calcul du soeuil F_err
IF (DOT_PRODUCT(H(:,2),H(:,2)) == 0D0) THEN
F_err = ABS(MAXVAL((Hm(:))))
ELSE
Size = COUNT(H(:,2)>1D-6)
F_err = ABS(MAXVAL((H(:Size,3)-H(:Size,2))/H(:Size,2)))
ENDIF
DEALLOCATE(Hm,a,b,c,S,qa)
END SUBROUTINE THICKNESS_INTE_GFD_BERCOVICI
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!-------------------------------------------------------------------------------------
! SUBROUTINE THICKNESS
!-------------------------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE THICKNESS_MATRIX_FILL(a,b,c,S,N,M,H,P,T,BL,Ts,Dt,Dr,dist,ray,el,grav,nu,delta0,qa)
!*****************************************************************
! Give the jacobian coeficient a1,b1,c1
!*****************************************************************
IMPLICIT NONE
! Tableaux
DOUBLE PRECISION ,DIMENSION(:) , INTENT(INOUT) :: a,b,c,S
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(IN) :: H,T,BL,Ts
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(IN) :: P
DOUBLE PRECISION ,DIMENSION(:), INTENT(IN) :: dist,ray,qa
! Prametre du model
DOUBLE PRECISION ,INTENT(IN) :: Dt,Dr
INTEGER ,INTENT(IN) :: N,M
! Nombre sans dimension
DOUBLE PRECISION ,INTENT(IN) :: el,grav,nu,delta0
! Parametre pour le sous programme
DOUBLE PRECISION :: Agrav,h_a3,Bgrav,h_b3
INTEGER :: i,col,algo1,err1
col =2
! Remplissage de la matrice Jacobienne
DO i=1,N,1
IF1: IF (i .NE. N) THEN
Agrav = grav*Dt*(ray(i)/(dist(i)*Dr**2))
! IF (H(i,col) == 0 .AND. H(i+1,col) ==0) THEN
! h_a3 =0.d0
! ENDIF
h_a3 = (0.5d0*(H(i,col)+H(i+1,col)))**3
!h_a3 =0.5*(H(i+1,col)**3+H(i,col)**3)
ENDIF IF1
IF2: IF (i .NE. 1) THEN
Bgrav=Dt*grav*(ray(i-1)/(dist(i)*Dr**2))
! IF (H(i,col) == 0 .AND. H(i-1,col) ==0) THEN
! h_a3 =0.d0
! ENDIF
! h_b3 = (H(i-1,col)+H(i,col))**3
h_b3 = (0.5d0*(H(i,col)+H(i-1,col)))**3
ENDIF IF2
IF3:IF (i==1) THEN
a(i) = 0.d0
b(i) = 1.d0+Agrav*h_a3
c(i) = -Agrav*h_a3
S(i) = H(i,1)+qa(i)*Dt
ELSEIF (i == N) THEN
a(i) = -Bgrav*h_b3
b(i) = 1.d0+Bgrav*h_b3
c(i) = 0.d0
S(i) = H(i,1)+qa(i)*Dt
ELSE
a(i) = -Bgrav*h_b3
b(i) = 1.d0+Bgrav*h_b3+Agrav*h_a3
c(i) = -Agrav*h_a3
S(i) = H(i,1)+qa(i)*Dt
END IF IF3
END DO
END SUBROUTINE THICKNESS_MATRIX_FILL
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!-------------------------------------------------------------------------------------
! SUBROUTINE NONA DIAG
!-------------------------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE NONA_DIAGO(N,Hm,a,b,c,d,e,f,g,k,l,S)
!*****************************************************************
! Solves for a vector Hm of length N the nano diagonal linear set
! M Hm = S, where A, B, C, D, E, F, G, K and L are the three main
! diagonals of matrix M(N,N), the other terms are 0.
! S is the right side vector.
!*****************************************************************
IMPLICIT NONE
INTEGER , INTENT(IN) :: N
INTEGER :: i
INTEGER :: err3,err4
DOUBLE PRECISION, DIMENSION(:), INTENT(IN) :: a,b,c,d,e,f,g,k,l,S
DOUBLE PRECISION, DIMENSION(:),INTENT(INOUT) :: Hm
DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: zeta,alpha,beta,mu,xi,lambda,eta,omega,gamma
AllOCATE(zeta(1:N),alpha(1:N),beta(1:N),mu(1:N),xi(1:N),stat=err3)
ALLOCATE(lambda(1:N),eta(1:N),omega(1:N),gamma(1:N),stat=err4)
IF (err3>1 .OR. err4>1) THEN
PRINT*, 'Erreur d''allocation dans vecteur P,Q'; STOP
END IF
zeta(1)=b(1)
alpha(1)=c(1)
beta(1)=d(1)
mu(1)=e(1)
xi(1)=f(1)/mu(1)
lambda(1)=g(1)/mu(1)
eta(1)=k(1)/mu(1)
omega(1)=l(1)/mu(1)
gamma(1)=S(1)/mu(1)
zeta(2)=b(2)
alpha(2)=c(2)
beta(2)=d(2)
mu(2)=e(2)-xi(1)*beta(2)
xi(2)=(f(2)-lambda(1)*beta(2))/mu(2)
lambda(2)=(g(2)-eta(1)*beta(2))/mu(2)
eta(2)=(k(2)-omega(1)*beta(2))/mu(2)
omega(2)=l(2)/mu(2)
gamma(2)=(S(2)-beta(2)*gamma(1))/mu(2)
zeta(3)=b(3)
alpha(3)=c(3)
beta(3)=d(3)-xi(1)*alpha(3)
mu(3)=e(3)-lambda(1)*alpha(3)-xi(2)*beta(3)
xi(3)=(f(3)-eta(1)*alpha(3)-lambda(2)*beta(3))/mu(3)
lambda(3)=(g(3)-omega(1)*alpha(3)-eta(2)*beta(3))/mu(3)
eta(3)=(k(3)-omega(2)*beta(3))/mu(3)
omega(3)=l(3)/mu(3)
gamma(3)=(S(3)-alpha(3)*gamma(1)-beta(3)*gamma(2))/mu(3)
zeta(4)=b(4)
alpha(4)=c(4)-xi(1)*zeta(4)
beta(4)=d(4)-lambda(1)*zeta(4)-xi(2)*alpha(4)
mu(4)=e(4)-eta(1)*zeta(4)-lambda(2)*alpha(4)-xi(3)*beta(4)
xi(4)=(f(4)-omega(1)*zeta(4)-eta(2)*alpha(4)-lambda(3)*beta(4))/mu(4)
lambda(4)=(g(4)-omega(2)*alpha(4)-eta(3)*beta(4))/mu(4)
eta(4)=(k(4)-omega(3)*beta(4))/mu(4)
omega(4)=l(4)/mu(4)
gamma(4)=(S(4)-zeta(4)*gamma(1)-alpha(4)*gamma(2)-beta(4)*gamma(3))/mu(4)
DO i=5,N
zeta(i)=b(i)-a(i)*xi(i-4)
alpha(i)=c(i)-a(i)*lambda(i-4)-xi(i-3)*zeta(i)
beta(i)=d(i)-a(i)*eta(i-4)-lambda(i-3)*zeta(i)-alpha(i)*xi(i-2)
mu(i)=e(i)-a(i)*omega(i-4)-zeta(i)*eta(i-3)-lambda(i-2)*alpha(i)-beta(i)*xi(i-1)
xi(i)=(f(i)-omega(i-3)*zeta(i)-eta(i-2)*alpha(i)-lambda(i-1)*beta(i))/mu(i)
lambda(i)=(g(i)-alpha(i)*omega(i-2)-eta(i-1)*beta(i))/mu(i)
eta(i)=(k(i)-omega(i-1)*beta(i))/mu(i)
omega(i)=l(i)/mu(i)
gamma(i)=(S(i)-a(i)*gamma(i-4)-zeta(i)*gamma(i-3)-alpha(i)*gamma(i-2)-beta(i)*gamma(i-1))/mu(i)
END DO
Hm(N)=gamma(N)
Hm(N-1)=gamma(N-1)-xi(N-1)*Hm(N)
Hm(N-2)=gamma(N-2)-lambda(N-2)*Hm(N)-xi(N-2)*Hm(N-1)
Hm(N-3)=gamma(N-3)-eta(N-3)*Hm(N)-lambda(N-3)*Hm(N-1)-xi(N-3)*Hm(N-2)
DO i=N-4,1,-1
Hm(i)=gamma(i)-xi(i)*Hm(i+1)-lambda(i)*Hm(i+2)-eta(i)*Hm(i+3)-omega(i)*Hm(i+4)
END DO
DEALLOCATE(zeta,alpha,beta,mu,xi,lambda,eta,omega,gamma)
END SUBROUTINE NONA_DIAGO
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!-------------------------------------------------------------------------------------
! SUBROUTINE TRIDIAG
!-------------------------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE TRIDIAG(A,B,C,S,N,U)
!*****************************************************************
! Solves for a vector U of length N the tridiagonal linear set
! M U = R, where A, B and C are the three main diagonals of matrix
! M(N,N), the other terms are 0. R is the right side vector.
!*****************************************************************
IMPLICIT NONE
DOUBLE PRECISION, DIMENSION(N), INTENT(IN) :: A,B,C,S
DOUBLE PRECISION, DIMENSION(N), INTENT(INOUT) :: U
INTEGER, INTENT(IN) :: N
INTEGER :: CODE
DOUBLE PRECISION, DIMENSION(N) :: GAM
DOUBLE PRECISION :: BET
INTEGER :: j
BET = B(1)
IF (BET == 0.D0) THEN
PRINT*,'ERROR TRIDIAG'
STOP
ENDIF
U(1) = S(1)/BET
DO J=2,N !Decomposition and forward substitution
GAM(j)=C(j-1)/BET
BET=B(j)-A(j)*GAM(j)
IF(BET.EQ.0.D0) THEN !Algorithm fails
PRINT*,'ERRORTRIDIAG2',j,N
STOP
END IF
U(j)=(S(j)-A(j)*U(j-1))/BET
END DO
DO j=N-1,1,-1 !Back substitution
U(j)=U(j)-GAM(j+1)*U(j+1)
END DO
CODE=0
RETURN
END SUBROUTINE TRIDIAG
END MODULE MODULE_THICKNESS_INTE_GFD_BERCOVICI