allen-tildesley-book
|
README,
f.00,
f.01,
f.02,
f.03,
f.04,
f.05,
f.06,
f.07,
f.08,
f.09,
f.10,
f.11,
f.12,
f.13,
f.14,
f.15,
f.16,
f.17,
f.18,
f.19,
f.20,
f.21,
f.22,
f.23,
f.24,
f.25,
f.26,
f.27,
f.28,
f.29,
f.30,
f.31,
f.32,
f.33,
f.34,
f.35,
f.36,
f.37,
older-version
|
|
|
********************************************************************************
** FICHE F.26. ROUTINES TO FOLD/UNFOLD TRAJECTORIES IN PERIODIC BOUNDARIES **
** This FORTRAN code is intended to illustrate points made in the text. **
** To our knowledge it works correctly. However it is the responsibility of **
** the user to test it, if it is to be used in a research application. **
********************************************************************************
SUBROUTINE FOLD ( N, RX, RY, RZ )
C *******************************************************************
C ** SUBROUTINE TO FOLD TRAJECTORIES IN PERIODIC BOUNDARIES. **
C ** **
C ** THE FOLDING ROUTINE IS SIMPLY THE USUAL APPLICATION OF **
C ** BOUNDARY CONDITIONS. WE TAKE THE UNIT CUBE AS AN EXAMPLE. **
C ** **
C ** PRINCIPAL VARIABLES: **
C ** **
C ** INTEGER N NUMBER OF MOLECULES **
C ** REAL RX(N),RY(N),RZ(N) MOLECULAR POSITIONS **
C ** **
C ** USAGE: **
C ** **
C ** THE ROUTINE IS CALLED FOR EVERY CONFIGURATION GENERATED IN A **
C ** SIMULATION. **
C *******************************************************************
INTEGER N
REAL RX(N), RY(N), RZ(N)
INTEGER I
C *******************************************************************
DO 100 I = 1, N
RX(I) = RX(I) - ANINT ( RX(I) )
RY(I) = RY(I) - ANINT ( RY(I) )
RZ(I) = RZ(I) - ANINT ( RZ(I) )
100 CONTINUE
RETURN
END
SUBROUTINE UNFOLD ( N, RX, RY, RZ, RX0, RY0, RZ0 )
C *******************************************************************
C ** SUBROUTINE TO FOLD TRAJECTORIES IN PERIODIC BOUNDARIES. **
C ** **
C ** THE UNFOLDING ROUTINE UNDOES THE EFFECT OF FOLDING. **
C ** AGAIN WE TAKE THE UNIT CUBE AS AN EXAMPLE. **
C ** THIS ROUTINE REQUIRES THAT COORDINATES FROM SUCCESSIVE STEPS **
C ** BE SUPPLIED AND ASSUMES THAT NATURAL MOVEMENT ACROSS HALF A **
C ** BOX LENGTH IN ONE STEP WILL NEVER OCCUR. **
C ** THE RESULTING COORDINATES WOULD BE SUITABLE, FOR EXAMPLE, TO **
C ** CALCULATE THE DIFFUSION COEFFICIENT BY EINSTEIN'S RELATION. **
C ** **
C ** PRINCIPAL VARIABLES: **
C ** **
C ** INTEGER N NUMBER OF MOLECULES **
C ** REAL RX(N),RY(N),RZ(N) MOLECULAR POSITIONS AT TIME T **
C ** REAL RX0(N),RY0(N),RY0(N) MOLECULAR POSITIONS AT TIME T-DT **
C ** **
C ** USAGE: **
C ** **
C ** (1) READ INITIAL COORDINATES INTO RX0,RY0,RZ0 **
C ** (2) WRITE RX0,RY0,RZ0 TO OUTPUT FILE (OR USE IMMEDIATELY) **
C ** (3) READ NEXT STEP COORDINATES INTO RX,RY,RZ **
C ** (4) CALL UNFOLD ( N, RX, RY, RZ, RX0, RY0, RZ0 ) **
C ** (5) WRITE RX,RY,RZ TO OUTPUT FILE (OR USE IMMEDIATELY) **
C ** (6) SET RX0(I)=RX(I), RY0(I)=RY(I), RZ0(I)=RZ(I), I = 1,N **
C ** (7) UNLESS DATA EXHAUSTED, GO TO (3) **
C *******************************************************************
INTEGER N
REAL RX(N), RY(N), RZ(N), RX0(N), RY0(N), RZ0(N)
INTEGER I
REAL DX, DY, DZ
C *******************************************************************
DO 100 I = 1, N
DX = RX(I) - RX0(I)
DY = RY(I) - RY0(I)
DZ = RZ(I) - RZ0(I)
DX = DX - ANINT ( DX )
DY = DY - ANINT ( DY )
DZ = DZ - ANINT ( DZ )
RX(I) = RX0(I) + DX
RY(I) = RY0(I) + DY
RZ(I) = RZ0(I) + DZ
100 CONTINUE
RETURN
END
|