ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/Snapshot.cpp
(Generate patch)

Comparing:
trunk/src/brains/Snapshot.cpp (file contents), Revision 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
branches/development/src/brains/Snapshot.cpp (file contents), Revision 1568 by gezelter, Wed May 25 16:20:37 2011 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 + * [4]  Vardeman & Gezelter, in progress (2009).                        
40   */
41    
42   /**
# Line 51 | Line 51
51   #include "utils/NumericConstant.hpp"
52   #include "utils/simError.h"
53   #include "utils/Utility.hpp"
54 < namespace oopse {
54 > #include <cstdio>
55  
56 + namespace OpenMD {
57 +
58    void  Snapshot::setHmat(const Mat3x3d& m) {
57    const double orthoTolerance = NumericConstant::epsilon;
59      hmat_ = m;
60      invHmat_ = hmat_.inverse();
61      
62      //prepare fortran Hmat
63 <    double fortranHmat[9];
64 <    double fortranInvHmat[9];
63 >    RealType fortranHmat[9];
64 >    RealType fortranInvHmat[9];
65      hmat_.getArray(fortranHmat);
66      invHmat_.getArray(fortranInvHmat);
67  
68      //determine whether the box is orthoTolerance or not
69      int oldOrthoRhombic = orthoRhombic_;
70      
71 <    double smallDiag = fabs(hmat_(0, 0));
71 >    RealType smallDiag = fabs(hmat_(0, 0));
72      if(smallDiag > fabs(hmat_(1, 1))) smallDiag = fabs(hmat_(1, 1));
73      if(smallDiag > fabs(hmat_(2, 2))) smallDiag = fabs(hmat_(2, 2));    
74 <    double tol = smallDiag * orthoTolerance;
74 >    RealType tol = smallDiag * orthoTolerance_;
75  
76      orthoRhombic_ = 1;
77  
# Line 89 | Line 90 | namespace oopse {
90  
91        if( orthoRhombic_ ) {
92          sprintf( painCave.errMsg,
93 <                 "OOPSE is switching from the default Non-Orthorhombic\n"
93 >                 "OpenMD is switching from the default Non-Orthorhombic\n"
94                   "\tto the faster Orthorhombic periodic boundary computations.\n"
95 <                 "\tThis is usually a good thing, but if you wan't the\n"
95 >                 "\tThis is usually a good thing, but if you want the\n"
96                   "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n"
97                   "\tvariable ( currently set to %G ) smaller.\n",
98 <                 orthoTolerance);
99 <        painCave.severity = OOPSE_INFO;
98 >                 orthoTolerance_);
99 >        painCave.severity = OPENMD_INFO;
100          simError();
101        }
102        else {
103          sprintf( painCave.errMsg,
104 <                 "OOPSE is switching from the faster Orthorhombic to the more\n"
104 >                 "OpenMD is switching from the faster Orthorhombic to the more\n"
105                   "\tflexible Non-Orthorhombic periodic boundary computations.\n"
106                   "\tThis is usually because the box has deformed under\n"
107 <                 "\tNPTf integration. If you wan't to live on the edge with\n"
107 >                 "\tNPTf integration. If you want to live on the edge with\n"
108                   "\tthe Orthorhombic computations, make the orthoBoxTolerance\n"
109                   "\tvariable ( currently set to %G ) larger.\n",
110 <                 orthoTolerance);
111 <        painCave.severity = OOPSE_WARNING;
110 >                 orthoTolerance_);
111 >        painCave.severity = OPENMD_WARNING;
112          simError();
113        }
114      }    
115  
116      //notify fortran simulation box has changed
117 <    setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_);
117 >    // setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_);
118    }
119  
120  
121    void Snapshot::wrapVector(Vector3d& pos) {
122 +    
123 +    Vector3d scaled = scaleVector(pos);
124 +    
125 +    for (int i = 0; i < 3; i++)
126 +      scaled[i] -= roundMe(scaled[i]);
127  
128 <    int i;
129 <    Vector3d scaled;
128 >    if( !orthoRhombic_ )
129 >      pos = hmat_ * scaled;    
130 >    else {
131  
125    if( !orthoRhombic_ ){
126
127      // calc the scaled coordinates.
128      scaled = invHmat_* pos;
129
130      // wrap the scaled coordinates
131      for (i = 0; i < 3; ++i) {
132        scaled[i] -= roundMe(scaled[i]);
133      }
134
132        // calc the wrapped real coordinates from the wrapped scaled coordinates
133 <      pos = hmat_ * scaled;    
133 >      for (int i=0; i<3; i++) {
134 >        pos[i] = scaled[i] * hmat_(i, i);
135 >      }  
136 >    }
137 >  }
138  
139 <    } else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element
139 >  inline Vector3d Snapshot::scaleVector(Vector3d& pos) {  
140      
141 <      // calc the scaled coordinates.
141 <      for (i=0; i<3; i++) {
142 <        scaled[i] = pos[i] * invHmat_(i, i);
143 <      }
144 <        
145 <      // wrap the scaled coordinates
146 <      for (i = 0; i < 3; ++i) {
147 <        scaled[i] -= roundMe(scaled[i]);
148 <      }
141 >    Vector3d scaled;
142  
143 <      // calc the wrapped real coordinates from the wrapped scaled coordinates
144 <      for (i=0; i<3; i++) {
145 <        pos[i] = scaled[i] * hmat_(i, i);
146 <      }
147 <        
143 >    if( !orthoRhombic_ )
144 >      scaled = invHmat_* pos;
145 >    else {
146 >      // calc the scaled coordinates.
147 >      for (int i=0; i<3; i++)
148 >        scaled[i] = pos[i] * invHmat_(i, i);
149      }
150  
151 +    return scaled;
152    }
153 <
153 >  
154 >  Vector3d Snapshot::getCOM() {
155 >    if( !hasCOM_ ) {
156 >      sprintf( painCave.errMsg, "COM was requested before COM was computed!\n");
157 >      painCave.severity = OPENMD_ERROR;
158 >      simError();
159 >    }
160 >    return COM_;
161 >  }
162 >  
163 >  Vector3d Snapshot::getCOMvel() {
164 >    if( !hasCOM_ ) {
165 >      sprintf( painCave.errMsg, "COMvel was requested before COM was computed!\n");
166 >      painCave.severity = OPENMD_ERROR;
167 >      simError();
168 >    }
169 >    return COMvel_;
170 >  }
171 >  
172 >  Vector3d Snapshot::getCOMw() {
173 >    if( !hasCOM_ ) {
174 >      sprintf( painCave.errMsg, "COMw was requested before COM was computed!\n");
175 >      painCave.severity = OPENMD_ERROR;
176 >      simError();
177 >    }
178 >    return COMw_;
179 >  }
180   }
181    

Comparing:
trunk/src/brains/Snapshot.cpp (property svn:keywords), Revision 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
branches/development/src/brains/Snapshot.cpp (property svn:keywords), Revision 1568 by gezelter, Wed May 25 16:20:37 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines