module commvar integer,parameter :: n=2,n1=3*n*n*n*8,n2=n1+1,n3=8*n*n*n real*8 :: realn,mini real*8 :: pos(n3,3),dpos(n3,3),r0(3,3),o0,pi,dv(n1,n1),small integer :: neigh(n3,4),type(n3) logical :: flag(n3,n3) ! Variables used ! ! n = length of side of lattice in 8 atom blocks ! n1,n2,n3 = sizes of arrays ! pos = default positions of atoms ! dpos = changes in positions of atoms ! opos = positions loaded in ! neigh(i,j) = j th neighbour of ith atom ! r0(i,j)= perfect lattice length between atoms of type=i and type=j ! o0= 109' ! pi ! wrap = boundary conditions function ! type = ith atom is type i 1=Si 2=Ge 3=C ! contains subroutine values implicit none open(unit=101,file='mini2',status='old') read(101,*) mini close(101) r0(1,1)=dble(2.35156) r0(2,2)=dble(2.447) r0(3,3)=dble(1.545) r0(1,2)=(r0(1,1)+r0(2,2))/dble(2) r0(2,1)=r0(1,2) r0(2,3)=(r0(2,2)+r0(3,3))/dble(2) r0(3,2)=r0(2,3) r0(1,3)=dble(1.888) r0(3,1)=dble(1.888) realn=dble(4*n)*r0(1,1)/sqrt(dble(3)) o0=acos(dble(-1)/dble(3)) pi=acos(dble(-1)) small=dble(.0001) end subroutine values end module commvar ! MAIN PROGRAM program phd4 use commvar use para implicit none call values call parameters call setup call leastsquares call writeout(2) end program phd4 subroutine lsqfun(iflag,m1,no,x,fvecc,iw,liw,w,lw) use commvar use para implicit none integer :: iflag,m1,no,liw,iw(liw),lw,i,j,a,b real*8 :: x(no),fvecc(m1),w(lw),sum sum=dble(0) bfr(1,2)=x(1) bfr(2,1)=x(1) call writeout(2) call relax call makedv call ek(sum) write(10,*) 'LVM=',sum,sum*dble(519) write(10,*) sum=sum-(dble(386)/dble(519)) if (sum**2pi) angle=2*pi-angle end function angle real*8 function r3(a,b,c) use commvar implicit none integer a,b,c,ta,tb,tc ta=type(a) tb=type(b) tc=type(c) r3=(r0(ta,tb)+r0(tb,tc))/dble(2) end function r3 real*8 function r41(a,b,c,d) use commvar implicit none integer a,b,c,d,ta,tb,tc,td ta=type(a) tb=type(b) tc=type(c) td=type(d) r41=(r0(ta,tb)+r0(ta,tc)+r0(ta,td))/dble(3) end function r41 real*8 function r42(a,b,c,d) use commvar implicit none integer a,b,c,d,ta,tb,tc,td ta=type(a) tb=type(b) tc=type(c) td=type(d) r42=(r0(ta,tb)+r0(tb,tc)+r0(tc,td))/dble(3) end function r42 real*8 function r51(a,b,c,d,e) use commvar implicit none integer a,b,c,d,e,ta,tb,tc,td,te ta=type(a) tb=type(b) tc=type(c) td=type(d) te=type(e) r51=(r0(ta,tb)+r0(tb,tc)+r0(tc,td)+r0(td,te))/dble(4) end function r51 real*8 function r52(a,b,c,d,e) use commvar implicit none integer a,b,c,d,e,ta,tb,tc,td,te ta=type(a) tb=type(b) tc=type(c) td=type(d) te=type(e) r52=(r0(ta,td)+r0(tb,td)+r0(tc,td)+r0(tc,te))/dble(4) end function r52 subroutine writeout(a) use para implicit none integer :: a,i,j,k,l,m if (a==1)open(unit=22,file='start.f90',status='replace') if (a==2)open(unit=22,file='param.f90',status='replace') if (a==3)open(unit=22,file='minim.f90',status='replace') write(22,*)' module para' write(22,*)' real*8::bfr(0:3,0:3),bfo(0:3,0:3,0:3)' write(22,*)' real*8::bfro(0:3,0:3,0:3),bfrr(0:3,0:3,0:3)' write(22,*)' real*8::bfoo(0:3,0:3,0:3,0:3)' write(22,*)' real*8::bfoo1(0:3,0:3,0:3,0:3)' write(22,*)' real*8::bfoo4(0:3,0:3,0:3,0:3,0:3)' write(22,*)' real*8::bfoo5(0:3,0:3,0:3,0:3,0:3)' write(22,*)' real*8::bfoo7(0:3,0:3,0:3,0:3,0:3)' write(22,*)' contains' write(22,*)' subroutine parameters' 1 format(a10,i1,a1,i1,a2,f13.8) do i=0,3 do j=0,3 write(22,1)' bfr(',i,',',j,')=',bfr(i,j)**2 end do end do 2 format(a10,i1,a1,i1,a1,i1,a2,f10.8) do i=0,3 do j=0,3 do k=0,3 write(22,2)' bfo(',i,',',j,',',k,')=',bfo(i,j,k) end do end do end do 3 format(a11,i1,a1,i1,a1,i1,a2,f10.8) do i=0,3 do j=0,3 do k=0,3 write(22,3)' bfro(',i,',',j,',',k,')=',bfro(i,j,k) end do end do end do do i=0,3 do j=0,3 do k=0,3 write(22,3)' bfrr(',i,',',j,',',k,')=',bfrr(i,j,k) end do end do end do 4 format(a11,i1,a1,i1,a1,i1,a1,i1,a2,f10.8) do i=0,3 do j=0,3 do k=0,3 do l=0,3 write(22,4)' bfoo(',i,',',j,',',k,',',l,')=',bfoo(i,j,k,l) end do end do end do end do 5 format(a12,i1,a1,i1,a1,i1,a1,i1,a2,f10.8) do i=0,3 do j=0,3 do k=0,3 do l=0,3 write(22,5)' bfoo1(',i,',',j,',',k,',',l,')=',bfoo1(i,j,k,l) end do end do end do end do 6 format(a12,i1,a1,i1,a1,i1,a1,i1,a1,i1,a2,f10.8) do i=0,3 do j=0,3 do k=0,3 do l=0,3 do m=0,3 write(22,6)' bfoo4(',i,',',j,',',k,',',l,',',m,')=',bfoo4(i,j,k,l,m) end do end do end do end do end do do i=0,3 do j=0,3 do k=0,3 do l=0,3 do m=0,3 write(22,6)' bfoo5(',i,',',j,',',k,',',l,',',m,')=',bfoo5(i,j,k,l,m) end do end do end do end do end do do i=0,3 do j=0,3 do k=0,3 do l=0,3 do m=0,3 write(22,6)' bfoo7(',i,',',j,',',k,',',l,',',m,')=',bfoo7(i,j,k,l,m) end do end do end do end do end do write(22,*)' end subroutine parameters' write(22,*)' end module para' close(22) return end subroutine writeout subroutine ek(lvm) use commvar implicit none real*8 :: lvm real*8 :: rr(n1),mass,br(n1,n1),empty(n1,n1),dl(n1),e(n1) integer :: ifail,iter(n1),i,j,k,l,m,o,p lvm=dble(0) do j=1,n1 rr(j)=dble(0) dl(j)=dble(0) e(j)=dble(0) end do do l=1,n3 do m=1,n3 do o=1,3 do p=1,3 br(3*(l-1)+o,3*(m-1)+p)=dble(0) if (l==m.and.o==p) br(3*(l-1)+o,3*(m-1)+p)=mass(type(m)) end do end do end do end do ifail=0 call f02aef(dv,n1,br,n1,n1,rr,empty,n1,dl,e,ifail) if (ifail/=0) write(10,*) 'EK error Ifail=',ifail lvm=sqrt(rr(n1)) return end subroutine ek subroutine makedv use commvar implicit none real*8 :: swap1,swap2,e1,e2,e3,e4,d,dd integer :: i,j,k,l,m do i=1,n1 do j=1,n1 dv(i,j)=dble(0) end do end do write(10,*) 'Into makedv' do i=1,n3 do j=i,n3 do k=1,n3 if (flag(k,i).and.flag(k,j)) then if (i==j) then do l=1,3 do m=l,3 if (l==m) then swap1=dpos(i,l) call poti(e1,k) dpos(i,l)=swap1+small+small call poti(e2,k) dpos(i,l)=swap1-small-small call poti(e3,k) dpos(i,l)=swap1 dv(3*(i-1)+l,3*(i-1)+l)=dv(3*(i-1)+l,3*(i-1)+l)+& (e2-e1-e1+e3)/(dble(4)*small*small) else d=dd(k,i,l,i,m) dv(3*(i-1)+l,3*(i-1)+m)=dv(3*(i-1)+l,3*(i-1)+m)+d dv(3*(i-1)+m,3*(i-1)+l)=dv(3*(i-1)+m,3*(i-1)+l)+d end if end do end do else do l=1,3 do m=1,3 d=dd(k,i,l,j,m) dv(3*(i-1)+l,3*(j-1)+m)=dv(3*(i-1)+l,3*(j-1)+m)+d dv(3*(j-1)+m,3*(i-1)+l)=dv(3*(j-1)+m,3*(i-1)+l)+d end do end do end if end if end do end do end do return end subroutine makedv real*8 function dd(a,b,c,d,e) use commvar implicit none integer a,b,c,d,e real*8 :: swap1,swap2,e1,e2,e3,e4 swap1=dpos(b,c) swap2=dpos(d,e) dpos(b,c)=swap1+small dpos(d,e)=swap2+small call poti(e1,a) dpos(b,c)=swap1-small dpos(d,e)=swap2+small call poti(e2,a) dpos(b,c)=swap1+small dpos(d,e)=swap2-small call poti(e3,a) dpos(b,c)=swap1-small dpos(d,e)=swap2-small call poti(e4,a) dpos(b,c)=swap1 dpos(d,e)=swap2 dd=(e1-e2-e3+e4)/(dble(4)*small*small) end function dd real*8 function mass(i) implicit none integer :: i if (i==1) mass=dble(28.09) if (i==2) mass=dble(72.61) if (i==3) mass=dble(12.01) end function mass