def process_coeff(self, coeff): v0 = coeff['v0'] eps = coeff['eps'] scaledr_cut = coeff['scaledr_cut'] kappa = coeff['kappa'] return _hoomd.make_scalar4(v0, eps, scaledr_cut, kappa)
def process_coeff(self, coeff): A = coeff['A']; i = coeff['i']; w = coeff['w']; p = coeff['p']; return _hoomd.make_scalar4(_hoomd.int_as_scalar(i), A, w, _hoomd.int_as_scalar(p));
def process_coeff(self, coeff): A = coeff['A'] sigma = coeff['sigma'] x = coeff['x'] y = coeff['y'] return _hoomd.make_scalar4(x, y, A, sigma)
def process_coeff(self, coeff): D0 = coeff['D0'] alpha = coeff['alpha'] r0 = coeff['r0'] return _md.make_wall_morse_params( _hoomd.make_scalar4(D0, alpha, r0, 0.0), coeff['r_cut'] * coeff['r_cut'], coeff['r_extrap'])
def process_coeff(self, coeff): A = coeff['A'] i = coeff['i'] w = coeff['w'] p = coeff['p'] return _hoomd.make_scalar4(_hoomd.int_as_scalar(i), A, w, _hoomd.int_as_scalar(p))
def process_coeff(self, coeff): epsilon = float(coeff['epsilon']); sigma = float(coeff['sigma']); n = float(coeff['n']); m = float(coeff['m']); mie1 = epsilon * math.pow(sigma, n) * (n/(n-m)) * math.pow(n/m,m/(n-m)); mie2 = epsilon * math.pow(sigma, m) * (n/(n-m)) * math.pow(n/m,m/(n-m)); mie3 = n mie4 = m return _md.make_wall_mie_params(_hoomd.make_scalar4(mie1, mie2, mie3, mie4), coeff['r_cut']*coeff['r_cut'], coeff['r_extrap']);
def process_coeff(self, coeff): epsilon = coeff['epsilon'] sigma = coeff['sigma'] style = coeff['style'] if style == 'slv-slv': style = 0 elif style == 'coll-slv': style = 1 elif style == 'coll-coll': style = 2 else: hoomd.context.msg.error('Unknown interaction style\n') raise RuntimeError('Unknown interaction style') return _hoomd.make_scalar4(epsilon, sigma**3, sigma**6, _hoomd.int_as_scalar(style))
def set_orientation(self, i, ref_orient): R""" Set the reference orientation for a particular particle. Args: i (int): Index of the particle ref_orient (array_like): Reference orientation for the particle Examples:: field = azplugins.restrain.position(group=hoomd.group.all(), k=1.0) director = [1., 0., 0., 0.] field.set_reference_orientation(0,director) """ hoomd.util.print_status_line() try: xyzw = _hoomd.make_scalar4(ref_orient[0],ref_orient[1],ref_orient[2],ref_orient[3]) except: hoomd.context.msg.error('restrain.orientation.set_orientation: ref_orient must be a 4-item iterable composed of scalars\n') raise ValueError('ref_orient must be a 4-item iterable composed of scalars') self.cpp_force.setOrientation(i,xyzw)
def process_coeff(self, coeff): k = coeff['k'] r0 = coeff['r0'] epsilon = coeff['epsilon'] sigma = coeff['sigma'] lj1 = 4.0 * epsilon * math.pow(sigma, 12.0) lj2 = 4.0 * epsilon * math.pow(sigma, 6.0) if epsilon==0: hoomd.context.msg.error("azplugins.bond.fene(): epsilon must be non-zero.\n") raise ValueError('epsilon must be non-zero') if sigma==0: hoomd.context.msg.error("azplugins.bond.fene(): sigma must be non-zero.\n") raise ValueError('sigma must be non-zero') if k==0: hoomd.context.msg.error("azplugins.bond.fene(): k must be non-zero.\n") raise ValueError('k must be non-zero') if r0==0: hoomd.context.msg.error("azplugins.bond.fene(): r0 must be non-zero.\n") raise ValueError('r0 must be non-zero') return _hoomd.make_scalar4(k, r0, lj1, lj2)
def set_position(self, i, ref_pos): R""" Set the reference position for a particular particle. Args: i (int): Index of the particle ref_pos (array_like): Reference position for the particle Examples:: springs = azplugins.restrain.position(group=hoomd.group.all(), k=1.0) lattice = [1., 2., 3.] springs.set_reference_position(0,lattice) """ hoomd.util.print_status_line() try: xyz = _hoomd.make_scalar4(ref_pos[0],ref_pos[1],ref_pos[2],0.0) except: hoomd.context.msg.error('restrain.orientation.set_positions: ref_pos must be a 3-item iterable composed of scalars\n') raise ValueError('ref_pos must be a 3-item iterable composed of scalars') self.cpp_force.setPosition(i,xyz)
def set_param(self, type_name, types, positions, orientations=None, charges=None, diameters=None): R""" Set constituent particle types and coordinates for a rigid body. Args: type_name (str): The type of the central particle types (list): List of types of constituent particles positions (list): List of relative positions of constituent particles orientations (list): List of orientations of constituent particles (**optional**) charge (list): List of charges of constituent particles (**optional**) diameters (list): List of diameters of constituent particles (**optional**) .. caution:: The constituent particle type must be exist. If it does not exist, it can be created on the fly using ``system.particles.types.add('A_const')`` (see :py:mod:`hoomd.data`). Example:: rigid = constrain.rigd() rigid.set_param('A', types = ['A_const', 'A_const'], positions = [(0,0,1),(0,0,-1)]) rigid.set_param('B', types = ['B_const', 'B_const'], positions = [(0,0,.5),(0,0,-.5)]) """ # get a list of types from the particle data ntypes = hoomd.context.current.system_definition.getParticleData( ).getNTypes() type_list = [] for i in range(0, ntypes): type_list.append(hoomd.context.current.system_definition. getParticleData().getNameByType(i)) if type_name not in type_list: hoomd.context.msg.error('Type ' '{}' ' not found.\n'.format(type_name)) raise RuntimeError( 'Error setting up parameters for constrain.rigid()') type_id = type_list.index(type_name) if not isinstance(types, list): hoomd.context.msg.error('Expecting list of particle types.\n') raise RuntimeError( 'Error setting up parameters for constrain.rigid()') type_vec = _hoomd.std_vector_uint() for t in types: if t not in type_list: hoomd.context.msg.error('Type ' '{}' ' not found.\n'.format(t)) raise RuntimeError( 'Error setting up parameters for constrain.rigid()') constituent_type_id = type_list.index(t) type_vec.append(constituent_type_id) pos_vec = _hoomd.std_vector_scalar3() positions_list = list(positions) for p in positions_list: p = tuple(p) if len(p) != 3: hoomd.context.msg.error( 'Particle position is not a coordinate triple.\n') raise RuntimeError( 'Error setting up parameters for constrain.rigid()') pos_vec.append(_hoomd.make_scalar3(p[0], p[1], p[2])) orientation_vec = _hoomd.std_vector_scalar4() if orientations is not None: orientations_list = list(orientations) for o in orientations_list: o = tuple(o) if len(o) != 4: hoomd.context.msg.error( 'Particle orientation is not a 4-tuple.\n') raise RuntimeError( 'Error setting up parameters for constrain.rigid()') orientation_vec.append( _hoomd.make_scalar4(o[0], o[1], o[2], o[3])) else: for p in positions: orientation_vec.append(_hoomd.make_scalar4(1, 0, 0, 0)) charge_vec = _hoomd.std_vector_scalar() if charges is not None: charges_list = list(charges) for c in charges_list: charge_vec.append(float(c)) else: for p in positions: charge_vec.append(0.0) diameter_vec = _hoomd.std_vector_scalar() if diameters is not None: diameters_list = list(diameters) for d in diameters_list: diameter_vec.append(float(d)) else: for p in positions: diameter_vec.append(1.0) # set parameters in C++ force self.cpp_force.setParam(type_id, type_vec, pos_vec, orientation_vec, charge_vec, diameter_vec)
def process_coeff(self, coeff): k = coeff['k']; r0 = coeff['r0']; lj1 = 4.0 * coeff['epsilon'] * math.pow(coeff['sigma'], 12.0); lj2 = 4.0 * coeff['epsilon'] * math.pow(coeff['sigma'], 6.0); return _hoomd.make_scalar4(k, r0, lj1, lj2);
def set_param(self,type_name, types, positions, orientations=None, charges=None, diameters=None): R""" Set constituent particle types and coordinates for a rigid body. Args: type_name (str): The type of the central particle types (list): List of types of constituent particles positions (list): List of relative positions of constituent particles orientations (list): List of orientations of constituent particles (**optional**) charge (list): List of charges of constituent particles (**optional**) diameters (list): List of diameters of constituent particles (**optional**) .. caution:: The constituent particle type must be exist. If it does not exist, it can be created on the fly using ``system.particles.types.add('A_const')`` (see :py:mod:`hoomd.data`). Example:: rigid = constrain.rigd() rigid.set_param('A', types = ['A_const', 'A_const'], positions = [(0,0,1),(0,0,-1)]) rigid.set_param('B', types = ['B_const', 'B_const'], positions = [(0,0,.5),(0,0,-.5)]) """ # get a list of types from the particle data ntypes = hoomd.context.current.system_definition.getParticleData().getNTypes(); type_list = []; for i in range(0,ntypes): type_list.append(hoomd.context.current.system_definition.getParticleData().getNameByType(i)); if type_name not in type_list: hoomd.context.msg.error('Type ''{}'' not found.\n'.format(type_name)) raise RuntimeError('Error setting up parameters for constrain.rigid()') type_id = type_list.index(type_name) if not isinstance(types, list): hoomd.context.msg.error('Expecting list of particle types.\n') raise RuntimeError('Error setting up parameters for constrain.rigid()') type_vec = _hoomd.std_vector_uint() for t in types: if t not in type_list: hoomd.context.msg.error('Type ''{}'' not found.\n'.format(t)) raise RuntimeError('Error setting up parameters for constrain.rigid()') constituent_type_id = type_list.index(t) type_vec.append(constituent_type_id) pos_vec = _hoomd.std_vector_scalar3() positions_list = list(positions) for p in positions_list: p = tuple(p) if len(p) != 3: hoomd.context.msg.error('Particle position is not a coordinate triple.\n') raise RuntimeError('Error setting up parameters for constrain.rigid()') pos_vec.append(_hoomd.make_scalar3(p[0],p[1],p[2])) orientation_vec = _hoomd.std_vector_scalar4() if orientations is not None: orientations_list = list(orientations) for o in orientations_list: o = tuple(o) if len(o) != 4: hoomd.context.msg.error('Particle orientation is not a 4-tuple.\n') raise RuntimeError('Error setting up parameters for constrain.rigid()') orientation_vec.append(_hoomd.make_scalar4(o[0], o[1], o[2], o[3])) else: for p in positions: orientation_vec.append(_hoomd.make_scalar4(1,0,0,0)) charge_vec = _hoomd.std_vector_scalar() if charges is not None: charges_list = list(charges) for c in charges_list: charge_vec.append(float(c)) else: for p in positions: charge_vec.append(0.0) diameter_vec = _hoomd.std_vector_scalar() if diameters is not None: diameters_list = list(diameters) for d in diameters_list: diameter_vec.append(float(d)) else: for p in positions: diameter_vec.append(1.0) # set parameters in C++ force self.cpp_force.setParam(type_id, type_vec, pos_vec, orientation_vec, charge_vec, diameter_vec)
def process_coeff(self, coeff): D0 = coeff['D0']; alpha = coeff['alpha']; r0 = coeff['r0'] return _md.make_wall_morse_params(_hoomd.make_scalar4(D0, alpha, r0, 0.0), coeff['r_cut']*coeff['r_cut'], coeff['r_extrap']);