# | Line 1 | Line 1 | |
---|---|---|
1 | #include <iostream> | |
2 | < | #include <cstdlib> |
3 | < | #include <cmath> |
2 | > | #include <stdlib.h> |
3 | > | #include <math.h> |
4 | ||
5 | #ifdef IS_MPI | |
6 | #include "mpiSimulation.hpp" | |
7 | #include <unistd.h> | |
8 | #endif //is_mpi | |
9 | ||
10 | + | #ifdef PROFILE |
11 | + | #include "mdProfile.hpp" |
12 | + | #endif // profile |
13 | + | |
14 | #include "Integrator.hpp" | |
15 | #include "simError.h" | |
16 | ||
17 | ||
18 | < | template<typename T> Integrator<T>::Integrator( SimInfo *theInfo, ForceFields* the_ff ) { |
19 | < | |
18 | > | template<typename T> Integrator<T>::Integrator(SimInfo* theInfo, |
19 | > | ForceFields* the_ff){ |
20 | info = theInfo; | |
21 | myFF = the_ff; | |
22 | isFirst = 1; | |
# | Line 21 | Line 25 | template<typename T> Integrator<T>::Integrator( SimInf | |
25 | nMols = info->n_mol; | |
26 | ||
27 | // give a little love back to the SimInfo object | |
24 | – | |
25 | – | if( info->the_integrator != NULL ) delete info->the_integrator; |
26 | – | info->the_integrator = this; |
28 | ||
29 | < | nAtoms = info->n_atoms; |
29 | > | if (info->the_integrator != NULL){ |
30 | > | delete info->the_integrator; |
31 | > | } |
32 | ||
33 | + | nAtoms = info->n_atoms; |
34 | + | integrableObjects = info->integrableObjects; |
35 | + | |
36 | // check for constraints | |
37 | < | |
38 | < | constrainedA = NULL; |
39 | < | constrainedB = NULL; |
37 | > | |
38 | > | constrainedA = NULL; |
39 | > | constrainedB = NULL; |
40 | constrainedDsqr = NULL; | |
41 | < | moving = NULL; |
42 | < | moved = NULL; |
43 | < | oldPos = NULL; |
44 | < | |
41 | > | moving = NULL; |
42 | > | moved = NULL; |
43 | > | oldPos = NULL; |
44 | > | |
45 | nConstrained = 0; | |
46 | ||
47 | checkConstraints(); | |
48 | + | |
49 | } | |
50 | ||
51 | < | template<typename T> Integrator<T>::~Integrator() { |
52 | < | |
46 | < | if( nConstrained ){ |
51 | > | template<typename T> Integrator<T>::~Integrator(){ |
52 | > | if (nConstrained){ |
53 | delete[] constrainedA; | |
54 | delete[] constrainedB; | |
55 | delete[] constrainedDsqr; | |
# | Line 51 | Line 57 | template<typename T> Integrator<T>::~Integrator() { | |
57 | delete[] moved; | |
58 | delete[] oldPos; | |
59 | } | |
54 | – | |
60 | } | |
61 | ||
62 | < | template<typename T> void Integrator<T>::checkConstraints( void ){ |
58 | < | |
59 | < | |
62 | > | template<typename T> void Integrator<T>::checkConstraints(void){ |
63 | isConstrained = 0; | |
64 | ||
65 | < | Constraint *temp_con; |
66 | < | Constraint *dummy_plug; |
65 | > | Constraint* temp_con; |
66 | > | Constraint* dummy_plug; |
67 | temp_con = new Constraint[info->n_SRI]; | |
68 | nConstrained = 0; | |
69 | int constrained = 0; | |
70 | < | |
70 | > | |
71 | SRI** theArray; | |
72 | < | for(int i = 0; i < nMols; i++){ |
73 | < | |
74 | < | theArray = (SRI**) molecules[i].getMyBonds(); |
75 | < | for(int j=0; j<molecules[i].getNBonds(); j++){ |
73 | < | |
72 | > | for (int i = 0; i < nMols; i++){ |
73 | > | |
74 | > | theArray = (SRI * *) molecules[i].getMyBonds(); |
75 | > | for (int j = 0; j < molecules[i].getNBonds(); j++){ |
76 | constrained = theArray[j]->is_constrained(); | |
77 | ||
78 | < | if(constrained){ |
78 | > | if (constrained){ |
79 | > | dummy_plug = theArray[j]->get_constraint(); |
80 | > | temp_con[nConstrained].set_a(dummy_plug->get_a()); |
81 | > | temp_con[nConstrained].set_b(dummy_plug->get_b()); |
82 | > | temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
83 | ||
84 | < | dummy_plug = theArray[j]->get_constraint(); |
85 | < | temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
86 | < | temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
81 | < | temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
82 | < | |
83 | < | nConstrained++; |
84 | < | constrained = 0; |
85 | < | } |
84 | > | nConstrained++; |
85 | > | constrained = 0; |
86 | > | } |
87 | } | |
88 | ||
89 | < | theArray = (SRI**) molecules[i].getMyBends(); |
90 | < | for(int j=0; j<molecules[i].getNBends(); j++){ |
90 | < | |
89 | > | theArray = (SRI * *) molecules[i].getMyBends(); |
90 | > | for (int j = 0; j < molecules[i].getNBends(); j++){ |
91 | constrained = theArray[j]->is_constrained(); | |
92 | < | |
93 | < | if(constrained){ |
94 | < | |
95 | < | dummy_plug = theArray[j]->get_constraint(); |
96 | < | temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
97 | < | temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
98 | < | temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
99 | < | |
100 | < | nConstrained++; |
101 | < | constrained = 0; |
92 | > | |
93 | > | if (constrained){ |
94 | > | dummy_plug = theArray[j]->get_constraint(); |
95 | > | temp_con[nConstrained].set_a(dummy_plug->get_a()); |
96 | > | temp_con[nConstrained].set_b(dummy_plug->get_b()); |
97 | > | temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
98 | > | |
99 | > | nConstrained++; |
100 | > | constrained = 0; |
101 | } | |
102 | } | |
103 | ||
104 | < | theArray = (SRI**) molecules[i].getMyTorsions(); |
105 | < | for(int j=0; j<molecules[i].getNTorsions(); j++){ |
107 | < | |
104 | > | theArray = (SRI * *) molecules[i].getMyTorsions(); |
105 | > | for (int j = 0; j < molecules[i].getNTorsions(); j++){ |
106 | constrained = theArray[j]->is_constrained(); | |
107 | < | |
108 | < | if(constrained){ |
109 | < | |
110 | < | dummy_plug = theArray[j]->get_constraint(); |
111 | < | temp_con[nConstrained].set_a( dummy_plug->get_a() ); |
112 | < | temp_con[nConstrained].set_b( dummy_plug->get_b() ); |
113 | < | temp_con[nConstrained].set_dsqr( dummy_plug->get_dsqr() ); |
114 | < | |
115 | < | nConstrained++; |
118 | < | constrained = 0; |
107 | > | |
108 | > | if (constrained){ |
109 | > | dummy_plug = theArray[j]->get_constraint(); |
110 | > | temp_con[nConstrained].set_a(dummy_plug->get_a()); |
111 | > | temp_con[nConstrained].set_b(dummy_plug->get_b()); |
112 | > | temp_con[nConstrained].set_dsqr(dummy_plug->get_dsqr()); |
113 | > | |
114 | > | nConstrained++; |
115 | > | constrained = 0; |
116 | } | |
117 | } | |
118 | } | |
119 | ||
120 | < | if(nConstrained > 0){ |
121 | < | |
120 | > | |
121 | > | if (nConstrained > 0){ |
122 | isConstrained = 1; | |
123 | ||
124 | < | if(constrainedA != NULL ) delete[] constrainedA; |
125 | < | if(constrainedB != NULL ) delete[] constrainedB; |
126 | < | if(constrainedDsqr != NULL ) delete[] constrainedDsqr; |
124 | > | if (constrainedA != NULL) |
125 | > | delete[] constrainedA; |
126 | > | if (constrainedB != NULL) |
127 | > | delete[] constrainedB; |
128 | > | if (constrainedDsqr != NULL) |
129 | > | delete[] constrainedDsqr; |
130 | ||
131 | < | constrainedA = new int[nConstrained]; |
132 | < | constrainedB = new int[nConstrained]; |
131 | > | constrainedA = new int[nConstrained]; |
132 | > | constrainedB = new int[nConstrained]; |
133 | constrainedDsqr = new double[nConstrained]; | |
134 | < | |
135 | < | for( int i = 0; i < nConstrained; i++){ |
136 | < | |
134 | > | |
135 | > | for (int i = 0; i < nConstrained; i++){ |
136 | constrainedA[i] = temp_con[i].get_a(); | |
137 | constrainedB[i] = temp_con[i].get_b(); | |
138 | constrainedDsqr[i] = temp_con[i].get_dsqr(); | |
140 | – | |
139 | } | |
140 | ||
141 | < | |
142 | < | // save oldAtoms to check for lode balanceing later on. |
143 | < | |
141 | > | |
142 | > | // save oldAtoms to check for lode balancing later on. |
143 | > | |
144 | oldAtoms = nAtoms; | |
145 | < | |
145 | > | |
146 | moving = new int[nAtoms]; | |
147 | < | moved = new int[nAtoms]; |
147 | > | moved = new int[nAtoms]; |
148 | ||
149 | < | oldPos = new double[nAtoms*3]; |
149 | > | oldPos = new double[nAtoms * 3]; |
150 | } | |
151 | < | |
151 | > | |
152 | delete[] temp_con; | |
153 | } | |
154 | ||
155 | ||
156 | < | template<typename T> void Integrator<T>::integrate( void ){ |
156 | > | template<typename T> void Integrator<T>::integrate(void){ |
157 | ||
158 | < | int i, j; // loop counters |
159 | < | |
160 | < | double runTime = info->run_time; |
163 | < | double sampleTime = info->sampleTime; |
164 | < | double statusTime = info->statusTime; |
158 | > | double runTime = info->run_time; |
159 | > | double sampleTime = info->sampleTime; |
160 | > | double statusTime = info->statusTime; |
161 | double thermalTime = info->thermalTime; | |
162 | + | double resetTime = info->resetTime; |
163 | ||
164 | + | double difference; |
165 | double currSample; | |
166 | double currThermal; | |
167 | double currStatus; | |
168 | + | double currReset; |
169 | ||
170 | int calcPot, calcStress; | |
172 | – | int isError; |
171 | ||
172 | < | tStats = new Thermo( info ); |
173 | < | statOut = new StatWriter( info ); |
174 | < | dumpOut = new DumpWriter( info ); |
172 | > | tStats = new Thermo(info); |
173 | > | statOut = new StatWriter(info); |
174 | > | dumpOut = new DumpWriter(info); |
175 | ||
176 | atoms = info->atoms; | |
179 | – | DirectionalAtom* dAtom; |
177 | ||
178 | dt = info->dt; | |
179 | dt2 = 0.5 * dt; | |
180 | ||
181 | + | readyCheck(); |
182 | + | |
183 | + | // remove center of mass drift velocity (in case we passed in a configuration |
184 | + | // that was drifting |
185 | + | tStats->removeCOMdrift(); |
186 | + | |
187 | + | // initialize the retraints if necessary |
188 | + | if (info->useSolidThermInt && !info->useLiquidThermInt) { |
189 | + | myFF->initRestraints(); |
190 | + | } |
191 | + | |
192 | // initialize the forces before the first step | |
193 | ||
194 | calcForce(1, 1); | |
195 | < | // myFF->doForces(1,1); |
196 | < | |
197 | < | if( info->setTemp ){ |
198 | < | |
199 | < | thermalize(); |
195 | > | |
196 | > | if (nConstrained){ |
197 | > | preMove(); |
198 | > | constrainA(); |
199 | > | calcForce(1, 1); |
200 | > | constrainB(); |
201 | } | |
202 | ||
203 | + | if (info->setTemp){ |
204 | + | thermalize(); |
205 | + | } |
206 | + | |
207 | calcPot = 0; | |
208 | calcStress = 0; | |
209 | currSample = sampleTime + info->getTime(); | |
210 | currThermal = thermalTime+ info->getTime(); | |
211 | currStatus = statusTime + info->getTime(); | |
212 | + | currReset = resetTime + info->getTime(); |
213 | ||
214 | < | dumpOut->writeDump( info->getTime() ); |
215 | < | statOut->writeStat( info->getTime() ); |
214 | > | dumpOut->writeDump(info->getTime()); |
215 | > | statOut->writeStat(info->getTime()); |
216 | ||
203 | – | readyCheck(); |
217 | ||
218 | #ifdef IS_MPI | |
219 | < | strcpy( checkPointMsg, |
207 | < | "The integrator is ready to go." ); |
219 | > | strcpy(checkPointMsg, "The integrator is ready to go."); |
220 | MPIcheckPoint(); | |
221 | #endif // is_mpi | |
222 | ||
223 | < | while( info->getTime() < runTime ){ |
224 | < | |
225 | < | if( (info->getTime()+dt) >= currStatus ){ |
223 | > | while (info->getTime() < runTime && !stopIntegrator()){ |
224 | > | difference = info->getTime() + dt - currStatus; |
225 | > | if (difference > 0 || fabs(difference) < 1e-4 ){ |
226 | calcPot = 1; | |
227 | calcStress = 1; | |
228 | } | |
229 | ||
230 | < | integrateStep( calcPot, calcStress ); |
231 | < | |
230 | > | #ifdef PROFILE |
231 | > | startProfile( pro1 ); |
232 | > | #endif |
233 | > | |
234 | > | integrateStep(calcPot, calcStress); |
235 | > | |
236 | > | #ifdef PROFILE |
237 | > | endProfile( pro1 ); |
238 | > | |
239 | > | startProfile( pro2 ); |
240 | > | #endif // profile |
241 | > | |
242 | info->incrTime(dt); | |
243 | ||
244 | < | if( info->setTemp ){ |
245 | < | if( info->getTime() >= currThermal ){ |
246 | < | thermalize(); |
247 | < | currThermal += thermalTime; |
244 | > | if (info->setTemp){ |
245 | > | if (info->getTime() >= currThermal){ |
246 | > | thermalize(); |
247 | > | currThermal += thermalTime; |
248 | } | |
249 | } | |
250 | ||
251 | < | if( info->getTime() >= currSample ){ |
252 | < | dumpOut->writeDump( info->getTime() ); |
251 | > | if (info->getTime() >= currSample){ |
252 | > | dumpOut->writeDump(info->getTime()); |
253 | currSample += sampleTime; | |
254 | } | |
255 | ||
256 | < | if( info->getTime() >= currStatus ){ |
257 | < | statOut->writeStat( info->getTime() ); |
258 | < | calcPot = 0; |
256 | > | if (info->getTime() >= currStatus){ |
257 | > | statOut->writeStat(info->getTime()); |
258 | > | calcPot = 0; |
259 | calcStress = 0; | |
260 | currStatus += statusTime; | |
261 | < | } |
261 | > | } |
262 | ||
263 | + | if (info->resetIntegrator){ |
264 | + | if (info->getTime() >= currReset){ |
265 | + | this->resetIntegrator(); |
266 | + | currReset += resetTime; |
267 | + | } |
268 | + | } |
269 | + | |
270 | + | #ifdef PROFILE |
271 | + | endProfile( pro2 ); |
272 | + | #endif //profile |
273 | + | |
274 | #ifdef IS_MPI | |
275 | < | strcpy( checkPointMsg, |
243 | < | "successfully took a time step." ); |
275 | > | strcpy(checkPointMsg, "successfully took a time step."); |
276 | MPIcheckPoint(); | |
277 | #endif // is_mpi | |
246 | – | |
278 | } | |
279 | ||
280 | < | dumpOut->writeFinal(info->getTime()); |
280 | > | // dump out a file containing the omega values for the final configuration |
281 | > | if (info->useSolidThermInt && !info->useLiquidThermInt) |
282 | > | myFF->dumpzAngle(); |
283 | > | |
284 | ||
285 | delete dumpOut; | |
286 | delete statOut; | |
287 | } | |
288 | ||
289 | < | template<typename T> void Integrator<T>::integrateStep( int calcPot, int calcStress ){ |
290 | < | |
257 | < | |
258 | < | |
289 | > | template<typename T> void Integrator<T>::integrateStep(int calcPot, |
290 | > | int calcStress){ |
291 | // Position full step, and velocity half step | |
292 | ||
293 | + | #ifdef PROFILE |
294 | + | startProfile(pro3); |
295 | + | #endif //profile |
296 | + | |
297 | preMove(); | |
298 | + | |
299 | + | #ifdef PROFILE |
300 | + | endProfile(pro3); |
301 | + | |
302 | + | startProfile(pro4); |
303 | + | #endif // profile |
304 | + | |
305 | moveA(); | |
263 | – | if( nConstrained ) constrainA(); |
306 | ||
307 | + | #ifdef PROFILE |
308 | + | endProfile(pro4); |
309 | ||
310 | + | startProfile(pro5); |
311 | + | #endif//profile |
312 | + | |
313 | + | |
314 | #ifdef IS_MPI | |
315 | < | strcpy( checkPointMsg, "Succesful moveA\n" ); |
315 | > | strcpy(checkPointMsg, "Succesful moveA\n"); |
316 | MPIcheckPoint(); | |
317 | #endif // is_mpi | |
270 | – | |
318 | ||
319 | // calc forces | |
320 | + | calcForce(calcPot, calcStress); |
321 | ||
274 | – | calcForce(calcPot,calcStress); |
275 | – | |
322 | #ifdef IS_MPI | |
323 | < | strcpy( checkPointMsg, "Succesful doForces\n" ); |
323 | > | strcpy(checkPointMsg, "Succesful doForces\n"); |
324 | MPIcheckPoint(); | |
325 | #endif // is_mpi | |
280 | – | |
326 | ||
327 | + | #ifdef PROFILE |
328 | + | endProfile( pro5 ); |
329 | + | |
330 | + | startProfile( pro6 ); |
331 | + | #endif //profile |
332 | + | |
333 | // finish the velocity half step | |
334 | < | |
334 | > | |
335 | moveB(); | |
336 | < | if( nConstrained ) constrainB(); |
337 | < | |
336 | > | |
337 | > | #ifdef PROFILE |
338 | > | endProfile(pro6); |
339 | > | #endif // profile |
340 | > | |
341 | #ifdef IS_MPI | |
342 | < | strcpy( checkPointMsg, "Succesful moveB\n" ); |
342 | > | strcpy(checkPointMsg, "Succesful moveB\n"); |
343 | MPIcheckPoint(); | |
344 | #endif // is_mpi | |
291 | – | |
292 | – | |
345 | } | |
346 | ||
347 | ||
348 | < | template<typename T> void Integrator<T>::moveA( void ){ |
349 | < | |
298 | < | int i, j; |
348 | > | template<typename T> void Integrator<T>::moveA(void){ |
349 | > | size_t i, j; |
350 | DirectionalAtom* dAtom; | |
351 | double Tb[3], ji[3]; | |
301 | – | double A[3][3], I[3][3]; |
302 | – | double angle; |
352 | double vel[3], pos[3], frc[3]; | |
353 | double mass; | |
354 | + | double omega; |
355 | + | |
356 | + | for (i = 0; i < integrableObjects.size() ; i++){ |
357 | + | integrableObjects[i]->getVel(vel); |
358 | + | integrableObjects[i]->getPos(pos); |
359 | + | integrableObjects[i]->getFrc(frc); |
360 | + | |
361 | + | mass = integrableObjects[i]->getMass(); |
362 | ||
363 | < | for( i=0; i<nAtoms; i++ ){ |
307 | < | |
308 | < | atoms[i]->getVel( vel ); |
309 | < | atoms[i]->getPos( pos ); |
310 | < | atoms[i]->getFrc( frc ); |
311 | < | |
312 | < | mass = atoms[i]->getMass(); |
313 | < | |
314 | < | for (j=0; j < 3; j++) { |
363 | > | for (j = 0; j < 3; j++){ |
364 | // velocity half step | |
365 | < | vel[j] += ( dt2 * frc[j] / mass ) * eConvert; |
365 | > | vel[j] += (dt2 * frc[j] / mass) * eConvert; |
366 | // position whole step | |
367 | pos[j] += dt * vel[j]; | |
368 | } | |
369 | ||
370 | < | atoms[i]->setVel( vel ); |
371 | < | atoms[i]->setPos( pos ); |
370 | > | integrableObjects[i]->setVel(vel); |
371 | > | integrableObjects[i]->setPos(pos); |
372 | ||
373 | < | if( atoms[i]->isDirectional() ){ |
373 | > | if (integrableObjects[i]->isDirectional()){ |
374 | ||
326 | – | dAtom = (DirectionalAtom *)atoms[i]; |
327 | – | |
375 | // get and convert the torque to body frame | |
329 | – | |
330 | – | dAtom->getTrq( Tb ); |
331 | – | dAtom->lab2Body( Tb ); |
376 | ||
377 | + | integrableObjects[i]->getTrq(Tb); |
378 | + | integrableObjects[i]->lab2Body(Tb); |
379 | + | |
380 | // get the angular momentum, and propagate a half step | |
381 | ||
382 | < | dAtom->getJ( ji ); |
382 | > | integrableObjects[i]->getJ(ji); |
383 | ||
384 | < | for (j=0; j < 3; j++) |
384 | > | for (j = 0; j < 3; j++) |
385 | ji[j] += (dt2 * Tb[j]) * eConvert; | |
339 | – | |
340 | – | // use the angular velocities to propagate the rotation matrix a |
341 | – | // full time step |
386 | ||
387 | < | dAtom->getA(A); |
344 | < | dAtom->getI(I); |
345 | < | |
346 | < | // rotate about the x-axis |
347 | < | angle = dt2 * ji[0] / I[0][0]; |
348 | < | this->rotate( 1, 2, angle, ji, A ); |
387 | > | this->rotationPropagation( integrableObjects[i], ji ); |
388 | ||
389 | < | // rotate about the y-axis |
390 | < | angle = dt2 * ji[1] / I[1][1]; |
391 | < | this->rotate( 2, 0, angle, ji, A ); |
353 | < | |
354 | < | // rotate about the z-axis |
355 | < | angle = dt * ji[2] / I[2][2]; |
356 | < | this->rotate( 0, 1, angle, ji, A); |
357 | < | |
358 | < | // rotate about the y-axis |
359 | < | angle = dt2 * ji[1] / I[1][1]; |
360 | < | this->rotate( 2, 0, angle, ji, A ); |
361 | < | |
362 | < | // rotate about the x-axis |
363 | < | angle = dt2 * ji[0] / I[0][0]; |
364 | < | this->rotate( 1, 2, angle, ji, A ); |
365 | < | |
389 | > | integrableObjects[i]->setJ(ji); |
390 | > | } |
391 | > | } |
392 | ||
393 | < | dAtom->setJ( ji ); |
394 | < | dAtom->setA( A ); |
369 | < | |
370 | < | } |
393 | > | if (nConstrained){ |
394 | > | constrainA(); |
395 | } | |
396 | } | |
397 | ||
398 | ||
399 | < | template<typename T> void Integrator<T>::moveB( void ){ |
399 | > | template<typename T> void Integrator<T>::moveB(void){ |
400 | int i, j; | |
377 | – | DirectionalAtom* dAtom; |
401 | double Tb[3], ji[3]; | |
402 | double vel[3], frc[3]; | |
403 | double mass; | |
404 | ||
405 | < | for( i=0; i<nAtoms; i++ ){ |
406 | < | |
407 | < | atoms[i]->getVel( vel ); |
385 | < | atoms[i]->getFrc( frc ); |
405 | > | for (i = 0; i < integrableObjects.size(); i++){ |
406 | > | integrableObjects[i]->getVel(vel); |
407 | > | integrableObjects[i]->getFrc(frc); |
408 | ||
409 | < | mass = atoms[i]->getMass(); |
409 | > | mass = integrableObjects[i]->getMass(); |
410 | ||
411 | // velocity half step | |
412 | < | for (j=0; j < 3; j++) |
413 | < | vel[j] += ( dt2 * frc[j] / mass ) * eConvert; |
392 | < | |
393 | < | atoms[i]->setVel( vel ); |
394 | < | |
395 | < | if( atoms[i]->isDirectional() ){ |
412 | > | for (j = 0; j < 3; j++) |
413 | > | vel[j] += (dt2 * frc[j] / mass) * eConvert; |
414 | ||
415 | < | dAtom = (DirectionalAtom *)atoms[i]; |
415 | > | integrableObjects[i]->setVel(vel); |
416 | ||
417 | < | // get and convert the torque to body frame |
417 | > | if (integrableObjects[i]->isDirectional()){ |
418 | ||
419 | < | dAtom->getTrq( Tb ); |
402 | < | dAtom->lab2Body( Tb ); |
419 | > | // get and convert the torque to body frame |
420 | ||
421 | + | integrableObjects[i]->getTrq(Tb); |
422 | + | integrableObjects[i]->lab2Body(Tb); |
423 | + | |
424 | // get the angular momentum, and propagate a half step | |
425 | ||
426 | < | dAtom->getJ( ji ); |
426 | > | integrableObjects[i]->getJ(ji); |
427 | ||
428 | < | for (j=0; j < 3; j++) |
428 | > | for (j = 0; j < 3; j++) |
429 | ji[j] += (dt2 * Tb[j]) * eConvert; | |
410 | – | |
430 | ||
431 | < | dAtom->setJ( ji ); |
431 | > | |
432 | > | integrableObjects[i]->setJ(ji); |
433 | } | |
434 | } | |
435 | + | |
436 | + | if (nConstrained){ |
437 | + | constrainB(); |
438 | + | } |
439 | } | |
440 | ||
441 | < | template<typename T> void Integrator<T>::preMove( void ){ |
441 | > | template<typename T> void Integrator<T>::preMove(void){ |
442 | int i, j; | |
443 | double pos[3]; | |
444 | ||
445 | < | if( nConstrained ){ |
445 | > | if (nConstrained){ |
446 | > | for (i = 0; i < nAtoms; i++){ |
447 | > | atoms[i]->getPos(pos); |
448 | ||
449 | < | for(i=0; i < nAtoms; i++) { |
450 | < | |
425 | < | atoms[i]->getPos( pos ); |
426 | < | |
427 | < | for (j = 0; j < 3; j++) { |
428 | < | oldPos[3*i + j] = pos[j]; |
449 | > | for (j = 0; j < 3; j++){ |
450 | > | oldPos[3 * i + j] = pos[j]; |
451 | } | |
430 | – | |
452 | } | |
453 | < | } |
453 | > | } |
454 | } | |
455 | ||
456 | template<typename T> void Integrator<T>::constrainA(){ | |
457 | < | |
437 | < | int i,j,k; |
457 | > | int i, j; |
458 | int done; | |
459 | double posA[3], posB[3]; | |
460 | double velA[3], velB[3]; | |
# | Line 449 | Line 469 | template<typename T> void Integrator<T>::constrainA(){ | |
469 | double gab; | |
470 | int iteration; | |
471 | ||
472 | < | for( i=0; i<nAtoms; i++){ |
472 | > | for (i = 0; i < nAtoms; i++){ |
473 | moving[i] = 0; | |
474 | < | moved[i] = 1; |
474 | > | moved[i] = 1; |
475 | } | |
476 | ||
477 | iteration = 0; | |
478 | done = 0; | |
479 | < | while( !done && (iteration < maxIteration )){ |
460 | < | |
479 | > | while (!done && (iteration < maxIteration)){ |
480 | done = 1; | |
481 | < | for(i=0; i<nConstrained; i++){ |
463 | < | |
481 | > | for (i = 0; i < nConstrained; i++){ |
482 | a = constrainedA[i]; | |
483 | b = constrainedB[i]; | |
466 | – | |
467 | – | ax = (a*3) + 0; |
468 | – | ay = (a*3) + 1; |
469 | – | az = (a*3) + 2; |
484 | ||
485 | < | bx = (b*3) + 0; |
486 | < | by = (b*3) + 1; |
487 | < | bz = (b*3) + 2; |
485 | > | ax = (a * 3) + 0; |
486 | > | ay = (a * 3) + 1; |
487 | > | az = (a * 3) + 2; |
488 | ||
489 | < | if( moved[a] || moved[b] ){ |
490 | < | |
491 | < | atoms[a]->getPos( posA ); |
492 | < | atoms[b]->getPos( posB ); |
493 | < | |
494 | < | for (j = 0; j < 3; j++ ) |
489 | > | bx = (b * 3) + 0; |
490 | > | by = (b * 3) + 1; |
491 | > | bz = (b * 3) + 2; |
492 | > | |
493 | > | if (moved[a] || moved[b]){ |
494 | > | atoms[a]->getPos(posA); |
495 | > | atoms[b]->getPos(posB); |
496 | > | |
497 | > | for (j = 0; j < 3; j++) |
498 | pab[j] = posA[j] - posB[j]; | |
482 | – | |
483 | – | //periodic boundary condition |
499 | ||
500 | < | info->wrapVector( pab ); |
500 | > | //periodic boundary condition |
501 | ||
502 | < | pabsq = pab[0] * pab[0] + pab[1] * pab[1] + pab[2] * pab[2]; |
502 | > | info->wrapVector(pab); |
503 | ||
504 | < | rabsq = constrainedDsqr[i]; |
490 | < | diffsq = rabsq - pabsq; |
504 | > | pabsq = pab[0] * pab[0] + pab[1] * pab[1] + pab[2] * pab[2]; |
505 | ||
506 | < | // the original rattle code from alan tidesley |
507 | < | if (fabs(diffsq) > (tol*rabsq*2)) { |
494 | < | rab[0] = oldPos[ax] - oldPos[bx]; |
495 | < | rab[1] = oldPos[ay] - oldPos[by]; |
496 | < | rab[2] = oldPos[az] - oldPos[bz]; |
506 | > | rabsq = constrainedDsqr[i]; |
507 | > | diffsq = rabsq - pabsq; |
508 | ||
509 | < | info->wrapVector( rab ); |
509 | > | // the original rattle code from alan tidesley |
510 | > | if (fabs(diffsq) > (tol * rabsq * 2)){ |
511 | > | rab[0] = oldPos[ax] - oldPos[bx]; |
512 | > | rab[1] = oldPos[ay] - oldPos[by]; |
513 | > | rab[2] = oldPos[az] - oldPos[bz]; |
514 | ||
515 | < | rpab = rab[0] * pab[0] + rab[1] * pab[1] + rab[2] * pab[2]; |
515 | > | info->wrapVector(rab); |
516 | ||
517 | < | rpabsq = rpab * rpab; |
517 | > | rpab = rab[0] * pab[0] + rab[1] * pab[1] + rab[2] * pab[2]; |
518 | ||
519 | + | rpabsq = rpab * rpab; |
520 | ||
505 | – | if (rpabsq < (rabsq * -diffsq)){ |
521 | ||
522 | + | if (rpabsq < (rabsq * -diffsq)){ |
523 | #ifdef IS_MPI | |
524 | < | a = atoms[a]->getGlobalIndex(); |
525 | < | b = atoms[b]->getGlobalIndex(); |
524 | > | a = atoms[a]->getGlobalIndex(); |
525 | > | b = atoms[b]->getGlobalIndex(); |
526 | #endif //is_mpi | |
527 | < | sprintf( painCave.errMsg, |
528 | < | "Constraint failure in constrainA at atom %d and %d.\n", |
529 | < | a, b ); |
530 | < | painCave.isFatal = 1; |
531 | < | simError(); |
532 | < | } |
527 | > | sprintf(painCave.errMsg, |
528 | > | "Constraint failure in constrainA at atom %d and %d.\n", a, |
529 | > | b); |
530 | > | painCave.isFatal = 1; |
531 | > | simError(); |
532 | > | } |
533 | ||
534 | < | rma = 1.0 / atoms[a]->getMass(); |
535 | < | rmb = 1.0 / atoms[b]->getMass(); |
534 | > | rma = 1.0 / atoms[a]->getMass(); |
535 | > | rmb = 1.0 / atoms[b]->getMass(); |
536 | ||
537 | < | gab = diffsq / ( 2.0 * ( rma + rmb ) * rpab ); |
537 | > | gab = diffsq / (2.0 * (rma + rmb) * rpab); |
538 | ||
539 | dx = rab[0] * gab; | |
540 | dy = rab[1] * gab; | |
541 | dz = rab[2] * gab; | |
542 | ||
543 | < | posA[0] += rma * dx; |
544 | < | posA[1] += rma * dy; |
545 | < | posA[2] += rma * dz; |
543 | > | posA[0] += rma * dx; |
544 | > | posA[1] += rma * dy; |
545 | > | posA[2] += rma * dz; |
546 | ||
547 | < | atoms[a]->setPos( posA ); |
547 | > | atoms[a]->setPos(posA); |
548 | ||
549 | < | posB[0] -= rmb * dx; |
550 | < | posB[1] -= rmb * dy; |
551 | < | posB[2] -= rmb * dz; |
549 | > | posB[0] -= rmb * dx; |
550 | > | posB[1] -= rmb * dy; |
551 | > | posB[2] -= rmb * dz; |
552 | ||
553 | < | atoms[b]->setPos( posB ); |
553 | > | atoms[b]->setPos(posB); |
554 | ||
555 | dx = dx / dt; | |
556 | dy = dy / dt; | |
557 | dz = dz / dt; | |
558 | ||
559 | < | atoms[a]->getVel( velA ); |
559 | > | atoms[a]->getVel(velA); |
560 | ||
561 | < | velA[0] += rma * dx; |
562 | < | velA[1] += rma * dy; |
563 | < | velA[2] += rma * dz; |
561 | > | velA[0] += rma * dx; |
562 | > | velA[1] += rma * dy; |
563 | > | velA[2] += rma * dz; |
564 | ||
565 | < | atoms[a]->setVel( velA ); |
565 | > | atoms[a]->setVel(velA); |
566 | ||
567 | < | atoms[b]->getVel( velB ); |
567 | > | atoms[b]->getVel(velB); |
568 | ||
569 | < | velB[0] -= rmb * dx; |
570 | < | velB[1] -= rmb * dy; |
571 | < | velB[2] -= rmb * dz; |
569 | > | velB[0] -= rmb * dx; |
570 | > | velB[1] -= rmb * dy; |
571 | > | velB[2] -= rmb * dz; |
572 | ||
573 | < | atoms[b]->setVel( velB ); |
573 | > | atoms[b]->setVel(velB); |
574 | ||
575 | < | moving[a] = 1; |
576 | < | moving[b] = 1; |
577 | < | done = 0; |
578 | < | } |
575 | > | moving[a] = 1; |
576 | > | moving[b] = 1; |
577 | > | done = 0; |
578 | > | } |
579 | } | |
580 | } | |
581 | < | |
582 | < | for(i=0; i<nAtoms; i++){ |
567 | < | |
581 | > | |
582 | > | for (i = 0; i < nAtoms; i++){ |
583 | moved[i] = moving[i]; | |
584 | moving[i] = 0; | |
585 | } | |
# | Line 572 | Line 587 | template<typename T> void Integrator<T>::constrainA(){ | |
587 | iteration++; | |
588 | } | |
589 | ||
590 | < | if( !done ){ |
591 | < | |
592 | < | sprintf( painCave.errMsg, |
593 | < | "Constraint failure in constrainA, too many iterations: %d\n", |
579 | < | iteration ); |
590 | > | if (!done){ |
591 | > | sprintf(painCave.errMsg, |
592 | > | "Constraint failure in constrainA, too many iterations: %d\n", |
593 | > | iteration); |
594 | painCave.isFatal = 1; | |
595 | simError(); | |
596 | } | |
597 | ||
598 | } | |
599 | ||
600 | < | template<typename T> void Integrator<T>::constrainB( void ){ |
601 | < | |
588 | < | int i,j,k; |
600 | > | template<typename T> void Integrator<T>::constrainB(void){ |
601 | > | int i, j; |
602 | int done; | |
603 | double posA[3], posB[3]; | |
604 | double velA[3], velB[3]; | |
# | Line 594 | Line 607 | template<typename T> void Integrator<T>::constrainB( v | |
607 | int a, b, ax, ay, az, bx, by, bz; | |
608 | double rma, rmb; | |
609 | double dx, dy, dz; | |
610 | < | double rabsq, pabsq, rvab; |
598 | < | double diffsq; |
610 | > | double rvab; |
611 | double gab; | |
612 | int iteration; | |
613 | ||
614 | < | for(i=0; i<nAtoms; i++){ |
614 | > | for (i = 0; i < nAtoms; i++){ |
615 | moving[i] = 0; | |
616 | moved[i] = 1; | |
617 | } | |
618 | ||
619 | done = 0; | |
620 | iteration = 0; | |
621 | < | while( !done && (iteration < maxIteration ) ){ |
610 | < | |
621 | > | while (!done && (iteration < maxIteration)){ |
622 | done = 1; | |
623 | ||
624 | < | for(i=0; i<nConstrained; i++){ |
614 | < | |
624 | > | for (i = 0; i < nConstrained; i++){ |
625 | a = constrainedA[i]; | |
626 | b = constrainedB[i]; | |
627 | ||
628 | < | ax = (a*3) + 0; |
629 | < | ay = (a*3) + 1; |
630 | < | az = (a*3) + 2; |
628 | > | ax = (a * 3) + 0; |
629 | > | ay = (a * 3) + 1; |
630 | > | az = (a * 3) + 2; |
631 | ||
632 | < | bx = (b*3) + 0; |
633 | < | by = (b*3) + 1; |
634 | < | bz = (b*3) + 2; |
632 | > | bx = (b * 3) + 0; |
633 | > | by = (b * 3) + 1; |
634 | > | bz = (b * 3) + 2; |
635 | ||
636 | < | if( moved[a] || moved[b] ){ |
636 | > | if (moved[a] || moved[b]){ |
637 | > | atoms[a]->getVel(velA); |
638 | > | atoms[b]->getVel(velB); |
639 | ||
640 | < | atoms[a]->getVel( velA ); |
641 | < | atoms[b]->getVel( velB ); |
642 | < | |
631 | < | vxab = velA[0] - velB[0]; |
632 | < | vyab = velA[1] - velB[1]; |
633 | < | vzab = velA[2] - velB[2]; |
640 | > | vxab = velA[0] - velB[0]; |
641 | > | vyab = velA[1] - velB[1]; |
642 | > | vzab = velA[2] - velB[2]; |
643 | ||
644 | < | atoms[a]->getPos( posA ); |
645 | < | atoms[b]->getPos( posB ); |
644 | > | atoms[a]->getPos(posA); |
645 | > | atoms[b]->getPos(posB); |
646 | ||
647 | < | for (j = 0; j < 3; j++) |
647 | > | for (j = 0; j < 3; j++) |
648 | rab[j] = posA[j] - posB[j]; | |
640 | – | |
641 | – | info->wrapVector( rab ); |
642 | – | |
643 | – | rma = 1.0 / atoms[a]->getMass(); |
644 | – | rmb = 1.0 / atoms[b]->getMass(); |
649 | ||
650 | < | rvab = rab[0] * vxab + rab[1] * vyab + rab[2] * vzab; |
647 | < | |
648 | < | gab = -rvab / ( ( rma + rmb ) * constrainedDsqr[i] ); |
650 | > | info->wrapVector(rab); |
651 | ||
652 | < | if (fabs(gab) > tol) { |
653 | < | |
652 | < | dx = rab[0] * gab; |
653 | < | dy = rab[1] * gab; |
654 | < | dz = rab[2] * gab; |
655 | < | |
656 | < | velA[0] += rma * dx; |
657 | < | velA[1] += rma * dy; |
658 | < | velA[2] += rma * dz; |
652 | > | rma = 1.0 / atoms[a]->getMass(); |
653 | > | rmb = 1.0 / atoms[b]->getMass(); |
654 | ||
655 | < | atoms[a]->setVel( velA ); |
655 | > | rvab = rab[0] * vxab + rab[1] * vyab + rab[2] * vzab; |
656 | ||
657 | < | velB[0] -= rmb * dx; |
663 | < | velB[1] -= rmb * dy; |
664 | < | velB[2] -= rmb * dz; |
657 | > | gab = -rvab / ((rma + rmb) * constrainedDsqr[i]); |
658 | ||
659 | < | atoms[b]->setVel( velB ); |
660 | < | |
661 | < | moving[a] = 1; |
662 | < | moving[b] = 1; |
663 | < | done = 0; |
664 | < | } |
659 | > | if (fabs(gab) > tol){ |
660 | > | dx = rab[0] * gab; |
661 | > | dy = rab[1] * gab; |
662 | > | dz = rab[2] * gab; |
663 | > | |
664 | > | velA[0] += rma * dx; |
665 | > | velA[1] += rma * dy; |
666 | > | velA[2] += rma * dz; |
667 | > | |
668 | > | atoms[a]->setVel(velA); |
669 | > | |
670 | > | velB[0] -= rmb * dx; |
671 | > | velB[1] -= rmb * dy; |
672 | > | velB[2] -= rmb * dz; |
673 | > | |
674 | > | atoms[b]->setVel(velB); |
675 | > | |
676 | > | moving[a] = 1; |
677 | > | moving[b] = 1; |
678 | > | done = 0; |
679 | > | } |
680 | } | |
681 | } | |
682 | ||
683 | < | for(i=0; i<nAtoms; i++){ |
683 | > | for (i = 0; i < nAtoms; i++){ |
684 | moved[i] = moving[i]; | |
685 | moving[i] = 0; | |
686 | } | |
687 | < | |
687 | > | |
688 | iteration++; | |
689 | } | |
682 | – | |
683 | – | if( !done ){ |
690 | ||
691 | < | |
692 | < | sprintf( painCave.errMsg, |
693 | < | "Constraint failure in constrainB, too many iterations: %d\n", |
694 | < | iteration ); |
691 | > | if (!done){ |
692 | > | sprintf(painCave.errMsg, |
693 | > | "Constraint failure in constrainB, too many iterations: %d\n", |
694 | > | iteration); |
695 | painCave.isFatal = 1; | |
696 | simError(); | |
697 | < | } |
692 | < | |
697 | > | } |
698 | } | |
699 | ||
700 | < | template<typename T> void Integrator<T>::rotate( int axes1, int axes2, double angle, double ji[3], |
701 | < | double A[3][3] ){ |
700 | > | template<typename T> void Integrator<T>::rotationPropagation |
701 | > | ( StuntDouble* sd, double ji[3] ){ |
702 | ||
703 | < | int i,j,k; |
703 | > | double angle; |
704 | > | double A[3][3], I[3][3]; |
705 | > | int i, j, k; |
706 | > | |
707 | > | // use the angular velocities to propagate the rotation matrix a |
708 | > | // full time step |
709 | > | |
710 | > | sd->getA(A); |
711 | > | sd->getI(I); |
712 | > | |
713 | > | if (sd->isLinear()) { |
714 | > | i = sd->linearAxis(); |
715 | > | j = (i+1)%3; |
716 | > | k = (i+2)%3; |
717 | > | |
718 | > | angle = dt2 * ji[j] / I[j][j]; |
719 | > | this->rotate( k, i, angle, ji, A ); |
720 | > | |
721 | > | angle = dt * ji[k] / I[k][k]; |
722 | > | this->rotate( i, j, angle, ji, A); |
723 | > | |
724 | > | angle = dt2 * ji[j] / I[j][j]; |
725 | > | this->rotate( k, i, angle, ji, A ); |
726 | > | |
727 | > | } else { |
728 | > | // rotate about the x-axis |
729 | > | angle = dt2 * ji[0] / I[0][0]; |
730 | > | this->rotate( 1, 2, angle, ji, A ); |
731 | > | |
732 | > | // rotate about the y-axis |
733 | > | angle = dt2 * ji[1] / I[1][1]; |
734 | > | this->rotate( 2, 0, angle, ji, A ); |
735 | > | |
736 | > | // rotate about the z-axis |
737 | > | angle = dt * ji[2] / I[2][2]; |
738 | > | sd->addZangle(angle); |
739 | > | this->rotate( 0, 1, angle, ji, A); |
740 | > | |
741 | > | // rotate about the y-axis |
742 | > | angle = dt2 * ji[1] / I[1][1]; |
743 | > | this->rotate( 2, 0, angle, ji, A ); |
744 | > | |
745 | > | // rotate about the x-axis |
746 | > | angle = dt2 * ji[0] / I[0][0]; |
747 | > | this->rotate( 1, 2, angle, ji, A ); |
748 | > | |
749 | > | } |
750 | > | sd->setA( A ); |
751 | > | } |
752 | > | |
753 | > | template<typename T> void Integrator<T>::rotate(int axes1, int axes2, |
754 | > | double angle, double ji[3], |
755 | > | double A[3][3]){ |
756 | > | int i, j, k; |
757 | double sinAngle; | |
758 | double cosAngle; | |
759 | double angleSqr; | |
# | Line 707 | Line 765 | template<typename T> void Integrator<T>::rotate( int a | |
765 | ||
766 | // initialize the tempA | |
767 | ||
768 | < | for(i=0; i<3; i++){ |
769 | < | for(j=0; j<3; j++){ |
768 | > | for (i = 0; i < 3; i++){ |
769 | > | for (j = 0; j < 3; j++){ |
770 | tempA[j][i] = A[i][j]; | |
771 | } | |
772 | } | |
773 | ||
774 | // initialize the tempJ | |
775 | ||
776 | < | for( i=0; i<3; i++) tempJ[i] = ji[i]; |
777 | < | |
776 | > | for (i = 0; i < 3; i++) |
777 | > | tempJ[i] = ji[i]; |
778 | > | |
779 | // initalize rot as a unit matrix | |
780 | ||
781 | rot[0][0] = 1.0; | |
# | Line 726 | Line 785 | template<typename T> void Integrator<T>::rotate( int a | |
785 | rot[1][0] = 0.0; | |
786 | rot[1][1] = 1.0; | |
787 | rot[1][2] = 0.0; | |
788 | < | |
788 | > | |
789 | rot[2][0] = 0.0; | |
790 | rot[2][1] = 0.0; | |
791 | rot[2][2] = 1.0; | |
792 | < | |
792 | > | |
793 | // use a small angle aproximation for sin and cosine | |
794 | ||
795 | < | angleSqr = angle * angle; |
795 | > | angleSqr = angle * angle; |
796 | angleSqrOver4 = angleSqr / 4.0; | |
797 | top = 1.0 - angleSqrOver4; | |
798 | bottom = 1.0 + angleSqrOver4; | |
# | Line 746 | Line 805 | template<typename T> void Integrator<T>::rotate( int a | |
805 | ||
806 | rot[axes1][axes2] = sinAngle; | |
807 | rot[axes2][axes1] = -sinAngle; | |
808 | < | |
808 | > | |
809 | // rotate the momentum acoording to: ji[] = rot[][] * ji[] | |
810 | < | |
811 | < | for(i=0; i<3; i++){ |
810 | > | |
811 | > | for (i = 0; i < 3; i++){ |
812 | ji[i] = 0.0; | |
813 | < | for(k=0; k<3; k++){ |
813 | > | for (k = 0; k < 3; k++){ |
814 | ji[i] += rot[i][k] * tempJ[k]; | |
815 | } | |
816 | } | |
817 | ||
818 | < | // rotate the Rotation matrix acording to: |
818 | > | // rotate the Rotation matrix acording to: |
819 | // A[][] = A[][] * transpose(rot[][]) | |
820 | ||
821 | ||
# | Line 764 | Line 823 | template<typename T> void Integrator<T>::rotate( int a | |
823 | // calculation as: | |
824 | // transpose(A[][]) = transpose(A[][]) * transpose(rot[][]) | |
825 | ||
826 | < | for(i=0; i<3; i++){ |
827 | < | for(j=0; j<3; j++){ |
826 | > | for (i = 0; i < 3; i++){ |
827 | > | for (j = 0; j < 3; j++){ |
828 | A[j][i] = 0.0; | |
829 | < | for(k=0; k<3; k++){ |
830 | < | A[j][i] += tempA[i][k] * rot[j][k]; |
829 | > | for (k = 0; k < 3; k++){ |
830 | > | A[j][i] += tempA[i][k] * rot[j][k]; |
831 | } | |
832 | } | |
833 | } | |
834 | } | |
835 | ||
836 | < | template<typename T> void Integrator<T>::calcForce( int calcPot, int calcStress ){ |
837 | < | myFF->doForces(calcPot,calcStress); |
779 | < | |
836 | > | template<typename T> void Integrator<T>::calcForce(int calcPot, int calcStress){ |
837 | > | myFF->doForces(calcPot, calcStress); |
838 | } | |
839 | ||
840 | template<typename T> void Integrator<T>::thermalize(){ | |
841 | < | tStats->velocitize(); |
841 | > | tStats->velocitize(); |
842 | } | |
843 | + | |
844 | + | template<typename T> double Integrator<T>::getConservedQuantity(void){ |
845 | + | return tStats->getTotalE(); |
846 | + | } |
847 | + | template<typename T> string Integrator<T>::getAdditionalParameters(void){ |
848 | + | //By default, return a null string |
849 | + | //The reason we use string instead of char* is that if we use char*, we will |
850 | + | //return a pointer point to local variable which might cause problem |
851 | + | return string(); |
852 | + | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |