diff --git a/pyMBE.py b/pyMBE.py index dece52c..6a1fc42 100644 --- a/pyMBE.py +++ b/pyMBE.py @@ -464,15 +464,18 @@ def check_dimensionality(self, variable, expected_dimensionality): Args: `variable`(`pint.Quantity`): Quantity to be checked. `expected_dimensionality(`str`): Expected dimension of the variable. - """ - try: - correct_dimensionality=variable.check(f"[{expected_dimensionality}]") - except: - raise ValueError(f"The variable {variable} should be a `pint.Quantity` object, instead the variable is {type(variable)}") - + Returns: + `bool`: `True` if the variable if of the expected dimensionality, `False` otherwise. + + Note: + - `expected_dimensionality` takes dimensionality following the Pint standards [docs](https://pint.readthedocs.io/en/0.10.1/wrapping.html?highlight=dimensionality#checking-dimensionality). + - For example, to check for a variable corresponding to a velocity `expected_dimensionality = "[length]/[time]"` + """ + correct_dimensionality=variable.check(f"{expected_dimensionality}") if not correct_dimensionality: raise ValueError(f"The variable {variable} should have a dimensionality of {expected_dimensionality}, instead the variable has a dimensionality of {variable.dimensionality}") + return correct_dimensionality def check_if_df_cell_has_a_value(self, index,key): """ @@ -2706,7 +2709,7 @@ def setup_lj_interactions(self, espresso_system, shift_potential=True, combining Args: espresso_system(`obj`): Instance of a system object from the espressomd library. shift_potential(`bool`, optional): If True, a shift will be automatically computed such that the potential is continuous at the cutoff radius. Otherwise, no shift will be applied. Defaults to True. - combining_rule(`string`, optional): combining rule used to calculate `sigma` and `epsilon` for the potential betwen a pair of particles. Defaults to 'Lorentz-Berthelot'. + combining_rule(`string`, optional): combining rule used to calculate `sigma` and `epsilon` for the potential between a pair of particles. Defaults to 'Lorentz-Berthelot'. warning(`bool`, optional): switch to activate/deactivate warning messages. Defaults to True. Note: @@ -2749,7 +2752,7 @@ def setup_lj_interactions(self, espresso_system, shift_potential=True, combining for ptype in type_pair: for key in lj_parameters_keys: lj_parameters[key].append(self.find_value_from_es_type(es_type=ptype, column_name=key)) - # If one of the particle has sigma=0, no LJ interations are setuo between that particle type and the others + # If one of the particle has sigma=0, no LJ interations are set up between that particle type and the others if not all([ sigma_value.magnitude for sigma_value in lj_parameters["sigma"]]): continue # Apply combining rule diff --git a/samples/Beyer2024/peptide.py b/samples/Beyer2024/peptide.py index 118ec7e..f02dd43 100644 --- a/samples/Beyer2024/peptide.py +++ b/samples/Beyer2024/peptide.py @@ -70,8 +70,8 @@ pmb.load_pka_set (filename='parameters/pka_sets/CRC1991.txt') model = '2beadAA' # Model with 2 beads per each aminoacid N_peptide_chains = 4 - sigma_Na=0.35*pmb.units.nm - sigma_Cl=0.35*pmb.units.nm + sigma_cation=0.35*pmb.units.nm + sigma_anion=0.35*pmb.units.nm c_salt=1e-2 * pmb.units.mol/ pmb.units.L chain_length=len(sequence)*2 @@ -81,8 +81,8 @@ model = '1beadAA' N_peptide_chains = 1 c_salt = 5e-3 * pmb.units.mol/ pmb.units.L - sigma_Na=0.2*pmb.units.nm - sigma_Cl=0.36*pmb.units.nm + sigma_cation=0.2*pmb.units.nm + sigma_anion=0.36*pmb.units.nm chain_length=len(sequence) # Simulation parameters @@ -101,7 +101,9 @@ raise RuntimeError() -pmb.define_peptide (name=sequence, sequence=sequence, model=model) +pmb.define_peptide (name=sequence, + sequence=sequence, + model=model) # Solution parameters cation_name = 'Na' @@ -110,12 +112,12 @@ pmb.define_particle(name=cation_name, q=1, - sigma=sigma_Na, + sigma=sigma_cation, epsilon=1*pmb.units('reduced_energy')) pmb.define_particle(name=anion_name, q=-1, - sigma=sigma_Cl, + sigma=sigma_anion, epsilon=1*pmb.units('reduced_energy')) # System parameters diff --git a/testsuite/lj_tests.py b/testsuite/lj_tests.py index 2245466..aebe443 100644 --- a/testsuite/lj_tests.py +++ b/testsuite/lj_tests.py @@ -157,7 +157,7 @@ verbose=True) print(f"*** Unit test passed ***") -print(f"*** Unit test: test that setup_lj_interactions does not setup any LJ interactions for particles with sigma = 0 ***") +print(f"*** Unit test: test that setup_lj_interactions does not set up any LJ interactions for particles with sigma = 0 ***") lj_labels=pmb.filter_df("LennardJones")["name"].values # Check that no interaction between particle C and any other particle has been set up