-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncontracted indices error when summing two contracted objects #121
Comments
I think this is mostly a problem of misunderstanding how expressions are parsed in Julia. A line break typically indicates the end of an expression, unless the parser detects that the expression does not make sense, in which case it will try to add the second line and ignore the line break. So if you had written @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 This works fine. But your input is equivalent to @tensor begin
Riemann[ρ,σ,μ,ν] := g_inverse[ρ,f]*(g_∂[f,μ,λ] + g_∂[f,λ,μ] - g_∂[μ,λ,f])*g_inverse[λ,h]*(g_∂[h,ν,σ] + g_∂[h,σ,ν] - g_∂[ν,σ,h])
end and @tensor begin
-g_inverse[ρ,i]*(g_∂[i,ν,λ] + g_∂[i,λ,ν] - g_∂[ν,λ,i])*g_inverse[λ,k]*(g_∂[k,μ,σ] + g_∂[k,σ,μ] - g_∂[μ,σ,k])
end For this second case, TensorOperations will try to evaluate to a scalar (but of course fails), which would then be the return value of this block. |
Yes you are right! Sorry I am a new Julia-er so didn't realise this is how it worked. Thanks for your help and apologies for the spam issue! |
No problem, glad I could help out. You've got me worried for a second too, before I noticed the problem. Also, the error messages of the |
MWE:
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.is ok ✅ , as is
The summation of these two scalar quantities then seems to throw the error?
Any guidance appreciated 🙏
The text was updated successfully, but these errors were encountered: