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)
def _attach(self): integrator = self._simulation.operations.integrator if not isinstance(integrator, integrate.HPMCIntegrator): raise RuntimeError("The integrator must be a HPMC integrator.") cpp_cls_name = "UpdaterClusters" cpp_cls_name += integrator.__class__.__name__ cpp_cls = getattr(_hpmc, cpp_cls_name) use_gpu = (isinstance(self._simulation.device, hoomd.device.GPU) and (cpp_cls_name + 'GPU') in _hpmc.__dict__) if use_gpu: cpp_cls_name += "GPU" cpp_cls = getattr(_hpmc, cpp_cls_name) if not integrator._attached: raise RuntimeError("Integrator is not attached yet.") if use_gpu: sys_def = self._simulation.state._cpp_sys_def self._cpp_cell = _hoomd.CellListGPU(sys_def) self._cpp_obj = cpp_cls(self._simulation.state._cpp_sys_def, integrator._cpp_obj, self._cpp_cell) else: self._cpp_obj = cpp_cls(self._simulation.state._cpp_sys_def, integrator._cpp_obj) super()._attach()
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()
def __init__(self, group, T, seed=0, xi = 0.5, error = 0.001, function_form = None, max_strain = 0.5, nlist_type = "cell" ): # Print the status of the initialization hoomd.util.print_status_line(); # initialize base class hoomd.md.integrate._integration_method.__init__(self); # setup the variant inputs T = hoomd.variant._setup_variant_input(T); # create the compute thermo compute._get_unique_thermo(group=group); # Real space neighborlist cutoff based on error estimate for spectral sums self.rcut = math.sqrt( - math.log( error ) ) / xi; # If this line is changed, remember to change in C++ code as well!! # initialize the reflected c++ class if not hoomd.context.exec_conf.isCUDAEnabled(): hoomd.context.msg.error("Sorry, we have not written CPU code for PSE RPY simulation. \n"); raise RuntimeError('Error creating Stokes'); else: # Create a neighborlist exclusively for real space interactions. Use cell lists by # default, but also allow the user to specify if ( nlist_type.upper() == "CELL" ): cl_stokes = _hoomd.CellListGPU(hoomd.context.current.system_definition); hoomd.context.current.system.addCompute(cl_stokes, "stokes_cl") self.neighbor_list = _md.NeighborListGPUBinned(hoomd.context.current.system_definition, self.rcut, 0.4, cl_stokes); elif ( nlist_type.upper() == "TREE" ): self.neighbor_list = _md.NeighborListGPUTree(hoomd.context.current.system_definition, self.rcut, 0.4) elif ( nlist_type.upper() == "STENCIL" ): cl_stokes = _hoomd.CellListGPU(hoomd.context.current.system_definition) hoomd.context.current.system.addCompute(cl_stokes, "stokes_cl") cls_stokes = _hoomd.CellListStencil( hoomd.context.current.system_definition, cl_stokes ) hoomd.context.current.system.addCompute( cls_stokes, "stokes_cls") self.neighbor_list = _md.NeighborListGPUStencil(hoomd.context.current.system_definition, self.rcut, 0.4, cl_stokes, cls_stokes) else: hoomd.context.msg.error("Invalid neighborlist method specified. Valid options are: cell, tree, stencil. \n"); raise RuntimeError('Error constructing neighborlist'); # Set neighborlist properties self.neighbor_list.setEvery(1, True); hoomd.context.current.system.addCompute(self.neighbor_list, "stokes_nlist") self.neighbor_list.countExclusions(); # Call the stokes integrator self.cpp_method = _PSEv1.Stokes(hoomd.context.current.system_definition, group.cpp_group, T.cpp_variant, seed, self.neighbor_list, xi, error); self.cpp_method.validateGroup() if function_form is not None: self.cpp_method.setShear(function_form.cpp_function, max_strain) else: no_shear_function = shear_function.steady(dt = 0) self.cpp_method.setShear(no_shear_function.cpp_function, max_strain) self.cpp_method.setParams()