openff
#
Tensor representations of SMIRNOFF force fields.
Modules:
-
nonbonded
–Convert SMIRNOFF non-bonded parameters into tensors.
-
valence
–Convert SMIRNOFF valence parameters into tensors.
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_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.