Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_dynamics.cpp

    r112b09 r389cc8  
    1313#include "element.hpp"
    1414#include "info.hpp"
     15#include "verbose.hpp"
    1516#include "log.hpp"
    16 #include "memoryallocator.hpp"
    1717#include "molecule.hpp"
    1818#include "parser.hpp"
    1919#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>
    2025
    2126/************************************* Functions for class molecule *********************************/
     
    472477 * \param startstep stating initial configuration in molecule::Trajectories
    473478 * \param endstep stating final configuration in molecule::Trajectories
     479 * \param &prefix path and prefix
    474480 * \param &config configuration structure
    475481 * \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()
    476482 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
    477483 */
    478 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)
     484bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity)
    479485{
    480486  molecule *mol = NULL;
     
    524530  for (int i=getAtomCount(); i--; )
    525531    SortIndex[i] = i;
    526   status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     532
     533  status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
    527534  delete[](SortIndex);
    528535
     
    537544 * have to transform them).
    538545 * This adds a new MD step to the config file.
    539  * \param *out output stream for debugging
    540546 * \param *file filename
    541547 * \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
    545549 * \return true - file found and parsed, false - file not found or imparsable
    546550 * \todo This is not yet checked if it is correctly working with DoConstrained set to true.
    547551 */
    548 bool molecule::VerletForceIntegration(char *file, config &configuration)
     552bool molecule::VerletForceIntegration(char *file, config &configuration, const size_t offset)
    549553{
    550554  Info FunctionInfo(__func__);
     
    556560  ForceMatrix Force;
    557561
    558   CountElements();  // make sure ElementsInMolecule is up to date
    559 
     562  const int AtomCount = getAtomCount();
    560563  // check file
    561564  if (input == NULL) {
     
    568571      return false;
    569572    }
    570     if (Force.RowCounter[0] != getAtomCount()) {
     573    if (Force.RowCounter[0] != AtomCount) {
    571574      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl);
    572575      performCriticalExit();
     
    575578    // correct Forces
    576579    Velocity.Zero();
    577     for(int i=0;i<getAtomCount();i++)
     580    for(int i=0;i<AtomCount;i++)
    578581      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];
    580583      }
    581     for(int i=0;i<getAtomCount();i++)
     584    for(int i=0;i<AtomCount;i++)
    582585      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);
    584587      }
    585588    // solve a constrained potential if we are meant to
     
    596599    //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );
    597600
    598     ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force);
     601    ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force, (const size_t) 0);
    599602  }
    600603  // correct velocities (rather momenta) so that center of mass remains motionless
     
    643646
    644647  // calculate scale configuration
    645   ScaleTempFactor = configuration.TargetTemp/ActualTemp;
     648  ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;
    646649
    647650  // differentating between the various thermostats
     
    651654      break;
    652655     case Woodcock:
    653       if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {
     656      if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {
    654657        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
    655658        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
     
    684687      delta_alpha = 0.;
    685688      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    686       delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(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);
    689692      // apply updated alpha as additional force
    690693      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
Note: See TracChangeset for help on using the changeset viewer.