Changeset 543ce4 for molecuilder/src/molecule_dynamics.cpp
- Timestamp:
- Nov 4, 2009, 7:56:04 PM (16 years ago)
- Children:
- 4ef101, aa8542
- Parents:
- ec70ec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/molecule_dynamics.cpp
rec70ec r543ce4 9 9 #include "config.hpp" 10 10 #include "element.hpp" 11 #include "log.hpp" 11 12 #include "memoryallocator.hpp" 12 13 #include "molecule.hpp" … … 63 64 tmp = trajectory2.Norm(); // remaining norm is distance 64 65 } else if ((fabs(trajectory1.ScalarProduct(&trajectory2)/Norm1/Norm2) - 1.) < MYEPSILON) { // check whether they're linear dependent 65 // *out<< Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear dependent: ";66 // *out<< trajectory1;67 // *out<< " and ";68 // *out<< trajectory2;66 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear dependent: "; 67 // Log() << Verbose(0) << trajectory1; 68 // Log() << Verbose(0) << " and "; 69 // Log() << Verbose(0) << trajectory2; 69 70 tmp = Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.startstep)); 70 // *out<< " with distance " << tmp << "." << endl;71 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 71 72 } else { // determine distance by finding minimum distance 72 // *out<< Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear independent ";73 // *out<< endl;74 // *out<< "First Trajectory: ";75 // *out<< trajectory1 << endl;76 // *out<< "Second Trajectory: ";77 // *out<< trajectory2 << endl;73 // Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear independent "; 74 // Log() << Verbose(0) << endl; 75 // Log() << Verbose(0) << "First Trajectory: "; 76 // Log() << Verbose(0) << trajectory1 << endl; 77 // Log() << Verbose(0) << "Second Trajectory: "; 78 // Log() << Verbose(0) << trajectory2 << endl; 78 79 // determine normal vector for both 79 80 normal.MakeNormalVector(&trajectory1, &trajectory2); 80 81 // print all vectors for debugging 81 // *out<< "Normal vector in between: ";82 // *out<< normal << endl;82 // Log() << Verbose(0) << "Normal vector in between: "; 83 // Log() << Verbose(0) << normal << endl; 83 84 // setup matrix 84 85 for (int i=NDIM;i--;) { … … 92 93 // distance from last component 93 94 tmp = gsl_vector_get(x,2); 94 // *out<< " with distance " << tmp << "." << endl;95 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 95 96 // test whether we really have the intersection (by checking on c_1 and c_2) 96 97 TestVector.CopyVector(&Runner->Trajectory.R.at(Params.startstep)); … … 103 104 TestVector.SubtractVector(&trajectory1); 104 105 if (TestVector.Norm() < MYEPSILON) { 105 // *out<< Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl;106 // Log() << Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl; 106 107 } else { 107 // *out<< Verbose(2) << "Test: failed.\tIntersection is off by ";108 // *out<< TestVector;109 // *out<< "." << endl;108 // Log() << Verbose(2) << "Test: failed.\tIntersection is off by "; 109 // Log() << Verbose(0) << TestVector; 110 // Log() << Verbose(0) << "." << endl; 110 111 } 111 112 } … … 114 115 if (fabs(tmp) > MYEPSILON) { 115 116 result += Params.PenaltyConstants[1] * 1./tmp; 116 // *out<< Verbose(4) << "Adding " << 1./tmp*constants[1] << "." << endl;117 //Log() << Verbose(4) << "Adding " << 1./tmp*constants[1] << "." << endl; 117 118 } 118 119 } … … 134 135 if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[Runner->nr]) && (Walker->nr < Runner->nr)) { 135 136 // atom *Sprinter = PermutationMap[Walker->nr]; 136 // *out<< *Walker << " and " << *Runner << " are heading to the same target at ";137 // *out<< Sprinter->Trajectory.R.at(endstep);138 // *out<< ", penalting." << endl;137 // Log() << Verbose(0) << *Walker << " and " << *Runner << " are heading to the same target at "; 138 // Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep); 139 // Log() << Verbose(0) << ", penalting." << endl; 139 140 result += Params.PenaltyConstants[2]; 140 // *out<< Verbose(4) << "Adding " << constants[2] << "." << endl;141 //Log() << Verbose(4) << "Adding " << constants[2] << "." << endl; 141 142 } 142 143 } … … 159 160 * \todo There's a bit double counting going on for the first time, bu nothing to worry really about. 160 161 */ 161 double molecule::ConstrainedPotential( ofstream *out,struct EvaluatePotential &Params)162 double molecule::ConstrainedPotential(struct EvaluatePotential &Params) 162 163 { 163 164 double tmp, result; … … 173 174 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 174 175 result += Params.PenaltyConstants[0] * tmp; 175 // *out<< Verbose(4) << "Adding " << tmp*constants[0] << "." << endl;176 //Log() << Verbose(4) << "Adding " << tmp*constants[0] << "." << endl; 176 177 177 178 // second term: sum of distances to other trajectories … … 190 191 * \param AtomCount number of atoms 191 192 */ 192 void PrintPermutationMap( ofstream *out,int AtomCount, struct EvaluatePotential &Params)193 void PrintPermutationMap(int AtomCount, struct EvaluatePotential &Params) 193 194 { 194 195 stringstream zeile1, zeile2; … … 206 207 doubles++; 207 208 if (doubles >0) 208 *out<< "Found " << doubles << " Doubles." << endl;209 Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl; 209 210 Free(&DoubleList); 210 // *out<< zeile1.str() << endl << zeile2.str() << endl;211 // Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl; 211 212 }; 212 213 … … 239 240 * \param &Params constrained potential parameters 240 241 */ 241 void CreateInitialLists( ofstream *out,molecule *mol, struct EvaluatePotential &Params)242 void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params) 242 243 { 243 244 atom *Walker = mol->start; … … 248 249 Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++; // increase this target's source count (>1? not injective) 249 250 Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin(); // and remember which one we picked 250 *out<< *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl;251 Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl; 251 252 } 252 253 }; … … 259 260 * \param &Params constrained potential parameters 260 261 */ 261 double TryNextNearestNeighbourForInjectivePermutation( ofstream *out,molecule *mol, atom *Walker, double &OldPotential, struct EvaluatePotential &Params)262 double TryNextNearestNeighbourForInjectivePermutation(molecule *mol, atom *Walker, double &OldPotential, struct EvaluatePotential &Params) 262 263 { 263 264 double Potential = 0; … … 268 269 if (NewBase != Params.DistanceList[Walker->nr]->end()) { 269 270 Params.PermutationMap[Walker->nr] = NewBase->second; 270 Potential = fabs(mol->ConstrainedPotential( out,Params));271 Potential = fabs(mol->ConstrainedPotential(Params)); 271 272 if (Potential > OldPotential) { // undo 272 273 Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; … … 276 277 Params.DistanceIterators[Walker->nr] = NewBase; 277 278 OldPotential = Potential; 278 *out<< Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl;279 Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl; 279 280 } 280 281 } … … 287 288 * \param &Params constrained potential parameters 288 289 */ 289 void MakeInjectivePermutation( ofstream *out,molecule *mol, struct EvaluatePotential &Params)290 void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params) 290 291 { 291 292 atom *Walker = mol->start; 292 293 DistanceMap::iterator NewBase; 293 double Potential = fabs(mol->ConstrainedPotential( out,Params));294 double Potential = fabs(mol->ConstrainedPotential(Params)); 294 295 295 296 while ((Potential) > Params.PenaltyConstants[2]) { 296 PrintPermutationMap( out,mol->AtomCount, Params);297 PrintPermutationMap(mol->AtomCount, Params); 297 298 Walker = Walker->next; 298 299 if (Walker == mol->end) // round-robin at the end … … 301 302 continue; 302 303 // now, try finding a new one 303 Potential = TryNextNearestNeighbourForInjectivePermutation( out,mol, Walker, Potential, Params);304 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params); 304 305 } 305 306 for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1 306 307 if (Params.DoubleList[i] > 1) { 307 cerr<< "Failed to create an injective PermutationMap!" << endl;308 eLog() << Verbose(0) << "Failed to create an injective PermutationMap!" << endl; 308 309 exit(1); 309 310 } 310 *out<< Verbose(1) << "done." << endl;311 Log() << Verbose(1) << "done." << endl; 311 312 }; 312 313 … … 338 339 * \bug this all is not O(N log N) but O(N^2) 339 340 */ 340 double molecule::MinimiseConstrainedPotential( ofstream *out,atom **&PermutationMap, int startstep, int endstep, bool IsAngstroem)341 double molecule::MinimiseConstrainedPotential(atom **&PermutationMap, int startstep, int endstep, bool IsAngstroem) 341 342 { 342 343 double Potential, OldPotential, OlderPotential; … … 357 358 Params.PenaltyConstants[2] = 1e+7; // just a huge penalty 358 359 // generate the distance list 359 *out<< Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl;360 Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl; 360 361 FillDistanceList(this, Params); 361 362 362 363 // create the initial PermutationMap (source -> target) 363 CreateInitialLists( out,this, Params);364 CreateInitialLists(this, Params); 364 365 365 366 // make the PermutationMap injective by checking whether we have a non-zero constants[2] term in it 366 *out<< Verbose(1) << "Making the PermutationMap injective ... " << endl;367 MakeInjectivePermutation( out,this, Params);367 Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl; 368 MakeInjectivePermutation(this, Params); 368 369 Free(&Params.DoubleList); 369 370 370 371 // argument minimise the constrained potential in this injective PermutationMap 371 *out<< Verbose(1) << "Argument minimising the PermutationMap, at current potential " << OldPotential << " ... " << endl;372 Log() << Verbose(1) << "Argument minimising the PermutationMap, at current potential " << OldPotential << " ... " << endl; 372 373 OldPotential = 1e+10; 373 374 round = 0; 374 375 do { 375 *out<< "Starting round " << ++round << " ... " << endl;376 Log() << Verbose(2) << "Starting round " << ++round << " ... " << endl; 376 377 OlderPotential = OldPotential; 377 378 do { … … 379 380 while (Walker->next != end) { // pick one 380 381 Walker = Walker->next; 381 PrintPermutationMap( out,AtomCount, Params);382 PrintPermutationMap(AtomCount, Params); 382 383 Sprinter = Params.DistanceIterators[Walker->nr]->second; // store initial partner 383 384 Strider = Params.DistanceIterators[Walker->nr]; //remember old iterator … … 387 388 break; 388 389 } 389 // *out<< Verbose(2) << "Current Walker: " << *Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;390 //Log() << Verbose(2) << "Current Walker: " << *Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl; 390 391 // find source of the new target 391 392 Runner = start->next; 392 393 while(Runner != end) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already) 393 394 if (Params.PermutationMap[Runner->nr] == Params.DistanceIterators[Walker->nr]->second) { 394 // *out<< Verbose(2) << "Found the corresponding owner " << *Runner << " to " << *PermutationMap[Runner->nr] << "." << endl;395 //Log() << Verbose(2) << "Found the corresponding owner " << *Runner << " to " << *PermutationMap[Runner->nr] << "." << endl; 395 396 break; 396 397 } … … 404 405 break; 405 406 if (Rider != Params.DistanceList[Runner->nr]->end()) { // if we have found one 406 // *out<< Verbose(2) << "Current Other: " << *Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl;407 //Log() << Verbose(2) << "Current Other: " << *Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl; 407 408 // exchange both 408 409 Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap 409 410 Params.PermutationMap[Runner->nr] = Sprinter; // and hand the old target to its respective owner 410 PrintPermutationMap( out,AtomCount, Params);411 PrintPermutationMap(AtomCount, Params); 411 412 // calculate the new potential 412 // *out<< Verbose(2) << "Checking new potential ..." << endl;413 Potential = ConstrainedPotential( out,Params);413 //Log() << Verbose(2) << "Checking new potential ..." << endl; 414 Potential = ConstrainedPotential(Params); 414 415 if (Potential > OldPotential) { // we made everything worse! Undo ... 415 // *out<< Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl;416 // *out<< Verbose(3) << "Setting " << *Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl;416 //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl; 417 //Log() << Verbose(3) << "Setting " << *Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl; 417 418 // Undo for Runner (note, we haven't moved the iteration yet, we may use this) 418 419 Params.PermutationMap[Runner->nr] = Params.DistanceIterators[Runner->nr]->second; 419 420 // Undo for Walker 420 421 Params.DistanceIterators[Walker->nr] = Strider; // take next farther distance target 421 // *out<< Verbose(3) << "Setting " << *Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl;422 //Log() << Verbose(3) << "Setting " << *Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl; 422 423 Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; 423 424 } else { 424 425 Params.DistanceIterators[Runner->nr] = Rider; // if successful also move the pointer in the iterator list 425 *out<< Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl;426 Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl; 426 427 OldPotential = Potential; 427 428 } 428 429 if (Potential > Params.PenaltyConstants[2]) { 429 cerr<< "ERROR: The two-step permutation procedure did not maintain injectivity!" << endl;430 eLog() << Verbose(0) << "ERROR: The two-step permutation procedure did not maintain injectivity!" << endl; 430 431 exit(255); 431 432 } 432 // *out<< endl;433 //Log() << Verbose(0) << endl; 433 434 } else { 434 cerr<< "ERROR: " << *Runner << " was not the owner of " << *Sprinter << "!" << endl;435 eLog() << Verbose(0) << "ERROR: " << *Runner << " was not the owner of " << *Sprinter << "!" << endl; 435 436 exit(255); 436 437 } … … 442 443 } while (Walker->next != end); 443 444 } while ((OlderPotential - OldPotential) > 1e-3); 444 *out<< Verbose(1) << "done." << endl;445 Log() << Verbose(1) << "done." << endl; 445 446 446 447 … … 450 451 Free(&Params.DistanceList); 451 452 Free(&Params.DistanceIterators); 452 return ConstrainedPotential( out,Params);453 return ConstrainedPotential(Params); 453 454 }; 454 455 … … 462 463 * \todo the constant for the constrained potential distance part is hard-coded independently of the hard-coded value in MinimiseConstrainedPotential() 463 464 */ 464 void molecule::EvaluateConstrainedForces( ofstream *out,int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force)465 void molecule::EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) 465 466 { 466 467 /// evaluate forces (only the distance to target dependent part) with the final PermutationMap 467 *out<< Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl;468 Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl; 468 469 ActOnAllAtoms( &atom::EvaluateConstrainedForce, startstep, endstep, PermutationMap, Force ); 469 *out<< Verbose(1) << "done." << endl;470 Log() << Verbose(1) << "done." << endl; 470 471 }; 471 472 … … 479 480 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories 480 481 */ 481 bool molecule::LinearInterpolationBetweenConfiguration( ofstream *out,int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)482 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity) 482 483 { 483 484 molecule *mol = NULL; … … 489 490 atom *Walker = NULL, *Sprinter = NULL; 490 491 if (!MapByIdentity) 491 MinimiseConstrainedPotential( out,PermutationMap, startstep, endstep, configuration.GetIsAngstroem());492 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); 492 493 else { 493 494 PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap"); … … 502 503 503 504 // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule 504 *out<< Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl;505 Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl; 505 506 for (int step = 0; step <= MaxSteps; step++) { 506 507 mol = new molecule(elemente); … … 514 515 Sprinter->x.x[n] = Walker->Trajectory.R.at(startstep).x[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep).x[n] - Walker->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps); 515 516 // add to Trajectories 516 // *out<< Verbose(3) << step << ">=" << MDSteps-1 << endl;517 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 517 518 if (step < MaxSteps) { 518 519 Walker->Trajectory.R.at(step).x[n] = Walker->Trajectory.R.at(startstep).x[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep).x[n] - Walker->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps); … … 529 530 for (int i=AtomCount; i--; ) 530 531 SortIndex[i] = i; 531 status = MoleculePerStep->OutputConfigForListOfFragments( out,&configuration, SortIndex);532 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 532 533 533 534 // free and return … … 550 551 * \todo This is not yet checked if it is correctly working with DoConstrained set to true. 551 552 */ 552 bool molecule::VerletForceIntegration( ofstream *out,char *file, config &configuration)553 bool molecule::VerletForceIntegration(char *file, config &configuration) 553 554 { 554 555 ifstream input(file); … … 567 568 // parse file into ForceMatrix 568 569 if (!Force.ParseMatrix(file, 0,0,0)) { 569 cerr<< "Could not parse Force Matrix file " << file << "." << endl;570 eLog() << Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl; 570 571 return false; 571 572 } 572 573 if (Force.RowCounter[0] != AtomCount) { 573 cerr<< "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl;574 eLog() << Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl; 574 575 return false; 575 576 } … … 588 589 // calculate forces and potential 589 590 atom **PermutationMap = NULL; 590 ConstrainedPotentialEnergy = MinimiseConstrainedPotential( out,PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem());591 EvaluateConstrainedForces( out,configuration.DoConstrainedMD, 0, PermutationMap, &Force);591 ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem()); 592 EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force); 592 593 Free(&PermutationMap); 593 594 } … … 649 650 switch(Thermostat) { 650 651 case None: 651 cout<< Verbose(2) << "Applying no thermostat..." << endl;652 Log() << Verbose(2) << "Applying no thermostat..." << endl; 652 653 break; 653 654 case Woodcock: 654 655 if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) { 655 cout<< Verbose(2) << "Applying Woodcock thermostat..." << endl;656 Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl; 656 657 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); 657 658 } 658 659 break; 659 660 case Gaussian: 660 cout<< Verbose(2) << "Applying Gaussian thermostat..." << endl;661 Log() << Verbose(2) << "Applying Gaussian thermostat..." << endl; 661 662 ActOnAllAtoms( &atom::Thermostat_Gaussian_init, MDSteps, &G, &E ); 662 663 663 cout<< Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl;664 Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl; 664 665 ActOnAllAtoms( &atom::Thermostat_Gaussian_least_constraint, MDSteps, G/E, &ekin, &configuration); 665 666 666 667 break; 667 668 case Langevin: 668 cout<< Verbose(2) << "Applying Langevin thermostat..." << endl;669 Log() << Verbose(2) << "Applying Langevin thermostat..." << endl; 669 670 // init random number generator 670 671 gsl_rng_env_setup(); … … 676 677 677 678 case Berendsen: 678 cout<< Verbose(2) << "Applying Berendsen-VanGunsteren thermostat..." << endl;679 Log() << Verbose(2) << "Applying Berendsen-VanGunsteren thermostat..." << endl; 679 680 ActOnAllAtoms( &atom::Thermostat_Berendsen, MDSteps, ScaleTempFactor, &ekin, &configuration ); 680 681 break; 681 682 682 683 case NoseHoover: 683 cout<< Verbose(2) << "Applying Nose-Hoover thermostat..." << endl;684 Log() << Verbose(2) << "Applying Nose-Hoover thermostat..." << endl; 684 685 // dynamically evolve alpha (the additional degree of freedom) 685 686 delta_alpha = 0.; … … 687 688 delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass); 688 689 configuration.alpha += delta_alpha*configuration.Deltat; 689 cout<< Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl;690 Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl; 690 691 // apply updated alpha as additional force 691 692 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration ); 692 693 break; 693 694 } 694 cout<< Verbose(1) << "Kinetic energy is " << ekin << "." << endl;695 }; 695 Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl; 696 };
Note:
See TracChangeset
for help on using the changeset viewer.