# Condition on Inside of Region

How do I handle boundary conditions present in the region. Mathematica complains about the condition v [1 , t ] == u [1,t]. The condition should be given to this point!

NDSolve[{
D[u[x, t], t] + D[u[x, t], x] == -u[x, t],
D[v[x, t], t] + D[v[x, t], x] == -v[x, t],
u[x, 0] == E^-x,
v[x, 0] == E^(1 - x),
u[0, t] == 1,
v[1, t] == u[1, t]
},
{u[x, t], v[x, t]},
{x, 0, 2},
{t, 0, 5}]


Many thanks for any help ...

The error message is very descriptive: you haven't specified a boundary condition, but a condition on the middle of the region. If you amend the {x, 0, 2} to {x, 0, 1} it works correctly (but points out that your conditions are inconsistent, which they are).

You should be able to impose conditions on the inside of the region by splitting the region in two, and using the boundary condition to specify both in turn.

{{uin, vin}} =
NDSolve[{D[u[x, t], t] + D[u[x, t], x] == -u[x, t],
D[v[x, t], t] + D[v[x, t], x] == -v[x, t], u[x, 0] == E^-x,
v[x, 0] == E^(1 - x), u[0, t] == 1, v[1, t] == u[1, t]},
{u[x, t], v[x, t]},
{x, 0, 1}, {t, 0, 5}]

NDSolve[{D[u[x, t], t] + D[u[x, t], x] == -u[x, t],
D[v[x, t], t] + D[v[x, t], x] == -v[x, t], u[x, 0] == E^-x,
v[x, 0] == E^(1 - x), u[1, t] == (u[x, t] /. uin /. x -> 1),
v[1, t] == (v[x, t] /. vin /. x -> 1)},
{u[x, t], v[x, t]},
{x, 1, 2}, {t, 0, 5}]

• Thank you very much for your help, but I need to specify a condition within the region and not the borders. Disregard the part of inconsistency is just a bad initial condition imposed . – Jeiveison Gobério Maia Aug 19 '15 at 19:33
• Does my edit help? – Patrick Stevens Aug 19 '15 at 19:40
• Thank you very much for your help, but the interesting thing is the use of a single NDSolve because the real problem I want to solve is even more costly . Appreciate more suggestions in this regard ! – Jeiveison Gobério Maia Aug 19 '15 at 19:58

The analogous 1D problem,

NDSolveValue[{D[u[x], x] == -u[x], D[v[x], x] == -v[x], u[0] == 1, v[1] == u[1]},
{u, v}, {x, 0, 2}]


integrates across x == 1 without difficult. Therefore, I expected that

NDSolveValue[{D[u[x, t], t] + D[u[x, t], x] == -u[x, t],
D[v[x, t], t] + D[v[x, t], x] == -v[x, t], u[x, 0] == E^-x,
v[x, 0] == E^(1 - x), u[0, t] == 1, v[1, t] == u[1, t]}, {u[x, t], v[x, t]},
{t, 0, 5}, {x, 0, 2}, Method -> {"MethodOfLines", "TemporalVariable" -> x}]


also would work, because the Method chosen causes NDSolve to discretize the computation into a set of 1D equations in x. No such luck.

However, another approach does work, although it does involve running NDSolve for u and v separately.

su = NDSolveValue[{D[u[x, t], t] + D[u[x, t], x] == -u[x, t],
u[x, 0] == E^-x, u[0, t] == 1}, u, {x, 0, 2}, {t, 0, 5}];
sv = NDSolveValue[{D[v[x, t], t] + D[v[x, t], x] == -v[x, t],
v[x, 0] == E^(1 - x), v[1, t] == su[1, t]}, v, {x, 0, 2}, {t, 0, 5}]


This approach integrates across x == 1 without difficulty, although with an unrelated warning message,

(* NDSolveValue::ibcinc: Warning: boundary and initial conditions are inconsistent. >> *)


indicating that u[x, 0] is not equal to E^(1 - x) at x == 1. If the original code in the Question had not failed due to

(* NDSolveValue::bcedge: Boundary condition v[1,t]==u[1,t] is not specified on a single edge of the boundary of the computational domain. >> *)


it would have failed for this (legitimate) reason. Consider, therefore a consistent initial condition,

sv = NDSolveValue[{D[v[x, t], t] + D[v[x, t], x] == -v[x, t],
v[x, 0] == E^(-.75 (x - 1)) su[1, 0], v[1, t] == su[1, t]}, v, {x, 0, 2}, {t, 0, 5}]


The resulting curves are

Plot3D[su[x, t], {x, 0, 2}, {t, 0, 5}, AxesLabel -> {x, t, u}]


Plot3D[sv[x, t], {x, 0, 2}, {t, 0, 5}, AxesLabel -> {x, t, v}]