# Solution for a wave equation containing a function

I'm trying to solve the following PDE:

$$\frac{\partial^2u}{\partial t^2}-\frac{\partial}{\partial x}\left(\left(\frac{1}{1+0.25\sin\frac{2\pi x}{\varepsilon}}\right)^2\frac{\partial u}{\partial x}\right)=e^{-t}$$

with $x\in[0,1], t\geq0$ and the following boundary conditions: $u(0,t)=u(1,t)=0$, and the initial conditions $u(x,0)=0$ and $\frac{\partial u(x,0)}{\partial t}=0$, where I plan to give at least 4 different values of $\varepsilon$.

Following a book, I have an estimate for the solution, however, when computing it in Mathematica for t=10, it takes a long time for it to finish, and the result makes no sense.

I am a complete newbie to Mathematica, so my question would be if there is a way to compute the solution within Mathematica itself, where I can compare the plots of different values of $\varepsilon$?

Any insight would be greatly appreciated.

pde = D[u[t, x], {t, 2}] -D[(1/(1 + 0.25*Sin[2*Pi*x/epsilon]))^2*D[u[t, x], x], x] - Exp[-t]
bc1 = DirichletCondition[u[t, x] == 0, x == 0];
bc2 = DirichletCondition[u[t, x] == 0, x == 1];
ic1 = DirichletCondition[u[t, x] == 0, t == 0];
ic2 = NeumannValue[0, t == 0];
sol = ParametricNDSolveValue[{pde ==ic2,  ic1 , bc1, bc2},
u, {x, 0, 1}, {t, 0, 10}, {epsilon}];

Plot3D[Evaluate@Table[sol[epsilon][t, x], {epsilon, {2, 3}}], {x, 0, 1}, {t,
0, 1}, Mesh -> All, AxesLabel -> {"x", "t", "u[t,x]"}]

Plot[(sol[#][10, x]) & /@ {2, 3} // Evaluate, {x, 0, 1}, PlotStyle -> {Red, Green}]


• Is there a way to see a 2D graphic for a set t (such as t=10)? I am assuming this way it plots 2 different values of epsilon, or is it a range going from 0.5 to 5? Also, isn't there a ^2 missing from the function or was it absorbed somewhere in the code? Basically, I'm trying to compare the plots given by this problem with the one given by this other one, but I'm having a little trouble making it work as well... eqn = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}] + Exp[-t] ic = {u[x, 0] == 0, Derivative[0, 1][u][x, 0] == 0} bc = {u[0, t] == 0, u[1, t] == 0} – REVB Jun 15 '18 at 4:14
• Excuse me for the mess above, I'm not familiar on how to paste code from Mathematica unto this page. – REVB Jun 15 '18 at 4:20
• The plot is completely empty? – REVB Jun 15 '18 at 4:31
• I have no idea why, but when I put your code on Mathematica the plot is completely blank. – REVB Jun 15 '18 at 4:44
• @REVB restart your kernel by go to Evaluation>Quit Kernel>Local and then evaluate again. – zhk Jun 15 '18 at 4:45