Message Boards Message Boards

How does one plot a PDE using the Wolfram Language?

Posted 8 years ago

Hello Everyone!

I am trying to plot the solution to the following PDE but am having problems telling Mathematica how to do this. Does anyone have any suggestions? Greatly appreciated!

Utt = Uxx, -Infinity < x < Infinity, t > 0

u(0,x) = 0

ut(0,x) = Piecewise[{1, 1<x<2} , {0, everywhere else}]

Plot for t = 0, 0.25, 0.5, 0.75, 1, 1.25

Thanks!

POSTED BY: Ben Harris
3 Replies

Utt = Uxx, -Infinity < x < Infinity, t > 0

u(0,x) = 0

ut(0,x) = Piecewise[{1, 1<x<2} , {0, everywhere else}]

Blockquote

Should your first boundary condition be u(t,0) = 0 ?

POSTED BY: Murray Eisenberg

Perhaps you meant

ic2 = Derivative[1, 0][u][0, x] == 
  Piecewise[{{1, 1 < x < 2}, {0, x <= 1}, {0, x >= 2}}]

The function f is undefined. You cannot make numerical computations with it.

POSTED BY: Gianluca Gorni
Posted 8 years ago

UPDATE: I have gotten this far using a model of the Telegraph equation, but below it I will post the errors I am getting. Any suggestions?

ic1 = u[0, x] == 0
ic2 = D[u[t, x], {t, 1}] == 
  Piecewise[{{1, 1 < x < 2}, {0, x <= 1}, {0, x >= 2}}]
 pde1 = NDSolveValue[{D[u[t, x], {t, 2}] == 
    D[u[t, x], {x, 2}, ic1, ic2], 
   DirichletCondition[u[t, x] == f[-10], x == -10], 
   DirichletCondition[u[t, x] == f[10], x == 10]}, 
  u, {t, -10, 10}, {x, 0, 2}]

framesTEQ = 
  Table[Plot[pde1[t, x], {x, -10, 10}, PlotRange -> {-1, 1.3}], {t, 
    0, .25, 0.5, .75, 1, 1.25}];
Manipulate[framesTEQ[[i]], {{i, 3, "time"}, 1, Length[framesTEQ], 1}, 
 SaveDefinitions -> True]

ERRORS:

General::ivar: u[0,x]==0 is not a valid variable. >>

NDSolveValue::bcedge: Boundary condition u[t,10]==f[10] is not specified on a single edge of the boundary of the computational domain. >>
POSTED BY: Ben Harris
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract