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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
/*@@
@file GRHydro_EOSResetHydro.F90
@date Sat Jan 26 01:36:57 2002
@author Ian Hawke
@desc
This routine will reset the specific internal energy using the polytropic
EOS that will be used at evolution. This is wanted if the EoS changes
between setting up the initial data and evolving
@enddesc
@@*/
#include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"
#include "GRHydro_Macros.h"
#define velx(i,j,k) vup(i,j,k,1)
#define vely(i,j,k) vup(i,j,k,2)
#define velz(i,j,k) vup(i,j,k,3)
#define sx(i,j,k) scon(i,j,k,1)
#define sy(i,j,k) scon(i,j,k,2)
#define sz(i,j,k) scon(i,j,k,3)
/*@@
@routine GRHydro_EOSResetHydro
@date Sat Jan 26 01:38:12 2002
@author Ian Hawke
@desc
see above
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
subroutine GRHydro_EoSChangeGamma(CCTK_ARGUMENTS)
implicit none
! save memory when MP is not used
! TARGET as to be before DECLARE_CCTK_ARGUMENTS for gcc 4.1
TARGET gaa, gab, gac, gbb, gbc, gcc
TARGET gxx, gxy, gxz, gyy, gyz, gzz
TARGET lvel, vel
DECLARE_CCTK_ARGUMENTS
DECLARE_CCTK_PARAMETERS
CCTK_INT :: i, j, k
CCTK_REAL :: det
CCTK_REAL :: local_gamma
! save memory when MP is not used
CCTK_INT :: GRHydro_UseGeneralCoordinates
CCTK_REAL, DIMENSION(:,:,:), POINTER :: g11, g12, g13, g22, g23, g33
CCTK_REAL, DIMENSION(:,:,:,:), POINTER :: vup
!!$ Set up the fluid constants
! begin EOS Omni vars
integer :: n,keytemp,anyerr,keyerr(1)
real*8 :: xpress,xeps,xtemp,xye
n=1;keytemp=0;anyerr=0;keyerr(1)=0
xpress=0.0d0;xeps=0.0d0;xtemp=0.0d0;xye=0.0d0
! end EOS Omni vars
call EOS_Omni_press(GRHydro_polytrope_handle,keytemp,GRHydro_eos_rf_prec,n,&
1.0d0,1.0d0,xtemp,xye,xpress,keyerr,anyerr)
call EOS_Omni_EpsFromPress(GRHydro_polytrope_handle,keytemp,GRHydro_eos_rf_prec,n,&
1.0d0,1.0d0,xtemp,xye,xpress,xeps,keyerr,anyerr)
! save memory when MP is not used
if (GRHydro_UseGeneralCoordinates(cctkGH).ne.0) then
g11 => gaa
g12 => gab
g13 => gac
g22 => gbb
g23 => gbc
g33 => gcc
vup => lvel
else
g11 => gxx
g12 => gxy
g13 => gxz
g22 => gyy
g23 => gyz
g33 => gzz
vup => vel
end if
local_Gamma = 1.0d0 + xpress/xeps
press = poly_k * &
rho**local_Gamma
eps = press / (rho * (local_Gamma - 1.d0))
!!$ Change the pressure and specific internal energy
!!$ Get the conserved variables. Hardwired polytrope EoS!!!
!!$ Note that this call also sets pressure and eps
do k = 1, cctk_lsh(3)
do j = 1, cctk_lsh(2)
do i = 1, cctk_lsh(1)
det = SPATIAL_DETERMINANT(g11(i,j,k),g12(i,j,k),g13(i,j,k),\
g22(i,j,k),g23(i,j,k),g33(i,j,k))
call prim2conpolytype(GRHydro_polytrope_handle,g11(i,j,k),g12(i,j,k),&
g13(i,j,k),g22(i,j,k),g23(i,j,k),g33(i,j,k),&
det, dens(i,j,k),sx(i,j,k),sy(i,j,k),sz(i,j,k),&
tau(i,j,k),rho(i,j,k),velx(i,j,k),vely(i,j,k),velz(i,j,k),&
eps(i,j,k),press(i,j,k),w_lorentz(i,j,k))
end do
end do
end do
end subroutine GRHydro_EoSChangeGamma
/*@@
@routine GRHydro_EoSChangeK
@date Mon Oct 20 12:56:14 2003
@author Ian Hawke
@desc
Reset the hydro variables when K is changed.
Unlike the routine above, this actually gives a solution to
the constraints.
Only two cases are given as the general case is transcendental.
We find this by holding rho * enthalpy fixed and assuming a
polytropic EOS.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
subroutine GRHydro_EoSChangeK(CCTK_ARGUMENTS)
implicit none
! save memory when MP is not used
! TARGET has to be before DECLARE_CCTK_ARGUMENTS for gcc 4.1
TARGET gaa, gab, gac, gbb, gbc, gcc
TARGET gxx, gxy, gxz, gyy, gyz, gzz
TARGET lvel, vel
DECLARE_CCTK_ARGUMENTS
DECLARE_CCTK_PARAMETERS
CCTK_INT :: i, j, k
CCTK_REAL :: det
CCTK_REAL :: local_gamma, local_k
CCTK_REAL, dimension(cctk_lsh(1),cctk_lsh(2),cctk_lsh(3)) :: Q
! save memory when MP is not used
CCTK_INT :: GRHydro_UseGeneralCoordinates
CCTK_REAL, DIMENSION(:,:,:), POINTER :: g11, g12, g13, g22, g23, g33
CCTK_REAL, DIMENSION(:,:,:,:), POINTER :: vup
!!$ Set up the fluid constants
! begin EOS Omni vars
integer :: n,keytemp,anyerr,keyerr(1)
real*8 :: xpress,xeps,xtemp,xye
n=1;keytemp=0;anyerr=0;keyerr(1)=0
xpress=0.0d0;xeps=0.0d0;xtemp=0.0d0;xye=0.0d0
! end EOS Omni vars
call EOS_Omni_press(GRHydro_polytrope_handle,keytemp,GRHydro_eos_rf_prec,n,&
1.0d0,1.0d0,xtemp,xye,xpress,keyerr,anyerr)
call EOS_Omni_EpsFromPress(GRHydro_polytrope_handle,keytemp,GRHydro_eos_rf_prec,n,&
1.0d0,1.0d0,xtemp,xye,xpress,xeps,keyerr,anyerr)
local_Gamma = 1.0d0 + xpress/xeps
local_K = xpress
call CCTK_INFO("Adjusting EOS via K change!")
if (abs(local_Gamma - 2.d0) < 1.d-10) then
rho = -0.5d0/local_k+sqrt(0.25d0/local_k**2+(rho+initial_k*rho**2)/local_k)
else if (abs(local_Gamma - 3.d0) < 1.d-10) then
call CCTK_WARN(0, "This part of the code is not tested!")
!!$ This code is probably just wrong. We have never used it anyway.
Q = -9.d0 * local_k**2 * rho * (2.d0 + 3.d0 * initial_k * rho**2) + &
sqrt(local_k**3 * (32.d0 + 81.d0 * local_k * rho**2 * &
(2.d0 + 3.d0 * initial_k * rho**2)**2))
Q = Q**(1.d0/3.d0)
rho = (2**(7.d0/3.d0) * local_k - 2**(2.d0/3.d0) * Q**2) / &
(6.d0 * local_k * Q)
else
call CCTK_WARN(0, "EoSChangeK only knows how to do Gamma=2 or 3!")
end if
press = local_k * rho**local_gamma
eps = local_k / (local_gamma - 1.d0) * rho**(local_gamma-1.0d0)
! save memory when MP is not used
if (GRHydro_UseGeneralCoordinates(cctkGH).ne.0) then
g11 => gaa
g12 => gab
g13 => gac
g22 => gbb
g23 => gbc
g33 => gcc
vup => lvel
else
g11 => gxx
g12 => gxy
g13 => gxz
g22 => gyy
g23 => gyz
g33 => gzz
vup => vel
end if
do k = 1, cctk_lsh(3)
do j = 1, cctk_lsh(2)
do i = 1, cctk_lsh(1)
det = SPATIAL_DETERMINANT(g11(i,j,k),g12(i,j,k),g13(i,j,k),\
g22(i,j,k),g23(i,j,k),g33(i,j,k))
call prim2conpolytype(GRHydro_polytrope_handle,g11(i,j,k),g12(i,j,k),&
g13(i,j,k),g22(i,j,k),g23(i,j,k),g33(i,j,k),&
det, dens(i,j,k),sx(i,j,k),sy(i,j,k),sz(i,j,k),&
tau(i,j,k),rho(i,j,k),velx(i,j,k),vely(i,j,k),velz(i,j,k),&
eps(i,j,k),press(i,j,k),w_lorentz(i,j,k))
end do
end do
end do
end subroutine GRHydro_EoSChangeK
/*@@
@routine GRHydro_EoSChangeGammaK_Shibata
@date Jan. 2005
@author Christian D. Ott
@desc
Reset the hydro variables when K and Gamma are changed.
This is according to Shibata in astro-ph/0412243 (PRD71 024014) in
which he switches K and Gamma after initial data setup,
but keeps the internal energy constant.
Note: this works only with one refinement level
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
subroutine GRHydro_EoSChangeGammaK_Shibata(CCTK_ARGUMENTS)
implicit none
! save memory when MP is not used
! TARGET as to be before DECLARE_CCTK_ARGUMENTS for gcc 4.1
TARGET gaa, gab, gac, gbb, gbc, gcc
TARGET gxx, gxy, gxz, gyy, gyz, gzz
TARGET lvel, vel
DECLARE_CCTK_ARGUMENTS
DECLARE_CCTK_PARAMETERS
CCTK_INT :: i, j, k
CCTK_REAL :: det
CCTK_REAL :: local_Gamma, local_k, eos_k_initial
CCTK_REAL, dimension(cctk_lsh(1),cctk_lsh(2),cctk_lsh(3)) :: Q
character(len=100) infoline
! save memory when MP is not used
CCTK_INT :: GRHydro_UseGeneralCoordinates
CCTK_REAL, DIMENSION(:,:,:), POINTER :: g11, g12, g13, g22, g23, g33
CCTK_REAL, DIMENSION(:,:,:,:), POINTER :: vup
! begin EOS Omni vars
integer :: n,keytemp,anyerr,keyerr(1)
real*8 :: xpress,xeps,xtemp,xye
n=1;keytemp=0;anyerr=0;keyerr(1)=0
xpress=0.0d0;xeps=0.0d0;xtemp=0.0d0;xye=0.0d0
! end EOS Omni vars
!!$ Set up the fluid constants
call EOS_Omni_press(GRHydro_polytrope_handle,keytemp,GRHydro_eos_rf_prec,n,&
1.0d0,1.0d0,xtemp,xye,xpress,keyerr,anyerr)
call EOS_Omni_EpsFromPress(GRHydro_polytrope_handle,keytemp,GRHydro_eos_rf_prec,n,&
1.0d0,1.0d0,xtemp,xye,xpress,xeps,keyerr,anyerr)
! save memory when MP is not used
if (GRHydro_UseGeneralCoordinates(cctkGH).ne.0) then
g11 => gaa
g12 => gab
g13 => gac
g22 => gbb
g23 => gbc
g33 => gcc
vup => lvel
else
g11 => gxx
g12 => gxy
g13 => gxz
g22 => gyy
g23 => gyz
g33 => gzz
vup => vel
end if
local_Gamma = 1.0d0 + xpress/xeps
local_K = xpress
eos_k_initial = initial_k
press = (local_Gamma - 1.d0) / (initial_Gamma - 1.0d0 ) * eos_k_initial * &
rho ** initial_Gamma
eps = eos_k_initial * &
rho ** initial_Gamma / &
(rho * (initial_Gamma - 1.0d0))
do k = 1, cctk_lsh(3)
do j = 1, cctk_lsh(2)
do i = 1, cctk_lsh(1)
det = SPATIAL_DETERMINANT(g11(i,j,k),g12(i,j,k),g13(i,j,k),\
g22(i,j,k),g23(i,j,k),g33(i,j,k))
call prim2con(GRHydro_eos_handle,g11(i,j,k),g12(i,j,k),&
g13(i,j,k),g22(i,j,k),g23(i,j,k),g33(i,j,k),&
det, dens(i,j,k),sx(i,j,k),sy(i,j,k),sz(i,j,k),&
tau(i,j,k),rho(i,j,k),velx(i,j,k),vely(i,j,k),velz(i,j,k),&
eps(i,j,k),press(i,j,k),w_lorentz(i,j,k))
end do
end do
end do
end subroutine GRHydro_EoSChangeGammaK_Shibata
|