Help with MATLAB BVP4C: Solving Non-Newtonian Equations

  • MATLAB
  • Thread starter Juggler123
  • Start date
  • Tags
    Matlab
In summary, the conversation is about solving a system of differential equations using MATLAB and receiving an error message about a singular Jacobian matrix. The person is using a test case of n=1 and is seeking help with finding a solution for other values of n. They are also asking for suggestions on how to test the code on a system with a known well-behaved solution.
  • #1
Juggler123
83
0
Hi all, (Don't mean to spam, meant to put this in General Math not General Engineering!)
I'm running the following code in MATLAB:



function M = nonNewtonian(~)

M = bvpinit(linspace(0,10,301),@VKinit);
sol = bvp4c(@VK,@VKbc,M);

figure;
hold all;
plot(sol.x,sol.y(2,:));
plot(sol.x,sol.y(4,:));
hold off;
xlabel('\zeta')
xlabel('\zeta')
hleg = legend('F\prime','G\prime',...
'Location','NorthEast'); %#ok<NASGU>

figure;
hold all;
plot(sol.x,sol.y(1,:));
plot(sol.x,sol.y(3,:));
plot(sol.x,(-1)*sol.y(5,:));
hold off;
xlabel('\zeta')
hleg = legend('F','G','-H',...
'Location','East'); %#ok<NASGU>


function yprime = VK(x,y)

n=1;

yprime = [ y(2)
n^(-1)*((y(2)^(2)+y(4)^(2))^((n-1)/2))^(-1)*((y(1)^(2)-y(3)^(2)+(y(5)+((1-n)/(n+1))*y(1)*x)*y(2))*(1+(n-1)*(y(2)^(2)+y(4)^2)^(-1)*y(4)^(2))-(n-1)*y(2)*y(4)*(y(2)^(2)+y(4)^(2))^(-1)*(2*y(1)*y(3)+(y(5)+((1-n)/(n+1))*y(1)*x)*y(4)))
y(4)
n^(-1)*((y(2)^(2)+y(4)^(2))^((n-1)/2))^(-1)*((2*y(1)*y(3)+(y(5)+((1-n)/(n+1))*y(1)*x)*y(4))*(1+(n-1)*(y(2)^(2)+y(4)^2)^(-1)*y(2)^(2))-(n-1)*y(2)*y(4)*(y(2)^(2)+y(4)^(2))^(-1)*(y(1)^(2)-y(3)^(2)+(y(5)+((1-n)/(n+1))*y(1)*x)*y(2)))
-2*y(1)-(1-n)/(n+1)*x*y(2)];

function res = VKbc(ya,yb)


res = [ya(1);ya(3)-1;ya(5);yb(2)-(yb(5)*yb(1));yb(4)-(yb(5)*yb(3))];


function yinit = VKinit(~)

yinit = [0;0;1;0;0];



but receive the following error message:

? Error using ==> bvp4c at 252
Unable to solve the collocation equations -- a singular Jacobian encountered.

Error in ==> nonNewtonian at 4
sol = bvp4c(@VK,@VKbc,M);

I struggle to see where I am going wrong?! Five differential equations and five boundary conditions, should be fine? I'm using n=1 as a test case here. I know the solutions to this system for n=1 but would like to look into the solutions when n is not equal to one.

Any help anyone could give would be greatly appreciated.
Thanks!
 
Physics news on Phys.org
  • #2
That code is almost impossible to decipher, but, as MATLAB says, the problem is that your Jacobian matrix is singular. Have you tried testing this on a system that you know has a well behaved solution?
 

1. What is MATLAB BVP4C?

MATLAB BVP4C is a function in MATLAB that is used to solve boundary value problems (BVPs) for ordinary differential equations (ODEs). It uses a finite difference method to numerically solve the equations and find the unknown variables.

2. What are Non-Newtonian equations?

Non-Newtonian equations are a type of differential equation that describe the non-linear behavior of fluids, such as viscosity and shear stress, that cannot be explained by Newton's law of viscosity. These equations are commonly used in fluid mechanics and are more complex than the traditional Newtonian equations.

3. How does MATLAB BVP4C solve Non-Newtonian equations?

MATLAB BVP4C uses a numerical method called finite difference method to solve Non-Newtonian equations. This method breaks down the equations into smaller parts and approximates the solution at each point by using the values of neighboring points. It then iteratively improves the approximation until a satisfactory solution is reached.

4. What are some common applications of MATLAB BVP4C for Non-Newtonian equations?

MATLAB BVP4C is commonly used in various fields, such as fluid mechanics, chemical engineering, and materials science, to solve Non-Newtonian equations. Some specific applications include modeling the behavior of polymers, suspensions, and non-Newtonian fluids in pipes or channels.

5. Are there any limitations to using MATLAB BVP4C for Non-Newtonian equations?

While MATLAB BVP4C is a powerful tool for solving Non-Newtonian equations, it does have some limitations. It may not be suitable for highly complex equations or systems with a large number of variables. Additionally, the accuracy of the solution may be affected by the choice of boundary conditions and the step size used in the numerical method.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
999
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
126
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
572
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top