コード例 #1
0
    def meanSterr(self, remove=False, max=None):
        """
        Returns array of mean and standard error of measured data.

        Parameters
        ----------
        remove : bool
            Remove inf and -inf as well as nan. (default: False)
            NOTE: A warning will be issued if remove == False and such objects are
                  encountered.
        max : float or None
            Remove data which is strictly above max in absolute value.
            (default: None)
            NOTE: max != None will trigger remove = True.

        Returns
        -------
        SCGF : (self.sValues.size, 3) float Numpy array
            Scaled cumulant generating function.
        orderParameter : (self.sValues.size, 3) float Numpy array.
            Order parameter.
        orderParameterSq : (self.sValues.size, 3) float Numpy array.
            Squared order parameter.

        NOTE: (0) Biasing parameter.
              (1) Mean.
              (2) Standard error.

        I : (self.sValues.size, 4) float Numpy array
            Rate function.

        NOTE: (0) (Squared) order parameter.
              (1) Standard error on (squared) order parameter.
              (2) Rate function.
              (3) Standard error on rate function.
        """

        SCGF = np.empty((self.sValues.size, 3))
        orderParameter = np.empty((self.sValues.size, 3))
        orderParameterSq = np.empty((self.sValues.size, 3))
        I = np.empty((self.sValues.size, 4))
        for i in range(self.sValues.size):
            SCGF[i] = [
                self.sValues[i],
                *mean_sterr(self.SCGF[i], remove=remove, max=max)
            ]
            orderParameter[i] = [
                self.sValues[i],
                *mean_sterr(self.orderParameter[i], remove=remove, max=max)
            ]
            orderParameterSq[i] = [
                self.sValues[i],
                *mean_sterr(self.orderParameterSq[i], remove=remove, max=max)
            ]
            I[i] = [
                *mean_sterr(self.I[i, :, 0], remove=remove, max=max),
                *mean_sterr(self.I[i, :, 1], remove=remove, max=max)
            ]

        return SCGF, orderParameter, orderParameterSq, I
コード例 #2
0
    def msd(self, n_max=100, int_max=100, min=None, max=None, jump=1):
        """
        Compute mean square displacement.

        Parameters
        ----------
        n_max : int
            Maximum number of times at which to compute the mean square
            displacement. (default: 100)
        int_max : int
            Maximum number of different intervals to consider when averaging
            the mean square displacement. (default: 100)
        min : int or None
            Minimum time at which to compute the displacement. (default: None)
            NOTE: if min == None, then min = 1.
        max : int or None
            Maximum time at which to compute the displacement. (default: None)
            NOTE: if max == None, then max is taken to be the maximum according
                  to the choice of int_max.
        jump : int
            Compute displacements by treating frames in packs of `jump'. This
            can speed up calculation but also give unaccuracies if
            `jump'*self.dt is of the order of the system size. (default: 1)

        Returns
        -------
        msd_sterr : (3, *) float numpy array
            Array of:
                (0) lag time at which the mean square displacement is computed,
                (1) mean square displacement,
                (2) standard error of the computed mean square displacement.
        """

        min = 1 if min == None else int(min)
        max = ((self.frames - self.skip - 1) //
               int_max if max == None else int(max))

        # COMPUTE RELEVANT DISPLACEMENTS FROM DATA
        dt = logspace(min, max, n_max)  # array of lag times
        displacements = self.dtDisplacements(
            dt,  # array of displacements for different initial times and lag times
            int_max=int_max,
            jump=jump,
            norm=False)

        # COMPUTE MEAN SQUARE DISPLACEMENTS
        msd_sterr = []
        for i in range(dt.size):
            disp = displacements[:, i]
            if self.N > 1:
                disp -= disp.mean(axis=1).reshape(
                    displacements.shape[0], 1, 2
                )  # substract mean displacement of particles during each considered intervals
            disp.reshape(displacements.shape[0] * self.N, 2)
            msd_sterr += [[
                dt[i], *mean_sterr(np.sum(disp**2, axis=-1).flatten())
            ]]

        return np.array(msd_sterr)
コード例 #3
0
    def corWorkOrderAve(self,
                        n_max=100,
                        int_max=None,
                        min=None,
                        max=None,
                        log=False):
        """
        Compute correlations of the fluctuations of the work averaged over an
        interval of length `tau' and the fluctuations of the order parameter norm
        at the beginning of the interval.

        Parameters
        ----------
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of disjoint
                     intervals will be considered.
        min : int or None
            Minimum value at which to compute the correlation. (default: None)
            NOTE: this value is passed as `min' to self.n.
        max : int or None
            Maximum value at which to compute the correlation. (default: None)
            NOTE: this value is passed as `max' to self.n.
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: True)

        Returns
        -------
        cor : (5, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation,
                (3) standard deviation of the active work,
                (4) standard deviation of the order parameter norm.
        """

        cor = []
        for n in self._n(n_max=n_max, min=min, max=max, log=log):
            works = (lambda l: l - np.mean(l))(
                self.nWork(n, int_max=int_max)
            )  # fluctuations of the active wok on intervals of size n
            orders = (lambda l: l - np.mean(l))(
                np.array(
                    list(
                        map(  # fluctuations of the order parameter norm at the beginning of these intervals
                            lambda t: self.getOrderParameter(t, norm=True),
                            self.framesWork *
                            self._time0(n, int_max=int_max)))))
            workOrder = works * orders
            cor += [[n, *mean_sterr(workOrder), np.std(works), np.std(orders)]]

        return np.array(cor)
コード例 #4
0
ファイル: force.py プロジェクト: yketa/active_work
    def corForceForce(self,
        n_max=100, int_max=None, min=1, max=None, log=False):
        """
        Returns fluctuations of the force autocorrelations.

        Parameters
        ----------
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of disjoint
                  intervals will be considered.
        min : int or None
            Minimum value at which to compute the correlation. (default: 1)
        max : int or None
            Maximum value at which to compute the correlation. (default: None)
            NOTE: if max == None, then n_max = self.frames - self.skip - 1.
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: False)

        Returns
        -------
        cor : (3, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation,
                (3) mean of the squared norm of the flucuations of the force.
        """

        min = 1 if min == None else int(min)
        max = self.frames - self.skip - 1 if max == None else int(max)
        int_max = ((self.frames - self.skip - 1)//max if int_max == None
            else int(int_max))

        if log: space = logspace
        else: space = linspace

        dt = space(min, max, n_max)
        time0 = linspace(self.skip, self.frames - max - 1, int_max)

        cor = []
        forcesIni = (
            (lambda l: (np.array(l)
                - np.mean(l, axis=1).reshape(time0.size, 1)).flatten())(    # fluctuations of the force scalar the orientation at t0
                list(map(
                    lambda t: self._ForceOrientation(t),
                    time0))))
        for tau in dt:
            forcesFin = (
                (lambda l:
                    np.array(l) - np.mean(l, axis=1).reshape(time0.size, 1, 2))(    # fluctuations of the force at t0 + tau
                list(map(lambda t: self.getForce(t + tau), time0)))).reshape(
                    (self.N*time0.size, 2))
            forcesForces = list(map(lambda x, y: np.dot(x, y),
                *(forcesIni, forcesFin)))
            forcesNormSq = (list(map(lambda x, y: np.dot(x, y),
                *(forcesIni, forcesIni)))
                + list(map(lambda x, y: np.dot(x, y),
                    *(forcesFin, forcesFin))))
            cor += [[tau, *mean_sterr(forcesForces), np.mean(forcesNormSq)]]

        return np.array(cor)
コード例 #5
0
ファイル: force.py プロジェクト: yketa/active_work
    def corForceVelocity(self,
        n_max=100, int_max=None, min=1, max=None, log=False):
        """
        Returns correlations of the scalar product of force and velocity.

        Parameters
        ----------
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of disjoint
                  intervals will be considered.
        min : int or None
            Minimum value at which to compute the correlation. (default: 1)
        max : int or None
            Maximum value at which to compute the correlation. (default: None)
            NOTE: if max == None, then n_max = self.frames - self.skip - 1.
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: False)

        Returns
        -------
        cor : (3, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation,
                (3) product of the standard deviations of the scalar product
                    at initial and final times.
        """

        min = 1 if min == None else int(min)
        max = self.frames - self.skip - 1 if max == None else int(max)
        int_max = ((self.frames - self.skip - 1)//max if int_max == None
            else int(int_max))

        if log: space = logspace
        else: space = linspace

        dt = space(min, max, n_max)
        time0 = linspace(self.skip, self.frames - max - 1, int_max)

        cor = []
        forcesVelocitesIni = (
            (lambda l:
                np.array(l) - np.mean(l, axis=1).reshape(time0.size, 1))(   # fluctuations of the scalar product of force and velocity at t0
                list(map(
                    lambda t: list(map(
                        lambda f, v: np.dot(f, v),
                        *(self.getForce(t),
                            self.getVelocities(t, norm=False)))),
                    time0)))).flatten()
        print(forcesVelocitesIni)
        for tau in dt:
            forcesVelocitesFin = (
                (lambda l:
                    np.array(l) - np.mean(l, axis=1).reshape(time0.size, 1))(   # fluctuations of the scalar product of force and velocity at t0 + tau
                    list(map(
                        lambda t: list(map(
                            lambda f, v: np.dot(f, v),
                            *(self.getForce(t),
                                self.getVelocities(t, norm=False)))),
                        time0 + tau)))).flatten()
            print(forcesVelocitesFin)
            cor += [[
                tau,
                *mean_sterr(forcesVelocitesIni*forcesVelocitesFin),
                forcesVelocitesIni.std()*forcesVelocitesFin.std()]]

        return np.array(cor)
コード例 #6
0
    def meanSterr(self, remove=False, max=None):
        """
        Returns array of mean and standard error of measured data.

        Parameters
        ----------
        remove : bool
            Remove inf and -inf as well as nan. (default: False)
            NOTE: A warning will be issued if remove == False and such objects
                  are encountered.
        max : float or None
            Remove data which is strictly above max in absolute value.
            (default: None)
            NOTE: max != None will trigger remove = True.

        Returns
        -------
        activeWork : (self.gValues.size, 3) float Numpy array
            Normalised rate of active work.
        activeWorkForce : (self.gValues.size, 3) float Numpy array
            Force part of the normalised rate of active work.
        activeWorkOri : (self.gValues.size, 3) float Numpy array
            Orientation part of the normalised rate of active work.
        orderParameter : (self.gValues.size, 3) float Numpy array
            Order parameter.
        torqueIntegral1 : (self.gValues.size, 3) float Numpy array
            First torque integral.
        torqueIntegral2 : (self.gValues.size, 3) float Numpy array
            Second torque integral.

        NOTE: (0) Torque parameter.
              (1) Mean.
              (2) Standard error.

        Lambda : (self.gValues.size, 4) float Numpy array
            Bound to the rate function.

        NOTE: (0) Active work.
              (1) Standard error on active work.
              (2) Bound to the rate function.
              (3) Standard error on the boudn to the function.
        """

        activeWork = np.empty((self.gValues.size, 3))
        activeWorkForce = np.empty((self.gValues.size, 3))
        activeWorkOri = np.empty((self.gValues.size, 3))
        orderParameter = np.empty((self.gValues.size, 3))
        torqueIntegral1 = np.empty((self.gValues.size, 3))
        torqueIntegral2 = np.empty((self.gValues.size, 3))
        Lambda = np.empty((self.gValues.size, 4))
        for i in range(self.gValues.size):
            activeWork[i] = [
                self.gValues[i],
                *mean_sterr(self.activeWork[i], remove=remove, max=max)]
            activeWorkForce[i] = [
                self.gValues[i],
                *mean_sterr(self.activeWorkForce[i], remove=remove, max=max)]
            activeWorkOri[i] = [
                self.gValues[i],
                *mean_sterr(self.activeWorkOri[i], remove=remove, max=max)]
            orderParameter[i] = [
                self.gValues[i],
                *mean_sterr(self.orderParameter[i], remove=remove, max=max)]
            torqueIntegral1[i] = [
                self.gValues[i],
                *mean_sterr(self.torqueIntegral1[i], remove=remove, max=max)]
            torqueIntegral2[i] = [
                self.gValues[i],
                *mean_sterr(self.torqueIntegral2[i], remove=remove, max=max)]
            Lambda[i] = [
                *mean_sterr(self.Lambda[i, :, 0], remove=remove, max=max),
                *mean_sterr(self.Lambda[i, :, 1], remove=remove, max=max)]

        return (activeWork, activeWorkForce, activeWorkOri, orderParameter,
            torqueIntegral1, torqueIntegral2, Lambda)
コード例 #7
0
ファイル: cloning.py プロジェクト: yketa/active_work
    def meanSterr(self, remove=False, max=None):
        """
        Returns array of mean and standard error of measured data.

        Parameters
        ----------
        remove : bool
            Remove inf and -inf as well as nan. (default: False)
            NOTE: A warning will be issued if remove == False and such objects
                  are encountered.
        max : float or None
            Remove data which is strictly above max in absolute value.
            (default: None)
            NOTE: max != None will trigger remove = True.

        Returns
        -------
        SCGF : (self.sValues.size, 3) float Numpy array
            Scaled cumulant generating function.
        activeWork : (self.sValues.size, 3) float Numpy array
            Normalised rate of active work.
        activeWorkForce : (self.sValues.size, 3) float Numpy array
            Force part of the normalised rate of active work.
        activeWorkOri : (self.sValues.size, 3) float Numpy array
            Orientation part of the normalised rate of active work.
        orderParameter : (self.sValues.size, 3) float Numpy array
            Order parameter.

        NOTE: (0) Biasing parameter.
              (1) Mean.
              (2) Standard error.

        I : (self.sValues.size, 4) float Numpy array
            Rate function.

        NOTE: (0) Active work.
              (1) Standard error on active work.
              (2) Rate function.
              (3) Standard error on rate function.
        """

        if max != None: remove = True

        SCGF = np.empty((self.sValues.size, 3))
        activeWork = np.empty((self.sValues.size, 3))
        activeWorkForce = np.empty((self.sValues.size, 3))
        activeWorkOri = np.empty((self.sValues.size, 3))
        orderParameter = np.empty((self.sValues.size, 3))
        I = np.empty((self.sValues.size, 4))
        for i in range(self.sValues.size):
            SCGF[i] = [
                self.sValues[i],
                *mean_sterr(self.SCGF[i], remove=remove, max=max)
            ]
            activeWork[i] = [
                self.sValues[i],
                *mean_sterr(self.activeWork[i], remove=remove, max=max)
            ]
            activeWorkForce[i] = [
                self.sValues[i],
                *mean_sterr(self.activeWorkForce[i], remove=remove, max=max)
            ]
            activeWorkOri[i] = [
                self.sValues[i],
                *mean_sterr(self.activeWorkOri[i], remove=remove, max=max)
            ]
            orderParameter[i] = [
                self.sValues[i],
                *mean_sterr(self.orderParameter[i], remove=remove, max=max)
            ]
            I[i] = [
                *mean_sterr(self.I[i, :, 0], remove=remove, max=max),
                *mean_sterr(self.I[i, :, 1], remove=remove, max=max)
            ]

        return (SCGF, activeWork, activeWorkForce, activeWorkOri,
                orderParameter, I)
コード例 #8
0
    def corOrderOrder(self,
                      n_max=100,
                      int_max=100,
                      max=None,
                      norm=False,
                      log=False):
        """
        Compute autocorrelations of the fluctuations of the order parameter.

        Parameters
        ----------
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: 100)
        max : int or None
            Maximum value at which to compute the correlation. (default: None)
            NOTE: if max == None, then max = self.frames - 1.
        norm : bool
            Consider the norm of the order parameter rather than its vector
            form. (default: False)
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: True)

        Returns
        -------
        cor : (3, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation.
        """

        if max == None: max = self.frames - 1

        if log: space = logspace
        else: space = linspace

        cor = []
        for tau in space(1, max, n_max):
            time0 = list(
                OrderedDict.fromkeys(
                    np.linspace(self.skip * self.framesWork,
                                self.frames - tau - 1,
                                int_max,
                                endpoint=True,
                                dtype=int)))
            ordersIni = (lambda l: np.array(l) - np.mean(l, axis=0))(list(
                map(lambda t: self.getOrderParameter(t, norm=norm), time0)))
            ordersFin = (lambda l: np.array(l) - np.mean(l, axis=0))(list(
                map(lambda t: self.getOrderParameter(t + tau, norm=norm),
                    time0)))
            orderOrder = list(
                map(lambda x, y: np.dot(x, y), *(ordersIni, ordersFin)))
            cor += [[tau, *mean_sterr(orderOrder)]]

        return np.array(cor)
コード例 #9
0
    def corWorkOrderIns(self,
                        tau0=1,
                        n_max=100,
                        int_max=None,
                        min=None,
                        max=None,
                        log=False):
        """
        Compute correlations of the fluctuations of the order parameter norm
        at a given time and the fluctuations of the active work averaged over
        a time `tau0' at a later time.

        Parameters
        ----------
        tau0 : int
            Number of consecutive individual active works on which to average
            it. (default: 1)
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of disjoint
                     intervals will be considered.
        min : int or None
            Minimum value at which to compute the correlation. (default: None)
            NOTE: if min == None then min = `tau0', otherwise the minimum of
                  `tau0' and `min' is taken.
        max : int or None
            Maximum value at which to compute the correlation. (default: None)
            NOTE: this value is passed as `max' to self.n.
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: True)

        Returns
        -------
        cor : (5, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation,
                (3) standard deviation of the active work,
                (4) standard deviation of the order parameter norm.
        """

        cor = []
        for n in self._n(
                n_max=n_max,
                log=log,
                min=(2 *
                     tau0 if min == None else np.max([tau0 + min, 2 * tau0])),
                max=(None if max == None else tau0 + max)):
            ordersIni = (lambda l: l - np.mean(l))(
                list(
                    map(
                        lambda t: self.getOrderParameter(
                            t, norm=True
                        ),  # fluctuations of the active work averaged between t0 and t0 + tau0
                        self._time0(n, int_max=int_max))))
            worksFin = (lambda l: l - np.mean(l))(
                list(
                    map(
                        lambda t: self.workArray[t + n - tau0:t + n].mean(
                        ),  # fluctuations of the active work averaged between t0 and t0 + tau0
                        self._time0(n, int_max=int_max))))
            workOrder = ordersIni * worksFin
            cor += [[
                n - tau0, *mean_sterr(workOrder),
                np.std(ordersIni),
                np.std(worksFin)
            ]]

        return np.array(cor)
コード例 #10
0
    def varWorkFromCorWork(self, tau0=1, n=100, int_max=None, bruteForce=True):
        """
        Compute variance of the active work from its "instantaneous"
        fluctuations correlations.

        This function is primarily for consistency testing of
        the correlations functions.

        Parameters
        ----------
        tau0 : int
            Number of consecutive individual active works on which to average
            it, and for which correlations will be computed. (default: 1)
        n : int
            Compute variance for tau = i*tau0 with i in {1, ..., n}.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of intervals will
                  intervals will be considered (joint if bruteForce else
                  disjoint).
        bruteForce : bool
            Use self.corWorkWorkInsBruteForce rather than self.corWorkWorkIns.
            (default: True)

        Returns
        -------
        var : (3, *) numpy array
            Array of:
                (0) value at which the variance is computed,
                (1) mean of the computed variance,
                (2) standard error of the computed variance.
        """

        if bruteForce: corWorkWorkIns = self.corWorkWorkInsBruteForce
        else: corWorkWorkIns = self.corWorkWorkIns

        if bruteForce:
            cor = self.corWorkWorkInsBruteForce(tau0,
                                                n_max=n,
                                                int_max=int_max,
                                                max=n - 1,
                                                log=False)
        else:
            cor = self.corWorkWorkIns(tau0,
                                      n_max=n,
                                      int_max=int_max,
                                      min=tau0,
                                      max=(n - 1) * tau0,
                                      log=False)

        var0 = mean_sterr(
            (lambda l: (l - l.mean())**2)(self.nWork(tau0, int_max=int_max)))

        var = []
        for n0 in range(1, n + 1):
            var += [[n0 * tau0, var0[0] / n0, (var0[1] / n0)**2]]
            for i in range(1, n0):
                var[-1][1] += 2 * (n0 - i) * cor[i - 1, 1] / (n0**2)
                var[-1][2] += (2 * (n0 - i) * cor[i - 1, 2] / (n0**2))**2
            var[-1][2] = np.sqrt(var[-1][2])

        return np.array(var)
コード例 #11
0
    def corWorkWorkInsBruteForce(self,
                                 workPart1=None,
                                 workPart2=None,
                                 tau0=1,
                                 n_max=100,
                                 int_max=None,
                                 max=None,
                                 log=True):
        """
        Compute (cross) correlations of the fluctuations of the work averaged
        over `tau0' between different times.

        This algorithm computes the correlations more quickly by averaging over
        successive couples of initial and final values of the active work.
        Results of this function should then be taken with care as some other
        unwanted low-time correlations could be picked.

        Parameters
        ----------
        workPart1 : string
            Part of the active work to consider at the beginning of the
            interval:
                * 'all': active work,
                * 'force': force part of the active work,
                * 'orientation': orientation part of the active work,
                * 'noise': noise part of the active work.
            (default: None)
            NOTE: if workPart1 == None, then self.workArray is taken.
        workPart2 : string
            Part of the active work to consider at the end of the interval.
            (default: None)
            NOTE: if workPart2 == None, then self.workArray is taken.
        tau0 : int
            Number of consecutive individual active works on which to average
            it. (default: 1)
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of intervals will
                  intervals will be considered.
        max : int or None
            Maximum value at which to compute the correlation in units of tau0.
            (default: None)
            NOTE: if max == None, the maximum number of values is computed.
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: True)

        Returns
        -------
        cor : (3, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation.
        """

        work1 = (self.workArray
                 if workPart1 == None else self.workDict[workPart1])
        work2 = (self.workArray
                 if workPart2 == None else self.workDict[workPart2])

        if log: space = logspace
        else: space = linspace

        if int_max == None: int_max = (self.numberWork - self.skip) // tau0
        Nsample = int(
            np.min([(self.numberWork - self.skip) // tau0, int_max * tau0])
        )  # size of the sample of consecutive normalised rates of active work to consider
        workArray1 = np.array(
            list(
                map(  # array of consecutive normalised rate of active work averaged of time tau0
                    lambda t: work1[self.skip + t * tau0:self.skip + t * tau0 +
                                    tau0].mean(), range(Nsample))))
        workArray1 -= workArray1.mean(
        )  # only considering fluctuations to the mean
        if workPart1 == workPart2: workArray2 = workArray1
        else:
            workArray2 = np.array(
                list(
                    map(  # array of consecutive normalised rate of active work averaged of time tau0
                        lambda t: work2[self.skip + t * tau0:self.skip + t *
                                        tau0 + tau0].mean(), range(Nsample))))
            workArray2 -= workArray2.mean(
            )  # only considering fluctuations to the mean

        lagTimes = space(  # array of lag times considered
            1,
            (Nsample - 1) if max == None else int(np.min([max, Nsample - 1])),
            n_max)

        cor = list(
            map(
                lambda dt: [
                    tau0 * dt, *mean_sterr(
                        (workArray1 * np.roll(workArray2, -dt))[:Nsample - dt])
                ], lagTimes))

        return np.array(cor)
コード例 #12
0
    def corWorkWorkIns(self,
                       workPart1=None,
                       workPart2=None,
                       tau0=1,
                       n_max=100,
                       int_max=None,
                       min=None,
                       max=None,
                       log=True):
        """
        Compute (cross) correlations of the fluctuations of the work averaged
        over `tau0' between different times.

        Parameters
        ----------
        workPart1 : string
            Part of the active work to consider at the beginning of the
            interval:
                * 'all': active work,
                * 'force': force part of the active work,
                * 'orientation': orientation part of the active work,
                * 'noise': noise part of the active work.
            (default: None)
            NOTE: if workPart1 == None, then self.workArray is taken.
        workPart2 : string
            Part of the active work to consider at the end of the interval.
            (default: None)
            NOTE: if workPart2 == None, then self.workArray is taken.
        tau0 : int
            Number of consecutive individual active works on which to average
            it. (default: 1)
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of disjoint
                  intervals will be considered.
        min : int or None
            Minimum value at which to compute the correlation. (default: None)
            NOTE: if min == None then min = `tau0', otherwise the minimum of
                  `tau0' and `min' is taken.
        max : int or None
            Maximum value at which to compute the correlation. (default: None)
            NOTE: this value is passed as `max' to self.n.
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: True)

        Returns
        -------
        cor : (5, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation,
                (3) standard deviation of the active work computed at the
                    beginning of the interval,
                (4) standard deviation of the active work computed at the end
                    of the interval.
        """

        work1 = (self.workArray
                 if workPart1 == None else self.workDict[workPart1])
        work2 = (self.workArray
                 if workPart2 == None else self.workDict[workPart2])

        cor = []
        for n in self._n(
                n_max=n_max,
                log=log,
                min=(2 *
                     tau0 if min == None else np.max([tau0 + min, 2 * tau0])),
                max=(None if max == None else tau0 + max)):
            worksIni = (lambda l: l - np.mean(l))(
                list(
                    map(
                        lambda t: work1[t:t + tau0].mean(
                        ),  # fluctuations of the active work averaged between t0 and t0 + tau0
                        self._time0(n, int_max=int_max))))
            worksFin = (lambda l: l - np.mean(l))(
                list(
                    map(
                        lambda t: work2[t + n - tau0:t + n].mean(
                        ),  # fluctuations of the active work averaged between t0 and t0 + tau0
                        self._time0(n, int_max=int_max))))
            workWork = worksIni * worksFin
            cor += [[
                n - tau0, *mean_sterr(workWork),
                np.std(worksIni),
                np.std(worksFin)
            ]]

        return np.array(cor)
コード例 #13
0
    def corWorkWorkAve(self,
                       tau0=1,
                       n_max=100,
                       int_max=None,
                       min=None,
                       max=None,
                       log=True):
        """
        Compute correlations of the fluctuations of the work averaged over
        `tau0' at the beginning of an interval and the fluctuations of the work
        averaged over the whole interval.

        Parameters
        ----------
        tau0 : int
            Number of consecutive individual active works on which to average
            it. (default: 1)
        n_max : int
            Maximum number of values at which to evaluate the correlation.
            (default: 100)
        int_max : int or None
            Maximum number of different intervals to consider in order to
            compute the mean which appears in the correlation expression.
            (default: None)
            NOTE: if int_max == None, then a maximum number of disjoint
                     intervals will be considered.
        min : int or None
            Minimum value at which to compute the correlation. (default: None)
            NOTE: if min == None then this value is passed as `min' to self.n,
                  otherwise the minimum of `tau0' and `min' is taken.
        max : int or None
            Maximum value at which to compute the correlation. (default: None)
            NOTE: this value is passed as `max' to self.n.
        log : bool
            Logarithmically space values at which the correlations are
            computed. (default: True)

        Returns
        -------
        cor : (5, *) numpy array
            Array of:
                (0) value at which the correlation is computed,
                (1) mean of the computed correlation,
                (2) standard error of the computed correlation,
                (3) standard deviation of the active work computed at the
                    beginning of the interval,
                (4) standard deviation of the active work computed over the
                    interval.
        """

        cor = []
        for n in self._n(n_max=n_max,
                         max=max,
                         log=log,
                         min=(None if min == None else np.max([min, tau0]))):
            worksTot = (lambda l: l - np.mean(l))(
                self.nWork(n, int_max=int_max)
            )  # fluctuations of the active wok on intervals of size n
            worksIni = (lambda l: l - np.mean(l))(
                list(
                    map(
                        lambda t: self.workArray[t:t + tau0].mean(
                        ),  # fluctuations of the active work averaged on tau0 at the beginning of these intervals
                        self._time0(n, int_max=int_max))))
            workWork = worksTot * worksIni
            cor += [[
                n, *mean_sterr(workWork),
                np.std(worksTot),
                np.std(worksIni)
            ]]

        return np.array(cor)