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 __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()