def dgradV_dT(self, X, T): """ Find the derivative of the gradient with respect to temperature. This is useful when trying to follow the minima of the potential as they move with temperature. """ T_eps = self.T_eps try: gradVT = self._gradVT except: # Create the gradient function self._gradVT = helper_functions.gradientFunction( self.V1T_from_X, self.x_eps, self.Ndim, self.deriv_order) gradVT = self._gradVT # Need to add extra axes to T since extra axes get added to X in # the helper function. T = np.asanyarray(T)[...,np.newaxis,np.newaxis] assert (self.deriv_order == 2 or self.deriv_order == 4) if self.deriv_order == 2: y = gradVT(X,T+T_eps,False) - gradVT(X,T-T_eps,False) y *= 1./(2*T_eps) else: y = gradVT(X,T-2*T_eps,False) y -= 8*gradVT(X,T-T_eps,False) y += 8*gradVT(X,T+T_eps,False) y -= gradVT(X,T+2*T_eps,False) y *= 1./(12*T_eps) return y
def gradV(self, X, T): """ Find the gradient of the full effective potential. This uses :func:`helper_functions.gradientFunction` to calculate the gradient using finite differences, with differences given by `self.x_eps`. Note that `self.x_eps` is only used directly the first time this function is called, so subsequently changing it will not have an effect. """ try: f = self._gradV except: # Create the gradient function self._gradV = helper_functions.gradientFunction( self.Vtot, self.x_eps, self.Ndim, self.deriv_order) f = self._gradV # Need to add extra axes to T since extra axes get added to X in # the helper function. T = np.asanyarray(T)[...,np.newaxis,np.newaxis] return f(X,T,False)