-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_Cshock.f90
151 lines (144 loc) · 4.83 KB
/
setup_Cshock.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
!------------------------------------------------------------------------------!
! NDSPMHD: A Smoothed Particle (Magneto)Hydrodynamics code for (astrophysical) !
! fluid dynamics simulations in 1, 2 and 3 spatial dimensions. !
! !
! (c) 2002-2015 Daniel Price !
! !
! http://users.monash.edu.au/~dprice/ndspmhd !
! daniel.price@monash.edu -or- dprice@cantab.net (forwards to current address) !
! !
! NDSPMHD comes with ABSOLUTELY NO WARRANTY. !
! This is free software; and you are welcome to redistribute !
! it under the terms of the GNU General Public License !
! (see LICENSE file for details) and the provision that !
! this notice remains intact. If you modify this file, please !
! note section 2a) of the GPLv2 states that: !
! !
! a) You must cause the modified files to carry prominent notices !
! stating that you changed the files and the date of any change. !
! !
! ChangeLog: !
!------------------------------------------------------------------------------!
!----------------------------------------------------------------
! Set up C shock problem in MacLow et al. (1995), ApJ 442, 726
!----------------------------------------------------------------
subroutine setup
!
!--include relevant global variables
!
use dimen_mhd
use debug
use loguns
use bound
use options
use part
use setup_params
use eos
use uniform_distributions
!
!--define local variables
!
implicit none
integer :: i,nparty
real :: massp,volume,totmass,shockl,domainl,va
real :: denszero,Bzero,vamach,csmach,theta,cs,vs,vx0
!
!--allow for tracing flow
!
if (trace) write(iprint,*) ' entering subroutine setup (C-shock)'
!
!--set boundaries
!
ibound = 3 ! y-z boundaries are periodic
ibound(1) = 1 ! x-boundary is fixed
nbpts = 0 ! use ghosts not fixed
vamach = 5.
csmach = 50.
cs = 0.1
vs = cs*csmach
theta = 0.25*pi
denszero = 1.0
rho_ion = 1.e-5
vx0 = 4.45
Bzero = 1.
print "(/,1x,a)",'C-shock: '
gamma = 1.
gamma_ambipolar = 1.
shockl = Bzero/(gamma_ambipolar*rho_ion*sqrt(denszero))
va = Bzero/sqrt(denszero)
print "(a,es10.3)",' neutral density = ',denszero
print "(a,es10.3)",' ion density = ',rho_ion
print "(a,es10.3)",' gamma = ',gamma_ambipolar
print "(a,es10.3)",' B0 = ',Bzero
print "(a,es10.3)",' Bx0 = ',Bzero*cos(theta)
print "(a,es10.3)",' By0 = ',Bzero*sin(theta)
print "(a,es10.3)",' shock length = ',shockl
print "(a,es10.3)",' Alfvenic mach number = ',vs/(Bzero**2/denszero)
print "(a,es10.3)",' sonic mach number = ',csmach
print "(a,es10.3)",' sound speed = ',cs
print "(a,es10.3)",' Alfven speed = ',va
print "(a,es10.3,/)",' vshock = ',vs
nparty = 8
domainl = 500.*shockl
xmin(:) = -domainl - nparty*psep ! set position of boundaries
xmax(:) = domainl + nparty*psep
if (ndim.ge.2) then
xmin(2:ndim) = 0.0
xmax(2:ndim) = xmin(2:ndim) + nparty*psep
endif
!
!--set up the uniform density grid
!
call set_uniform_cartesian(2,psep,xmin,xmax,adjustbound=.true.)
npart = ntotal
print*,'npart =',npart
!
!--determine particle mass
!
volume = product(xmax-xmin)
totmass = denszero*volume
massp = totmass/float(ntotal) ! average particle mass
!
!--now assign particle properties
!
do i=1,ntotal
vel(:,i) = 0.
if (x(1,i) < -domainl) then
itype(i) = itypebnd
nbpts = nbpts + 1
vel(1,i) = vx0
elseif (x(1,i) > domainl) then
nbpts = nbpts + 1
itype(i) = itypebnd
vel(1,i) = -vx0
elseif (x(1,i) < 0.) then
itype(i) = itypegas
vel(1,i) = vx0
else
itype(i) = itypegas
vel(1,i) = -vx0
endif
dens(i) = denszero
pmass(i) = massp
if (iener.gt.0) then
uu(i) = cs**2/(gamma*(gamma - 1.)) ! isothermal
endif
Bfield(:,i) = 0.
if (imhd > 0) then
Bfield(1,i) = Bzero*cos(theta)
Bfield(2,i) = Bzero*sin(theta)
endif
enddo
polyk = cs**2
!
!--allow for tracing flow
!
if (trace) write(iprint,*) ' exiting subroutine setup'
return
end
!
! use this routine to modify the dump upon code restart
!
subroutine modify_dump()
implicit none
end subroutine modify_dump