program gсk_na_ploskosti implicit none real :: x(1000), y(1000) integer n common x,y,n integer, parameter :: s=10 real, parameter :: ro=1.9 integer i,j,l,vac real a,r,xa,some real en_at, en_sis1, en_sis2 real energy_atom, potencial_morze open (1, file='energy.txt') a=sqrt(2.0)*ro n=s*s+(s-1)*(s-1) l=1 do i=1,s do j=1,s y(l)=(i-1)*a x(l)=(j-1)*a l=l+1 enddo enddo l=s*s+1 do i=1,s-1 do j=1,s-1 y(l)=(2*(i-1)+1)*0.5*a x(l)=(2*(j-1)+1)*0.5*a l=l+1 enddo enddo if (mod(s,2)/=0) then vac=ceiling(s*s/2.0) else vac=s*s+ceiling((s-1)*(s-1)/2.0) endif xa=x(vac) write (1,'(2x,29HЧисло атомов: ,I5)') n write (1,'(2x,29HПараметр решетки: ,f10.4)') a call energy_system(en_sis1) write (1,'(2x,29HЗнергия системы без вакансии:,f10.4)') en_sis1 x(vac)=1000 call energy_system(en_sis2) write (1,'(2x,29HЗнергия системы c вакансии: ,f10.4)') en_sis2 write (1,'(2x,29HЗнергия образования вакансии:,f10.4)') en_sis2-en_sis1 write (1,*) '-------------------------------------------------' write (1,*) ' Номер атома | X | Y | Энегрия атома' write (1,*) '-------------------------------------------------' do i=1, n x(vac)=xa some=energy_atom(x(i),y(i)) write (1,'(5x,i3,5x,3f10.4)') i,x(i),y(i),some !energy_atom(x(i),y(i)) x(vac)=1000 write (1,'(13x,4f10.4)') x(i),y(i),energy_atom(x(i),y(i)), energy_atom(x(i),y(i))-some enddo close(1) open (2,file='potencial.xls') r=1.0 do while (r<5) write(2,*) r, potencial_morze(r) r=r+0.005 enddo close(2) end program gсk_na_ploskosti real function potencial_morze(r) real, intent(in) :: r real, parameter :: e=0.36, lyamda=1.41, ro=2.35 real temp temp=lyamda*(r-ro) potencial_morze=e*(exp(-2*temp)-2*exp(-temp)) end function potencial_morze real function energy_atom(x_at,y_at) common x(1000),y(1000),n real, intent(in) :: x_at,y_at integer i real r energy_atom=0.0 do i=1,n r=sqrt((x(i)-x_at)*(x(i)-x_at)+(y(i)-y_at)*(y(i)-y_at)) if (r/=0) then energy_atom=energy_atom+potencial_morze(r) endif enddo end function energy_atom subroutine energy_system(var) common x(1000),y(1000),n real, intent(out) :: var integer i,j real f,g var=0.0 do j=1,n-1 do i=j+1,n f=x(j); g=y(j) r=sqrt((x(i)-f)*(x(i)-f)+(y(i)-g)*(y(i)-g)) var=var+potencial_morze(r) enddo enddo end subroutine energy_system
|