1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Change contravariant tensor to covariant tensor in einsteinpy package

Discussão em 'Python' iniciado por Stack, Setembro 12, 2025.

  1. Stack

    Stack Membro Participativo

    Using einsteinpy package of Python, I am defining the electromagnetic tensor (or any other arbitrary tensor). While defining, I am defining it as 'uu' tensor using the BaseRelativityTensor class file. I want the 'll' version from this, ie. F_covariant from F_contravariant. But the package seems not to provide any .change_config() property, which EinsteinTensor (another class which defines (G^{\mu\nu})) does.

    FYI: I am using the 0.3.1 version of the package.

    So my question is, once F^{\mu\nu} has been defined as a BaseRelativityTensor, how to get (F_{\mu\nu}) from F^{\mu\nu}? My code is given below:

    from IPython.display import display
    import sympy as sp
    from einsteinpy.symbolic import BaseRelativityTensor, MetricTensor

    Ex, Ey, Ez, Bx, By, Bz, c = sp.symbols("E_x E_y E_z B_x B_y B_z c")
    t, x, y, z = sp.symbols("t x y z")

    # Define Minkowski metric (signature -,+,+,+)
    eta = sp.Array([
    [-1, 0, 0, 0],
    [ 0, 1, 0, 0],
    [ 0, 0, 1, 0],
    [ 0, 0, 0, 1]
    ])
    syms = (t, x, y, z)
    metric = MetricTensor(eta, syms)
    g = metric.tensor()

    # Define the F array for F^{mu,nu}
    F_contra_array = sp.Array([
    [0, Ex/c, Ey/c, Ez/c],
    [-Ex/c, 0, Bz, -By],
    [-Ey/c, -Bz, 0, Bx],
    [-Ez/c, By, -Bx, 0]
    ])

    # Define contravariant tensor F^{mu nu}
    F_contra = BaseRelativityTensor(F_contra_array, syms, "uu",
    parent_metric=metric)
    print("F^{mu nu} =")
    display(F_contra.tensor())

    Continue reading...

Compartilhe esta Página