Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Solving a damped wave equation

I am trying to solve the equation

$$ \frac{d^2u}{dt^2}-\frac{d^2}{dx^2}\left(c_s^2u+\nu\frac{du}{dt}\right)=0 $$

with initial conditions

$$u(x, 0)=0$$

$$\frac{du}{dt}|_{t=0}=0$$

and boundary conditions

$$ {\frac{du}{dx}}|_{x=0,1}=a\sin{(\omega_d t)}-b\cos{(\omega_d t)}$$

My attempts so far are

ClearAll[u, x, t, a, b, c, w, n];

c = 1;
n = 1;
a = 1;
b = 1;
w = 1;

pde = D[u[t, x], t, t] - c*D[u[t, x], x, x] - n*D[u[t, x], x, x, t] == 0;
ics = {u[0,x]==0};
bcs = 
  {(D[u[t,x],x] /. x->0) == a*Sin[w*t]-b*Cos[w*t], 
   (D[u[t,x],x] /. x->1) == a*Sin[w*t]-b*Cos[w*t]};

sol = NDSolveValue[{pde, ics, bcs}, u, {x, 0, 1},{t, 0, 10}]

but I am receiving multiple error messages. Among them:

NDSolveValue::fembdnl: The dependent variable in (u^(0,1))[t,0]==-Cos[t]+Sin[t] in the boundary condition DirichletCondition[(u^(0,1))[t,0]==-Cos[t]+Sin[t],x==0.] needs to be linear.

NDSolveValue::fembdnl: The dependent variable in (u^(0,1))[t,0]==-Cos[t]+Sin[t] in the boundary condition DirichletCondition[(u^(0,1))[t,0]==-Cos[t]+Sin[t],x==0.] needs to be linear.

NDSolveValue::femcmsd: The spatial derivative order of the PDE may not exceed two.

How can I solve it?

Answer*

Cancel
6
  • $\begingroup$ Thank you for your answe, it is very useful. Though, I have a few doubts on your procedure: why did you add an IF condition in the boundary conditions? Is it needed to add the new initial condition v[0, x] == 0 ? Is there a particular reason why you specified all those options to solve the pde? $\endgroup$ Commented Oct 27, 2019 at 10:25
  • $\begingroup$ The initial conditions Derivative[1, 0][u][0, x] == 0 and boundary conditions are not matched for t = 0. To harmonize these conditions, we excite the boundary conditions immediately at t>0. $\endgroup$ Commented Oct 27, 2019 at 12:10
  • $\begingroup$ If I try to run your code with mathematica 12, I receive the error NDSolveValue::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution.. Furthermore, using discontinuous boundary conditions apparently causes the solution to have some artifacts at the time point of the discontinuity. $\endgroup$ Commented Oct 29, 2019 at 9:05
  • $\begingroup$ @AlessandroZunino You can remove If[], but determine Derivative[1, 0][u][0, x]. Otherwise, we have a warning NDSolveValue::ibcinc: Warning: boundary and initial conditions are inconsistent. $\endgroup$ Commented Oct 29, 2019 at 9:28
  • $\begingroup$ If I remove the if[] indeed the error you quote appears, even if Derivative[1, 0][u][0, x]==0 is present. Even if this happens, the solutions is still exactly the same you show. Some other errors appear: NDSolveValue::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution. $\endgroup$ Commented Oct 29, 2019 at 10:25