随机行走程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

INTEGER M(1:10000), NUMBER1(0:364), NUMBER2

REAL X,Y

ISEED=RTC()

DO J=1, 10000

NUMBER1=0

X=RAN(ISEED)

NUMBER1(0)=INT(365*X+1)

JJJ=1

DO I=1,364

Y=RAN(ISEED)

NUMBER2=INT(365*Y+1)

ETR=COUNT(NUMBER1.EQ.NUMBER2)

IF (ETR= =1) THEN

EXIT

ELSE

JJJ=JJJ+1

M(J)=JJJ

NUMBER1(I)=NUMBER2

END IF

END DO

END DO

DO I=1,10000

IF(M(I).LE.23) SUM=SUM+1

END DO

PRINT *,SUM/10000

END

Monte Carlo Simulation of One Dimensional Diffusion

INTEGER X,XX(1:1000,1:1000)

REAL XXM(1:1000)

! X:INSTANTANEOUS POSITION OF ATOM

! XX(J,I):X*X ,J:第几天实验,I:第几步跳跃

! XXM(I): THE MEAN OF XX

WRITE(*,*) "实验天数JMAX,实验次数IMAX"

READ(*,*) JMAX,IMAX

ISEED=RTC()

DO J=1,JMAX !第几天实验

X=0 !!!

DO I=1,IMAX !第几步跳跃

RN=RAN(ISEED)

IF(RN<0.5)THEN

X=X+1

ELSE

X=X-1

END IF

XX(J,I)=X*X

END DO

END DO

OPEN(1,FILE="C:\DIF1.DAT")

DO I=1,IMAX

XXM=0.0

XXM(I)=1.0*SUM(XX(1:JMAX,I))/JMAX !!

WRITE(1,*) I, XXM(I)

END DO

CLOSE(1)

END

! Monte Carlo Simulation of Two Dimensional Diffusion INTEGER X,Y,XY(1:1000,1:1000)

REAL XYM(1:1000)

! X:INSTANTANEOUS POSITION OF ATOM

! XY(J,I):X*Y ,J:第几天实验,I:第几步跳跃

! XYM(I): THE MEAN OF XY

WRITE(*,*) "实验天数JMAX,实验次数IMAX"

READ(*,*) JMAX,IMAX

ISEED=RTC()

DO J=1,JMAX !第几天实验

X=0 !!!

Y=0 !!!

DO I=1,IMAX !第几步跳跃

RN=RAN(ISEED)

IF(RN.LT.0.25)THEN

x=x

y=y-1

END IF

IF(RN.LT.0.5.AND.RN.GE.0.25)THEN

x=x

y=y+1

END IF

IF(RN.LT.0.75.AND.RN.GE.0.5)THEN

x=x-1

y=y

END IF

IF(RN.GE.0.75)THEN

x=x+1

y=y

END IF

XY(J,I)=X*X+Y*Y

END DO

END DO

OPEN(1,FILE="C:\DIF2.DAT")

DO I=1,IMAX

XYM=0.0

XYM(I)=1.0*SUM(XY(1:JMAX,I))/JMAX !!

WRITE(1,*) I, XYM(I)

END DO

CLOSE(1)

END

! Monte Carlo Simulation of One Dimensional Diffusion INTEGER X,XY(1:1000,1:1000),y,XN(1:4),YN(1:4),RN

REAL XYM(1:1000)

! X:INSTANTANEOUS POSITION OF ATOM

! XY(J,I):X*Y ,J:第几天实验,I:第几步跳跃

! XYM(I): THE MEAN OF XY

WRITE(*,*) "实验天数JMAX,实验次数IMAX"

READ(*,*) JMAX,IMAX

XN=(/0,0,-1,1/)

YN=(/-1,1,0,0/)

ISEED=RTC()

DO J=1,JMAX !第几天实验

X=0 !!!

Y=0 !!!

DO I=1,IMAX !第几步跳跃

RN=4*RAN(ISEED)+1

X=X+YN(RN)

Y=Y+YN(RN)

XY(J,I)=X*X+Y*Y

END DO

END DO

OPEN(1,FILE="C:\DIF2.DAT")

DO I=1,IMAX

XYM=0.0

XYM(I)=1.0*SUM(XY(1:JMAX,I))/JMAX !!

WRITE(1,*) I, XYM(I)

END DO

CLOSE(1)

END

做三维空间随机行走??留作业

! Monte Carlo Simulation of One Dimensional Diffusion INTEGER X,XY(1:1000,1:1000),y,XN(1:6),YN(1:6),ZN(1:6),RN REAL XYM(1:1000)

! X:INSTANTANEOUS POSITION OF ATOM

! XY(J,I):X*Y ,J:第几天实验,I:第几步跳跃

! XYM(I): THE MEAN OF XY

WRITE(*,*) "实验天数JMAX,实验次数IMAX"

READ(*,*) JMAX,IMAX

XN=(/0,0,-1,1,0,0/)

YN=(/-1,1,0,0,0,0/)

ZN=(/0,0,0,0,1,-1/)

ISEED=RTC()

DO J=1,JMAX !第几天实验

X=0 !!!

Y=0 !!!

Z=0

DO I=1,IMAX !第几步跳跃

RN=6*RAN(ISEED)+1

X=X+XN(RN)

Y=Y+YN(RN)

Z=Z+ZN(RN)

XY(J,I)=X*X+Y*Y+Z*Z

相关文档
最新文档