Hello All,
I am doing some work using the yt.create_profile function, and it seems to be returning incorrect results, but that may be based just me misunderstanding something. I am currently working on collecting the dark matter profile within the virial radius of halos in an ART simulation, and have been using this create_profile function for a while. It was pointed out to me that two different profiles I created (one linearly spaced, and one logarithmacilly spaced seemed to disagree on the total mass in a given sphere. Upon looking into this I noticed that there appears to be a drastic falloff in mass for the inner most profiles which does not appear physical. Here is a script that shows the issue:
import yt
import numpy as np
ds.quan(float(19.97536), 'Mpccm/h') center = [ds.quan(19.97536, 'Mpccm/h'), ds.quan(19.58991, 'Mpccm/h'), ds.quan(20.38296, 'Mpccm/h')]
rvir = ds.quan(185.12684881603383, 'kpc')
ds = yt.load('/Volumes/My Passport for Mac/VELAhalos_4_1_2021/GEN6/VELA07_snap/10MpcBox_csf512_a0.500.d')
sp = ds.sphere(center, rvir)
#space = np.logspace(-2,0,30) radius_bins = ds.arr(np.logspace(-2, 0, 30)*float(rvir), 'kpc') #print(radius_bins)
#create the profile rp_darkmatter = yt.create_profile(sp, ('darkmatter', 'particle_radius'), [('darkmatter', 'particle_mass')], accumulation = True, units = {('darkmatter', 'particle_radius'): 'kpc', ('darkmatter', 'particle_mass'): 'Msun'}, weight_field=None, override_bins={('darkmatter', 'particle_radius'): radius_bins})
#now just find the mass within the smallest sphere to compare sp = ds.sphere(center, (1.85126849, 'kpc')) darkmatter_mass_rvir= sp.quantities.total_quantity([('darkmatter', 'particle_mass')])
Here is the outputs for the profile:
print(rp_darkmatter.x_bins) print(rp_darkmatter[('darkmatter', 'particle_mass')])
[ 1.85126849 2.16987605 2.5433167 2.98102735 3.49406901 4.09540631 4.80023514 5.62636664 6.59467727 7.72963638 9.05992455 10.61915839 12.44673994 14.58885248 17.09962751 20.0425127 23.49187518 27.53488087 32.27369713 37.82807456 44.3383731 51.96910898 60.91311203 71.39639856 83.68388279 98.08607129 114.96690951 134.75297878 157.94427603 185.12684882] kpc [1.71640907e+09 4.08670014e+09 7.29731648e+09 1.15396909e+10 1.70891641e+10 2.43093919e+10 3.36631560e+10 4.56267933e+10 6.02872054e+10 7.78791509e+10 9.85060803e+10 1.22442170e+11 1.49759934e+11 1.80141955e+11 2.13532847e+11 2.51746816e+11 2.95421277e+11 3.46319791e+11 4.05501975e+11 4.73278346e+11 5.52642140e+11 6.41302652e+11 7.43654270e+11 8.45108184e+11 9.51028253e+11 1.06624695e+12 1.17616790e+12 1.29792900e+12 1.43690732e+12] Msun
And here is the result for the two inner most spheres centered at the same center: 3597806296.1175537 Msun - 1.85126849 kpc 4420085989.534953 Msun - 2.16987605 kpc
This is not the same mass as found by any of the inner spheres of the profile, and contains over twice as big as the inner most sphere. I have tried this for several radii, and it appears to always be off by a bit, but the difference gets smaller as the radii gets larger, as shown by a sphere for the total virial radius:
1440505125868.4753 Msun - 185.12684882 kpc
Vs the total mass enclosed in the profile of 1.43690732e+12 (only about a 1% difference).
I am wondering if there might be something wrong how I am using this, or if there is an issue with the profile maker. I had asked about profile before, and was told to use the rp_darkmatter.x, but rp_darkmatter.x_bins field for the radii. Has something been changed in this function? (Note, I have tried looking at the rp_darkmatter.x radii, but those also do not agree with a ds.sphere of the same radii) (PSS: This is using yt 3.5.1, as I tried to update to 3.6.1 and ran into an error importing yt)