Hi Sean,

The problem comes from taking the “total_quantity” for density. This sums the values of “gas”,”density” for each cell in the box, but you don’t want the sum of the densities, but their (mass-weighted) average. The total mass divided by the total volume will give the correct values.

To get to a total mass of metals of a certain type, just create a mass field by multiplying “Metal_density_SNII” by cell volume, then sum that mass field. To get an average density, divide that mass field by the volume again.

Hope that helps!

Cheers,
Clayton

On Fri, Jun 4, 2021 at 9:06 PM Sean Larkin via yt-users <yt-users@python.org> wrote:
Hello All!

I am having some trouble understanding the interplay between a few gas fields, namely ('gas', 'density'), ('gas', 'cell_mass'), and ('gas', 'cell_volume').  Looking at the O/H ratios at various radii for some galaxies has lead me to some confusion in how to properly convert between these .

I am using a script like this to construct a sphere of a given radius (here 10% of the virial radius) and find the mass of the gas within it:

###BEGIN SCRIPT
import yt

ds = yt.load('/Volumes/My Passport for Mac/VELAhalos_4_1_2021/GEN6/VELA07_snap/10MpcBox_csf512_a0.500.d')

x = ds.quan(19.97536, 'Mpccm/h')
y = ds.quan(19.58991, 'Mpccm/h')
z = ds.quan(20.38296, 'Mpccm/h')

center = [x,y,z]

sp_10percent = ds.sphere(center, radius * 0.1)

gas_density, gas_volume, gas_mass = sp_10percent.quantities.total_quantity([('gas', 'density'), ('gas', 'cell_volume'), ('gas', 'cell_mass')])

##END SCRIPT

This script returns these values:

gas_density  = 11770623025851.596 Msun/kpc**3
gas_volume = 26575.843162683213 kpc**3
gas_mass = 15826330839.340445 Msun

Now, from what I understood, the gas_mass field is derived from the gas_density * gas_volume (from this page https://yt-project.org/doc/reference/field_list.html). However, doing that calculation returns a value around 10^16 Msun, not anywhere close to the 10^9 value returned by the cell_mass field. I am wondering the proper way to manually convert from the gas_density to the cell_mass field, and I am clearly missing something in my understanding. I would like to be able to do this outside of yt for convenience as the 'art', 'Metal_Density_SNII' field only returns a density, and not a mass, which I would like to study, so where do I look to find the proper conversion? Or is my understanding of one of the above fields lacking in some way?

Thank you for your time and convience!
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org
https://mail.python.org/mailman3/lists/yt-users.python.org/