-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_shock.f90
59 lines (43 loc) · 1.17 KB
/
setup_shock.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
module setup
use toolkit, only:ibound
use eos, only:c_s,gamma
implicit none
real, parameter :: pi=4*atan(1.)
real :: xmin, xmax
contains
subroutine setup_particles(pos,vel,mass,h,dens,u,n)
use toolkit, only:n_max
real, dimension(n_max), intent(out) :: pos,vel,mass,h,dens,u
integer, intent(out) :: n
real :: sep1, sep2
integer :: i, n1, n2
xmin = -0.5
xmax = 0.5
ibound = 2
!Particle spacing
sep1 = 0.001
sep2 = 0.008
n1 = int((xmax - xmin) / (2. * sep1))
n2 = int((xmax - xmin) / (2. * sep2))
n = n1 + n2
dens(1:n1) = 1.
dens(n1+1:n) = 0.125
u(1:n1) = 1./(dens(1:n1) * (gamma - 1))
u(n1+1:n) = 0.1/(dens(n1+1:n) * (gamma - 1))
vel = 0.
do i=1,n1
pos(i) = ((i-0.5) * sep1) + xmin
!Particle masses based on density
mass(i) = dens(i) * sep1
!Particle smoothing length
h(i) = 1.2 * sep1
enddo
do i=1 + n1,n
pos(i) = ((i-0.5-n1) * sep2) + (xmax + xmin) / 2.
!Particle masses based on density
mass(i) = dens(i) * sep2
!Particle smoothing length
h(i) = 1.2 * sep2
enddo
end subroutine setup_particles
end module setup