def ReIter2(self,FT): [a,b]=ipVar.poptDir(self.RePath); z=np.where(np.diff(np.sign(a)))[0]; r1=b[z[0]];r2=b[z[0]+1]; while(abs(r1-r2)>11): [a,b]=ipVar.poptDir(self.RePath); ReCr=funcs.calcReC(a,b); self.ReList.append(ReCr+5); self.ReList.append(ReCr-5); self.CritRe(FT); [a,b]=ipVar.poptDir(self.RePath); ReCr=funcs.calcReC(a,b); z=np.where(np.diff(np.sign(a)))[0]; r1=b[z[0]];r2=b[z[0]+1]; if(abs(r1-r2)< 11): [a,b]=ipVar.poptDir(self.RePath); ReCr=funcs.calcReC(a,b); self.ReList.append(ReCr); self.CritRe(FT); [a,b]=ipVar.poptDir(self.RePath); if(len(a)>3):func=InterpolatedUnivariateSpline(b,a,k=3); ReC=func.roots(); return ReC;
def ReIter2(self, FT): [a, b] = ipVar.poptDir(self.RePath) z = np.where(np.diff(np.sign(a)))[0] r1 = b[z[0]] r2 = b[z[0] + 1] while (abs(r1 - r2) > 11): [a, b] = ipVar.poptDir(self.RePath) ReCr = funcs.calcReC(a, b) self.ReList.append(ReCr + 5) self.ReList.append(ReCr - 5) self.CritRe(FT) [a, b] = ipVar.poptDir(self.RePath) ReCr = funcs.calcReC(a, b) z = np.where(np.diff(np.sign(a)))[0] r1 = b[z[0]] r2 = b[z[0] + 1] if (abs(r1 - r2) < 11): [a, b] = ipVar.poptDir(self.RePath) ReCr = funcs.calcReC(a, b) self.ReList.append(ReCr) self.CritRe(FT) [a, b] = ipVar.poptDir(self.RePath) if (len(a) > 3): func = InterpolatedUnivariateSpline(b, a, k=3) ReC = func.roots() return ReC
def Re100(self, N, time): self.ReList = [] [a, b] = ipVar.poptFile(os.getcwd()) xx = (i for i in range(0, len(a)) if a[i] > 0).next() self.ReList.append(abs(b[xx] - 100)) para = [ 0.005, 150, '2*FinalTime/TimeStep', '', '', self.beta, '', '0.2/TimeStep', str(np.pi / self.alpha) + ' 0 0 ', '0.5' ] self.CritRe2(para) self.ReList = [] re = funcs.calcReC(a, b) a = np.floor(re / 1000) * 1000 b = np.ceil(re / 1000) * 1000 c = (b - a) / N c = int(c) for i in range(1, N): self.ReList.append(int(a + i * c)) para = [ 0.005, time, '2*FinalTime/TimeStep', '', '', self.beta, '', '0.2/TimeStep', str(np.pi / self.alpha) + ' 0 0 ', '0.5' ] self.CritRe2(para)
def Re10(self, N, time): self.ReList = [] [a, b] = ipVar.poptFile(os.getcwd()) xx = [] for i in range(0, len(a) - 1): if (a[i] * a[i + 1] < 0): xx.append(i) if (len(xx) > 2): self.ReList.append(b[xx[1]] + 10) self.ReList.append(abs(b[xx[1]] - 10)) self.ReList.append(b[xx[2]] + 10) self.ReList.append(abs(b[xx[2]] - 10)) para = [ 0.005, 150, '2*FinalTime/TimeStep', '', '', self.beta, '', '0.2/TimeStep', str(np.pi / self.alpha) + ' 0 0 ', '0.5' ] self.CritRe2(para) self.ReList = [] [a, b] = ipVar.poptFile(os.getcwd()) re = funcs.calcReC(a, b) a = np.floor(re / 100) * 100 b = np.ceil(re / 100) * 100 c = (b - a) / N c = int(c) for i in range(1, N): self.ReList.append(int(a + i * c)) para = [ 0.005, time, '2*FinalTime/TimeStep', '', '', self.beta, '', '0.2/TimeStep', str(np.pi / self.alpha) + ' 0 0 ', '1' ] self.CritRe2(para)
def Re10(self,N,time): self.ReList=[]; [a,b]=ipVar.poptFile(os.getcwd()); xx=[]; for i in range(0,len(a)-1): if(a[i]*a[i+1] < 0):xx.append(i); if(len(xx) >2): self.ReList.append(b[xx[1]]+10); self.ReList.append(abs(b[xx[1]]-10)); self.ReList.append(b[xx[2]]+10); self.ReList.append(abs(b[xx[2]]-10)); para=[0.005,150,'2*FinalTime/TimeStep','','',self.beta,'','2*FinalTime/TimeStep',str(np.pi/self.alpha)+' 0 0 ','0.5']; self.CritRe2(para); self.ReList=[]; [a,b]=ipVar.poptFile(os.getcwd()); re=funcs.calcReC(a,b); a=np.floor(re/100)*100; b=np.ceil(re/100)*100; c=(b-a)/N; c=int(c); for i in range(1,N): self.ReList.append(int(a+i*c)); para=[0.005,time,'2*FinalTime/TimeStep','','',self.beta,'','2*FinalTime/TimeStep',str(np.pi/self.alpha)+' 0 0 ','1']; self.CritRe2(para);
def ReFinal2(self,time): [a,b]=ipVar.poptFile(os.getcwd()); re=funcs.calcReC(a,b); self.ReList=[]; self.ReList.append(re); para=[0.005,time,'0.1*FinalTime/TimeStep','','',self.beta,'','2*FinalTime/TimeStep',str(np.pi/self.alpha)+' 0 0 ','1']; self.CritRe2(para);
def ReIter(self): [a, b] = ipVar.poptDir(self.RePath) z = np.where(np.diff(np.sign(a)))[0] i = z[0] r1 = b[i] r2 = b[i + 1] print(r1) print(r2) print("the value of the ") while (abs(r1 - r2) > 20): self.ReList = [] ReCr = funcs.calcReC(a, b) self.ReList.append(ReCr + 0.3 * abs(r1 - r2)) self.ReList.append(ReCr - 0.3 * abs(r1 - r2)) self.CritRe() print(r1) print(r2) [a, b] = ipVar.poptDir(self.RePath) z = np.where(np.diff(np.sign(a)))[0] r1 = b[z[0]] r2 = b[z[0] + 1] [a, b] = ipVar.poptDir(self.RePath) if (len(a) > 3): func = InterpolatedUnivariateSpline(b, a, k=3) ReC = func.roots() return ReC
def ReFinal2(self,time): [a,b]=ipVar.poptFile(os.getcwd()); re=funcs.calcReC(a,b); re=int(re); self.ReList=[]; self.ReList.append(re); para=[0.005,time,'0.1*FinalTime/TimeStep','','',self.beta,'','0.2/TimeStep',str(np.pi/self.alpha)+' 0 0 ','1']; self.CritRe2(para);
def ReIter(self, FT): [a, b] = ipVar.poptDir(self.RePath) while (all(i > 0 for i in a)): self.ReList = [] ReNew = float(b[0]) - 0.2 * float(b[0]) self.ReList.append(ReNew) self.CritRe(FT) [a, b] = ipVar.poptDir(self.RePath) while (all(i < 0 for i in a)): self.ReList = [] ReNew = float(b[-1]) + 0.3 * float(b[-1]) self.ReList.append(ReNew) self.CritRe(FT) [a, b] = ipVar.poptDir(self.RePath) [a, b] = ipVar.poptDir(self.RePath) z = np.where(np.diff(np.sign(a)))[0] i = z[0] r1 = b[i] r2 = b[i + 1] print(r1) print(r2) print("the value of the ") temp = [0] ReCr = funcs.calcReC(a, b) temp.append(ReCr) while (abs(temp[-1] - temp[-2]) > 1): self.ReList = [] ReCr = funcs.calcReC(a, b) self.ReList.append(ReCr + 0.1 * abs(r1 - r2)) self.ReList.append(ReCr - 0.1 * abs(r1 - r2)) self.CritRe(FT) print(r1) print(r2) ReCr = funcs.calcReC(a, b) temp.append(ReCr) [a, b] = ipVar.poptDir(self.RePath) z = np.where(np.diff(np.sign(a)))[0] r1 = b[z[0]] r2 = b[z[0] + 1] [a, b] = ipVar.poptDir(self.RePath) if (len(a) > 3): func = InterpolatedUnivariateSpline(b, a, k=3) ReC = func.roots() return ReC
def ReIter(self,FT): [a,b]=ipVar.poptDir(self.RePath); while(all(i > 0 for i in a)): self.ReList=[]; ReNew=float(b[0])- 0.2*float(b[0]); self.ReList.append(ReNew); self.CritRe(FT); [a,b]=ipVar.poptDir(self.RePath); while(all(i < 0 for i in a)): self.ReList=[]; ReNew=float(b[-1])+0.3*float(b[-1]); self.ReList.append(ReNew); self.CritRe(FT); [a,b]=ipVar.poptDir(self.RePath); [a,b]=ipVar.poptDir(self.RePath); z=np.where(np.diff(np.sign(a)))[0]; i=z[0]; r1=b[i];r2=b[i+1]; print(r1);print(r2); print("the value of the "); temp=[0]; ReCr=funcs.calcReC(a,b); temp.append(ReCr); while(abs(temp[-1]-temp[-2])>1): self.ReList=[]; ReCr=funcs.calcReC(a,b); self.ReList.append(ReCr+0.1*abs(r1-r2)); self.ReList.append(ReCr-0.1*abs(r1-r2)); self.CritRe(FT); print(r1);print(r2); ReCr=funcs.calcReC(a,b); temp.append(ReCr); [a,b]=ipVar.poptDir(self.RePath); z=np.where(np.diff(np.sign(a)))[0]; r1=b[z[0]];r2=b[z[0]+1]; [a,b]=ipVar.poptDir(self.RePath); if(len(a)>3):func=InterpolatedUnivariateSpline(b,a,k=3); ReC=func.roots(); return ReC;
def ReFinal(self): [a,b]=ipVar.poptFile(os.getcwd()); re=funcs.calcReC(a,b); re=int(re); self.ReList=[]; self.ReList.append(re); path=os.getcwd(); if not os.path.exists(str(re)): os.makedirs(str(re)); os.chdir(str(re)); para=[0.005,400,'0.1*FinalTime/TimeStep','','',self.beta,'','0.2/TimeStep',str(np.pi/self.alpha)+' 0 0 ','1']; funcs.CopyFile(path,os.getcwd(),self.FileList); self.CritRe2(para);
def ReSmooth(self, time, incre): [a, b] = ipVar.poptFile(os.getcwd()) re = funcs.calcReC(a, b) self.ReList = [] self.ReList.append(re) self.ReList.append(re + incre) self.ReList.append(re - incre) para = [ 0.005, time, '2*FinalTime/TimeStep', '', '', self.beta, '', '2*FinalTime/TimeStep', str(np.pi / self.alpha) + ' 0 0 ', '1' ] self.CritRe2(para)
def ReFinal(self, time): [a, b] = ipVar.poptFile(os.getcwd()) re = funcs.calcReC(a, b) re = int(re) self.ReList = [] self.ReList.append(re) path = os.getcwd() if not os.path.exists(str(re)): os.makedirs(str(re)) os.chdir(str(re)) para = [ 0.005, time, '2*FinalTime/TimeStep', '', '', self.beta, '', '2*FinalTime/TimeStep', str(np.pi / self.alpha) + ' 0 0 ', '1' ] funcs.CopyFile(path, os.getcwd(), self.FileList) self.CritRe2(para)
def Re100(self,N,time): self.ReList=[]; [a,b]=ipVar.poptFile(os.getcwd()); xx=(i for i in range(0,len(a)) if a[i] > 0 ).next(); self.ReList.append(abs(b[xx]-100)); para=[0.005,150,'2*FinalTime/TimeStep','','',self.beta,'','2*FinalTime/TimeStep',str(np.pi/self.alpha)+' 0 0 ','0.5']; self.CritRe2(para); self.ReList=[]; re=funcs.calcReC(a,b); a=np.floor(re/1000)*1000; b=np.ceil(re/1000)*1000; c=(b-a)/N; c=int(c); for i in range(1,N): self.ReList.append(int(a+i*c)); para=[0.005,time,'2*FinalTime/TimeStep','','',self.beta,'','2*FinalTime/TimeStep',str(np.pi/self.alpha)+' 0 0 ','0.5']; self.CritRe2(para);
def nsFile(path): os.chdir(path) col=color.color(); cwd=path; p1=glob("*/"); aa=[];bb=[];cc=[];dd=[];ee=[]; for i in p1: try: [a,b]=poptFile(cwd+'/'+i); except: os.chdir(cwd); continue; try: c=funcs.calcReC(a,b); if(c>0): bb.append(c); aa.append(float(i.split('/')[0])); except: args='The Critical Reynolds can not be found for '+i; print col.YELLOW + args+ col.END; cc.append(float(i.split('/')[0])); dd.append(a); ee.append(b); continue; os.chdir(cwd); l2, l1 = zip(*sorted(zip(aa, bb))); l2=list(l2);l1=list(l1); c=(l2,l1) c=np.asarray(c); sVal=cwd.split('/')[-1]; alpha=cwd.split('/')[-2]; np.savetxt('ns-'+sVal+'-'+alpha+'-.txt',c.T); print(col.DARKCYAN+'The Critical Reynolds can not be found for '+str(cc)+col.END); print(col.CYAN+'The corresponding growth rates \t'+col.END); print(col.PURPLE+'Reynolds Number '+col.END); for i in range(0,len(dd)): c=(dd[i],ee[i]); c=np.asarray(c); print(col.CYAN+str(c.T[:,0])+col.END); print(col.PURPLE+str(c.T[:,1])+col.END); return l2, l1;
def ReIter(self): [a,b]=ipVar.poptDir(self.RePath); z=np.where(np.diff(np.sign(a)))[0]; i=z[0]; r1=b[i];r2=b[i+1]; print(r1);print(r2); print("the value of the "); while(abs(r1-r2)>20): self.ReList=[]; ReCr=funcs.calcReC(a,b); self.ReList.append(ReCr+0.3*abs(r1-r2)); self.ReList.append(ReCr-0.3*abs(r1-r2)); self.CritRe(); print(r1);print(r2); [a,b]=ipVar.poptDir(self.RePath); z=np.where(np.diff(np.sign(a)))[0]; r1=b[z[0]];r2=b[z[0]+1]; [a,b]=ipVar.poptDir(self.RePath); if(len(a)>3):func=InterpolatedUnivariateSpline(b,a,k=3); ReC=func.roots(); return ReC;