Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
b438a6ea
Commit
b438a6ea
authored
Jan 07, 2016
by
peastman
Browse files
Merge pull request #1327 from peastman/torsiontorsion
AmoebaTorsionTorsionForce avoids singularity in acos()
parents
59e45c58
a557b94c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
plugins/amoeba/platforms/cuda/src/kernels/amoebaTorsionTorsionForce.cu
...a/platforms/cuda/src/kernels/amoebaTorsionTorsionForce.cu
+22
-4
No files found.
plugins/amoeba/platforms/cuda/src/kernels/amoebaTorsionTorsionForce.cu
View file @
b438a6ea
...
@@ -40,8 +40,17 @@ real rcb = SQRT(xcb*xcb + ycb*ycb + zcb*zcb);
...
@@ -40,8 +40,17 @@ real rcb = SQRT(xcb*xcb + ycb*ycb + zcb*zcb);
real
cosine1
=
(
rtru
!=
0
?
(
xt
*
xu
+
yt
*
yu
+
zt
*
zu
)
/
rtru
:
(
real
)
0
);
real
cosine1
=
(
rtru
!=
0
?
(
xt
*
xu
+
yt
*
yu
+
zt
*
zu
)
/
rtru
:
(
real
)
0
);
cosine1
=
(
cosine1
>
1
?
(
real
)
1
:
cosine1
);
cosine1
=
(
cosine1
>
1
?
(
real
)
1
:
cosine1
);
cosine1
=
(
cosine1
<
-
1
?
(
real
)
-
1
:
cosine1
);
cosine1
=
(
cosine1
<
-
1
?
(
real
)
-
1
:
cosine1
);
real
angle1
;
real
angle1
=
RAD_TO_DEG
*
ACOS
(
cosine1
);
if
(
cosine1
>
0.99
f
||
cosine1
<
-
0.99
f
)
{
// We're close to the singularity in acos(), so take the cross product and use asin() instead.
real3
cross_prod
=
cross
(
make_real3
(
xt
,
yt
,
zt
),
make_real3
(
xu
,
yu
,
zu
));
angle1
=
RAD_TO_DEG
*
ASIN
(
SQRT
(
dot
(
cross_prod
,
cross_prod
)
/
(
rt2
*
ru2
)));
if
(
cosine1
<
0.0
f
)
angle1
=
180
-
angle1
;
}
else
angle1
=
RAD_TO_DEG
*
ACOS
(
cosine1
);
real
sign
=
xba
*
xu
+
yba
*
yu
+
zba
*
zu
;
real
sign
=
xba
*
xu
+
yba
*
yu
+
zba
*
zu
;
angle1
=
(
sign
<
0
?
-
angle1
:
angle1
);
angle1
=
(
sign
<
0
?
-
angle1
:
angle1
);
real
value1
=
angle1
;
real
value1
=
angle1
;
...
@@ -50,8 +59,17 @@ real rdc = SQRT(xdc*xdc + ydc*ydc + zdc*zdc);
...
@@ -50,8 +59,17 @@ real rdc = SQRT(xdc*xdc + ydc*ydc + zdc*zdc);
real
cosine2
=
(
xu
*
xv
+
yu
*
yv
+
zu
*
zv
)
/
rurv
;
real
cosine2
=
(
xu
*
xv
+
yu
*
yv
+
zu
*
zv
)
/
rurv
;
cosine2
=
(
cosine2
>
1
?
(
real
)
1
:
cosine2
);
cosine2
=
(
cosine2
>
1
?
(
real
)
1
:
cosine2
);
cosine2
=
(
cosine2
<
-
1
?
(
real
)
-
1
:
cosine2
);
cosine2
=
(
cosine2
<
-
1
?
(
real
)
-
1
:
cosine2
);
real
angle2
=
RAD_TO_DEG
*
ACOS
(
cosine2
);
real
angle2
;
if
(
cosine2
>
0.99
f
||
cosine2
<
-
0.99
f
)
{
// We're close to the singularity in acos(), so take the cross product and use asin() instead.
real3
cross_prod
=
cross
(
make_real3
(
xu
,
yu
,
zu
),
make_real3
(
xv
,
yv
,
zv
));
angle2
=
RAD_TO_DEG
*
ASIN
(
SQRT
(
dot
(
cross_prod
,
cross_prod
)
/
(
ru2
*
rv2
)));
if
(
cosine2
<
0.0
f
)
angle2
=
180
-
angle2
;
}
else
angle2
=
RAD_TO_DEG
*
ACOS
(
cosine2
);
sign
=
xcb
*
xv
+
ycb
*
yv
+
zcb
*
zv
;
sign
=
xcb
*
xv
+
ycb
*
yv
+
zcb
*
zv
;
angle2
=
(
sign
<
0
?
-
angle2
:
angle2
);
angle2
=
(
sign
<
0
?
-
angle2
:
angle2
);
real
value2
=
angle2
;
real
value2
=
angle2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment