예제 #1
0
def rigid():
    R""" Groups particles that belong to rigid bodies.

    Creates a particle group from particles. All particles that belong to a rigid body will be added to the group.
    The group is always named 'rigid'.

    Examples::

        rigid = group.rigid()

    """
    hoomd.util.print_status_line()

    # check if initialization has occurred
    if not hoomd.init.is_initialized():
        hoomd.context.msg.error(
            "Cannot create a group before initialization\n")
        raise RuntimeError('Error creating group')

    # create the group
    name = 'rigid'
    selector = _hoomd.ParticleSelectorRigid(
        hoomd.context.current.system_definition, True)
    cpp_group = _hoomd.ParticleGroup(hoomd.context.current.system_definition,
                                     selector)

    # notify the user of the created group
    hoomd.context.msg.notice(
        2, 'Group "' + name + '" created containing ' +
        str(cpp_group.getNumMembersGlobal()) + ' particles\n')

    # return it in the wrapper class
    return group(name, cpp_group)
예제 #2
0
def nonrigid():
    R""" Groups particles that do not belong to rigid bodies.

    Creates a particle group from particles. All particles that **do not** belong to a rigid body will be added to
    the group. The group is always named 'nonrigid'.

    Examples::

        nonrigid = group.nonrigid()

    """

    # check if initialization has occurred
    if not hoomd.init.is_initialized():
        raise RuntimeError('Cannot create a group before initialization\n');

    # create the group
    name = 'nonrigid';
    selector = _hoomd.ParticleSelectorRigid(hoomd.context.current.system_definition, False);
    cpp_group = _hoomd.ParticleGroup(hoomd.context.current.system_definition, selector);

    # notify the user of the created group
    hoomd.context.current.device.cpp_msg.notice(2, 'Group "' + name + '" created containing ' + str(cpp_group.getNumMembersGlobal()) + ' particles\n');

    # return it in the wrapper class
    return group(name, cpp_group);