diff --git a/mbuild/lattice.py b/mbuild/lattice.py index 791ba0aed..b2a85fbe1 100644 --- a/mbuild/lattice.py +++ b/mbuild/lattice.py @@ -625,6 +625,7 @@ def populate(self, compound_dict=None, x=1, y=1, z=1): ret_lattice = mb.Compound() # Create (clone) a mb.Compound for the newly generate positions + compoundsList = [] # particles to add at the end elementsSet = set() if compound_dict is None: for key_id, all_pos in cell.items(): @@ -641,7 +642,7 @@ def populate(self, compound_dict=None, x=1, y=1, z=1): for pos in all_pos: particle_to_add = mb.clone(particle) particle_to_add.translate_to(list(pos)) - ret_lattice.add(particle_to_add) + compoundsList.append(particle_to_add) else: for key_id, all_pos in cell.items(): if isinstance(compound_dict[key_id], mb.Compound): @@ -649,7 +650,7 @@ def populate(self, compound_dict=None, x=1, y=1, z=1): for pos in all_pos: tmp_comp = mb.clone(compound_to_move) tmp_comp.translate_to(list(pos)) - ret_lattice.add(tmp_comp) + compoundsList.append(tmp_comp) else: err_type = type(compound_dict.get(key_id)) raise TypeError( @@ -661,7 +662,7 @@ def populate(self, compound_dict=None, x=1, y=1, z=1): warnings.warn( f"Element assumed from cif file to be {element}.", UserWarning ) - + ret_lattice.add(compoundsList) # Create mbuild.box ret_lattice.box = mb.Box( lengths=[a * x, b * y, c * z], angles=self.angles