[yt-users] DM density profiles

Matthew Turk matthewturk at gmail.com
Tue Jan 19 12:25:42 PST 2016


Hi Junhwan,

On Tue, Jan 19, 2016 at 12:43 PM, Junhwan Choi (최준환) <choi.junhwan at gmail.com
> wrote:

> Hi yt user,
>
> I make a simple DM and gas density profile for my enzo simulation with
> following script:
> ======================
> import matplotlib as matplotlib
> matplotlib.use('Agg')
> import yt
> import yt.units as units
> import numpy as np
> import matplotlib.pyplot as plt
>
> def _radiuspc(field, data):
>     return data[('radius')].in_units('pc')
> yt.add_field('radiuspc', function=_radiuspc, units="pc")
>
> Nbin= 100
> rmax = 4000
> index = 60
> ds = yt.load("../DD%04d/DD%04d" % (index,index))
> ds.index
> ad= ds.all_data()
>
> center = ds.find_max(("gas", "density"))[1]
> my_sphere = ds.sphere(center, rmax*units.pc)
>
> rmin = max([1.0e-4,2.0*ds.index.get_smallest_dx().in_units('pc')])
> profile = yt.Profile1D(my_sphere, 'radiuspc', Nbin, x_min=rmin,
> x_max=rmax, x_log=True, weight_field='cell_volume')
> profile.add_fields(('gas','density'))
> profile.add_fields(('gas','dark_matter_density'))
> profile.add_fields(('deposit','all_density'))
>
> plt.plot(np.log10(profile.x), np.log10(profile[('gas','density')]),
> label="('gas','density')", linestyle="-", color='g')
> plt.plot(np.log10(profile.x),
> np.log10(profile[('gas','dark_matter_density')]),
> label="('gas','dark_matter_density')", linestyle="-", color='r')
> plt.plot(np.log10(profile.x),
> np.log10(profile[('deposit','all_density')]),
> label="('deposit','all_density')", linestyle="-", color='b')
>
> plt.legend(loc=0,prop={'size':9})
> plt.savefig('DMTest')
> ======================
>
> The only particle in the simulation is the dark matter so that
> profile[('gas','dark_matter_density')] and
> profile[('deposit','all_density')] should be same.
> However, as shown in the attached figure, they are very different.
> I would like to ask a few questions regarding to this plot.
> 1) Why do profile[('gas','dark_matter_density')] and

profile[('deposit','all_density')] show significant difference?
>

I can't say for sure, but note that in many areas they do agree.  They're
generated differently; one comes from Enzo, one from yt.  Where they
disagree, I would suspect there is lacking data.


> 2) What limit the minimum r in profile[('deposit','all_density')]?
>

Probably the grid size, or the cell size at which there're particles.


> 3) If I would like to make total density profile, what do I do?
>     I think that profile[('deposit','all_density')] is more liable result.
>     Can I add data[('gas','density')] and
> data[('deposit','all_density')], two different field types, in the
> derived field?
>

Yes, those two can be added.


>
> Thank you in advance,
> Junhwan Choi
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160119/ac142031/attachment.htm>
-------------- next part --------------
_______________________________________________
yt-users mailing list
yt-users at lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org


More information about the yt-users mailing list