Exemplo n.º 1
0
    def __init__(self, r_buff=0.4, check_period=1, d_max=None, dist_check=True, name=None, deterministic=False):

        nlist.__init__(self)

        if name is None:
            self.name = "cell_nlist_%d" % cell.cur_id
            cell.cur_id += 1
        else:
            self.name = name

        # create the C++ mirror class
        if not hoomd.context.current.device.cpp_exec_conf.isCUDAEnabled():
            self.cpp_cl = _hoomd.CellList(hoomd.context.current.system_definition)
            hoomd.context.current.system.addCompute(self.cpp_cl , self.name + "_cl")
            self.cpp_nlist = _md.NeighborListBinned(hoomd.context.current.system_definition, 0.0, r_buff, self.cpp_cl )
        else:
            self.cpp_cl  = _hoomd.CellListGPU(hoomd.context.current.system_definition)
            hoomd.context.current.system.addCompute(self.cpp_cl , self.name + "_cl")
            self.cpp_nlist = _md.NeighborListGPUBinned(hoomd.context.current.system_definition, 0.0, r_buff, self.cpp_cl )

        self.cpp_nlist.setEvery(check_period, dist_check)

        hoomd.context.current.system.addCompute(self.cpp_nlist, self.name)
        self.cpp_cl.setSortCellList(deterministic)

        # register this neighbor list with the context
        hoomd.context.current.neighbor_lists += [self]

        # save the user defined parameters
        self.set_params(r_buff, check_period, d_max, dist_check)
Exemplo n.º 2
0
    def __init__(self, r_buff=0.4, check_period=1, d_max=None, dist_check=True, cell_width=None, name=None, deterministic=False):
        hoomd.util.print_status_line()

        # register the citation
        c = hoomd.cite.article(cite_key='howard2016',
                         author=['M P Howard', 'J A Anderson', 'A Nikoubashman', 'S C Glotzer', 'A Z Panagiotopoulos'],
                         title='Efficient neighbor list calculation for molecular simulation of colloidal systems using graphics processing units',
                         journal='Computer Physics Communications',
                         volume=203,
                         pages='45--52',
                         month='Mar',
                         year='2016',
                         doi='10.1016/j.cpc.2016.02.003',
                         feature='stenciled neighbor lists')
        hoomd.cite._ensure_global_bib().add(c)

        nlist.__init__(self)

        if name is None:
            self.name = "stencil_nlist_%d" % stencil.cur_id
            stencil.cur_id += 1
        else:
            self.name = name

        # create the C++ mirror class
        if not hoomd.context.exec_conf.isCUDAEnabled():
            self.cpp_cl = _hoomd.CellList(hoomd.context.current.system_definition)
            hoomd.context.current.system.addCompute(self.cpp_cl , self.name + "_cl")
            cls = _hoomd.CellListStencil(hoomd.context.current.system_definition, self.cpp_cl)
            hoomd.context.current.system.addCompute(cls, self.name + "_cls")
            self.cpp_nlist = _md.NeighborListStencil(hoomd.context.current.system_definition, 0.0, r_buff, self.cpp_cl, cls)
        else:
            self.cpp_cl  = _hoomd.CellListGPU(hoomd.context.current.system_definition)
            hoomd.context.current.system.addCompute(self.cpp_cl , self.name + "_cl")
            cls = _hoomd.CellListStencil(hoomd.context.current.system_definition, self.cpp_cl)
            hoomd.context.current.system.addCompute(cls, self.name + "_cls")
            self.cpp_nlist = _md.NeighborListGPUStencil(hoomd.context.current.system_definition, 0.0, r_buff, self.cpp_cl, cls)

        self.cpp_nlist.setEvery(check_period, dist_check)

        hoomd.context.current.system.addCompute(self.cpp_nlist, self.name)
        self.cpp_cl.setSortCellList(deterministic)

        # register this neighbor list with the context
        hoomd.context.current.neighbor_lists += [self]

        # save the user defined parameters
        hoomd.util.quiet_status()
        self.set_params(r_buff, check_period, d_max, dist_check)
        self.set_cell_width(cell_width)
        hoomd.util.unquiet_status()
Exemplo n.º 3
0
    def _attach(self):
        integrator = self._simulation.operations.integrator
        if not isinstance(integrator, integrate.HPMCIntegrator):
            raise RuntimeError("The integrator must be an HPMC integrator.")

        # Extract 'Shape' from '<hoomd.hpmc.integrate.Shape object>'
        integrator_name = integrator.__class__.__name__
        try:
            if isinstance(self._simulation.device, hoomd.device.CPU):
                cpp_cls = getattr(_hpmc, 'ComputeFreeVolume' + integrator_name)
            else:
                cpp_cls = getattr(
                    _hpmc, 'ComputeFreeVolume' + integrator_name + 'GPU')
        except AttributeError:
            raise RuntimeError("Unsupported integrator.")

        cl = _hoomd.CellList(self._simulation.state._cpp_sys_def)
        self._cpp_obj = cpp_cls(self._simulation.state._cpp_sys_def,
                                integrator._cpp_obj, cl)

        super()._attach()
Exemplo n.º 4
0
    def __init__(self, mc, seed, suffix='', test_type=None, nsample=None):

        # initialize base class
        _compute.__init__(self);

        # create the c++ mirror class
        cl = _hoomd.CellList(hoomd.context.current.system_definition);
        hoomd.context.current.system.addCompute(cl, "auto_cl3")

        cls = None;
        if not hoomd.context.current.device.cpp_exec_conf.isCUDAEnabled():
            if isinstance(mc, integrate.sphere):
                cls = _hpmc.ComputeFreeVolumeSphere;
            elif isinstance(mc, integrate.convex_polygon):
                cls = _hpmc.ComputeFreeVolumeConvexPolygon;
            elif isinstance(mc, integrate.simple_polygon):
                cls = _hpmc.ComputeFreeVolumeSimplePolygon;
            elif isinstance(mc, integrate.convex_polyhedron):
                cls = _hpmc.ComputeFreeVolumeConvexPolyhedron;
            elif isinstance(mc, integrate.convex_spheropolyhedron):
                cls = _hpmc.ComputeFreeVolumeSpheropolyhedron;
            elif isinstance(mc, integrate.ellipsoid):
                cls = _hpmc.ComputeFreeVolumeEllipsoid;
            elif isinstance(mc, integrate.convex_spheropolygon):
                cls =_hpmc.ComputeFreeVolumeSpheropolygon;
            elif isinstance(mc, integrate.faceted_ellipsoid):
                cls =_hpmc.ComputeFreeVolumeFacetedEllipsoid;
            elif isinstance(mc, integrate.polyhedron):
                cls =_hpmc.ComputeFreeVolumePolyhedron;
            elif isinstance(mc, integrate.sphinx):
                cls =_hpmc.ComputeFreeVolumeSphinx;
            elif isinstance(mc, integrate.convex_spheropolyhedron_union):
                cls = _hpmc.ComputeFreeVolumeConvexPolyhedronUnion
            elif isinstance(mc, integrate.faceted_ellipsoid_union):
                cls = _hpmc.ComputeFreeVolumeFacetedEllipsoidUnion
            elif isinstance(mc, integrate.sphere_union):
                cls = _hpmc.ComputeFreeVolumeSphereUnion;
            else:
                hoomd.context.current.device.cpp_msg.error("compute.free_volume: Unsupported integrator.\n");
                raise RuntimeError("Error initializing compute.free_volume");
        else:
            if isinstance(mc, integrate.sphere):
                cls = _hpmc.ComputeFreeVolumeGPUSphere;
            elif isinstance(mc, integrate.convex_polygon):
                cls = _hpmc.ComputeFreeVolumeGPUConvexPolygon;
            elif isinstance(mc, integrate.simple_polygon):
                cls = _hpmc.ComputeFreeVolumeGPUSimplePolygon;
            elif isinstance(mc, integrate.convex_polyhedron):
                cls = _hpmc.ComputeFreeVolumeGPUConvexPolyhedron;
            elif isinstance(mc, integrate.convex_spheropolyhedron):
                cls = _hpmc.ComputeFreeVolumeGPUSpheropolyhedron;
            elif isinstance(mc, integrate.ellipsoid):
                cls = _hpmc.ComputeFreeVolumeGPUEllipsoid;
            elif isinstance(mc, integrate.convex_spheropolygon):
                cls =_hpmc.ComputeFreeVolumeGPUSpheropolygon;
            elif isinstance(mc, integrate.faceted_ellipsoid):
                cls =_hpmc.ComputeFreeVolumeGPUFacetedEllipsoid;
            elif isinstance(mc, integrate.polyhedron):
                cls =_hpmc.ComputeFreeVolumeGPUPolyhedron;
            elif isinstance(mc, integrate.sphinx):
                cls =_hpmc.ComputeFreeVolumeGPUSphinx;
            elif isinstance(mc, integrate.sphere_union):
                cls = _hpmc.ComputeFreeVolumeGPUSphereUnion;
            elif isinstance(mc, integrate.faceted_ellipsoid_union):
                cls = _hpmc.ComputeFreeVolumeGPUFacetedEllipsoidUnion;
            elif isinstance(mc, integrate.convex_spheropolyhedron_union):
                cls = _hpmc.ComputeFreeVolumeGPUConvexPolyhedronUnion;
            else:
                hoomd.context.current.device.cpp_msg.error("compute.free_volume: Unsupported integrator.\n");
                raise RuntimeError("Error initializing compute.free_volume");

        if suffix is not '':
            suffix = '_' + suffix

        self.cpp_compute = cls(hoomd.context.current.system_definition,
                                mc.cpp_integrator,
                                cl,
                                seed,
                                suffix)

        if test_type is not None:
            itype = hoomd.context.current.system_definition.getParticleData().getTypeByName(test_type)
            self.cpp_compute.setTestParticleType(itype)
        if nsample is not None:
            self.cpp_compute.setNumSamples(int(nsample))

        hoomd.context.current.system.addCompute(self.cpp_compute, self.compute_name)
        self.enabled = True