1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2009 The Regents of the University of California 4 // 5 // This file is part of Qbox 6 // 7 // Qbox is distributed under the terms of the GNU General Public License 8 // as published by the Free Software Foundation, either version 2 of 9 // the License, or (at your option) any later version. 10 // See the file COPYING in the root directory of this distribution 11 // or <http://www.gnu.org/licenses/>. 12 // 13 //////////////////////////////////////////////////////////////////////////////// 14 // 15 // GlobalExtForce.h 16 // 17 //////////////////////////////////////////////////////////////////////////////// 18 19 #ifndef GLOBALEXTFORCE_H 20 #define GLOBALEXTFORCE_H 21 22 #include "ExtForce.h" 23 #include "D3vector.h" 24 #include <cassert> 25 26 class AtomSet; 27 28 class GlobalExtForce: public ExtForce 29 { 30 D3vector force_; 31 int na_; 32 33 public: 34 GlobalExtForce(std::string name,D3vector force)35 GlobalExtForce(std::string name, D3vector force) : force_(force) 36 { 37 name_ = name; 38 } ~GlobalExtForce(void)39 ~GlobalExtForce(void) {} 40 type(void)41 std::string type(void) const { return "global"; } set_value(std::vector<double> f)42 void set_value(std::vector<double> f) 43 { 44 force_.x = f[0]; 45 force_.y = f[1]; 46 force_.z = f[2]; 47 } 48 49 void setup(const AtomSet& atoms); 50 double energy(const std::vector<std::vector<double> > &r, 51 std::vector<std::vector<double> > &f); sum_contrib(void)52 D3vector sum_contrib(void) { return force_; } magnitude(void)53 double magnitude(void) { return length(force_); } 54 std::ostream& print( std::ostream& os ); 55 56 }; 57 #endif 58