PositionConstraint.h 2.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008 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/>.
//
////////////////////////////////////////////////////////////////////////////////
//
//  PositionConstraint.h
//
////////////////////////////////////////////////////////////////////////////////
18
// $Id: PositionConstraint.h,v 1.2 2009-05-15 04:38:48 fgygi Exp $
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

#ifndef POSITIONCONSTRAINT_H
#define POSITIONCONSTRAINT_H

#include "Constraint.h"
#include <cassert>
#include <cmath> // fabs

class AtomSet;

class PositionConstraint : public Constraint
{
  std::string name1_;
  int    ia1_, is1_;
  double force_, weight_, tol_;

  public:

  PositionConstraint(std::string name, std::string name1, double tolerance):
  name1_(name1), tol_(tolerance)
  {
    name_ = name;
    names_.resize(1);
    names_[0] = name1_;
    force_ = 0.0;
    weight_ = 1.0;
  }
  ~PositionConstraint(void) {}

  std::string type(void) const { return "position"; }
  double value(void) const { return 0.0; }
  double velocity(void) const { return 0.0; }
  double force(void) const { return force_; }
  double weight(void) const { return weight_; }
  double tolerance(void) const { return tol_; }
  void set_value(double value)
  {
    // no value to set
  }
  void set_velocity(double velocity)
  {
    // no value to set
  }

  void setup(const AtomSet& atoms);
64
  int dofs(void) const { return 3; }
65 66 67 68 69 70 71 72 73 74 75
  void update(double dt);
  bool enforce_r(const std::vector<std::vector<double> > &r0,
                 std::vector<std::vector<double> > &rp) const;
  bool enforce_v(const std::vector<std::vector<double> > &r0,
                 std::vector<std::vector<double> > &v0) const;
  void compute_force(const std::vector<std::vector<double> > &r0,
                     const std::vector<std::vector<double> > &f);
  std::ostream& print( std::ostream& os );

};
#endif