4
$\begingroup$

First I would like to say that I'm a novice at Mathematica. I'm trying to solve a second order PDE with simple initial and boundary conditions but I keep getting two errors messages:

Warning: boundary and initial conditions are inconsistent.>>

and

The initial conditions did not evaluate to an array of numbers of depth 1 on the spatial grid. Initial conditions for partial differential equations should be specified as scalar functions of the spatial variables.

Please find my code below:

Deff == 2.16*10^-9;(* effective diffusivity of oxygen in the pellet [m^2/s] *)
dens == 2*10^6;(* cell density [cell] *)
qmax == 2.78*10^-17;(* maximum specific O2 consumption [mol of  oxygen/(cell)] *)
ks == 1075*10^-8;(* consumption constant [mol/m^3] *)
V == 3*10^-5; (* cartilage pellet volume *)
Ci == 1.3*10^-6; (* initial concentration of oxygen when t==0 [mol/m^3] *)
Cs == 8.5*10^-7; (* superficial oxygen concentration at x==0 [mol/m^3] *)

sol = NDSolve[{D[C[x, t], t] == Deff*D[C[x, t], x, x] - \
     (((dens*qmax)/V )*(C[x, t]/(ks + C[x, t]))), C[x, 0] == Ci,  C[0, t] == Cs, \
     Derivative[1, 0][C] [5*10^-2, t] == 0}, \
     C[x, t], {x, 0, 5*10^-2}, {t, 0, 1000}];

Actually, I don't know why I keep getting the error about the consistency of my conditions once they have physical meaning. I tried to assign zero for all initial and boundary conditions (Ci==0, Cs==0 and Derivative[1, 0][C][5*10^-2, t] == 0) and the result was a plane with no meaning. I also assign any others values for these conditions ($1,2,1000,\ldots,$ etc.) but it didn't work. From this, I can infer that my problem is about the IC and BC, but I have no idea about the reason of these errors.

I would like to say that I've already tried to solve another PDE with the same type of IC and BC and it worked. Could you please help me?

$\endgroup$

closed as off-topic by Sjoerd C. de Vries, m_goldberg, MarcoB, LLlAMnYP, Dr. belisarius Nov 4 '15 at 17:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Sjoerd C. de Vries, m_goldberg, MarcoB, LLlAMnYP, Dr. belisarius
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Replace Equal by Set in your definitions of constants. Also, this question is identical to one that you posted earlier today. Please delete the earlier question. $\endgroup$ – bbgodfrey Nov 4 '15 at 1:26
  • $\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 Nov 4 '15 at 2:13
  • $\begingroup$ It worked! Thank you so very much for your help today, @bbgodfrey. $\endgroup$ – Felipe Odaguiri Nov 4 '15 at 2:16
  • $\begingroup$ @FelipeOdaguiri Look carefully at the answer, especially at C[0,t] with t in the range 0 to 20. Is that what you expect? $\endgroup$ – bbgodfrey Nov 4 '15 at 2:44
  • $\begingroup$ yes @bbgodfrey. The concentration profiles obtained have physical meaning. Now I'm just struggling with some other issues but I don't wanna bother you again. Thanks for your help, once again $\endgroup$ – Felipe Odaguiri Nov 4 '15 at 3:09
4
$\begingroup$

Although the OP seems satisfied with the results of the correction suggested in my first comment above, I feel that I should point out a small glitch.

Plot3D[C[x, t] /. sol, {x, 0, 5*10^-2}, {t, 0, 1000}, 
    AxesLabel -> {x, t, C}, PlotRange -> All, PlotPoints -> {20, 200}]

enter image description here

A negative spike occurs near C[0, 0]. (It would not even be visible with the default setting for PlotPoints.) A blow-up of that region shows this bad behavior more clearly.

Plot3D[C[x, t] /. sol, {x, 0, 2*10^-3}, {t, 0, 10}, 
    AxesLabel -> {x, t, C}, PlotRange -> All, PlotPoints -> {20, 200}]

enter image description here

This minor problem can be eliminated by increasing resolution in t and fixing the inconsistency between C[0, t] == Cs and C[x, 0] == Ci at C[0, 0], as recommended in my second comment.

sol = First@NDSolve[{D[C[x, t], t] == Deff*D[C[x, t], x, x] - 
    (((dens*qmax)/V )*(C[x, t]/(ks + C[x, t]))), 
    C[x, 0] == Ci, C[0, t] == Cs + (Ci - Cs) Exp[-t/5], 
    Derivative[1, 0][C] [5*10^-2, t] == 0}, 
    C[x, t], {x, 0, 5*10^-2}, {t, 0, 1000}, "MaxStepSize" -> 1];
Plot3D[C[x, t] /. sol, {x, 0, 2*10^-3}, {t, 0, 10}, 
    AxesLabel -> {x, t, C}, PlotRange -> All, PlotPoints -> {20, 200}]

enter image description here

Even finer resolution in t with "MaxStepSize" -> 0.1 produces the same result.

$\endgroup$

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