converters
#
Convert to / from smee
tensor representations.
Modules:
-
openff
–Tensor representations of SMIRNOFF force fields.
-
openmm
–Convert tensor representations into OpenMM systems.
Functions:
-
convert_handlers
–Convert a set of SMIRNOFF parameter handlers into a set of tensor potentials.
-
convert_interchange
–Convert a list of interchange objects into tensor potentials.
-
smirnoff_parameter_converter
–A decorator used to flag a function as being able to convert a parameter handlers
-
convert_to_openmm_ffxml
–Convert a SMEE force field and system to OpenMM force field XML
-
convert_to_openmm_force
–Convert a
smee
potential to OpenMM forces. -
convert_to_openmm_system
–Convert a
smee
force field and system / topology into an OpenMM system. -
convert_to_openmm_topology
–Convert a
smee
system to an OpenMM topology. -
ffxml_converter
–A decorator used to flag a function as being able to convert a tensor potential
convert_handlers
#
convert_handlers(
handlers: list[SMIRNOFFCollection],
topologies: list[Topology],
v_site_maps: list[VSiteMap | None] | None = None,
potentials: (
list[tuple[TensorPotential, list[ParameterMap]]]
| None
) = None,
constraints: (
list[TensorConstraints | None] | None
) = None,
) -> list[tuple[TensorPotential, list[ParameterMap]]]
Convert a set of SMIRNOFF parameter handlers into a set of tensor potentials.
Parameters:
-
handlers
(list[SMIRNOFFCollection]
) –The SMIRNOFF parameter handler collections for a set of interchange objects to convert.
-
topologies
(list[Topology]
) –The topologies associated with each interchange object.
-
v_site_maps
(list[VSiteMap | None] | None
, default:None
) –The v-site maps associated with each interchange object.
-
constraints
(list[TensorConstraints | None] | None
, default:None
) –Any distance constraints between atoms.
-
potentials
(list[tuple[TensorPotential, list[ParameterMap]]] | None
, default:None
) –Already converted parameter handlers that may be required as dependencies.
Returns:
-
list[tuple[TensorPotential, list[ParameterMap]]]
–The potential containing the values of the parameters in each handler collection, and a list of maps (one per topology) between molecule elements (e.g. bond indices) and parameter indices.
Examples:
>>> from openff.toolkit import ForceField, Molecule
>>> from openff.interchange import Interchange
>>>
>>> force_field = ForceField("openff_unconstrained-2.0.0.offxml")
>>> molecules = [Molecule.from_smiles("CCO"), Molecule.from_smiles("CC")]
>>>
>>> interchanges = [
... Interchange.from_smirnoff(force_field, molecule.to_topology())
... for molecule in molecules
... ]
>>> vdw_handlers = [
... interchange.collections["vdW"] for interchange in interchanges
... ]
>>>
>>> vdw_potential, applied_vdw_parameters = convert_handlers(interchanges)
Source code in smee/converters/openff/_openff.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
convert_interchange
#
convert_interchange(
interchange: Interchange | list[Interchange],
) -> tuple[TensorForceField, list[TensorTopology]]
Convert a list of interchange objects into tensor potentials.
Parameters:
-
interchange
(Interchange | list[Interchange]
) –The list of (or singile) interchange objects to convert into tensor potentials.
Returns:
-
tuple[TensorForceField, list[TensorTopology]]
–The tensor force field containing the parameters of each handler, and a list (one per interchange) of objects mapping molecule elements (e.g. bonds, angles) to corresponding handler parameters.
Examples:
>>> from openff.toolkit import ForceField, Molecule
>>> from openff.interchange import Interchange
>>>
>>> force_field = ForceField("openff_unconstrained-2.0.0.offxml")
>>> molecules = [Molecule.from_smiles("CCO"), Molecule.from_smiles("CC")]
>>>
>>> interchanges = [
... Interchange.from_smirnoff(force_field, molecule.to_topology())
... for molecule in molecules
... ]
>>>
>>> tensor_ff, tensor_topologies = convert_interchange(interchanges)
Source code in smee/converters/openff/_openff.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
smirnoff_parameter_converter
#
smirnoff_parameter_converter(
type_: str,
default_units: dict[str, Unit],
depends_on: list[str] | None = None,
)
A decorator used to flag a function as being able to convert a parameter handlers parameters into tensors.
Parameters:
-
type_
(str
) –The type of parameter handler that the decorated function can convert.
-
default_units
(dict[str, Unit]
) –The default units of each parameter in the handler.
-
depends_on
(list[str] | None
, default:None
) –The names of other handlers that this handler depends on. When set, the convert function should additionally take in a list of the already converted potentials and return a new list of potentials that should either include or replace the original potentials.
Source code in smee/converters/openff/_openff.py
convert_to_openmm_ffxml
#
convert_to_openmm_ffxml(
force_field: TensorForceField,
system: TensorSystem | TensorTopology,
) -> list[str]
Convert a SMEE force field and system to OpenMM force field XML representations.
Parameters:
-
force_field
(TensorForceField
) –The force field to convert.
-
system
(TensorSystem | TensorTopology
) –The system to convert.
Returns:
-
list[str]
–One OpenMM force field XML representation per topology in the system.
Source code in smee/converters/openmm/_ff.py
convert_to_openmm_force
#
convert_to_openmm_force(
potential: TensorPotential, system: TensorSystem
) -> list[Force]
Convert a smee
potential to OpenMM forces.
Some potentials may return multiple forces, e.g. a vdW potential may return one force containing intermolecular interactions and another containing intramolecular interactions.
See Also
potential_converter: for how to define a converter function.
Parameters:
-
potential
(TensorPotential
) –The potential to convert.
-
system
(TensorSystem
) –The system to convert.
Returns:
-
list[Force]
–The OpenMM force(s).
Source code in smee/converters/openmm/_openmm.py
convert_to_openmm_system
#
convert_to_openmm_system(
force_field: TensorForceField,
system: TensorSystem | TensorTopology,
) -> System
Convert a smee
force field and system / topology into an OpenMM system.
Parameters:
-
force_field
(TensorForceField
) –The force field parameters.
-
system
(TensorSystem | TensorTopology
) –The system / topology to convert.
Returns:
-
System
–The OpenMM system.
Source code in smee/converters/openmm/_openmm.py
convert_to_openmm_topology
#
convert_to_openmm_topology(
system: TensorSystem | TensorTopology,
) -> Topology
Convert a smee
system to an OpenMM topology.
Notes
Virtual sites are given the name "X{i}".
Parameters:
-
system
(TensorSystem | TensorTopology
) –The system to convert.
Returns:
-
Topology
–The OpenMM topology.
Source code in smee/converters/openmm/_openmm.py
ffxml_converter
#
A decorator used to flag a function as being able to convert a tensor potential of a given type and energy function to an OpenMM force field XML representation.
The decorated function should take a smee.TensorPotential
, and
the associated smee.ParameterMap
and list of atom types, and return a
xml.etree.ElementTree
representing the potential.