Hi Prateek and Nathan, thanks for your suggestion, I did accordingly, and seems the field is not add up properly. I have attached the error. At this point I would ask you to kindly take a look at my code too, i am new in python and I want to make sure I am not doing other things wrong along with it. I am trying to make slice plots of gravitational acceleration through z-axis from the FLASH plotfiles and make a folder with it. thanks in advance. Turhan On Fri, Jun 24, 2016 at 9:20 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
On Fri, Jun 24, 2016 at 6:40 AM, Prateek Gupta <prateekgidolia@gmail.com> wrote:
Hello Turhan,
I am not sure but I think this will work, you can try this...
*ds = yt.load("data_file_Name")*
*grad = ds.add_gradient_fields(("gas","gravitational_potential"))*
*grad *list will have a list of new field names which representing the 3 different components of the field and the magnitude of the gradient , e.g., "*gravitational_potential_gradient_x*" , " *gravitational_potential_gradient_y*" , " *gravitational_potential_gradient_z*" and " *gravitational_potential_gradient_magnitude*"
Now for getting the negative gradient of gravitational potential we can derive field as follows:
*####...x-component of negative of gradient of gravitational potential...* *def _GradientX(field, data)* * Gx = -1.0*data["gravitational_potential_gradient_x"]* * return Gx*
*yt.add_field("Gx", function=_GradientX, take_log=False, units="code length/ code time**2")*
*####...y-component of negative of gradient of gravitational potential...* *def _GradientY(field, data)* * Gy = -1.0*data["gravitational_potential_gradient_y"]* * return Gx* *yt.add_field("Gy", function=_GradientY, take_log=False, units="**code length/ code time**2**")*
*####...z-component of negative of gradient of gravitational potential...* *def _GradientZ(field, data)* * Gz = -1.0*data["gravitational_potential_gradient_z"]* * return Gz* *yt.add_field("Gz", function=_GradientZ, take_log=False, units="**code length/ code time**2**")*
Otherwise you can do this also,
*grad = -1.0*ds.add_gradient_fields(("gas","gravitational_potential"))*
This isn't quite right. The ds.add_gradient_fields function returns a set of field names, not a field object itself. If you want to add the negative signs to the field definition, you'll need to define some derived fields as Prateek suggested above.
I think this will work but this will also make the magnitude negative. But if you want to use only 3-components then this works and you can access it , e.g., *data["gravitational_potential_gradient_x"]* and similar for y and z component.
Please let me know if this work.
Regards Prateek Gupta
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org