[yt-users] AMR grid creation in spherical coordinates

Andrea Negri negri.andre at gmail.com
Wed May 11 05:36:52 PDT 2016


Hi all,

I'm trying to build an AMR in yt in spherical coordinates. I was able
to it in the following code. But I have a couple of questions.

There is something I don't understand: except for the level 0 grid,
the right_edge arrays seems to be useless...
In addition, as you can notice the number of grids in theta direction
increased as a factor of 5. Is there a way to preserve the number of
grid in theta (and in phi) from level 0 to level 1?




import numpy as np
import yt

refine_by=5
top_grid_dim = [100,  10, 2]
n1=100
n2=10
n3=2

grid_data = [
    dict(left_edge = [0.0, 0.0, 0.0],
         right_edge = [1.0, np.pi, np.pi*2.],
         level = 0,
         dimensions = [n1, n2, n3]),
    dict(left_edge = [0., 0., 0.],
         right_edge = [0.5, np.pi, np.pi*2.],
         level = 1,
         dimensions = [n1, n2*refine_by, n3*refine_by]),
   ]


for g in grid_data:
    g["density"] = (np.random.random(g["dimensions"]), "g/cm**3")

ds = yt.load_amr_grids(grid_data, top_grid_dim ,
geometry='spherical', refine_by=refine_by, length_unit='kpc')

ds.print_stats()

yt.SlicePlot(ds, 'phi', 'density').save()
yt.SlicePlot(ds, 'theta', 'density').save()
yt.SlicePlot(ds, 'r', 'density').save()


More information about the yt-users mailing list