4
$\begingroup$

I'm trying to solve 2D Fick's law of diffusion from the boundaries of a triangle (future shapes will include more complex implicit regions). I'm able to model diffusion without time in complex implicit regions. I'm also able to model diffusion with time over a rectangular region. However, once I use the implicit region function along with time in Fick's law, I get the error message

NDSolve::femimvr: The number of independent variables 3 ({x,y,t}) does not match the embedding dimension 2 >>

Is there any way to correct my code for this error? I've included the code below.

\[CapitalOmega] = ImplicitRegion[(x + y <= 10), {{x, 0, 10}, {y, 0, 10}}];

Dif = 0.0000072;

eq1 = D[u[x, y, t], t] == Dif*(D[u[x, y, t], x, x] + D[u[x, y, t], y, y]) - 1.2;

sol = NDSolve[{eq1, DirichletCondition[u[x, y, t] == 100, x + y == 10], u[x, 0, t] == 100,
      u[0, y, t] == 100, u[x, y, 0] == 100}, u, {x, y} \[Element] \[CapitalOmega], {t, 0, 1000}];

Animate[ContourPlot[u[x, y, t] /. sol, {x, y} \[Element] \[CapitalOmega], 
      PlotRange -> {0, 100}, ClippingStyle -> Automatic, 
      ColorFunction -> "DarkRainbow", PlotLegends -> Automatic], {t, 0, 1000}]
$\endgroup$
5
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – bbgodfrey
    Commented Jan 23, 2015 at 23:21
  • $\begingroup$ For future reference, please format your code according to the guidelines in meta1027. Doing so will encourage more people to consider your question. $\endgroup$
    – bbgodfrey
    Commented Jan 23, 2015 at 23:21
  • $\begingroup$ The error message is totally unhelpful, but the problem is that t has to come first for some reason. You have to make it u[t, x, y] everywhere and do NDSolve[..., u, {t, 0, 1000}, {x, y} ∈ Ω], then it works. $\endgroup$
    – user484
    Commented Jan 24, 2015 at 4:32
  • 1
    $\begingroup$ For now t needs to be in the first position. Future versions all it in the last position as well. $\endgroup$
    – user21
    Commented Jan 24, 2015 at 9:36
  • $\begingroup$ @Rahul, the fact that the error message is unhelpful, is because it was not intended to fail in the first place; bugs are such an inconvenience ;-) $\endgroup$
    – user21
    Commented Jan 24, 2015 at 9:37

1 Answer 1

4
$\begingroup$

[Udpate: simplified DirichletCondition, omitted unnecessary Method specification.]

Following the Transient PDE examples in Finite Element Programming, I came up with this:

Ω = ImplicitRegion[(x + y <= 10), {{x, 0, 10}, {y, 0, 10}}];

Dif = 0.0000072;

eq1 = D[u[t, x, y], t] == Dif*Laplacian[u[t, x, y], {x, y}] - 1.2;

sol = NDSolve[{eq1, DirichletCondition[u[t, x, y] == 100, True], 
   u[0, x, y] == 100}, 
  u, {t, 0, 1000}, {x, y} ∈ Ω]
$\endgroup$
4
  • 1
    $\begingroup$ It should also work without the Method specification. $\endgroup$
    – user21
    Commented Jan 24, 2015 at 9:39
  • $\begingroup$ @MichaelE2 In fact, based on the observation by @user21, the only substantive difference between your solution and that in the Question seems to be the order of variables in u[t, x, y]. But, why should that matter? $\endgroup$
    – bbgodfrey
    Commented Jan 24, 2015 at 13:52
  • $\begingroup$ @bbgodfrey According to the 2nd comment to the question by user21, it seems to be an unintended restriction (bug) that the time variable precede the spatial variables. The error message made me think it might be a space v. time issue, but as I indicated, I sort of stumbled on a working solution by starting with a working example from the docs and adapting it. $\endgroup$
    – Michael E2
    Commented Jan 24, 2015 at 14:16
  • $\begingroup$ I am not sure the solution is satisfactory though: if I try ContourPlot[ u[t, x, y] /. sol[[1]] /. t -> 1000, {x, y} \[Element] \[CapitalOmega]] I get a very rough function. Or did I miss something? $\endgroup$
    – chris
    Commented Apr 24, 2021 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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