24小时热门版块排行榜    

查看: 206  |  回复: 0

leigp

木虫 (正式写手)


[交流] 【讨论】麻烦各位高手给看一下我这程序有问题吗?多谢

麻烦高手帮忙给看一下我这段程序有问题吗?为什么开始几十步的时候,能量基本保持不变,但是后来,动能急剧增加呢,势能也在增加,有劳各位了,多谢了


SUBROUTINE L_J (n,a,ahalf,rcut,position_x,position_y,position_z,u,f_x,f_y,f_z,Ep)
IMPLICIT NONE
! the number of particles
INTEGER,INTENT(IN)::n
! the potential cutoff
REAL,INTENT(IN)::rcut
! the length and half length of box
REAL,INTENT(IN)::a,ahalf
!potential energy
REAL,INTENT(OUT)::Ep
! the position of particles
REAL(8),DIMENSION(n),INTENT(INOUT)::position_x,position_y,position_z
! the potential and force of particles
REAL,DIMENSION(n),INTENT(OUT)::u,f_x,f_y,f_z
! the contral variable of loop
INTEGER::i,j,k
! the label of particles
INTEGER::ijk
! the distance of every two particles along the three axis
REAL::distance_x,distance_y,distance_z
! the distance's square of every two particles
REAL::distance_sq
REAL::distance6,distance12,rcut_sq,rcut6,rcut12
REAL::Ec,ff
! initialize the potential and force
u=0.
Ep=0
f_x=0.
f_y=0.
f_z=0.
ijk=0
!calculate the rcut_sq
rcut_sq=rcut*rcut
rcut6=rcut_sq**3
rcut12=rcut6*rcut6
Ec=(1./rcut12-1./rcut6)
position_i: DO i=1,n-1   
    distance_ij:  DO j=i+1,n
   distance_x=position_x(i)-position_x(j)
         distance_y=position_y(i)-position_y(j)
         distance_z=position_z(i)-position_z(j)
         !x_distance:
   distance_x=distance_x-a*REAL(ANINT(distance_x/a))            
         !y_distance:
   distance_y=distance_y-a*REAL(ANINT(distance_y/a))
         !z_distance:
   distance_z=distance_z-a*REAL(ANINT(distance_z/a))
         ! calculate the distance_sq
         distance_sq=distance_x**2+distance_y**2+distance_z**2     
         ! calculate potential and force
     force:IF (distance_sq      ! calculate the distance6 and distance12
        distance6=distance_sq**3
        distance12=distance6*distance6
     ff=(distance_x/distance_sq)*((12./distance12)-(6./distance6))      
      !  u(ijk)=u(ijk)+(1./distance12-1./distance6)-Ec
              f_x(i)=f_x(i)+4.*ff
              f_y(i)=f_y(i)+4.*ff
              f_z(i)=f_z(i)+4.*ff
              f_x(j)=f_x(j)-4.*ff
              f_y(j)=f_y(j)-4.*ff
              f_z(j)=f_z(j)-4.*ff
     Ep=Ep+(1./distance12-1./distance6)-Ec
     END IF force
     END DO distance_ij
  !   u(ijk)=4.*u(ijk)
END DO position_i  
Ep=4.*Ep
Ep=Ep/real(n)
END SUBROUTINE L_J

[ Last edited by ghcacj on 2010-12-16 at 13:08 ]
回复此楼

» 猜你喜欢

» 抢金币啦!回帖就可以得到:

查看全部散金贴

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 leigp 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 085601材料工程专硕求调剂 +5 慕寒mio 2026-03-16 5/250 2026-03-17 21:31 by hmn_wj
[考研] 能源材料化学课题组招收硕士研究生8-10名 +3 脱颖而出 2026-03-16 6/300 2026-03-17 21:19 by z1z2z3879
[考研] 0703化学调剂 ,六级已过,有科研经历 +8 曦熙兮 2026-03-15 8/400 2026-03-17 20:31 by xilongliang
[考研] 344求调剂 +4 knight344 2026-03-16 4/200 2026-03-17 17:27 by ruiyingmiao
[考研] 085601求调剂 +4 Du.11 2026-03-16 4/200 2026-03-17 17:08 by ruiyingmiao
[考研] 085600材料与化工求调剂 +5 绪幸与子 2026-03-17 5/250 2026-03-17 16:40 by laoshidan
[考研] 一志愿苏州大学材料工程(085601)专硕有科研经历三项国奖两个实用型专利一项省级立项 +6 大火山小火山 2026-03-16 8/400 2026-03-17 15:05 by 无懈可击111
[考研] 302求调剂 +4 小贾同学123 2026-03-15 8/400 2026-03-17 10:33 by 小贾同学123
[硕博家园] 深圳大学硕士招生(2026秋,传感器方向,仅录取第一志愿) +4 xujiaoszu 2026-03-11 9/450 2026-03-17 10:29 by xujiaoszu
[考研] 070305求调剂 +3 mlpqaz03 2026-03-14 4/200 2026-03-15 11:04 by peike
[考研] 中科大材料专硕319求调剂 +3 孟鑫材料 2026-03-13 3/150 2026-03-14 18:10 by houyaoxu
[考研] 266求调剂 +4 学员97LZgn 2026-03-13 4/200 2026-03-14 08:37 by zhukairuo
[考研] 四川大学085601材料工程专硕 初试294求调剂 +4 祝我们好在冬天 2026-03-11 4/200 2026-03-13 21:39 by peike
[考研] 329求调剂 +3 miaodesi 2026-03-12 4/200 2026-03-13 20:53 by 18595523086
[考研] 26调剂/材料科学与工程/总分295/求收留 +9 2026调剂侠 2026-03-12 9/450 2026-03-13 20:46 by 18595523086
[考研] 301求调剂 +6 Liyouyumairs 2026-03-11 6/300 2026-03-13 20:11 by JourneyLucky
[考研] 295求调剂 +3 小匕仔汁 2026-03-12 3/150 2026-03-13 15:17 by vgtyfty
[考研] 328化工专硕求调剂 +4 。,。,。,。i 2026-03-12 4/200 2026-03-13 14:44 by JourneyLucky
[考研] 277求调剂 +4 anchor17 2026-03-12 4/200 2026-03-13 11:15 by 白夜悠长
[考研] 283求调剂,材料、化工皆可 +8 苏打水7777 2026-03-11 10/500 2026-03-13 09:06 by Linda Hu
信息提示
请填处理意见