def tags(tag_min, tag_max=None, name=None): util.print_status_line() # check if initialization has occurred if not init.is_initialized(): globals.msg.error("Cannot create a group before initialization\n") raise RuntimeError('Error creating group') # handle the optional argument if tag_max is not None: if name is None: name = 'tags ' + str(tag_min) + '-' + str(tag_max) else: # if the option is not specified, tag_max is set equal to tag_min to include only that particle in the range # and the name is chosen accordingly tag_max = tag_min if name is None: name = 'tag ' + str(tag_min) # create the group selector = hoomd.ParticleSelectorTag(globals.system_definition, tag_min, tag_max) cpp_group = hoomd.ParticleGroup(globals.system_definition, selector) # notify the user of the created group globals.msg.notice( 2, 'Group "' + name + '" created containing ' + str(cpp_group.getNumMembersGlobal()) + ' particles\n') # return it in the wrapper class return group(name, cpp_group)
def all(): util.print_status_line() # check if initialization has occurred if not init.is_initialized(): globals.msg.error("Cannot create a group before initialization\n") raise RuntimeError('Error creating group') name = 'all' # the all group is special: when the first one is created, it is cached in globals and future calls to group.all() # return the cached version if globals.group_all is not None: expected_N = globals.system_definition.getParticleData().getNGlobal() if len(globals.group_all) != expected_N: # update group_all tag_min = 0 tag_max = globals.system_definition.getParticleData().getNGlobal( ) - 1 selector = hoomd.ParticleSelectorTag(globals.system_definition, tag_min, tag_max) globals.group_all.cpp_group.updateMemberTags(selector) globals.msg.notice( 2, 'Group "' + name + '" updated containing ' + str(globals.group_all.cpp_group.getNumMembersGlobal()) + ' particles\n') return globals.group_all # choose the tag range tag_min = 0 tag_max = globals.system_definition.getParticleData().getNGlobal() - 1 # create the group selector = hoomd.ParticleSelectorTag(globals.system_definition, tag_min, tag_max) cpp_group = hoomd.ParticleGroup(globals.system_definition, selector) # notify the user of the created group globals.msg.notice( 2, 'Group "' + name + '" created containing ' + str(cpp_group.getNumMembersGlobal()) + ' particles\n') # cache it and then return it in the wrapper class globals.group_all = group(name, cpp_group) return globals.group_all