ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/staticProps/GofRtheta.cpp
Revision: 811
Committed: Tue Oct 21 19:33:19 2003 UTC (20 years, 8 months ago) by mmeineke
File size: 1979 byte(s)
Log Message:
added useInitTime to the BASS syntax.
   * useInitTime = false: sets the origin time to 0.0 regardless of the time stamp in the .init file
   * default=> useInitTime = true;

File Contents

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