Message Boards Message Boards

0
|
305 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Deriving Cottrell equation using Fick's 2nd law of diffusion

Posted 19 days ago

Hello, I am trying to solve Fick's 2nd law of diffusion in Mathematica. The initial and boundary conditions are shown in the image attached. The only difference is that the concentration at t = 0 s is defined by a function of x. I have attached the Mathematica code below and the errors I get while solving the problem. Thank you enter image description here enter image description here

(*Define the PDE*)
pde = D[F[x, t], t] == 0.000051*D[F[x, t], {x, 2}]

(*Define the initial and boundary conditions*)
ic = F[x, 0] == Co
bc = {F[0, t] == 0, F[x, t] == Co

(*Solve the PDE*)
sol = NDSolve[{pde, ic, bc}, F, {x, 0, 1}, {t, 0, 10}];

(*Plot the solution*)
Plot3D[F[x, t] /. sol, {x, 0, 1}, {t, 0, 10}]
POSTED BY: Saurabh Pathak
2 Replies
Posted 19 days ago

Boundary and initial conditions are inconsistent, and they are the usual suspect for warning messages.

tMin = 0; tMax = 10;
xMin = 0; xMax = 1;

(*Solve the PDE*) 
sol = NDSolve[{
   D[u[x, t], t] == 0.000051*D[u[x, t], {x, 2}],
   u[x, tMin] == 0.0,
   u[xMin, t] == Sin[t],
   u[xMax, t] == 0.0}
  , u
  , {t, tMin, tMax}, {x, xMin, xMax}]

(*Plot the solution*)
Plot3D[u[x, t] /. sol, {x, xMin, xMax}, {t, tMin, tMax}, 
 PlotRange -> All, AxesLabel -> Automatic]
POSTED BY: Sangdon Lee
Posted 19 days ago

Thank you for the answer, I worked with the initial and boundary conditions mentioned in the answer. Another problem I am facing is that, my initial condition is an incomplete gamma function of x. and at xmin and at all times the function is 0. and also at xmax and all times t the concentration is constants value which is 0.001 M. Whenever I apply this the Mathematica shows error message.

In[5]:= tMin = 0; tMax = 10;
xMin = 0; xMax = 1;

(*Solve the PDE*)
sol = NDSolve[{D[u[x, t], t] == 0.000051*D[u[x, t], {x, 2}], 
   u[x, tMin] == 
    1.1193194537721065` (0.892979511569249` - (
       0.3333333333333334` (x^3)^(2/3)
         Gamma[0.3333333333333333`, 4.299881111111103`*^17 x^3])/x^2),
    u[xMin, t] == 0, u[xMax, t] == 0.001}, 
  u, {t, tMin, tMax}, {x, xMin, xMax}]

(*Plot the solution*)
Plot3D[u[x, t] /. sol, {x, xMin, xMax}, {t, tMin, tMax}, 
 PlotRange -> All, AxesLabel -> Automatic]

During evaluation of In[5]:= Power::infy: Infinite expression 1/0.^2 encountered.

During evaluation of In[5]:= Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered.

During evaluation of In[5]:= NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`.

During evaluation of In[5]:= Power::infy: Infinite expression 1/0.^2 encountered.

During evaluation of In[5]:= Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered.

During evaluation of In[5]:= NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`.

Out[7]= NDSolve[{
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", 
RowBox[{"0", ",", "1"}], ")"}],
Derivative],
MultilineFunction->None]\)[x, t] == 0.000051 
\!\(\*SuperscriptBox[\(u\), 
TagBox[
RowBox[{"(", 
RowBox[{"2", ",", "0"}], ")"}],
Derivative],
MultilineFunction->None]\)[x, t], 
  u[x, 0] == 
   1.11932 (0.89298 - (
      0.333333 (x^3)^(2/3) Gamma[0.333333, 4.29988*10^17 x^3])/x^2), 
  u[0, t] == 0, u[1, t] == 0.001}, u, {t, 0, 10}, {x, 0, 1}]

During evaluation of In[5]:= General::munfl: Exp[-157180.] is too small to represent as a normalized machine number; precision may be lost.

During evaluation of In[5]:= NDSolve::dsvar: 0.000715` cannot be used as a variable.

During evaluation of In[5]:= ReplaceAll::reps: {NDSolve[{(u^(0,1))[0.0000715,0.000715]==0.000051 (u^(2,0))[0.0000715,0.000715],u[0.0000715,0]==0.999529,u[0,0.000715]==0,u[1,0.000715]==0.001},u,{0.000715,0,10},{0.0000715,0,1}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

During evaluation of In[5]:= NDSolve::dsvar: 0.000715` cannot be used as a variable.

During evaluation of In[5]:= ReplaceAll::reps: {NDSolve[{(u^(0,1))[0.0000715,0.000715]==0.000051 (u^(2,0))[0.0000715,0.000715],u[0.0000715,0.]==0.999529,u[0.,0.000715]==0.,u[1.,0.000715]==0.001},u,{0.000715,0.,10.},{0.0000715,0.,1.}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

During evaluation of In[5]:= General::munfl: Exp[-1.57172*10^14] is too small to represent as a normalized machine number; precision may be lost.

During evaluation of In[5]:= NDSolve::dsvar: 0.000715` cannot be used as a variable.

During evaluation of In[5]:= General::stop: Further output of NDSolve::dsvar will be suppressed during this calculation.

During evaluation of In[5]:= ReplaceAll::reps: {NDSolve[{(u^(0,1))[0.0715001,0.000715]==0.000051 (u^(2,0))[0.0715001,0.000715],u[0.0715001,0]==0.999529,u[0,0.000715]==0,u[1,0.000715]==0.001},u,{0.000715,0,10},{0.0715001,0,1}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

During evaluation of In[5]:= General::stop: Further output of ReplaceAll::reps will be suppressed during this calculation.

During evaluation of In[5]:= General::munfl: Exp[-1.25549*10^15] is too small to represent as a normalized machine number; precision may be lost.

During evaluation of In[5]:= General::stop: Further output of General::munfl will be suppressed during this calculation.
POSTED BY: Saurabh Pathak
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract