Znn3bq.jpeg
²é¿´: 1191  |  »Ø¸´: 2
¡¾½±Àø¡¿ ±¾Ìû±»ÆÀ¼Û2´Î£¬×÷ÕßfangyongxinxiÔö¼Ó½ð±Ò 1.6 ¸ö
µ±Ç°Ö»ÏÔʾÂú×ãÖ¸¶¨Ìõ¼þµÄ»ØÌû£¬µã»÷ÕâÀï²é¿´±¾»°ÌâµÄËùÓлØÌû

fangyongxinxi

гæ (ÕýʽдÊÖ)


[×ÊÔ´] Ò»¸öHF·½·¨¼ÆËãH2¼ü³¤µÄmatlab´úÂ루һ°Ù¶àÐУ©

% Downloadable MATLAB code, copyright Amritanshu Palaria
% H2 ground state from a non-relativistic Hartree Fock treatment using STO-4G basis set and Born Oppenheimer approximation  
% Program written by Amritanshu Palaria @ NCN, Apr 12, 2006
% For theoretical reference, please see "Computational Physics" by Thijssen
%  erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt
clear all;
% initialization
Z=1,S=1,A=0,F=0,V=0,D=0,g=0,Vecp=0,Vec=0,Val=0,EVal=0;
for y=1:41
    clear T,S,A,F,V,D,g,Vecp,Vec,Val,EVal;
    % y = 11;
    disp('Step '); disp(y);
    r = 0.45+0.05*y; % distance between nucleii in a.u.(units of a0, ie. Bohr radius)... since the problem is essentially 1-D, this is all that is needed
    disp('H-H bondlength'); disp(r);
    NNr=1/r;
    % alphas for the 4 Gaussian basis functions for each H atom
    alpha1 = [13.00773 1.962079 0.444529 0.1219492];  % sto-4g, Phi = 0.03492*exp(-13.00773*r^2)+0.2347*exp(-1.962079*r^2)+0.8138*exp(-0.444529*r^2)+1*exp(-0.1219492*r^2)
    alpha = [alpha1 alpha1];
    asize=size(alpha);
    % one H nucleus at origin, the other at r
    ra=[0 0 0 0 r r r r]; % the location of the atom with the ith basisfunction
    % first 4 basis fns come from the atom at origin
    % the next 4 come from the one at r
    % the S (overlap), T (K.E.) and A (Coulomb) matrices
    for i=1:8 % run over all basis functions
        for j=1:i % do not run over all basis functions to exploit symmetry
            % intermediate variables
            as = alpha(i)+alpha(j);
            ap = alpha(i)*alpha(j);
            rat=ap/as;
            % location of the gaussian resulting from product of
            % the 2 gaussian basis functions
            rp=(alpha(i)*ra(i)+alpha(j)*ra(j))/as;
            S(i,j)=(pi/as)^1.5*exp(-rat*(ra(i)-ra(j))^2);
            S(j,i)=S(i,j); % using symmetry
            T(i,j)=0.5*rat*(6-4*rat*(ra(i)-ra(j))^2)*S(i,j);
            T(j,i)=T(i,j); % using symmetry
            if (rp==0)
                F0=1+sqrt(pi)/2*erf(sqrt(as*(rp-r)^2))/sqrt(as*(rp-r)^2);  %  erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt
            elseif (rp==r)
                F0=sqrt(pi)/2*erf(sqrt(as*(rp-0)^2))/sqrt(as*(rp-0)^2)+1;
            else
                F0=sqrt(pi)/2*(erf(sqrt(as*(rp-0)^2))/sqrt(as*(rp-0)^2)+erf(sqrt(as*(rp-r)^2))/sqrt(as*(rp-r)^2));
            end
            A(i,j)=-2*pi*Z/as*exp(-rat*(ra(i)-ra(j))^2)*F0;
            A(j,i)=A(i,j); % using symmetry
        end
    end
    S
    T
    A
    [V,D]=eig(S); % gives eigenvectors in columns of V, this diagnolizes S
    for i=1:asize(2)
        V(:,i)=V(:,i)/(D(i,i)^0.5);
    end
    % the two-electron integrals P taking care of all symmetries
    % it is noted that the gaussian functions evaluate to REAL values
    % and the g operator is real and symmetric w.r.t. 1 and 2
    for i=1:8
        for j=1:i % do not run over all basis functions to exploit symmetry
            as1=alpha(i)+alpha(j);
            ap1=alpha(i)*alpha(j);
            rp=(alpha(i)*ra(i)+alpha(j)*ra(j))/as1;
            for k=1:i-1 % do not run over all basis functions to exploit symmetry
                for l=1:k % do not run over all basis functions to exploit symmetry
                    as2=alpha(k)+alpha(l);
                    ap2=alpha(k)*alpha(l);
                    rq=(alpha(k)*ra(k)+alpha(l)*ra(l))/as2;
                    if ((rp-rq)==0)
                        F0=1;
                    else
                        F0=sqrt(pi)/2*erf(sqrt(as1*as2*(rp-rq)^2/(as1+as2)))/sqrt(as1*as2*(rp-rq)^2/(as1+as2));
                    end
                    g(i,j,k,l)=2*pi^2.5/as1/as2/(as1+as2)^0.5*exp(-ap1*(ra(i)-ra(j))^2/as1-ap2*(ra(k)-ra(l))^2/as2)*F0;
                    g(k,l,i,j)=g(i,j,k,l); % using symmetry
                    g(j,i,k,l)=g(i,j,k,l); % using symmetry
                    g(i,j,l,k)=g(i,j,k,l); % using symmetry
                    g(j,i,l,k)=g(i,j,k,l); % using symmetry
                    g(k,l,j,i)=g(i,j,k,l); % using symmetry
                    g(l,k,i,j)=g(i,j,k,l); % using symmetry
                    g(l,k,j,i)=g(i,j,k,l); % using symmetry
                end
                k=i;
                for l=1:j
                    as2=alpha(k)+alpha(l);
                    ap2=alpha(k)*alpha(l);
                    rq=(alpha(k)*ra(k)+alpha(l)*ra(l))/as2;
                    if ((rp-rq)==0)
                        F0=1;
                    else
                        F0=sqrt(pi)/2*erf(sqrt(as1*as2*(rp-rq)^2/(as1+as2)))/sqrt(as1*as2*(rp-rq)^2/(as1+as2));
                    end
                    g(i,j,k,l)=2*pi^2.5/as1/as2/(as1+as2)^0.5*exp(-ap1*(ra(i)-ra(j))^2/as1-ap2*(ra(k)-ra(l))^2/as2)*F0;
                    g(k,l,i,j)=g(i,j,k,l); % using symmetry
                    g(j,i,k,l)=g(i,j,k,l); % using symmetry
                    g(i,j,l,k)=g(i,j,k,l); % using symmetry
                    g(j,i,l,k)=g(i,j,k,l); % using symmetry
                    g(k,l,j,i)=g(i,j,k,l); % using symmetry
                    g(l,k,i,j)=g(i,j,k,l); % using symmetry
                    g(l,k,j,i)=g(i,j,k,l); % using symmetry
                end
            end
        end
    end
    % Self-consistent loop
    C=ones(1,asize(2)); %initial guess, 11 Ðм¸ÁеÄ1¾ØÕó
    nor=C*S*C'   % c' תÖÃ
    disp('Initial Guess');
    C=C/nor
    Elast=1;
    EVal=0;
    P=C'*C;
    count=0;
    rplot=-2:0.01:3; % range in atomic units (bohr) for plotting the probability density
    % figure();
    % Generating Fock matrix
    while((abs(EVal(1)-Elast))>0.000001)
        count=count+1;
        disp('Step #');
        disp(count);
        Elast=EVal(1)
        for i=1:8
            for j=1:8
                J=0;
                for k=1:8
                    for l=1:8
                        J=J+P(k,l)*g(i,j,k,l);
                    end
                end
                F(i,j)=T(i,j)+A(i,j)+J;
            end
        end
        % solve the generalized eigenvalue problem FC=ESC
        % inverse of V is its conjugate transpose because V is unitary
        Fp=V'*F*V; % modified Fock matrix
        [Vecp,Val]=eig(Fp);
        Vec=V*Vecp;
        EigVal=diag(Val,0)
        [EVal,index]=sort(EigVal);
        disp('Ground State eigenvalue from this step is (in a.u., i.e. Hartree):');
        Erec(count)=EVal(1) % lowest eigenvalue
        GrCoeff=Vec(:,index(1)); % eigenvector corresponding to ground state
        disp('C matrix from this step is:');
        C=GrCoeff.' %new C matrix, this is normalized w.r.t. S ie. C*S*C'=1
        disp('Input density matrix for next step is:');
        P=0.8*P+0.2*C'*C %new input density matrix
        GndWvFn=C(1:4)*exp(-(alpha(1:4)).'*(rplot.*rplot))+C(5:8)*exp(-(alpha(5:8)).'*((rplot-r).*(rplot-r))); % ground state wavefunction from STO-4G approximation
        %     Uncomment the next 4 lines if you need a plot of probability with step of convergence
        %     hold on;
        %     plot(rplot,(abs(GndWvFn)).^2,'r--','LineWidth',1.5);
        %     xlabel('r position');
        %     ylabel('Probability density');
        %     title('Plot of the probability density vs. r position with step of convergence');
    end
    Qs=0;
    for i=1:8
        for j=1:8
            for k=1:8
                for l=1:8
                    Qs=Qs+g(i,j,k,l)*C(i)*C(j)*C(k)*C(l);
                end
            end
        end
    end
    disp('The final total energy (including nuclear-nuclear repulsion) after convergence for this H-H bond is ');
    Eg(y)=2*C*(T+A)*C'+Qs+NNr; % the energy from h for each e, the e-e interaction and the nucleus-nucleus interaction added
    disp(Eg(y));
    if Eg(y)==min(Eg)
        rmin = r;
        Erecmin = Erec;
        WvFnmin = GndWvFn;
    end
end

figure();
plot([0.5:0.05:2.5],Eg,'bo','LineWidth',2);
title('Plot showing total energy from Hartree Fock treatment of H-H using Born Oppenheimer approximation');
xlabel('H-H bondlength');
ylabel('Total energy (in a.u.)');

disp('The least energy bond length (A) for H-H is '); disp(rmin*0.529177);
disp('The energy (Hartree) of this bond is '); disp(min(Eg));

figure();
plot(Erecmin,'ro','LineWidth',2);
axis([1 count min(Erecmin) max(Erecmin)+0.1]);
title('Plot showing convergence of Fock level with every step for the least energy H-H bondlength ');
xlabel('Step of convergence');
ylabel('Fock energy level (in a.u.)');

%plot of final probabiliy density
figure();
plot(rplot,(abs(WvFnmin)).^2,'LineWidth',2.5);
xlabel('r position');
ylabel('Probability density');
title('Plot of the probability density of electrons vs. r position for the least energy H-H bond');
axis tight;
»Ø¸´´ËÂ¥

» ÊÕ¼±¾ÌûµÄÌÔÌûר¼­ÍƼö

Á¿»¯

» ²ÂÄãϲ»¶

» ±¾Ö÷ÌâÏà¹Ø¼ÛÖµÌùÍÆ¼ö£¬¶ÔÄúͬÑùÓаïÖú:

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

dhqdqk

½ð³æ (ÕýʽдÊÖ)


¡ï¡ï¡ï¡ï¡ï ÎåÐǼ¶,ÓÅÐãÍÆ¼ö

¼ÆËã½á¹û£¨matlab 2011ra X64):
The final total energy (including nuclear-nuclear repulsion) after convergence for this H-H bond is
   -1.0327

The least energy bond length (A) for H-H is
    0.7408

The energy (Hartree) of this bond is
   -1.1265

[ Last edited by dhqdqk on 2011-12-6 at 12:54 ]
3Â¥2011-12-06 11:53:05
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
²é¿´È«²¿ 3 ¸ö»Ø´ð

anionxt

Ìú¸Ëľ³æ (ÖøÃûдÊÖ)


¡ï¡ï¡ï¡ï¡ï ÎåÐǼ¶,ÓÅÐãÍÆ¼ö

¡ï¡ï¡ï¡ï¡ï ÎåÐǼ¶
2Â¥2011-12-05 15:48:44
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
¡î ÎÞÐǼ¶ ¡ï Ò»ÐǼ¶ ¡ï¡ï¡ï ÈýÐǼ¶ ¡ï¡ï¡ï¡ï¡ï ÎåÐǼ¶
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] »¯Ñ§¹¤³ÌÓë¼¼Êõרҵһ־Ը¹þ¹¤³Ì 291·ÖBÇø ¹ú¼Ò¼¶´ó´´¸ºÔðÈË ÓÐÒ»×÷ÂÛÎÄ +10 Emmy~ 2026-04-09 10/500 2026-04-09 12:12 by 418490947
[¿¼²©] ²©Ê¿×Ô¼ö +3 ¿É¿ÉСÅÖ 2026-04-08 3/150 2026-04-09 11:25 by juanzi_88
[¿¼ÑÐ] Ò»Ö¾Ô¸2110£¬»¯Ñ§Ñ§Ë¶310·Ö£¬±¾¿ÆÖصãË«·ÇÇóµ÷¼Á +15 ŬÁ¦·Ü¶·112 2026-04-08 15/750 2026-04-09 11:22 by lenovolsw
[¿¼ÑÐ] 070300»¯Ñ§279Çóµ÷¼Á +17 ¹þ¹þ¹þ^_^ 2026-04-08 18/900 2026-04-09 10:49 by ÈýÆßÆßÏëÉϰ¶
[¿¼ÑÐ] 085404 293Çóµ÷¼Á +4 ÓÂÔ¶¿â°®314 2026-04-08 4/200 2026-04-09 08:56 by ±£±¼³¬°®Ñ§Ï°
[¿¼ÑÐ] 070300»¯Ñ§ Çóµ÷¼Á +10 73372112 2026-04-08 10/500 2026-04-09 07:59 by yuandd_2001
[¿¼ÑÐ] Ò»Ö¾Ô¸µç×ӿƼ¼´óѧ085600²ÄÁÏÓ뻯¹¤ 329·ÖÇóµ÷¼Á +11 Naiko 2026-04-04 11/550 2026-04-08 14:00 by wutongshun
[¿¼ÑÐ] 298Çóµ÷¼Á +4 ²ÐºÉÐÂÁø 2026-04-07 4/200 2026-04-07 23:02 by lbsjt
[¿¼ÑÐ] Ò»Ö¾Ô¸Ö£ÖÝ´óѧ²ÄÁÏÓ뻯¹¤085600£¬Çóµ÷¼Á +34 ³ÔµÄ²»ÉÙ 2026-04-02 34/1700 2026-04-07 20:01 by lrll?l
[¿¼ÑÐ] 081700»¯Ñ§¹¤³ÌÓë¼¼Êõ Ò»Ö¾Ô¸Öк£Ñó 323 Çóµ÷¼ÁѧУ +19 ÅûÐÇºÓ 2026-04-03 19/950 2026-04-07 15:14 by ¾¡Ë´Ò¢1
[¿¼ÑÐ] 0854Çóµ÷¼Á +9 ºàÊÏ·¬ÇÑɳ˾ 2026-04-06 10/500 2026-04-07 14:37 by shdgaomin
[¿¼ÑÐ] 319Çóµ÷¼Á +3 handrui 2026-04-05 3/150 2026-04-06 09:33 by jp9609
[¿¼ÑÐ] ²ÄÁÏÓ뻯¹¤371Çóµ÷¼Á +14 ÅãÁÕ¿´º£ 2026-04-04 15/750 2026-04-06 06:59 by houyaoxu
[¿¼ÑÐ] Çóµ÷¼Á +10 Hllºú 2026-04-04 10/500 2026-04-05 20:09 by nepu_uu
[¿¼ÑÐ] Ò»Ö¾Ô¸±±½»´ó²ÄÁϹ¤³Ì×Ü·Ö358Çóµ÷¼Á +6 cs0106 2026-04-05 6/300 2026-04-05 16:34 by imissbao
[¿¼ÑÐ] 292Çóµ÷¼Á +11 2022080213 2026-04-04 13/650 2026-04-04 18:38 by macy2011
[¿¼ÑÐ] Çóµ÷¼Á +3 ũҵ¹¤³ÌÓëÐÅÏ¢¼ 2026-04-04 3/150 2026-04-04 12:19 by Éá¶øºóµÃ
[¿¼ÑÐ] ±¾9Ò»Ö¾Ô¸2 0854µÍ·Öר˶286Çóµ÷¼Á +9 âÖÖ111 2026-04-04 9/450 2026-04-04 11:01 by tangruihua
[¿¼ÑÐ] 085501Ò»Ö¾Ô¸Ì칤´ó£¬»úеר˶Çóµ÷¼Á£¬¿ç²ÄÁÏ +3 33ÉÏ 2026-04-03 3/150 2026-04-03 14:08 by 1753564080
[¿¼ÑÐ] ר˶085601Çóµ÷¼Á +7 suyifei 2026-04-03 8/400 2026-04-03 14:00 by ÐÀϲ777
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û