Compute divergence of vector field using python
- by nyvltak
Is there a function that could be used for calculation of the divergence of the vectorial field? (in matlab http://www.mathworks.ch/help/techdoc/ref/divergence.html)
I would expect it exists in numpy/scipy but I can not find it using google :(.
#
I need to calculate div[A * grad(F)],
where
F = np.array([[1,2,3,4],[5,6,7,8]]) (2D numpy ndarray)
A = np.array([[1,2,3,4],[1,2,3,4]]) (2D numpy ndarray)
so grad(F) is a set of 2D ndarrays
#
I know, I can calculate divergence like this:
http://en.wikipedia.org/wiki/Divergence#Application_in_Cartesian_coordinates
but do not want to reinvent the wheel. (and also I expent there is some optimized function)