Пример #1
0
 def __init__(self,
              origin=(0.0, 0.0, 0.0),
              normal=(0.0, 0.0, 1.0),
              inside=True):
     self._origin = hoomd.make_scalar3(*origin)
     self._normal = hoomd.make_scalar3(*normal)
     self.inside = inside
Пример #2
0
    def set_params(self, fx, fy, fz, xmin, xmax, ymin, ymax, zmin, zmax):
        self.check_initialization()

        f = hoomd.make_scalar3(fx, fy, fz)
        min = hoomd.make_scalar3(xmin, ymin, zmin)
        max = hoomd.make_scalar3(xmax, ymax, zmax)

        self.cpp_force.setParams(f, min, max)
Пример #3
0
    def __init__(self,
                 r=None,
                 rx=None,
                 ry=None,
                 rz=None,
                 P=hoomd.make_scalar3(0, 0, 0),
                 group=None):
        util.print_status_line()
        period = 1

        # Error out in MPI simulations
        if (hoomd.is_MPI_available()):
            if globals.system_definition.getParticleData(
            ).getDomainDecomposition():
                globals.msg.error(
                    "constrain.ellipsoid is not supported in multi-processor simulations.\n\n"
                )
                raise RuntimeError("Error initializing updater.")

        # Error out if no radii are set
        if (r is None and rx is None and ry is None and rz is None):
            globals.msg.error(
                "no radii were defined in update.constraint_ellipsoid.\n\n")
            raise RuntimeError("Error initializing updater.")

        # initialize the base class
        _updater.__init__(self)

        # Set parameters
        P = hoomd.make_scalar3(P[0], P[1], P[2])
        if (r is not None): rx = ry = rz = r

        # create the c++ mirror class
        if not globals.exec_conf.isCUDAEnabled():
            if (group is not None):
                self.cpp_updater = hoomd.ConstraintEllipsoid(
                    globals.system_definition, group.cpp_group, P, rx, ry, rz)
            else:
                self.cpp_updater = hoomd.ConstraintEllipsoid(
                    globals.system_definition, globals.group_all.cpp_group, P,
                    rx, ry, rz)
        else:
            if (group is not None):
                self.cpp_updater = hoomd.ConstraintEllipsoidGPU(
                    globals.system_definition, group.cpp_group, P, rx, ry, rz)
            else:
                self.cpp_updater = hoomd.ConstraintEllipsoidGPU(
                    globals.system_definition, globals.group_all.cpp_group, P,
                    rx, ry, rz)
        self.setupUpdater(period)

        # store metadata
        self.group = group
        self.P = P
        self.rx = rx
        self.ry = ry
        self.rz = rz
        self.metadata_fields = ['group', 'P', 'rx', 'ry', 'rz']
Пример #4
0
 def __init__(self,
              r=0.0,
              origin=(0.0, 0.0, 0.0),
              axis=(0.0, 0.0, 1.0),
              inside=True):
     self.r = r
     self._origin = hoomd.make_scalar3(*origin)
     self._axis = hoomd.make_scalar3(*axis)
     self.inside = inside
Пример #5
0
    def __init__(self, group, P, r):
        util.print_status_line()

        # Error out in MPI simulations
        if (hoomd.is_MPI_available()):
            if globals.system_definition.getParticleData(
            ).getDomainDecomposition():
                globals.msg.error(
                    "constrain.sphere is not supported in multi-processor simulations.\n\n"
                )
                raise RuntimeError("Error initializing constraint force.")

        # initialize the base class
        _constraint_force.__init__(self)

        # create the c++ mirror class
        P = hoomd.make_scalar3(P[0], P[1], P[2])
        if not globals.exec_conf.isCUDAEnabled():
            self.cpp_force = hoomd.ConstraintSphere(globals.system_definition,
                                                    group.cpp_group, P, r)
        else:
            self.cpp_force = hoomd.ConstraintSphereGPU(
                globals.system_definition, group.cpp_group, P, r)

        globals.system.addCompute(self.cpp_force, self.force_name)

        # store metadata
        self.group = group
        self.P = P
        self.r = r
        self.metadata_fields = ['group', 'P', 'r']
Пример #6
0
    def __init__(self, group, P, r):
        util.print_status_line();

        # Error out in MPI simulations
        if (hoomd.is_MPI_available()):
            if globals.system_definition.getParticleData().getDomainDecomposition():
                globals.msg.error("constrain.sphere is not supported in multi-processor simulations.\n\n")
                raise RuntimeError("Error initializing constraint force.")

        # initialize the base class
        _constraint_force.__init__(self);

        # create the c++ mirror class
        P = hoomd.make_scalar3(P[0], P[1], P[2]);
        if not globals.exec_conf.isCUDAEnabled():
            self.cpp_force = hoomd.ConstraintSphere(globals.system_definition, group.cpp_group, P, r);
        else:
            self.cpp_force = hoomd.ConstraintSphereGPU(globals.system_definition, group.cpp_group, P, r);

        globals.system.addCompute(self.cpp_force, self.force_name);

        # store metadata
        self.group = group
        self.P = P
        self.r = r
        self.metadata_fields = ['group','P', 'r']
Пример #7
0
    def __init__(self,
                 fx=None,
                 fy=None,
                 fz=None,
                 xmin=None,
                 xmax=None,
                 ymin=None,
                 ymax=None,
                 zmin=None,
                 zmax=None):
        util.print_status_line()

        # initialize the base class
        _force.__init__(self)

        # handle the optional arguments
        box = globals.system_definition.getParticleData().getBox()
        if xmin is None:
            xmin = box.xlo - 0.5
        if xmax is None:
            xmax = box.xhi + 0.5
        if ymin is None:
            ymin = box.ylo - 0.5
        if ymax is None:
            ymax = box.yhi + 0.5
        if zmin is None:
            zmin = box.zlo - 0.5
        if zmax is None:
            zmax = box.zhi + 0.5

        f = hoomd.make_scalar3(fx, fy, fz)
        min = hoomd.make_scalar3(xmin, ymin, zmin)
        max = hoomd.make_scalar3(xmax, ymax, zmax)

        # initialize the reflected c++ class
        if not globals.exec_conf.isCUDAEnabled():
            self.cpp_force = _cuboid_force_plugin.CuboidForceCompute(
                globals.system_definition, f, min, max)
        else:
            self.cpp_force = _cuboid_force_plugin.CuboidForceComputeGPU(
                globals.system_definition, f, min, max)

        globals.system.addCompute(self.cpp_force, self.force_name)
Пример #8
0
    def __init__(self, group, P, r):
        util.print_status_line();
        
        # initialize the base class
        _constraint_force.__init__(self);
        
        # create the c++ mirror class
        P = hoomd.make_scalar3(P[0], P[1], P[2]);
        if not globals.exec_conf.isCUDAEnabled():
            self.cpp_force = hoomd.ConstraintSphere(globals.system_definition, group.cpp_group, P, r);
        else:
            self.cpp_force = hoomd.ConstraintSphereGPU(globals.system_definition, group.cpp_group, P, r);

        globals.system.addCompute(self.cpp_force, self.force_name);
Пример #9
0
    def process_coeff(self, coeff):
        es = coeff['es']
        n = coeff['n']
        roff = coeff['roff']

        return hoomd.make_scalar3(es, n, roff)
Пример #10
0
 def process_field_coeff(self, field):
     return hoomd.make_scalar3(field[0], field[1], field[2])
Пример #11
0
    def __init__(
        self,
        seed,
        f_lst,
        orientation_link=True,
        rotation_diff=0,
        constraint=None,
        group=None,
    ):
        util.print_status_line()

        # initialize the base class
        _force.__init__(self)

        # input check
        if (f_lst is not None):
            for element in f_lst:
                if type(element) != tuple or len(element) != 3:
                    raise RuntimeError(
                        "Active force passed in should be a list of 3-tuples (fx, fy, fz)"
                    )

        # assign constraints
        if (constraint is not None):
            if (constraint.__class__.__name__ is "constraint_ellipsoid"):
                P = constraint.P
                rx = constraint.rx
                ry = constraint.ry
                rz = constraint.rz
            else:
                raise RuntimeError(
                    "Active force constraint is not accepted (currently only accepts ellipsoids)"
                )
        else:
            P = hoomd.make_scalar3(0, 0, 0)
            rx = 0
            ry = 0
            rz = 0

        # create the c++ mirror class
        if not globals.exec_conf.isCUDAEnabled():
            if (group is not None):
                self.cpp_force = hoomd.ActiveForceCompute(
                    globals.system_definition, group.cpp_group, seed, f_lst,
                    orientation_link, rotation_diff, P, rx, ry, rz)
            else:
                self.cpp_force = hoomd.ActiveForceCompute(
                    globals.system_definition, globals.group_all.cpp_group,
                    seed, f_lst, orientation_link, rotation_diff, P, rx, ry,
                    rz)

        else:
            if (group is not None):
                self.cpp_force = hoomd.ActiveForceComputeGPU(
                    globals.system_definition, group.cpp_group, seed, f_lst,
                    orientation_link, rotation_diff, P, rx, ry, rz)
            else:
                self.cpp_force = hoomd.ActiveForceComputeGPU(
                    globals.system_definition, globals.group_all.cpp_group,
                    seed, f_lst, orientation_link, rotation_diff, P, rx, ry,
                    rz)

        # store metadata
        self.metdata_fields = [
            'group', 'seed', 'orientation_link', 'rotation_diff', 'constraint'
        ]
        self.group = group
        self.seed = seed
        self.orientation_link = orientation_link
        self.rotation_diff = rotation_diff
        self.constraint = constraint

        globals.system.addCompute(self.cpp_force, self.force_name)
Пример #12
0
 def normal(self, normal):
     self._normal = hoomd.make_scalar3(*normal)
Пример #13
0
 def origin(self, origin):
     self._origin = hoomd.make_scalar3(*origin)
Пример #14
0
 def axis(self, axis):
     self._axis = hoomd.make_scalar3(*axis)
Пример #15
0
 def process_coeff(self, coeff):
     k = coeff['k']
     r0 = coeff['r0']
     roff = coeff['roff']
     return hoomd.make_scalar3(k, r0, roff)
Пример #16
0
 def process_field_coeff(self, field):
     return hoomd.make_scalar3(field[0],field[1],field[2])