Using variable Dirichlet boundary condition

18 days ago by
I was wondering how it is possible to define a Dirichlet boundary condition with respect to another variable. Lets say I am solving a time-dependent mixed space including two scalar variables (Alpha and Beta). This is a part of the code:

dt = 0.04
t = 0
T = 1

F =  dot(grad(Alpha), grad(v_3)) * dx(2) +dt * dot(grad(Beta), grad(v_2)) * dx(1)+ ...

while t <= T:
    J = derivative(F, z, dz)
    problem = NonlinearVariationalProblem(F, z, bcs, J)
    solver = NonlinearVariationalSolver(problem)


    (Alpha,Beta) = z.split(True)

    t += dt​
But the problem is related to the Dirichlet boundary condition. The variational form (F) includes 2 different equations. The first one for Alpha and the second one for Beta.  I want to use the variable Alpha as the boundary condition for Solving the equation for the other variable (Beta).  In other words, I want to take the most recent Alpha at each time-step (iteration) and use it as the boundary condition for solving the equation to compute Beta. Here is what I want to do:

Dirichlet = DirichletBC(W.sub(2),Alpha, boundaries, 5)

bcs = [Dirichlet]
And this is the error I get:

Error:   Unable to create function.​
Reason:  Cannot be created from subspace. Consider collapsing the function space.
To be more specific, the Dirichlet boundary condition in my problem should be updated at each time step based on the value of the other variable.  Could anybody help me with that? Thanks!
Community: FEniCS Project
For the error messsage, use W.sub(2).collapse()
written 17 days ago by Moritz  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »