I am getting the error as " Not enough input arguments " and " Failure in initial objective function evaluation. FSOLVE cannot continue". Please suggest me possible solutions.

조회 수: 3 (최근 30일)
Efu(1)=0;
Efe(1)=0;
landau_levels=@(EF, m, B) ( (1 / (2 * B)) * ((EF^2 / m^2) - 1) );
amuu = 5.0;
amud = 5.0;
amue = 0.511;
amus = 150.0;
hbarc = 197.3271;
fscon = 137.036;
Bcs = ( 3 * (fscon^0.5) * (amus^2) ) / (hbarc^1.5);
Bcu = ( 1.5 * (fscon^0.5) * (amuu^2) ) / (hbarc^1.5);
Bcd = ( 3 * (fscon^0.5) * (amud^2) )/ (hbarc^1.5);
Bce = ( (fscon^0.5) * (amue^2) )/ (hbarc^1.5);
Bc = (5e17 * 1.95e-14);
Bds = Bc / Bcs;
Bdu = Bc / Bcu;
Bdd = Bc / Bcd;
Bde = Bc / Bce;
Efs(1)=400;
Efu_ini= 300;
Efe_ini= 20;
Efd=Efs(1);
nu_u= landau_levels(Efu_ini,amuu,Bdu);
nu_e= landau_levels(Efe_ini,amue,Bde);
nu_d= landau_levels(Efd(1),amud,Bdd);
nu_s= landau_levels(Efs(1),amus,Bds);
pF_u= sqrt( max( (Efu_ini^2 - amuu^2 * (1 + 2 * nu_u * Bdu)), 0) );
pF_e= sqrt( max( (Efe_ini^2 - amue^2 * (1 + 2 * nu_e * Bde)), 0) );
pF_d= sqrt( max( (Efd(1)^2 - amud^2 * (1 + 2 * nu_d * Bdd)), 0) );
pF_s= sqrt( max( (Efs(1)^2 - amus^2 * (1 + 2 * nu_s * Bds)), 0) );
n_u = (2 / (3 * pi^2)) * pF_u^3;
n_e = (2 / (3 * pi^2)) * pF_e^3;
n_d = (2 / (3 * pi^2)) * pF_d^3;
n_s = (2 / (3 * pi^2)) * pF_s^3;
fun= @(n_s, n_u, n_d, n_e, Efu_ini, Efe_ini, Efd) root2d(n_s, n_u, n_d, n_e, Efu_ini, Efe_ini, Efd);
x0=[300,20];
x= fsolve( fun,x0)
function F = root2d(n_s, n_u, n_d, n_e , Efu_ini ,Efe_ini ,Efd)
eq1= (2 / 3) * n_u - (1 / 3) * (n_d + n_s) - n_e ;
eq2= Efu_ini + Efe_ini - Efd ;
end

답변 (2개)

Matt J
Matt J 2025년 4월 7일
편집: Matt J 2025년 4월 7일
It is not clear from your code which variables are meant to be the 2 unknowns, and which are constants. In any case, your fun needs to receive the unknowns as a vector, not as separate arguments.
  댓글 수: 5
Arunkarthiheyan
Arunkarthiheyan 2025년 4월 9일
@Torsten I am getting the values of x as the initial values 300 and 20.
The logical error says the following
"No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
value of the function tolerance."
Can you help me fix this?
Torsten
Torsten 2025년 4월 9일
편집: Torsten 2025년 4월 9일
Which variables are the unknowns (I named them Efu and Efe) in this part of the code where the equations to be solved are deduced ? If you don't know what I mean: can you write down the equations you are trying to solve in a mathematical way and mark the two unknowns ?
landau_levels=@(EF, m, B) ( (1 / (2 * B)) * ((EF^2 / m^2) - 1) );
amuu = 5.0;
amud = 5.0;
amue = 0.511;
amus = 150.0;
hbarc = 197.3271;
fscon = 137.036;
Bcs = ( 3 * (fscon^0.5) * (amus^2) ) / (hbarc^1.5);
Bcu = ( 1.5 * (fscon^0.5) * (amuu^2) ) / (hbarc^1.5);
Bcd = ( 3 * (fscon^0.5) * (amud^2) )/ (hbarc^1.5);
Bce = ( (fscon^0.5) * (amue^2) )/ (hbarc^1.5);
Bc = (5e17 * 1.95e-14);
Bds = Bc / Bcs;
Bdu = Bc / Bcu;
Bdd = Bc / Bcd;
Bde = Bc / Bce;
Efs(1)=400;
Efd=Efs(1);
nu_u= landau_levels(Efu_ini,amuu,Bdu);
nu_e= landau_levels(Efe_ini,amue,Bde);
nu_d= landau_levels(Efd(1),amud,Bdd);
nu_s= landau_levels(Efs(1),amus,Bds);
pF_u= sqrt( max( (Efu_ini^2 - amuu^2 * (1 + 2 * nu_u * Bdu)), 0) );
pF_e= sqrt( max( (Efe_ini^2 - amue^2 * (1 + 2 * nu_e * Bde)), 0) );
pF_d= sqrt( max( (Efd(1)^2 - amud^2 * (1 + 2 * nu_d * Bdd)), 0) );
pF_s= sqrt( max( (Efs(1)^2 - amus^2 * (1 + 2 * nu_s * Bds)), 0) );
n_u = (2 / (3 * pi^2)) * pF_u^3;
n_e = (2 / (3 * pi^2)) * pF_e^3;
n_d = (2 / (3 * pi^2)) * pF_d^3;
n_s = (2 / (3 * pi^2)) * pF_s^3;

댓글을 달려면 로그인하십시오.


Star Strider
Star Strider 2025년 4월 7일
Note that ‘F’ is the output of ‘root2d’, however ‘F’ is nowhere defined as a calculation result in that code:
function F = root2d(n_s, n_u, n_d, n_e , Efu_ini ,Efe_ini ,Efd)
eq1= (2 / 3) * n_u - (1 / 3) * (n_d + n_s) - n_e ;
eq2= Efu_ini + Efe_ini - Efd ;
end
That might be something to consider fixing.
.
  댓글 수: 3
Star Strider
Star Strider 2025년 4월 9일
The fsolve function is a root-finder, that is it finds the values of the parameters where the function crosses or equals zero. With your function, fsolve finds a minimum, however it may not be able to find a root.
You might be able to use either contour or fimplicit to see graphically if it has any roots.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by