[0b990d] | 1 | //
|
---|
| 2 | // bend.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 | /* bend.cc -- implementation of the bending simple internal coordinate class
|
---|
| 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 BendSimpleCo_cd(
|
---|
| 58 | typeid(BendSimpleCo),"BendSimpleCo",1,"public SimpleCo",
|
---|
| 59 | create<BendSimpleCo>, create<BendSimpleCo>, create<BendSimpleCo>);
|
---|
| 60 | SimpleCo_IMPL(BendSimpleCo)
|
---|
| 61 |
|
---|
| 62 | BendSimpleCo::BendSimpleCo() : SimpleCo(3) {}
|
---|
| 63 |
|
---|
| 64 | BendSimpleCo::BendSimpleCo(const BendSimpleCo& s)
|
---|
| 65 | : SimpleCo(3)
|
---|
| 66 | {
|
---|
| 67 | *this=s;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | BendSimpleCo::BendSimpleCo(const char *refr, int a1, int a2, int a3)
|
---|
| 71 | : SimpleCo(3,refr)
|
---|
| 72 | {
|
---|
| 73 | atoms[0]=a1; atoms[1]=a2; atoms[2]=a3;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | BendSimpleCo::BendSimpleCo(const Ref<KeyVal> &kv)
|
---|
| 77 | : SimpleCo(kv,3)
|
---|
| 78 | {
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | BendSimpleCo::~BendSimpleCo()
|
---|
| 82 | {
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | BendSimpleCo&
|
---|
| 86 | BendSimpleCo::operator=(const BendSimpleCo& s)
|
---|
| 87 | {
|
---|
| 88 | if(label_) delete[] label_;
|
---|
| 89 | label_=new char[strlen(s.label_)+1]; strcpy(label_,s.label_);
|
---|
| 90 | atoms[0]=s.atoms[0]; atoms[1]=s.atoms[1]; atoms[2]=s.atoms[2];
|
---|
| 91 | return *this;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | double
|
---|
| 95 | BendSimpleCo::calc_intco(Molecule& m, double *bmat, double coeff)
|
---|
| 96 | {
|
---|
| 97 | SCVector3 u1, u2;
|
---|
| 98 | int a=atoms[0]-1; int b=atoms[1]-1; int c=atoms[2]-1;
|
---|
| 99 |
|
---|
| 100 | SCVector3 ra(m.r(a));
|
---|
| 101 | SCVector3 rb(m.r(b));
|
---|
| 102 | SCVector3 rc(m.r(c));
|
---|
| 103 |
|
---|
| 104 | u1 = ra-rb;
|
---|
| 105 | u1.normalize();
|
---|
| 106 | u2 = rc-rb;
|
---|
| 107 | u2.normalize();
|
---|
| 108 |
|
---|
| 109 | double co=u1.dot(u2);
|
---|
| 110 |
|
---|
| 111 | value_=acos(co);
|
---|
| 112 |
|
---|
| 113 | if(bmat) {
|
---|
| 114 | double uu,ww,vv;
|
---|
| 115 | double si=s2(co);
|
---|
| 116 | double r1i, r2i;
|
---|
| 117 | if (si > 1.0e-4) {
|
---|
| 118 | r1i = 1.0/(si*ra.dist(rb));
|
---|
| 119 | r2i = 1.0/(si*rc.dist(rb));
|
---|
| 120 | }
|
---|
| 121 | else {r1i = 0.0; r2i = 0.0;}
|
---|
| 122 | #if OLD_BMAT
|
---|
| 123 | r1i /= bohr;
|
---|
| 124 | r2i /= bohr;
|
---|
| 125 | #endif
|
---|
| 126 | for (int j=0; j < 3; j++) {
|
---|
| 127 | uu = (co*u1[j]-u2[j])*r1i;
|
---|
| 128 | ww = (co*u2[j]-u1[j])*r2i;
|
---|
| 129 | vv = -uu-ww;
|
---|
| 130 | bmat[a*3+j] += coeff*uu;
|
---|
| 131 | bmat[b*3+j] += coeff*vv;
|
---|
| 132 | bmat[c*3+j] += coeff*ww;
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | return value_;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | double
|
---|
| 140 | BendSimpleCo::calc_force_con(Molecule& m)
|
---|
| 141 | {
|
---|
| 142 | int a=atoms[1]-1; int b=atoms[0]-1; int c=atoms[2]-1;
|
---|
| 143 |
|
---|
| 144 | double rad_ab = m.atominfo()->atomic_radius(m.Z(a))
|
---|
| 145 | + m.atominfo()->atomic_radius(m.Z(b));
|
---|
| 146 |
|
---|
| 147 | double rad_ac = m.atominfo()->atomic_radius(m.Z(a))
|
---|
| 148 | + m.atominfo()->atomic_radius(m.Z(c));
|
---|
| 149 |
|
---|
| 150 | SCVector3 ra(m.r(a));
|
---|
| 151 | SCVector3 rb(m.r(b));
|
---|
| 152 | SCVector3 rc(m.r(c));
|
---|
| 153 |
|
---|
| 154 | double r_ab = ra.dist(rb);
|
---|
| 155 | double r_ac = ra.dist(rc);
|
---|
| 156 |
|
---|
| 157 | double k = 0.089 + 0.11/pow((rad_ab*rad_ac),-0.42) *
|
---|
| 158 | exp(-0.44*(r_ab+r_ac-rad_ab-rad_ac));
|
---|
| 159 |
|
---|
| 160 | #if OLD_BMAT
|
---|
| 161 | // return force constant in mdyn*ang/rad^2
|
---|
| 162 | return k*4.359813653;
|
---|
| 163 | #else
|
---|
| 164 | return k;
|
---|
| 165 | #endif
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | const char *
|
---|
| 169 | BendSimpleCo::ctype() const
|
---|
| 170 | {
|
---|
| 171 | return "BEND";
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | double
|
---|
| 175 | BendSimpleCo::radians() const
|
---|
| 176 | {
|
---|
| 177 | return value_;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | double
|
---|
| 181 | BendSimpleCo::degrees() const
|
---|
| 182 | {
|
---|
| 183 | return value_*rtd;
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | double
|
---|
| 187 | BendSimpleCo::preferred_value() const
|
---|
| 188 | {
|
---|
| 189 | return value_*rtd;
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 193 |
|
---|
| 194 | // Local Variables:
|
---|
| 195 | // mode: c++
|
---|
| 196 | // c-file-style: "ETS"
|
---|
| 197 | // End:
|
---|