2#include "math/libfunc.h"
24 constexpr bool do_e = Ver::e;
25 constexpr bool do_g = Ver::g;
26 constexpr bool do_v = Ver::v;
28 if CONSTEXPR (do_v) vxx = 0, vyx = 0, vzx = 0, vyy = 0, vzy = 0, vzz = 0;
30 const int ia =
itors[i][0];
31 const int ib =
itors[i][1];
32 const int ic =
itors[i][2];
33 const int id =
itors[i][3];
57 real xt = yba * zcb - ycb * zba;
58 real yt = zba * xcb - zcb * xba;
59 real zt = xba * ycb - xcb * yba;
60 real xu = ycb * zdc - ydc * zcb;
61 real yu = zcb * xdc - zdc * xcb;
62 real zu = xcb * ydc - xdc * ycb;
63 real xtu = yt * zu - yu * zt;
64 real ytu = zt * xu - zu * xt;
65 real ztu = xt * yu - xu * yt;
66 real rt2 = xt * xt + yt * yt + zt * zt;
67 real ru2 = xu * xu + yu * yu + zu * zu;
68 real rtru = REAL_SQRT(rt2 * ru2);
71 real rcb = REAL_SQRT(xcb * xcb + ycb * ycb + zcb * zcb);
72 real cosine = (xt * xu + yt * yu + zt * zu) * REAL_RECIP(rtru);
73 real sine = (xcb * xtu + ycb * ytu + zcb * ztu) * REAL_RECIP(rcb * rtru);
98 real cosine2 = cosine * cosine - sine * sine;
99 real sine2 = 2 * cosine * sine;
100 real cosine3 = cosine * cosine2 - sine * sine2;
101 real sine3 = cosine * sine2 + sine * cosine2;
102 real cosine4 = cosine * cosine3 - sine * sine3;
103 real sine4 = cosine * sine3 + sine * cosine3;
104 real cosine5 = cosine * cosine4 - sine * sine4;
105 real sine5 = cosine * sine4 + sine * cosine4;
106 real cosine6 = cosine * cosine5 - sine * sine5;
107 real sine6 = cosine * sine5 + sine * cosine5;
109 real phi1 = 1 + (cosine * c1 + sine * s1);
110 real phi2 = 1 + (cosine2 * c2 + sine2 * s2);
111 real phi3 = 1 + (cosine3 * c3 + sine3 * s3);
112 real phi4 = 1 + (cosine4 * c4 + sine4 * s4);
113 real phi5 = 1 + (cosine5 * c5 + sine5 * s5);
114 real phi6 = 1 + (cosine6 * c6 + sine6 * s6);
115 real dphi1 = (cosine * s1 - sine * c1);
116 real dphi2 = 2 * (cosine2 * s2 - sine2 * c2);
117 real dphi3 = 3 * (cosine3 * s3 - sine3 * c3);
118 real dphi4 = 4 * (cosine4 * s4 - sine4 * c4);
119 real dphi5 = 5 * (cosine5 * s5 - sine5 * c5);
120 real dphi6 = 6 * (cosine6 * s6 - sine6 * c6);
124 * (v1 * phi1 + v2 * phi2 + v3 * phi3 + v4 * phi4 + v5 * phi5
129 * (v1 * dphi1 + v2 * dphi2 + v3 * dphi3 + v4 * dphi4 + v5 * dphi5
134 real xca = xic - xia;
135 real yca = yic - yia;
136 real zca = zic - zia;
137 real xdb = xid - xib;
138 real ydb = yid - yib;
139 real zdb = zid - zib;
141 real rt_inv = REAL_RECIP(rt2 * rcb);
142 real ru_inv = REAL_RECIP(ru2 * rcb);
143 real dedxt = dedphi * (yt * zcb - ycb * zt) * rt_inv;
144 real dedyt = dedphi * (zt * xcb - zcb * xt) * rt_inv;
145 real dedzt = dedphi * (xt * ycb - xcb * yt) * rt_inv;
146 real dedxu = -dedphi * (yu * zcb - ycb * zu) * ru_inv;
147 real dedyu = -dedphi * (zu * xcb - zcb * xu) * ru_inv;
148 real dedzu = -dedphi * (xu * ycb - xcb * yu) * ru_inv;
152 real dedxia = zcb * dedyt - ycb * dedzt;
153 real dedyia = xcb * dedzt - zcb * dedxt;
154 real dedzia = ycb * dedxt - xcb * dedyt;
155 real dedxib = yca * dedzt - zca * dedyt + zdc * dedyu - ydc * dedzu;
156 real dedyib = zca * dedxt - xca * dedzt + xdc * dedzu - zdc * dedxu;
157 real dedzib = xca * dedyt - yca * dedxt + ydc * dedxu - xdc * dedyu;
158 real dedxic = zba * dedyt - yba * dedzt + ydb * dedzu - zdb * dedyu;
159 real dedyic = xba * dedzt - zba * dedxt + zdb * dedxu - xdb * dedzu;
160 real dedzic = yba * dedxt - xba * dedyt + xdb * dedyu - ydb * dedxu;
161 real dedxid = zcb * dedyu - ycb * dedzu;
162 real dedyid = xcb * dedzu - zcb * dedxu;
163 real dedzid = ycb * dedxu - xcb * dedyu;
179 vxx = xcb * (dedxic + dedxid) - xba * dedxia + xdc * dedxid;
180 vyx = ycb * (dedxic + dedxid) - yba * dedxia + ydc * dedxid;
181 vzx = zcb * (dedxic + dedxid) - zba * dedxia + zdc * dedxid;
182 vyy = ycb * (dedyic + dedyid) - yba * dedyia + ydc * dedyid;
183 vzy = zcb * (dedyic + dedyid) - zba * dedyia + zdc * dedyid;
184 vzz = zcb * (dedzic + dedzid) - zba * dedzia + zdc * dedzid;
void atomic_add(T value, T *buffer, size_t offset=0)
Definition: acc/adddef.h:14
#define SEQ_CUDA
Definition: acc/seqdef.h:12
#define restrict
Definition: macro.h:51
#define CONSTEXPR
Definition: macro.h:61
real * z
Current coordinates used in energy evaluation and neighbor lists.
real * x
Number of the trajectory frames.
real * y
Current coordinates used in energy evaluation and neighbor lists.
float real
Definition: precision.h:80
fixed grad_prec
Definition: precision.h:103
__device__ void dk_tors(real &__restrict__ e, real &__restrict__ vxx, real &__restrict__ vyx, real &__restrict__ vzx, real &__restrict__ vyy, real &__restrict__ vzy, real &__restrict__ vzz, grad_prec *__restrict__ detx, grad_prec *__restrict__ dety, grad_prec *__restrict__ detz, real torsunit, int i, const int(*__restrict__ itors)[4], const real(*__restrict__ tors1)[4], const real(*__restrict__ tors2)[4], const real(*__restrict__ tors3)[4], const real(*__restrict__ tors4)[4], const real(*__restrict__ tors5)[4], const real(*__restrict__ tors6)[4], const real *__restrict__ x, const real *__restrict__ y, const real *__restrict__ z)
Definition: torsion.h:10