[yt-users] Inspecting gradient of a field at boundary
tazkera haque
h.tazkera at gmail.com
Thu May 18 08:15:04 PDT 2017
Hi people,
I am trying to define curl of a vector field in yt, but first I needed to
see if correct derivatives are taken at the boundary. I am starting with a
mock data set and followed yt tutorial:
import yt
from yt import YTArray
import numpy as np
posx = np.linspace(-1.0,1.0,12)
posy = np.linspace(-1.0,1.0,12)
posz = np.linspace(-1.0,1.0,12)
X, Y, Z = np.meshgrid(posx, posy, posz, indexing='ij') # From gradient
output, yt seems to use ij indexing
psi = X
data_dict = {"psi":(psi,'kg/cm**3'),
"number_of_particles":12,
"particle_position_x":(posx, 'kg/cm**3'),
"particle_position_y":(posy, 'kg/cm**3'),
"particle_position_z":(posz, 'kg/cm**3')}
bbox = np.array([[-1.0, 1.0], [-1.0, 1.0], [-1.0, 1.0]])
y = yt.load_uniform_grid(data_dict,domain_dimensions=(12,12,12),bbox=bbox)
grad_fields = y.add_gradient_fields(("stream","psi"))
ad = y.all_data()
print( ad["psi_gradient_x"] )
print( ad["psi_gradient_y"] )
print( ad["psi_gradient_z"] )
Output:
yt : [INFO ] 2017-05-17 19:40:16,410 Parameters: current_time
= 0.0
yt : [INFO ] 2017-05-17 19:40:16,410 Parameters: domain_dimensions
= [12 12 12]
yt : [INFO ] 2017-05-17 19:40:16,411 Parameters: domain_left_edge
= [-1. -1. -1.]
yt : [INFO ] 2017-05-17 19:40:16,411 Parameters: domain_right_edge
= [ 1. 1. 1.]
yt : [INFO ] 2017-05-17 19:40:16,412 Parameters:
cosmological_simulation = 0.0
[-5.45454545 -5.45454545 -5.45454545 ..., -5.45454545 -5.45454545
-5.45454545] kg/cm**4
[ 0. 0. 0. ..., 0. 0. 0.] kg/cm**4
[ 0. 0. 0. ..., 0. 0. 0.] kg/cm**4
Now my question is, since psi(x,y,z) = x, the gradient should be
(1,0,0)...and it is everywhere except the boundaries of the box. Can you
please explain to me what is going wrong here? I don't
think YT is interpreting the bbox and grid points as I am.
Best
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170518/0d21b7bd/attachment.htm>
More information about the yt-users
mailing list