def _set_heat_capacity_P_polyfit(self):
    cp = [0.0]
    dsdv = [0.0]
    self._volume_entropy_parameters = []
    self._volume_cv_parameters = []
    self._volume_entropy = []
    self._volume_cv = []
    for j in range(1, (self._num_elems - 1)):
        t = self._temperatures[j]
        x = self._equiv_volumes[j]
        try:
            parameters = np.polyfit(self._volumes, self._cv[j], 4)
        except np.lib.polynomial.RankWarning:
            msg = ['Failed to fit heat capacities to polynomial of degree 4.']
            if (len(self._volumes) < 5):
                msg += ['At least 5 volume points are needed for the fitting.']
            raise RuntimeError('\n'.join(msg))
        cv_p = np.dot(parameters, np.array([(x ** 4), (x ** 3), (x ** 2), x, 1]))
        self._volume_cv_parameters.append(parameters)
        try:
            parameters = np.polyfit(self._volumes, self._entropy[j], 4)
        except np.lib.polynomial.RankWarning:
            msg = ['Failed to fit entropies to polynomial of degree 4.']
            if (len(self._volumes) < 5):
                msg += ['At least 5 volume points are needed for the fitting.']
            raise RuntimeError('\n'.join(msg))
        dsdv_t = np.dot(parameters[:4], np.array([(4 * (x ** 3)), (3 * (x ** 2)), (2 * x), 1]))
        self._volume_entropy_parameters.append(parameters)
        try:
            parameters = np.polyfit(self._temperatures[(j - 1):(j + 2)], self._equiv_volumes[(j - 1):(j + 2)], 2)
        except np.lib.polynomial.RankWarning:
            msg = 'Failed to fit equilibrium volumes vs T to polynomial of degree 2.'
            raise RuntimeError(msg)
        dvdt = (((parameters[0] * 2) * t) + parameters[1])
        cp.append((cv_p + ((t * dvdt) * dsdv_t)))
        dsdv.append(dsdv_t)
        self._volume_cv.append(np.array([self._volumes, self._cv[j]]).T)
        self._volume_entropy.append(np.array([self._volumes, self._entropy[j]]).T)
    self._cp_polyfit = cp
    self._dsdv = dsdv
def _set_heat_capacity_P_polyfit(self):
    cp = [0.0]
    dsdv = [0.0]
    self._volume_entropy_parameters = []
    self._volume_cv_parameters = []
    self._volume_entropy = []
    self._volume_cv = []
    for j in range(1, (self._num_elems - 1)):
        t = self._temperatures[j]
        x = self._equiv_volumes[j]
        try:
            parameters = np.polyfit(self._volumes, self._cv[j], 4)
        except np.lib.polynomial.RankWarning:
            msg = ['Failed to fit heat capacities to polynomial of degree 4.']
            if (len(self._volumes) < 5):
                msg += ['At least 5 volume points are needed for the fitting.']
            raise RuntimeError('\n'.join(msg))
        cv_p = np.dot(parameters, np.array([(x ** 4), (x ** 3), (x ** 2), x, 1]))
        self._volume_cv_parameters.append(parameters)
        try:
            parameters = np.polyfit(self._volumes, self._entropy[j], 4)
        except np.lib.polynomial.RankWarning:
            msg = ['Failed to fit entropies to polynomial of degree 4.']
            if (len(self._volumes) < 5):
                msg += ['At least 5 volume points are needed for the fitting.']
            raise RuntimeError('\n'.join(msg))
        dsdv_t = np.dot(parameters[:4], np.array([(4 * (x ** 3)), (3 * (x ** 2)), (2 * x), 1]))
        self._volume_entropy_parameters.append(parameters)
        try:
            parameters = np.polyfit(self._temperatures[(j - 1):(j + 2)], self._equiv_volumes[(j - 1):(j + 2)], 2)
        except np.lib.polynomial.RankWarning:
            msg = 'Failed to fit equilibrium volumes vs T to polynomial of degree 2.'
            raise RuntimeError(msg)
        dvdt = (((parameters[0] * 2) * t) + parameters[1])
        cp.append((cv_p + ((t * dvdt) * dsdv_t)))
        dsdv.append(dsdv_t)
        self._volume_cv.append(np.array([self._volumes, self._cv[j]]).T)
        self._volume_entropy.append(np.array([self._volumes, self._entropy[j]]).T)
    self._cp_polyfit = cp
    self._dsdv = dsdv