-
Notifications
You must be signed in to change notification settings - Fork 14
/
mc-muvt-indices.f
129 lines (89 loc) · 4.74 KB
/
mc-muvt-indices.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
********************************************************************************
** FICHE F.14. ALGORITHM TO HANDLE INDICES IN CONSTANT MU VT MONTE CARLO **
** 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. **
********************************************************************************
C *******************************************************************
C ** INDEX-HANDLING IN GRAND CANONICAL MONTE CARLO SIMULATION. **
C ** **
C ** ROUTINES SUPPLIED: **
C ** **
C ** SUBROUTINE ADD ( RXNEW, RYNEW, RZNEW, N ) **
C ** ADDS AN ATOM TO THE ARRAY LOCATE. **
C ** SUBROUTINE REMOVE ( NLOC, IPULL, N ) **
C ** REMOVES AN ATOM FROM THE ARRAY LOCATE. **
C ** **
C ** PRINCIPAL VARIABLES: **
C ** **
C ** INTEGER N NUMBER OF ATOMS BEFORE TRIAL **
C ** INTEGER NMAX MAXIMUM NUMBER OF ATOMS **
C ** INTEGER IPULL INDEX OF ATOM FOR REMOVAL **
C ** INTEGER NLOC POSITION OF N IN LOCATE **
C ** INTEGER NTRIAL NUMBER OF ATOMS DURING TRIAL **
C ** INTEGER LOCATE(NMAX) ARRAY OF ACTIVE ATOM INDICES **
C ** REAL RXNEW,RYNEW,RZNEW POSITION FOR ADDITION OF AN ATOM **
C ** REAL RX(NMAX), ETC. POSITIONS OF ATOMS **
C ** **
C ** USAGE: **
C ** **
C ** ROUTINE ADD IS CALLED AFTER A SUCCESSFUL TRIAL ADDITION. **
C ** ROUTINE REMOVE IS CALLED AFTER A SUCCESSFUL TRIAL REMOVAL. **
C ** THE ARRAY LOCATE IS UPDATED IN EACH CASE. **
C *******************************************************************
SUBROUTINE ADD ( RXNEW, RYNEW, RZNEW, N )
COMMON / BLOCK1 / RX, RY, RZ
COMMON / BLOCK2 / LOCATE
C *******************************************************************
C ** SUBROUTINE TO ADD AN ATOM TO THE ARRAY LOCATE. **
C ** **
C ** THERE ARE N ATOMS IN THE SIMULATION BEFORE THE NEW ADDITION **
C *******************************************************************
INTEGER NMAX
PARAMETER ( NMAX = 500 )
REAL RX(NMAX), RY(NMAX), RZ(NMAX)
INTEGER LOCATE(NMAX)
REAL RXNEW, RYNEW, RZNEW
INTEGER N, IPULL
INTEGER INEW, NTRIAL
C *******************************************************************
NTRIAL = N + 1
INEW = LOCATE(NTRIAL)
IF ( INEW .EQ. 0 ) THEN
C ** ATOM REQUIRES A NEW NUMBER **
LOCATE(NTRIAL) = NTRIAL
INEW = NTRIAL
ENDIF
C ** FIT NEW ATOM INTO THE ARRAY **
RX(INEW) = RXNEW
RY(INEW) = RYNEW
RZ(INEW) = RZNEW
RETURN
END
SUBROUTINE REMOVE ( NLOC, IPULL, N )
COMMON / BLOCK1 / RX, RY, RZ
COMMON / BLOCK2 / LOCATE
C *******************************************************************
C ** SUBROUTINE TO REMOVE AN ATOM FROM THE ARRAY LOCATE. **
C ** **
C ** THERE ARE N ATOMS IN THE SIMULATION BEFORE THE REMOVAL. **
C ** ELEMENT IPULL OF LOCATE IS TO BE DESTROYED. **
C *******************************************************************
INTEGER NMAX
PARAMETER ( NMAX = 500 )
REAL RX(NMAX), RY(NMAX), RZ(NMAX)
INTEGER LOCATE(NMAX)
INTEGER N, IPULL, NLOC
INTEGER K
C *******************************************************************
IF ( NLOC .LT. N ) THEN
C ** CLOSE UP THE ARRAY LOCATE AFTER THE REMOVAL **
DO 10 K = NLOC + 1, N
LOCATE(K - 1) = LOCATE(K)
10 CONTINUE
C ** PLACE THE GHOST ATOM IPULL JUST OUTSIDE THE ACTIVE **
C ** RANGE OF THE ARRAY LOCATE FOR FUTURE USE **
LOCATE(N) = IPULL
ENDIF
RETURN
END