@@ -12,17 +12,19 @@ def __init__(self):
1212 """
1313 Initializes the class with relevant information.
1414
15- Args:
16- run_manager: Manager for universe and selection operations.
17- args: Argument namespace containing user parameters.
18- universe: MDAnalysis universe representing the simulation system.
19- data_logger: Logger for storing and exporting entropy data.
2015 """
2116 self ._molecule_groups = None
2217
2318 def grouping_molecules (self , universe , grouping ):
2419 """
2520 Grouping molecules by desired level of detail.
21+
22+ Args:
23+ universe: MDAnalysis univers object for the system of interest.
24+ grouping (str): how to group molecules for averaging
25+
26+ Returns:
27+ molecule_groups (dict): molecule indices for each group.
2628 """
2729
2830 molecule_groups = {}
@@ -33,11 +35,22 @@ def grouping_molecules(self, universe, grouping):
3335 if grouping == "molecules" :
3436 molecule_groups = self ._by_molecules (universe )
3537
38+ number_groups = len (molecule_groups )
39+
40+ logger .info (f"Number of molecule groups: { number_groups } " )
41+ logger .debug (f"Molecule groups are: { molecule_groups } " )
42+
3643 return molecule_groups
3744
3845 def _by_none (self , universe ):
3946 """
4047 Don't group molecules. Every molecule is in its own group.
48+
49+ Args:
50+ universe: MDAnalysis universe
51+
52+ Returns:
53+ molecule_groups (dict): molecule indices for each group.
4154 """
4255
4356 # fragments is MDAnalysis terminology for molecules
@@ -48,17 +61,18 @@ def _by_none(self, universe):
4861 for molecule_i in range (number_molecules ):
4962 molecule_groups [molecule_i ] = [molecule_i ]
5063
51- number_groups = len (molecule_groups )
52-
53- logger .info (f"Number of molecule groups: { number_groups } " )
54- logger .debug (f"Molecule groups are: { molecule_groups } " )
55-
5664 return molecule_groups
5765
5866 def _by_molecules (self , universe ):
5967 """
6068 Group molecules by chemical type.
6169 Based on number of atoms and atom names.
70+
71+ Args:
72+ universe: MDAnalysis universe
73+
74+ Returns:
75+ molecule_groups (dict): molecule indices for each group.
6276 """
6377
6478 # fragments is MDAnalysis terminology for molecules
@@ -75,6 +89,10 @@ def _by_molecules(self, universe):
7589 names_j = fragments [molecule_j ].names
7690 number_atoms_j = len (names_j )
7791
92+ # If molecule_i has the same number of atoms and same
93+ # atom names as molecule_j, then index i is added to group j
94+ # The index of molecule_j is the group key, the keys are
95+ # all integers, but may not be consecutive numbers.
7896 if number_atoms_i == number_atoms_j and (names_i == names_j ).all :
7997 if molecule_j in molecule_groups .keys ():
8098 molecule_groups [molecule_j ].append (molecule_i )
@@ -83,9 +101,4 @@ def _by_molecules(self, universe):
83101 molecule_groups [molecule_j ].append (molecule_i )
84102 break
85103
86- number_groups = len (molecule_groups )
87-
88- logger .info (f"Number of molecule groups: { number_groups } " )
89- logger .debug (f"Molecule groups are: { molecule_groups } " )
90-
91104 return molecule_groups
0 commit comments