- Main Page
- Classes
- Files
- Related Pages

# simple.h

    00001
    00002 /* simple.h -- definition of the simple internal coordinate classes
    00003  *
    00004  *      THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
    00005  *      "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
    00006  *      AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
    00007  *      CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
    00008  *      PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
    00009  *      RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
    00010  *
    00011  *  Author:
    00012  *      E. T. Seidl
    00013  *      Bldg. 12A, Rm. 2033
    00014  *      Computer Systems Laboratory
    00015  *      Division of Computer Research and Technology
    00016  *      National Institutes of Health
    00017  *      Bethesda, Maryland 20892
    00018  *      Internet: seidl@alw.nih.gov
    00019  *      February, 1993
    00020  */
    00021
    00022 #ifndef _intco_simple_h
    00023 #define _intco_simple_h
    00024
    00025 #ifdef __GNUC__
    00026 #pragma interface
    00027 #endif
    00028
    00029
    00030 #include <iostream>
    00031
    00032 #include <util/class/class.h>
    00033 #include <util/state/state.h>
    00034 #include <util/keyval/keyval.h>
    00035 #include <chemistry/molecule/molecule.h>
    00036 #include <chemistry/molecule/coor.h>
    00037
    00038 #include <math/scmat/vector3.h>
    00039
    00040 namespace sc {
    00041
    00042 // ////////////////////////////////////////////////////////////////////////
    00043
    00083 class SimpleCo : public IntCoor {
    00084   protected:
    00085     int natoms_;
    00086     int *atoms;
    00087
    00088   public:
    00089     SimpleCo();
    00094     SimpleCo(int,const char* =0);
    00096     SimpleCo(const Ref<KeyVal>&,int natom);
    00097
    00098     virtual ~SimpleCo();
    00099
    00101     int natoms() const;
    00103     int operator[](int i) const;
    00104
    00105     void save_data_state(StateOut&);
    00106     SimpleCo(StateIn&);
    00107
    00108     virtual int operator==(SimpleCo&);
    00109     int operator!=(SimpleCo&u);
    00110
    00111     // these IntCoor members are implemented in term of
    00112     // the calc_force_con and calc_intco members.
    00114     double force_constant(Ref<Molecule>&);
    00117     void update_value(const Ref<Molecule>&);
    00119     void bmat(const Ref<Molecule>&,RefSCVector&bmat,double coef = 1.0);
    00120
    00122     virtual double calc_force_con(Molecule&) = 0;
    00127     virtual double calc_intco(Molecule&, double* =0, double =1) = 0;
    00128
    00130     void print_details(const Ref<Molecule> &,
    00131                        std::ostream& = ExEnv::out0()) const;
    00132
    00135     int equivalent(Ref<IntCoor>&);
    00136   };
    00137
    00138
    00139
    00140 // ///////////////////////////////////////////////////////////////////////
    00141
    00142 #define SimpleCo_DECLARE(classname)                                           \
    00143   public:                                                                     \
    00144     virtual classname& operator=(const classname&);                           \
    00145     SimpleCo& operator=(const SimpleCo&);                                     \
    00146     double calc_force_con(Molecule&);                                         \
    00147     double calc_intco(Molecule&, double* =0, double =1);                      \
    00148     classname(StateIn&);                                                      \
    00149     void save_data_state(StateOut&)
    00150
    00151 #define SimpleCo_IMPL_eq(classname)                                           \
    00152 SimpleCo& classname::operator=(const SimpleCo& c)                             \
    00153 {                                                                             \
    00154   classname *cp = dynamic_cast<classname*>((SimpleCo*)&c);                            \
    00155   if(cp) {                                                                    \
    00156       *this=*cp;                                                              \
    00157     }                                                                         \
    00158   else {                                                                      \
    00159       natoms_ = 0;                                                            \
    00160       atoms = 0;                                                              \
    00161     }                                                                         \
    00162                                                                               \
    00163   return *this;                                                               \
    00164   }
    00165
    00166 #define SimpleCo_IMPL_StateIn(classname)                                      \
    00167 classname::classname(StateIn&si):                                             \
    00168   SimpleCo(si)                                                                \
    00169 {                                                                             \
    00170 }
    00171
    00172 #define SimpleCo_IMPL_save_data_state(classname)                              \
    00173 void classname::save_data_state(StateOut&so)                                  \
    00174 {                                                                             \
    00175   SimpleCo::save_data_state(so);                                              \
    00176 }
    00177
    00178 #define SimpleCo_IMPL(classname)                \
    00179         SimpleCo_IMPL_eq(classname)             \
    00180         SimpleCo_IMPL_StateIn(classname)        \
    00181         SimpleCo_IMPL_save_data_state(classname)
    00182
    00183 // ///////////////////////////////////////////////////////////////////////
    00184
    00193 class StreSimpleCo : public SimpleCo {
    00194     SimpleCo_DECLARE(StreSimpleCo);
    00195   public:
    00196     StreSimpleCo();
    00197     StreSimpleCo(const StreSimpleCo&);
    00201     StreSimpleCo(const char*, int, int);
    00204     StreSimpleCo(const Ref<KeyVal>&);
    00205
    00206     ~StreSimpleCo();
    00207
    00209     const char * ctype() const;
    00210
    00212     double bohr() const;
    00214     double angstrom() const;
    00216     double preferred_value() const;
    00217   };
    00218
    00219 typedef StreSimpleCo Stre;
    00220
    00221 // ///////////////////////////////////////////////////////////////////////
    00222
    00223 static const double rtd = 180.0/M_PI;
    00224
    00238 class BendSimpleCo : public SimpleCo {
    00239     SimpleCo_DECLARE(BendSimpleCo);
    00240   public:
    00241     BendSimpleCo();
    00242     BendSimpleCo(const BendSimpleCo&);
    00246     BendSimpleCo(const char*, int, int, int);
    00249     BendSimpleCo(const Ref<KeyVal>&);
    00250
    00251     ~BendSimpleCo();
    00252
    00254     const char * ctype() const;
    00255
    00257     double radians() const;
    00259     double degrees() const;
    00261     double preferred_value() const;
    00262   };
    00263
    00264 typedef BendSimpleCo Bend;
    00265
    00266 // ///////////////////////////////////////////////////////////////////////
    00267
    00296 class TorsSimpleCo : public SimpleCo {
    00297     SimpleCo_DECLARE(TorsSimpleCo);
    00298   public:
    00299     TorsSimpleCo();
    00300     TorsSimpleCo(const TorsSimpleCo&);
    00304     TorsSimpleCo(const char *refr, int, int, int, int);
    00307     TorsSimpleCo(const Ref<KeyVal>&);
    00308
    00309     ~TorsSimpleCo();
    00310
    00312     const char * ctype() const;
    00313
    00315     double radians() const;
    00317     double degrees() const;
    00319     double preferred_value() const;
    00320   };
    00321
    00322 typedef TorsSimpleCo Tors;
    00323
    00324 // ///////////////////////////////////////////////////////////////////////
    00325
    00357 class ScaledTorsSimpleCo : public SimpleCo {
    00358     SimpleCo_DECLARE(ScaledTorsSimpleCo);
    00359   private:
    00360     double old_torsion_;
    00361   public:
    00362     ScaledTorsSimpleCo();
    00363     ScaledTorsSimpleCo(const ScaledTorsSimpleCo&);
    00367     ScaledTorsSimpleCo(const char *refr, int, int, int, int);
    00370     ScaledTorsSimpleCo(const Ref<KeyVal>&);
    00371
    00372     ~ScaledTorsSimpleCo();
    00373
    00375     const char * ctype() const;
    00376
    00378     double radians() const;
    00380     double degrees() const;
    00382     double preferred_value() const;
    00383   };
    00384
    00385 typedef ScaledTorsSimpleCo ScaledTors;
    00386
    00387 // ///////////////////////////////////////////////////////////////////////
    00388
    00389 /*
    00390 The OutSimpleCo class describes an out-of-plane internal coordinate
    00391 of a molecule.  The input is described in the documentation of its parent
    00392 class SimpleCo.
    00393
    00394 Designating the four atoms as \f$a\f$, \f$b\f$, \f$c\f$, and \f$d\f$ and
    00395 their cartesian positions as \f$\bar{r}_a\f$, \f$\bar{r}_b\f$,
    00396 \f$\bar{r}_c\f$, and \f$\bar{r}_d\f$, the value of the coordinate,
    00397 \f$\tau\f$, is given by
    00398
    00399 \f[ \bar{u}_{ab} = \frac{\bar{r}_a - \bar{r}_b}{\| \bar{r}_a - \bar{r}_b \|}\f]
    00400 \f[ \bar{u}_{cb} = \frac{\bar{r}_b - \bar{r}_c}{\| \bar{r}_c - \bar{r}_b \|}\f]
    00401 \f[ \bar{u}_{db} = \frac{\bar{r}_c - \bar{r}_d}{\| \bar{r}_c - \bar{r}_b \|}\f]
    00402 \f[ \bar{n}_{bcd}= \frac{\bar{u}_{cb} \times \bar{u}_{db}}
    00403                      {\| \bar{u}_{cb} \times \bar{u}_{db} \|}\f]
    00404 \f[ \phi         = \arcsin ( \bar{u}_{ab} \cdot \bar{n}_{bcd} )\f]
    00405
    00406 */
    00407 class OutSimpleCo : public SimpleCo {
    00408     SimpleCo_DECLARE(OutSimpleCo);
    00409   public:
    00410     OutSimpleCo();
    00411     OutSimpleCo(const OutSimpleCo&);
    00416     OutSimpleCo(const char *refr, int, int, int, int);
    00419     OutSimpleCo(const Ref<KeyVal>&);
    00420
    00421     ~OutSimpleCo();
    00422
    00424     const char * ctype() const;
    00425
    00427     double radians() const;
    00429     double degrees() const;
    00431     double preferred_value() const;
    00432   };
    00433
    00434 typedef OutSimpleCo Out;
    00435
    00436 // ///////////////////////////////////////////////////////////////////////
    00437
    00459 class LinIPSimpleCo : public SimpleCo {
    00460     SimpleCo_DECLARE(LinIPSimpleCo);
    00461   private:
    00462     SCVector3 u2;
    00463   public:
    00464     LinIPSimpleCo();
    00465     LinIPSimpleCo(const LinIPSimpleCo&);
    00471     LinIPSimpleCo(const char *refr, int, int, int, const SCVector3 &u);
    00474     LinIPSimpleCo(const Ref<KeyVal>&);
    00475
    00476     ~LinIPSimpleCo();
    00477
    00479     const char * ctype() const;
    00480
    00482     double radians() const;
    00484     double degrees() const;
    00486     double preferred_value() const;
    00487   };
    00488
    00489 typedef LinIPSimpleCo LinIP;
    00490
    00491 // ///////////////////////////////////////////////////////////////////////
    00492
    00517 class LinOPSimpleCo : public SimpleCo {
    00518     SimpleCo_DECLARE(LinOPSimpleCo);
    00519   private:
    00520     SCVector3 u2;
    00521   public:
    00522     LinOPSimpleCo();
    00523     LinOPSimpleCo(const LinOPSimpleCo&);
    00529     LinOPSimpleCo(const char *refr, int, int, int, const SCVector3 &u);
    00532     LinOPSimpleCo(const Ref<KeyVal>&);
    00533
    00534     ~LinOPSimpleCo();
    00535
    00537     const char * ctype() const;
    00538
    00540     double radians() const;
    00542     double degrees() const;
    00544     double preferred_value() const;
    00545   };
    00546
    00547 typedef LinOPSimpleCo LinOP;
    00548
    00549 }
    00550
    00551 #endif /* _intco_simple_h */
    00552
    00553 // Local Variables:
    00554 // mode: c++
    00555 // c-file-style: "CLJ"
    00556 // End: