I'm trying to solve the following partial differential equation:

Mass Diffusion Equation

With the boundary conditions:

enter image description here

I could use another way to resolve this, like the finite volume method, but after I solve the equation I want to manipulate the Dm term and see what happens to the results. The equation is responsible to return the values of humidity in soybeans, and Dm term is the mass diffusion coefficient.

Here's what I've tried:

D[m[r, t], t] == 1*10^-7*(D[m[r, t], r, r] + 2/r *D[m[r, t], r]),
m[r, 0] ==   0.5, 
m[1, t] ==  0.2}, m, {t, 0, 5}, {r, 0, 1}]

And it returned:

NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {(m^(0,1))[r,t]==((2 (m^(1,0))[r,t])/r+(m^(2,0))[r,t])/10000000,True,True}. >>

First things first, I'm just trying to solve and plot the PDE with Dm = 1*10 ^-7, and after that I'll try use the function Manipulate to change Dm (Since i haven't been able to solve the equation, I erased the manipulate and plot code, baby steps)

Since I'm a new mathematica user, I don't know what else to do, if anyone could help me I would be grateful!

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) 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! $\endgroup$
    – Michael E2
    Jun 25 '16 at 22:58
  • 2
    $\begingroup$ Do Clear[m] and try again. You probably have some left-over downvalues for m, that could have come from doing m = ... instead of m == ... or similar. $\endgroup$ Jun 25 '16 at 23:00
  • 1
    $\begingroup$ What about m[1,0]? Boundary condition says it should be 0.2, but initial condition says it's 0.5 $\endgroup$
    – BlacKow
    Jun 26 '16 at 2:15

Your initial and boundary conditions are inconsistent. Check NDSolve::ibcinc how to avoid that.

Also I think you need additional boundary condition. Anyway I'm not sure your constant functions are good for boundary/initial conditions.

The r domain includes zero and it gives error in your $1/r$ term.

Using the recipe from above link and adding another boundary condition:

sol = NDSolve[{D[m[r, t], 
     t] == 1*10^-7*(D[m[r, t], r, r] + 2/r*D[m[r, t], r]), 
   m[r, 0] == 0.5, m[1, t] == 0.2 + 0.3 Exp[-100 t], 
   m[0.001, t] == 0.5}, m, {t, 0, 5}, {r, 0.001, 1}]

f[r_, t_] := (m /. sol[[1, 1]])[r, t];

Plot3D[f[r, t], {t, 0, 5}, {r, 0.01, 1}, PlotRange -> Full]

enter image description here

  • $\begingroup$ Thanks @BlacKow ! After I posted here, I saw NDSolve::ibcinc how to avoid that inconsistency. The problem is: I assume that, at any time t after the process start, the humidity at the surface is 20%, and I want to know how it changes with r and t. I don't know what else boundary condition add, since it's a sphere and at any time 't' it's surface has M = 0.5. Also, what does this line means? f[r_, t_] := (m /. sol[[1, 1]])[r, t]. Thanks a lot for your time and effort! $\endgroup$
    – G. Dal
    Jun 28 '16 at 0:49
  • $\begingroup$ @G.Dal In your spherical coordinates the boundary in your r domain is two points: $r=0$ and $r=1$ the $r=0$ point has singularity because of your $1/r$ term, so I used $r=0.01$. You can try solving in $x,y,z$ coordinates tosee if NDSolve would behave better. $\endgroup$
    – BlacKow
    Jun 28 '16 at 2:47
  • $\begingroup$ NDSolve return rules. /. is the same as `ReplaceAll', more here $\endgroup$
    – BlacKow
    Jun 28 '16 at 2:49
  • $\begingroup$ Thanks a lot @BlacKow! Is there any way Icould use Manipulate[] with this code? I want to change the term Dm (it's the 1*10^-7 value in the previous code) from 1*10^-6 to 1*10^-9, and see graphically the influence of the term. My sphere has 1*10^-3m radius (Already changed the code), and i want to change it too. I'm a little bit familiar with the function Manipulate, but i couldn't use it with the NDSolve and plot all together. $\endgroup$
    – G. Dal
    Jun 30 '16 at 1:00
  • $\begingroup$ @G.Dal You will need to precalculate solutions for different parameters (using a Table for example) and then Manipulate over the table index. $\endgroup$
    – BlacKow
    Jun 30 '16 at 14:21

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.