ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/props/GofR.cpp
Revision: 762
Committed: Fri Sep 12 20:51:29 2003 UTC (21 years, 7 months ago) by mmeineke
File size: 1598 byte(s)
Log Message:
added AllCorr. It eill still need some work

File Contents

# Content
1 #include <iostream>
2 #include <fstream>
3
4 #include <cstring>
5 #include <cmath>
6
7 #include "PairCorrType.hpp"
8
9 using namespace std;
10
11 GofR::GofR( char* key1, char* key2, int theNatoms ):
12 PairCorrType( key1, key2, theNatoms )
13 {
14 int i;
15
16 strcpy( corrType, "GofR" );
17
18 for(i=0;i<N_BINS;i++){
19 currHist[i] = 0;
20 currGofR[i] = 0.0;
21 avgGofR[i] = 0.0;
22 }
23
24 nFrames = 0;
25 }
26
27
28
29 void GofR::correlate( double[3] Rij, double dist,
30 double[3] uHatI, double[3] uHatJ ){
31 int bin;
32
33 if( correlateMe ){
34
35 bin = (int)( dist / delR );
36 if( bin < N_BINS )currHist[bin] += 2;
37
38 }
39 }
40
41 void GofR::accumulateFrame( void ){
42 int i;
43 double rLower, rUpper, volSlice;
44 int nIdeal;
45
46 nFrames++;
47
48 for(i=0;i<N_BINS;i++){
49
50 rLower = i * delR;
51 rUpper = rLower + delR;
52
53 volSlice = pow( rUpper, 3.0 ) - pow( rLower, 3.0 );
54 nIdeal = volSlice * pairConstant;
55
56 currGofR[i] = currHist[i] / nIdeal;
57 currHist[i] = 0;
58
59 avgGofR[i] += currGofR[i];
60 }
61 }
62
63
64 void GofR::writeCorr( char* outPrefix ){
65
66 double rValue, corrValue;
67 int i;
68 char outName[200];
69
70 sprintf( outName,
71 "%s-%s-%s.GofR",
72 outPrefix,
73 atom1,
74 atom2 );
75 ofstream outStream( outName );
76
77 if( !outStream ){
78
79 sprintf( painCave.errMsg,
80 "Error opening \"%s\" for output.\n",
81 outName );
82 painCave.isFatal = 1;
83 simError();
84 }
85
86 outStream << "#rValue\tcorrValue\n"
87
88 for(i=0;i<N_BINS;i++){
89
90 rValue = ( i + 0.5 ) * delR;
91 corrValue = avgGofR[i] / nFrames;
92
93 outStream << rValue << "\t" << corrValue << "\n";
94 }
95
96 outStream.close();
97 }