def inside_sub(self, msec): if len(self.subs) == 0: return None idx = utils.bisect(self.subs, lambda x: x[self.COL_SUB].startTime, msec) sub = self.subs[idx][self.COL_SUB] return sub if sub.startTime <= msec <= sub.stopTime else None
def findzero(self,start,end,eshift=0.): ''' find zero point on a path from center point to k. start/end: The start/end point. efunc: Energy function. *return*: The k point at the zero point of energy. ''' resolution=self.resolution tol=self.tol efunc=lambda k:self.efunc(k)-eshift dk=(end-start)*resolution Nmax=int(1./resolution) ei_old=efunc(start) for i in xrange(Nmax): ki=start+dk*(i+1) ei=efunc(ki) if abs(ei)<1e-15: return ki elif ei*ei_old<0: if ei<0: klow,khigh=ki,ki-dk else: klow,khigh=ki-dk,ki return bisect(efunc,klow,khigh,tol=tol)
def absolute_monotonicity_radius(self, acc=1.e-10, rmax=200, tol=3.e-16): r""" Returns the radius of absolute monotonicity of a TSRK method. """ from utils import bisect r = bisect(0, rmax, acc, tol, self.is_absolutely_monotonic) return r
def absolute_monotonicity_radius(self,acc=1.e-10,rmax=200, tol=3.e-16): r""" Returns the radius of absolute monotonicity of a TSRK method. """ from utils import bisect r=bisect(0,rmax,acc,tol,self.is_absolutely_monotonic) return r