ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/integrators/NPTi.cpp
(Generate patch)

Comparing:
trunk/OOPSE-2.0/src/integrators/NPTi.cpp (file contents), Revision 1490 by gezelter, Fri Sep 24 04:16:43 2004 UTC vs.
branches/new_design/OOPSE-2.0/src/integrators/NPTi.cpp (file contents), Revision 1774 by tim, Tue Nov 23 23:12:23 2004 UTC

# Line 1 | Line 1
1   #include <math.h>
2 < #include "Atom.hpp"
3 < #include "SRI.hpp"
4 < #include "AbstractClasses.hpp"
5 < #include "SimInfo.hpp"
6 < #include "ForceFields.hpp"
7 < #include "Thermo.hpp"
8 < #include "ReadWrite.hpp"
9 < #include "Integrator.hpp"
10 < #include "simError.h"
2 > #include "primitives/Atom.hpp"
3 > #include "primitives/SRI.hpp"
4 > #include "primitives/AbstractClasses.hpp"
5 > #include "brains/SimInfo.hpp"
6 > #include "UseTheForce/ForceFields.hpp"
7 > #include "brains/Thermo.hpp"
8 > #include "io/ReadWrite.hpp"
9 > #include "integrators/Integrator.hpp"
10 > #include "utils/simError.h"
11  
12   #ifdef IS_MPI
13 < #include "mpiSimulation.hpp"
13 > #include "brains/mpiSimulation.hpp"
14   #endif
15  
16   // Basic isotropic thermostating and barostating via the Melchionna
# Line 23 | Line 23 | template<typename T> NPTi<T>::NPTi ( SimInfo *theInfo,
23   //
24   //    Hoover, W. G., 1986, Phys. Rev. A, 34, 2499.
25  
26 < template<typename T> NPTi<T>::NPTi ( SimInfo *theInfo, ForceFields* the_ff):
26 > NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff):
27    T( theInfo, the_ff )
28   {
29    GenericData* data;
30 <  DoubleArrayData * etaValue;
30 >  DoubleVectorGenericData * etaValue;
31    vector<double> etaArray;
32  
33    eta = 0.0;
# Line 35 | Line 35 | template<typename T> NPTi<T>::NPTi ( SimInfo *theInfo,
35  
36    if( theInfo->useInitXSstate ){
37      // retrieve eta from simInfo if
38 <    data = info->getProperty(ETAVALUE_ID);
38 >    data = info->getPropertyByName(ETAVALUE_ID);
39      if(data){
40 <      etaValue = dynamic_cast<DoubleArrayData*>(data);
40 >      etaValue = dynamic_cast<DoubleVectorGenericData*>(data);
41        
42        if(etaValue){
43 <        etaArray = etaValue->getData();
44 <        eta = etaArray[0];
43 >        eta = (*etaValue)[0];
44          oldEta = eta;
45        }
46      }
47    }
48   }
49  
50 < template<typename T> NPTi<T>::~NPTi() {
50 > NPTi::~NPTi() {
51    //nothing for now
52   }
53  
54 < template<typename T> void NPTi<T>::resetIntegrator() {
56 <  eta = 0.0;
57 <  T::resetIntegrator();
58 < }
59 <
60 < template<typename T> void NPTi<T>::evolveEtaA() {
54 > void NPTi::evolveEtaA() {
55    eta += dt2 * ( instaVol * (instaPress - targetPressure) /
56                   (p_convert*NkBT*tb2));
57    oldEta = eta;
58   }
59  
60 < template<typename T> void NPTi<T>::evolveEtaB() {
60 > void NPTi::evolveEtaB() {
61  
62    prevEta = eta;
63    eta = oldEta + dt2 * ( instaVol * (instaPress - targetPressure) /
64                   (p_convert*NkBT*tb2));
65   }
66  
67 < template<typename T> void NPTi<T>::calcVelScale(void) {
67 > void NPTi::calcVelScale() {
68    vScale = chi + eta;
69   }
70  
71 < template<typename T> void NPTi<T>::getVelScaleA(double sc[3], double vel[3]) {
72 <  int i;
79 <
80 <  for(i=0; i<3; i++) sc[i] = vel[i] * vScale;
71 > void NPTi::getVelScaleA(Vector3d& sc, const Vector3d& vel) {
72 >    sc = vel * vScale;
73   }
74  
75 < template<typename T> void NPTi<T>::getVelScaleB(double sc[3], int index ){
76 <  int i;
85 <
86 <  for(i=0; i<3; i++) sc[i] = oldVel[index*3 + i] * vScale;
75 > void NPTi::getVelScaleB(Vector3d& sc, int index ){
76 >    sc = oldVel[index] * vScale;    
77   }
78  
79  
80 < template<typename T> void NPTi<T>::getPosScale(double pos[3], double COM[3],
81 <                                               int index, double sc[3]){
82 <  int j;
83 <
84 <  for(j=0; j<3; j++)
95 <    sc[j] = ( oldPos[index*3+j] + pos[j]) / 2.0 - COM[j];
96 <
97 <  for(j=0; j<3; j++)
98 <    sc[j] *= eta;
80 > void NPTi::getPosScale(const Vector3d& pos, const Vector3d& COM,
81 >                                               int index, Vector3d& sc){
82 >    /**@todo*/
83 >    sc  = oldPos[index] + pos/2.0 -COM;
84 >    sc *= eta;
85   }
86  
87 < template<typename T> void NPTi<T>::scaleSimBox( void ){
87 > void NPTi::scaleSimBox(){
88  
89    double scaleFactor;
90  
# Line 118 | Line 104 | template<typename T> bool NPTi<T>::etaConverged() {
104  
105   }
106  
107 < template<typename T> bool NPTi<T>::etaConverged() {
107 > bool NPTi::etaConverged() {
108  
109    return ( fabs(prevEta - eta) <= etaTolerance );
110   }
111  
112 < template<typename T> double NPTi<T>::getConservedQuantity(void){
112 > double NPTi::calcConservedQuantity(){
113  
114    double conservedQuantity;
115    double Energy;
# Line 149 | Line 135 | template<typename T> double NPTi<T>::getConservedQuant
135    conservedQuantity = Energy + thermostat_kinetic + thermostat_potential +
136      barostat_kinetic + barostat_potential;
137  
152 //   cout.width(8);
153 //   cout.precision(8);
154
155 //   cerr << info->getTime() << "\t" << Energy << "\t" << thermostat_kinetic <<
156 //       "\t" << thermostat_potential << "\t" << barostat_kinetic <<
157 //       "\t" << barostat_potential << "\t" << conservedQuantity << endl;
138    return conservedQuantity;
139   }
140  
161 template<typename T> string NPTi<T>::getAdditionalParameters(void){
162  string parameters;
163  const int BUFFERSIZE = 2000; // size of the read buffer
164  char buffer[BUFFERSIZE];
165
166  sprintf(buffer,"\t%G\t%G;", chi, integralOfChidt);
167  parameters += buffer;
168
169  sprintf(buffer,"\t%G\t0\t0;", eta);
170  parameters += buffer;
171
172  sprintf(buffer,"\t0\t%G\t0;", eta);
173  parameters += buffer;
174
175  sprintf(buffer,"\t0\t0\t%G;", eta);
176  parameters += buffer;
177
178  return parameters;
179
180 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines