1
$\begingroup$

So, in my 1D diffusion equation, everything works as I would expect.

    eq = \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(p[x, t]\)\) == 
   diffusionrate*Laplacian[p[x, t], {x}];

diffusionrate = 1;

iv = {p[x, 0] == 0, p[0, t] == Sin[t], p[1, t] == 0};

s1D = NDSolve[{eq, iv}, {p[x, t]}, {x, 0, 1}, {t, 0, 10}]

Plot3D[p[x, t] /. s1D, {x, 0, 1}, {t, 0, 10}]

And gives a nice result

enter image description here

But when I try to do this in 3D, I expand on the above like so,

eq2 = \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(p[x, y, z, t]\)\) == 
   diffusionrate*Laplacian[p[x, y, z, t], {x, y, z}];

diffusionrate = 1;

iv = {p[x, y, z, 0] == 0, p[0, 0, 0, t] == Sin[t], p[1, 1, 1, t] == 0};

s3D = NDSolve[{eq2, iv}, {p[x, y, z, t]}, {x, 0, 1}, {y, 0, 1}, {z, 0,
    1}, {t, 0, 10}]

And I get the error

NDSolve::bcedge: Boundary condition p[0,0,0,t]==Sin[t] is not specified on a single edge of the boundary of the computational domain.

But, I think this is defined along the boundary. I don't understand why it isn't working and why I'm getting this error.

$\endgroup$
6
$\begingroup$

You'd need to specify boundary conditions and initial conditions, for example like so:

eq2 = Derivative[0,0,0,1][p][x,y,z,t] == 
   Laplacian[p[x,y,z,t], {x,y,z}];
iv = {p[x, y, z, 0] == 0};
bcs = {p[0, y, z, t] == Sin[t], p[1, y, z, t] == 0};
Dynamic["time: " <> ToString[CForm[currentTime]]]
s3D = NDSolveValue[{eq2, iv, bcs}, 
  p, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, {t, 0, 10}, 
  Method -> {"MethodOfLines", 
    "SpatialDiscretization" -> {"FiniteElement", 
      "MeshOptions" -> {"MaxCellMeasure" -> 0.01}}}
  , EvaluationMonitor :> (currentTime = t;)
  ]
| improve this answer | |
$\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.