Help with MATLAB BVP4C: Solving Non-Newtonian Equations

  • Context: MATLAB 
  • Thread starter Thread starter Juggler123
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The forum discussion centers on resolving a singular Jacobian error encountered while using MATLAB's bvp4c function to solve a system of five non-Newtonian differential equations. The user is implementing the function nonNewtonian with a test case of n=1 but faces issues when attempting to explore solutions for other values of n. The error message indicates that the collocation equations cannot be solved due to a singular Jacobian matrix, suggesting potential issues with the boundary conditions or the initial guess provided to the solver.

PREREQUISITES
  • Familiarity with MATLAB programming and syntax
  • Understanding of boundary value problems (BVP) and the bvp4c function
  • Knowledge of differential equations, particularly non-Newtonian fluid dynamics
  • Experience with Jacobian matrices and their significance in numerical methods
NEXT STEPS
  • Investigate the structure and properties of the Jacobian matrix in the context of the bvp4c function
  • Explore alternative initial guesses for the boundary value problem using bvpinit
  • Review MATLAB documentation on bvp4c and common pitfalls in solving BVPs
  • Test the implementation with simpler systems to ensure the solver's functionality before applying it to complex equations
USEFUL FOR

Mathematicians, engineers, and researchers working with MATLAB who are solving boundary value problems, particularly in the field of fluid dynamics and non-Newtonian materials.

Juggler123
Messages
80
Reaction score
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
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?
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K