Because yt provides you with an low-cost entry-point for examining both particle and baryon data, it can be used for very quickly-written analysis tasks. To that end, some of the simplest ones are just looking at the distribution of mass in a given simulation.
The first, most basic thing to try is to sum up all the mass in a given region. Here we simply sum up over the entire domain. (cookbook_mass_sum.py)
1 2 3 4 5 6 7 8 9 10 11 12 | from yt.mods import *
pf = get_pf() # last argument on the command line gets turned into an EnzoStaticOutput
sp = pf.h.sphere([0.5,0.5,0.5], 1.0) # Everything, no pre-loading of fields
baryon_mass = sp["CellMassMsun"].sum()
dm = sphere["creation_time"] < 0
dm_mass = sphere["ParticleMassMsun"][dm].sum()
star_mass = sphere["ParticleMassMsun"][~dm].sum()
print "Total mass in grids in %s is %0.5e (gas = %0.5e / dm = %0.5e / star = %0.5e)" % \
(pf, baryon_mass + dm_mass + star_mass, baryon_mass, dm_mass, star_mass)
|
With the inclusion of HOP in the code, we can now identify halos and use those as inputs into our calculations of things like the total mass in a region. For instance, one can iterate over a set of HOP-centers and examine (as above) the mass as divided into stars, dark matter, and baryons. (cookbook_hop_mass_sum.py)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | from yt.mods import *
from yt.lagos import hop
pf = get_pf() # last argument on the command line gets turned into an EnzoStaticOutput
full_sphere = pf.h.sphere([0.5,0.5,0.5], 1.0) # Everything, no pre-loading of fields
hop_results = hop.HopList(full_sphere, 80.0) # threshold = 80
def get_mass_results(hop_group):
sphere = hop_group.get_sphere()
baryon_mass = sphere["CellMassMsun"].sum()
dm = sphere["creation_time"] < 0
dm_mass = sphere["ParticleMassMsun"][dm].sum()
star_mass = sphere["ParticleMassMsun"][~dm].sum()
return "Total mass in HOP group %s is %0.5e (gas = %0.5e / dm = %0.5e / star = %0.5e)" % \
(hop_group.id, baryon_mass + dm_mass + star_mass, baryon_mass, dm_mass, star_mass)
s = [get_mass_results(g) for g in hop_results]
print "\n".join(s)
|