Skip to content

Uncontracted indices error when summing two contracted objects #121

@tomkimpson

Description

@tomkimpson

MWE:

g_inverse = zeros(Float64,4,4)     # 2 indices
g_∂ = zeros(Float64,4,4,4)         # 3 indicies

@tensor begin
Riemann[ρ,σ,μ,ν] := 
g_inverse[ρ,f]*(g_∂[f,μ,λ] + g_∂[f,λ,μ] - g_∂[μ,λ,f])*g_inverse[λ,h]*(g_∂[h,ν,σ] + g_∂[h,σ,ν] - g_∂[ν,σ,h])
-g_inverse[ρ,i]*(g_∂[i,ν,λ] + g_∂[i,λ,ν] - g_∂[ν,λ,i])*g_inverse[λ,k]*(g_∂[k,μ,σ] + g_∂[k,σ,μ] - g_∂[μ,σ,k])
                                
end

throws an error that it cannot be evaluated to a scalar due to uncontracted indices.

Analytically, the indices contract correctly. Additionally each of the two lines within the @tensor constructor work separately, i.e.

@tensor begin
Riemann[ρ,σ,μ,ν] := 
g_inverse[ρ,f]*(g_∂[f,μ,λ] + g_∂[f,λ,μ] - g_∂[μ,λ,f])*g_inverse[λ,h]*(g_∂[h,ν,σ] + g_∂[h,σ,ν] - g_∂[ν,σ,h])                                
end

is ok ✅ , as is

@tensor begin
Riemann[ρ,σ,μ,ν] := 
-g_inverse[ρ,i]*(g_∂[i,ν,λ] + g_∂[i,λ,ν] - g_∂[ν,λ,i])*g_inverse[λ,k]*(g_∂[k,μ,σ] + g_∂[k,σ,μ] - g_∂[μ,σ,k])                              
end

The summation of these two scalar quantities then seems to throw the error?

Any guidance appreciated 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions