Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I didn't know how to find a solution fminsearch

1 回表示 (過去 30 日間)
MAROUANE ENNAGADI
MAROUANE ENNAGADI 2019 年 4 月 24 日
閉鎖済み: John D'Errico 2019 年 4 月 30 日
Hello,
I will be happy if someone help me to solve this problem, because I work on it for 4 days but I didn't find the solution
I want to minimize this equation with fminsearch :
I took the following steps :
% g(E):
function [DOS_Gauss] = DOS_Gauss(sigma,N,E,E_LUMO)
DOS_Gauss=N./(sigma*sqrt(2*pi)).*exp(-(E-E_LUMO).^2./(2*sigma^2));
end
% 1-f(E,E_f):
function [C_D_Fermi]=C_D_Fermi(D_Fermi)
C_D_Fermi=1-D_Fermi;
end
% [1-f(E,E_f)]*g(E):
function [n_t_1]=n_t_1(DOS_Gauss,C_D_Fermi)
n_t_1=C_D_Fermi.*DOS_Gauss;
end
% ?[1-f(E,Ef)]g(E)dE:
function [n_t_f_1]=n_t_f_1(n_t_1,E1)
n_t_f_1=trapz(E1,n_t_1);
end
% 1-f(Et-Ef):
function [C_1_D_Fermi] = C_1_D_Fermi(E_t,E_f,K_B,T)
C_1_D_Fermi = 1-(1./(1+exp((E_t-E_f)./(K_B*T))));
end
%g(Et):
function [C_DOS_Gauss] = C_DOS_Gauss(sigma,N,E_t,E_LUMO)
C_DOS_Gauss=N./(sigma*sqrt(2*pi)).*exp(-(E_t-E_LUMO).^2./(2*sigma^2));
end
% [1-f(E_t,E_f)]*g(Et):
function [n_t_2]=n_t_2(C_DOS_Gauss,C_1_D_Fermi)
n_t_2=C_1_D_Fermi.*C_DOS_Gauss;
end
% TE:
function [E_T]=f_min(Bc,K_B,T,Alpha,n_t_f_1,n_t_2)
E_T=abs((2/3)*(4.*pi/3*Bc).^-1/3.*(K_B*T./Alpha).*(n_t_f_1).^-4/3.*n_t_2-1);
end
E_t_0=0.0;
E_t=fminsearch(@f_min,E_t_0,[],Bc,K_B,T,Alpha)
I Have here the problem, with my variable is " E_t"
Help me please.
Best regard,
  2 件のコメント
John D'Errico
John D'Errico 2019 年 4 月 24 日
Terribly hard to dig through. You have this confusing bundle of functions for no good reason. That is, if you just want to subtract 1 from something, you don't need to make a separate function out of it.
First problem:
function [C_DOS_Gauss] = C_DOS_Gauss(sigma,N,E_t,E_LUMO)
C_DOS_Gauss=N./(sigma*sqrt(2*pi)).*exp(-(E_t-E_LUMO).^2./(2*sigma^2));
end
Making the output variable of a function to have the same name as the function is sure to cause problems. I'm not sure if it actually causes an error, but it will certianly cause you pain if you ever need to debug your code in the future.
A big problem of your code is this:
function [n_t_2]=n_t_2(C_DOS_Gauss,C_1_D_Fermi)
n_t_2=C_1_D_Fermi.*C_DOS_Gauss;
end
These are functions themselves: C_DOS_Gauss and C_1_D_Fermi. But now you want to form the product of the result of them. However, you cannot just multiply the names of those functions. They have inputs.
John D'Errico
John D'Errico 2019 年 4 月 30 日
編集済み: John D'Errico 2019 年 4 月 30 日
That you have worked on it for 4 days does not mean you should post the same question every day for 4 days in a row. Stop the duplicate posts. I've now seen at least 3 of them. One you got answers on. This one hs gotten nothing more than a comment by me. And the other I closed.

回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by