ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/madProps/GofR.c
(Generate patch)

Comparing trunk/madProps/GofR.c (file contents):
Revision 46 by mmeineke, Tue Jul 23 20:10:49 2002 UTC vs.
Revision 103 by mmeineke, Thu Aug 29 17:21:54 2002 UTC

# Line 12 | Line 12 | void GofR( char* out_prefix, char* atom1, char* atom2,
12   // constant boxSize
13  
14   void GofR( char* out_prefix, char* atom1, char* atom2,
15 <           struct xyz_frame* frames, int nFrames ){
15 >           struct xyz_frame* frames, int nFrames,
16 >           int startFrame, int endFrame ){
17  
18    int i,j,k;
19  
# Line 20 | Line 21 | void GofR( char* out_prefix, char* atom1, char* atom2,
21    enum g_types the_type;
22    char* allAtom;
23    
24 <  double atom1Dens;
25 <  double atom2Dens;
25 <  double allDens;
24 >  double pairDens;
25 >  double pairConstant;
26  
27  double atom1Constant;
28  double atom2Constant;
29  double allConstant;
30
27    double nAtom1;
28    double nAtom2;
29    double nAtoms;
# Line 126 | Line 122 | void GofR( char* out_prefix, char* atom1, char* atom2,
122  
123      // calculate some of the constants;
124      
125 <    atom1Dens = nAtom1 / boxVol;
126 <    atom2Dens = nAtom2 / boxVol;
127 <    
128 <    atom1Constant = ( 4.0 * M_PI * atom1Dens ) / 3.0;
129 <    atom2Constant = ( 4.0 * M_PI * atom2Dens ) / 3.0;
134 <    
125 >    if( !strcmp( atom1, atom2 ) ) pairDens = nAtom1 * (nAtom1 - 1) / boxVol;
126 >    else pairDens = nAtom1 * nAtom2 / boxVol;
127 >
128 >    pairConstant = ( 4.0 * M_PI * pairDens ) / 3.0;
129 >        
130      // calculate the histogram
131  
132 <    for( i=0; i<nFrames; i++){
132 >    for( i=startFrame; i<endFrame; i++){
133        for( j=0; j<(frames[i].nAtoms-1); j++ ){
134          
135          if( !strcmp( frames[0].names[j], atom1 ) ){
# Line 201 | Line 196 | void GofR( char* out_prefix, char* atom1, char* atom2,
196        rUpper = rLower + delR;
197        
198        volSlice = pow( rUpper, 3.0 ) - pow( rLower, 3.0 );
199 <      nIdeal = volSlice * ( atom1Constant + atom2Constant );
199 >      nIdeal = volSlice * pairConstant;
200        
201 <      the_GofR[i] = histogram[i] / ( nFrames * ( nAtom1 + nAtom2 ) * nIdeal );
201 >      the_GofR[i] = histogram[i] / ( nFrames * nIdeal );
202        rValue[i] = rLower + ( delR / 2.0 );
203      }
204  
# Line 244 | Line 239 | void GofR( char* out_prefix, char* atom1, char* atom2,
239  
240      // calculate some of the constants;
241      
242 <    atom1Dens = nAtom1 / boxVol;
243 <    allDens  = frames[0].nAtoms / boxVol;
244 <    
250 <    atom1Constant = ( 4.0 * M_PI * atom1Dens ) / 3.0;
251 <    allConstant  = ( 4.0 * M_PI * allDens ) / 3.0;
252 <    
242 >    pairDens = frames[0].nAtoms * (nAtom1 - 1) / boxVol;
243 >    pairConstant =  ( 4.0 * M_PI * pairDens ) / 3.0;
244 >
245      // calculate the histogram
246  
247 <    for( i=0; i<nFrames; i++){
247 >    for( i=startFrame; i<endFrame; i++){
248        for( j=0; j<(frames[i].nAtoms-1); j++ ){
249          
250          if( !strcmp( frames[0].names[j], allAtom ) ){
# Line 316 | Line 308 | void GofR( char* out_prefix, char* atom1, char* atom2,
308        rUpper = rLower + delR;
309        
310        volSlice = pow( rUpper, 3.0 ) - pow( rLower, 3.0 );
311 <      nIdeal = volSlice * ( allConstant );
311 >      nIdeal = volSlice * pairConstant;
312        
313 <      the_GofR[i] = histogram[i] / ( nFrames * frames[0].nAtoms * nIdeal );
313 >      the_GofR[i] = histogram[i] / ( nFrames * nIdeal );
314        rValue[i] = rLower + ( delR / 2.0 );
315      }
316  
# Line 342 | Line 334 | void GofR( char* out_prefix, char* atom1, char* atom2,
334      
335      // calculate some of the constants;
336      
337 <    allDens  = frames[0].nAtoms / boxVol;
337 >    pairDens  = frames[0].nAtoms * (frames[0].nAtoms - 1) / boxVol;
338 >    pairConstant  = ( 4.0 * M_PI * pairDens ) / 3.0;
339      
347    allConstant  = ( 4.0 * M_PI * allDens ) / 3.0;
348    
340      // calculate the histogram
341  
342 <    for( i=0; i<nFrames; i++){
342 >    for( i=startFrame; i<endFrame; i++){
343        for( j=0; j<(frames[i].nAtoms-1); j++ ){
344          
345          rxj = frames[i].r[j].x;
# Line 382 | Line 373 | void GofR( char* out_prefix, char* atom1, char* atom2,
373        rUpper = rLower + delR;
374        
375        volSlice = pow( rUpper, 3.0 ) - pow( rLower, 3.0 );
376 <      nIdeal = volSlice * ( allConstant );
376 >      nIdeal = volSlice * pairConstant;
377        
378 <      the_GofR[i] = histogram[i] / ( nFrames * frames[0].nAtoms * nIdeal );
378 >      the_GofR[i] = histogram[i] / ( nFrames * nIdeal );
379        rValue[i] = rLower + ( delR / 2.0 );
380      }
381  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines