예제 #1
0
def extract_DensVelVort(fil,args,vars):
    lev=0
    if args.ytVersion2: 
       ds=load(fil)
       lbox= float(ds.domain_width[0])
       cube= ds.h.covering_grid(level=lev,left_edge=ds.domain_left_edge,
                          dims=ds.domain_dimensions) 
    else:
        ds=yt.load(fil)
        lbox= float(ds.domain_width[0])
        cube= ds.covering_grid(level=lev,left_edge=ds.domain_left_edge,
                          dims=ds.domain_dimensions)
    print "gathering 3d data arrays"
    #3D arrays
    rho_x = np.array(cube["density"])
    vx = np.array(cube["X-momentum"])/rho_x
    vy = np.array(cube["Y-momentum"])/rho_x
    vz = np.array(cube["Z-momentum"])/rho_x
    print "3d arrays extracted, now calculating vorticity and single numbers like 3D Mach"
    rho_inf= rho_x.flatten().mean()
    (vmag_x,Mach_3D)= getVrms_weighted3DVrms(vx,vy,vz,rho_x,args)
    wmag_x= Sim_curl.getCurl(vx,vy,vz,  ds) #3D array
    del vx,vy,vz,cube
    #store variables
    vars.rho.append(rho_x)
    vars.vmag.append(vmag_x)
    vars.wmag.append(wmag_x)
    vars.basename.append(ds.basename)
    vars.lbox.append(lbox)
    vars.mach3d.append(Mach_3D)
    del rho_x,vmag_x,wmag_x
예제 #2
0
#3D arrays
rho_x = np.array(cube["density"])
vx = np.array(cube["X-momentum"])/rho_x
vy = np.array(cube["Y-momentum"])/rho_x
vz = np.array(cube["Z-momentum"])/rho_x
if args.hasBfield:
    bx = np.array(cube["X-magnfield"])*(4.*np.pi)**0.5
    by = np.array(cube["Y-magnfield"])*(4.*np.pi)**0.5
    bz = np.array(cube["Z-magnfield"])*(4.*np.pi)**0.5
    Bmag= np.sqrt(bx**2+by**2+bz**2)
    beta_x= 8*np.pi*rho_x*args.cs**2/Bmag**2
    del bx,by,bz,Bmag
print "3d arrays extracted, now calculating vorticity and single numbers like 3D Mach"
rho_inf= rho_x.flatten().mean()
(vmag_x,Mach_3D)= getVrms_weighted3DVrms(vx,vy,vz,rho_x,args)
(wmag_x,div_x)= Sim_curl.getCurl(vx,vy,vz,  ds) #3D array
fsol= get_fsol(vx,vy,vz) 
del vx,vy,vz,cube
#plot projection plots following federrath 2010
#proj=[]
#proj.append( np.log10(np.sum(rho_x,axis=2)) )
#proj.append( np.log10(np.sum(div_x,axis=2)) )
#proj.append( np.sum(wmag_x,axis=2)/100. )
#fig = plt.figure()
#plt.subplots_adjust(hspace=0.1)
#cticks= [[-2,-1,0,1],[1,2,3],[-1,0,1]]
#cmaps=['Blues','hot','rainbow']
#labs=[r'column density $log_{10}\Sigma$',r'proj. vorticity $log_{10}|\nabla x v|$',r'proj. divergence $\nabla v [10^2]$']
#for i in [0,1,2]:
#    a=fig.add_subplot(3,1,i+1)
#    imgplot = plt.imshow(proj[i])
예제 #3
0
# curl
lev = 0
if args.ytVersion2:
    ds = load(args.f_hdf5)
    lbox = float(ds.domain_width[0])
    cube = ds.h.covering_grid(level=lev, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)
else:
    ds = yt.load(args.f_hdf5)
    lbox = float(ds.domain_width[0])
    cube = ds.covering_grid(level=lev, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)
# 3D arrays
rho_x = np.array(cube["density"])
vx = np.array(cube["X-momentum"]) / rho_x
vy = np.array(cube["Y-momentum"]) / rho_x
vz = np.array(cube["Z-momentum"]) / rho_x
wmag_x = Sim_curl.getCurl(vx, vy, vz, ds)  # 3D array
print "shapes of vx,wmag= ", vx.shape, wmag_x.shape
vrms2_x = vx ** 2 + vy ** 2 + vz ** 2
# free memory don't need anymore
del vx, vy, vz, cube
# single number paramaters
vrms2_MassWt = np.average(vrms2_x.flatten(), weights=rho_x.flatten())
Mach_3D = vrms2_MassWt ** 0.5 / args.cs
rho_inf = rho_x.flatten().mean()

# have data to plot krumholz 2006 Fig. 6
name = "fig6_K06_" + ds.basename[5:9] + ".png"
PlotFig6(name, np.sqrt(vrms2_x), Mach_3D, args)
name = "fig7_K06_" + ds.basename[5:9] + ".png"
PlotFig7(name, wmag_x, lbox, Mach_3D, args)
med_u = np.median(np.sqrt(vrms2_x.flatten())) / Mach_3D / args.cs