Initial Guess for infinite terms

Hello everyone,

I’m dealing with mixed variatonal formulation and I have the following free energy functional:

# Kinematics
d = u.geometric_dimension()
I = Identity(d)             # Identity tensor
F = I + grad(u)             # Deformation gradient
C = F.T*F                   # Right Cauchy-Green tensor

# Invariants of deformation tensors
Ic = tr(C)
J  = det(F)


psi = (mu/2)*(Ic - 3) - mu*ln(T) + (lmbda/2)*(ln(T))**2

where “T” is another function (like displacement) in mixed formulation. But it is in “ln” form in the energy functional which causes mathematical infinite error in the first step. Is there any way to define initial guess for T which will not cause 0 in ln. Force example it would be perfect if I can define it as T_0=1.0. Thanks.

Is something like the following what you’re looking for?

from dolfin import *
mesh = UnitSquareMesh(1,1)
c = mesh.ufl_cell()
V = FunctionSpace(mesh,MixedElement([VectorElement("CG",c,1),
                                     FiniteElement("DG",c,0)]))
f = Function(V)

# Notice that, for purposes of assignment (and also projection), the components
# of the mixed space get flattened into a single vector, so the first two
# components of what is assigned/projected here are the components of the
# VectorElement from V.sub(0), while the third is the FiniteElement from
# V.sub(1).
f.assign(Constant((0,0,1)))

for i in range(0,3):
    print(assemble(f[i]*dx))
1 Like

Hello kamesky,

Thank you for your answer. It seems like it works. But when we assign
f.assign(Constant((0,0,1)))
after the iterative solution, does it re-assign the solved value over “f” ?

And if I have a tensor function space in my mixed formulation, how can I assign initial values to “f” ?

Nonlinear iterations will start at whatever is the state of f immediately before calling the nonlinear solve.

I don’t know off the top of my head the general formula used by FEniCS for flattening tensor-valued components of mixed elements, but you could always reverse-engineer it with tests like the following:

from dolfin import *
mesh = UnitSquareMesh(1,1)
c = mesh.ufl_cell()
V = FunctionSpace(mesh,MixedElement([TensorElement("CG",c,1),
                                     FiniteElement("DG",c,0)]))
f = Function(V)
f.assign(Constant((0,1,2,3,4)))
f_tens,f_scal = split(f)

for i in range(0,2):
    for j in range(0,2):
        print("i="+str(i)+" , j="+str(j)+" : "+str(assemble(f_tens[i,j]*dx)))
1 Like

Thanks, kamensky. It makes sense.