0
$\begingroup$

I have simple diffusion equation with point source at c(0, t) = 1 and initial condition c(elsewhere, 0) = 0. How should I apply DSolve or NDSolve to solve the equation ? I have tried specifying my initial conditions like this:

ic = {c[x > 0, 0] == 0, c[x < 0, 0] == 0, c[0, t] == 1, Derivative[1, 0][c][1, t] == 0}

but it fails. Any suggestions?

Diff = D[c[x, t], t] - D[c[x, t], {x, 2}] == 0;
ic = {c[x > 0, 0] == 0, c[x < 0, 0] == 0, c[0, t] == 1, Derivative[1, 0][c][1,t] == 0};
s1 = NDSolve[{Diff, ic}, {c[x, t]}, {x, 0, 1}, {t, 0, 1}];
Plot3D[c[x, t] /. s1, {x, 0, 1}, {t, 0, 1}]
$\endgroup$
3
  • 3
    $\begingroup$ Have a look at DSolve and NDSOlve. There are many examples in the documentation. $\endgroup$ Aug 27, 2014 at 9:03
  • $\begingroup$ Can you show the rest of your input? $\endgroup$
    – user21
    Aug 27, 2014 at 12:10
  • $\begingroup$ Ofcourse, Diff = D[c[x, t], t] - D[c[x, t], {x, 2}] == 0; ic = {c[x > 0, 0] == 0, c[x < 0, 0] == 0, c[0, t] == 1, Derivative[1, 0][c][1, t] == 0}; s1 = NDSolve[{Diff, ic}, {c[x, t]}, {x, 0, 1}, {t, 0, 1}]; Plot3D[c[x, t] /. s1, {x, 0, 1}, {t, 0, 1}]; any advice/suggestions will be greatly appreciated! $\endgroup$
    – user19388
    Aug 27, 2014 at 13:14

1 Answer 1

1
$\begingroup$

Your syntax c[x > 0, 0] is not valid, try this:

 Diff = D[c[x, t], t] - D[c[x, t], {x, 2}] == 0;
 ic = {c[x, 0] == If[x != 0, 0, 1], c[0, t] == 1, 
      Derivative[1, 0][c][1, t] == 0};
 s1 = NDSolve[{Diff, ic}, {c[x, t]}, {x, 0, 1}, {t, 0, 1}];

You get a solution, however note that B.C. is ill conditioned in that the soluion must go sharply from zero to 1 right at the corner.

 Plot3D[c[x, t] /. s1, {x, 0, 1}, {t, 0, 1}]

enter image description here

If you look at the solution along t=0 you see it struggling to satisfy the incompatible conditions:

enter image description here

$\endgroup$

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.