Logaritm of a tensor

``````*#from this import
from dolfinx import fem
import ufl
from ufl import ds, dx, grad, inner, dot
from petsc4py.PETSc import ScalarType
from dolfinx.io import XDMFFile
from dolfinx import fem, mesh
from dolfinx.io import gmshio
from mpi4py import MPI
import numpy as np
from petsc4py import PETSc

#Create geometry and aproximation space
domain= mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0,0]), np.array([2,1])],
[20,20], cell_type=mesh.CellType.triangle)

V = fem.VectorFunctionSpace(domain, ("CG", 1))

u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

#Create Strain Tensor
d = len(u)
I = (ufl.Identity(d))
F =(I + ufl.grad(u))

#calling the logarithm function by UFL
C= ufl.dot(F, F.T )

Hencky_Strain= ufl.ln(C)
``````
``````#I end up getting this error:

Expecting scalar argument.
ERROR:UFL:Expecting scalar argument.
File "/home/dolfinx/gmsh_testes.py", line 53, in <module>
Hencky_Strain= ufl.ln(C)
File "/usr/lib/python3/dist-packages/ufl/operators.py", line 604, in ln
return _mathfunction(f, Ln)
File "/usr/lib/python3/dist-packages/ufl/operators.py", line 584, in _mathfunction
r = cls(f)
File "/usr/lib/python3/dist-packages/ufl/mathfunctions.py", line 119, in __init__
MathFunction.__init__(self, "ln", argument)
File "/usr/lib/python3/dist-packages/ufl/mathfunctions.py", line 55, in __init__
error("Expecting scalar argument.")
File "/usr/lib/python3/dist-packages/ufl/log.py", line 158, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Expecting scalar argument.``````

How about:

``````from dolfinx import mesh, fem
import ufl
from mpi4py import MPI
import numpy as np
from petsc4py import PETSc

#Create geometry and aproximation space
domain= mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0,0]), np.array([2,1])],
[20,20], cell_type=mesh.CellType.triangle)

V = fem.VectorFunctionSpace(domain, ("CG", 1))

u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

#Create Strain Tensor
d = len(u)
I = (ufl.Identity(d))
F =(I + ufl.grad(u))

#calling the logarithm function by UFL
C= ufl.dot(F, F.T )
N, M = C.ufl_shape
Hencky_Strain= ufl.as_tensor([[ufl.ln(C[i,j]) for i in range(N)] for j in range(M)])

``````