PLUTO
Sph_disk.py
Go to the documentation of this file.
1 import os
2 import sys
3 from numpy import *
4 from matplotlib.pyplot import *
5 import pyPLUTO as pp
6 
7 plutodir = os.environ['PLUTO_DIR']
8 wdir = plutodir+'/Test_Problems/MHD/FARGO/Spherical_Disk/'
9 nlinf = pp.nlast_info(w_dir=wdir,datatype='vtk')
10 
11 D = pp.pload(nlinf['nlast'],w_dir=wdir,datatype='vtk') # Loading the data into a pload object D.
12 
13 I = pp.Image()
14 
15 f1 = figure(figsize=[15,6],num=1)
16 ax1=f1.add_subplot(122)
17 I.pltSphData(D,w_dir=wdir,datatype='vtk',plvar='bx1',logvar=False,rphi=False,x3cut=96)
18 colorbar(orientation='horizontal')
19 ax1.set_xlabel(r'Radius')
20 ax1.set_ylabel(r'Height')
21 ax1.set_title(r'Magnetic field $B_{\rm x}$')
22 
23 ax2=f1.add_subplot(121)
24 I.pltSphData(D,w_dir=wdir,datatype='vtk',plvar='rho',logvar=True,rphi=True,x2cut=24)
25 colorbar(orientation='vertical')
26 ax2.set_xlabel(r'x')
27 ax2.set_ylabel(r'y')
28 ax2.set_title(r'Log $\rho$')
29 
30 # Code to plot arrows. --> Spacing between the arrow can be adjusted by
31 # modifying the newdims tuple of conrid function.
32 
33 T = pp.Tools()
34 newdims = 2*(20,)
35 R,Z,SphData = I.getSphData(D,w_dir=wdir,datatype='vtk',rphi=True,x2cut=24)
36 xcong = T.congrid(R,newdims,method='linear')
37 ycong = T.congrid(Z,newdims,method='linear')
38 vel1 = SphData['v1c']
39 vel2 = SphData['v3c']
40 
41 xveccong = T.congrid(vel1,newdims,method='linear')
42 yveccong = T.congrid(vel2,newdims,method='linear')
43 normVp = sqrt(xveccong**2 + yveccong**2)
44 xveccong = xveccong/normVp
45 yveccong = yveccong/normVp
46 ax2.quiver(xcong, ycong, xveccong, yveccong,color='w')
47 
48 show()