def __init__(self): super().__init__() params = TypeParameter("params", "special_pair_types", TypeParameterDict(alpha=float, len_keys=1)) r_cut = TypeParameter("r_cut", "special_pair_types", TypeParameterDict(float, len_keys=1)) self._extend_typeparam([params, r_cut])
def __init__(self, filter, kT, seed, alpha=None, tally_reservoir_energy=False): # store metadata param_dict = ParameterDict( filter=ParticleFilter, kT=Variant, seed=int(seed), alpha=OnlyType(float, allow_none=True), tally_reservoir_energy=bool(tally_reservoir_energy), ) param_dict.update(dict(kT=kT, alpha=alpha, filter=filter)) # set defaults self._param_dict.update(param_dict) gamma = TypeParameter('gamma', type_kind='particle_types', param_dict=TypeParameterDict(1., len_keys=1)) gamma_r = TypeParameter('gamma_r', type_kind='particle_types', param_dict=TypeParameterDict((1., 1., 1.), len_keys=1)) self._extend_typeparam([gamma, gamma_r])
def __init__(self, filter, seed, rotation_diff=0.1): # store metadata param_dict = ParameterDict( filter=ParticleFilter, seed=int(seed), rotation_diff=float(rotation_diff), constraint=OnlyType(ConstraintForce, allow_none=True, preprocess=ellip_preprocessing), ) param_dict.update( dict(constraint=None, rotation_diff=rotation_diff, seed=seed, filter=filter)) # set defaults self._param_dict.update(param_dict) active_force = TypeParameter('active_force', type_kind='particle_types', param_dict=TypeParameterDict((1, 0, 0), len_keys=1)) active_torque = TypeParameter('active_torque', type_kind='particle_types', param_dict=TypeParameterDict((0, 0, 0), len_keys=1)) self._extend_typeparam([active_force, active_torque])
def __init__(self, filter, rotation_diff=0.1): # store metadata param_dict = ParameterDict( filter=ParticleFilter, rotation_diff=float(rotation_diff), constraint=OnlyTypes( ConstraintForce, allow_none=True, preprocess=ellip_preprocessing ), ) param_dict.update( dict( constraint=None, rotation_diff=rotation_diff, filter=filter, ) ) # set defaults self._param_dict.update(param_dict) active_force = TypeParameter( "active_force", type_kind="particle_types", param_dict=TypeParameterDict((1.0, 0.0, 0.0), len_keys=1), ) active_torque = TypeParameter( "active_torque", type_kind="particle_types", param_dict=TypeParameterDict((0.0, 0.0, 0.0), len_keys=1), ) self._extend_typeparam([active_force, active_torque])
def __init__(self, filter, manifold_constraint, tolerance=0.000001, alpha=None): # store metadata param_dict = ParameterDict( filter=ParticleFilter, alpha=OnlyTypes(float, allow_none=True), ) param_dict.update(dict(alpha=alpha, filter=filter)) # set defaults self._param_dict.update(param_dict) gamma = TypeParameter('gamma', type_kind='particle_types', param_dict=TypeParameterDict(1., len_keys=1)) gamma_r = TypeParameter('gamma_r', type_kind='particle_types', param_dict=TypeParameterDict((1., 1., 1.), len_keys=1)) self._extend_typeparam([gamma, gamma_r]) super().__init__(manifold_constraint, tolerance)
def __init__(self, r_cut_constituent, code_constituent, r_cut_isotropic, code_isotropic, param_array_constituent, param_array_isotropic): param_dict = ParameterDict( r_cut_constituent=float(r_cut_constituent), r_cut_isotropic=float(r_cut_isotropic), leaf_capacity=int(4), param_array_constituent=NDArrayValidator(dtype=np.float32, shape=(None, )), param_array_isotropic=NDArrayValidator(dtype=np.float32, shape=(None, )), code_constituent=str, code_isotropic=str, ) param_dict['param_array_constituent'] = param_array_constituent param_dict['param_array_isotropic'] = param_array_isotropic self._param_dict.update(param_dict) # add union specific per-type parameters typeparam_positions = TypeParameter( 'positions', type_kind='particle_types', param_dict=TypeParameterDict([(float, float, float)], len_keys=1), ) typeparam_orientations = TypeParameter( 'orientations', type_kind='particle_types', param_dict=TypeParameterDict([(float, float, float, float)], len_keys=1), ) typeparam_diameters = TypeParameter( 'diameters', type_kind='particle_types', param_dict=TypeParameterDict([float], len_keys=1), ) typeparam_charges = TypeParameter( 'charges', type_kind='particle_types', param_dict=TypeParameterDict([float], len_keys=1), ) typeparam_typeids = TypeParameter( 'typeids', type_kind='particle_types', param_dict=TypeParameterDict([int], len_keys=1), ) self._extend_typeparam([ typeparam_positions, typeparam_orientations, typeparam_diameters, typeparam_charges, typeparam_typeids ]) self.code_constituent = code_constituent self.code_isotropic = code_isotropic
def __init__(self, nlist, default_r_cut=None, mode='none'): super().__init__(nlist, default_r_cut, mode) params = TypeParameter( 'params', 'particle_types', TypeParameterDict(A=float, kappa=float, len_keys=2)) mu = TypeParameter('mu', 'particle_types', TypeParameterDict((float, float, float), len_keys=1)) self._extend_typeparam((params, mu))
def __init__(self): # setup the coefficient options params = TypeParameter( "params", "special_pair_types", TypeParameterDict(epsilon=float, sigma=float, len_keys=1)) r_cut = TypeParameter("r_cut", "special_pair_types", TypeParameterDict(float, len_keys=1)) self._extend_typeparam([params, r_cut])
def __init__(self, moves, target, solver, types=None, max_translation_move=None, max_rotation_move=None): super().__init__(target, solver) # A flag for knowing when to update the maximum move sizes self._should_update_move_sizes = False # set up maximum trial move sizes t_moves = TypeParameter( 'max_translation_move', 'particle_type', TypeParameterDict(OnlyTypes( float, postprocess=self._flag_move_size_update, allow_none=True), len_keys=1)) r_moves = TypeParameter( 'max_rotation_move', 'particle_type', TypeParameterDict(OnlyTypes( float, postprocess=self._flag_move_size_update, allow_none=True), len_keys=1)) self._typeparam_dict = { 'max_translation_move': t_moves, 'max_rotation_move': r_moves } # This is a bit complicated because we are having to ensure that we keep # the list of tunables and the solver updated with the changes to # attributes. However, these are simply forwarding a change along. param_dict = ParameterDict( moves=OnlyIf(to_type_converter([OnlyFrom(['a', 'd'])]), postprocess=self._update_moves), types=OnlyIf(to_type_converter([str]), postprocess=self._update_types, allow_none=True), ) self._param_dict.update(param_dict) self.target = target self.solver = solver self.moves = moves self.types = types self.max_rotation_move.default = max_rotation_move self.max_translation_move.default = max_translation_move if types is not None: self._update_tunables(new_moves=moves, new_types=types)
def test_extending_typeparams(base_op): type_params = [TypeParameter('1', 'fake1', dict(a=1)), TypeParameter('2', 'fake2', dict(a=2)), TypeParameter('3', 'fake3', dict(a=3))] base_op._extend_typeparam(type_params) keys = set(base_op._typeparam_dict.keys()) expected_keys = set(['1', '2', '3']) # That keys are the same assert keys.union(expected_keys) == keys and keys - expected_keys == set() # That each value is the same for tp in type_params: assert base_op._typeparam_dict[tp.name].param_dict == tp.param_dict assert base_op._typeparam_dict[tp.name].type_kind == tp.type_kind
def typeparam(): return TypeParameter(name='type_param', type_kind='particle_types', param_dict=TypeParameterDict( foo=1, bar=identity, len_keys=1) )
def __init__(self, mesh): params = TypeParameter( "params", "types", TypeParameterDict(k=float, r0=float, len_keys=1)) self._add_typeparam(params) super().__init__(mesh)
def __init__(self, transfer_types, ngibbs=1, max_volume_rescale=0.1, volume_move_probability=0.5, trigger=1): super().__init__(trigger) self.ngibbs = int(ngibbs) _default_dict = dict(ntrial=1) param_dict = ParameterDict( transfer_types=list(transfer_types), max_volume_rescale=float(max_volume_rescale), volume_move_probability=float(volume_move_probability), **_default_dict) self._param_dict.update(param_dict) typeparam_fugacity = TypeParameter( 'fugacity', type_kind='particle_types', param_dict=TypeParameterDict( hoomd.variant.Variant, len_keys=1, _defaults=hoomd.variant.Constant(0.0))) self._extend_typeparam([typeparam_fugacity])
def __init__(self, nlist, default_r_cut=None): self._nlist = validate_nlist(nlist) r_cut_param = TypeParameter( 'r_cut', 'particle_types', TypeParameterDict(positive_real, len_keys=2)) if default_r_cut is not None: r_cut_param.default = default_r_cut self._add_typeparam(r_cut_param)
def __init__(self): params = TypeParameter( 'params', 'dihedral_types', TypeParameterDict(k=float, d=float, n=float, phi0=float, len_keys=1)) self._add_typeparam(params)
def __init__(self, nlist, default_r_cut=None, mode="none"): self._nlist = OnlyTypes(md.nlist.NList, strict=True)(nlist) tp_r_cut = TypeParameter('r_cut', 'particle_types', TypeParameterDict(positive_real, len_keys=2)) if default_r_cut is not None: tp_r_cut.default = default_r_cut self._param_dict.update(ParameterDict(mode=OnlyFrom(['none', 'shift']))) self.mode = mode self._add_typeparam(tp_r_cut)
def __init__(self, nlist, default_r_cut=None, mode='none'): super().__init__(nlist, default_r_cut, mode) params = TypeParameter( 'params', 'particle_types', TypeParameterDict(epsilon=float, lperp=float, lpar=float, len_keys=2)) self._add_typeparam(params)
def __init__(self): params = TypeParameter( "params", "bond_types", TypeParameterDict(k=float, r0=float, epsilon=float, sigma=float, len_keys=1)) self._add_typeparam(params)
def __init__(self): # check that some dihedrals are defined params = TypeParameter( 'params', 'dihedral_types', TypeParameterDict(k1=float, k2=float, k3=float, k4=float, len_keys=1)) self._add_typeparam(params)
def __init__(self, nlist, default_r_cut=None): super().__init__() r_cut_param = TypeParameter( 'r_cut', 'particle_types', TypeParameterDict(positive_real, len_keys=2)) if default_r_cut is not None: r_cut_param.default = default_r_cut self._add_typeparam(r_cut_param) self._param_dict.update(ParameterDict(nlist=hoomd.md.nlist.NList)) self.nlist = nlist
def __init__(self, default_step_size=None): if default_step_size is None: step_size = float else: step_size = float(default_step_size) typeparam_step_size = TypeParameter('step_size', type_kind='particle_types', param_dict=TypeParameterDict( step_size, len_keys=1)) self._add_typeparam(typeparam_step_size)
def __init__(self, nlist, default_r_cut=None): super().__init__(nlist, default_r_cut) params = TypeParameter( 'params', 'particle_types', TypeParameterDict(sigma=2.0, n=1.0, epsilon=1.0, lambda3=1.0, len_keys=2)) self._add_typeparam(params)
def __init__(self, default_step_size=None, vertex_move_probability=1): super().__init__(default_step_size) param_dict = ParameterDict( vertex_move_probability=float(vertex_move_probability)) self._param_dict.update(param_dict) typeparam_volume = TypeParameter('volume', type_kind='particle_types', param_dict=TypeParameterDict( float, len_keys=1)) self._add_typeparam(typeparam_volume)
def __init__(self, filter): super().__init__() # store metadata param_dict = ParameterDict(filter=ParticleFilter) param_dict["filter"] = filter # set defaults self._param_dict.update(param_dict) active_force = TypeParameter( "active_force", type_kind="particle_types", param_dict=TypeParameterDict((1.0, 0.0, 0.0), len_keys=1), ) active_torque = TypeParameter( "active_torque", type_kind="particle_types", param_dict=TypeParameterDict((0.0, 0.0, 0.0), len_keys=1), ) self._extend_typeparam([active_force, active_torque])
def __init__(self): super().__init__() params = TypeParameter( "params", "bond_types", TypeParameterDict(k_b=float, l_min=float, l_c1=float, l_c0=float, l_max=float, len_keys=1)) self._add_typeparam(params)
def __init__(self, width): super().__init__() param_dict = hoomd.data.parameterdicts.ParameterDict(width=int) param_dict['width'] = width self._param_dict = param_dict params = TypeParameter( "params", "angle_types", TypeParameterDict( V=hoomd.data.typeconverter.NDArrayValidator(numpy.float64), tau=hoomd.data.typeconverter.NDArrayValidator(numpy.float64), len_keys=1)) self._add_typeparam(params)
def __init__(self, nlist, default_r_cut=None, mode='none'): super().__init__(nlist, default_r_cut, mode) params = TypeParameter( 'params', 'particle_types', TypeParameterDict(epsilon=float, sigma_i=float, sigma_j=float, alpha=int, contact_ratio_i=0.15, contact_ratio_j=0.15, average_simplices=True, len_keys=2)) shape = TypeParameter( 'shape', 'particle_types', TypeParameterDict(vertices=[(float, float, float)], faces=[[int]], rounding_radii=OnlyIf( to_type_converter((float, float, float)), preprocess=self._to_three_tuple), len_keys=1)) self._extend_typeparam((params, shape))
def __init__(self): body = TypeParameter( "body", "particle_types", TypeParameterDict(OnlyIf(to_type_converter({ 'constituent_types': [str], 'positions': [(float, ) * 3], 'orientations': [(float, ) * 4], 'charges': [float], 'diameters': [float] }), allow_none=True), len_keys=1)) self._add_typeparam(body) self.body.default = None
def __init__(self, callback, default_step_size=None, param_move_probability=1): super().__init__(default_step_size) param_dict = ParameterDict( param_move_probability=float(param_move_probability), callback=object) param_dict["callback"] = callback self._param_dict.update(param_dict) typeparam_shapeparams = TypeParameter('params', type_kind='particle_types', param_dict=TypeParameterDict( [float], len_keys=1)) self._add_typeparam(typeparam_shapeparams)
def __init__(self, nlist, default_r_cut=None): super().__init__(nlist, default_r_cut) params = TypeParameter( 'params', 'particle_types', TypeParameterDict(cutoff_thickness=0.2, magnitudes=(1.0, 1.0), exp_factors=(2.0, 1.0), lambda3=0.0, dimer_r=1.5, n=0.0, gamma=0.0, c=0.0, d=1.0, m=0.0, alpha=3.0, len_keys=2)) self._add_typeparam(params)