-
Notifications
You must be signed in to change notification settings - Fork 4
/
RANS_getk.f90
61 lines (50 loc) · 2.33 KB
/
RANS_getk.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
!-----------------------------------------------------------------------------------!
!
! PROGRAM : RANS_getk.f90
!
! PURPOSE : Get k(turbulent kinetic energy) using k-e model relation
!
! 2016.11.19 K.Noh
!
!-----------------------------------------------------------------------------------!
SUBROUTINE GETK
USE RANS_module, &
ONLY : Ny, dy, nu, Sk, alpha, beta
USE RANS_module, &
ONLY : k, k_new, dis, U_new, nu_T, prod
IMPLICIT NONE
INTEGER :: i,j
REAL(KIND=8),DIMENSION(:),ALLOCATABLE :: a,b,c,r,x
ALLOCATE ( a(0:Ny), b(0:Ny), c(0:Ny), r(0:Ny), x(0:Ny))
!-----------------------------------------------------------!
! Set TDMA constants
!-----------------------------------------------------------!
DO j = 1,Ny-1
a(j) = Sk*2*nu + nu_T(j-1) + nu_T(j)
b(j) = -(Sk*4*nu + nu_T(j+1) + 2*nu_T(j) + nu_T(j-1))
c(j) = Sk*2*nu + nu_T(j+1) + nu_T(j)
r(j) = 2*dy**2*Sk* ( dis(j) - prod(j) )
END DO
r(0:Ny) = r(0:Ny) + b(0:Ny) * k(0:Ny)*(1-alpha)/alpha
b(0:Ny) = b(0:Ny) / alpha
x(0:Ny) = k(0:Ny)
!-----------------------------------------------------------!
! Boundary conditions
!-----------------------------------------------------------!
b(0) = 1
b(Ny) = 1
a(Ny) = 0
c(0) = 0
r(0) = 0
r(Ny) = 0
!-----------------------------------------------------------!
! Calculate TDMA
!-----------------------------------------------------------!
CALL TDMA_Solver(a,b,c,r,x,Ny)
!-----------------------------------------------------------!
! Relaxation & Update
!-----------------------------------------------------------!
k_new(0:Ny) = beta * x(0:Ny) + (1-beta) * k(0:Ny)
k(0:Ny) = k_new(0:Ny)
DEALLOCATE(a,b,c,r,x)
END SUBROUTINE GETK