0

I wanna solve the following PDE of wave equation using Mathematica.

$u_{tt}=u_{xx}$

$0<x<\pi , t>0$

Initial Conditions:

$\begin{cases}u(x,0)=sin(x) \\u_{t}(x,0)=1\end{cases}$

Boundary Conditions:

$\begin{cases}u(0,t)+u_{x}(0,t)=1\\u(\pi,t)+u_{x}(\pi,t)=-1\end{cases}$

  • I know the boundary and initial conditions are inconsistent.

Are the following codes correct?

weqn = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}];
ic = {u[x, 0] == Sin[x],Derivative[0, 1][u][x, 0] == 1 };
bc = {u[0, t] + Derivative[1, 0][u][0, t] == 1, 
   u[Pi, t] + Derivative[1, 0][u][Pi, t] == -1};
sol = NDSolve[{weqn, ic, bc}, u, {x, 0, Pi}, {t, 0, 10}];
Moreza7
  • 83
  • 5
  • 1
    Yes! Apparently it looks fine. – zhk Jan 19 '19 at 03:51
  • @zhk In this case, the solution happens to be correct, but it's no more than a coincidence. Just change u[0, t] + Derivative[1, 0][u][0, t] == 1 to e.g. u[0, t] + Derivative[1, 0][u][0, t] == 100, you'll find the solution doesn't change at all. To make the solution always correct, option like Method -> {"MethodOfLines", "DifferentiateBoundaryConditions" -> {True, "ScaleFactor" -> 20}} is necessary. One can also turn to FiniteElement method, of course. Please check the linked question for more information. – xzczd Jan 19 '19 at 06:41
  • @xzczd Thx for pointing that out. – zhk Jan 19 '19 at 06:43
  • Are the b.c. correct? Only for bc = {u[0, t] - Derivative[1, 0][u][0, t] == 1 , u[Pi, t] + Derivative[1, 0][u][Pi, t] == -1}; I get finite symmetric periodic solution! – Ulrich Neumann Jan 19 '19 at 13:36
  • @xzczd here the solution of a hyperbolic type equation is discussed, and in your example, a solution has been given of a parabolic type equation. How can these problems be duplicates? – Alex Trounev Jan 19 '19 at 15:50
  • @alex There's no doubt it's a duplicate. Though the equations are different, the root of both problems is the way NDSolve treats inconsistent i.c. and b.c., and as mentioned in my last comment, the solution is to adjust DifferentiateBoundaryConditions option or turn to FiniteElement method, which is the same as mentioned in the linked question. – xzczd Jan 19 '19 at 15:56
  • @xzczd For methodical purposes, a solution must be given. Other users, such as mathematicians, may not understand what the connection is between the two problems. – Alex Trounev Jan 19 '19 at 16:17
  • @Alex Well, I think my first comment already forms a simple answer. Let's wait for OP's reply, if OP thinks the given solution and the linked question are too hard to understand, we can reopen this one. – xzczd Jan 19 '19 at 16:26

0 Answers0