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 visualizaciones (últimos 30 días)
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

Respuestas (2)

Matt J
Matt J el 7 de Abr. de 2025
Editada: Matt J el 7 de Abr. de 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 comentarios
Arunkarthiheyan
Arunkarthiheyan el 9 de Abr. de 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 el 9 de Abr. de 2025
Editada: Torsten el 9 de Abr. de 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;

Iniciar sesión para comentar.


Star Strider
Star Strider el 7 de Abr. de 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 comentarios
Star Strider
Star Strider el 9 de Abr. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by