Hello,
I would like to solve a nonlinear problem using ufl.derivative and MixedElement. Here is a (much simplified) example code of what I am trying to solve:
import dolfinx
import ufl
import numpy as np
from mpi4py import MPI
import dolfinx.fem.petsc
from dolfinx import nls, fem, io, mesh
L = 0.125 # total length
delta = 2.0 # aspect ratio
d=L *delta # thickness
my_domain = dolfinx.mesh.create_rectangle(MPI.COMM_WORLD, [np.array([0, 0]), np.array([L, d])], [10,10], cell_type=dolfinx.mesh.CellType.quadrilateral)
u_el = ufl.VectorElement('Lagrange', my_domain.ufl_cell(), degree=1, dim=2)
phi_el = ufl.FiniteElement('Lagrange', my_domain.ufl_cell(), degree=1)
mixed_el = ufl.MixedElement([u_el, phi_el]) # mixed element
V = dolfinx.fem.FunctionSpace(my_domain, mixed_el)
u_gen = fem.Function(V)
u, phi = ufl.split(u_gen)
v = ufl.TrialFunction(V)
dim = len(u)
I = ufl.variable(ufl.Identity(dim))
F = ufl.variable(I + ufl.grad(u))
C = ufl.variable(F.T * F)
E = ufl.variable(1/2*(C-I))
dx = ufl.Measure("dx", domain=my_domain)
potential_energy = (ufl.tr(E)**2+ufl.inner(phi,phi))*dx
residual = ufl.derivative(potential_energy, u_gen, v)
problem = dolfinx.fem.petsc.NonlinearProblem(residual, u_gen, bcs=[])
I get the following error message:
ValueError: too many values to unpack (expected 2)
I am not sure what is the correct syntax to define such a nonlinear problem.
Many thanks in advance for your help!
Claire