From d96c7086c0a5e0e28bcdae75aa0ef80aa7335b0f Mon Sep 17 00:00:00 2001 From: Mark Driver <mdd31@cam.ac.uk> Date: Wed, 19 Jul 2017 13:14:33 +0100 Subject: [PATCH] create method to calculate matrix. --- .../solvationcalculation/solvationcalculator.py | 10 ++++++++++ .../solvationcalculatortest.py | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/solventmapcreator/solvationcalculation/solvationcalculator.py b/solventmapcreator/solvationcalculation/solvationcalculator.py index 1ed157c..eba12c0 100644 --- a/solventmapcreator/solvationcalculation/solvationcalculator.py +++ b/solventmapcreator/solvationcalculation/solvationcalculator.py @@ -39,6 +39,16 @@ pairwise manner. As detailed in DOI: http://dx.doi.org/10.1039/c3sc22124e. """ EVDW = -5.6 +def calcluate_association_energy_matrix(epsilon_i_list, epsilon_j_list, temperature, theta, polynomial_coefficients): + """This iterates through and fills an array with all the solvation energies. + """ + association_matrix = np.zeros((len(epsilon_i_list), len(epsilon_j_list))) + for i in range(len(epsilon_i_list)): + for j in range(len(epsilon_j_list)): + association_energy = calculate_association_energy(epsilon_i_list[i], epsilon_j_list[j], temperature, theta, polynomial_coefficients) + association_matrix[i][j] = association_energy + return association_matrix + def calculate_association_energy(epsilon_i, epsilon_j, temperature, theta, polynomial_coefficients): """This calculates the energy described above """ diff --git a/solventmapcreator/test/solvationcalculationtest/solvationcalculatortest.py b/solventmapcreator/test/solvationcalculationtest/solvationcalculatortest.py index a479a06..e566d40 100644 --- a/solventmapcreator/test/solvationcalculationtest/solvationcalculatortest.py +++ b/solventmapcreator/test/solvationcalculationtest/solvationcalculatortest.py @@ -24,6 +24,12 @@ class SolvationCalculatorTestCase(unittest.TestCase): def tearDown(self): """tear down after tests. """ + def test_calcluate_association_energy_matrix(self): + """Test to see if expected matrix is produced. + """ + expected_array = np.array([[-1.2500649680700651]]) + actual_array = solvationcalculator.calcluate_association_energy_matrix([1.0],[1.0], 298.0, 1.0, np.array([0.5, 1.0])) + np.testing.assert_array_almost_equal(expected_array, actual_array) def test_calculate_association_energy(self): """Test to see if expected_value is returned. """ -- GitLab