| 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 |
! Plot exact solution for a magnetohydrodynamic shock |
| 25 |
! (ie. one dimensional MHD Riemann problem) |
| 26 |
! |
| 27 |
! For want of a better solution these are just taken from the tables in |
| 28 |
! Ryu & Jones (1995), ApJ 442, 228 or from ruler and pencil |
| 29 |
! on the results in Balsara (1998), or from running the Athena code via |
| 30 |
! http://rainman.astro.illinois.edu/ddr/oned/cgi-bin/athena.pl |
| 31 |
! |
| 32 |
! ---------------------------------------------------------------------- |
| 33 |
module mhdshock |
| 34 |
implicit none |
| 35 |
public :: exact_mhdshock |
| 36 |
integer, parameter, public :: nmhdshocksolns = 7 |
| 37 |
character(len=23), dimension(nmhdshocksolns), parameter, public :: mhdprob = & |
| 38 |
(/'Brio/Wu (gamma=2) ', & |
| 39 |
'fast/slow shock (RJ95)', & |
| 40 |
'7 jump shock (RJ95)', & |
| 41 |
'isothermal shock (B98) ', & |
| 42 |
'rarefaction wave (RJ95)', & |
| 43 |
'Mach 25 shock (DW94)', & |
| 44 |
'Toth shock (RJ95/T00)'/) |
| 45 |
|
| 46 |
|
| 47 |
contains |
| 48 |
|
| 49 |
subroutine exact_mhdshock(iplot,ishk,time,gamma,xmin,xmax,xshock,xpts,ypts,npts,ierr) |
| 50 |
integer, intent(in) :: iplot,ishk |
| 51 |
integer, intent(out) :: npts,ierr |
| 52 |
real, intent(in) :: time,gamma,xmin,xmax,xshock |
| 53 |
real, dimension(:), intent(inout) :: xpts |
| 54 |
real, dimension(size(xpts)), intent(out) :: ypts |
| 55 |
|
| 56 |
real, dimension(16) :: rho,pr,vx,vy,vz,By,Bz |
| 57 |
real :: const, Bxzero,tfac |
| 58 |
|
| 59 |
print*,' Plotting exact mhd shock #',ishk,' at t = ',time |
| 60 |
! |
| 61 |
!--set up grid for exact solution |
| 62 |
! |
| 63 |
const = 1./sqrt(4.*3.1415926536) |
| 64 |
ierr = 0 |
| 65 |
|
| 66 |
select case(ishk) ! which solution to plot |
| 67 |
case(1) |
| 68 |
! |
| 69 |
!--Brio & Wu problem with gamma = 2 |
| 70 |
! |
| 71 |
tfac = time/0.1 |
| 72 |
vz = 0. |
| 73 |
Bz = 0. |
| 74 |
Bxzero = 0.75 |
| 75 |
npts = 14 |
| 76 |
xpts(1) = xmin |
| 77 |
xpts(2) = -0.18*tfac |
| 78 |
xpts(3) = -0.08*tfac |
| 79 |
xpts(4:6) = -0.03*tfac |
| 80 |
xpts(7) = -0.005*tfac |
| 81 |
xpts(8:9) = 0.06*tfac |
| 82 |
xpts(10:11) = 0.147*tfac |
| 83 |
xpts(12) = 0.33*tfac |
| 84 |
xpts(13) = 0.36*tfac |
| 85 |
xpts(14) = xmax |
| 86 |
|
| 87 |
rho(1:2) = 1.0 |
| 88 |
rho(3:4) = 0.67623 |
| 89 |
rho(5) = 0.827 |
| 90 |
rho(6) = 0.775 |
| 91 |
rho(7:8) = 0.6962 |
| 92 |
rho(9:10) = 0.2352 |
| 93 |
rho(11:12) = 0.117 |
| 94 |
rho(13:14) = 0.125 |
| 95 |
|
| 96 |
pr(1:2) = 1.0 |
| 97 |
pr(3:4) = 0.447 |
| 98 |
pr(5) = 0.727219 |
| 99 |
pr(6) = 0.6 |
| 100 |
pr(7:10) = 0.5160 |
| 101 |
pr(11:12) = 0.0876 |
| 102 |
pr(13:14) = 0.1 |
| 103 |
|
| 104 |
vx(1:2) = 0.0 |
| 105 |
vx(3:4) = 0.63721 |
| 106 |
vx(5) = 0.48 |
| 107 |
vx(6) = 0.52 |
| 108 |
vx(7:10) = 0.600 |
| 109 |
vx(11:12) = -0.24 |
| 110 |
vx(13:14) = 0.0 |
| 111 |
|
| 112 |
vy(1:2) = 0.0 |
| 113 |
vy(3:4) = -0.23345 |
| 114 |
vy(5) = -1.3 |
| 115 |
vy(6) = -1.4 |
| 116 |
vy(7:10) = -1.584 |
| 117 |
vy(11:12) = -0.166 |
| 118 |
vy(13:14) = 0. |
| 119 |
|
| 120 |
By(1:2) = 1.0 |
| 121 |
By(3:4) = 2.1*const |
| 122 |
By(5) = -1.2*const |
| 123 |
By(6) = -1.3*const |
| 124 |
By(7:10) = -1.9*const |
| 125 |
By(11:12) = -3.25*const |
| 126 |
By(13:14) = -1.0 |
| 127 |
|
| 128 |
case(2) |
| 129 |
! |
| 130 |
!--fast/slow shock from RJ95 |
| 131 |
! |
| 132 |
tfac = time/0.15 |
| 133 |
vz = 0. |
| 134 |
Bz = 0. |
| 135 |
Bxzero = 1.0 |
| 136 |
npts = 12 |
| 137 |
xpts(1) = xmin |
| 138 |
xpts(2) = -0.27*tfac |
| 139 |
xpts(3) = -0.09*tfac |
| 140 |
xpts(4) = -0.03*tfac |
| 141 |
xpts(5) = -0.01*tfac |
| 142 |
xpts(6:7) = 0.135*tfac |
| 143 |
xpts(8:9) = 0.25*tfac |
| 144 |
xpts(10:11) = 0.35*tfac |
| 145 |
xpts(12) = xmax |
| 146 |
|
| 147 |
rho(1:2) = 1.0 |
| 148 |
rho(3:4) = 0.5955 |
| 149 |
rho(5:6) = 0.55151 |
| 150 |
rho(7:8) = 0.41272 |
| 151 |
rho(9:10) = 0.2337 |
| 152 |
rho(11:12) = 0.2 |
| 153 |
|
| 154 |
pr(1:2) = 1.0 |
| 155 |
pr(3:4) = 0.42629 |
| 156 |
pr(5:8) = 0.37090 |
| 157 |
pr(9:10) = 0.12402 |
| 158 |
pr(11:12) = 0.1 |
| 159 |
|
| 160 |
vx(1:2) = 0.0 |
| 161 |
vx(3:4) = 0.81237 |
| 162 |
vx(5:8) = 0.89416 |
| 163 |
vx(9:10) = 0.24722 |
| 164 |
vx(11:12) = 0.0 |
| 165 |
|
| 166 |
vy(1:2) = 0.0 |
| 167 |
vy(3:4) = -0.59961 |
| 168 |
vy(5:8) = -0.5447 |
| 169 |
vy(9:10) = -0.91164 |
| 170 |
vy(11:12) = 0. |
| 171 |
|
| 172 |
By(1:2) = 1.0 |
| 173 |
By(3:4) = 0.28431 |
| 174 |
By(5:8) = 0.31528 |
| 175 |
By(9:10) = 0.43086 |
| 176 |
By(11:12) = 0.0 |
| 177 |
|
| 178 |
case(3) |
| 179 |
! |
| 180 |
!--problem with 7 discontinuities from RJ95 |
| 181 |
! |
| 182 |
tfac = time/0.2 |
| 183 |
Bxzero = 2.*const |
| 184 |
npts = 16 |
| 185 |
xpts(1) = xmin |
| 186 |
xpts(2:3) = -0.19*tfac |
| 187 |
xpts(4:5) = 0.03*tfac |
| 188 |
xpts(6:7) = 0.051*tfac |
| 189 |
xpts(8:9) = 0.12*tfac ! contact discontinuity |
| 190 |
xpts(10:11) = 0.18*tfac |
| 191 |
xpts(12:13) = 0.205*tfac |
| 192 |
xpts(14:15) = 0.45*tfac |
| 193 |
xpts(16) = xmax |
| 194 |
|
| 195 |
rho(1:2) = 1.08 |
| 196 |
rho(3:4) = 1.4903 |
| 197 |
rho(5:8) = 1.6343 |
| 198 |
rho(9:10) = 1.4735 |
| 199 |
rho(11:14) = 1.3090 |
| 200 |
rho(15:16) = 1.0 |
| 201 |
|
| 202 |
pr(1:2) = 0.95 |
| 203 |
pr(3:4) = 1.6558 |
| 204 |
pr(5:10) = 1.9317 |
| 205 |
pr(11:14) = 1.5844 |
| 206 |
pr(15:16) = 1.0 |
| 207 |
|
| 208 |
vx(1:2) = 1.2 |
| 209 |
vx(3:5) = 0.60588 |
| 210 |
vx(6:11) = 0.57538 |
| 211 |
vx(12:14) = 0.53432 |
| 212 |
vx(15:16) = 0.0 |
| 213 |
|
| 214 |
vy(1:2) = 0.01 |
| 215 |
vy(3:4) = 0.11235 |
| 216 |
vy(5:6) = 0.22157 |
| 217 |
vy(7:8) = 0.047602 |
| 218 |
vy(9:10) = 0.047601 |
| 219 |
vy(11:12) = -0.18411 |
| 220 |
vy(13:14) = -0.094572 |
| 221 |
vy(15:16) = 0.0 |
| 222 |
|
| 223 |
vz(1:2) = 0.5 |
| 224 |
vz(3:4) = 0.55686 |
| 225 |
vz(5:6) = 0.30125 |
| 226 |
vz(7:10) = 0.24734 |
| 227 |
vz(11:12) = 0.17554 |
| 228 |
vz(13:14) = -0.047286 |
| 229 |
vz(15:16) = 0.0 |
| 230 |
|
| 231 |
By(1:2) = 1.0155 |
| 232 |
By(3:4) = 1.4383 |
| 233 |
By(5:6) = 1.5716 |
| 234 |
By(7:10) = 1.4126 |
| 235 |
By(11:12) = 1.6103 |
| 236 |
By(13:14) = 1.5078 |
| 237 |
By(15:16) = 1.1284 |
| 238 |
|
| 239 |
Bz(1:2) = 0.56419 |
| 240 |
Bz(3:4) = 0.79907 |
| 241 |
Bz(5:6) = 0.48702 |
| 242 |
Bz(7:10) = 0.43772 |
| 243 |
Bz(11:12) = 0.49899 |
| 244 |
Bz(13:14) = 0.75392 |
| 245 |
Bz(15:16) = 0.56419 |
| 246 |
|
| 247 |
case(4) |
| 248 |
! |
| 249 |
!--isothermal MHD problem from Balsara (1998) |
| 250 |
! |
| 251 |
tfac = time/0.2 |
| 252 |
Bxzero = 2.*const |
| 253 |
npts = 14 |
| 254 |
xpts(1) = xmin |
| 255 |
xpts(2:3) = -0.15*tfac |
| 256 |
xpts(4:5) = 0.035*tfac |
| 257 |
xpts(6:7) = 0.07*tfac |
| 258 |
xpts(8:9) = 0.17*tfac |
| 259 |
xpts(10:11) = 0.2*tfac |
| 260 |
xpts(12:13) = 0.41*tfac |
| 261 |
xpts(14) = xmax |
| 262 |
|
| 263 |
rho(1:2) = 1.08 |
| 264 |
rho(3:6) = 1.515 |
| 265 |
rho(7:8) = 1.745 |
| 266 |
rho(9:12) = 1.36 |
| 267 |
rho(13:14) = 1.0 |
| 268 |
|
| 269 |
vx(1:2) = 1.2 |
| 270 |
vx(3:6) = 0.65 |
| 271 |
vx(7:8) = 0.62 |
| 272 |
vx(9:12) = 0.54 |
| 273 |
vx(13:14) = 0.0 |
| 274 |
|
| 275 |
vy(1:2) = 0.01 |
| 276 |
vy(3:4) = 0.13 |
| 277 |
vy(5:6) = 0.24 |
| 278 |
vy(7:8) = 0.071 |
| 279 |
vy(9:10) = -0.215 |
| 280 |
vy(11:12) = -0.125 |
| 281 |
vy(13:14) = 0.0 |
| 282 |
|
| 283 |
vz(1:2) = 0.5 |
| 284 |
vz(3:4) = 0.57 |
| 285 |
vz(5:6) = 0.31 |
| 286 |
vz(7:8) = 0.255 |
| 287 |
vz(9:10) = 0.165 |
| 288 |
vz(11:12) = -0.06 |
| 289 |
vz(13:14) = 0.0 |
| 290 |
|
| 291 |
By(1:2) = 3.6*const |
| 292 |
By(3:4) = 5.2*const |
| 293 |
By(5:6) = 5.7*const |
| 294 |
By(7:8) = 5.22*const |
| 295 |
By(9:10) = 5.96*const |
| 296 |
By(11:12) = 5.58*const |
| 297 |
By(13:14) = 4.0*const |
| 298 |
|
| 299 |
Bz(1:2) = 2.0*const |
| 300 |
Bz(3:4) = 2.885*const |
| 301 |
Bz(5:6) = 1.76*const |
| 302 |
Bz(7:8) = 1.62*const |
| 303 |
Bz(9:10) = 1.85*const |
| 304 |
Bz(11:12) = 2.79*const |
| 305 |
Bz(13:14) = 2.0*const |
| 306 |
|
| 307 |
pr = rho |
| 308 |
|
| 309 |
case(5) |
| 310 |
! |
| 311 |
!--rarefaction from RJ95 |
| 312 |
! |
| 313 |
tfac = time/0.1 |
| 314 |
npts = 6 |
| 315 |
vy = 0. |
| 316 |
vz = 0. |
| 317 |
Bz = 0. |
| 318 |
Bxzero = 0. |
| 319 |
xpts(1) = xmin |
| 320 |
xpts(2) = -0.27*tfac |
| 321 |
xpts(3) = -0.12*tfac |
| 322 |
xpts(4) = 0.12*tfac |
| 323 |
xpts(5) = 0.27*tfac |
| 324 |
xpts(6) = xmax |
| 325 |
|
| 326 |
rho(1:2) = 1.0 |
| 327 |
rho(3:4) = 0.49653 |
| 328 |
rho(5:6) = 1.0 |
| 329 |
|
| 330 |
pr(1:2) = 1.0 |
| 331 |
pr(3:4) = 0.31134 |
| 332 |
pr(5:6) = 1.0 |
| 333 |
|
| 334 |
vx(1:2) = -1.0 |
| 335 |
vx(3:4) = 0. ! this is approximate (to 10-7) |
| 336 |
vx(5:6) = 1.0 |
| 337 |
|
| 338 |
By(1:2) = 1.0 |
| 339 |
By(3:4) = 0.49638 |
| 340 |
By(5:6) = 1.0 |
| 341 |
|
| 342 |
case(6) |
| 343 |
! |
| 344 |
!--mach 25 shocks from Dai and Woodward (1994) |
| 345 |
! |
| 346 |
tfac = time/0.03 |
| 347 |
Bxzero = 4.*const |
| 348 |
npts = 6 |
| 349 |
rho(1:2) = 1.0 |
| 350 |
rho(3:4) = 3.982 |
| 351 |
rho(5:6) = 0.1 |
| 352 |
|
| 353 |
pr(1:2) = 1.0 |
| 354 |
pr(3:4) = 1806.0 |
| 355 |
pr(5:6) = 1.0 |
| 356 |
|
| 357 |
! machno = 0.5*25.5 |
| 358 |
! vs = sqrt(gamma*pr(1)/rho(1)) |
| 359 |
! |
| 360 |
xpts(1) = xmin |
| 361 |
xpts(2:3) = -0.35*tfac |
| 362 |
xpts(4:5) = 0.35*tfac |
| 363 |
xpts(6) = xmax |
| 364 |
|
| 365 |
vx(1:2) = 36.87 |
| 366 |
vx(3:4) = 0.0 |
| 367 |
vx(5:6) = -36.87 |
| 368 |
|
| 369 |
vy(1:2) = -0.1546 |
| 370 |
vy(3:4) = -0.07727 |
| 371 |
vy(5:6) = 0.0 |
| 372 |
|
| 373 |
vz(1:2) = -0.03864 |
| 374 |
vz(3:4) = -0.01932 |
| 375 |
vz(5:6) = 0.0 |
| 376 |
|
| 377 |
By(1:2) = 4.0*const |
| 378 |
By(3:4) = 15.95*const |
| 379 |
By(5:6) = 4.0*const |
| 380 |
|
| 381 |
Bz(1:2) = 1.0*const |
| 382 |
Bz(3:4) = 3.988*const |
| 383 |
Bz(5:6) = 1.0*const |
| 384 |
|
| 385 |
case(7) |
| 386 |
! |
| 387 |
!--Problem 1A in Ryu and Jones (1995) |
| 388 |
! |
| 389 |
Bxzero = 5.*const |
| 390 |
npts = 12 |
| 391 |
tfac = time/0.08 |
| 392 |
xpts(1) = xmin |
| 393 |
xpts(2:3) = -0.386*tfac |
| 394 |
xpts(4:5) = -0.01*tfac |
| 395 |
xpts(6:7) = 0.0505*tfac |
| 396 |
xpts(8:9) = 0.12*tfac |
| 397 |
xpts(10:11) = 0.37*tfac |
| 398 |
xpts(12) = xmax |
| 399 |
|
| 400 |
rho(1:2) = 1.0 |
| 401 |
rho(3:4) = 2.6797 |
| 402 |
rho(5:6) = 2.6713 |
| 403 |
rho(7:8) = 3.8508 |
| 404 |
rho(9:10) = 3.7481 |
| 405 |
rho(11:12) = 1.0 |
| 406 |
|
| 407 |
pr(1:2) = 20.0 |
| 408 |
pr(3:4) = 150.98 |
| 409 |
pr(5:8) = 150.19 |
| 410 |
pr(9:10) = 143.57 |
| 411 |
pr(11:12) = 1.0 |
| 412 |
|
| 413 |
vx(1:2) = 10.0 |
| 414 |
vx(3:4) = 0.72113 |
| 415 |
vx(5:8) = 0.72376 |
| 416 |
vx(9:10) = 0.70505 |
| 417 |
vx(11:12) = -10.0 |
| 418 |
|
| 419 |
vy(1:2) = 0.0 |
| 420 |
vy(3:4) = 0.23139 |
| 421 |
vy(5:8) = 0.35684 |
| 422 |
vy(9:10) = -0.38804 |
| 423 |
vy(11:12) = 0.0 |
| 424 |
|
| 425 |
vz(1:12) = 0.0 |
| 426 |
|
| 427 |
By(1:2) = 1.4105 |
| 428 |
By(3:4) = 3.8389 |
| 429 |
By(5:8) = 4.0380 |
| 430 |
By(9:10) = 5.4272 |
| 431 |
By(11:12) = 1.4105 |
| 432 |
|
| 433 |
Bz(1:12) = 0.0 |
| 434 |
|
| 435 |
case default |
| 436 |
ierr = 1 |
| 437 |
npts = 0 |
| 438 |
ypts = 0. |
| 439 |
xpts = 0. |
| 440 |
return |
| 441 |
|
| 442 |
end select |
| 443 |
|
| 444 |
! |
| 445 |
!--plot just the initial conditions at t=0 |
| 446 |
! |
| 447 |
if (abs(time) <= 0.) then |
| 448 |
rho(1:2) = rho(1) |
| 449 |
pr(1:2) = pr(1) |
| 450 |
vx(1:2) = vx(1) |
| 451 |
vy(1:2) = vy(1) |
| 452 |
vz(1:2) = vz(1) |
| 453 |
By(1:2) = By(1) |
| 454 |
Bz(1:2) = Bz(1) |
| 455 |
xpts(3) = 0. |
| 456 |
xpts(4) = xpts(npts) |
| 457 |
rho(3:4) = rho(npts) |
| 458 |
pr(3:4) = pr(npts) |
| 459 |
vx(3:4) = vx(npts) |
| 460 |
vy(3:4) = vy(npts) |
| 461 |
vz(3:4) = vz(npts) |
| 462 |
By(3:4) = By(npts) |
| 463 |
Bz(3:4) = Bz(npts) |
| 464 |
npts = 4 |
| 465 |
endif |
| 466 |
|
| 467 |
! |
| 468 |
!--translate positions if shock is not at x=0 |
| 469 |
! |
| 470 |
xpts(:) = xpts(:) + xshock |
| 471 |
|
| 472 |
! |
| 473 |
!--determine which parameter to plot |
| 474 |
! |
| 475 |
select case(iplot) |
| 476 |
case(1) |
| 477 |
ypts(1:npts) = rho(1:npts) |
| 478 |
case(2) |
| 479 |
ypts(1:npts) = pr(1:npts) |
| 480 |
case(3) |
| 481 |
ypts(1:npts) = vx(1:npts) |
| 482 |
case(4) |
| 483 |
ypts(1:npts) = vy(1:npts) |
| 484 |
case(5) |
| 485 |
ypts(1:npts) = vz(1:npts) |
| 486 |
case(6) |
| 487 |
ypts(1:npts) = By(1:npts) |
| 488 |
case(7) |
| 489 |
ypts(1:npts) = Bz(1:npts) |
| 490 |
case(8) |
| 491 |
print*,'gamma = ',gamma |
| 492 |
if (abs(gamma-1.) > 1.e-5) then |
| 493 |
where (abs(rho(1:npts)) > 0.) |
| 494 |
ypts(1:npts) = pr(1:npts) / ((gamma-1.)*rho(1:npts)) |
| 495 |
end where |
| 496 |
else |
| 497 |
print*,' ***isothermal: utherm solution not valid' |
| 498 |
ypts(1:npts) = 0. |
| 499 |
endif |
| 500 |
case(9) |
| 501 |
ypts(1:npts) = Bxzero |
| 502 |
case default |
| 503 |
print*,'error: unknown solution to plot' |
| 504 |
end select |
| 505 |
|
| 506 |
return |
| 507 |
end subroutine exact_mhdshock |
| 508 |
|
| 509 |
end module mhdshock |