如何在GraviPy上指定张量,而不是让它们成为任意函数

2024-06-16 12:32:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在GraviPy包上定义一个张量,而不让它的组件成为任意函数

这是tutorial in docs,但我找到张量定义的唯一方法,而不是一般形式,是这个,我真的不明白

def S_new_method(idxs): # definition
    component = (V.covariantD(idxs[0], idxs[1], idxs[2])
                 - V.covariantD(idxs[0], idxs[2], idxs[1])).simplify()
    S.components.update({idxs: component}) # memoization
    return component
S._compute_covariant_component = S_new_method
# _compute_covariant_component method was overriden

例如:我想设置张量:

U_i=2*x[i]

或者更复杂的事情


Tags: 方法函数indocsnew定义组件tutorial