yt.data_objects.construction_data_containers.YTCoveringGridBase.calculate_isocontour_flux

YTCoveringGridBase.calculate_isocontour_flux(field, value, field_x, field_y, field_z, fluxing_field=None)

This identifies isocontours on a cell-by-cell basis, with no consideration of global connectedness, and calculates the flux over those contours.

This function will conduct marching cubes on all the cells in a given data container (grid-by-grid), and then for each identified triangular segment of an isocontour in a given cell, calculate the gradient (i.e., normal) in the isocontoured field, interpolate the local value of the “fluxing” field, the area of the triangle, and then return:

area * local_flux_value * (n dot v)

Where area, local_value, and the vector v are interpolated at the barycenter (weighted by the vertex values) of the triangle. Note that this specifically allows for the field fluxing across the surface to be different from the field being contoured. If the fluxing_field is not specified, it is assumed to be 1.0 everywhere, and the raw flux with no local-weighting is returned.

Additionally, the returned flux is defined as flux into the surface, not flux out of the surface.

Parameters:

field : string

Any field that can be obtained in a data object. This is the field which will be isocontoured and used as the “local_value” in the flux equation.

value : float

The value at which the isocontour should be calculated.

field_x : string

The x-component field

field_y : string

The y-component field

field_z : string

The z-component field

fluxing_field : string, optional

The field whose passage over the surface is of interest. If not specified, assumed to be 1.0 everywhere.

Returns:

flux : float

The summed flux. Note that it is not currently scaled; this is simply the code-unit area times the fields.

References

[R3]Marching Cubes: http://en.wikipedia.org/wiki/Marching_cubes

Examples

This will create a data object, find a nice value in the center, and calculate the metal flux over it.

>>> dd = ds.all_data()
>>> rho = dd.quantities["WeightedAverageQuantity"](
...     "Density", weight="CellMassMsun")
>>> flux = dd.calculate_isocontour_flux("Density", rho,
...     "velocity_x", "velocity_y", "velocity_z", "Metal_Density")