Esempio n. 1
0
    def __init__(
        self,
        fx=None,
        fy=None,
        fz=None,
        fvec=None,
        tvec=None,
        group=None,
        callback=None,
    ):

        if (fx is not None) and (fy is not None) and (fz is not None):
            self.fvec = (fx, fy, fz)
        elif fvec is not None:
            self.fvec = fvec
        else:
            self.fvec = (0, 0, 0)

        if tvec is not None:
            self.tvec = tvec
        else:
            self.tvec = (0, 0, 0)

        if (self.fvec == (0, 0, 0)) and (
            self.tvec == (0, 0, 0) and callback is None
        ):
            hoomd.context.current.device.cpp_msg.warning(
                "The constant force specified has no non-zero components\n"
            )

        # initialize the base class
        Force.__init__(self)

        # create the c++ mirror class
        if group is not None:
            self.cppForce = _hoomd.ConstForceCompute(
                hoomd.context.current.system_definition,
                group.cpp_group,
                self.fvec[0],
                self.fvec[1],
                self.fvec[2],
                self.tvec[0],
                self.tvec[1],
                self.tvec[2],
            )
        else:
            self.cppForce = _hoomd.ConstForceCompute(
                hoomd.context.current.system_definition,
                self.fvec[0],
                self.fvec[1],
                self.fvec[2],
                self.tvec[0],
                self.tvec[1],
                self.tvec[2],
            )

        if callback is not None:
            self.cppForce.setCallback(callback)

        hoomd.context.current.system.addCompute(self.cppForce, self.force_name)
Esempio n. 2
0
    def __init__(self, fx, fy, fz, group=None):
        hoomd.util.print_status_line()

        # initialize the base class
        _force.__init__(self)

        # create the c++ mirror class
        if (group is not None):
            self.cpp_force = _hoomd.ConstForceCompute(
                hoomd.context.current.system_definition, group.cpp_group, fx,
                fy, fz)
        else:
            self.cpp_force = _hoomd.ConstForceCompute(
                hoomd.context.current.system_definition,
                hoomd.context.current.group_all.cpp_group, fx, fy, fz)

        # store metadata
        self.metadata_fields = ['fx', 'fy', 'fz']
        self.fx = fx
        self.fy = fy
        self.fz = fz
        if group is not None:
            self.metadata_fields.append('group')
            self.group = group

        hoomd.context.current.system.addCompute(self.cpp_force,
                                                self.force_name)
Esempio n. 3
0
    def __init__(self,
                 fx=None,
                 fy=None,
                 fz=None,
                 fvec=None,
                 tvec=None,
                 group=None,
                 callback=None):
        hoomd.util.print_status_line()

        if (fx is not None) and (fy is not None) and (fz is not None):
            self.fvec = (fx, fy, fz)
        elif (fvec is not None):
            self.fvec = fvec
        else:
            self.fvec = (0, 0, 0)

        if (tvec is not None):
            self.tvec = tvec
        else:
            self.tvec = (0, 0, 0)

        if (self.fvec == (0, 0, 0)) and (self.tvec == (0, 0, 0)
                                         and callback is None):
            hoomd.context.msg.warning(
                "The constant force specified has no non-zero components\n")

        # initialize the base class
        _force.__init__(self)

        # create the c++ mirror class
        if (group is not None):
            self.cpp_force = _hoomd.ConstForceCompute(
                hoomd.context.current.system_definition, group.cpp_group,
                self.fvec[0], self.fvec[1], self.fvec[2], self.tvec[0],
                self.tvec[1], self.tvec[2])
        else:
            self.cpp_force = _hoomd.ConstForceCompute(
                hoomd.context.current.system_definition, self.fvec[0],
                self.fvec[1], self.fvec[2], self.tvec[0], self.tvec[1],
                self.tvec[2])

        if callback is not None:
            self.cpp_force.setCallback(callback)

        # store metadata
        self.metadata_fields = ['fvec', 'tvec']
        if group is not None:
            self.metadata_fields.append('group')
            self.group = group

        hoomd.context.current.system.addCompute(self.cpp_force,
                                                self.force_name)