Compute divergence of vector field using python

前端 未结 10 2671
甜味超标
甜味超标 2020-12-03 21:58

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 us

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 22:30

    import numpy as np
    
    def divergence(field):
        "return the divergence of a n-D field"
        return np.sum(np.gradient(field),axis=0)
    

提交回复
热议问题