コード例 #1
0
def trigger_preprocessing(trigger):
    if isinstance(trigger, Trigger):
        return trigger
    else:
        try:
            return Periodic(period=int(trigger), phase=0)
        except Exception:
            raise ValueError("Expected a hoomd.trigger.Trigger or int object.")
コード例 #2
0
    def update(state, box, filter=All()):
        """Immediately scale the particle in the system state to the given box.

        Args:
            state (State): System state to scale.
            box (Box): New box.
            filter (hoomd.filter.ParticleFilter): The subset of particles to
                update.
        """
        group = state._get_group(filter)
        updater = _hoomd.BoxResizeUpdater(state._cpp_sys_def, Periodic(1),
                                          state.box._cpp_obj, box._cpp_obj,
                                          Constant(1), group)
        updater.update(state._simulation.timestep)
コード例 #3
0
    def write(state, filename, filter=All(), mode='wb', log=None):
        """Write the given simulation state out to a GSD file.

        Args:
            state (State): Simulation state.
            filename (str): File name to write.
            filter (hoomd.filter.ParticleFilter): Select the particles to write.
            mode (str): The file open mode. Defaults to ``'wb'``.
            log (hoomd.logging.Logger): Provide log quantities to write.

        The valid file modes for `write` are ``'wb'`` and ``'xb'``.
        """
        if mode != 'wb' and mode != 'xb':
            raise ValueError(f"Invalid GSD.write file mode: {mode}")

        writer = _hoomd.GSDDumpWriter(state._cpp_sys_def,
                                      Periodic(1), filename,
                                      state._get_group(filter), mode, False)

        if log is not None:
            writer.log_writer = _GSDLogWriter(log)
        writer.analyze(state._simulation.timestep)