Doubt with a non linear system problem

Hello to everyone! I’m using fenics legacy version to solve a nonlinear system of partial differential equations with time evolution, but I’m struggling with some problems. I’ll post the code here:

from fenics import *
import matplotlib.pyplot as plt
import numpy as np
import time

combined_file = XDMFFile("combined_solution.xdmf")
combined_file.parameters["flush_output"] = True  # Ensure data is written immediately

T = 10.0            # final time
num_steps = 201     # number of time steps
dt = T / num_steps # time step size
tol = 1E-14; eta = 1*10E-7; eps = 4*10E-2; delta = 0.5; Alternate_tol = 1*10E-5
G_c = 1

mesh = UnitSquareMesh(5,5)
mesh_h = UnitSquareMesh(5,5)

V = FunctionSpace(mesh, "Lagrange", 1)
V_h = FunctionSpace(mesh_h, "Lagrange", 1)

g_t = Expression('t', degree=1, t=0)

def boundary_D(x, on_boundary):
    return on_boundary and near(x[0], 0, tol) and (x[1] > eps) and (x[1] < 5 + eps)

bc = DirichletBC(V, g_t, boundary_D)

u = Function(V)
v = Function(V)
v.assign(Constant(1.0))  # Initialize v as a constant value
u1 = TestFunction(V)
v1 = TestFunction(V)

F1 = (v**2 + eta)*u*u1*dx
F2 = ((grad(u)**2)*v*v1 + 2*G_c*(v-1)*v1/(4*eps) - eps*inner(grad(v), grad(v1)))*dx

v.interpolate(Constant(1.0))  # Initialize v0 as 1.0
u = Function(V)
v_previous = Function(V)

for t in range(num_steps):
    # Update the projection of u at the beginning of each time step
    u_n = project(g_t, V)

    check_tol = False
    i = 0

    while not check_tol:
        u.assign(u_n)  # Set u to the projected value

        # Solve for u
        solve(F1 == 0, u, bc)

        # Solve for v using the previous time step's solution as an upper bound
        solve(F2 == 0, v, bc)

        # Apply constraints for v not to be smaller than the previous time step
        v.vector().set_local(np.maximum(v.vector().get_local(), v_previous.vector().get_local()))

        # Calculate the maximum norm of the difference between consecutive v solutions
        if(i >0):
            maxnorm = norm(v - v_previous, 'linf')

        if maxnorm < Alternate_tol:
            check_tol = True
        else:
            i += 1
            v_previous.assign(v)  # Update the previous solution of v for the next iteration

    # Update for the next time step
    t += dt
    g_t.t = t
    combined_file.write(u, t)  # Save solution of u
    combined_file.write(v, t)  # Save solution of v

    # Assign current solutions for the next iteration
    u_n.assign(u)
    v_previous.assign(v)

combined_file.close()

The error that is appearing, is:

No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 4.406e+00 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
  Newton iteration 1: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 2.166e-16 (tol = 1.000e-09)
  Newton solver finished in 1 iterations and 1 linear solver iterations.
Traceback (most recent call last):
  File "/home/philip/Documents/math-programming/MATH code/First FEM approx/brittle_9999.py", line 64, in <module>
    if maxnorm < Alternate_tol:
NameError: name 'maxnorm' is not defined

I’m struggling with the fact that I need to guarantee that at each time step, the function v is less than the previous time step and, inside the arguments, I need to solve for u such that the Dirichlet conditions are being satisfied (This one I think that I’m done successfully) and I need to do it until the max norm of the difference between v at iteration I and I - 1 is lesser than Alternate_tol. I tried to do this in the code, but I don’t know why it’s not working, and I thought that max norm is defined in fenics, but it’s not working. Does anyone have any tips that could help me please?

Your error doesn’t have anything to do with FEniCS. Let me explain by copying some of your lines of code:

for t in range(num_steps):

    ...

    i = 0

    while not check_tol:

        ...

        if(i >0):
            maxnorm = norm(v - v_previous, 'linf')

        if maxnorm < Alternate_tol:
            check_tol = True
        else:
            i += 1

When you start a new time step you define i = 0. You then have an if statement that is only executed when i > 0, and inside that if statement maxnorm is (re)defined. Afterward maxnorm is used in a second if statement.
In your first time step maxnorm is undefined, so your code throws this error:

Traceback (most recent call last):
  File "/home/philip/Documents/math-programming/MATH code/First FEM approx/brittle_9999.py", line 64, in <module>
    if maxnorm < Alternate_tol:
NameError: name 'maxnorm' is not defined

You can easily solve this by adding the line maxnorm = 1. before stepping into your time stepping for loop.

1 Like

What can I do to fix this error? It’s related with the error in calculating the sup_norm, I tried to define v-v_previous as a function in the space V, but it didn’t even iterate over newton’s method

,
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F’.
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F’.
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 4.406e+00 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Newton iteration 1: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 2.166e-16 (tol = 1.000e-09)
Newton solver finished in 1 iterations and 1 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F’.
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F’.
Solving nonlinear variational problem.
Newton iteration 0: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
Newton solver finished in 0 iterations and 0 linear solver iterations.
Traceback (most recent call last):
File “/home/philip/Documents/math-programming/MATH code/First FEM approx/brittle_9999.py”, line 64, in
maxnorm = norm((v - v_previous), ‘linf’)
File “/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/norms.py”, line 151, in norm
raise TypeError(“Do not know how to compute norm of {}”.format(str(v)))
TypeError: Do not know how to compute norm of f_16 + -1 * f_24

,

The problem, I guess is in this line that I make the difference between the two iterated functions and take the Sup Norm:
,
u = Function(V)
v = Function(V)
v.assign(Constant(1.0)) # Initialize v as a constant value
u1 = TestFunction(V)
v1 = TestFunction(V)

F1 = (v**2 + eta)uu1dx
F2 = ((grad(u)**2)vv1 + 2
G_c*(v-1)v1/(4eps) - eps*inner(grad(v), grad(v1)))*dx

v.interpolate(Constant(1.0)) # Initialize v0 as 1.0
u = Function(V)
v_previous = Function(V)

for t in range(num_steps):
# Update the projection of u at the beginning of each time step
u_n = project(g_t, V)

check_tol = False
i = 0

while not check_tol:
    u.assign(u_n)  # Set u to the projected value

    # Solve for u
    solve(F1 == 0, u, bc)

    # Solve for v using the previous time step's solution as an upper bound
    solve(F2 == 0, v, bc)

    # Apply constraints for v not to be smaller than the previous time step
    v.vector().set_local(np.maximum(v.vector().get_local(), v_previous.vector().get_local()))

    # Calculate the maximum norm of the difference between consecutive v solutions
    
    if(i >0):
        maxnorm = norm((v - v_previous), 'linf')

    if maxnorm < Alternate_tol:
        check_tol = True
    else:
        i += 1
        v_previous.assign(v)  # Update the previous solution of v for the next iteration

# Update for the next time step
t += dt
g_t.t = t
combined_file.write(u, t)  # Save solution of u
combined_file.write(v, t)  # Save solution of v

# Assign current solutions for the next iteration
u_n.assign(u)
v_previous.assign(v)


Could someone help me please with syntaxe?

Please format your code with 3x` encapsulation, i.e.

```python
# add code here
```

When it comes to you error, I would suggest doing this through several steps as shown below:

from petsc4py import PETSc
import dolfin
mesh = dolfin.UnitSquareMesh(10, 10)

V = dolfin.FunctionSpace(mesh, "Lagrange", 1)
u = dolfin.Function(V)
v = dolfin.Function(V)
u.interpolate(dolfin.Expression("x[0]", degree=1))
v.interpolate(dolfin.Expression("2*x[0]+x[1]+0.1", degree=1))

u_vec = dolfin.as_backend_type(u.vector()).vec()
v_vec = dolfin.as_backend_type(v.vector()).vec()
u_vec.axpy(-1, v_vec)
print(u_vec.norm(PETSc.NormType.INFINITY))
from petsc4py import PETSc
from fenics import *
import matplotlib.pyplot as plt
import numpy as np
import time

combined_file = XDMFFile("combined_solution.xdmf")
combined_file.parameters["flush_output"] = True  # Ensure data is written immediately

T = 10.0            # final time
num_steps = 201     # number of time steps
dt = T / num_steps # time step size
tol = 1E-14; eta = 1*10E-7; eps = 4*10E-2; delta = 0.5; Alternate_tol = 1*10E-5
G_c = 1
maxnorm = 1

mesh = UnitSquareMesh(5,5)
mesh_h = UnitSquareMesh(5,5)

V = FunctionSpace(mesh, "Lagrange", 1)
V_h = FunctionSpace(mesh_h, "Lagrange", 1)

g_t = Expression('t', degree=1, t=0)

def boundary_D(x, on_boundary):
    return on_boundary and near(x[0], 0, tol) and (x[1] > eps) and (x[1] < 5 + eps)

bc = DirichletBC(V, g_t, boundary_D)

u = Function(V)
v = Function(V)
v.assign(Constant(1.0))  # Initialize v as a constant value
u1 = TestFunction(V)
v1 = TestFunction(V)

F1 = (v**2 + eta)*u*u1*dx
F2 = ((grad(u)**2)*v*v1 + 2*G_c*(v-1)*v1/(4*eps) - eps*inner(grad(v), grad(v1)))*dx

v.interpolate(Constant(1.0))  # Initialize v0 as 1.0
u = Function(V)
v_previous = Function(V)

for t in range(num_steps):
    # Update the projection of u at the beginning of each time step
    u_n = project(g_t, V)

    check_tol = False
    i = 0

    while not check_tol:
        u.assign(u_n)  # Set u to the projected value

        # Solve for u
        solve(F1 == 0, u, bc)

        # Solve for v using the previous time step's solution as an upper bound
        solve(F2 == 0, v, bc)

        # Apply constraints for v not to be smaller than the previous time step
        v.vector().set_local(np.maximum(v.vector().get_local(), v_previous.vector().get_local()))
        
        print('\n')
        print('Dolfin Test\n')
        print('\n')
        u_vec = as_backend_type(u.vector()).vec()
        v_vec = as_backend_type(v.vector()).vec()
        u_vec.axpy(-1, v_vec)
        print(u_vec.norm(PETSc.NormType.INFINITY))
        # Calculate the maximum norm of the difference between consecutive v solutions
        
        if(i >0):
            maxnorm = norm((v - v_previous), 'linf')

        if maxnorm < Alternate_tol:
            check_tol = True
        else:
            i += 1
            v_previous.assign(v)  # Update the previous solution of v for the next iteration

    # Update for the next time step
    t += dt 
    g_t.t = t
    combined_file.write(u, t)  # Save solution of u
    combined_file.write(v, t)  # Save solution of v

    # Assign current solutions for the next iteration
    u_n.assign(u)
    v_previous.assign(v)

combined_file.close()
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 4.406e+00 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
  Newton iteration 1: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 2.166e-16 (tol = 1.000e-09)
  Newton solver finished in 1 iterations and 1 linear solver iterations.


Dolfin Test



2.568550725441046
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.


Dolfin Test



2.568550725441046
Traceback (most recent call last):
  File "/home/philip/Documents/math-programming/MATH code/First FEM approx/brittle_9999.py", line 72, in <module>
    maxnorm = norm((v - v_previous), 'linf')
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/norms.py", line 151, in norm
    raise TypeError("Do not know how to compute norm of {}".format(str(v)))
TypeError: Do not know how to compute norm of f_16 + -1 * f_24

I don’t understand what PETSc does, but it seems like does not change between each interaction. Also, I would like to know more about v.previous.assign(v) function, please, because my intention there was to iterate, and see if the difference is in that tolerance with restriction of the new iterate function is lesser than the previous one, because it represents a crack term in a brittle fracture, and the energy term associated with the crack cannot increase (there is a 1-v² in the original formulation). Anyway, thanks for helping, I appreciate it.

Remove the re-definition of u in the second to last line of what Ive quoted.

Also, please split your question into multiple, smaller questions where you isolate each part of your problem.

ok, sorry for this. i remove it, but still appearing the same error at my definition of maxnorm:

No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 4.406e+00 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
  Newton iteration 1: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 2.166e-16 (tol = 1.000e-09)
  Newton solver finished in 1 iterations and 1 linear solver iterations.


Dolfin Test



2.568550725441046
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.


Dolfin Test



2.568550725441046
Traceback (most recent call last):
  File "/home/philip/Documents/math-programming/MATH code/First FEM approx/brittle_9999.py", line 71, in <module>
    maxnorm = norm((v - v_previous), 'linf')
  File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/norms.py", line 151, in norm
    raise TypeError("Do not know how to compute norm of {}".format(str(v)))
TypeError: Do not know how to compute norm of f_16 + -1 * f_21

Ok, some questions:

  1. I saw an example in Fenics book of nonlinear differential equation, and when he solves, there is a jacobian. What did I do wrong?

  2. The iterations over Newton’s method, are converging too fast, is this a problem of my code structure?

  3. When dealing with nonlinear system of PDEs under constraints, what is the better way to build the problem? I tried to do similar with the nonlinear one from fenics book.

  4. There is a discord of fenics?

Also, thanks for answering me.

You did nothing wrong. When you call

it is optional to pass the Jacobian. If you do not pass it, it is computed as derivative(F1, u).

Your definition isn’t supported in dolfin, so Im not sure why you exist on keeping it even after I showed you another way of conputing the error.

Your first equation is linear wrt to u, so it should be solved with one iteration.

Your second equation is linear wrt to v.
I would strongly suggest you write out the strong formulation of your problem so that anyone can help you further.

This is a complex question, highly dependent on your PDEs.

Fenics has a slack channel, see https://fenicsproject.org/community/ for details

The strong form is:

And I’m working with the antiplanar case, where w(e(u)) is the squared module of the gradient of u, with u depending only on y and x, and as v is a surface term that depends on x, y and z.

Also, related to the code, I replaced the max norm by:

        u_vec = as_backend_type(u.vector()).vec()
        v_vec = as_backend_type(v.vector()).vec()
        v_previous_vec = as_backend_type(v_previous.vector()).vec()
        u_vec.axpy(v_previous_vec, v_vec)
        
        if(i >0):
            maxnorm = u_vec.norm(PETSc.NormType.INFINITY)
        # Calculate the maximum norm of the difference between consecutive v solutions
 No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)
  Newton solver finished in 0 iterations and 0 linear solver iterations.
No Jacobian form specified for nonlinear variational problem.
Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 4.406e+00 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
  Newton iteration 1: r (abs) = 9.545e-16 (tol = 1.000e-10) r (rel) = 2.166e-16 (tol = 1.000e-09)
  Newton solver finished in 1 iterations and 1 linear solver iterations.
Traceback (most recent call last):
  File "/home/philip/Documents/math-programming/MATH code/First FEM approx/brittle_9999.py", line 64, in <module>
    u_vec.axpy(v_previous_vec, v_vec)
  File "PETSc/Vec.pyx", line 954, in petsc4py.PETSc.Vec.axpy
  File "PETSc/PETSc.pyx", line 96, in petsc4py.PETSc.asScalar
TypeError: must be real number, not petsc4py.PETSc.Vec

Axpy is the operation

u_vec = a*u_vec + y
and thus what you do in the code above is not valid, as a has to be a scalar value.

Ok, i think that “it’s working”, the code:

from petsc4py import PETSc
from fenics import *
import matplotlib.pyplot as plt
import numpy as np
import time

combined_file = XDMFFile("combined_solution.xdmf")
combined_file.parameters["flush_output"] = True  # Ensure data is written immediately

T = 10.0            # final time
num_steps = 201     # number of time steps
dt = T / num_steps # time step size
tol = 1E-14; eta = 1*10E-7; eps = 4*10E-2; delta = 0.5; Alternate_tol = 1*10E-5
G_c = 1

mesh = UnitSquareMesh(5,5)
mesh_h = UnitSquareMesh(5,5)

V = FunctionSpace(mesh, "Lagrange", 1)
V_h = FunctionSpace(mesh_h, "Lagrange", 1)

g_t = Expression('t', degree=1, t=0)

def boundary_D(x, on_boundary):
    return on_boundary and near(x[0], 0, tol) and (x[1] > eps) and (x[1] < 5 + eps)

bc = DirichletBC(V, g_t, boundary_D)

u = Function(V)
v = Function(V)
v.assign(Constant(1.0))  # Initialize v as a constant value
u1 = TestFunction(V)
v1 = TestFunction(V)

F1 = (v**2 + eta)*u*u1*dx
F2 = ((grad(u)**2)*v*v1 + 2*G_c*(v-1)*v1/(4*eps) - eps*inner(grad(v), grad(v1)))*dx

v.interpolate(Constant(1.0))  # Initialize v0 as 1.0
v_previous = Function(V)

for t in range(num_steps):
    # Update the projection of u at the beginning of each time step
    u_n = project(g_t, V)

    check_tol = False
    i = 0

    u.assign(u_n)  # Set u to the projected value
    solve(F1 == 0, u, bc)

    while not check_tol:
        maxnorm = 1

        # Solve for v using the previous time step's solution as an upper bound
        solve(F2 == 0, v, bc)

        # Apply constraints for v not to be smaller than the previous time step
        v.vector().set_local(np.minimum(v.vector().get_local(), v_previous.vector().get_local()))
        
        u_vec = as_backend_type(u.vector()).vec()
        v_vec = as_backend_type(v.vector()).vec()
        v_previous_vec = as_backend_type(v_previous.vector()).vec()
        diff_vec = v_vec.copy()  # Create a copy of v_vec
        diff_vec.axpy(-1.0, v_previous_vec)  # Compute the difference v_vec - v_previous_vec
        maxnorm = diff_vec.norm(PETSc.NormType.INFINITY)  # Calculate the maximum norm
        
        if(i >0):
            maxnorm = v_vec.norm(PETSc.NormType.INFINITY)
        # Calculate the maximum norm of the difference between consecutive v solutions

        if(maxnorm < Alternate_tol) or i == 50:
            check_tol = True
            break
        else:
            i += 1
            v_previous.assign(v)  # Update the previous solution of v for the next iteration

    # Update for the next time step
    t += dt 
    g_t.t = t
    combined_file.write(u, t)  # Save solution of u
    combined_file.write(v, t)  # Save solution of v

    # Assign current solutions for the next iteration
    u_n.assign(u)
    v_previous.assign(v)

combined_file.close()

print(v,'\n')
print(u)

The program was entering through an infinite loop. so I put a limit in the i interactions, but the exit:

Differentiating residual form F to obtain Jacobian J = F'.
Solving nonlinear variational problem.
  Newton iteration 0: r (abs) = 4.121e+04 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)
  Newton iteration 1: r (abs) = 1.004e-09 (tol = 1.000e-10) r (rel) = 2.436e-14 (tol = 1.000e-09)
  Newton solver finished in 1 iterations and 1 linear solver iterations.
f_16 

f_13
  1. How can I print numerical values for u and v?
  2. How can I plot this lot of numerical values to see if the crack is propagating or not?
  3. Why without putting this limit on i, it was going through the infinite loop?
  4. Does it has any function in fenics for computing the time solution?

Thanks.

u and v are of the class dolfin.Function.
You can access the underlying degrees of freedom by calling u.vector().get_local() and v.vector().get_local()

Simply call plot(u), plot(v), which will plot the values using matplotlib.

Now you are asking why your algorithm doesn’t converge. Do you have proof that such a split method for solving the non-linear problems will converged? Is there a reason for using a split approach and not a coupled approach?

It is quite common in finite element problems that one uses finite difference for the time derivative, and then in turn solve a sequence of problems. FEniCS is no exception.
There do exist space-time finite element methods, which should be a separate investigation.

I’m using The alternate minimizations algorithim. It consists in repeating iteractions until we arrive at a tolerance error.

Basically, it starts at each time step, with i = 0 and doing v as 1 at time step 0 and equal the previous solution, at any other time step.

Now, my doubt is with these function:

u_n = project(g_t, V)

   check_tol = False
   i = 0

   u.assign(u_n)  # Set u to the projected value
   solve(F1 == 0, u, bc)

   while not check_tol:
       maxnorm = 1

       # Solve for v using the previous time step's solution as an upper bound
       solve(F2 == 0, v, bc)

       v.vector().set_local(np.minimum(v.vector().get_local(), v_previous.vector().get_local()))
       
       u_vec = as_backend_type(u.vector()).vec()
       v_vec = as_backend_type(v.vector()).vec()
       v_previous_vec = as_backend_type(v_previous.vector()).vec()
       diff_vec = v_vec.copy()  
       diff_vec.axpy(-1.0, v_previous_vec)  
       maxnorm = diff_vec.norm(PETSc.NormType.INFINITY)  # Calculate the maximum norm
       print('\n',f"Iteration {i}: MaxNorm(v) = {maxnorm}",'\n')
       
   
       if(maxnorm < Alternate_tol) or i == 30:
           check_tol = True
           break
       else:
           i += 1
           v_previous.assign(v)  # Update the previous solution of v for the next iteration
  1. when I interpolate u, i’m solving the F1 problem under the constraint that u need to be equal G in a part of the domain?

2)To solve for F2, i’m taking the solution that is lesser than the previous time step with this function:

v.vector().set_local(np.minimum(v.vector().get_local(), v_previous.vector().get_local()))

And with that definition that i did on maxnorm, that you provides me, it iterates untill satisfies the tolerance condition?

  1. With assign functions, am I setting the currently solution at time step p to be the one that i found with these iteractions?

  2. In fenics book, the most part of this functions don’t appear. Where can I found more to read about it?