def __init__(self, order_parameters, lattice_vectors, interface_width, periodicity, name): # initialize the base class force._force.__init__(self, name); self.cpp_force = None; cpp_order_parameters = hoomd.std_vector_float() for l in order_parameters: cpp_order_parameters.append(l) cpp_lattice_vectors = _external.std_vector_int3() for l in lattice_vectors: if len(l) != 3: globals.msg.error("List of input lattice vectors not a list of triples.\n") raise RuntimeError('Error creating external ordering potential.') cpp_lattice_vectors.append(hoomd.make_int3(l[0], l[1], l[2])) cpp_interface_width = float(interface_width) cpp_periodicity = int(periodicity) if not globals.exec_conf.isCUDAEnabled(): self.cpp_force = _external.OrderingExternal(globals.system_definition, cpp_order_parameters, cpp_lattice_vectors, cpp_interface_width, cpp_periodicity, self.name) else: self.cpp_force = _external.OrderingExternalGPU(globals.system_definition, cpp_order_parameters, cpp_lattice_vectors, cpp_interface_width, cpp_periodicity, self.name) globals.system.addCompute(self.cpp_force, self.force_name) self.enabled = True;
def update_bond_table(self, btype, func, rmin, rmax, coeff): # allocate arrays to store V and F Vtable = hoomd.std_vector_float(); Ftable = hoomd.std_vector_float(); # calculate dr dr = (rmax - rmin) / float(self.width-1); # evaluate each point of the function for i in range(0, self.width): r = rmin + dr * i; (V,F) = func(r, rmin, rmax, **coeff); # fill out the tables Vtable.append(V); Ftable.append(F); # pass the tables on to the underlying cpp compute self.cpp_force.setTable(btype, Vtable, Ftable, rmin, rmax);
def __init__(self, order_parameters, lattice_vectors, interface_width, periodicity, name): # initialize the base class force._force.__init__(self, name) self.cpp_force = None cpp_order_parameters = hoomd.std_vector_float() for l in order_parameters: cpp_order_parameters.append(l) cpp_lattice_vectors = _external.std_vector_int3() for l in lattice_vectors: if len(l) != 3: globals.msg.error( "List of input lattice vectors not a list of triples.\n") raise RuntimeError( 'Error creating external ordering potential.') cpp_lattice_vectors.append(hoomd.make_int3(l[0], l[1], l[2])) cpp_interface_width = float(interface_width) cpp_periodicity = int(periodicity) if not globals.exec_conf.isCUDAEnabled(): self.cpp_force = _external.OrderingExternal( globals.system_definition, cpp_order_parameters, cpp_lattice_vectors, cpp_interface_width, cpp_periodicity, self.name) else: self.cpp_force = _external.OrderingExternalGPU( globals.system_definition, cpp_order_parameters, cpp_lattice_vectors, cpp_interface_width, cpp_periodicity, self.name) globals.system.addCompute(self.cpp_force, self.force_name) self.enabled = True