ExtForceCmd.h 2.09 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 39 40 41 42
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2009 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/>.
//
////////////////////////////////////////////////////////////////////////////////
//
// ExtForceCmd.h:
//
////////////////////////////////////////////////////////////////////////////////
// $Id: ExtForceCmd.h,v 1.1 2010-02-20 23:13:02 fgygi Exp $

#ifndef EXTFORCECMD_H
#define EXTFORCECMD_H

#include "UserInterface.h"
#include "Sample.h"

class ExtForceCmd : public Cmd
{
  public:

  Sample *s;

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

  char *name(void) const { return "extforce"; }
  char *help_msg(void) const
  {
    return
    "\n extforce\n\n"
    " syntax:\n\n"
    "   extforce define atomic name atom fx fy fz\n"
    "   extforce define pair name atom1 atom2 force\n"
    "   extforce define global name fx fy fz\n"
43 44
    "   extforce set name fx fy fz\n"
    "   extforce set name f\n"
Francois Gygi committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    "   extforce delete name\n"
    "   extforce list\n"
    "   External forces are added to ionic forces at each MD step.\n\n";
  }

  int action(int argc, char **argv)
  {
    const bool onpe0 = s->ctxt_.onpe0();
    if ( argc < 2 )
    {
      if ( onpe0 )
        cout << help_msg();
      return 1;
    }
    string subcmd(argv[1]);
    if ( subcmd == "define" )
    {
      return s->extforces.define_extforce(s->atoms,argc,argv);
    }
    else if ( subcmd == "set" )
    {
      return s->extforces.set_extforce(argc,argv);
    }
    else if ( subcmd == "delete" )
    {
      return s->extforces.delete_extforce(argc,argv);
    }
    else if ( subcmd == "list" )
    {
      if ( onpe0 )
        s->extforces.list_extforces(cout);
    }
    else
    {
      if ( onpe0 )
        cout << help_msg();
    }

    return 0;
  }
};
#endif