2
$\begingroup$

Mathematica 12.0.0.0 happily solves the trivial coupled differential system as follows:

NDSolve[{D[u[x], x] == 1, D[v[x], x] == 1, DirichletCondition[v[x] == 1, x == 0], DirichletCondition[u[x] == 0, x == 0]}, {u, v}, {x, 0, 1}]

but complains when given differently stated (but equivalent) boundary conditions:

NDSolve[{D[u[x], x] == 1, D[v[x], x] == 1, DirichletCondition[v[x] - u[x] == 1, x == 0], DirichletCondition[v[x] + u[x] == 1, x == 0]}, {u, v}, {x, 0, 1}]

NDSolve::fembdcc "Cross-coupling of dependent variables in DirichletCondition ... is not supported in this version"

The error message seems clear -- it does not like when u and v simultaneously appear in a Dirichlet condition. But why not? Indeed, the documentation of DirichletCondition seems to imply that a general equation is supported:

DirichletCondition[beqn,pred]: "In general, the boundary equation beqn needs to be affine linear in the dependent variables, i.e. h1 u1+ … = r, where hi and r can depend on any of the independent variables {x1,x2,…}."

DirichletCondition---Documentation

$\endgroup$

1 Answer 1

1
$\begingroup$

Without DirichletCondition NDSolve evaluates the solution:

{U, V} = NDSolveValue[{D[u[x], x] == 1, D[v[x], x] == 1,v[0] - u[0] == 1 , v[0] + u[0] == 1 }, {u, v}, {x, 0, 1}]
{V[0] + U[0 ], V[0] - U[0 ]} 
(* {1,1} *)

Unfortunately using only one DirichletCondition DirichletCondition[v[x] - u[x] == 1 && v[x] + u[x], x == 0] doesn't work.

$\endgroup$
5
  • $\begingroup$ Curious... thanks for this workaround. I think it may only work for ODEs. I tried the same thing with a PDE (with two independent variables), and unfortunately got the error again. With a PDE, Mathematica seems to generate a DirichletCondition internally. So it still seems useful to understand the behavior with DirichletCondition $\endgroup$
    – Will.Mo
    Aug 2, 2019 at 12:22
  • $\begingroup$ For PDE you might use PeriodicBoundaries instead of coupled DirichletConditions: See 202645 and 202542 $\endgroup$ Aug 2, 2019 at 12:29
  • $\begingroup$ thanks for the suggestion. I looked at the examples you sent, but although I can see how this method could allow you to "couple" a single dependent variable to itself (at different values of the independent variables) I'm not sure I see how PeriodicBoundaryCondition can be used to impose a Dirichlet condition, at least not in a straightforward manner. $\endgroup$
    – Will.Mo
    Aug 2, 2019 at 13:40
  • $\begingroup$ Sorry für my misleading Suggestion. I think actual MMA can solve only explicit DirichletConditions. $\endgroup$ Aug 3, 2019 at 9:27
  • $\begingroup$ Thanks nevertheless Ulrich! $\endgroup$
    – Will.Mo
    Aug 5, 2019 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.