### Avoiding NaN on invariants of Cauchy Green deformation tensor

258

views

0

I would like to limit the values of invariants of Cauchy Green deformation tensor. In the code below Igama should not be lower than zero since there is a square root of Igama at the end. When I do this I get this message: "UFL conditions cannot be evaluated as bool in a Python context". If I donot limit I gama solution yields NaN. So, how can I limit the value of a solution variable (Igama)?

I = Identity(d) # Identity tensor

F = I + grad(u1) # Deformation gradient

C = F.T*F # Right Cauchy-Green tensor

Cinv=inv(C)

Finv=inv(F)

J = det(F)

I1 = tr(C)

I2 = 0.5*(tr(C)**2-tr(dot(C,C)))

I3 = J**2.0

Jinv=J**(-1.0)

I1bar=I1/(I3**(1.0/3.0))

I2bar=I2/(I3**(2.0/3.0))

Igama = (2.0*(I1bar**2)-6.0*I2bar)

tol=1E-14

if Igama < tol:

Igama = tol

Igama = (Igama**0.5)/6.0

I = Identity(d) # Identity tensor

F = I + grad(u1) # Deformation gradient

C = F.T*F # Right Cauchy-Green tensor

Cinv=inv(C)

Finv=inv(F)

J = det(F)

I1 = tr(C)

I2 = 0.5*(tr(C)**2-tr(dot(C,C)))

I3 = J**2.0

Jinv=J**(-1.0)

I1bar=I1/(I3**(1.0/3.0))

I2bar=I2/(I3**(2.0/3.0))

Igama = (2.0*(I1bar**2)-6.0*I2bar)

tol=1E-14

if Igama < tol:

Igama = tol

Igama = (Igama**0.5)/6.0

Community: FEniCS Project

### 2 Answers

0

- You can define if statement by use of conditional statement in FEniCS. See for example here, https://fenicsproject.org/qa/14105/ufl-condition-in-if-statement

0

I tried it. It works as in the following. Now I donot get NaN and problem converges. Thank you !

# Compute Igama

Igama = (2.0*(I1bar**2)-6.0*I2bar)

tolV=project(Constant("1E-14"),VF)

Igama=conditional(le(Igama,tolV), tolV, Igama) # required to avoid minus values in sqrt()

Igama = sqrt(Igama)/6.0

#

# Compute Igama

Igama = (2.0*(I1bar**2)-6.0*I2bar)

tolV=project(Constant("1E-14"),VF)

Igama=conditional(le(Igama,tolV), tolV, Igama) # required to avoid minus values in sqrt()

Igama = sqrt(Igama)/6.0

#

Please login to add an answer/comment or follow this question.