1
$\begingroup$

First, I define a constant I'll use later:

eyng = (1/(1 + 0.25*Sin[2 Pi y]))^2;
cfec = 1/\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(1\)]\(\((
\*FractionBox[\(1\), \(eyng\)])\) \[DifferentialD]y\)\)

Then I try to solve the following PDE following a similar idea to this:

wqn = D[u[t, x], {t, 2}] == cfec*D[u[t, x], {x, 2}] + Exp[-t]
bc1 = {u[t, x] == 0, x == 0};
bc2 = {u[t, x] == 0, x == 1};
ic1 = {u[t, x] == 0, t == 0};
ic2 = {Derivative[1, 0][u][x, 0] == 0};
sol = DSolveValue[{wqn, ic1, ic2, bc1, bc2}, u[t, x], {t, x}]

However, Mathematica doesn't really solve the problem, it just rewrites it, and I'm not sure what I'm doing wrong. I need to plot the solution to it at a fixed t, then compare it with another problem's solution, but I cannot continue.

Any advice will be greatly appreciated

$\endgroup$
1
  • $\begingroup$ Well, I solved the PDE the old fashioned way, plotted it, and then used Show to compare both graphics. Maybe this will help someone with a similar problem. $\endgroup$ – REVB Jun 15 '18 at 18:54
1
$\begingroup$

I edited your try a little bit and it seems to work:

wqn = D[u[t, x], {t, 2}] == cfec*D[u[t, x], {x, 2}] + Exp[-t]
bc1 = u[t, 0] == 0  ;
bc2 = u[t, 1] == 0  ;
ic1 = u[0, x] == 0  ;
ic2 = Derivative[1, 0][u][0, x ] == 0 ;
sol = NDSolveValue[{wqn, ic1, ic2, bc1, bc2},u , {t, 0, 4}, {x, 0, 1 }]

Plot[Table[sol[t, x], {t, 0, 1, .1}], {x, 0, 1}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Much appreciated! However, I don't understand why there are multiple plots, even when inputing a single value of t. The solution should be unique because of the initial and boundary conditions. $\endgroup$ – REVB Jun 16 '18 at 2:48
  • $\begingroup$ I tried using Plot[(sol[3, x]) // Evaluate, {x, 0, 1}] and changing to {t, 0, 5} and got something more along the lines of what I obtained by the method I described before. $\endgroup$ – REVB Jun 16 '18 at 2:55
  • $\begingroup$ The solution is unique! In my plot you see the solution for different times. $\endgroup$ – Ulrich Neumann Jun 16 '18 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.