How to implement the absolute value function in python for fenics?

this too does not work. that’s what you suggested.

def sigma(u):
    mu    = E/(2.0*(1.0 + nu))
    lmbda = E*nu/(1.0 - nu**2)
    stress = conditional(ge(tr(eps(u)),0),2.0*mu*(eps(u)) + lmbda*tr(eps(u))*Identity(ndim),2.0*mu*(eps(u)) - lmbda*tr(eps(u))*Identity(ndim))
    return stress