-
Notifications
You must be signed in to change notification settings - Fork 1
/
ic.F90
executable file
·120 lines (115 loc) · 3.29 KB
/
ic.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
SUBROUTINE getic(x,uc,up,ucsol)
USE prms
USE conv
USE io
IMPLICIT NONE
REAL, INTENT(OUT) :: uc(3,0:n), up(3,0:n), ucsol(0:nsteps,3,0:n)
REAL :: x(0:n), udum(3,0:n)
real :: a,b,w
integer :: i
FORALL(i=0:n:1) x(i) = i*dx
x(:) = x(:) - L/2.
if (which_ic.eq.1) then
!Entropy wave: Gaussian
do i=0,n
up(1,i) = amp * ( exp( -(x(i)**2.) ) + 1 )
end do
up(2,:) = 1; up(3,:) = 1./g
else if (which_ic.eq.2) then
!Entropy wave: Shock
do i=0,n
if (x(i) > 0 ) then
up(1,i) = amp
else
up(1,i) = 2.*amp
end if
end do
up(2,:) = 1; up(3,:) = 1./g
else if (which_ic.eq.3) then
!Sod shocktube
do i = 0,n
if ( x(i) .le. 0 ) then
up(1,i) = 1.; up(2,i) = 0.; up(3,i) = 1.
else
up(1,i) = 0.125; up(2,i) = 0.; up(3,i) = 0.1
end if
end do
else if (which_ic.eq.4) then
!Gaussians
do i=0,n
up(1,i) = amp * ( exp( -(x(i)**2.) ) + 1 ) !between amp and 2*amp
up(2,i) = 0.1*(exp( -(x(i)**2.) )+1) !between 0.1 0.2
up(3,i) = 0.1*exp( -(x(i)**2.) ) + 5 !between 5 and 5.1
end do
else if (which_ic.eq.5) then
!Square wave
do i=0,n
if ( x(i) > -1 .and. x(i) < 1 ) then
up(1,i) = 2.*amp
else
up(1,i) = amp
end if
end do
up(2,:) = 1; up(3,:) = 1./g
else if (which_ic.eq.6) then
!Shocks only in density and velocity
do i=0,n
if ( x(i) < 0.) then
up(1,i) = 2.*amp
else
up(1,i) = amp
end if
if ( x(i) < 1.) then
up(2,i) = -1
else
up(2,i) = 1
end if
end do
up(3,:) = 1./g
else if (which_ic.eq.7) then
!Modified Sod shock tube
do i=0,n
if ( x(i) < 0.) then
up(1,i) = 1
else
up(1,i) = 0.5
end if
if ( x(i) < 1.) then
up(2,i) = 1.
else
up(2,i) = 1.
end if
if (x(i) < -0.5 ) then
up(3,i) = 0.2
else
up(3,i) = 0.1
end if
end do
else if (which_ic.eq.8) then
!Sod shocktube2
do i = 0,n
if ( x(i) .le. 0 ) then
up(1,i) = 1.; up(2,i) = 0.1; up(3,i) = 1.
else
up(1,i) = 0.125; up(2,i) = 0.1; up(3,i) = 0.1
end if
end do
else if (which_ic.eq.33) then
!Sod shocktube with hyperbolic tangent regularization
do i = 0,n
w = 100.
a = 1.; b = 0.125;
up(1,i) = (a - b)*(( Tanh(-w*x(i)) + 1)/2.) + b
a = 1.; b = 0.1;
up(3,i) = (a - b)*(( Tanh(-w*x(i)) + 1)/2.) + b
up(2,i) = 0.
end do
end if
udum = up
do i = 1,n-1
up(:,i) = 1./6.*(udum(:,i-1) + 4.*udum(:,i) + udum(:,i+1))
end do
call p_to_c(up,uc)
call output(uc(1,:),x,'rho',0)
ucsol(0,:,:) = uc(:,:)
END SUBROUTINE getic