| 1 | //
 | 
|---|
| 2 | // linip.cc
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // Modifications are
 | 
|---|
| 5 | // Copyright (C) 1996 Limit Point Systems, Inc.
 | 
|---|
| 6 | //
 | 
|---|
| 7 | // Author: Edward Seidl <seidl@janed.com>
 | 
|---|
| 8 | // Maintainer: LPS
 | 
|---|
| 9 | //
 | 
|---|
| 10 | // This file is part of the SC Toolkit.
 | 
|---|
| 11 | //
 | 
|---|
| 12 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
| 13 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
| 14 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 15 | // any later version.
 | 
|---|
| 16 | //
 | 
|---|
| 17 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 20 | // GNU Library General Public License for more details.
 | 
|---|
| 21 | //
 | 
|---|
| 22 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
| 23 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
| 24 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 25 | //
 | 
|---|
| 26 | // The U.S. Government is granted a limited license as per AL 91-7.
 | 
|---|
| 27 | //
 | 
|---|
| 28 | 
 | 
|---|
| 29 | /* lin.cc -- implementation of the linear bending internal coordinate classes
 | 
|---|
| 30 |  *
 | 
|---|
| 31 |  *      THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
 | 
|---|
| 32 |  *      "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
 | 
|---|
| 33 |  *      AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
 | 
|---|
| 34 |  *      CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
 | 
|---|
| 35 |  *      PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
 | 
|---|
| 36 |  *      RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
 | 
|---|
| 37 |  *
 | 
|---|
| 38 |  *  Author:
 | 
|---|
| 39 |  *      E. T. Seidl
 | 
|---|
| 40 |  *      Bldg. 12A, Rm. 2033
 | 
|---|
| 41 |  *      Computer Systems Laboratory
 | 
|---|
| 42 |  *      Division of Computer Research and Technology
 | 
|---|
| 43 |  *      National Institutes of Health
 | 
|---|
| 44 |  *      Bethesda, Maryland 20892
 | 
|---|
| 45 |  *      Internet: seidl@alw.nih.gov
 | 
|---|
| 46 |  *      February, 1993
 | 
|---|
| 47 |  */
 | 
|---|
| 48 | 
 | 
|---|
| 49 | #include <string.h>
 | 
|---|
| 50 | #include <math.h>
 | 
|---|
| 51 | 
 | 
|---|
| 52 | #include <chemistry/molecule/simple.h>
 | 
|---|
| 53 | #include <chemistry/molecule/localdef.h>
 | 
|---|
| 54 | 
 | 
|---|
| 55 | using namespace sc;
 | 
|---|
| 56 | 
 | 
|---|
| 57 | static ClassDesc LinIPSimpleCo_cd(
 | 
|---|
| 58 |   typeid(LinIPSimpleCo),"LinIPSimpleCo",1,"public SimpleCo",
 | 
|---|
| 59 |   create<LinIPSimpleCo>, create<LinIPSimpleCo>, create<LinIPSimpleCo>);
 | 
|---|
| 60 | SimpleCo_IMPL(LinIPSimpleCo)
 | 
|---|
| 61 | 
 | 
|---|
| 62 | LinIPSimpleCo::LinIPSimpleCo() : SimpleCo(3)
 | 
|---|
| 63 | {
 | 
|---|
| 64 |   u2[0] = 1.0; u2[1] = 0.0; u2[2] = 0.0;
 | 
|---|
| 65 | }
 | 
|---|
| 66 | 
 | 
|---|
| 67 | LinIPSimpleCo::LinIPSimpleCo(const LinIPSimpleCo& s)
 | 
|---|
| 68 |   : SimpleCo(3)
 | 
|---|
| 69 | {
 | 
|---|
| 70 |   *this=s;
 | 
|---|
| 71 | }
 | 
|---|
| 72 | 
 | 
|---|
| 73 | LinIPSimpleCo::LinIPSimpleCo(const char *refr, int a1, int a2, int a3,
 | 
|---|
| 74 |                              const SCVector3 &u)
 | 
|---|
| 75 |   : SimpleCo(3,refr), u2(u)
 | 
|---|
| 76 | {
 | 
|---|
| 77 |   atoms[0]=a1; atoms[1]=a2; atoms[2]=a3;
 | 
|---|
| 78 |   u2.normalize();
 | 
|---|
| 79 | }
 | 
|---|
| 80 | 
 | 
|---|
| 81 | LinIPSimpleCo::~LinIPSimpleCo()
 | 
|---|
| 82 | {
 | 
|---|
| 83 | }
 | 
|---|
| 84 | 
 | 
|---|
| 85 | LinIPSimpleCo::LinIPSimpleCo(const Ref<KeyVal> &kv) :
 | 
|---|
| 86 |   SimpleCo(kv,3)
 | 
|---|
| 87 | {
 | 
|---|
| 88 |   for (int i=0; i<3; i++) u2[i] = kv->doublevalue("u",i);
 | 
|---|
| 89 |   u2.normalize();
 | 
|---|
| 90 | }
 | 
|---|
| 91 | 
 | 
|---|
| 92 | LinIPSimpleCo&
 | 
|---|
| 93 | LinIPSimpleCo::operator=(const LinIPSimpleCo& s)
 | 
|---|
| 94 | {
 | 
|---|
| 95 |   if(label_) delete[] label_;
 | 
|---|
| 96 |   label_=new char[strlen(s.label_)+1];
 | 
|---|
| 97 |   strcpy(label_,s.label_);
 | 
|---|
| 98 |   atoms[0]=s.atoms[0]; atoms[1]=s.atoms[1]; atoms[2]=s.atoms[2];
 | 
|---|
| 99 |   u2 = s.u2;
 | 
|---|
| 100 |   return *this;
 | 
|---|
| 101 | }
 | 
|---|
| 102 | 
 | 
|---|
| 103 | double
 | 
|---|
| 104 | LinIPSimpleCo::calc_intco(Molecule& m, double *bmat, double coeff)
 | 
|---|
| 105 | {
 | 
|---|
| 106 |   int a=atoms[0]-1; int b=atoms[1]-1; int c=atoms[2]-1;
 | 
|---|
| 107 |   SCVector3 u1,u3;
 | 
|---|
| 108 | 
 | 
|---|
| 109 |   SCVector3 ra(m.r(a));
 | 
|---|
| 110 |   SCVector3 rb(m.r(b));
 | 
|---|
| 111 |   SCVector3 rc(m.r(c));
 | 
|---|
| 112 | 
 | 
|---|
| 113 |   u1=ra-rb;
 | 
|---|
| 114 |   u1.normalize();
 | 
|---|
| 115 |   u3=rc-rb;
 | 
|---|
| 116 |   u3.normalize();
 | 
|---|
| 117 | 
 | 
|---|
| 118 |   double co=u1.dot(u2);
 | 
|---|
| 119 |   double co2=u3.dot(u2);
 | 
|---|
| 120 | 
 | 
|---|
| 121 |   value_ = pi-acos(co)-acos(co2);
 | 
|---|
| 122 | 
 | 
|---|
| 123 |   if (bmat) {
 | 
|---|
| 124 |     double uu,ww,vv;
 | 
|---|
| 125 |     SCVector3 z1,z2;
 | 
|---|
| 126 |     z2 = u2.perp_unit(u1);
 | 
|---|
| 127 |     z1 = u1.perp_unit(z2);
 | 
|---|
| 128 |     z2 = u3.perp_unit(u2);
 | 
|---|
| 129 |     u1 = z2.perp_unit(u3);
 | 
|---|
| 130 |     double r1 = ra.dist(rb);
 | 
|---|
| 131 |     double r2 = rc.dist(rb);
 | 
|---|
| 132 | #if OLD_BMAT
 | 
|---|
| 133 |     r1 *= bohr;
 | 
|---|
| 134 |     r2 *= bohr;
 | 
|---|
| 135 | #endif    
 | 
|---|
| 136 |     for (int j=0; j < 3; j++) {
 | 
|---|
| 137 |       uu=z1[j]/r1;
 | 
|---|
| 138 |       ww=u1[j]/r2;
 | 
|---|
| 139 |       vv = -uu-ww;
 | 
|---|
| 140 |       bmat[a*3+j] += coeff*uu;
 | 
|---|
| 141 |       bmat[b*3+j] += coeff*vv;
 | 
|---|
| 142 |       bmat[c*3+j] += coeff*ww;
 | 
|---|
| 143 |     }
 | 
|---|
| 144 |   }
 | 
|---|
| 145 | 
 | 
|---|
| 146 |   return value_;
 | 
|---|
| 147 | }
 | 
|---|
| 148 | 
 | 
|---|
| 149 | double
 | 
|---|
| 150 | LinIPSimpleCo::calc_force_con(Molecule&m)
 | 
|---|
| 151 | {
 | 
|---|
| 152 |   int a=atoms[1]-1; int b=atoms[0]-1; int c=atoms[2]-1;
 | 
|---|
| 153 | 
 | 
|---|
| 154 |   SCVector3 ra(m.r(a));
 | 
|---|
| 155 |   SCVector3 rb(m.r(b));
 | 
|---|
| 156 |   SCVector3 rc(m.r(c));
 | 
|---|
| 157 | 
 | 
|---|
| 158 |   double rad_ab =   m.atominfo()->atomic_radius(m.Z(a))
 | 
|---|
| 159 |                   + m.atominfo()->atomic_radius(m.Z(b));
 | 
|---|
| 160 | 
 | 
|---|
| 161 |   double rad_ac =   m.atominfo()->atomic_radius(m.Z(a))
 | 
|---|
| 162 |                   + m.atominfo()->atomic_radius(m.Z(c));
 | 
|---|
| 163 | 
 | 
|---|
| 164 |   double r_ab = ra.dist(rb);
 | 
|---|
| 165 |   double r_ac = ra.dist(rc);
 | 
|---|
| 166 | 
 | 
|---|
| 167 |   double k = 0.089 + 0.11/pow((rad_ab*rad_ac),-0.42) *
 | 
|---|
| 168 |                            exp(-0.44*(r_ab+r_ac-rad_ab-rad_ac));
 | 
|---|
| 169 | 
 | 
|---|
| 170 | #if OLD_BMAT
 | 
|---|
| 171 |   // return force constant in mdyn*ang/rad^2
 | 
|---|
| 172 |   return k*4.359813653;
 | 
|---|
| 173 | #else  
 | 
|---|
| 174 |   return k;
 | 
|---|
| 175 | #endif  
 | 
|---|
| 176 | }
 | 
|---|
| 177 | 
 | 
|---|
| 178 | const char *
 | 
|---|
| 179 | LinIPSimpleCo::ctype() const
 | 
|---|
| 180 | {
 | 
|---|
| 181 |   return "LINIP";
 | 
|---|
| 182 | }
 | 
|---|
| 183 | 
 | 
|---|
| 184 | double
 | 
|---|
| 185 | LinIPSimpleCo::radians() const
 | 
|---|
| 186 | {
 | 
|---|
| 187 |   return value_;
 | 
|---|
| 188 | }
 | 
|---|
| 189 | 
 | 
|---|
| 190 | double
 | 
|---|
| 191 | LinIPSimpleCo::degrees() const
 | 
|---|
| 192 | {
 | 
|---|
| 193 |   return value_*rtd;
 | 
|---|
| 194 | }
 | 
|---|
| 195 | 
 | 
|---|
| 196 | double
 | 
|---|
| 197 | LinIPSimpleCo::preferred_value() const
 | 
|---|
| 198 | {
 | 
|---|
| 199 |   return value_*rtd;
 | 
|---|
| 200 | }
 | 
|---|
| 201 | 
 | 
|---|
| 202 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
| 203 | 
 | 
|---|
| 204 | // Local Variables:
 | 
|---|
| 205 | // mode: c++
 | 
|---|
| 206 | // c-file-style: "ETS"
 | 
|---|
| 207 | // End:
 | 
|---|