<div dir="ltr">Hello Turhan,<div><br><div>I am not sure but I think this will work, you can try this...</div><div><br></div><div><br></div><div><b>ds = yt.load("data_file_Name")</b></div><div><b>grad = ds.add_gradient_fields(("gas","gravitational_potential"))<br></b></div><div><br></div><div><b>grad </b>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., "<i>gravitational_potential_gradient_x</i>" , "<i>gravitational_potential_gradient_y</i>" , "<i>gravitational_potential_gradient_z</i>" and "<i>gravitational_potential_gradient_magnitude</i>"</div><div><br></div><div>Now for getting the negative gradient of gravitational potential we can derive field as follows:</div><div><br></div><div><br></div><div><b>####...x-component of negative of gradient of gravitational potential...</b></div><div><b>def _GradientX(field, data)</b></div><div><b>     Gx = -1.0*data["gravitational_potential_gradient_x"]</b></div><div><b>     return Gx</b></div><div><b>yt.add_field("Gx", function=_GradientX, take_log=False, units="code length/ code time**2")<br></b></div></div><div><b><br></b></div><div><div><b>####...y-component of negative of gradient of gravitational potential...</b></div><div><b>def _GradientY(field, data)</b></div><div><b>     Gy = -1.0*data["gravitational_potential_gradient_y"]</b></div><div><b>     return Gx</b></div><div><b>yt.add_field("Gy", function=_GradientY, take_log=False, units="</b><b>code length/ code time**2</b><b>")</b></div></div><div><b><br></b></div><div><div><b>####...z-component of negative of gradient of gravitational potential...</b></div><div><b>def _GradientZ(field, data)</b></div><div><b>     Gz = -1.0*data["gravitational_potential_gradient_z"]</b></div><div><b>     return Gz</b></div><div><b>yt.add_field("Gz", function=_GradientZ, take_log=False, units="</b><b>code length/ code time**2</b><b>")</b></div></div><div><b><br></b></div><div><br></div><div><br></div><div>Otherwise you can do this also, </div><div><b>grad = -1.0*ds.add_gradient_fields(("gas","gravitational_potential"))<br></b></div><div><br></div><div>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., <b>data["gravitational_potential_gradient_x"]</b> and similar for y and z component.</div><div><br></div><div><br></div><div><br></div><div>Please let me know if this work.</div><div><br></div><div><br></div><div><br></div><div>Regards</div><div>Prateek Gupta</div></div>