Changes in src/molecule_dynamics.cpp [112b09:389cc8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_dynamics.cpp
r112b09 r389cc8 13 13 #include "element.hpp" 14 14 #include "info.hpp" 15 #include "verbose.hpp" 15 16 #include "log.hpp" 16 #include "memoryallocator.hpp"17 17 #include "molecule.hpp" 18 18 #include "parser.hpp" 19 19 #include "Plane.hpp" 20 #include "ThermoStatContainer.hpp" 21 22 #include <gsl/gsl_matrix.h> 23 #include <gsl/gsl_vector.h> 24 #include <gsl/gsl_linalg.h> 20 25 21 26 /************************************* Functions for class molecule *********************************/ … … 472 477 * \param startstep stating initial configuration in molecule::Trajectories 473 478 * \param endstep stating final configuration in molecule::Trajectories 479 * \param &prefix path and prefix 474 480 * \param &config configuration structure 475 481 * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential() 476 482 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories 477 483 */ 478 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)484 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity) 479 485 { 480 486 molecule *mol = NULL; … … 524 530 for (int i=getAtomCount(); i--; ) 525 531 SortIndex[i] = i; 526 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 532 533 status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex); 527 534 delete[](SortIndex); 528 535 … … 537 544 * have to transform them). 538 545 * This adds a new MD step to the config file. 539 * \param *out output stream for debugging540 546 * \param *file filename 541 547 * \param config structure with config::Deltat, config::IsAngstroem, config::DoConstrained 542 * \param delta_t time step width in atomic units 543 * \param IsAngstroem whether coordinates are in angstroem (true) or bohrradius (false) 544 * \param DoConstrained whether we perform a constrained (>0, target step in molecule::trajectories) or unconstrained (0) molecular dynamics, \sa molecule::MinimiseConstrainedPotential() 548 * \param offset offset in matrix file to the first force component 545 549 * \return true - file found and parsed, false - file not found or imparsable 546 550 * \todo This is not yet checked if it is correctly working with DoConstrained set to true. 547 551 */ 548 bool molecule::VerletForceIntegration(char *file, config &configuration )552 bool molecule::VerletForceIntegration(char *file, config &configuration, const size_t offset) 549 553 { 550 554 Info FunctionInfo(__func__); … … 556 560 ForceMatrix Force; 557 561 558 CountElements(); // make sure ElementsInMolecule is up to date 559 562 const int AtomCount = getAtomCount(); 560 563 // check file 561 564 if (input == NULL) { … … 568 571 return false; 569 572 } 570 if (Force.RowCounter[0] != getAtomCount()) {573 if (Force.RowCounter[0] != AtomCount) { 571 574 DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl); 572 575 performCriticalExit(); … … 575 578 // correct Forces 576 579 Velocity.Zero(); 577 for(int i=0;i< getAtomCount();i++)580 for(int i=0;i<AtomCount;i++) 578 581 for(int d=0;d<NDIM;d++) { 579 Velocity[d] += Force.Matrix[0][i][d+ 5];582 Velocity[d] += Force.Matrix[0][i][d+offset]; 580 583 } 581 for(int i=0;i< getAtomCount();i++)584 for(int i=0;i<AtomCount;i++) 582 585 for(int d=0;d<NDIM;d++) { 583 Force.Matrix[0][i][d+ 5] -= Velocity[d]/static_cast<double>(getAtomCount());586 Force.Matrix[0][i][d+offset] -= Velocity[d]/static_cast<double>(AtomCount); 584 587 } 585 588 // solve a constrained potential if we are meant to … … 596 599 //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 ); 597 600 598 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force );601 ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force, (const size_t) 0); 599 602 } 600 603 // correct velocities (rather momenta) so that center of mass remains motionless … … 643 646 644 647 // calculate scale configuration 645 ScaleTempFactor = configuration.T argetTemp/ActualTemp;648 ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp; 646 649 647 650 // differentating between the various thermostats … … 651 654 break; 652 655 case Woodcock: 653 if ((configuration. ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {656 if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) { 654 657 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl); 655 658 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); … … 684 687 delta_alpha = 0.; 685 688 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 686 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.T argetTemp)/(configuration.HooverMass*Units2Electronmass);687 configuration. alpha += delta_alpha*configuration.Deltat;688 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration. alpha << "." << endl);689 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.Thermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass); 690 configuration.Thermostats->alpha += delta_alpha*configuration.Deltat; 691 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.Thermostats->alpha << "." << endl); 689 692 // apply updated alpha as additional force 690 693 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
Note:
See TracChangeset
for help on using the changeset viewer.