使用python计算矢量场的散度 [英] Compute divergence of vector field using python
问题描述
是否存在一个可用于计算矢量场散度的函数? (在 matlab 中)我希望它存在于numpy/scipy中,但我无法使用来找到它Google.
Is there a function that could be used for calculation of the divergence of the vectorial field? (in matlab) I would expect it exists in numpy/scipy but I can not find it using Google.
我需要计算div[A * grad(F)]
,其中
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)
所以grad(F)
是2D ndarray
s
我知道我可以像此那样计算出差异,但是不想重新发明轮子. (我还希望得到一些更优化的东西)有人建议吗?
I know I can calculate divergence like this but do not want to reinvent the wheel. (I would also expect something more optimized) Does anyone have suggestions?
推荐答案
只是给每个阅读以下内容的人一个提示:
Just a hint for everybody reading that:
上面的函数不计算矢量场的散度.他们对标量场A的导数求和:
the functions above do not compute the divergence of a vector field. they sum the derivatives of a scalar field A:
结果= dA/dx + dA/dy
与矢量场(带有三维示例)相反:
in contrast to a vector field (with three dimensional example):
结果= dAi/dxi总和= dAx/dx + dAy/dy + dAz/dz
全民投票!从数学上讲,这完全是错误的.
Vote down for all! It is mathematically simply wrong.
干杯!
这篇关于使用python计算矢量场的散度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!