使用python计算向量场的散度 [英] Compute divergence of vector field using python

查看:48
本文介绍了使用python计算向量场的散度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可以用来计算矢量场散度的函数?(在 matlab 中)我希望它存在于 numpy/scipy 中,但我找不到它谷歌.

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)

so grad(F) 是二维 ndarrays

我知道我可以像this那样计算散度,但不想重新发明轮子.(我也希望有更优化的东西)有人有什么建议吗?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆