| 1 |
!----------------------------------------------------------------- |
| 2 |
! |
| 3 |
! This file is (or was) part of SPLASH, a visualisation tool |
| 4 |
! for Smoothed Particle Hydrodynamics written by Daniel Price: |
| 5 |
! |
| 6 |
! http://users.monash.edu.au/~dprice/splash |
| 7 |
! |
| 8 |
! SPLASH comes with ABSOLUTELY NO WARRANTY. |
| 9 |
! This is free software; and you are welcome to redistribute |
| 10 |
! it under the terms of the GNU General Public License |
| 11 |
! (see LICENSE file for details) and the provision that |
| 12 |
! this notice remains intact. If you modify this file, please |
| 13 |
! note section 2a) of the GPLv2 states that: |
| 14 |
! |
| 15 |
! a) You must cause the modified files to carry prominent notices |
| 16 |
! stating that you changed the files and the date of any change. |
| 17 |
! |
| 18 |
! Copyright (C) 2005-2012 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
! ---------------------------------------------------------------------- |
| 24 |
! compute exact solution for the one dimensional Riemann problem |
| 25 |
! in Special Relativity |
| 26 |
! |
| 27 |
! input parameters are initial left and right states of |
| 28 |
! density, pressure and velocity |
| 29 |
! |
| 30 |
! Computes shock profile at time t |
| 31 |
! |
| 32 |
! Calls the exact solution routine provided by Marti & Mueller |
| 33 |
! |
| 34 |
! Daniel Price, Institute of Astronomy, Cambridge, 2004 |
| 35 |
! University of Exeter 2004-2008 |
| 36 |
! Monash University 2008- |
| 37 |
! |
| 38 |
! [email protected] |
| 39 |
!----------------------------------------------------------------------- |
| 40 |
module shock_sr |
| 41 |
implicit none |
| 42 |
public :: exact_shock_sr |
| 43 |
|
| 44 |
contains |
| 45 |
|
| 46 |
subroutine exact_shock_sr(iplot,time,gamma,rho_L,rho_R,p_L,p_R,v_L,v_R,xplot,yplot,ierr) |
| 47 |
integer, intent(in) :: iplot |
| 48 |
integer, intent(out) :: ierr |
| 49 |
real, intent(in) :: time,gamma |
| 50 |
real, intent(in) :: rho_L,rho_R,p_L,p_R,v_L,v_R |
| 51 |
real, dimension(:), intent(inout) :: xplot |
| 52 |
real, dimension(size(xplot)), intent(out) :: yplot |
| 53 |
double precision, dimension(size(xplot)) :: rad,dens,pr,vel,uu |
| 54 |
double precision :: rhol,rhor,pl,prr,vl,vr,gam,t |
| 55 |
|
| 56 |
print*,'Plotting Special Relativistic Riemann solution at t = ',time,' gamma = ',gamma |
| 57 |
! |
| 58 |
! check for errors in input |
| 59 |
! |
| 60 |
ierr = 0 |
| 61 |
if (rho_L <= 0. .or. rho_R <= 0.) then |
| 62 |
print*,'error: rho <= 0 on input : ',rho_L,rho_R |
| 63 |
ierr = 1 |
| 64 |
return |
| 65 |
elseif (p_L <= 0. .or. p_R <= 0.) then |
| 66 |
print*,'error: pr <= 0 on input ',p_L, p_R |
| 67 |
ierr = 2 |
| 68 |
return |
| 69 |
endif |
| 70 |
|
| 71 |
rhol = rho_L |
| 72 |
rhor = rho_R |
| 73 |
pl = p_L |
| 74 |
prr = p_R |
| 75 |
vl = v_L |
| 76 |
vr = v_R |
| 77 |
gam = gamma |
| 78 |
t = time |
| 79 |
rad(:) = xplot(:) |
| 80 |
call riemann(size(xplot),rad,dens,pr,vel,uu,rhol,rhor,pl,prr,vl,vr,gam,t,0.0d0) |
| 81 |
|
| 82 |
!------------------------------------ |
| 83 |
! determine which solution to plot |
| 84 |
!------------------------------------ |
| 85 |
select case(iplot) |
| 86 |
case(1) |
| 87 |
yplot = real(dens) |
| 88 |
case(2) |
| 89 |
yplot = real(pr) |
| 90 |
case(3) |
| 91 |
yplot = real(vel) |
| 92 |
case(4) |
| 93 |
if (gamma > 1.0001) then |
| 94 |
yplot = real(pr/((gamma-1.)*dens)) |
| 95 |
else |
| 96 |
yplot = real(pr/dens) |
| 97 |
endif |
| 98 |
case(5) ! rho* |
| 99 |
yplot = real(dens/dsqrt(1.d0-vel**2)) |
| 100 |
end select |
| 101 |
|
| 102 |
return |
| 103 |
end subroutine exact_shock_sr |
| 104 |
|
| 105 |
! ------------ |
| 106 |
!n name: r i e m a n n |
| 107 |
! ------------ |
| 108 |
|
| 109 |
!p purpose: |
| 110 |
!p this program computes the solution of a 1d |
| 111 |
!p relativistic riemann problem (for constant-gamma ideal gases) with |
| 112 |
!p initial data ul if x<0.5 and ur if x>0.5 |
| 113 |
!p in the whole spatial domain [0, 1] |
| 114 |
! |
| 115 |
|
| 116 |
!c comments: |
| 117 |
!c see marti and mueller, jfm, 1994 |
| 118 |
!c |
| 119 |
!c written by: jose-maria marti |
| 120 |
!c departamento de astronomia y astrofisica |
| 121 |
!c universidad de valencia |
| 122 |
!c 46100 burjassot (valencia), spain |
| 123 |
!c [email protected] |
| 124 |
!c and |
| 125 |
!c ewald mueller |
| 126 |
!c max-planck-institut fuer astrophysik |
| 127 |
!c karl-schwarzschild-str. 1 |
| 128 |
!c 85741 garching, germany |
| 129 |
!c [email protected] |
| 130 |
!c |
| 131 |
!c Modifications by D. Price ([email protected]): |
| 132 |
!c 07/2007: used as subroutine instead of program |
| 133 |
!c 09/2008: reformatted in free-form and included in exact_shock_sr module |
| 134 |
!c |
| 135 |
|
| 136 |
subroutine riemann(mn,rad,rhoa,pa,vela,ua,rholin,rhorin,plin,prin, & |
| 137 |
vlin,vrin,gamin,tin,x0) |
| 138 |
|
| 139 |
! ------- |
| 140 |
! common blocks |
| 141 |
! ------- |
| 142 |
|
| 143 |
double precision rhol, pl, ul, hl, csl, vell, wl, & |
| 144 |
rhor, pr, ur, hr, csr, velr, wr |
| 145 |
common /states/ rhol, pl, ul, hl, csl, vell, wl, & |
| 146 |
rhor, pr, ur, hr, csr, velr, wr |
| 147 |
|
| 148 |
double precision rhols, uls, hls, csls, vells, vshockl |
| 149 |
common /ls/ rhols, uls, hls, csls, vells, vshockl |
| 150 |
|
| 151 |
double precision rhors, urs, hrs, csrs, velrs, vshockr |
| 152 |
common /rs/ rhors, urs, hrs, csrs, velrs, vshockr |
| 153 |
|
| 154 |
double precision gamma |
| 155 |
common /adind/ gamma |
| 156 |
|
| 157 |
! --------- |
| 158 |
! internal variables |
| 159 |
! --------- |
| 160 |
|
| 161 |
integer, intent(in) :: mn |
| 162 |
integer n, i, iloop |
| 163 |
! parameter (mn = 400) |
| 164 |
|
| 165 |
double precision tol, pmin, pmax, dvel1, dvel2, check !, xmin |
| 166 |
double precision, intent(in) :: rholin,rhorin,plin,prin,vlin,vrin,gamin,tin |
| 167 |
|
| 168 |
double precision ps, vels |
| 169 |
|
| 170 |
double precision, intent(out) :: rhoa(mn), pa(mn), vela(mn), ua(mn) |
| 171 |
|
| 172 |
double precision, intent(in) :: x0 |
| 173 |
double precision xi |
| 174 |
|
| 175 |
double precision, intent(in) :: rad(mn) |
| 176 |
double precision x1, x2, x3, x4, x5, t |
| 177 |
|
| 178 |
! ------- |
| 179 |
! initial states |
| 180 |
! ------- |
| 181 |
|
| 182 |
! write(*,*) ' adiabatic index of the gas: ' |
| 183 |
! read (*,*) gamma |
| 184 |
gamma = gamin |
| 185 |
|
| 186 |
! write(*,*) ' time for the solution: ' |
| 187 |
! read (*,*) t |
| 188 |
t = tin |
| 189 |
! xmin = x0 - 0.5d0 |
| 190 |
|
| 191 |
! ----- |
| 192 |
! left state |
| 193 |
! ----- |
| 194 |
|
| 195 |
! write(*,*) ' -- left state -- ' |
| 196 |
! write(*,*) ' pressure : ' |
| 197 |
! read (*,*) pl |
| 198 |
! write(*,*) ' density : ' |
| 199 |
! read (*,*) rhol |
| 200 |
! write(*,*) ' flow velocity: ' |
| 201 |
! read (*,*) vell |
| 202 |
pl = plin |
| 203 |
rhol = rholin |
| 204 |
vell = vlin |
| 205 |
|
| 206 |
pr = prin |
| 207 |
rhor = rhorin |
| 208 |
velr = vrin |
| 209 |
|
| 210 |
! ------ |
| 211 |
! right state |
| 212 |
! ------ |
| 213 |
|
| 214 |
! write(*,*) ' -- right state -- ' |
| 215 |
! write(*,*) ' pressure : ' |
| 216 |
! read (*,*) pr |
| 217 |
! write(*,*) ' density : ' |
| 218 |
! read (*,*) rhor |
| 219 |
! write(*,*) ' flow velocity: ' |
| 220 |
! read (*,*) velr |
| 221 |
|
| 222 |
! ------------------------------ |
| 223 |
! specific internal energy, specific enthalpy, sound speed and |
| 224 |
! flow lorentz factors in the initial states |
| 225 |
! ------------------------------ |
| 226 |
|
| 227 |
ul = pl/(gamma-1.d0)/rhol |
| 228 |
ur = pr/(gamma-1.d0)/rhor |
| 229 |
|
| 230 |
hl = 1.d0+ul+pl/rhol |
| 231 |
hr = 1.d0+ur+pr/rhor |
| 232 |
|
| 233 |
csl = dsqrt(gamma*pl/rhol/hl) |
| 234 |
csr = dsqrt(gamma*pr/rhor/hr) |
| 235 |
|
| 236 |
wl = 1.d0/dsqrt(1.d0-vell**2) |
| 237 |
wr = 1.d0/dsqrt(1.d0-velr**2) |
| 238 |
|
| 239 |
! -------- |
| 240 |
! number of points |
| 241 |
! -------- |
| 242 |
|
| 243 |
n = mn |
| 244 |
|
| 245 |
! ------------- |
| 246 |
! tolerance for the solution |
| 247 |
! ------------- |
| 248 |
|
| 249 |
tol = 0.d0 |
| 250 |
|
| 251 |
! |
| 252 |
|
| 253 |
iloop = 0 |
| 254 |
|
| 255 |
pmin = (pl + pr)/2.d0 |
| 256 |
pmax = pmin |
| 257 |
|
| 258 |
5 iloop = iloop + 1 |
| 259 |
|
| 260 |
pmin = 0.5d0*max(pmin,0.d0) |
| 261 |
pmax = 2.d0*pmax |
| 262 |
|
| 263 |
call getdvel(pmin, dvel1) |
| 264 |
|
| 265 |
call getdvel(pmax, dvel2) |
| 266 |
|
| 267 |
check = dvel1*dvel2 |
| 268 |
if (check > 0.d0) goto 5 |
| 269 |
|
| 270 |
! --------------------------- |
| 271 |
! pressure and flow velocity in the intermediate states |
| 272 |
! --------------------------- |
| 273 |
|
| 274 |
call getp(pmin, pmax, tol, ps) |
| 275 |
|
| 276 |
vels = 0.5d0*(vells + velrs) |
| 277 |
|
| 278 |
! --------------- |
| 279 |
! solution on the numerical mesh |
| 280 |
! --------------- |
| 281 |
|
| 282 |
! ----------- |
| 283 |
! positions of the waves |
| 284 |
! ----------- |
| 285 |
|
| 286 |
if (pl >= ps) then |
| 287 |
|
| 288 |
x1 = x0 + (vell - csl )/(1.d0 - vell*csl )*t |
| 289 |
x2 = x0 + (vels - csls)/(1.d0 - vels*csls)*t |
| 290 |
|
| 291 |
else |
| 292 |
|
| 293 |
x1 = x0 + vshockl*t |
| 294 |
x2 = x1 |
| 295 |
|
| 296 |
endif |
| 297 |
|
| 298 |
x3 = x0 + vels*t |
| 299 |
|
| 300 |
if (pr >= ps) then |
| 301 |
|
| 302 |
x4 = x0 + (vels + csrs)/(1.d0 + vels*csrs)*t |
| 303 |
x5 = x0 + (velr + csr )/(1.d0 + velr*csr )*t |
| 304 |
|
| 305 |
else |
| 306 |
|
| 307 |
x4 = x0 + vshockr*t |
| 308 |
x5 = x4 |
| 309 |
|
| 310 |
endif |
| 311 |
|
| 312 |
! ---------- |
| 313 |
! solution on the mesh |
| 314 |
! ---------- |
| 315 |
|
| 316 |
!do i=1,n |
| 317 |
|
| 318 |
! rad(i) = xmin + dfloat(i-1)/dfloat(n-1) |
| 319 |
|
| 320 |
!enddo |
| 321 |
|
| 322 |
do i=1,n |
| 323 |
|
| 324 |
if (rad(i) <= x1) then |
| 325 |
|
| 326 |
pa(i) = pl |
| 327 |
rhoa(i) = rhol |
| 328 |
vela(i) = vell |
| 329 |
ua(i) = ul |
| 330 |
|
| 331 |
elseif (rad(i) <= x2) then |
| 332 |
|
| 333 |
xi = (rad(i) - x0)/t |
| 334 |
|
| 335 |
call raref(xi, rhol, csl, vell, 'l', & |
| 336 |
rhoa(i), pa(i), ua(i), vela(i)) |
| 337 |
|
| 338 |
elseif (rad(i) <= x3) then |
| 339 |
|
| 340 |
pa(i) = ps |
| 341 |
rhoa(i) = rhols |
| 342 |
vela(i) = vels |
| 343 |
ua(i) = uls |
| 344 |
|
| 345 |
elseif (rad(i) <= x4) then |
| 346 |
|
| 347 |
pa(i) = ps |
| 348 |
rhoa(i) = rhors |
| 349 |
vela(i) = vels |
| 350 |
ua(i) = urs |
| 351 |
|
| 352 |
elseif (rad(i) <= x5) then |
| 353 |
|
| 354 |
xi = (rad(i) - x0)/t |
| 355 |
|
| 356 |
call raref(xi, rhor, csr, velr, 'r', & |
| 357 |
rhoa(i), pa(i), ua(i), vela(i)) |
| 358 |
|
| 359 |
else |
| 360 |
|
| 361 |
pa(i) = pr |
| 362 |
rhoa(i) = rhor |
| 363 |
vela(i) = velr |
| 364 |
ua(i) = ur |
| 365 |
|
| 366 |
endif |
| 367 |
|
| 368 |
enddo |
| 369 |
|
| 370 |
! open (3,file='solution.dat',form='formatted',status='new') |
| 371 |
|
| 372 |
! write(3,150) n, t |
| 373 |
! 150 format(i5,1x,f10.5) |
| 374 |
|
| 375 |
! do 60 i=1,n |
| 376 |
! write(3,200) rad(i),pa(i),rhoa(i),vela(i),ua(i) |
| 377 |
! 60 continue |
| 378 |
|
| 379 |
! 200 format(5(e15.8,1x)) |
| 380 |
|
| 381 |
! close(3) |
| 382 |
|
| 383 |
return |
| 384 |
end subroutine riemann |
| 385 |
|
| 386 |
! ---------- |
| 387 |
!n name: g e t d v e l |
| 388 |
! ---------- |
| 389 |
|
| 390 |
!p purpose: |
| 391 |
!p compute the difference in flow speed between left and right intermediate |
| 392 |
!p states for given left and right states and pressure |
| 393 |
! |
| 394 |
|
| 395 |
!c comments |
| 396 |
!c none |
| 397 |
|
| 398 |
subroutine getdvel( p, dvel ) |
| 399 |
|
| 400 |
|
| 401 |
! ----- |
| 402 |
! arguments |
| 403 |
! ----- |
| 404 |
|
| 405 |
doubleprecision, intent(in) :: p |
| 406 |
doubleprecision, intent(out) :: dvel |
| 407 |
|
| 408 |
! ------- |
| 409 |
! common blocks |
| 410 |
! ------- |
| 411 |
|
| 412 |
double precision rhols,uls,hls,csls,vells,vshockl |
| 413 |
common /ls/ rhols,uls,hls,csls,vells,vshockl |
| 414 |
|
| 415 |
double precision rhors,urs,hrs,csrs,velrs,vshockr |
| 416 |
common /rs/ rhors,urs,hrs,csrs,velrs,vshockr |
| 417 |
|
| 418 |
double precision rhol, pl, ul, hl, csl, vell, wl, & |
| 419 |
rhor, pr, ur, hr, csr, velr, wr |
| 420 |
common /states/ rhol, pl, ul, hl, csl, vell, wl, & |
| 421 |
rhor, pr, ur, hr, csr, velr, wr |
| 422 |
|
| 423 |
double precision gamma |
| 424 |
common /adind/ gamma |
| 425 |
|
| 426 |
! ----- |
| 427 |
! left wave |
| 428 |
! ----- |
| 429 |
|
| 430 |
call getvel(p, rhol, pl, hl, csl, vell, wl, 'l', & |
| 431 |
rhols, uls, hls, csls, vells, vshockl ) |
| 432 |
|
| 433 |
! ----- |
| 434 |
! right wave |
| 435 |
! ----- |
| 436 |
|
| 437 |
call getvel(p, rhor, pr, hr, csr, velr, wr, 'r', & |
| 438 |
rhors, urs, hrs, csrs, velrs, vshockr ) |
| 439 |
|
| 440 |
dvel = vells - velrs |
| 441 |
|
| 442 |
return |
| 443 |
end subroutine getdvel |
| 444 |
|
| 445 |
! ------- |
| 446 |
!n name: g e t p |
| 447 |
! ------- |
| 448 |
|
| 449 |
!p purpose: |
| 450 |
!p find the pressure in the intermediate state of a riemann problem in |
| 451 |
!p relativistic hydrodynamics |
| 452 |
! |
| 453 |
|
| 454 |
!c comments: |
| 455 |
!c this routine uses a combination of interval bisection and inverse |
| 456 |
!c quadratic interpolation to find the root in a specified interval. |
| 457 |
!c it is assumed that dvel(pmin) and dvel(pmax) have opposite signs without |
| 458 |
!c a check. |
| 459 |
!c adapted from "computer methods for mathematical computation", |
| 460 |
!c by g. e. forsythe, m. a. malcolm, and c. b. moler, |
| 461 |
!c prentice-hall, englewood cliffs n.j. |
| 462 |
! |
| 463 |
subroutine getp( pmin, pmax, tol, ps ) |
| 464 |
|
| 465 |
|
| 466 |
! ----- |
| 467 |
! arguments |
| 468 |
! ----- |
| 469 |
|
| 470 |
doubleprecision, intent(in) :: pmin, pmax, tol |
| 471 |
doubleprecision, intent(out) :: ps |
| 472 |
|
| 473 |
! ------- |
| 474 |
! common blocks |
| 475 |
! ------- |
| 476 |
|
| 477 |
doubleprecision gamma |
| 478 |
common /adind/ gamma |
| 479 |
|
| 480 |
doubleprecision rhol, pl, ul, hl, csl, vell, wl, & |
| 481 |
rhor, pr, ur, hr, csr, velr, wr |
| 482 |
common /states/ rhol, pl, ul, hl, csl, vell, wl, & |
| 483 |
rhor, pr, ur, hr, csr, velr, wr |
| 484 |
|
| 485 |
! --------- |
| 486 |
! internal variables |
| 487 |
! --------- |
| 488 |
|
| 489 |
doubleprecision a, b, c, d, e, eps, fa, fb, fc, tol1, xm, p, q, r, s |
| 490 |
|
| 491 |
! ------------- |
| 492 |
! compute machine precision |
| 493 |
! ------------- |
| 494 |
|
| 495 |
eps = 1.d0 |
| 496 |
10 eps = eps/2.d0 |
| 497 |
tol1 = 1.d0 + eps |
| 498 |
if ( tol1 > 1.d0 ) go to 10 |
| 499 |
|
| 500 |
! ------- |
| 501 |
! initialization |
| 502 |
! ------- |
| 503 |
|
| 504 |
a = pmin |
| 505 |
b = pmax |
| 506 |
call getdvel(a,fa) |
| 507 |
call getdvel(b,fb) |
| 508 |
|
| 509 |
! ----- |
| 510 |
! begin step |
| 511 |
! ----- |
| 512 |
|
| 513 |
20 c = a |
| 514 |
fc = fa |
| 515 |
d = b - a |
| 516 |
e = d |
| 517 |
30 if ( dabs(fc) >= dabs(fb) )go to 40 |
| 518 |
a = b |
| 519 |
b = c |
| 520 |
c = a |
| 521 |
fa = fb |
| 522 |
fb = fc |
| 523 |
fc = fa |
| 524 |
|
| 525 |
! -------- |
| 526 |
! convergence test |
| 527 |
! -------- |
| 528 |
|
| 529 |
40 tol1 = 2.d0*eps*dabs(b) + 0.5d0*tol |
| 530 |
xm = 0.5d0*(c - b) |
| 531 |
if ( dabs(xm) <= tol1 ) go to 90 |
| 532 |
if ( fb == 0.d0 ) go to 90 |
| 533 |
|
| 534 |
! ------------ |
| 535 |
! is bisection necessary? |
| 536 |
! ------------ |
| 537 |
|
| 538 |
if ( dabs(e) < tol1 ) go to 70 |
| 539 |
if ( dabs(fa) <= dabs(fb) ) go to 70 |
| 540 |
|
| 541 |
! ------------------ |
| 542 |
! is quadratic interpolation possible? |
| 543 |
! ------------------ |
| 544 |
|
| 545 |
if ( a /= c ) go to 50 |
| 546 |
|
| 547 |
! ---------- |
| 548 |
! linear interpolation |
| 549 |
! ---------- |
| 550 |
|
| 551 |
s = fb/fa |
| 552 |
p = 2.d0*xm*s |
| 553 |
q = 1.d0 - s |
| 554 |
go to 60 |
| 555 |
|
| 556 |
! ---------------- |
| 557 |
! inverse quadratic interpolation |
| 558 |
! ---------------- |
| 559 |
|
| 560 |
50 q = fa/fc |
| 561 |
r = fb/fc |
| 562 |
s = fb/fa |
| 563 |
p = s*(2.d0*xm*q*(q - r) - (b - a)*(r - 1.d0)) |
| 564 |
q = (q - 1.d0)*(r - 1.d0)*(s - 1.d0) |
| 565 |
|
| 566 |
! ------ |
| 567 |
! adjust signs |
| 568 |
! ------ |
| 569 |
|
| 570 |
60 if ( p > 0.d0 ) q = -q |
| 571 |
p = dabs(p) |
| 572 |
|
| 573 |
! -------------- |
| 574 |
! is interpolation acceptable? |
| 575 |
! -------------- |
| 576 |
|
| 577 |
if ( (2.d0*p) >= (3.d0*xm*q-dabs(tol1*q)) ) go to 70 |
| 578 |
if ( p >= dabs(0.5d0*e*q) ) go to 70 |
| 579 |
e = d |
| 580 |
d = p/q |
| 581 |
go to 80 |
| 582 |
|
| 583 |
! ----- |
| 584 |
! bisection |
| 585 |
! ----- |
| 586 |
|
| 587 |
70 d = xm |
| 588 |
e = d |
| 589 |
|
| 590 |
! ------- |
| 591 |
! complete step |
| 592 |
! ------- |
| 593 |
|
| 594 |
80 a = b |
| 595 |
fa = fb |
| 596 |
if ( dabs(d) > tol1 ) b = b+d |
| 597 |
if ( dabs(d) <= tol1 ) b = b+dsign(tol1,xm) |
| 598 |
call getdvel(b,fb) |
| 599 |
if ( (fb*(fc/dabs(fc))) > 0.d0) go to 20 |
| 600 |
go to 30 |
| 601 |
|
| 602 |
! -- |
| 603 |
! done |
| 604 |
! -- |
| 605 |
|
| 606 |
90 ps = b |
| 607 |
|
| 608 |
return |
| 609 |
end subroutine getp |
| 610 |
|
| 611 |
! --------- |
| 612 |
!n name: g e t v e l |
| 613 |
! --------- |
| 614 |
|
| 615 |
!p purpose: |
| 616 |
!p compute the flow velocity behind a rarefaction or shock in terms of the |
| 617 |
!p post-wave pressure for a given state ahead the wave in a relativistic |
| 618 |
!p flow |
| 619 |
! |
| 620 |
|
| 621 |
!c comments: |
| 622 |
!c this routine closely follows the expressions in Marti and Mueller, |
| 623 |
!c J. fluid mech., (1994) |
| 624 |
|
| 625 |
subroutine getvel( p, rhoa, pa, ha, csa, vela, wa, s, & |
| 626 |
rho, u, h, cs, vel, vshock ) |
| 627 |
|
| 628 |
|
| 629 |
! ----- |
| 630 |
! arguments |
| 631 |
! ----- |
| 632 |
|
| 633 |
double precision, intent(in) :: p, rhoa, pa, ha, csa, vela, wa |
| 634 |
character(len=1), intent(in) :: s |
| 635 |
double precision, intent(out) :: rho, u, h, cs, vel, vshock |
| 636 |
|
| 637 |
! ------- |
| 638 |
! common blocks |
| 639 |
! ------- |
| 640 |
|
| 641 |
double precision gamma |
| 642 |
common /adind/ gamma |
| 643 |
|
| 644 |
! --------- |
| 645 |
! internal variables |
| 646 |
! --------- |
| 647 |
|
| 648 |
double precision a, b, c, sign |
| 649 |
double precision j, wshock |
| 650 |
double precision k, sqgl1 |
| 651 |
|
| 652 |
! --------------- |
| 653 |
! left or right propagating wave |
| 654 |
! --------------- |
| 655 |
|
| 656 |
sign = 0.d0 |
| 657 |
if (s=='l') sign = -1.d0 |
| 658 |
|
| 659 |
if (s=='r') sign = 1.d0 |
| 660 |
|
| 661 |
! |
| 662 |
|
| 663 |
if (p > pa) then |
| 664 |
|
| 665 |
! --- |
| 666 |
! shock |
| 667 |
! --- |
| 668 |
|
| 669 |
a = 1.d0+(gamma-1.d0)*(pa-p)/gamma/p |
| 670 |
b = 1.d0-a |
| 671 |
c = ha*(pa-p)/rhoa-ha**2 |
| 672 |
|
| 673 |
! ---------------- |
| 674 |
! check for unphysical enthalpies |
| 675 |
! ---------------- |
| 676 |
|
| 677 |
if (c > (b**2/4.d0/a)) then |
| 678 |
print*,'getvel: unphysical specific enthalpy in intermediate state' |
| 679 |
return |
| 680 |
endif |
| 681 |
|
| 682 |
! ----------------------------- |
| 683 |
! specific enthalpy in the post-wave state |
| 684 |
! (from the equation of state and the taub adiabat, |
| 685 |
! eq.(74), mm94) |
| 686 |
! ----------------------------- |
| 687 |
|
| 688 |
h = (-b+dsqrt(b**2-4.d0*a*c))/2.d0/a |
| 689 |
|
| 690 |
! --------------- |
| 691 |
! density in the post-wave state |
| 692 |
! (from eq.(73), mm94) |
| 693 |
! --------------- |
| 694 |
|
| 695 |
rho = gamma*p/(gamma-1.d0)/(h-1.d0) |
| 696 |
|
| 697 |
! ------------------------ |
| 698 |
! specific internal energy in the post-wave state |
| 699 |
! (from the equation of state) |
| 700 |
! ------------------------ |
| 701 |
|
| 702 |
u = p/(gamma-1.d0)/rho |
| 703 |
|
| 704 |
! -------------------------- |
| 705 |
! mass flux across the wave |
| 706 |
! (from the rankine-hugoniot relations, eq.(71), mm94) |
| 707 |
! -------------------------- |
| 708 |
|
| 709 |
j = sign*dsqrt((p-pa)/(ha/rhoa-h/rho)) |
| 710 |
|
| 711 |
! ---------- |
| 712 |
! shock velocity |
| 713 |
! (from eq.(86), mm94 |
| 714 |
! ---------- |
| 715 |
|
| 716 |
a = j**2+(rhoa*wa)**2 |
| 717 |
b = -vela*rhoa**2*wa**2 |
| 718 |
vshock = (-b+sign*j**2*dsqrt(1.d0+rhoa**2/j**2))/a |
| 719 |
wshock = 1.d0/dsqrt(1.d0-vshock**2) |
| 720 |
|
| 721 |
! ------------------- |
| 722 |
! flow velocity in the post-shock state |
| 723 |
! (from eq.(67), mm94) |
| 724 |
! ------------------- |
| 725 |
|
| 726 |
a = wshock*(p-pa)/j+ha*wa*vela |
| 727 |
b = ha*wa+(p-pa)*(wshock*vela/j+1.d0/rhoa/wa) |
| 728 |
|
| 729 |
vel = a/b |
| 730 |
|
| 731 |
! --------------------- |
| 732 |
! local sound speed in the post-shock state |
| 733 |
! (from the equation of state) |
| 734 |
! --------------------- |
| 735 |
|
| 736 |
cs = dsqrt(gamma*p/rho/h) |
| 737 |
|
| 738 |
else |
| 739 |
|
| 740 |
! ------ |
| 741 |
! rarefaction |
| 742 |
! ------ |
| 743 |
|
| 744 |
! --------------------------- |
| 745 |
! politropic constant of the gas across the rarefaction |
| 746 |
! --------------------------- |
| 747 |
|
| 748 |
k = pa/rhoa**gamma |
| 749 |
|
| 750 |
! --------------- |
| 751 |
! density behind the rarefaction |
| 752 |
! --------------- |
| 753 |
|
| 754 |
rho = (p/k)**(1.d0/gamma) |
| 755 |
|
| 756 |
! ------------------------ |
| 757 |
! specific internal energy behind the rarefaction |
| 758 |
! (from the equation of state) |
| 759 |
! ------------------------ |
| 760 |
|
| 761 |
u = p/(gamma-1.d0)/rho |
| 762 |
|
| 763 |
! -------------------- |
| 764 |
! local sound speed behind the rarefaction |
| 765 |
! (from the equation of state) |
| 766 |
! -------------------- |
| 767 |
|
| 768 |
cs = dsqrt(gamma*p/(rho+gamma*p/(gamma-1.d0))) |
| 769 |
|
| 770 |
! ------------------ |
| 771 |
! flow velocity behind the rarefaction |
| 772 |
! ------------------ |
| 773 |
|
| 774 |
sqgl1 = dsqrt(gamma-1.d0) |
| 775 |
a = (1.d0+vela)/(1.d0-vela)*((sqgl1+csa)/(sqgl1-csa)* & |
| 776 |
(sqgl1-cs )/(sqgl1+cs ))**(-sign*2.d0/sqgl1) |
| 777 |
|
| 778 |
vel = (a-1.d0)/(a+1.d0) |
| 779 |
|
| 780 |
endif |
| 781 |
|
| 782 |
end subroutine getvel |
| 783 |
|
| 784 |
! -------- |
| 785 |
!n name: r a r e f |
| 786 |
! -------- |
| 787 |
|
| 788 |
!p purpose: |
| 789 |
!p compute the flow state in a rarefaction for given pre-wave state |
| 790 |
! |
| 791 |
|
| 792 |
!c comments: |
| 793 |
!c this routine closely follows the expressions in marti and mueller, |
| 794 |
!c j. fluid mech., (1994) |
| 795 |
|
| 796 |
subroutine raref( xi, rhoa, csa, vela, s, rho, p, u, vel ) |
| 797 |
|
| 798 |
|
| 799 |
! ----- |
| 800 |
! arguments |
| 801 |
! ----- |
| 802 |
|
| 803 |
double precision, intent(in) :: xi |
| 804 |
|
| 805 |
double precision, intent(in) :: rhoa, csa, vela |
| 806 |
|
| 807 |
character, intent(in) :: s |
| 808 |
|
| 809 |
double precision, intent(out) :: rho, p, u, vel |
| 810 |
|
| 811 |
! ------- |
| 812 |
! common blocks |
| 813 |
! ------- |
| 814 |
|
| 815 |
double precision gamma |
| 816 |
common /adind/ gamma |
| 817 |
|
| 818 |
! --------- |
| 819 |
! internal variables |
| 820 |
! --------- |
| 821 |
|
| 822 |
double precision b, c, d, k, l, v, ocs2, fcs2, dfdcs2, cs2, sign |
| 823 |
|
| 824 |
! --------------- |
| 825 |
! left or right propagating wave |
| 826 |
! --------------- |
| 827 |
|
| 828 |
sign = 0.d0 |
| 829 |
if (s=='l') sign = 1.d0 |
| 830 |
|
| 831 |
if (s=='r') sign = -1.d0 |
| 832 |
|
| 833 |
b = dsqrt(gamma - 1.d0) |
| 834 |
c = (b + csa)/(b - csa) |
| 835 |
d = -sign*b/2.d0 |
| 836 |
k = (1.d0 + xi)/(1.d0 - xi) |
| 837 |
l = c*k**d |
| 838 |
v = ((1.d0 - vela)/(1.d0 + vela))**d |
| 839 |
|
| 840 |
ocs2 = csa |
| 841 |
|
| 842 |
25 fcs2 = l*v*(1.d0 + sign*ocs2)**d*(ocs2 - b) + (1.d0 - sign*ocs2)**d*(ocs2 + b) |
| 843 |
|
| 844 |
dfdcs2 = l*v*(1.d0 + sign*ocs2)**d* & |
| 845 |
(1.d0 + sign*d*(ocs2 - b)/(1.d0 + sign*ocs2)) + & |
| 846 |
(1.d0 - sign*ocs2)**d* & |
| 847 |
(1.d0 - sign*d*(ocs2 + b)/(1.d0 - sign*ocs2)) |
| 848 |
|
| 849 |
cs2 = ocs2 - fcs2/dfdcs2 |
| 850 |
|
| 851 |
if (abs(cs2 - ocs2)/ocs2 > 5.e-7) then |
| 852 |
ocs2 = cs2 |
| 853 |
goto 25 |
| 854 |
endif |
| 855 |
|
| 856 |
vel = (xi + sign*cs2)/(1.d0 + sign*xi*cs2) |
| 857 |
|
| 858 |
rho = rhoa*((cs2**2*(gamma - 1.d0 - csa**2))/ & |
| 859 |
(csa**2*(gamma - 1.d0 - cs2**2)))**(1.d0/(gamma - 1.d0)) |
| 860 |
|
| 861 |
p = cs2**2*(gamma - 1.d0)*rho/(gamma - 1.d0 - cs2**2)/gamma |
| 862 |
|
| 863 |
u = p/(gamma - 1.d0)/rho |
| 864 |
|
| 865 |
return |
| 866 |
end subroutine raref |
| 867 |
|
| 868 |
end module shock_sr |