1 | //
|
---|
2 | // tors.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 | /* tors.cc -- implementation of the torsion 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 TorsSimpleCo_cd(
|
---|
58 | typeid(TorsSimpleCo),"TorsSimpleCo",1,"public SimpleCo",
|
---|
59 | create<TorsSimpleCo>, create<TorsSimpleCo>, create<TorsSimpleCo>);
|
---|
60 | SimpleCo_IMPL(TorsSimpleCo)
|
---|
61 |
|
---|
62 |
|
---|
63 | TorsSimpleCo::TorsSimpleCo() : SimpleCo(4) {}
|
---|
64 |
|
---|
65 | TorsSimpleCo::TorsSimpleCo(const TorsSimpleCo& s)
|
---|
66 | : SimpleCo(4)
|
---|
67 | {
|
---|
68 | *this=s;
|
---|
69 | }
|
---|
70 |
|
---|
71 | TorsSimpleCo::TorsSimpleCo(const char *refr, int a1, int a2, int a3, int a4)
|
---|
72 | : SimpleCo(4,refr)
|
---|
73 | {
|
---|
74 | atoms[0]=a1; atoms[1]=a2; atoms[2]=a3; atoms[3]=a4;
|
---|
75 | }
|
---|
76 |
|
---|
77 | TorsSimpleCo::~TorsSimpleCo()
|
---|
78 | {
|
---|
79 | }
|
---|
80 |
|
---|
81 | TorsSimpleCo::TorsSimpleCo(const Ref<KeyVal> &kv):
|
---|
82 | SimpleCo(kv,4)
|
---|
83 | {
|
---|
84 | }
|
---|
85 |
|
---|
86 | TorsSimpleCo&
|
---|
87 | TorsSimpleCo::operator=(const TorsSimpleCo& s)
|
---|
88 | {
|
---|
89 | if(label_) delete[] label_;
|
---|
90 | label_=new char[strlen(s.label_)+1];
|
---|
91 | strcpy(label_,s.label_);
|
---|
92 | atoms[0]=s.atoms[0]; atoms[1]=s.atoms[1]; atoms[2]=s.atoms[2];
|
---|
93 | atoms[3]=s.atoms[3];
|
---|
94 | return *this;
|
---|
95 | }
|
---|
96 |
|
---|
97 | double
|
---|
98 | TorsSimpleCo::calc_intco(Molecule& m, double *bmat, double coeff)
|
---|
99 | {
|
---|
100 | int a=atoms[0]-1; int b=atoms[1]-1; int c=atoms[2]-1; int d=atoms[3]-1;
|
---|
101 | SCVector3 u1,u2,u3,z1,z2;
|
---|
102 |
|
---|
103 | SCVector3 ra(m.r(a));
|
---|
104 | SCVector3 rb(m.r(b));
|
---|
105 | SCVector3 rc(m.r(c));
|
---|
106 | SCVector3 rd(m.r(d));
|
---|
107 |
|
---|
108 | u1 = ra-rb;
|
---|
109 | u1.normalize();
|
---|
110 | u2 = rc-rb;
|
---|
111 | u2.normalize();
|
---|
112 | u3 = rc-rd;
|
---|
113 | u3.normalize();
|
---|
114 |
|
---|
115 | z1 = u1.perp_unit(u2);
|
---|
116 | z2 = u3.perp_unit(u2);
|
---|
117 |
|
---|
118 | double co=z1.dot(z2);
|
---|
119 | u1[0]=z1[1]*z2[2]-z1[2]*z2[1];
|
---|
120 | u1[1]=z1[2]*z2[0]-z1[0]*z2[2];
|
---|
121 | u1[2]=z1[0]*z2[1]-z1[1]*z2[0];
|
---|
122 | double co2=u1.dot(u2);
|
---|
123 |
|
---|
124 | if (co < -1.0) co= -1.0;
|
---|
125 | if (co > 1.0) co = 1.0;
|
---|
126 |
|
---|
127 | // save the old value of the torsion so we can make sure the discontinuity
|
---|
128 | // at -pi/2 doesn't bite us
|
---|
129 |
|
---|
130 | double oldval = -value_;
|
---|
131 |
|
---|
132 | value_=(co2<0) ? -acos(-co) : acos(-co);
|
---|
133 |
|
---|
134 | // ok, we want omega between 3*pi/2 and -pi/2, so if omega is > pi/2
|
---|
135 | // (omega is eventually -omega), then knock 2pi off of it
|
---|
136 | if(value_ > pih) value_ -= tpi;
|
---|
137 |
|
---|
138 | // the following tests to see if the new coordinate has crossed the
|
---|
139 | // 3pi/2 <--> -pi/2 boundary...if so, then we add or subtract 2pi as
|
---|
140 | // needed to prevent the transformation from internals to cartesians
|
---|
141 | // from blowing up
|
---|
142 | while(oldval-value_ > (pi + 1.0e-8)) value_ += tpi;
|
---|
143 | while(oldval-value_ < -(pi + 1.0e-8)) value_ -= tpi;
|
---|
144 |
|
---|
145 | value_ = -value_;
|
---|
146 |
|
---|
147 | if (bmat) {
|
---|
148 | double uu,vv,ww,zz;
|
---|
149 | u1 = ra-rb;
|
---|
150 | u1.normalize();
|
---|
151 | u2 = rc-rb;
|
---|
152 | u2.normalize();
|
---|
153 | u3 = rc-rd;
|
---|
154 | u3.normalize();
|
---|
155 | z1 = u1.perp_unit(u2);
|
---|
156 | z2 = u3.perp_unit(u2);
|
---|
157 | co=u1.dot(u2); double si=s2(co);
|
---|
158 | co2=u2.dot(u3); double si2=s2(co2);
|
---|
159 | double r1 = ra.dist(rb);
|
---|
160 | double r2 = rc.dist(rb);
|
---|
161 | double r3 = rc.dist(rd);
|
---|
162 | #if OLD_BMAT
|
---|
163 | r1 *= bohr;
|
---|
164 | r2 *= bohr;
|
---|
165 | r3 *= bohr;
|
---|
166 | #endif
|
---|
167 | for (int j=0; j < 3; j++) {
|
---|
168 | if (si > 1.0e-5) uu = z1[j]/(r1*si);
|
---|
169 | else uu = 0.0;
|
---|
170 | if (si2 > 1.0e-5) zz = z2[j]/(r3*si2);
|
---|
171 | else zz = 0.0;
|
---|
172 | vv = (r1*co/r2-1.0)*uu-zz*r3*co2/r2;
|
---|
173 | ww = -uu-vv-zz;
|
---|
174 | bmat[a*3+j] += coeff*uu;
|
---|
175 | bmat[b*3+j] += coeff*vv;
|
---|
176 | bmat[c*3+j] += coeff*ww;
|
---|
177 | bmat[d*3+j] += coeff*zz;
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | return value_;
|
---|
182 | }
|
---|
183 |
|
---|
184 | double
|
---|
185 | TorsSimpleCo::calc_force_con(Molecule& m)
|
---|
186 | {
|
---|
187 | int a=atoms[1]-1; int b=atoms[2]-1;
|
---|
188 |
|
---|
189 | double rad_ab = m.atominfo()->atomic_radius(m.Z(a))
|
---|
190 | + m.atominfo()->atomic_radius(m.Z(b));
|
---|
191 |
|
---|
192 | SCVector3 ra(m.r(a));
|
---|
193 | SCVector3 rb(m.r(b));
|
---|
194 |
|
---|
195 | double r_ab = ra.dist(rb);
|
---|
196 |
|
---|
197 | double k = 0.0015 + 14.0*pow(1.0,0.57)/pow((rad_ab*r_ab),4.0) *
|
---|
198 | exp(-2.85*(r_ab-rad_ab));
|
---|
199 |
|
---|
200 | #if OLD_BMAT
|
---|
201 | // return force constant in mdyn*ang/rad^2
|
---|
202 | return k*4.359813653;
|
---|
203 | #else
|
---|
204 | return k;
|
---|
205 | #endif
|
---|
206 | }
|
---|
207 |
|
---|
208 | const char *
|
---|
209 | TorsSimpleCo::ctype() const
|
---|
210 | {
|
---|
211 | return "TORS";
|
---|
212 | }
|
---|
213 |
|
---|
214 | double
|
---|
215 | TorsSimpleCo::radians() const
|
---|
216 | {
|
---|
217 | return value_;
|
---|
218 | }
|
---|
219 |
|
---|
220 | double
|
---|
221 | TorsSimpleCo::degrees() const
|
---|
222 | {
|
---|
223 | return value_*rtd;
|
---|
224 | }
|
---|
225 |
|
---|
226 | double
|
---|
227 | TorsSimpleCo::preferred_value() const
|
---|
228 | {
|
---|
229 | return value_*rtd;
|
---|
230 | }
|
---|
231 |
|
---|
232 | /////////////////////////////////////////////////////////////////////////////
|
---|
233 |
|
---|
234 | // Local Variables:
|
---|
235 | // mode: c++
|
---|
236 | // c-file-style: "ETS"
|
---|
237 | // End:
|
---|