-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_unifdisND.f90
152 lines (130 loc) · 4.29 KB
/
setup_unifdisND.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 a uniform density cartesian grid of particles in ND
!----------------------------------------------------------------
subroutine setup
!
!--include relevant global variables
!
use dimen_mhd
use debug
use loguns
use bound
use options
use part
use setup_params
use uniform_distributions
!
!--define local variables
!
implicit none
integer :: i
real :: massp,volume,totmass
real :: denszero
!
!--allow for tracing flow
!
if (trace) write(iprint,*) ' entering subroutine setup(unifdis)'
!
!--set boundaries
!
ibound(:) = 3
!ibound(1) = 1 ! boundaries
nbpts = 0 ! use ghosts not fixed
xmin(:) = 0. ! set position of boundaries
xmax(:) = 1.
call set_uniform_cartesian(1,psep,xmin,xmax,adjustbound=.true.)
npart = ntotal
print*,'npart =',npart
!
!--determine particle mass
!
denszero = 1.0
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.
vel(1,i) = 1.e-4*sin(2.*pi*x(1,i))
!vel(1,i) = vx(x(:,i))
!vel(2,i) = vy(x(:,i))
!vel(3,i) = vz(x(:,i))
dens(i) = denszero
pmass(i) = massp
uu(i) = 1.5 ! isothermal
if (idiffuse > 0) then
!uu(i) = 1. + vx(x(:,i))
if (x(1,i) < 0.5) then
uu(i) = 1.
else
uu(i) = 2.
endif
endif
Bfield(:,i) = 0.
enddo
!
!--allow for tracing flow
!
if (trace) write(iprint,*) ' exiting subroutine setup'
return
contains
!----------------------------------------------------------------
!+
! functional form for v and its derivatives
!+
!----------------------------------------------------------------
real function vx(xyzhi)
use bound
use setup_params, only:pi
real, intent(in) :: xyzhi(3)
real :: dxbound
dxbound = xmax(1) - xmin(1)
vx = 0.5/pi*dxbound*sin(2.*pi*(xyzhi(1)-xmin(1))/dxbound)
end function vx
real function vy(xyzhi)
use bound
use setup_params, only:pi
real, intent(in) :: xyzhi(3)
real :: dxbound(3)
dxbound(1:ndim) = xmax(:) - xmin(:)
vy = 0.5/pi*dxbound(1)*sin(2.*pi*(xyzhi(1)-xmin(1))/dxbound(1)) &
- 0.5/pi*dxbound(3)*sin(2.*pi*(xyzhi(3)-xmin(3))/dxbound(3))
end function vy
real function vz(xyzhi)
use bound
use setup_params, only:pi
real, intent(in) :: xyzhi(3)
real :: dxbound(3)
dxbound(1:ndim) = xmax(:) - xmin(:)
vz = 0.05/pi*dxbound(2)*cos(4.*pi*(xyzhi(2)-xmin(2))/dxbound(2))
end function vz
end subroutine setup
!
! use this routine to modify the dump upon code restart
!
subroutine modify_dump()
implicit none
end subroutine modify_dump