-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModule_Thermal_Skin_Newton_Roscoe.f90
643 lines (525 loc) · 25.3 KB
/
Module_Thermal_Skin_Newton_Roscoe.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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
MODULE MODULE_THERMAL_SKIN_NEWTON_ROSCOE
CONTAINS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!! Equation : Heat equation
!!!!!!!! Model : Skin theory (Balmforth2004)
!!!!!!!! Schema : Newton_Rhapsod method
!!!!!!!! Model couplage : Roscoe rehology (tend vers infinity quand phi = maximum packing)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE THERMAL_SKIN_NEWTON_ROSCOE(Xi,H,P,T,Ts,BL,Dt,Dr,theta,dist,ray,M,sigma,nu,Pe,psi,delta0,el,grav,N1,F_err,z,tmps)
!*****************************************************************
! Solve for the parameter Xi, and split in Temperature and thermal layer
! from evolution equation using the Newton
! method
!*****************************************************************
IMPLICIT NONE
! Tableaux
DOUBLE PRECISION, DIMENSION(:,:), INTENT(IN) :: H,P
DOUBLE PRECISION , DIMENSION(:,:), INTENT(INOUT) :: Xi,T,BL,Ts
DOUBLE PRECISION , DIMENSION(:), INTENT(IN) :: dist,ray
!Parametre du model
DOUBLE PRECISION , INTENT(IN) :: Dt,Dr,theta,tmps
!Nombre sans dimensions
DOUBLE PRECISION , INTENT(IN) :: sigma,nu,Pe,psi,delta0,el,grav,N1
INTEGER, INTENT(IN) :: M, z
DOUBLE PRECISION , INTENT(INOUT) :: F_err
!Variable du sous programmes
DOUBLE PRECISION, DIMENSION(:),ALLOCATABLE :: Xi_guess,Xi_tmps
DOUBLE PRECISION, DIMENSION(:),ALLOCATABLE :: a,b,c,S
DOUBLE PRECISION, DIMENSION(:),ALLOCATABLE :: a1,b1,c1
DOUBLE PRECISION ,DIMENSION(:), ALLOCATABLE :: Xi_m
DOUBLE PRECISION :: U,Phi
INTEGER :: i,ndyke,N,Size
INTEGER :: err1,col
LOGICAL :: CHO
Phi=1D0/0.6D0
ndyke=sigma/Dr
DO i =1,M,1
IF (H(i,1)<delta0) THEN
N = i-1;EXIT
ENDIF
ENDDO
N=M-1
! Calcule de f tmps n et n+
ALLOCATE(Xi_tmps(1:N),Xi_guess(1:N),stat=err1)
IF (err1>1) THEN
PRINT*, 'Erreur alloc xi_tmps-xi_guess'; STOP
END IF
col=1
CALL TEMPERATURE_BALMFORTH(Xi_tmps,col,N,Xi,H,T,Ts,BL,P,dist,ray,Dr,nu,Pe,delta0,el,grav,N1,tmps+Dt,psi,Dt,Phi)
col=2
CALL TEMPERATURE_BALMFORTH(Xi_guess,col,N,Xi,H,T,Ts,BL,P,dist,ray,Dr,nu,Pe,delta0,el,grav,N1,tmps+Dt,psi,Dt,Phi)
! Jacobienner
ALLOCATE(a1(1:N),b1(1:N),c1(1:N),stat=err1)
IF (err1>1) THEN
PRINT*, 'Erreur allocation dans coeff Temperature'; STOP
END IF
CALL JACOBI_TEMPERATURE_BALMFORTH(a1,b1,c1,N,H,BL,T,Ts,Xi,P,Dr,dist,ray,nu,Pe,delta0,el,grav,Phi)
!Systeme a inverser
ALLOCATE(a(1:N),b(1:N),c(1:N),S(1:N),stat= err1)
IF (err1>1) THEN
PRINT*, 'Erreur d''allocation dans coeff du systeme'; STOP
END IF
DO i=1,N,1
a(i)=-theta*Dt*a1(i)
b(i)=1D0-theta*Dt*b1(i)
c(i)=-theta*Dt*c1(i)
S(i)=(Xi(i,1)-Xi(i,2))+theta*Dt*Xi_guess(i)+(1-theta)*Dt*Xi_tmps(i)
END DO
a(1)=0
c(N)=0
!Inversion de la matrice
ALLOCATE(Xi_m(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,Xi_m)
DO i=1,N,1
Xi(i,3)=Xi_m(i)+Xi(i,2)
IF (Xi(i,3) >H(i,3)/2D0) THEN
Xi(i:,3) = H(i:,3)/2D0
EXIT
ENDIF
END DO
! Separation variables
! CALL XI_SPLIT(Xi,T,BL,Ts,H,N,delta0,Dt,tmps,N1,Pe,el)
CALL XI_SPLIT_BALMFORTH(Xi,T,BL,Ts,H,N,delta0,Dt,tmps,N1,Pe,el)
! Calcule de l'erreur
IF (DOT_PRODUCT(Xi(:,3),Xi(:,3))==DOT_PRODUCT(H(:,3)/2D0,H(:,3)/2D0)) THEN
F_err = 0D0 ! Cas ou le refroidissemnt est trop important et tout devient nulle
ELSEIF (DOT_PRODUCT(Xi(:,2),Xi(:,2)) == 0D0) THEN
F_err = ABS(MAXVAL(Xi_m(:)))
ELSE
Size = COUNT(Xi(:,2)>1D-10)
F_err = ABS(MAXVAL(((Xi(:Size,3)-Xi(:Size,2))/Xi(:Size,2))))
ENDIF
DEALLOCATE(Xi_m,a,b,c,S)
DEALLOCATE(Xi_guess,Xi_tmps,a1,b1,c1)
END SUBROUTINE THERMAL_SKIN_NEWTON_ROSCOE
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!-------------------------------------------------------------------------------------
! 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(OUT) :: U
INTEGER, INTENT(IN) :: N
INTEGER :: CODE
DOUBLE PRECISION, DIMENSION(N) :: GAM
DOUBLE PRECISION :: BET
INTEGER :: j
IF(B(1) .EQ. 0.D0) THEN
CODE=1
RETURN
END IF
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*,'ERRORTRIDIAG'
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
SUBROUTINE XI_SPLIT(Xi,T,BL,Ts,H,N,delta0,Dt,tmps,N1,Pe,el)
!*****************************************************************
! Solve for T and BL from xi for balmofrth with Ts=0
!*****************************************************************
IMPLICIT NONE
! Tableaux
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(IN) :: H
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(INOUT) :: BL,T,Xi,Ts
!Dimensionless parameter
DOUBLE PRECISION, INTENT(IN) :: delta0,N1,Pe,el
!Parametre du model
DOUBLE PRECISION :: Dt,tmps
INTEGER, INTENT(IN) :: N
! Parametre pour le sous programme
INTEGER :: i
DOUBLE PRECISION, PARAMETER :: pi=3.14159265
DOUBLE PRECISION :: Xit,Tss,beta,d1,d2,Dr
! Separation des variables
DO i=1,N
Xit = H(i,3)/6.d0
IF (Xi(i,3) <= Xit) THEN
T(i,3) = 1.d0
BL(i,3) = 3.d0*Xi(i,3)
ELSEIF (Xi(i,3)> Xit) THEN
T(i,3)= 3.d0/2.D0-(3.d0*Xi(i,3)/H(i,3))
BL(i,3)=H(i,3)/2.d0
ENDIF
END DO
END SUBROUTINE XI_SPLIT
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! SUBROUTINE X_SPLIT_Balmforth
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
SUBROUTINE XI_SPLIT_BALMFORTH(Xi,T,BL,Ts,H,N,delta0,Dt,tmps,N1,Pe,el)
!*****************************************************************
! Solve for T and BL from Xi deriving Ts directly here
!*****************************************************************
IMPLICIT NONE
! Tableaux
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(IN) :: H
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(INOUT) :: BL,T,Xi,Ts
!Dimensionless parameter
DOUBLE PRECISION, INTENT(IN) :: delta0,N1,Pe,el
!Parametre du model
DOUBLE PRECISION :: Dt,tmps
INTEGER, INTENT(IN) :: N
! Parametre pour le sous programme
INTEGER :: i
DOUBLE PRECISION, PARAMETER :: pi=3.14159265
DOUBLE PRECISION :: Xit,Tss,beta
! Separation des variables
DO i=1,N
beta = N1*Pe**(-0.5d0)/(sqrt(pi*(tmps+Dt)))
Xit = beta*H(i,3)**2/(6.d0*beta*H(i,3)+24.d0)
IF (Xi(i,3) <= Xit) THEN
Ts(i,3) = 3.d0*beta/4.d0*Xi(i,3)&
&-sqrt(3.d0)/4.d0*sqrt(beta*Xi(i,3)*(3.d0*Xi(i,3)*beta+8.d0))+1.d0
T(i,3) = 1.d0
BL(i,3) = 1/(Ts(i,3)*beta)*(2.d0-2.d0*Ts(i,3))
ELSEIF (Xi(i,3)> Xit) THEN
Ts(i,3) =(-12.d0*Xi(i,3)+6.d0*H(i,3))/((beta*H(i,3)+6.d0)*H(i,3))
BL(i,3) = H(i,3)/2.d0
T(i,3) = Ts(i,3)/4.d0*(beta*H(i,3)+4.d0)
ENDIF
END DO
END SUBROUTINE XI_SPLIT_BALMFORTH
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! SUBROUTINE TEMPERATURE
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
SUBROUTINE TEMPERATURE_BALMFORTH(f,col,N,Xi,H,T,Ts,BL,P,dist,ray,Dr,nu,Pe,delta0,el,grav,N1,tmps,psi,Dt,Phi)
!*****************************************************************
! Give the vector f
!*****************************************************************
IMPLICIT NONE
! Tableaux
DOUBLE PRECISION ,DIMENSION(:) , INTENT(INOUT) :: f
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(IN) :: H,Xi,T,Ts,BL,P
DOUBLE PRECISION ,DIMENSION(:), INTENT(IN) :: dist,ray
! Prametre du model
DOUBLE PRECISION ,INTENT(IN) :: Dr
INTEGER ,INTENT(IN) :: col,N
! Nombre sans dimension
DOUBLE PRECISION ,INTENT(IN) :: nu,Pe,delta0,el,grav,N1,tmps,psi,Dt,Phi
! Parametre pour le sous programme
DOUBLE PRECISION, PARAMETER :: pi=3.14159265
DOUBLE PRECISION :: h_a,delta_a,delta_a2,eta_a,Ai,T_a
DOUBLE PRECISION :: T_a2,delta_a3,T_a3,Ts_a3,Ts_a2
DOUBLE PRECISIOn :: omega_a,sigma_a
DOUBLE PRECISION :: h_b,delta_b,delta_b2,eta_b,Bi,T_b
DOUBLE PRECISION :: T_b2,delta_b3,T_b3,Ts_b3,Ts_b2
DOUBLE PRECISIOn :: omega_b,sigma_b,Ts_a,Ts_b,Ds_b,Ds_a
DOUBLE PRECISION :: loss,beta
DOUBLE PRECISION :: Phi2
INTEGER :: i,Na
! Remplissage de f
Phi2 = Phi**2
DO i=1,N,1
IF1:IF (i .NE. 1) THEN
eta_b=(grav*(H(i,3)-H(i-1,3))+el*(P(i,3)-P(i-1,3)))/Dr
Bi=(ray(i-1)/(dist(i)*Dr))
h_b=0.5d0*(H(i,3)+H(i-1,3))
delta_b=0.5d0*(BL(i,col)+BL(i-1,col));delta_b2=0.5d0*(BL(i,col)**2+BL(i-1,col)**2)
delta_b3=0.5d0*(BL(i,col)**3+BL(i-1,col)**3)
T_b = 0.5d0*(T(i,col)+T(i-1,col));T_b2 = 0.5d0*(T(i,col)**2+T(i-1,col)**2)
T_b3 = 0.5d0*(T(i,col)**3+T(i-1,col)**3)
Ts_b = 0.5d0*(Ts(i,col)+Ts(i-1,col));Ts_b2 = 0.5d0*(Ts(i,col)**2+Ts(i-1,col)**2)
Ts_b3 = 0.5d0*(Ts(i,col)**3+Ts(i-1,col)**3)
omega_b = -38.0d0/35.0d0*Phi2*T_b2*delta_b2*eta_b + Phi2*&
& T_b2*delta_b*eta_b*h_b - 22.0d0/35.0d0*Phi2*T_b*Ts_b*delta_b2&
& *eta_b + Phi2*T_b*Ts_b*delta_b*eta_b*h_b + (14.0d0/5.0d0)*&
& Phi2*T_b*delta_b2*eta_b - 3*Phi2*T_b*delta_b*eta_b*h_b -&
& 2.0d0/7.0d0*Phi2*Ts_b2*delta_b2*eta_b + Phi2*Ts_b2*&
& delta_b*eta_b*h_b + (6.0d0/5.0d0)*Phi2*Ts_b*delta_b2*eta_b -&
& 3*Phi2*Ts_b*delta_b*eta_b*h_b - 2*Phi2*delta_b2*eta_b + 3*&
& Phi2*delta_b*eta_b*h_b - 14.0d0/5.0d0*Phi*T_b*delta_b2*eta_b&
& + 3*Phi*T_b*delta_b*eta_b*h_b - 6.0d0/5.0d0*Phi*Ts_b*delta_b2*&
& eta_b + 3*Phi*Ts_b*delta_b*eta_b*h_b + 4*Phi*delta_b2*eta_b - 6&
& *Phi*delta_b*eta_b*h_b - 2*delta_b2*eta_b + 3*delta_b*eta_b*h_b
sigma_b = (187.0d0/630.0d0)*Phi2*T_b3*delta_b3*eta_b - 1.0d0&
& /4.0d0*Phi2*T_b3*delta_b2*eta_b*h_b - 1.0d0/6.0d0*Phi2*&
& T_b2*Ts_b*delta_b3*eta_b + (1.0d0/12.0d0)*Phi2*T_b2*Ts_b*&
& delta_b2*eta_b*h_b - 76.0d0/105.0d0*Phi2*T_b2*delta_b3*&
& eta_b + (2.0d0/3.0d0)*Phi2*T_b2*delta_b2*eta_b*h_b - 19.0d0&
& /210.0d0*Phi2*T_b*Ts_b2*delta_b3*eta_b + (1.0d0/12.0d0)*Phi2&
& *T_b*Ts_b2*delta_b2*eta_b*h_b + (18.0d0/35.0d0)*Phi2*T_b&
& *Ts_b*delta_b3*eta_b - 1.0d0/3.0d0*Phi2*T_b*Ts_b*delta_b2*&
& eta_b*h_b + (7.0d0/15.0d0)*Phi2*T_b*delta_b3*eta_b - 1.0d0/&
& 2.0d0*Phi2*T_b*delta_b2*eta_b*h_b - 5.0d0/126.0d0*Phi2*Ts_b3&
& *delta_b3*eta_b + (1.0d0/12.0d0)*Phi2*Ts_b3*delta_b2*&
& eta_b*h_b + (22.0d0/105.0d0)*Phi2*Ts_b2*delta_b3*eta_b -&
& 1.0d0/3.0d0*Phi2*Ts_b2*delta_b2*eta_b*h_b - 7.0d0/15.0d0*&
& Phi2*Ts_b*delta_b3*eta_b + (1.0d0/2.0d0)*Phi2*Ts_b*delta_b2&
& *eta_b*h_b + (76.0d0/105.0d0)*Phi*T_b2*delta_b3*eta_b -&
& 2.0d0/3.0d0*Phi*T_b2*delta_b2*eta_b*h_b - 18.0d0/35.0d0*Phi*&
& T_b*Ts_b*delta_b3*eta_b + (1.0d0/3.0d0)*Phi*T_b*Ts_b*delta_b2&
& *eta_b*h_b - 14.0d0/15.0d0*Phi*T_b*delta_b3*eta_b + Phi*T_b*&
& delta_b2*eta_b*h_b - 22.0d0/105.0d0*Phi*Ts_b2*delta_b3*&
& eta_b + (1.0d0/3.0d0)*Phi*Ts_b2*delta_b2*eta_b*h_b &
& + (14.0d0/15.0d0)*Phi*Ts_b*delta_b3*eta_b - Phi*Ts_b*delta_b2*eta_b*h_b&
& + (7.0d0/15.0d0)*T_b*delta_b3*eta_b - 1.0d0/2.0d0*T_b*delta_b2&
& *eta_b*h_b - 7.0d0/15.0d0*Ts_b*delta_b3*eta_b + (1.0d0/2.0d0)*&
& Ts_b*delta_b2*eta_b*h_b
ENDIF IF1
IF2: IF (i .NE. N) THEN
eta_a=(grav*(H(i+1,3)-H(i,3))+el*(P(i+1,3)-P(i,3)))/Dr
Ai=(ray(i)/(dist(i)*Dr))
h_a=0.5d0*(H(i+1,3)+H(i,3))
delta_a=0.5d0*(BL(i+1,col)+BL(i,col))
delta_a2=0.5d0*(BL(i+1,col)**2+BL(i,col)**2)
delta_a3 =0.5d0*(BL(i+1,col)**3+BL(i,col)**3)
T_a = 0.5d0*(T(i,col)+T(i+1,col)); T_a2 = 0.5d0*(T(i,col)**2+T(i+1,col)**2)
T_a3 = 0.5d0*(T(i,col)**3+T(i+1,col)**3)
Ts_a = 0.5d0*(Ts(i,col)+Ts(i+1,col)); Ts_a2 = 0.5d0*(Ts(i,col)**2+Ts(i+1,col)**2)
Ts_a3 = 0.5d0*(Ts(i,col)**3+Ts(i+1,col)**3)
Ds_a = T_a-Ts_a
omega_a = -38.0d0/35.0d0*Phi2*T_a2*delta_a2*eta_a + Phi2*&
& T_a2*delta_a*eta_a*h_a - 22.0d0/35.0d0*Phi2*T_a*Ts_a*delta_a2&
& *eta_a + Phi2*T_a*Ts_a*delta_a*eta_a*h_a + (14.0d0/5.0d0)*&
& Phi2*T_a*delta_a2*eta_a - 3*Phi2*T_a*delta_a*eta_a*h_a -&
& 2.0d0/7.0d0*Phi2*Ts_a2*delta_a2*eta_a + Phi2*Ts_a2*&
& delta_a*eta_a*h_a + (6.0d0/5.0d0)*Phi2*Ts_a*delta_a2*eta_a -&
& 3*Phi2*Ts_a*delta_a*eta_a*h_a - 2*Phi2*delta_a2*eta_a + 3*&
& Phi2*delta_a*eta_a*h_a - 14.0d0/5.0d0*Phi*T_a*delta_a2*eta_a&
& + 3*Phi*T_a*delta_a*eta_a*h_a - 6.0d0/5.0d0*Phi*Ts_a*delta_a2*&
& eta_a + 3*Phi*Ts_a*delta_a*eta_a*h_a + 4*Phi*delta_a2*eta_a - 6&
& *Phi*delta_a*eta_a*h_a - 2*delta_a2*eta_a + 3*delta_a*eta_a*h_a
sigma_a = (187.0d0/630.0d0)*Phi2*T_a3*delta_a3*eta_a - 1.0d0&
& /4.0d0*Phi2*T_a3*delta_a2*eta_a*h_a - 1.0d0/6.0d0*Phi2*&
& T_a2*Ts_a*delta_a3*eta_a + (1.0d0/12.0d0)*Phi2*T_a2*Ts_a*&
& delta_a2*eta_a*h_a - 76.0d0/105.0d0*Phi2*T_a2*delta_a3*&
& eta_a + (2.0d0/3.0d0)*Phi2*T_a2*delta_a2*eta_a*h_a - 19.0d0&
& /210.0d0*Phi2*T_a*Ts_a2*delta_a3*eta_a + (1.0d0/12.0d0)*Phi2&
& *T_a*Ts_a2*delta_a2*eta_a*h_a + (18.0d0/35.0d0)*Phi2*T_a&
& *Ts_a*delta_a3*eta_a - 1.0d0/3.0d0*Phi2*T_a*Ts_a*delta_a2*&
& eta_a*h_a + (7.0d0/15.0d0)*Phi2*T_a*delta_a3*eta_a - 1.0d0/&
& 2.0d0*Phi2*T_a*delta_a2*eta_a*h_a - 5.0d0/126.0d0*Phi2*Ts_a3&
& *delta_a3*eta_a + (1.0d0/12.0d0)*Phi2*Ts_a3*delta_a2*&
& eta_a*h_a + (22.0d0/105.0d0)*Phi2*Ts_a2*delta_a3*eta_a -&
& 1.0d0/3.0d0*Phi2*Ts_a2*delta_a2*eta_a*h_a - 7.0d0/15.0d0*&
& Phi2*Ts_a*delta_a3*eta_a + (1.0d0/2.0d0)*Phi2*Ts_a*delta_a2&
& *eta_a*h_a + (76.0d0/105.0d0)*Phi*T_a2*delta_a3*eta_a -&
& 2.0d0/3.0d0*Phi*T_a2*delta_a2*eta_a*h_a - 18.0d0/35.0d0*Phi*&
& T_a*Ts_a*delta_a3*eta_a + (1.0d0/3.0d0)*Phi*T_a*Ts_a*delta_a2&
& *eta_a*h_a - 14.0d0/15.0d0*Phi*T_a*delta_a3*eta_a + Phi*T_a*&
& delta_a2*eta_a*h_a - 22.0d0/105.0d0*Phi*Ts_a2*delta_a3*&
& eta_a + (1.0d0/3.0d0)*Phi*Ts_a2*delta_a2*eta_a*h_a &
& + (14.0d0/15.0d0)*Phi*Ts_a*delta_a3*eta_a - Phi*Ts_a*delta_a2*eta_a*h_a&
& + (7.0d0/15.0d0)*T_a*delta_a3*eta_a - 1.0d0/2.0d0*T_a*delta_a2&
& *eta_a*h_a - 7.0d0/15.0d0*Ts_a*delta_a3*eta_a + (1.0d0/2.0d0)*&
& Ts_a*delta_a2*eta_a*h_a
END IF IF2
beta = N1*Pe**(-0.5d0)/(sqrt(pi*tmps))
loss = Pe*beta*Ts(i,col)/(1+psi)
IF4: IF (i==1) THEN
f(i)=loss+Ai*Omega_a*Xi(i,col)+Ai*Sigma_a
ELSEIF (i==N) THEN
f(i)=loss-Bi*Omega_b*Xi(i-1,col)-Bi*Sigma_b
ELSE
f(i)=Ai*Omega_a*Xi(i,col)&
&-Bi*Omega_b*Xi(i-1,col)&
&+Ai*Sigma_a-Bi*Sigma_b &
&+loss
END IF IF4
END DO
END SUBROUTINE TEMPERATURE_BALMFORTH
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! SUBROUTINE JACOBIENNE TEMPERATURE
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
SUBROUTINE JACOBI_TEMPERATURE_BALMFORTH(a,b,c,N,H,BL,T,Ts,Xi,P,Dr,dist,ray,nu,Pe,delta0,el,grav,Phi)
!*****************************************************************
! Give the jacobian coeficient a1,b1,c1
!*****************************************************************
IMPLICIT NONE
! Tableaux
DOUBLE PRECISION ,DIMENSION(:) , INTENT(INOUT) :: a,b,c
DOUBLE PRECISION ,DIMENSION(:,:), INTENT(IN) :: H,BL,T,Ts,Xi,P
DOUBLE PRECISION ,DIMENSION(:), INTENT(IN) :: dist,ray
! Prametre du model
DOUBLE PRECISION ,INTENT(IN) :: Dr
INTEGER ,INTENT(IN) :: N
! Nombre sans dimension
DOUBLE PRECISION ,INTENT(IN) :: nu,Pe,delta0,el,grav,Phi
! Parametre pour le sous programme
DOUBLE PRECISION :: h_a,delta_a,delta_a2,eta_a,Ai,T_a
DOUBLE PRECISION :: T_a2,delta_a3,T_a3,Ts_a3,Ts_a2
DOUBLE PRECISIOn :: omega_a,sigma_a
DOUBLE PRECISION :: h_b,delta_b,delta_b2,eta_b,Bi,T_b
DOUBLE PRECISION :: T_b2,delta_b3,T_b3,Ts_b3,Ts_b2
DOUBLE PRECISIOn :: omega_b,sigma_b,Ts_a,Ts_b,Ds_b,Ds_a
DOUBLE PRECISION :: Phi2
DOUBLE PRECISION :: loss
INTEGER :: i,col
! Remplissage de la matrice Jacobienne
col=2
Phi2 = Phi**2
DO i=1,N,1
IF1:IF (i .NE. 1) THEN
eta_b=(grav*(H(i,3)-H(i-1,3))+el*(P(i,3)-P(i-1,3)))/Dr
Bi=(ray(i-1)/(dist(i)*Dr))
h_b=0.5d0*(H(i,3)+H(i-1,3))
delta_b=0.5d0*(BL(i,col)+BL(i-1,col));delta_b2=0.5d0*(BL(i,col)**2+BL(i-1,col)**2)
delta_b3=0.5d0*(BL(i,col)**3+BL(i-1,col)**3)
T_b = 0.5d0*(T(i,col)+T(i-1,col));T_b2 = 0.5d0*(T(i,col)**2+T(i-1,col)**2)
T_b3 = 0.5d0*(T(i,col)**3+T(i-1,col)**3)
Ts_b = 0.5d0*(Ts(i,col)+Ts(i-1,col));Ts_b2 = 0.5d0*(Ts(i,col)**2+Ts(i-1,col)**2)
Ts_b3 = 0.5d0*(Ts(i,col)**3+Ts(i-1,col)**3)
omega_b = -38.0d0/35.0d0*Phi2*T_b2*delta_b2*eta_b + Phi2*&
& T_b2*delta_b*eta_b*h_b - 22.0d0/35.0d0*Phi2*T_b*Ts_b*delta_b2&
& *eta_b + Phi2*T_b*Ts_b*delta_b*eta_b*h_b + (14.0d0/5.0d0)*&
& Phi2*T_b*delta_b2*eta_b - 3*Phi2*T_b*delta_b*eta_b*h_b -&
& 2.0d0/7.0d0*Phi2*Ts_b2*delta_b2*eta_b + Phi2*Ts_b2*&
& delta_b*eta_b*h_b + (6.0d0/5.0d0)*Phi2*Ts_b*delta_b2*eta_b -&
& 3*Phi2*Ts_b*delta_b*eta_b*h_b - 2*Phi2*delta_b2*eta_b + 3*&
& Phi2*delta_b*eta_b*h_b - 14.0d0/5.0d0*Phi*T_b*delta_b2*eta_b&
& + 3*Phi*T_b*delta_b*eta_b*h_b - 6.0d0/5.0d0*Phi*Ts_b*delta_b2*&
& eta_b + 3*Phi*Ts_b*delta_b*eta_b*h_b + 4*Phi*delta_b2*eta_b - 6&
& *Phi*delta_b*eta_b*h_b - 2*delta_b2*eta_b + 3*delta_b*eta_b*h_b
ENDIF IF1
IF2: IF (i .NE. N) THEN
eta_a=(grav*(H(i+1,3)-H(i,3))+el*(P(i+1,3)-P(i,3)))/Dr
Ai=(ray(i)/(dist(i)*Dr))
h_a=0.5d0*(H(i+1,3)+H(i,3))
delta_a=0.5d0*(BL(i+1,col)+BL(i,col))
delta_a2=0.5d0*(BL(i+1,col)**2+BL(i,col)**2)
delta_a3 =0.5d0*(BL(i+1,col)**3+BL(i,col)**3)
T_a = 0.5d0*(T(i,col)+T(i+1,col)); T_a2 = 0.5d0*(T(i,col)**2+T(i+1,col)**2)
T_a3 = 0.5d0*(T(i,col)**3+T(i+1,col)**3)
Ts_a = 0.5d0*(Ts(i,col)+Ts(i+1,col)); Ts_a2 = 0.5d0*(Ts(i,col)**2+Ts(i+1,col)**2)
Ts_a3 = 0.5d0*(Ts(i,col)**3+Ts(i+1,col)**3)
Ds_a = T_a-Ts_a
omega_a = -38.0d0/35.0d0*Phi2*T_a2*delta_a2*eta_a + Phi2*&
& T_a2*delta_a*eta_a*h_a - 22.0d0/35.0d0*Phi2*T_a*Ts_a*delta_a2&
& *eta_a + Phi2*T_a*Ts_a*delta_a*eta_a*h_a + (14.0d0/5.0d0)*&
& Phi2*T_a*delta_a2*eta_a - 3*Phi2*T_a*delta_a*eta_a*h_a -&
& 2.0d0/7.0d0*Phi2*Ts_a2*delta_a2*eta_a + Phi2*Ts_a2*&
& delta_a*eta_a*h_a + (6.0d0/5.0d0)*Phi2*Ts_a*delta_a2*eta_a -&
& 3*Phi2*Ts_a*delta_a*eta_a*h_a - 2*Phi2*delta_a2*eta_a + 3*&
& Phi2*delta_a*eta_a*h_a - 14.0d0/5.0d0*Phi*T_a*delta_a2*eta_a&
& + 3*Phi*T_a*delta_a*eta_a*h_a - 6.0d0/5.0d0*Phi*Ts_a*delta_a2*&
& eta_a + 3*Phi*Ts_a*delta_a*eta_a*h_a + 4*Phi*delta_a2*eta_a - 6&
& *Phi*delta_a*eta_a*h_a - 2*delta_a2*eta_a + 3*delta_a*eta_a*h_a
END IF IF2
IF3:IF (i==1) THEN
a(i)=0.d0
b(i)=Ai*Omega_a
c(i)=0.d0
ELSEIF (i==N) THEN
a(i)=-Bi*Omega_b
b(i)=0.d0
c(i)=0.d0
ELSE
a(i) = -Bi*Omega_b
b(i) = Ai*Omega_a
c(i)=0.d0
END IF IF3
ENDDO
END SUBROUTINE JACOBI_TEMPERATURE_BALMFORTH
END MODULE MODULE_THERMAL_SKIN_NEWTON_ROSCOE