ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/ExtendedSystem.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/ExtendedSystem.cpp (file contents):
Revision 457 by gezelter, Fri Apr 4 19:16:11 2003 UTC vs.
Revision 471 by gezelter, Mon Apr 7 20:51:59 2003 UTC

# Line 5 | Line 5 | ExtendedSystem::ExtendedSystem( SimInfo &info ) {
5   #include "Thermo.hpp"
6   #include "ExtendedSystem.hpp"
7  
8 < ExtendedSystem::ExtendedSystem( SimInfo &info ) {
8 > ExtendedSystem::ExtendedSystem( SimInfo* the_entry_plug ) {
9  
10    // get what information we need from the SimInfo object
11    
12 <  entry_plug = &info;
13 <  nAtoms = info.n_atoms;
14 <  atoms = info.atoms;
15 <  nMols = info.n_mol;
16 <  molecules = info.molecules;
12 >  entry_plug = the_entry_plug;
13 >  nAtoms = entry_plug->n_atoms;
14 >  atoms = entry_plug->atoms;
15 >  nMols = entry_plug->n_mol;
16 >  molecules = entry_plug->molecules;
17 >  nOriented = entry_plug->n_oriented;
18 >  ndf = entry_plug->ndf;
19    zeta = 0.0;
20    epsilonDot = 0.0;
21  
22   }
23  
22 ExtendedSystem::~ExtendedSystem() {  
23 }
24
25
24   void ExtendedSystem::NoseHooverNVT( double dt, double ke ){
25  
26    // Basic thermostating via Hoover, Phys.Rev.A, 1985, Vol. 31 (5) 1695-1697
# Line 33 | Line 31 | void ExtendedSystem::NoseHooverNVT( double dt, double
31    const double kB = 8.31451e-7;     // boltzmann constant in amu*Ang^2*fs^-2/K
32    const double e_convert = 4.184e-4;    // to convert ke from kcal/mol to
33                                          // amu*Ang^2*fs^-2/K
34 <    
34 >  DirectionalAtom* dAtom;    
35 >
36    ke_temp = ke * e_convert;
37 <  NkBT = (double)getNDF() * kB * targetTemp;
37 >  NkBT = (double)ndf * kB * targetTemp;
38  
39    // advance the zeta term to zeta(t + dt) - zeta is 0.0d0 on config. readin
40    // qmass is set in the parameter file
41  
42    zeta += dt * ( (ke_temp*2.0 - NkBT) / qmass );
43 +  std::cerr << "ke_temp = " << ke_temp << "\n";
44 +
45    zetaScale = zeta * dt;
46 +  
47  
48 +
49    // perform thermostat scaling on linear velocities and angular momentum
50 <  for(i = 0; i < n_atoms; i++){
50 >  for(i = 0; i < nAtoms; i++){
51      
52      vx = atoms[i]->get_vx();
53      vy = atoms[i]->get_vy();
# Line 54 | Line 57 | void ExtendedSystem::NoseHooverNVT( double dt, double
57      atoms[i]->set_vy(vy * (1.0 - zetaScale));
58      atoms[i]->set_vz(vz * (1.0 - zetaScale));
59    }
60 <  if( n_oriented ){
60 >  if( nOriented ){
61      
62 <    for( i=0; i < n_atoms; i++ ){
62 >    for( i=0; i < nAtoms; i++ ){
63        
64        if( atoms[i]->isDirectional() ){
65          
# Line 89 | Line 92 | void ExtendedSystem::NoseHooverAndersonNPT( double dt,
92    const double e_convert = 4.184e-4;    // to convert ke from kcal/mol to
93                                          // amu*Ang^2*fs^-2/K
94  
95 <  double p_ext;
95 >  double p_ext, zetaScale, epsilonScale, scale, NkBT, ke_temp;
96 >  double volume, p_mol;
97 >  double vx, vy, vz, jx, jy, jz;
98 >  DirectionalAtom* dAtom;
99 >  int i;
100  
101    p_ext = targetPressure * p_units;
102    p_mol = p_int * p_units;
103  
104 <  getBox(oldBox);
104 >  entry_plug->getBox(oldBox);
105  
106    volume = oldBox[0]*oldBox[1]*oldBox[2];
107  
108    ke_temp = ke * e_convert;
109 <  NkBT = (double)getNDF() * kB * targetTemp;
109 >  NkBT = (double)ndf * kB * targetTemp;
110  
111    // propogate the strain rate
112  
# Line 114 | Line 121 | void ExtendedSystem::NoseHooverAndersonNPT( double dt,
121    newBox[2] = oldBox[2] * scale;
122    volume = newBox[0]*newBox[1]*newBox[2];
123  
124 +  entry_plug->setBox(newBox);
125 +
126    // perform affine transform to update positions with volume fluctuations
127    this->AffineTransform( oldBox, newBox );
128  
# Line 126 | Line 135 | void ExtendedSystem::NoseHooverAndersonNPT( double dt,
135    zetaScale = zeta * dt;
136    
137    // apply barostating and thermostating to velocities and angular momenta
138 <  for(i = 0; i < n_atoms; i++){
138 >  for(i = 0; i < nAtoms; i++){
139      
140      vx = atoms[i]->get_vx();
141      vy = atoms[i]->get_vy();
# Line 136 | Line 145 | void ExtendedSystem::NoseHooverAndersonNPT( double dt,
145      atoms[i]->set_vy(vy * (1.0 - zetaScale - epsilonScale));
146      atoms[i]->set_vz(vz * (1.0 - zetaScale - epsilonScale));
147    }
148 <  if( n_oriented ){
148 >  if( nOriented ){
149      
150 <    for( i=0; i < n_atoms; i++ ){
150 >    for( i=0; i < nAtoms; i++ ){
151        
152        if( atoms[i]->isDirectional() ){
153          
# Line 171 | Line 180 | void ExtendedSystem::AffineTransform( double oldBox[3]
180    
181    for (i=0; i < nMols; i++) {
182      
183 <    molecules[i]->getCOM(r);
183 >    molecules[i].getCOM(r);
184      
185      // find the minimum image coordinates of the molecular centers of mass:    
186      
# Line 197 | Line 206 | void ExtendedSystem::AffineTransform( double oldBox[3]
206      r[1] = ryi + boxNum[1];
207      r[2] = rzi + boxNum[2];
208  
209 <    molecules[i]->moveCOM(r);
209 >    molecules[i].moveCOM(r);
210    }
211   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines