Hi all I am trying to plot a second order BVP in MATLAB

1 回表示 (過去 30 日間)
Michael Hughes
Michael Hughes 2021 年 8 月 11 日
コメント済み: darova 2021 年 8 月 12 日
Me and my friend are trying to plot the following BVP:
-(L)* ((d^2)y/d(x^2)) - 5*(dy/dx)/x + (a*y)/L + (c/(2*L))*(x^4)*(y^3) = 0
Assume L=6*10^-8, a=44 and c=45 (but all 3 letters can be any constant). y is a function with respect to x. The boundary conditions are y(0)=0 and y(1)=C. Where C is some constant.
Me and my friend have tried ODE45 and bvp4c but doesn't work because of (c/(2*L))*(x^4)*(y^3) and 5*(dy/dx)/x, which gives us the jacobien error.
The following below is the code we tried to use for bvp4c, we used 2 functions and one sript at the end:
Function 1:
function yprime = secondode2(x,y)
%SECONDODE: Computes the derivatives of y 1 and y 2,
%as a colum vector
a=44; %Temperature dependent bulk constant
c=45; %
L=6*10^-8; %Elastic constant in the one constant approximation (splay=twist=bend)
yprime = [y(2); c/(2*L)*x^4*y(1)^3 + a*y(1)/L - 5*y(2)/x];
end
Function 2, for boundary conditions:
function res = boundary_conditions1(ya,yb)
res = [ya(2)
yb(1) - 1/2];
end
Here is our sript:
guess = [1/2; 0];
xmesh = linspace(0,1,5);
solinit = bvpinit(xmesh, guess);
S = [0 0; 0 5];
options = bvpset('SingularTerm',S);
sol = bvp4c(@secondode2, @boundary_conditions1, solinit,options);
plot(sol.x,sol.y(1,:))
hold on
title('S(r) ODE')
xlabel('x');
ylabel('solution y');
Errors:
Error using bvp4c (line 248)
Unable to solve the collocation equations -- a singular Jacobian encountered.
Error in bvp_four_c (line 7)
sol = bvp4c(@secondode2, @boundary_conditions1, solinit,options);
Would you please be able to help us in this problem, because we have tried nearly everything?

回答 (1 件)

darova
darova 2021 年 8 月 11 日
Here is the problem
  2 件のコメント
Michael Hughes
Michael Hughes 2021 年 8 月 12 日
Hi I am very sorry.
I have tried changing the the linespace from:
xmesh = linspace(0,1,5);
to
xmesh = linspace(0,1,1000);
The same errors occur.
I don't understand why linespace is a problem or why - 5*(dy/dx)/x is a problem. Could explain why MATLAB in stuggling please in more detail?
darova
darova 2021 年 8 月 12 日
The problem is not linespace but starting point . Starting point can't be zero because there is division by x

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by