ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/staticProps/PairCorrType.cpp
Revision: 810
Committed: Fri Oct 17 21:19:07 2003 UTC (20 years, 8 months ago) by mmeineke
File size: 3043 byte(s)
Log Message:
added the staticProps directory to the build list
for both configure  and configure.in


fixed a number of bugs in the staticProps code. gofr is now working.

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 isAtom1 = new bool[nAtoms];
26 isAtom2 = new bool[nAtoms];
27
28 jArray = NULL;
29
30 correlateMe = false;
31 isInitialized = false;
32
33 }
34
35 PairCorrType::~PairCorrType(){
36
37 delete[] isAtom1;
38 delete[] isAtom2;
39
40 }
41
42 void PairCorrType::initCorr( double theLengthScale, atomName* theNames ){
43 int i;
44
45 lengthScale = theLengthScale;
46 delR = lengthScale / nBins;
47
48 nAtoms1 = 0;
49 nAtoms2 = 0;
50
51 for( i=0; i<nAtoms; i++){
52
53 isAtom1[i] = !strcmp( atom1, theNames[i].name );
54 if( isAtom1[i] ) nAtoms1++;
55 isAtom2[i] = !strcmp( atom2, theNames[i].name );
56 if( isAtom2[i] ) nAtoms2++;
57 }
58
59 if( !strcmp( atom1, "_ALL_" ) ){
60 for(i=0;i<nAtoms;i++)isAtom1[i] = true;
61 nAtoms1 = nAtoms;
62 }
63
64 if( !strcmp( atom2, "_ALL_" ) ){
65 for(i=0;i<nAtoms;i++)isAtom2[i] = true;
66 nAtoms2 = nAtoms;
67 }
68
69 if(!nAtoms1){
70 sprintf( painCave.errMsg,
71 "\n"
72 "Atom \"%s\" was not found in the dump file by pair corelation:\n"
73 " %s < %s - %s >\n",
74 atom1,
75 corrType,
76 atom1,
77 atom2 );
78 painCave.isFatal = 1;
79 simError();
80 }
81
82 if(!nAtoms2){
83 sprintf( painCave.errMsg,
84 "\n"
85 "Atom \"%s\" was not found in the dump file by pair corelation:\n"
86 " %s < %s - %s >\n",
87 atom2,
88 corrType,
89 atom1,
90 atom2 );
91 painCave.isFatal = 1;
92 simError();
93 }
94
95 isInitialized = true;
96 }
97
98 void PairCorrType::setFrameVolume( double theVolume ){
99
100 volume = theVolume;
101
102 if( isSelfSelf ) pairDensity = nAtoms1 * (nAtoms1 - 1) / volume;
103 else pairDensity = nAtoms1 * nAtoms2 / volume;
104
105 pairConstant = ( 4.0 * M_PI * pairDensity ) / 3.0;
106
107 }
108
109 bool PairCorrType::matchI( int i ){
110
111 if( !isInitialized ){
112 sprintf( painCave.errMsg,
113 "Attempt to MatchI in <%s of %s - %s> before identity arrays"
114 " were initialized.\n",
115 corrType,
116 atom1,
117 atom2 );
118 painCave.isFatal = 1;
119 simError();
120 }
121
122 identI = -1;
123
124 if( isAtom1[i] ){
125
126 correlateMe = true;
127 identI = IS_A;
128 jArray = isAtom2;
129 return true;
130 }
131
132 if( isAtom2[i] ){
133
134 correlateMe = true;
135 identI = IS_B;
136 jArray = isAtom1;
137 return true;
138 }
139
140 correlateMe = false;
141 jArray = NULL;
142 return false;
143 }
144
145 bool PairCorrType::matchJ( int j ){
146
147 if( !isInitialized ){
148 sprintf( painCave.errMsg,
149 "Attempt to MatchJ in <%s of %s - %s> before identity arrays"
150 " were initialized.\n",
151 corrType,
152 atom1,
153 atom2 );
154 painCave.isFatal = 1;
155 simError();
156 }
157
158 if( correlateMe ){
159
160 if( jArray[j] ) return true;
161 }
162
163 correlateMe = false;
164 jArray = NULL;
165 return false;
166
167 }