def __init__(self, filter, S, tauS, couple, box_dof=(True, True, True, False, False, False), rescale_all=False, gamma=0.0): # store metadata param_dict = ParameterDict(filter=ParticleFilter, kT=Variant, S=OnlyIf( to_type_converter((Variant, ) * 6), preprocess=self._preprocess_stress), tauS=float, couple=str, box_dof=(bool, ) * 6, rescale_all=bool, gamma=float, barostat_dof=(float, ) * 6) param_dict.update( dict(filter=filter, kT=hoomd.variant.Constant(1.0), S=S, tauS=float(tauS), couple=str(couple), box_dof=tuple(box_dof), rescale_all=bool(rescale_all), gamma=float(gamma), barostat_dof=(0.0, 0.0, 0.0, 0.0, 0.0, 0.0))) # set defaults self._param_dict.update(param_dict)
def __init__(self, filter, kT, tau, S, tauS, couple, box_dof=[True,True,True,False,False,False], rescale_all=False, gamma=0.0): # store metadata param_dict = ParameterDict( filter=ParticleFilter, kT=Variant, tau=float(tau), S=OnlyIf(to_type_converter((Variant,)*6), preprocess=self._preprocess_stress), tauS=float(tauS), couple=str(couple), box_dof=[bool,]*6, rescale_all=bool(rescale_all), gamma=float(gamma), translational_thermostat_dof=(float, float), rotational_thermostat_dof=(float, float), barostat_dof=(float, float, float, float, float, float) ) param_dict.update( dict(filter=filter, kT=kT, S=S, couple=couple, box_dof=box_dof, translational_thermostat_dof=(0, 0), rotational_thermostat_dof=(0, 0), barostat_dof=(0, 0, 0, 0, 0, 0))) # set defaults self._param_dict.update(param_dict)
def __init__(self,N,epsilon=0): # store metadata param_dict = ParameterDict( N=OnlyIf(to_type_converter((int,)*3), preprocess=self._preprocess_unitcell), epsilon=float(epsilon), ) param_dict['N'] = N self._param_dict.update(param_dict)
def __init__(self): param_dict = ParameterDict(size=int, types=OnlyIf( to_type_converter([str]), preprocess=self._preprocess_type)) param_dict["types"] = ["mesh"] param_dict["size"] = 0 self._triangles = np.empty([0, 3], dtype=int) self._param_dict.update(param_dict)
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, boxmc, moves, target, solver, max_move_size=None, ): super().__init__(target, solver) # Flags for knowing when to update classes attributes self._update_move_sizes = False self._should_update_tunables = False # 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. params = ParameterDict( boxmc=hoomd.hpmc.update.BoxMC, moves=[ OnlyFrom(_MoveSizeTuneDefinition.acceptable_attrs, postprocess=self._flag_new_tunables) ], max_move_size=OnlyIf( to_type_converter({ attr: OnlyTypes(float, allow_none=True, postprocess=self._flag_move_size_update) for attr in _MoveSizeTuneDefinition.acceptable_attrs }),)) params["boxmc"] = boxmc params["moves"] = moves if max_move_size is None: max_move_size = { attr: None for attr in _MoveSizeTuneDefinition.acceptable_attrs } params["max_move_size"] = max_move_size self._param_dict.update(params) self._update_tunables()
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, moves, target, solver, types=None, max_translation_move=None, max_rotation_move=None): def target_postprocess(target): def check_fraction(value): if 0 <= value <= 1: return value raise ValueError( "Value {} should be between 0 and 1.".format(value)) self._update_tunables_attr('target', check_fraction(target)) self._tuned = 0 return target def update_moves(value): self._update_tunables(new_moves=value) self._tuned = 0 return value def update_types(value): self._update_tunables(new_types=value) self._tuned = 0 return value # A flag for knowing when to update the maximum move sizes self._update_move_sizes = False self._tunables = [] # A counter when tuned reaches 1 it means that the tuner has reported # being tuned one time in a row. However, as the first run of the tuner # is likely at timestep 0 which means that the counters are (0, 0) and # _MoveSizeTuneDefinition returns y == target for that case, we need two # rounds of tuning to be sure that we have converged. Since, in general, # solvers do not do much if any work on already tuned tunables, this is # not a performance problem. self._tuned = 0 self._is_attached = False # set up maximum trial move sizes def flag_move_size_update(value): self._update_move_sizes = True return value t_moves = TypeParameter( 'max_translation_move', 'particle_type', TypeParameterDict(OnlyTypes(float, postprocess=flag_move_size_update, allow_none=True), len_keys=1)) r_moves = TypeParameter( 'max_rotation_move', 'particle_type', TypeParameterDict(OnlyTypes(float, postprocess=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=update_moves), types=OnlyIf(to_type_converter([str]), postprocess=update_types, allow_none=True), target=OnlyTypes(float, postprocess=target_postprocess), solver=SolverStep) 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)