ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/staticProps/PairCorrType.cpp
Revision: 879
Committed: Tue Dec 16 20:49:11 2003 UTC (20 years, 6 months ago) by mmeineke
File size: 3292 byte(s)
Log Message:
finished gofRtheta and added gofRomega. both need to be debugged and tested.

File Contents

# Content
1 #include <iostream>
2 #include <cstdlib>
3 #include <cstring>
4 #include <math.h>
5
6 #include "simError.h"
7 #include "PairCorrType.hpp"
8
9
10 PairCorrType::PairCorrType( char* key1, char* key2, int theNatoms,
11 int theNbins ){
12
13 nBins = theNbins;
14
15 strcpy( atom1, key1 );
16 strcpy( atom2, key2 );
17
18 isSelfSelf = false;
19 if( !strcmp( atom1, atom2 ) ) isSelfSelf = true;
20
21 strcpy( corrType, "Donkey" );
22
23 nAtoms = theNatoms;
24
25 if( (nAtoms <= 0) || (nBins <= 0) ){
26 sprintf( painCave.errMsg,
27 "Pair Corr Type Error: nBins and nAtoms must be greater than 0\n"
28 " nBins = %d, nAtoms = %d\n",
29 nBins, nAtoms );
30 painCave.isFatal = 1;
31 simError();
32 }
33
34
35 isAtom1 = new bool[nAtoms];
36 isAtom2 = new bool[nAtoms];
37
38 jArray = NULL;
39
40 correlateMe = false;
41 isInitialized = false;
42
43 }
44
45 PairCorrType::~PairCorrType(){
46
47 delete[] isAtom1;
48 delete[] isAtom2;
49
50 }
51
52 void PairCorrType::initCorr( double theLengthScale, atomName* theNames ){
53 int i;
54
55 lengthScale = theLengthScale;
56 delR = lengthScale / nBins;
57
58 nAtoms1 = 0;
59 nAtoms2 = 0;
60
61 for( i=0; i<nAtoms; i++){
62
63 isAtom1[i] = !strcmp( atom1, theNames[i].name );
64 if( isAtom1[i] ) nAtoms1++;
65 isAtom2[i] = !strcmp( atom2, theNames[i].name );
66 if( isAtom2[i] ) nAtoms2++;
67 }
68
69 if( !strcmp( atom1, "_ALL_" ) ){
70 for(i=0;i<nAtoms;i++)isAtom1[i] = true;
71 nAtoms1 = nAtoms;
72 }
73
74 if( !strcmp( atom2, "_ALL_" ) ){
75 for(i=0;i<nAtoms;i++)isAtom2[i] = true;
76 nAtoms2 = nAtoms;
77 }
78
79 if(!nAtoms1){
80 sprintf( painCave.errMsg,
81 "\n"
82 "Atom \"%s\" was not found in the dump file by pair corelation:\n"
83 " %s < %s - %s >\n",
84 atom1,
85 corrType,
86 atom1,
87 atom2 );
88 painCave.isFatal = 1;
89 simError();
90 }
91
92 if(!nAtoms2){
93 sprintf( painCave.errMsg,
94 "\n"
95 "Atom \"%s\" was not found in the dump file by pair corelation:\n"
96 " %s < %s - %s >\n",
97 atom2,
98 corrType,
99 atom1,
100 atom2 );
101 painCave.isFatal = 1;
102 simError();
103 }
104
105 isInitialized = true;
106 }
107
108 void PairCorrType::setFrameVolume( double theVolume ){
109
110 volume = theVolume;
111
112 if( isSelfSelf ) pairDensity = nAtoms1 * (nAtoms1 - 1) / volume;
113 else pairDensity = nAtoms1 * nAtoms2 / volume;
114
115 pairConstant = ( 4.0 * M_PI * pairDensity ) / 3.0;
116
117 }
118
119 bool PairCorrType::matchI( int i ){
120
121 if( !isInitialized ){
122 sprintf( painCave.errMsg,
123 "Attempt to MatchI in <%s of %s - %s> before identity arrays"
124 " were initialized.\n",
125 corrType,
126 atom1,
127 atom2 );
128 painCave.isFatal = 1;
129 simError();
130 }
131
132 identI = -1;
133
134 if( isAtom1[i] ){
135
136 correlateMe = true;
137 identI = IS_A;
138 jArray = isAtom2;
139 return true;
140 }
141
142 if( isAtom2[i] ){
143
144 correlateMe = true;
145 identI = IS_B;
146 jArray = isAtom1;
147 return true;
148 }
149
150 correlateMe = false;
151 jArray = NULL;
152 return false;
153 }
154
155 bool PairCorrType::matchJ( int j ){
156
157 if( !isInitialized ){
158 sprintf( painCave.errMsg,
159 "Attempt to MatchJ in <%s of %s - %s> before identity arrays"
160 " were initialized.\n",
161 corrType,
162 atom1,
163 atom2 );
164 painCave.isFatal = 1;
165 simError();
166 }
167
168 if( correlateMe ){
169
170 if( jArray[j] ) return true;
171 }
172
173 correlateMe = false;
174 jArray = NULL;
175 return false;
176
177 }