diff --git a/pyMBE.py b/pyMBE.py index ad3172b..36cad88 100644 --- a/pyMBE.py +++ b/pyMBE.py @@ -1924,9 +1924,6 @@ def generate_random_points_in_a_sphere(self, center, radius, n_samples, on_surfa Returns: samples(`list`): Coordinates of the sample points inside the hypersphere. - - Note: - - Algorithm from: https://baezortega.github.io/2018/10/14/hypersphere-sampling/ """ # initial values center=np.array(center) diff --git a/testsuite/calculate_net_charge_unit_test.py b/testsuite/calculate_net_charge_unit_test.py index 3c373ae..a7af915 100644 --- a/testsuite/calculate_net_charge_unit_test.py +++ b/testsuite/calculate_net_charge_unit_test.py @@ -72,6 +72,7 @@ espresso_system=espresso_system, use_default_bond=True,) +# Check the case where the returned charge has a dimension charge_map=pmb.calculate_net_charge(molecule_name=molecule_name, espresso_system=espresso_system) @@ -91,6 +92,19 @@ 8: 0.0*pmb.units.Quantity(1,'reduced_charge'), 9: 0.0*pmb.units.Quantity(1,'reduced_charge')}) +# Check the case where the returned charge is dimensionless +charge_map=pmb.calculate_net_charge(molecule_name=molecule_name, + espresso_system=espresso_system, + dimensionless=True) + +# Check mean charge +np.testing.assert_equal(charge_map["mean"], 2.0) +# Check molecule charge map +np.testing.assert_equal(charge_map["molecules"],{0: 2.0, 1: 2.0}) +# Check residue charge map +np.testing.assert_equal(charge_map["residues"],{0: 1.0, 1: 1.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 1.0, 6: 1.0, 7: 0.0, 8: 0.0, 9: 0.0}) + + print("*** Unit test passed ***") print("*** Unit test: check that calculate_net_charge raises a ValueError if one provides the name of an object that is not a molecule ***") input_parameters={"molecule_name":"R1", diff --git a/testsuite/generate_coordinates_tests.py b/testsuite/generate_coordinates_tests.py index a7be98e..ccc2c1e 100644 --- a/testsuite/generate_coordinates_tests.py +++ b/testsuite/generate_coordinates_tests.py @@ -111,4 +111,21 @@ def test_arrays_less_equal(arr1, arr2, rtol=1e-7, atol=1e-7): test_arrays_less_equal(np.linalg.norm(samples-np.asarray(center), axis=1), outer_radius) test_arrays_less_equal(inner_radius, np.linalg.norm(samples-np.asarray(center), axis=1)) print("*** Unit test passed ***") +print("*** Check that the function raises a ValueError if the user provides a negative radius ***") +np.testing.assert_raises(ValueError, + pmb.generate_coordinates_outside_sphere, + center=center, + radius=-1.0, + max_dist=5.0, + n_samples=1) +print("*** Unit test passed ***") +print("*** Check that the function raises a ValueError if the user provides a larger inner radius than outer radius ***") +np.testing.assert_raises(ValueError, + pmb.generate_coordinates_outside_sphere, + center=center, + radius=10.0, + max_dist=5.0, + n_samples=1) +print("*** Unit test passed ***") + print("*** All unit tests passed ***\n")