Ejemplo n.º 1
0
    def read_observable_pressure(self, data_set_name="_pressure"):
        """
        Reads back the output of the "pressure" observable. As the pressure can be computed from the number of particles
        and the virial, this actually reads back the n_particles and virial observables. The data_set_name serves as a
        postfix, where the default value corresponds to the data sets as they are created when using the default
        settings of the observable.

        :param data_set_name: the data set name postfix, default="_pressure",
               yielding "n_particles_pressure" and "virial_pressure", respectively
        :return: a tuple which contains an array corresponding to the time as first entry and an array containing the
                 corresponding pressure per time step
        """
        time_n_particles, n_particles = self.read_observable_number_of_particles(
            "n_particles{}".format(data_set_name))
        time_virial, virial = self.read_observable_virial(
            "virial{}".format(data_set_name))

        if not _np.array_equal(time_n_particles, time_virial):
            raise RuntimeError(
                "For Pressure it is required to know the number of particles and the virial. "
                "However, these two observables were recorded with different strides."
            )

        pressure = _np.array([
            _calculate_pressure(self.box_volume, self.kbt, n_particles[i],
                                virial[i])
            for i in range(len(time_n_particles))
        ])
        return time_virial, pressure
Ejemplo n.º 2
0
 def _eval_user_callback(self):
     if self._n is not None and self._v is not None:
         self._user_callback(
             _calculate_pressure(box_volume=self._volume,
                                 kbt=self._kbt,
                                 n_particles=self._n,
                                 virial=self._v))
         self._n = None
         self._v = None
Ejemplo n.º 3
0
    def read_observable_pressure(self, data_set_name="_pressure"):
        """
        Reads back the output of the "pressure" observable. As the pressure can be computed from the number of particles
        and the virial, this actually reads back the n_particles and virial observables. The data_set_name serves as a
        postfix, where the default value corresponds to the data sets as they are created when using the default
        settings of the observable.

        :param data_set_name: the data set name postfix, default="_pressure",
               yielding "n_particles_pressure" and "virial_pressure", respectively
        :return: a tuple which contains an array corresponding to the time as first entry and an array containing the
                 corresponding pressure per time step
        """
        time_n_particles, n_particles = self.read_observable_number_of_particles("n_particles{}".format(data_set_name))
        time_virial, virial = self.read_observable_virial("virial{}".format(data_set_name))

        if not _np.array_equal(time_n_particles, time_virial):
            raise RuntimeError("For Pressure it is required to know the number of particles and the virial. "
                               "However, these two observables were recorded with different strides.")

        pressure = _np.array([_calculate_pressure(self.box_volume, self.kbt, n_particles[i], virial[i])
                              for i in range(len(time_n_particles))])
        return time_virial, pressure
Ejemplo n.º 4
0
 def _eval_user_callback(self):
     if self._n is not None and self._v is not None:
         self._user_callback(_calculate_pressure(box_volume=self._volume, kbt=self._kbt,
                                                 n_particles=self._n, virial=self._v))
         self._n = None
         self._v = None