필터 지우기
필터 지우기

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 CenterFile Exchange에서 Boundary Value Problems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by