Essay about Boundary Value Problem and Integer I, J Integer

Submitted By xieyingwudi
Words: 602
Pages: 3

第三次计算物理作业
------分子动力学
问题:
Put 20 particles in a 10X10 box with periodic boundary conditions, with initial speed v=0 in randomly chose directions. The time step was 0.02. Simulate the system and plot the positions of the particles after every third time step.
1、
Calculate the speed distribution of different time intervals (a)t=0-20, (b) t=20-40, (c) t=40-60 calculate the mean-square displacement of an atom as a function of time.
2、Show that the motion is indeed diffusive
解:

1、子程序:
随机撒点的子程序
subroutine init(x,y,vx,vy,xp,yp) integer,parameter :: L=10 integer,parameter :: N=20 real,parameter :: e=0.1 integer a(L,L) real x(N),y(N),xp(N),yp(N) real :: dr=0.1 real p,q,rnd1,rnd2 integer i,j integer :: k=1 do i=1,L do j=1,L a(i,j)=0 end do end do do while(k10) then y(k)=y(k)-10.0 end if a(ceiling(p*L),ceiling(q*L))=1 xp(k)=x(k) yp(k)=y(k) k=k+1 end if end do return end

!在y方向有小的扰动

!标记已用过的格点

计算力的子程序 subroutine Force(x,y,dx,dy,Fx,Fy) implicit none integer,parameter :: N=20 integer,parameter :: L=10 real :: x(N),y(N),xp(N),yp(N),vx(N),vy(N),LL(N),Fx(N),Fy(N),r(N),dx(N),dy(N),rr(N) integer j,k,i open(unit=20,file="f.txt") do i=1,20
!每次计算使力归零
Fx(i)=0.0
Fy(i)=0.0
end do do i=1,20 do k=1,20 dx(k)=0.0 dy(k)=0.0 rr(k)=0.0 end do do j=1,20 if(j/=i) then dx(j)=x(i)-y(j) dy(j)=y(i)-y(j) if (dx(j)>0.0) then if(dx(j)>l-dx(j))then dx(j)=dx(j)-l end if end if if(dx(j)l+dx(j))then dx(j)=dx(j)+l end if end if if(dy(j)>0.0)then if(dy(j)>=l-dy(j))then dy(j)=dy(j)-l end if end if if(dy(j)l+dy(j))then dy(j)=dy(j)+l
end…