diff --git a/src/main/qb.cc b/src/main/qb.cc index ad4aa886..60987ca6 100644 --- a/src/main/qb.cc +++ b/src/main/qb.cc @@ -84,6 +84,7 @@ using namespace std; #include #include #include +#include #include #include #include @@ -347,6 +348,7 @@ int main(int argc, char **argv, char **envp) ui->addCmd(new LockCmd(s)); ui->addCmd(new UnlockCmd(s)); ui->addCmd(new SetVelCmd(s)); + ui->addCmd(new SetPosCmd(s)); ui->addCmd(new ComputeMLWFCmd(s)); ui->addCmd(new ConstraintCmd(s)); ui->addCmd(new ShiftWFCmd(s)); diff --git a/src/qball/qbLink.cc b/src/qball/qbLink.cc index 1ed67273..d17ed2da 100644 --- a/src/qball/qbLink.cc +++ b/src/qball/qbLink.cc @@ -87,6 +87,7 @@ using namespace std; #include #include #include +#include #include #include #include diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am index 506ec139..b7cc9c42 100644 --- a/src/ui/Makefile.am +++ b/src/ui/Makefile.am @@ -39,6 +39,7 @@ noinst_HEADERS = \ SavesysCmd.h \ SetCmd.h \ SetVelCmd.h \ + SetPosCmd.h \ ShiftWFCmd.h \ SpeciesCmd.h \ StatusCmd.h \ diff --git a/src/ui/SetPosCmd.h b/src/ui/SetPosCmd.h new file mode 100644 index 00000000..83544c0a --- /dev/null +++ b/src/ui/SetPosCmd.h @@ -0,0 +1,122 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2013, Lawrence Livermore National Security, LLC. +// qb@ll: Qbox at Lawrence Livermore +// +// This file is part of qb@ll. +// +// Produced at the Lawrence Livermore National Laboratory. +// Written by Erik Draeger (draeger1@llnl.gov) and Francois Gygi (fgygi@ucdavis.edu). +// Based on the Qbox code by Francois Gygi Copyright (c) 2008 +// LLNL-CODE-635376. All rights reserved. +// +// qb@ll is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details, in the file COPYING in the +// root directory of this distribution or . +// +//////////////////////////////////////////////////////////////////////////////// +// +// SetVelCmd.h: +// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#ifndef SETPOSCMD_H +#define SETPOSCMD_H + +#include +#include +#include +using namespace std; + +#include +#include +#include +#include +#include + +class SetPosCmd : public Cmd { + public: + + Sample *s; + + SetPosCmd(Sample *sample) : s(sample) { }; + + char const*name(void) const { return "set_position"; } + + char const*help_msg(void) const { + return + "\n lock\n\n" + " syntax: set_position [atom name] [x] [y] [z]\n\n" + " The set_position command sets the velocity for a given atom.\n\n"; + } + + + int action(int argc, char **argv) { + string name; + + string pos_unit_name = "bohr"; +// string vel_unit_name = "atomicvelocity"; + + if ( argc != 5 && argc != 6) { + ui->error(""); + return 1; + } + + if (argc == 5) { + ui->warning("Units missing for the set_velocity command, assuming 'atomicvelocity'."); + } else { + pos_unit_name = string(argv[5]); + } + + Unit pos_unit(Dimensions::length, pos_unit_name); +// Unit vel_unit(Dimensions::velocity, vel_unit_name); + + if(!pos_unit.exists()) { + ui->error("Unknown position unit '" + pos_unit_name + "'."); + return 1; + } + + name = argv[1]; + double x = atof(argv[2]); + double y = atof(argv[3]); + double z = atof(argv[4]); + D3vector newpos(x,y,z); + + newpos = pos_unit.to_atomic(newpos); + + if (s->atoms.findAtom(name) ) { + Atom *a = s->atoms.findAtom(name); + + a->set_position(newpos); + if ( ui->oncoutpe() ) + cout << "" << endl; + } + else if (s->atoms.findMMAtom(name) ) { + Atom *a = s->atoms.findMMAtom(name); + + a->set_position(newpos); + if ( ui->oncoutpe() ) + cout << "" << endl; + } + else { + if ( ui->oncoutpe() ) + cout << "SetPosCmd: " << name << " not found!" << endl; + return 1; + } + return 0; + } + +}; +#endif + +// Local Variables: +// mode: c++ +// End: diff --git a/src/ui/SetVelCmd.h b/src/ui/SetVelCmd.h index 8bf57d73..e4f6734b 100644 --- a/src/ui/SetVelCmd.h +++ b/src/ui/SetVelCmd.h @@ -78,7 +78,7 @@ class SetVelCmd : public Cmd { Unit vel_unit(Dimensions::velocity, vel_unit_name); if(!vel_unit.exists()) { - ui->error("Unknown energy unit '" + vel_unit_name + "'."); + ui->error("Unknown velocity unit '" + vel_unit_name + "'."); return 1; }