RescaleVCmd.h 1.46 KB
Newer Older
Francois Gygi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2010 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
// RescaleVCmd.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef RESCALEVCMD_H
#define RESCALEVCMD_H

#include "UserInterface.h"
#include "Sample.h"
#include <string>
#include <cstdlib>
#include <iostream>
using namespace std;

class RescaleVCmd : public Cmd
{
  private:

  public:

  Sample *s;

  RescaleVCmd(Sample *sample) : s(sample) {};

39 40
  const char *name(void) const { return "rescale_v"; }
  const char *help_msg(void) const
Francois Gygi committed
41 42 43 44 45 46 47 48 49 50
  {
    return
    "\n rescale_v\n\n"
    " syntax: rescale_v f\n\n"
    "   The rescale_v command multiplies the velocity of all atoms \n"
    "   by the factor f.\n\n";
  }

  int action(int argc, char **argv)
  {
Francois Gygi committed
51 52 53 54 55 56
    if ( argc != 2 )
    {
      if ( ui->onpe0() )
        cout << " use: rescale_v fac" << endl;
      return 1;
    }
Francois Gygi committed
57 58 59 60 61 62
    const double fac = atof(argv[1]);
    s->atoms.rescale_velocities(fac);
    return 0;
  }
};
#endif