outfold.f90

来自「蒙特卡罗的一个程序分析 与大家分享 共同研究」· F90 代码 · 共 79 行

F90
79
字号

subroutine Outfold( Lengthlj, Lengthion, BoxSize,  &
					Xlj, Ylj, Zlj, Xion, Yion, Zion )

implicit none

! This subroutine reconstructs a molecule which might be divided into several
! parts because of the periodic boundary conditions.

! Lengthlj is the number of LJ beads in the chain being outfolded.
! Lengthion is the number of ionic beads in the chain being outfolded.

integer, intent(in)									:: Lengthlj
integer, intent(in)									:: Lengthion

! BoxSize is the length of the simulation box.

real, intent(in)									:: BoxSize

! Xlj, Ylj, and Zlj are the coordinates of the LJ beads.
! Xion, Yion, and Zion are the coordinates of the ionic beads.

real, dimension(Lengthlj)							:: Xlj, Ylj, Zlj
real, dimension(Lengthion)							:: Xion, Yion, Zion

! Local Variables

integer												:: i
real												:: xref, yref, zref
real												:: dx, dy, dz

xref = Xlj(1)
yref = Ylj(1)
zref = Zlj(1)

do i = 2, Lengthlj

	dx = Xlj(i) - xref
	dy = Ylj(i) - yref
	dz = Zlj(i) - zref
	
	Xlj(i) = Xlj(i) - nint(dx/BoxSize) * BoxSize
	Ylj(i) = Ylj(i) - nint(dy/BoxSize) * BoxSize
	Zlj(i) = Zlj(i) - nint(dz/BoxSize) * BoxSize
	
	xref = Xlj(i)
	yref = Ylj(i)
	zref = Zlj(i)

end do

xref = Xlj(1)
yref = Ylj(1)
zref = Zlj(1)

do i = 1, Lengthion

	dx = Xion(i) - xref
	dy = Yion(i) - yref
	dz = Zion(i) - zref
	
	Xion(i) = Xion(i) - nint(dx/BoxSize) * BoxSize
	Yion(i) = Yion(i) - nint(dy/BoxSize) * BoxSize
	Zion(i) = Zion(i) - nint(dz/BoxSize) * BoxSize

	xref = Xion(i)
	yref = Yion(i)
	zref = Zion(i)

end do

return

end subroutine Outfold




⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?