-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
Dear Prof. Barak Shoshany,
I receive an error when trying to contract tensors B and C to create scalar A. Here is the code
import OGRePy as T
OGREPY_DISABLE_WELCOME = True
from OGRePy.abc import x, y, z
Cartesian = T.Coordinates(x, y, z)
Cartesian.show()
Eucledian = T.Metric(
coords=Cartesian,
components=T.diag(1, 1, 1)
)
Fvx = T.func("F_v_x")(x, y, z)
Fvy = T.func("F_v_y")(x, y, z)
Fvz = T.func("F_v_z")(x, y, z)
Fv = T.Tensor(
metric=Eucledian,
coords=Cartesian,
indices=(1,),
components=T.s.Array([Fvx,Fvy,Fvz]),
symbol="F_v"
)
Fv.show()
Gvx = T.func("G_v_x")(x, y, z)
Gvy = T.func("G_v_y")(x, y, z)
Gvz = T.func("G_v_z")(x, y, z)
Gv = T.Tensor(
metric=Eucledian,
coords=Cartesian,
indices=(1,),
components=T.s.Array([Gvx,Gvy,Gvz]),
symbol="G_v"
)
Gv.show()
eps = T.Tensor(
metric=Eucledian,
coords=Cartesian,
indices=(1,1,1),
components=T.s.Array([[ [0, 0, 0],
[0, 0, 1],
[0, -1, 0] ],
[ [0, 0, -1],
[0, 0, 0],
[1, 0, 0] ],
[ [0, 1, 0],
[-1, 0, 0],
[0, 0, 0] ]]),
symbol="epsilon"
)
eps.show()
from OGRePy.abc import alpha, beta, gamma, delta, zeta, mu, nu, gamma, eta, nu, phi, chi, psi, omega, sigma
B = eps(alpha, eta, psi) @ Fv(eta) @ Gv(psi)
C = eps(alpha, eta, psi) @ Fv(eta) @ Gv(psi)
A = B(alpha) @ C(alpha)
And here is the error message:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[8], [line 66](vscode-notebook-cell:?execution_count=8&line=66)
[62](vscode-notebook-cell:?execution_count=8&line=62) B = eps(alpha, eta, psi) @ Fv(eta) @ Gv(psi)
[64](vscode-notebook-cell:?execution_count=8&line=64) C = eps(alpha, eta, psi) @ Fv(eta) @ Gv(psi)
---> [66](vscode-notebook-cell:?execution_count=8&line=66) A = B(alpha) @ C(alpha)
File ~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1029, in Tensor.__matmul__(self, other)
[1027](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1027) contract_count: int = len(_unique_summation_placeholders(self._symbol))
[1028](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1028) # Increase the numbering of the summation indices as well.
-> [1029](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1029) second_symbol = _summation_pattern.sub(lambda match: f"[{match[0]}{int(match[1]) + contract_count}{match[2]}]", second_symbol)
[1030](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1030) # Add the number of contractions in the second symbol to the total count.
[1031](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1031) contract_count += len(_unique_summation_placeholders(second_symbol))
File ~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1029, in Tensor.__matmul__.<locals>.<lambda>(match)
[1027](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1027) contract_count: int = len(_unique_summation_placeholders(self._symbol))
[1028](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1028) # Increase the numbering of the summation indices as well.
-> [1029](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1029) second_symbol = _summation_pattern.sub(lambda match: f"[{match[0]}{int(match[1]) + contract_count}{match[2]}]", second_symbol)
[1030](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1030) # Add the number of contractions in the second symbol to the total count.
[1031](https://file+.vscode-resource.vscode-cdn.net/home/mukhamet/Desktop/Hamiltonian/~/Documents/anaconda3/envs/OGRe/lib/python3.12/site-packages/OGRePy/_core.py:1031) contract_count += len(_unique_summation_placeholders(second_symbol))
ValueError: invalid literal for int() with base 10: ':'
Kind regards
Tileuzhan
Metadata
Metadata
Assignees
Labels
No labels