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
43f571d9
Unverified
Commit
43f571d9
authored
Nov 16, 2023
by
Peter Eastman
Committed by
GitHub
Nov 16, 2023
Browse files
Fixes to Python API for ATMForce (#4319)
parent
2ab3b77d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
wrappers/python/src/swig_doxygen/swigInputConfig.py
wrappers/python/src/swig_doxygen/swigInputConfig.py
+1
-0
wrappers/python/src/swig_doxygen/swig_lib/python/typemaps.i
wrappers/python/src/swig_doxygen/swig_lib/python/typemaps.i
+9
-2
wrappers/python/tests/TestAPIUnits.py
wrappers/python/tests/TestAPIUnits.py
+17
-0
No files found.
wrappers/python/src/swig_doxygen/swigInputConfig.py
View file @
43f571d9
...
...
@@ -521,4 +521,5 @@ UNITS = {
(
"ATMForce"
,
"getDefaultUmax"
)
:
(
'unit.kilojoule_per_mole'
,
()),
(
"ATMForce"
,
"getDefaultUbcore"
)
:
(
'unit.kilojoule_per_mole'
,
()),
(
"ATMForce"
,
"getDefaultAcore"
)
:
(
None
,
()),
(
"ATMForce"
,
"getParticleParameters"
)
:
(
None
,
(
"unit.nanometer"
,
"unit.nanometer"
)),
}
wrappers/python/src/swig_doxygen/swig_lib/python/typemaps.i
View file @
43f571d9
...
...
@@ -537,16 +537,23 @@ int Py_SequenceToVecVecVecDouble(PyObject* obj, std::vector<std::vector<std::vec
%
typemap
(
argout
)
const
std
::
vector
<
Vec3
>
&
{
}
/* The following typemaps handle the ways a Vec3 can be returned from a function. */
%
typemap
(
out
,
fragment
=
"Vec3_to_PyVec3"
)
Vec3
{
$
result
=
Vec3_to_PyVec3
(
*
$
1
)
;
}
%
typemap
(
out
,
fragment
=
"Vec3_to_PyVec3"
)
const
Vec3&
{
$
result
=
Vec3_to_PyVec3
(
*
$
1
)
;
}
%
typemap
(
in
,
numinputs
=
0
)
Vec3&
OUTPUT
(
Vec3
temp
)
{
$
1
=
&
temp;
}
%
typemap
(
argout
,
fragment
=
"Vec3_to_PyVec3"
)
Vec3&
OUTPUT
{
%
append_output
(
Vec3_to_PyVec3
(
*
$
1
))
;
}
/* Convert C++ (Vec3&, Vec3&, Vec3&) object to python tuple or tuples */
%
typemap
(
argout
,
fragment
=
"Vec3_to_PyVec3"
)
(
Vec3&
a
,
Vec3&
b
,
Vec3&
c
)
{
PyObject
*
pyVec1
=
Vec3_to_PyVec3
(
*
$
1
)
;
...
...
wrappers/python/tests/TestAPIUnits.py
View file @
43f571d9
...
...
@@ -526,6 +526,23 @@ class TestAPIUnits(unittest.TestCase):
self
.
assertEqual
(
force
.
getParticleParameters
(
1
)[
0
][
0
],
20
)
self
.
assertEqual
(
force
.
getParticleParameters
(
2
)[
0
][
0
],
30
*
4.184
)
def
testATMForce
(
self
):
"""Tests the ATMForce API features"""
force
=
ATMForce
(
0.1
,
0.2
,
0.3
,
0.4
,
0.5
,
0.7
,
0.6
,
0.8
,
-
1.0
);
force
.
addParticle
(
Vec3
(
1
,
2
,
3
),
Vec3
(
4
,
5
,
6
))
self
.
assertEqual
(
0.1
,
force
.
getGlobalParameterDefaultValue
(
0
))
self
.
assertEqual
(
0.2
,
force
.
getGlobalParameterDefaultValue
(
1
))
self
.
assertEqual
(
0.3
,
force
.
getGlobalParameterDefaultValue
(
2
))
self
.
assertEqual
(
0.4
,
force
.
getGlobalParameterDefaultValue
(
3
))
self
.
assertEqual
(
0.5
,
force
.
getGlobalParameterDefaultValue
(
4
))
self
.
assertEqual
(
0.7
,
force
.
getGlobalParameterDefaultValue
(
5
))
self
.
assertEqual
(
0.6
,
force
.
getGlobalParameterDefaultValue
(
6
))
self
.
assertEqual
(
0.8
,
force
.
getGlobalParameterDefaultValue
(
7
))
self
.
assertEqual
(
-
1.0
,
force
.
getGlobalParameterDefaultValue
(
8
))
d1
,
d0
=
force
.
getParticleParameters
(
0
)
self
.
assertEqual
(
Vec3
(
1
,
2
,
3
)
*
nanometers
,
d1
)
self
.
assertEqual
(
Vec3
(
4
,
5
,
6
)
*
nanometers
,
d0
)
def
testDrudeForce
(
self
):
""" Tests the DrudeForce API features """
force
=
DrudeForce
()
...
...
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