Mathematica: Help with NDSolve Error

In summary, the Mathematica user is receiving a NDSolve error when trying to solve a differential equation. The issue is that the boundary and initial conditions are not consistent, and the user may need to adjust parameters or use additional methods to obtain an accurate solution.
  • #1
PenguInABox
1
0
Mathematica: Help with NDSolve Error!

Hello All,

I am attempting to set up a model of an experiment I am running, but I keep getting the following error:
"NDSolve::ibcinc: Warning: Boundary and initial conditions are inconsistent."

However, I have checked all of my boundary conditions, and as far as I can tell they are compatible with the initial conditions. Can you see what I am missing?

Here is my script up to the offending line:


(*Clear Scope*)
ClearAll["Global`*"];
Clear[Derivative];
ClearGlobal[];
Remove["Global`*"];

(*Units:
length - mm
concentration - pmol/mm^3=uM
time - s
*)

(*Define Global Parameters*)
plotPoints=150;

(*Define Time Spans*)
inactiveRunTime=1000;(*time in time units to run model before activating Amplifier*)
activeRunTime=10;(*time in time units to run model after activating Amplifier*)

(*Define Gel Parameters*)
gelWidth=100;(*units:length*)
gelLength=100;(*units:length*)
gelDepth=1;(*units:length*)
sourceX=gelWidth/3;(*units:length*)
sourceY=gelLength/3;(*units:length*)
sourceZ=gelDepth/2;(*units:length*)
sourceWidth=10;(*units:length*)
sourceLength=5;(*units:length*)
sourceDepth=.9*gelDepth;(*units:length*)

(*Define Species Parameters*)
inputConcentration=1;(*units:concentration*)
dW25=150*10^-6;(*units:length^2/time*)
colorW25=(RGBColor[0,0,1]&);

(*Define Utility Functions*)
InputFunction[x_,y_,z_,cx_,cy_,cz_,w_,l_,d_]:=(1-1/(1+x^2))*(1-1/(1+(gelWidth-x)^2))*(1-1/(1+y^2))*(1-1/(1+(gelLength-y)^2))*(1-1/(1+z^2))*(1-1/(1+(gelDepth-z)^2))*Exp[-(x-cx)^2/(2*(w/2)^2)-(y-cy)^2/(2*(l/2)^2)-(z-cz)^2/(2*(d/2)^2)];

(*Construct Inputs*)
W25t0[x_,y_,z_]:=inputConcentration * InputFunction[x,y,z,sourceX,sourceX,sourceZ,sourceWidth,sourceLength,sourceDepth];

Plot3D[W25t0[x,y,sourceZ],{x,0,gelWidth},{y,0,gelLength},PlotRange -> All,PlotPoints -> plotPoints,Mesh->None]

diffuseInputs = NDSolve[{D[W25tA[t,x,y,z],t] == dW25*(D[W25tA[t,x,y,z],x,x]+D[W25tA[t,x,y,z],y,y]+D[W25tA[t,x,y,z],z,z]), W25tA[0,x,y,z]==W25t0[x,y,z],W25tA[t,0,y,z]==0,W25tA[t,gelWidth,y,z]==0,W25tA[t,x,0,z]==0,W25tA[t,x,gelLength,z]==0,Derivative[0,0,0,1][W25tA][t,x,y,0]==0,Derivative[0,0,0,1][W25tA][t,x,y,gelDepth]==0 },{W25tA},{t,0,inactiveRunTime},{x,0,gelWidth},{y,0,gelLength},{z,0,gelDepth}];
 
Physics news on Phys.org
  • #2
The error occurs on the last line, when I try to solve the differential equation using NDSolve. The main issue here is that your boundary and initial conditions are not compatible. The boundary conditions need to be consistent with the initial condition in order for the problem to be solvable. For example, if your initial condition specifies a particular value of the solution at time t=0, then your boundary conditions need to ensure that the solution does not deviate from this value. In addition, you may also need to adjust some of your parameters to get the desired behavior. For instance, if your diffusion coefficient is too low, then it may take too long for the system to reach equilibrium, resulting in an inconsistent solution. Finally, you may need to use additional methods to ensure that the solution is accurate. For instance, you could use MeshRefinement to refine the grid and increase the accuracy of the solution. I hope this helps!
 

What is Mathematica?

Mathematica is a powerful computational software program used for solving mathematical problems, creating visualizations, and conducting data analysis. It is commonly used by scientists, engineers, and mathematicians for its advanced mathematical and programming capabilities.

What is NDSolve in Mathematica?

NDSolve is a built-in function in Mathematica that is used for numerically solving differential equations. It can handle a wide range of differential equations, including ordinary differential equations (ODEs), partial differential equations (PDEs), and differential-algebraic equations (DAEs).

What does the error "NDSolve::ndsz" mean?

This error indicates that the numerical solution to the differential equation cannot be computed due to a singularity, such as a division by zero or an invalid initial condition. It is important to carefully check the input parameters and adjust them accordingly to resolve this error.

How can I troubleshoot NDSolve errors in Mathematica?

There are a few steps you can take to troubleshoot NDSolve errors in Mathematica. First, double check your input parameters and initial conditions to ensure they are correct. You can also try adjusting the numerical method used by NDSolve or increasing the precision or accuracy of the solution. Additionally, you can consult the Mathematica documentation or search online for solutions to specific error messages.

Can I visualize the solution of a differential equation in Mathematica?

Yes, Mathematica has built-in visualization tools that can be used to plot the solution of a differential equation. You can use functions such as Plot or ParametricPlot to create 2D plots, or use functions like Plot3D or ParametricPlot3D to create 3D plots. You can also use the Manipulate function to create interactive visualizations that allow you to adjust parameters and see the effects on the solution in real time.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
140
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
227
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
266
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
877
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Back
Top