Skip to content

Commit

Permalink
added tests for rubber band application
Browse files Browse the repository at this point in the history
  • Loading branch information
csbrasnett committed Nov 1, 2023
1 parent bcf4699 commit 99c0452
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions vermouth/tests/test_apply_rubber_band.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,38 @@ def test_bail_out_on_nan(caplog, test_molecule):
assert record.getMessage() == required_warning
assert len(caplog.records) == 1
assert test_molecule.interactions['bonds'] == []


@pytest.mark.parametrize('lower_bound, upper_bound, decay_factor, decay_power, base_constant, minimum_force, expected_output',
([1, 2, 0, 0, 500, 400, np.array([[ 0,500,500, 0],
[500, 0,500,500],
[500,500, 0,500],
[ 0,500,500,500]])], # no decays, return the base constant within the bounds
[1, 2, 0, 0, 500, 600, np.array([[ 0, 0, 0, 0],
[ 0, 0, 0, 0],
[ 0, 0, 0, 0],
[ 0, 0, 0, 0]])], # all forces less than the minumum force
[1, 0.5, 0, 0, 500, 600, np.array([[ 0, 0, 0, 0],
[ 0, 0, 0, 0],
[ 0, 0, 0, 0],
[ 0, 0, 0, 0]])], # all distances larger than the upper bound
[4, 2, 0, 0, 500, 600, np.array([[ 0, 0, 0, 0],
[ 0, 0, 0, 0],
[ 0, 0, 0, 0],
[ 0, 0, 0, 0]])], # all distances less than the lower bound
)
)
def test_compute_force_constants(lower_bound, upper_bound, decay_factor, decay_power, base_constant, minimum_force, expected_output):
# Define the constant distance_matrix for the test cases
distance_matrix = np.array([[0, 1, 2, 3],
[1, 0, 1, 2],
[2, 1, 0, 1],
[3, 2, 1, 0]])

# Call the compute_force_constants function with the constant distance_matrix and varied parameters
result = vermouth.processors.apply_rubber_band.compute_force_constants(distance_matrix, lower_bound, upper_bound,
decay_factor, decay_power, base_constant,
minimum_force)

# Assert the result against the expected output
assert result.all() == expected_output.all()

0 comments on commit 99c0452

Please sign in to comment.