4
$\begingroup$

I'm having the following issue that can not find a solution , by using this boundary condition

u[0, t] == 2 u[1, t]

that Mathematica does not understand, someone please help me!

s = NDSolve[
  {
   D[u[x, t], t] == -D[u[x, t], x] - u[x, t],
   u[x, 0] == 1,

   u[0, t] == 2 u[1, t]
   },

  {u[x, t]},

  {x, 0, 1}, {t, 0, 1},

  Method -> {"PDEDiscretization" -> {"MethodOfLines", 
      "TemporalVariable" -> t}}]

I'm getting this error message :

NDSolve::bcedge: Boundary condition u[0,t]==2u[1,t] is not specified on a single edge of the boundary of the computational domain.

I have already presented a similar problem here, but the reasoning suggested is not a good solution for my case.

What strategies do you know to treat this problem ? I appreciate any help...

$\endgroup$
0

1 Answer 1

4
$\begingroup$

It's possible to make use of the method suggested in this post, but since this equation is simpler, we can solve it by making a change of variable

$$u(x,t)=\frac{v(x,t)}{x+1}$$

I'll use DChange for the task.

set = {D[u[x, t], t] == -D[u[x, t], x] - u[x, t], u[x, 0] == 1, u[0, t] == 2 u[1, t]};

newset = DChange[set, u[x, t] == 1/(1 + x) v[x, t]]

mol[n_Integer, o_:"Pseudospectral"] := {"MethodOfLines", 
  "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n, 
    "MinPoints" -> n, "DifferenceOrder" -> o}}
newsol = NDSolveValue[newset, v, {x, 0, 1}, {t, 0, tend}, Method -> mol[201]]

Plot[{newsol[x, t]/(1 + x) /. x -> 0, 2 newsol[x, t]/(1 + x) /. x -> 1} // Evaluate, {t, 
  0, tend}, PlotStyle -> {Green, {Dashed, Red, Thick}}]

Mathematica graphics

Plot3D[newsol[x, t]/(1 + x), {x, 0, 1}, {t, 0, tend}]

Mathematica graphics

There's some noise at the discontinuity, but I think the result is still acceptable.

$\endgroup$

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.