-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
466bff3
commit 4184b6c
Showing
4 changed files
with
122 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,34 @@ | ||
import openff.interchange.models | ||
import openff.units | ||
import copy | ||
|
||
import openmm.unit | ||
import pytest | ||
import torch | ||
|
||
import smee.potentials | ||
import smee.mm | ||
import smee.tests.utils | ||
import smee.utils | ||
|
||
|
||
@pytest.fixture() | ||
def mock_lj_potential() -> smee.TensorPotential: | ||
return smee.TensorPotential( | ||
type="vdW", | ||
fn="LJ", | ||
parameters=torch.tensor([[0.1, 1.1], [0.2, 2.1], [0.3, 3.1]]), | ||
parameter_keys=[ | ||
openff.interchange.models.PotentialKey(id="[#1:1]"), | ||
openff.interchange.models.PotentialKey(id="[#6:1]"), | ||
openff.interchange.models.PotentialKey(id="[#8:1]"), | ||
], | ||
parameter_cols=("epsilon", "sigma"), | ||
parameter_units=( | ||
openff.units.unit.kilojoule_per_mole, | ||
openff.units.unit.angstrom, | ||
), | ||
attributes=torch.tensor([0.0, 0.0, 0.5, 1.0, 9.0, 2.0]), | ||
attribute_cols=( | ||
"scale_12", | ||
"scale_13", | ||
"scale_14", | ||
"scale_15", | ||
"cutoff", | ||
"switch_width", | ||
), | ||
attribute_units=( | ||
openff.units.unit.dimensionless, | ||
openff.units.unit.dimensionless, | ||
openff.units.unit.dimensionless, | ||
openff.units.unit.dimensionless, | ||
openff.units.unit.angstrom, | ||
openff.units.unit.angstrom, | ||
@pytest.fixture(scope="module") | ||
def _etoh_water_system() -> ( | ||
tuple[smee.TensorSystem, smee.TensorForceField, torch.Tensor, torch.Tensor] | ||
): | ||
system, force_field = smee.tests.utils.system_from_smiles(["CCO", "O"], [67, 123]) | ||
coords, box_vectors = smee.mm.generate_system_coords(system) | ||
|
||
return ( | ||
system, | ||
force_field, | ||
torch.tensor(coords.value_in_unit(openmm.unit.angstrom), dtype=torch.float32), | ||
torch.tensor( | ||
box_vectors.value_in_unit(openmm.unit.angstrom), dtype=torch.float32 | ||
), | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def mock_methane_top() -> smee.TensorTopology: | ||
methane_top = smee.tests.utils.topology_from_smiles("C") | ||
methane_top.parameters = { | ||
"vdW": smee.NonbondedParameterMap( | ||
assignment_matrix=torch.tensor( | ||
[ | ||
[0.0, 1.0, 0.0], | ||
[1.0, 0.0, 0.0], | ||
[1.0, 0.0, 0.0], | ||
[1.0, 0.0, 0.0], | ||
[1.0, 0.0, 0.0], | ||
] | ||
).to_sparse(), | ||
exclusions=torch.tensor( | ||
[ | ||
[0, 1], | ||
[0, 2], | ||
[0, 3], | ||
[0, 4], | ||
[1, 2], | ||
[1, 3], | ||
[1, 4], | ||
[2, 3], | ||
[2, 4], | ||
[3, 4], | ||
] | ||
), | ||
exclusion_scale_idxs=torch.tensor([[0] * 4 + [1] * 6]), | ||
) | ||
} | ||
return methane_top | ||
|
||
def etoh_water_system( | ||
_etoh_water_system, | ||
) -> tuple[smee.TensorSystem, smee.TensorForceField, torch.Tensor, torch.Tensor]: | ||
"""Creates a system of ethanol and water.""" | ||
|
||
@pytest.fixture() | ||
def mock_water_top() -> smee.TensorTopology: | ||
methane_top = smee.tests.utils.topology_from_smiles("O") | ||
methane_top.parameters = { | ||
"vdW": smee.NonbondedParameterMap( | ||
assignment_matrix=torch.tensor( | ||
[ | ||
[0.0, 0.0, 1.0], | ||
[1.0, 0.0, 0.0], | ||
[1.0, 0.0, 0.0], | ||
] | ||
).to_sparse(), | ||
exclusions=torch.tensor([[0, 1], [0, 2], [1, 2]]), | ||
exclusion_scale_idxs=torch.tensor([[0], [0], [1]]), | ||
) | ||
} | ||
return methane_top | ||
return copy.deepcopy(_etoh_water_system) |
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