Exemple #1
0
    def describeNextReport(self, simulation):
        """
        Get information about the next report this object will generate.

        Parameters
        ----------
        simulation : :class:`app.Simulation`
            The Simulation to generate a report for

        Returns
        -------
        nsteps, pos, vel, frc, ene : int, bool, bool, bool, bool
            nsteps is the number of steps until the next report
            pos, vel, frc, and ene are flags indicating whether positions,
            velocities, forces, and/or energies are needed from the Context
        """
        if self._startTime is None:
            # First time this is called, initialize the timers
            self._startTime = timeofday()
            self._lastReportTime = timeofday()
            self._timeStep = simulation.integrator.getStepSize()
            self._timeStep = self._timeStep.value_in_unit(u.nanosecond)
            self._firstStep = simulation.currentStep
        stepsleft = simulation.currentStep % self._reportInterval
        steps = self._reportInterval - stepsleft
        return (steps, False, False, False, self._needEnergy)
Exemple #2
0
    def describeNextReport(self, simulation):
        """
        Get information about the next report this object will generate.

        Parameters
        ----------
        simulation : :class:`app.Simulation`
            The Simulation to generate a report for

        Returns
        -------
        nsteps, pos, vel, frc, ene : int, bool, bool, bool, bool
            nsteps is the number of steps until the next report
            pos, vel, frc, and ene are flags indicating whether positions,
            velocities, forces, and/or energies are needed from the Context
        """
        if self._startTime is None:
            # First time this is called, initialize the timers
            self._startTime = timeofday()
            self._lastReportTime = timeofday()
            self._timeStep = simulation.integrator.getStepSize()
            self._timeStep = self._timeStep.value_in_unit(u.nanosecond)
            self._firstStep = simulation.currentStep
        stepsleft = simulation.currentStep % self._reportInterval
        steps = self._reportInterval - stepsleft
        return (steps, False, False, False, self._needEnergy)
    def describeNextReport(self, simulation):
        """
        Get information about the next report this object will generate.

        Parameters:
            - simulation (Simulation) The Simulation to generate a report for

        Returns: A five element tuple.  The first element is the number of steps
            until the next report.  The remaining elements specify whether that
            report will require positions, velocities, forces, and energies
            respectively.
        """
        if self._startTime is None:
            # First time this is called, initialize the timers
            self._startTime = timeofday()
            self._lastReportTime = timeofday()
            self._timeStep = simulation.integrator.getStepSize()
            self._timeStep = self._timeStep.value_in_unit(u.nanosecond)
            self._firstStep = simulation.currentStep
        stepsleft = simulation.currentStep % self._reportInterval
        steps = self._reportInterval - stepsleft
        return (steps, False, False, False, self._needEnergy)
Exemple #4
0
    def report(self, simulation, state):
        """
        Generate a report and predict the time to completion (and
        current/overall MD performance)
        """
        if not self._hasInitialized:
            self._initializeConstants(simulation)
            self._hasInitialized = True

        # Check for errors.
        self._checkForErrors(simulation, state)

        # Query for the values
        values = self._constructReportValues(simulation, state)

        now = timeofday()

        total_time = now - self._startTime
        partial_time = now - self._lastReportTime
        self._lastReportTime = now

        total_nsperday = ((values['step'] - self._firstStep) * self._timeStep /
                          total_time)
        partial_nsperday = (self._reportInterval *
                            self._timeStep) / partial_time

        # Get total and partial ns/day (currently ns/second)
        total_nsperday *= 3600 * 24
        partial_nsperday *= 3600 * 24

        # Estimated time to completion (based on performance of last N steps
        remaining_steps = self._totalSteps - values['step'] + self._firstStep
        etc = partial_time / self._reportInterval * remaining_steps

        if etc > 3600:
            etc /= 3600
            unitstr = 'hr.'
        elif etc > 60:
            etc /= 60
            unitstr = 'min.'
        else:
            unitstr = 'sec.'

        # Write the values.
        with open(self.fname, 'w') as f:
            f.write('-+' * 39 + '\n')
            f.write('\n')
            f.write('  On step %d of %d\n' %
                    (values['step'] - self._firstStep, self._totalSteps))
            f.write('\n')
            if self._totalEnergy:
                f.write('  Total Energy     = %12.4f\n' %
                        values['totalEnergy'])
            if self._potentialEnergy:
                f.write('  Potential Energy = %12.4f\n' %
                        values['potentialEnergy'])
            if self._kineticEnergy:
                f.write('  Kinetic Energy   = %12.4f\n' %
                        values['kineticEnergy'])
            if self._volume:
                f.write('  Volume           = %12.4f\n' % values['volume'])
            if self._density:
                f.write('  Density          = %12.4f\n' % values['density'])
            if self._temperature:
                f.write('  Temperature      = %12.4f\n' %
                        values['temperature'])
            f.write('\n')
            f.write(' Time for last %8d steps: %10.4f s. (%.3f ns/day)\n' %
                    (self._reportInterval, partial_time, partial_nsperday))
            f.write(
                ' Time for all %9d steps: %10.4f s. (%.3f ns/day)\n' %
                (values['step'] - self._firstStep, total_time, total_nsperday))
            f.write('\n')
            f.write(' Estimated time to completion: %.3f %s\n' %
                    (etc, unitstr))
            f.write('\n')
            f.write('-+' * 39 + '\n')

        if remaining_steps == 0: self._startTime = None
    def report(self, simulation, state):
        """
        Generate a report and predict the time to completion (and
        current/overall MD performance)
        """
        if not self._hasInitialized:
            self._initializeConstants(simulation)
            self._hasInitialized = True

        # Check for errors.
        self._checkForErrors(simulation, state)

        # Query for the values
        values = self._constructReportValues(simulation, state)

        now = timeofday()

        total_time = now - self._startTime
        partial_time = now - self._lastReportTime
        self._lastReportTime = now

        total_nsperday = (values["step"] - self._firstStep) * self._timeStep / total_time
        partial_nsperday = (self._reportInterval * self._timeStep) / partial_time

        # Get total and partial ns/day (currently ns/second)
        total_nsperday *= 3600 * 24
        partial_nsperday *= 3600 * 24

        # Estimated time to completion (based on performance of last N steps
        remaining_steps = self._totalSteps - values["step"] + self._firstStep
        etc = partial_time / self._reportInterval * remaining_steps

        if etc > 3600:
            etc /= 3600
            unitstr = "hr."
        elif etc > 60:
            etc /= 60
            unitstr = "min."
        else:
            unitstr = "sec."

        # Write the values.
        with open(self.fname, "w") as f:
            f.write("-+" * 39 + "\n")
            f.write("\n")
            f.write("  On step %d of %d\n" % (values["step"] - self._firstStep, self._totalSteps))
            f.write("\n")
            if self._totalEnergy:
                f.write("  Total Energy     = %12.4f\n" % values["totalEnergy"])
            if self._potentialEnergy:
                f.write("  Potential Energy = %12.4f\n" % values["potentialEnergy"])
            if self._kineticEnergy:
                f.write("  Kinetic Energy   = %12.4f\n" % values["kineticEnergy"])
            if self._volume:
                f.write("  Volume           = %12.4f\n" % values["volume"])
            if self._density:
                f.write("  Density          = %12.4f\n" % values["density"])
            if self._temperature:
                f.write("  Temperature      = %12.4f\n" % values["temperature"])
            f.write("\n")
            f.write(
                " Time for last %8d steps: %10.4f s. (%.3f ns/day)\n"
                % (self._reportInterval, partial_time, partial_nsperday)
            )
            f.write(
                " Time for all %9d steps: %10.4f s. (%.3f ns/day)\n"
                % (values["step"] - self._firstStep, total_time, total_nsperday)
            )
            f.write("\n")
            f.write(" Estimated time to completion: %.3f %s\n" % (etc, unitstr))
            f.write("\n")
            f.write("-+" * 39 + "\n")

        if remaining_steps == 0:
            self._startTime = None
Exemple #6
0
    def report(self, simulation, state):
        """
        Generate a report and predict the time to completion (and
        current/overall MD performance)
        """
        if not self._hasInitialized:
            self._initializeConstants(simulation)
            self._hasInitialized = True

        # Check for errors.
        self._checkForErrors(simulation, state)

        # Query for the values
        values = self._constructReportValues(simulation, state)

        now = timeofday()

        total_time = now - self._startTime
        partial_time = now - self._lastReportTime
        self._lastReportTime = now

        total_nsperday = ((values['step'] - self._firstStep) * self._timeStep /
                           total_time)
        partial_nsperday = (self._reportInterval*self._timeStep) / partial_time

        # Get total and partial ns/day (currently ns/second)
        total_nsperday *= 3600 * 24
        partial_nsperday *= 3600 * 24

        # Estimated time to completion (based on performance of last N steps
        remaining_steps = self._totalSteps - values['step'] + self._firstStep
        etc = partial_time / self._reportInterval * remaining_steps

        if etc > 3600:
            etc /= 3600
            unitstr = 'hr.'
        elif etc > 60:
            etc /= 60
            unitstr = 'min.'
        else:
            unitstr = 'sec.'

        # Write the values.
        with open(self.fname, 'w') as f:
            f.write('-+' * 39 + '\n')
            f.write('\n')
            f.write('  On step %d of %d\n' % (values['step'] - self._firstStep,
                                              self._totalSteps))
            f.write('\n')
            if self._totalEnergy:
                f.write('  Total Energy     = %12.4f\n' % values['totalEnergy'])
            if self._potentialEnergy:
                f.write('  Potential Energy = %12.4f\n' %
                        values['potentialEnergy'])
            if self._kineticEnergy:
                f.write('  Kinetic Energy   = %12.4f\n' %
                        values['kineticEnergy'])
            if self._volume:
                f.write('  Volume           = %12.4f\n' % values['volume'])
            if self._density:
                f.write('  Density          = %12.4f\n' % values['density'])
            if self._temperature:
                f.write('  Temperature      = %12.4f\n' % values['temperature'])
            f.write('\n')
            f.write(' Time for last %8d steps: %10.4f s. (%.3f ns/day)\n' %
                    (self._reportInterval, partial_time, partial_nsperday))
            f.write(' Time for all %9d steps: %10.4f s. (%.3f ns/day)\n' %
                    (values['step']-self._firstStep, total_time, total_nsperday)
            )
            f.write('\n')
            f.write(' Estimated time to completion: %.3f %s\n' % (etc, unitstr))
            f.write('\n')
            f.write('-+' * 39 + '\n')

        if remaining_steps == 0: self._startTime = None