diff --git a/vermouth/tests/test_apply_rubber_band.py b/vermouth/tests/test_apply_rubber_band.py index b7fa5cad1..17ab609e1 100644 --- a/vermouth/tests/test_apply_rubber_band.py +++ b/vermouth/tests/test_apply_rubber_band.py @@ -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()