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
0 件のコメント
回答 (2 件)
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 件のコメント
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
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
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.
参考
カテゴリ
Help Center および File Exchange で Systems of Nonlinear Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!