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 views (last 30 days)
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

Answers (2)

Matt J
Matt J on 7 Apr 2025
Edited: Matt J on 7 Apr 2025
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 Comments
Arunkarthiheyan
Arunkarthiheyan on 9 Apr 2025
@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 on 9 Apr 2025
Edited: Torsten on 9 Apr 2025
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;

Sign in to comment.


Star Strider
Star Strider on 7 Apr 2025
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 Comments
Star Strider
Star Strider on 9 Apr 2025
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.

Sign in to comment.

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!