Debian Codegraph @

scripts/splash_exact.py

raw
1 import os.path
2 from pathlib import Path
3
4 from ctypes import *
5
6 #### Add to your script
7 #
8 # import sys
9 # sys.path.append('/path/to/splash/scripts') (directory, which contains this script)
10 # import splash_exact
11 # import numpy
12 #
13 #### After those lines, all splash exact solutions are available for use
14 #
15 # x = numpy.linspace(-0.25, 0.25, num=1000)
16 # x, y, ierr = splash_exact.shock(x)
17 # if (ierr != 0):
18 # plt.plot(x,y)
19 # plt.show()
20 #
21 ####
22
23 def prerun():
24 libexactpath = Path(__file__).parent.parent.joinpath('build/libexact.so')
25 if (not libexactpath.exists()):
26 print("Could not find `libexact.so")
27 print("Please compile with `make libexact` first.")
28 exit(1)
29 else:
30 lib = cdll.LoadLibrary(str(libexactpath))
31 lib.check_argcv_f()
32 return lib
33
34 def checkfmt(str):
35 return str.lower().replace(' ', '_').replace('-', '_').replace('/', '_')
36
37 def shock(
38 x,
39 plot = 'density',
40 time = 0.1,
41 gamma = 5./3.,
42 xshock = 0.,
43 rho_L = 1.,
44 rho_R = 0.125,
45 p_L = 1.,
46 p_R = 0.1,
47 v_L = 0,
48 v_R = 0.,
49 rdust_to_gas = 0.):
50
51 pin = checkfmt(plot)
52 if (pin == 'density'):
53 iplot = 1
54 elif (pin == 'pressure'):
55 iplot = 2
56 elif (pin == 'velocity'):
57 iplot = 3
58 elif (pin == 'uthermal'):
59 iplot = 4
60 elif (pin == 'deltav'):
61 iplot = 5
62 elif (pin == 'dustfrac'):
63 iplot = 6
64 else:
65 print("Splash Exact: Unrecognised plot type.")
66 print("Splash Exact: plot = density || pressure || velocity || uthermal || deltav || dustfrac")
67 exit(1)
68
69 exactdll = prerun()
70 ierr = 0
71 c_x = (c_float*len(x))()
72 c_y = (c_float*len(x))()
73 c_x[:] = x[:]
74 exactdll.shock(
75 byref(c_int(iplot)),
76 byref(c_int(len(x))),
77 byref(c_float(time)),
78 byref(c_float(gamma)),
79 byref(c_float(xshock)),
80 byref(c_float(rho_L)),
81 byref(c_float(rho_R)),
82 byref(c_float(p_L)),
83 byref(c_float(p_R)),
84 byref(c_float(v_L)),
85 byref(c_float(v_R)),
86 byref(c_float(rdust_to_gas)),
87 byref(c_x),
88 byref(c_y),
89 byref(c_int(ierr))
90 )
91 return c_x[:], c_y[:], ierr
92
93 def shock_sr(
94 x,
95 plot = 'density',
96 time = 0.1,
97 gamma = 5./3.,
98 rho_L = 1.,
99 rho_R = 0.125,
100 p_L = 1.0,
101 p_R = 0.1,
102 v_L = 0.,
103 v_R = 0.):
104
105 pin = checkfmt(plot)
106 if (pin == 'density'):
107 iplot = 1
108 elif (pin == 'pressure'):
109 iplot = 2
110 elif (pin == 'velocity'):
111 iplot = 3
112 elif (pin == 'uthermal'):
113 iplot = 4
114 elif (pin == 'density*'):
115 iplot = 5
116 else:
117 print("Splash Exact: Unrecognised plot type.")
118 print("Splash Exact: plot = density || pressure || velocity || uthermal || density*")
119 exit(1)
120
121 exactdll = prerun()
122 ierr = 0
123 c_x = (c_float*len(x))()
124 c_y = (c_float*len(x))()
125 c_x[:] = x[:]
126 exactdll.shock_sr_(
127 byref(c_int(iplot)),
128 byref(c_int(len(x))),
129 byref(c_float(time)),
130 byref(c_float(gamma)),
131 byref(c_float(rho_L)),
132 byref(c_float(rho_R)),
133 byref(c_float(p_L)),
134 byref(c_float(p_R)),
135 byref(c_float(v_L)),
136 byref(c_float(v_R)),
137 byref(c_x),
138 byref(c_y),
139 byref(c_int(ierr))
140 )
141 return c_x[:],c_y[:],ierr
142
143 def sedov(
144 r,
145 plot = 'density',
146 time = 0.1,
147 gamma = 5./3.,
148 rhozero = 1.,
149 energy = 1.,
150 rmax = 1.):
151
152 pin = checkfmt(plot)
153 if (pin == 'density'):
154 iplot = 1
155 elif (pin == 'pressure'):
156 iplot = 2
157 elif (pin == 'uthermal'):
158 iplot = 3
159 elif (pin == 'kinetic_energy'):
160 iplot = 4
161 elif (pin == 'velocity'):
162 iplot = 5
163 else:
164 print("Splash Exact: Unrecognised plot type.")
165 print("Splash Exact: plot = density || pressure || uthermal || kinetic_energy || velocity ")
166 exit(1)
167
168 exactdll = prerun()
169 ierr = 0
170 c_r = (c_float*len(r))()
171 c_y = (c_float*len(r))()
172 c_r[:] = r[:]
173 exactdll.sedov_(
174 byref(c_int(iplot)),
175 byref(c_int(len(r))),
176 byref(c_float(time)),
177 byref(c_float(gamma)),
178 byref(c_float(rhozero)),
179 byref(c_float(energy)),
180 byref(c_float(rmax)),
181 byref(c_r),
182 byref(c_y),
183 byref(c_int(ierr))
184 )
185 return c_r[:],c_y[:],ierr
186
187 def polytrope(
188 r,
189 gamma = 5./3.,
190 polyk = 1.,
191 totmass = 1.):
192
193 exactdll = prerun()
194 ierr = 0
195 c_r = (c_float*len(r))()
196 c_y = (c_float*len(r))()
197 c_r[:] = r[:]
198 npartout = len(r)
199 nout = c_int(0)
200 exactdll.polytrope_(
201 byref(c_int(len(r))),
202 byref(c_float(gamma)),
203 byref(c_float(polyk)),
204 byref(c_float(totmass)),
205 byref(c_r),
206 byref(c_y),
207 byref(c_nout),
208 byref(c_int(ierr))
209 )
210 return c_r[:nout.value],c_y[:nout.value],ierr
211
212 def toystar1D(
213 x,
214 plot = 'density',
215 time = 1.,
216 gamma = 5./3.,
217 H0 = 1.,
218 A0 = 1.,
219 C0 = 1.,
220 sigma = 0.,
221 norder = -1):
222
223 pin = checkfmt(plot)
224 if (pin == 'density'):
225 iplot = 1
226 elif (pin == 'pressure'):
227 iplot = 2
228 elif (pin == 'uthermal'):
229 iplot = 3
230 elif (pin == 'velocity_x'):
231 iplot = 4
232 elif (pin == 'mag_field_y'):
233 iplot = 5
234 elif (pin == 'ac_plane'):
235 iplot = 7
236 else:
237 print("Splash Exact: Unrecognised plot type.")
238 print("Splash Exact: plot = density || pressure || uthermal || velocity_x || mag_field_y || ac_plane ")
239 exit(1)
240
241 exactdll = prerun()
242 ierr = 0
243 c_x = (c_float*len(x))()
244 c_y = (c_float*len(x))()
245 c_x[:] = x[:]
246 exactdll.toystar1d_(
247 byref(c_int(iplot)),
248 byref(c_int(len(x))),
249 byref(c_float(time)),
250 byref(c_float(gamma)),
251 byref(c_float(H0)),
252 byref(c_float(A0)),
253 byref(c_float(C0)),
254 byref(c_float(sigma)),
255 byref(c_int(norder)),
256 byref(c_x),
257 byref(c_y),
258 byref(c_int(ierr))
259 )
260 return c_x[:],c_y[:],ierr
261
262 def toystar2D(
263 x,
264 plot = 'density',
265 time = 1.,
266 gamma = 5./3.,
267 polyk = 1.,
268 totmass = 1.,
269 A0 = 1.,
270 H0 = 1.,
271 C0 = 1.,
272 jorder = -1,
273 morder = 0,
274 V11 = 0,
275 V22 = 0,
276 V12 = 0,
277 V21 = 0):
278
279 pin = checkfmt(plot)
280 if (pin == 'density'):
281 iplot = 1
282 elif (pin == 'pressure'):
283 iplot = 2
284 elif (pin == 'uthermal'):
285 iplot = 3
286 elif (pin == 'velocity_x'):
287 iplot = 4
288 elif (pin == 'velocity_y'):
289 iplot = 5
290 elif (pin == 'x_vs_y'):
291 iplot = 0
292 else:
293 print("Splash Exact: Unrecognised plot type.")
294 print("Splash Exact: plot = density || pressure || uthermal || velocity_x || velocity_y || x_vs_y ")
295 exit(1)
296
297 exactdll = prerun()
298 ierr = 0
299 c_x = (c_float*len(x))()
300 c_y = (c_float*len(x))()
301 c_x[:] = x[:]
302
303 exactdll.toystar2d_(
304 byref(c_int(iplot)),
305 byref(c_int(len(x))),
306 byref(c_float(time)),
307 byref(c_float(gamma)),
308 byref(c_float(polyk)),
309 byref(c_float(totmass)),
310 byref(c_float(A0)),
311 byref(c_float(H0)),
312 byref(c_float(C0)),
313 byref(c_int(jorder)),
314 byref(c_int(morder)),
315 byref(c_float(V11)),
316 byref(c_float(V22)),
317 byref(c_float(V12)),
318 byref(c_float(V21)),
319 byref(c_x),
320 byref(c_y),
321 byref(c_int(ierr))
322 )
323 return c_x[:],c_y[:],ierr
324
325 def gresho(
326 x,
327 plot = 'velocity_phi'):
328
329 pin = checkfmt(plot)
330 if (pin == 'velocity_phi'):
331 iplot = 1
332 elif (pin == 'pressure'):
333 iplot = 2
334 else:
335 print("Splash Exact: Unrecognised plot type.")
336 print("Splash Exact: plot = velocity_phi || pressure ")
337 exit(1)
338
339 exactdll = prerun()
340 ierr = 0
341 c_x = (c_float*len(x))()
342 c_y = (c_float*len(x))()
343 c_x[:] = x[:]
344
345 exactdll.gresho_(
346 byref(c_int(iplot)),
347 byref(c_int(len(x))),
348 byref(c_x),
349 byref(c_y),
350 byref(c_int(ierr))
351 )
352 return c_x[:],c_y[:],ierr
353
354 def mhdshock(
355 x,
356 plot = 'density',
357 solution = '7 jump',
358 time = 0.2,
359 gamma = 5./3.,
360 xmin = -1,
361 xmax = 1,
362 xshock = 0):
363
364 pin = checkfmt(plot)
365 if (pin == 'density'):
366 iplot = 1
367 elif (pin == 'pressure'):
368 iplot = 2
369 elif (pin == 'velocity_x'):
370 iplot = 3
371 elif (pin == 'velocity_y'):
372 iplot = 4
373 elif (pin == 'velocity_z'):
374 iplot = 5
375 elif (pin == 'mag_field_y'):
376 iplot = 6
377 elif (pin == 'mag_field_z'):
378 iplot = 7
379 elif (pin == 'uthermal'):
380 iplot = 8
381 elif (pin == 'Bxzero'):
382 iplot = 9
383 else:
384 print("Splash Exact: Unrecognised plot type.")
385 print("Splash Exact: plot = density || pressure || velocity_x || velocity_y || velocity_z || mag_field_y || mag_field_z || uthermal || Bxzero ")
386 exit(1)
387
388 ishk = 0
389 pin = checkfmt(solution)
390 if (pin == 'brio_wu'):
391 ishk = 1
392 elif (pin == 'fast_slow'):
393 ishk = 2
394 elif (pin == '7_jump'):
395 ishk = 3
396 elif (pin == 'isothermal'):
397 ishk = 4
398 elif (pin == 'rarefaction'):
399 ishk = 5
400 elif (pin == 'mach_25'):
401 ishk = 6
402 elif (pin == 'toth'):
403 ishk = 7
404 else:
405 print("Splash Exact: Unrecognised solution type.")
406 print("Splash Exact: solution = Brio/Wu || fast/slow || 7_jump || isothermal || rarefaction || Mach_25 || Toth ")
407 exit(1)
408
409 exactdll = prerun()
410 ierr = 0
411 c_x = (c_float*len(x))()
412 c_y = (c_float*len(x))()
413 c_x[:] = x[:]
414 c_nout = c_int(0)
415 exactdll.mhdshock_(
416 byref(c_int(iplot)),
417 byref(c_int(len(x))),
418 byref(c_int(ishk)),
419 byref(c_float(time)),
420 byref(c_float(gamma)),
421 byref(c_float(xmin)),
422 byref(c_float(xmax)),
423 byref(c_float(xshock)),
424 byref(c_x),
425 byref(c_y),
426 byref(c_nout),
427 byref(c_int(ierr))
428 )
429 return c_x[:c_nout.value],c_y[:c_nout.value],ierr
430
431 def rhoh(
432 x,
433 plot = 'density',
434 ndim = 3,
435 hfact = 1.2,
436 pmassval = 1.0):
437
438 pin = checkfmt(plot)
439 if (pin == 'h'):
440 iplot = 1
441 elif (pin == 'density'):
442 iplot = 2
443 else:
444 print("Splash Exact: Unrecognised plot type.")
445 print("Splash Exact: plot = h || density ")
446 exit(1)
447
448 exactdll = prerun()
449 ierr = 0
450 c_x = (c_float*len(x))()
451 c_y = (c_float*len(x))()
452 c_x[:] = x[:]
453
454 exactdll.rhoh_(
455 byref(c_int(iplot)),
456 byref(c_int(len(x))),
457 byref(c_int(ndim)),
458 byref(c_float(hfact)),
459 byref(c_float(pmassval)),
460 byref(c_x),
461 byref(c_y),
462 byref(c_int(ierr))
463 )
464 return c_x[:],c_y[:],ierr
465
466 def densityprofiles(
467 x,
468 plot = 'density',
469 profile = 'Plummer',
470 Msphere = [1.0,0.0],
471 rsoft = [1.0,0.1]):
472
473 pin = checkfmt(plot)
474 if (pin == 'density'):
475 iplot = 1
476 elif (pin == 'potential'):
477 iplot = 2
478 elif (pin == 'force'):
479 iplot = 3
480 else:
481 print("Splash Exact: Unrecognised plot type.")
482 print("Splash Exact: plot = density || potential || force ")
483 exit(1)
484
485 pin = checkfmt(profile)
486 if (pin == 'plummer'):
487 iprofile = 1
488 elif (pin == 'hernquist'):
489 iprofile = 2
490 else:
491 print("Splash Exact: Unrecognised plot type.")
492 print("Splash Exact: profile = Plummer || Hernquist ")
493 exit(1)
494
495 exactdll = prerun()
496 ierr = 0
497 c_x = (c_float*len(x))()
498 c_y = (c_float*len(x))()
499 c_x[:] = x[:]
500
501 exactdll.densityprofiles_(
502 byref(c_int(iplot)),
503 byref(c_int(len(x))),
504 byref(c_int(iprofile)),
505 byref(c_float(Msphere[0])),
506 byref(c_float(Msphere[1])),
507 byref(c_float(rsoft[0])),
508 byref(c_float(rsoft[1])),
509 byref(c_x),
510 byref(c_y),
511 byref(c_int(ierr))
512 )
513 return c_x[:],c_y[:],ierr
514
515 def torus(
516 x,
517 plot = 'density',
518 torus = 'default',
519 Mstar = 1.0,
520 Rtorus = 1.0,
521 polyk = 0.0764,
522 distortion = 1.1,
523 gamma = 5./3.):
524
525 pin = checkfmt(plot)
526 if (pin == 'density'):
527 iplot = 1
528 elif (pin == 'pressure'):
529 iplot = 2
530 elif (pin == 'uthermal'):
531 iplot = 3
532 elif (pin == 'Btheta'):
533 iplot = 4
534 elif (pin == 'Jphi_current'):
535 iplot = 5
536 else:
537 print("Splash Exact: Unrecognised plot type.")
538 print("Splash Exact: plot = density || pressure || uthermal || Btheta || Jphi_current")
539 exit(1)
540
541 itorus = 0
542 pin = checkfmt(torus)
543 if (pin == 'default'):
544 itorus = 1
545 elif (pin == 'tokamak'):
546 itorus = 2
547 else:
548 print("Splash Exact: Unrecognised torus type.")
549 print("Splash Exact: torus = Default || Tokamak ")
550 exit(1)
551
552 exactdll = prerun()
553 ierr = 0
554 c_x = (c_float*len(x))()
555 c_y = (c_float*len(x))()
556 c_x[:] = x[:]
557
558 exactdll.torus_(
559 byref(c_int(iplot)),
560 byref(c_int(len(x))),
561 byref(c_int(itorus)),
562 byref(c_float(Mstar)),
563 byref(c_float(Rtorus)),
564 byref(c_float(polyk)),
565 byref(c_float(distortion)),
566 byref(c_float(gamma)),
567 byref(c_x),
568 byref(c_y),
569 byref(c_int(ierr))
570 )
571 return c_x[:],c_y[:],ierr
572
573 def ringspread(
574 x,
575 plot = 'density',
576 time = 1.0,
577 Mdisk = 1.0,
578 Rdisk = 1.0,
579 viscnu = 1.e-3):
580
581 pin = checkfmt(plot)
582 if (pin == 'density'):
583 iplot = 1
584 else:
585 print("Splash Exact: Unrecognised plot type.")
586 print("Splash Exact: plot = density")
587 exit(1)
588
589 exactdll = prerun()
590 ierr = 0
591 c_x = (c_float*len(x))()
592 c_y = (c_float*len(x))()
593 c_x[:] = x[:]
594
595 exactdll.ringspread_(
596 byref(c_int(iplot)),
597 byref(c_int(len(x))),
598 byref(c_float(time)),
599 byref(c_float(Mdisk)),
600 byref(c_float(Rdisk)),
601 byref(c_float(viscnu)),
602 byref(c_x),
603 byref(c_y),
604 byref(c_int(ierr))
605 )
606 return c_x[:],c_y[:],ierr
607
608 def dustywave(
609 x,
610 plot = 'gas_density',
611 time = 1.0,
612 ampl = 1.0,
613 cs = 1.0,
614 Kdrag = 1.0,
615 lambdacoef = 1.0,
616 x0 = 1.0,
617 rhog0 = 1.0,
618 rhod0 = 1.0):
619
620 pin = checkfmt(plot)
621 if (pin == 'gas_velocity'):
622 iplot = 1
623 elif (pin == 'dust_velocity'):
624 iplot = 2
625 elif (pin == 'gas_density'):
626 iplot = 3
627 elif (pin == 'dust_density'):
628 iplot = 4
629 else:
630 print("Splash Exact: Unrecognised plot type `" + plot + "`")
631 print("Splash Exact: plot = gas_velocity || dust_velocity || gas_density || dust_density")
632 exit(1)
633
634 exactdll = prerun()
635 ierr = 0
636 c_x = (c_float*len(x))()
637 c_y = (c_float*len(x))()
638 c_x[:] = x[:]
639
640 exactdll.dustywave_(
641 byref(c_int(iplot)),
642 byref(c_int(len(x))),
643 byref(c_float(time)),
644 byref(c_float(ampl)),
645 byref(c_float(cs)),
646 byref(c_float(Kdrag)),
647 byref(c_float(lambdacoef)),
648 byref(c_float(x0)),
649 byref(c_float(rhog0)),
650 byref(c_float(rhod0)),
651 byref(c_x),
652 byref(c_y),
653 byref(c_int(ierr))
654 )
655 return c_x[:],c_y[:],ierr
656
657 def rochelobe(
658 x,
659 primatypos = [0.,0.],
660 secondarypos = [1.,0.],
661 primarymass = 1.,
662 secondarymass = 1.):
663
664 exactdll = prerun()
665 ierr = 0
666 c_x = (c_float*len(x))()
667 c_y = (c_float*len(x))()
668 c_x[:] = x[:]
669
670 exactdll.rochelobe_(
671 byref(c_int(len(x))),
672 byref(c_float(primatypos[0])),
673 byref(c_float(primatypos[1])),
674 byref(c_float(secondarypos[0])),
675 byref(c_float(secondarypos[0])),
676 byref(c_float(primarymass)),
677 byref(c_float(secondarymass)),
678 byref(c_x),
679 byref(c_y),
680 byref(c_int(ierr))
681 )
682 return c_x[:],c_y[:],ierr
683
684 def cshock(
685 x,
686 plot='density',
687 time=0.2,
688 gamma=5./3.,
689 machs = 50.,
690 macha = 5.,
691 xmin=-0.25,
692 xmax= 0.25,):
693
694 pin = checkfmt(plot)
695 if (pin == 'density'):
696 iplot = 1
697 elif (pin == 'mag_field_y'):
698 iplot = 2
699 elif (pin == 'velocity_x'):
700 iplot = 3
701 elif (pin == 'velocity_y'):
702 iplot = 4
703 elif (pin == 'mag_field_x'):
704 iplot = 5
705 else:
706 print("Splash Exact: Unrecognised plot type `" + plot + "`")
707 print("Splash Exact: plot = density || mag_field_x || mag_field_y || velocity_x || velocity_y")
708 exit(1)
709
710 exactdll = prerun()
711 ierr = 0
712 c_x = (c_float*len(x))()
713 c_y = (c_float*len(x))()
714 c_x[:] = x[:]
715
716 exactdll.cshock_(
717 byref(c_int(iplot)),
718 byref(c_int(len(x))),
719 byref(c_float(time)),
720 byref(c_float(gamma)),
721 byref(c_float(machs)),
722 byref(c_float(macha)),
723 byref(c_float(xmin)),
724 byref(c_float(xmax)),
725 byref(c_x),
726 byref(c_y),
727 byref(c_int(ierr))
728 )
729 return c_x[:],c_y[:],ierr
730
731 def check_spiral_params(i1,i2,j1,j2,nparams,nsolutions):
732 if (i1 > i2):
733 print("Splash Exact: Wrong Spiral Params. i1 > i2. Should define blocks [i1,i2,j1,j2,val].")
734 exit(1)
735 if (j1 > j2):
736 print("Splash Exact: Wrong Spiral Params. j1 > j2. Should define blocks [i1,i2,j1,j2,val].")
737 exit(1)
738 if (i2 >= nparams):
739 print("Splash Exact: Wrong Spiral Params. i1 > "+str(nparams)+". Should define blocks [i1,i2,j1,j2,val].")
740 exit(1)
741 if (j2 >= nsolutions):
742 print("Splash Exact: Wrong Spiral Params. i1 > "+str(nsolutions)+". Should define blocks [i1,i2,j1,j2,val].")
743 exit(1)
744
745 def planetdisc(
746 x,
747 plot='phi/r plane',
748 spiral='Ogilvie/Rafikov',
749 time=0.2,
750 HonR = 0.05,
751 rplanet = 1.,
752 q_index = 0.25,
753 narms = 1,
754 spiral_params=[[1,1,0,6,360]]):
755 # same as filling block i1 to i2, j1 to j2 with x
756 # spiral_params = 0.
757 # spiral_params(2,:) = 360.
758 pin = checkfmt(plot)
759 if (pin == 'phi_r_plane'):
760 iplot = 1
761 elif (pin == 'x_y_plane'):
762 iplot = 2
763 else:
764 print("Splash Exact: Unrecognised plot type `" + plot + "`")
765 print("Splash Exact: plot = phi-r plane || x-y plane")
766 exit(1)
767
768 ispiral = 0
769 pin = checkfmt(spiral)
770 if (pin == 'ogilvie_rafikov'):
771 ispiral = 1
772 elif (pin == 'spiral_arm_fitting'):
773 ispiral = 2
774 else:
775 print("Splash Exact: Unrecognised plot type `" + plot + "`")
776 print("Splash Exact: plot = Ogilvie/Rafikov || spiral_arm_fitting")
777 exit(1)
778
779 exactdll = prerun()
780 ierr = 0
781 c_x = (c_float*len(x))()
782 c_y = (c_float*len(x))()
783 c_x[:] = x[:]
784 nparams = 7
785 nsolutions = 10
786 c_params = (c_float*nparams*nsolutions)()
787 for e in spiral_params:
788 i1 = e[0]
789 i2 = e[1]
790 j1 = e[2]
791 j2 = e[3]
792 val = e[4]
793 check_spiral_params(i1,i2,j1,j2,nparams,nsolutions)
794 for i in range(i1,i2+1):
795 for j in range(j1,j2+1):
796 c_params[i][j] = val
797
798 exactdll.planetdisc_(
799 byref(c_int(iplot)),
800 byref(c_int(len(x))),
801 byref(c_int(ispiral)),
802 byref(c_float(time)),
803 byref(c_float(HonR)),
804 byref(c_float(rplanet)),
805 byref(c_float(q_index)),
806 byref(c_int(narms)),
807 byref(c_params),
808 byref(c_x),
809 byref(c_y),
810 byref(c_int(ierr))
811 )
812 return c_x[:],c_y[:],ierr
813
814 def bondi(
815 x,
816 plot = 'density',
817 time = 10,
818 gamma = 5./3.,
819 const1 = 8.,
820 const2 = 1.,
821 Mstar = 1,
822 relativistic = True,
823 geodesic_flow = False,
824 is_wind = True):
825
826 pin = checkfmt(plot)
827 if (pin == 'velocity_x'):
828 iplot = 1
829 elif (pin == 'uthermal'):
830 iplot = 2
831 elif (pin == 'density'):
832 iplot = 2
833 else:
834 print("Splash Exact: Unrecognised plot type `" + plot + "`")
835 print("Splash Exact: plot = velocity_x || uthermal || density")
836 exit(1)
837
838 exactdll = prerun()
839 ierr = 0
840 c_x = (c_float*len(x))()
841 c_y = (c_float*len(x))()
842 c_x[:] = x[:]
843
844 exactdll.bondi_(
845 byref(c_int(iplot)),
846 byref(c_int(len(x))),
847 byref(c_float(time)),
848 byref(c_float(gamma)),
849 byref(c_float(const1)),
850 byref(c_float(const2)),
851 byref(c_float(Mstar)),
852 byref(c_bool(relativistic)),
853 byref(c_bool(geodesic_flow)),
854 byref(c_bool(is_wind)),
855 byref(c_x),
856 byref(c_y),
857 byref(c_int(ierr))
858 )
859 return c_x[:],c_y[:],ierr