pylammps: use library API to return available groups
This commit is contained in:
@ -686,9 +686,7 @@ class PyLammps(object):
|
|||||||
:getter: Returns a list of atom groups that are currently active in this LAMMPS instance
|
:getter: Returns a list of atom groups that are currently active in this LAMMPS instance
|
||||||
:type: list
|
:type: list
|
||||||
"""
|
"""
|
||||||
output = self.lmp_info("groups")
|
return self.lmp.available_ids("group")
|
||||||
output = output[output.index("Group information:")+1:]
|
|
||||||
return self._parse_groups(output)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def variables(self):
|
def variables(self):
|
||||||
@ -802,16 +800,6 @@ class PyLammps(object):
|
|||||||
elements.append(element)
|
elements.append(element)
|
||||||
return elements
|
return elements
|
||||||
|
|
||||||
def _parse_groups(self, output):
|
|
||||||
groups = []
|
|
||||||
group_pattern = re.compile(r"(?P<name>.+) \((?P<type>.+)\)")
|
|
||||||
|
|
||||||
for line in output:
|
|
||||||
m = group_pattern.match(line.split(':')[1].strip())
|
|
||||||
group = {'name': m.group('name'), 'type': m.group('type')}
|
|
||||||
groups.append(group)
|
|
||||||
return groups
|
|
||||||
|
|
||||||
def lmp_print(self, s):
|
def lmp_print(self, s):
|
||||||
""" needed for Python2 compatibility, since print is a reserved keyword """
|
""" needed for Python2 compatibility, since print is a reserved keyword """
|
||||||
return self.__getattr__("print")(s)
|
return self.__getattr__("print")(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user