-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
178 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
target_sources(${PROJECT_NAME} | ||
PRIVATE ContextView.cpp DLExtForce.cpp DLExtForceImpl.cpp | ||
) | ||
|
||
if(BUILD_CUDA_LIB) | ||
target_sources(${PROJECT_NAME}CUDA | ||
PRIVATE ContextView.cpp DLExtForce.cpp DLExtForceImpl.cpp | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
target_sources(${PROJECT_NAME} PRIVATE DLExtKernelFactory.cpp) | ||
|
||
if(BUILD_CUDA_LIB) | ||
target_sources(${PROJECT_NAME}CUDA PRIVATE DLExtKernelFactory.cpp) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# SPDX-License-Identifier: MIT | ||
# See LICENSE.md and CONTRIBUTORS.md at https://github.com/SSAGESLabs/openmm-dlext | ||
|
||
# flake8: noqa:F401 | ||
|
||
import importlib.util | ||
import pathlib | ||
|
||
from .api_swig import Force, _to_capsule | ||
|
||
|
||
def _load_api(pattern): | ||
path = next(pathlib.Path(__file__).parent.glob(pattern)) | ||
spec = importlib.util.spec_from_file_location("_api", path) | ||
mod = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(mod) | ||
return mod | ||
|
||
|
||
try: | ||
_api = _load_api("_api.*") | ||
except: | ||
_api = _load_api("_api_fallback.*") | ||
|
||
ContextView = _api.ContextView | ||
DeviceType = _api.DeviceType | ||
IdsOrdering = _api.IdsOrdering | ||
atom_ids = _api.atom_ids | ||
forces = _api.forces | ||
inverse_masses = _api.inverse_masses | ||
positions = _api.positions | ||
register_plugin = _api.register_plugin | ||
velocities = _api.velocities | ||
|
||
|
||
class Force(Force): | ||
def __init__(self): | ||
super(Force, self).__init__() | ||
self.__alt__ = _api.Force(_to_capsule(self)) | ||
|
||
def is_present_in(self, system): | ||
return self.__alt__.is_present_in(_to_capsule(system)) | ||
|
||
def add_to(self, context): | ||
system = context.getSystem() | ||
if not self.thisown and not self.is_present_in(system): | ||
raise RuntimeError("Force already added to another system") | ||
self.__alt__.add_to(_to_capsule(context), _to_capsule(system)) | ||
self.thisown = False | ||
|
||
def set_callback_in(self, context, callback): | ||
self.__alt__.set_callback_in(_to_capsule(context), callback) | ||
|
||
def view(self, context): | ||
return self.__alt__.view(_to_capsule(context)) | ||
|
||
|
||
register_plugin() | ||
|
||
|
||
# Clean up namespace | ||
importlib = None | ||
pathlib = None | ||
api_swig = None | ||
|
||
del _load_api | ||
del register_plugin | ||
|
||
del api_swig | ||
del pathlib | ||
del importlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,11 @@ | ||
# flake8: noqa:F401 | ||
# SPDX-License-Identifier: MIT | ||
# See LICENSE.md and CONTRIBUTORS.md at https://github.com/SSAGESLabs/openmm-dlext | ||
|
||
from .dlpack_extension import ContextView, DeviceType | ||
from .dlpack_extension import Force as _Force | ||
from .dlpack_extension import ( | ||
IdsOrdering, | ||
atom_ids, | ||
forces, | ||
inverse_masses, | ||
positions, | ||
register_plugin, | ||
velocities, | ||
) | ||
from .dlpack_extension_swig import Force, _to_capsule | ||
# pylint: disable=unused-import,relative-beyond-top-level | ||
# flake8: noqa F401 | ||
|
||
from warnings import warn | ||
|
||
class Force(Force): | ||
def __init__(self): | ||
super(Force, self).__init__() | ||
self.__alt__ = _Force(_to_capsule(self)) | ||
from openmm.dlext import * | ||
|
||
def is_present_in(self, system): | ||
return self.__alt__.is_present_in(_to_capsule(system)) | ||
|
||
def add_to(self, context): | ||
system = context.getSystem() | ||
if not self.thisown and not self.is_present_in(system): | ||
raise RuntimeError("Force already added to another system") | ||
self.__alt__.add_to(_to_capsule(context), _to_capsule(system)) | ||
self.thisown = False | ||
|
||
def set_callback_in(self, context, callback): | ||
self.__alt__.set_callback_in(_to_capsule(context), callback) | ||
|
||
def view(self, context): | ||
return self.__alt__.view(_to_capsule(context)) | ||
|
||
|
||
register_plugin() | ||
|
||
|
||
dlpack_extension = None | ||
dlpack_extension_swig = None | ||
_dlpack_extension = None | ||
_dlpack_extension_swig = None | ||
|
||
del register_plugin | ||
del dlpack_extension | ||
del dlpack_extension_swig | ||
del _dlpack_extension | ||
del _dlpack_extension_swig | ||
warn("Importing `openmm_dlext` is deprecated. Import `openmm.dlext` instead") |