# | Line 5 | Line 5 | |
---|---|---|
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 | zeta = 0.0; | |
14 | epsilonDot = 0.0; | |
19 | – | |
15 | } | |
16 | ||
22 | – | ExtendedSystem::~ExtendedSystem() { |
23 | – | } |
24 | – | |
25 | – | |
17 | void ExtendedSystem::NoseHooverNVT( double dt, double ke ){ | |
18 | ||
19 | // Basic thermostating via Hoover, Phys.Rev.A, 1985, Vol. 31 (5) 1695-1697 | |
# | Line 33 | Line 24 | void ExtendedSystem::NoseHooverNVT( double dt, double | |
24 | const double kB = 8.31451e-7; // boltzmann constant in amu*Ang^2*fs^-2/K | |
25 | const double e_convert = 4.184e-4; // to convert ke from kcal/mol to | |
26 | // amu*Ang^2*fs^-2/K | |
27 | < | |
27 | > | DirectionalAtom* dAtom; |
28 | > | atoms = entry_plug->atoms; |
29 | > | |
30 | ke_temp = ke * e_convert; | |
31 | < | NkBT = (double)getNDF() * kB * targetTemp; |
31 | > | NkBT = (double)entry_plug->ndf * kB * targetTemp; |
32 | ||
33 | // advance the zeta term to zeta(t + dt) - zeta is 0.0d0 on config. readin | |
34 | // qmass is set in the parameter file | |
35 | ||
36 | zeta += dt * ( (ke_temp*2.0 - NkBT) / qmass ); | |
37 | + | |
38 | zetaScale = zeta * dt; | |
39 | + | |
40 | + | std::cerr << "zetaScale = " << zetaScale << "\n"; |
41 | ||
42 | // perform thermostat scaling on linear velocities and angular momentum | |
43 | < | for(i = 0; i < n_atoms; i++){ |
43 | > | for(i = 0; i < entry_plug->n_atoms; i++){ |
44 | ||
45 | vx = atoms[i]->get_vx(); | |
46 | vy = atoms[i]->get_vy(); | |
47 | vz = atoms[i]->get_vz(); | |
48 | < | |
48 | > | |
49 | atoms[i]->set_vx(vx * (1.0 - zetaScale)); | |
50 | atoms[i]->set_vy(vy * (1.0 - zetaScale)); | |
51 | atoms[i]->set_vz(vz * (1.0 - zetaScale)); | |
52 | } | |
53 | < | if( n_oriented ){ |
53 | > | if( entry_plug->n_oriented ){ |
54 | ||
55 | < | for( i=0; i < n_atoms; i++ ){ |
55 | > | for( i=0; i < entry_plug->n_atoms; i++ ){ |
56 | ||
57 | if( atoms[i]->isDirectional() ){ | |
58 | ||
# | Line 89 | Line 85 | void ExtendedSystem::NoseHooverAndersonNPT( double dt, | |
85 | const double e_convert = 4.184e-4; // to convert ke from kcal/mol to | |
86 | // amu*Ang^2*fs^-2/K | |
87 | ||
88 | < | double p_ext; |
88 | > | int i; |
89 | > | double p_ext, zetaScale, epsilonScale, scale, NkBT, ke_temp; |
90 | > | double volume, p_mol; |
91 | > | double vx, vy, vz, jx, jy, jz; |
92 | > | DirectionalAtom* dAtom; |
93 | > | atoms = entry_plug->atoms; |
94 | ||
95 | p_ext = targetPressure * p_units; | |
96 | p_mol = p_int * p_units; | |
97 | ||
98 | < | getBox(oldBox); |
98 | < | |
98 | > | entry_plug->getBox(oldBox); |
99 | volume = oldBox[0]*oldBox[1]*oldBox[2]; | |
100 | ||
101 | ke_temp = ke * e_convert; | |
102 | < | NkBT = (double)getNDF() * kB * targetTemp; |
102 | > | NkBT = (double)entry_plug->ndf * kB * targetTemp; |
103 | ||
104 | // propogate the strain rate | |
105 | ||
# | Line 114 | Line 114 | void ExtendedSystem::NoseHooverAndersonNPT( double dt, | |
114 | newBox[2] = oldBox[2] * scale; | |
115 | volume = newBox[0]*newBox[1]*newBox[2]; | |
116 | ||
117 | + | entry_plug->setBox(newBox); |
118 | + | |
119 | // perform affine transform to update positions with volume fluctuations | |
120 | this->AffineTransform( oldBox, newBox ); | |
121 | ||
# | Line 124 | Line 126 | void ExtendedSystem::NoseHooverAndersonNPT( double dt, | |
126 | ||
127 | zeta += dt * ( (ke_temp*2.0 - NkBT) / qmass ); | |
128 | zetaScale = zeta * dt; | |
129 | + | |
130 | + | std::cerr << "zetaScale = " << zetaScale << " epsilonScale = " << epsilonScale << "\n"; |
131 | ||
132 | // apply barostating and thermostating to velocities and angular momenta | |
133 | < | for(i = 0; i < n_atoms; i++){ |
133 | > | for(i = 0; i < entry_plug->n_atoms; i++){ |
134 | ||
135 | vx = atoms[i]->get_vx(); | |
136 | vy = atoms[i]->get_vy(); | |
# | Line 136 | Line 140 | void ExtendedSystem::NoseHooverAndersonNPT( double dt, | |
140 | atoms[i]->set_vy(vy * (1.0 - zetaScale - epsilonScale)); | |
141 | atoms[i]->set_vz(vz * (1.0 - zetaScale - epsilonScale)); | |
142 | } | |
143 | < | if( n_oriented ){ |
143 | > | if( entry_plug->n_oriented ){ |
144 | ||
145 | < | for( i=0; i < n_atoms; i++ ){ |
145 | > | for( i=0; i < entry_plug->n_atoms; i++ ){ |
146 | ||
147 | if( atoms[i]->isDirectional() ){ | |
148 | ||
# | Line 162 | Line 166 | void ExtendedSystem::AffineTransform( double oldBox[3] | |
166 | double r[3]; | |
167 | double boxNum[3]; | |
168 | double percentScale[3]; | |
169 | + | double delta[3]; |
170 | double rxi, ryi, rzi; | |
171 | + | |
172 | + | molecules = entry_plug->molecules; |
173 | ||
174 | // first determine the scaling factor from the box size change | |
175 | percentScale[0] = (newBox[0] - oldBox[0]) / oldBox[0]; | |
176 | percentScale[1] = (newBox[1] - oldBox[1]) / oldBox[1]; | |
177 | percentScale[2] = (newBox[2] - oldBox[2]) / oldBox[2]; | |
178 | ||
179 | < | for (i=0; i < nMols; i++) { |
179 | > | for (i=0; i < entry_plug->n_mol; i++) { |
180 | ||
181 | < | molecules[i]->getCOM(r); |
182 | < | |
181 | > | molecules[i].getCOM(r); |
182 | > | |
183 | // find the minimum image coordinates of the molecular centers of mass: | |
184 | ||
185 | boxNum[0] = oldBox[0] * copysign(1.0,r[0]) * | |
# | Line 193 | Line 200 | void ExtendedSystem::AffineTransform( double oldBox[3] | |
200 | ryi += ryi*percentScale[1]; | |
201 | rzi += rzi*percentScale[2]; | |
202 | ||
203 | < | r[0] = rxi + boxNum[0]; |
204 | < | r[1] = ryi + boxNum[1]; |
205 | < | r[2] = rzi + boxNum[2]; |
203 | > | delta[0] = r[0] - (rxi + boxNum[0]); |
204 | > | delta[1] = r[1] - (ryi + boxNum[1]); |
205 | > | delta[2] = r[2] - (rzi + boxNum[2]); |
206 | ||
207 | < | molecules[i]->moveCOM(r); |
207 | > | molecules[i].moveCOM(delta); |
208 | } | |
209 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |