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
c2817e92
Unverified
Commit
c2817e92
authored
Jan 16, 2019
by
peastman
Committed by
GitHub
Jan 16, 2019
Browse files
Merge pull request #2241 from peastman/cross
Fixed bug involving nested cross products
parents
4d7ab095
c2015d51
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
3 deletions
+9
-3
platforms/cuda/src/CudaExpressionUtilities.cpp
platforms/cuda/src/CudaExpressionUtilities.cpp
+2
-1
platforms/opencl/src/OpenCLExpressionUtilities.cpp
platforms/opencl/src/OpenCLExpressionUtilities.cpp
+2
-1
tests/TestCustomIntegrator.h
tests/TestCustomIntegrator.h
+5
-1
No files found.
platforms/cuda/src/CudaExpressionUtilities.cpp
View file @
c2817e92
...
@@ -97,6 +97,7 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
...
@@ -97,6 +97,7 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
// at once, so check to see if both are needed.
// at once, so check to see if both are needed.
vector
<
const
ExpressionTreeNode
*>
nodes
;
vector
<
const
ExpressionTreeNode
*>
nodes
;
nodes
.
push_back
(
&
node
);
for
(
int
j
=
0
;
j
<
(
int
)
allExpressions
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
allExpressions
.
size
();
j
++
)
findRelatedCustomFunctions
(
node
,
allExpressions
[
j
].
getRootNode
(),
nodes
);
findRelatedCustomFunctions
(
node
,
allExpressions
[
j
].
getRootNode
(),
nodes
);
vector
<
string
>
nodeNames
;
vector
<
string
>
nodeNames
;
...
@@ -155,7 +156,7 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
...
@@ -155,7 +156,7 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
)
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
)
out
<<
nodeNames
[
j
]
<<
" = make_"
<<
tempType
<<
"(dot("
<<
child1
<<
", "
<<
child2
<<
"));
\n
"
;
out
<<
nodeNames
[
j
]
<<
" = make_"
<<
tempType
<<
"(dot("
<<
child1
<<
", "
<<
child2
<<
"));
\n
"
;
else
else
throw
OpenMMException
(
"Unsupported derivative order for
cross
()"
);
throw
OpenMMException
(
"Unsupported derivative order for
dot
()"
);
}
}
}
}
else
if
(
node
.
getOperation
().
getName
()
==
"cross"
)
{
else
if
(
node
.
getOperation
().
getName
()
==
"cross"
)
{
...
...
platforms/opencl/src/OpenCLExpressionUtilities.cpp
View file @
c2817e92
...
@@ -88,6 +88,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
...
@@ -88,6 +88,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
// at once, so check to see if both are needed.
// at once, so check to see if both are needed.
vector
<
const
ExpressionTreeNode
*>
nodes
;
vector
<
const
ExpressionTreeNode
*>
nodes
;
nodes
.
push_back
(
&
node
);
for
(
int
j
=
0
;
j
<
(
int
)
allExpressions
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
allExpressions
.
size
();
j
++
)
findRelatedCustomFunctions
(
node
,
allExpressions
[
j
].
getRootNode
(),
nodes
);
findRelatedCustomFunctions
(
node
,
allExpressions
[
j
].
getRootNode
(),
nodes
);
vector
<
string
>
nodeNames
;
vector
<
string
>
nodeNames
;
...
@@ -146,7 +147,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
...
@@ -146,7 +147,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
)
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
)
out
<<
nodeNames
[
j
]
<<
" = dot("
<<
child1
<<
", "
<<
child2
<<
");
\n
"
;
out
<<
nodeNames
[
j
]
<<
" = dot("
<<
child1
<<
", "
<<
child2
<<
");
\n
"
;
else
else
throw
OpenMMException
(
"Unsupported derivative order for
cross
()"
);
throw
OpenMMException
(
"Unsupported derivative order for
dot
()"
);
}
}
}
}
else
if
(
node
.
getOperation
().
getName
()
==
"cross"
)
{
else
if
(
node
.
getOperation
().
getName
()
==
"cross"
)
{
...
...
tests/TestCustomIntegrator.h
View file @
c2817e92
...
@@ -1041,9 +1041,11 @@ void testVectorFunctions() {
...
@@ -1041,9 +1041,11 @@ void testVectorFunctions() {
integrator
.
addGlobalVariable
(
"sumy"
,
0.0
);
integrator
.
addGlobalVariable
(
"sumy"
,
0.0
);
integrator
.
addPerDofVariable
(
"angular"
,
0.0
);
integrator
.
addPerDofVariable
(
"angular"
,
0.0
);
integrator
.
addPerDofVariable
(
"shuffle"
,
0.0
);
integrator
.
addPerDofVariable
(
"shuffle"
,
0.0
);
integrator
.
addPerDofVariable
(
"multicross"
,
0.0
);
integrator
.
addComputeSum
(
"sumy"
,
"x*vector(0, 1, 0)"
);
integrator
.
addComputeSum
(
"sumy"
,
"x*vector(0, 1, 0)"
);
integrator
.
addComputePerDof
(
"angular"
,
"cross(v, x)"
);
integrator
.
addComputePerDof
(
"angular"
,
"cross(v, x)"
);
integrator
.
addComputePerDof
(
"shuffle"
,
"dot(vector(_z(x), _x(x), _y(x)), v)"
);
integrator
.
addComputePerDof
(
"shuffle"
,
"dot(vector(_z(x), _x(x), _y(x)), v)"
);
integrator
.
addComputePerDof
(
"multicross"
,
"cross(vector(1, 0, 0), cross(vector(0, 0, 1), vector(1, 0, 0)))"
);
OpenMM_SFMT
::
SFMT
sfmt
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
...
@@ -1061,12 +1063,14 @@ void testVectorFunctions() {
...
@@ -1061,12 +1063,14 @@ void testVectorFunctions() {
// See if the expressions were computed correctly.
// See if the expressions were computed correctly.
double
sumy
=
0
;
double
sumy
=
0
;
vector
<
Vec3
>
angular
,
shuffle
;
vector
<
Vec3
>
angular
,
shuffle
,
multicross
;
integrator
.
getPerDofVariable
(
0
,
angular
);
integrator
.
getPerDofVariable
(
0
,
angular
);
integrator
.
getPerDofVariable
(
1
,
shuffle
);
integrator
.
getPerDofVariable
(
1
,
shuffle
);
integrator
.
getPerDofVariable
(
2
,
multicross
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
ASSERT_EQUAL_VEC
(
velocities
[
i
].
cross
(
positions
[
i
]),
angular
[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
velocities
[
i
].
cross
(
positions
[
i
]),
angular
[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
Vec3
(
1
,
1
,
1
)
*
velocities
[
i
].
dot
(
Vec3
(
positions
[
i
][
2
],
positions
[
i
][
0
],
positions
[
i
][
1
])),
shuffle
[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
Vec3
(
1
,
1
,
1
)
*
velocities
[
i
].
dot
(
Vec3
(
positions
[
i
][
2
],
positions
[
i
][
0
],
positions
[
i
][
1
])),
shuffle
[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
Vec3
(
0
,
0
,
1
),
multicross
[
i
],
1e-5
);
sumy
+=
positions
[
i
][
1
];
sumy
+=
positions
[
i
][
1
];
}
}
ASSERT_EQUAL_TOL
(
sumy
,
integrator
.
getGlobalVariable
(
0
),
1e-5
);
ASSERT_EQUAL_TOL
(
sumy
,
integrator
.
getGlobalVariable
(
0
),
1e-5
);
...
...
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