diff --git a/tools/evaluation/thesisCoupled.py b/tools/evaluation/thesisCoupled.py index de99d3508a901acf9a2dee994c85bca99ad2039d..17cb29a86c72dd0d6d47ef62f93c6e8afde56ca1 100644 --- a/tools/evaluation/thesisCoupled.py +++ b/tools/evaluation/thesisCoupled.py @@ -85,13 +85,14 @@ def ErrorExtra(case): listEvaluationPoints=[1,2] else: listEvaluationPoints=[1,2,3,4,5,6,7,8,9] - nL=['\\SIOC'] - fL=[fSIOC] + nL=['\\SISVI','\\SIOC','\\GPDE'] + fL=[fSISVI,fSIOC,fGS] savePath='../../../thesis-lindner/thesis/tables/erstmal/coupled/' tabWriter = TableWriter(lL,tL,sdt,endTime,1,[fSIOC],listEvaluationPoints) if case=='Volumes': - tabWriter.writeVolumesExtraError(eP,fL,savePath,nL) + tabWriter.writeVolumesExtraError(eP,fL,savePath,nL,False) + tabWriter.writeVolumesExtraError(eP,fL,savePath,nL,True) else: tabWriter.writeErrorExtraTab(eP,fL,savePath,nL,case) diff --git a/tools/evaluation/utility/computing.py b/tools/evaluation/utility/computing.py index 7aaa05a4e9920ac1ca312f8a5cec52d00f6db1f2..2d78a2c4f0dab6a51c321cc3e66e1ef16b9f9aba 100644 --- a/tools/evaluation/utility/computing.py +++ b/tools/evaluation/utility/computing.py @@ -191,7 +191,7 @@ def getGTact(j,l,m,p,path,th,case): return g def getFTact(j,l,m,p,path,th,case): - tact_l=read.getActivaitionTimeFromLog(l,j,m, path, p,th,case) + tact_l=read.getActivaitionTimeFromLog(l,j,m, path, p,th,False,case) tact_lMinusOne=read.getActivaitionTimeFromLog(l-1,j,m, path, p,th,False,case) tact_lMinusTwo=read.getActivaitionTimeFromLog(l-2,j,m, path, p,th,False,case) #print(tact_l,tact_lMinusOne,tact_lMinusTwo) @@ -217,7 +217,6 @@ def getTactExtrapolateInTime(l,j,m,p,path,th,case): return T_ex def getTextFullExtrapolate(L,J,m,p,path,th,case=''): T_ex=-10.0 - tact_JEx = getTactExtrapolateInSpace(L,J,m,p,path,th,case) tact_JMinusOneEx = getTactExtrapolateInSpace(L,J-1,m,p,path,th,case) @@ -820,10 +819,12 @@ def computeMeanTact(p,pathLevel0): print('in compute',tact) return tact def getTactPerCase(t,V,th,case,withNearest=False): - if case!='Gamma': + if case=='Ca' or case=='': return getActivaitionTimeFromVWithID(t,V,th,withNearest) - else: + elif case=='Gamma' or case=='Volumes': return getActivaitionTimeFromGammaWithID(t,V,th,withNearest) + else: + print('comp.getTactPerCase: case not defined') def getActivaitionTimeFromVWithID(t,V,th,withNearest=False): value=-10.0 diff --git a/tools/evaluation/utility/latexTables.py b/tools/evaluation/utility/latexTables.py index 45aba0ede5d0099b2fdb872c5bd0ceeb9a3cc568..a780bdc144e9cff8acc0fb3314ac551e898dda48 100644 --- a/tools/evaluation/utility/latexTables.py +++ b/tools/evaluation/utility/latexTables.py @@ -3,6 +3,7 @@ from utility import computing as comp import matplotlib.pyplot as plt import math from decimal import Decimal +import numpy as np durEvalActi=0.4 class Table: @@ -2054,12 +2055,12 @@ class Table: block+='|c' block+='}\n' return block - def writeExtraErrorVolumes(self,fL,nL): + def writeExtraErrorVolumes(self,fL,nL,inInt): block = '' - + th=[135.0,150.0] length=len(fL)*2+2 block+=self.BeginDifferenceTable(length,'c') - block+='\\multicolumn{2}{c}{}'+'&\\multicolumn{'+str(len(fL))+'}{c}{ $\\errorLV^{j,\ell,}$}'+'& &\\multicolumn{'+str(len(fL))+'}{c}{ $\\errorRV^{j,\ell}$}'+'\\\\\n' + block+='\\multicolumn{2}{c}{}'+'&\\multicolumn{'+str(len(fL))+'}{c}{ $\\errorLV^{j,\ell}$}'+'& &\\multicolumn{'+str(len(fL))+'}{c}{ $\\errorRV^{j,\ell}$}'+'\\\\\n' block+='\cmidrule(lr){3-'+str(len(fL)+2)+'}\n' block+='\cmidrule(l){'+str(len(fL)+4)+'-'+str(2*len(fL)+3)+'}\n' block+='\\multicolumn{2}{c}{}' @@ -2075,11 +2076,22 @@ class Table: block+='\cmidrule(l){'+str(len(fL)+4)+'-'+str(2*len(fL)+3)+'}\n' #Extrapolates - LV_ref=comp.getFullExtrapolate(self.lL[-1],self.tL[-1],self.m,1,self.sdt,self.T,self.exP,'Volumes') + LV_ref=[] + RV_ref=[] + t=[] + if inInt: + tact_ref=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,1,self.exP,th[0],'Volumes') + (t,LV_ref)=comp.getVIntFullExtrapolate(self.lL[-1],self.tL[-1],1,1,self.exP,self.sdt,th[0],durEvalActi,tact_ref,'Volumes') + tact_ref=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,2,self.exP,th[1],'Volumes') + (t,RV_ref)=comp.getVIntFullExtrapolate(self.lL[-1],self.tL[-1],1,2,self.exP,self.sdt,th[1],durEvalActi,tact_ref,'Volumes') + + else: + LV_ref=comp.getFullExtrapolate(self.lL[-1],self.tL[-1],self.m,1,self.sdt,self.T,self.exP,'Volumes') + RV_ref=comp.getFullExtrapolate(self.lL[-1],self.tL[-1],self.m,2,self.sdt,self.T,self.exP,'Volumes') + + #plt.plot(t,RV_ref,label='ref',linewidth=2.5) normLV_ref=comp.L2(LV_ref,self.sdt,self.T,self.tL[-2],False) - RV_ref=comp.getFullExtrapolate(self.lL[-1],self.tL[-1],self.m,2,self.sdt,self.T,self.exP,'Volumes') normRV_ref=comp.L2(RV_ref,self.sdt,self.T,self.tL[-2],False) - for l in self.lL: block+='$\\ell='+str(l)+'$' for j in self.tL: @@ -2087,8 +2099,14 @@ class Table: standardlength=int(round(self.T/(self.sdt*2**(-j))))+1 for alg in fL: (t,V)=read.getDataFromTXT(alg,read.createFilename(l,j,self.m)+'Volumes',1) - if len(t)==standardlength or len(t)==standardlength-1: - value=comp.L2DiffInterval(V,LV_ref,self.sdt,j,self.tL[-2]) + if len(t)==standardlength: + value=0.0 + if inInt: + (tact,id_tact)=comp.getTactPerCase(t,V,th[0],'Volumes',True) + id_dur=self.getTimeID(id_tact,j) + value=comp.L2DiffInterval(V[id_tact:id_dur],LV_ref,self.sdt,j,self.tL[-2]) + else: + value=comp.L2DiffInterval(V,LV_ref,self.sdt,j,self.tL[-2]) value=value/normLV_ref block += " & $"+ str("%8.4f"%(value))+"$" else: @@ -2096,8 +2114,18 @@ class Table: block+='& ' for alg in fL: (t,V)=read.getDataFromTXT(alg,read.createFilename(l,j,self.m)+'Volumes',2) - if len(t)==standardlength or len(t)==standardlength-1: - value=comp.L2DiffInterval(V,RV_ref,self.sdt,j,self.tL[-2]) + if len(t)==standardlength : + value=0.0 + if inInt: + (tact,id_tact)=comp.getTactPerCase(t,V,th[1],'Volumes',True) + id_dur=self.getTimeID(id_tact,j) + value=comp.L2DiffInterval(V[id_tact:id_dur],RV_ref,self.sdt,j,self.tL[-2]) + if l==4: + for time in t: + time-=tact + plt.plot(t[id_tact:id_dur],V[id_tact:id_dur],label='j='+str(j),linewidth=2.5) + else: + value=comp.L2DiffInterval(V,RV_ref,self.sdt,j,self.tL[-2]) value=value/normRV_ref block += " & $"+ str("%8.4f"%(value))+"$" else: @@ -2107,7 +2135,8 @@ class Table: block+='\cmidrule(r){1-2}\n' block+='\cmidrule(lr){3-'+str(len(fL)+2)+'}\n' block+='\cmidrule(l){'+str(len(fL)+4)+'-'+str(2*len(fL)+3)+'}\n' - + plt.legend() + plt.show() block+='\\bottomrule\n' block +=self.EndTabular() return block @@ -2961,14 +2990,19 @@ class TableWriter: output_file.write(self.tab.writeBeginApproxAndDurationTabList(p,cap,label,fN,False)) output_file.write(self.tab.writeExtraErrorTab(fN,nL,p,case)) output_file.write(self.tab.writeEndTable()) - def writeVolumesExtraError(self,path,fN,savePath,nL): - cap='Der Fehler $\\errorLV^{j,\ell}$ bzw. $\\errorRV^{j,\ell}$ der Näherungslösungen bezüglich der Orts-Zeit-Grenzwertlösung $\\LV'+'^{\\infty,\\infty,}$ bzw. $\\RV'+'^{\\infty,\\infty,}$ in der $\\LtwonormT$-Norm auf dem biventrikulären Gebiet' - label ='tab:ErrorVolumes' - filename=savePath +'ErrorVolumes' + def writeVolumesExtraError(self,path,fN,savePath,nL,inInt): + if inInt: + cap='Der Fehler $\\errorLV^{j,\ell}$ bzw. $\\errorRV^{j,\ell}$ der Näherungslösungen bezüglich der Orts-Zeit-Grenzwertlösung $\\LV'+'^{\\infty,\\infty,}$ bzw. $\\RV'+'^{\\infty,\\infty,}$ in der $\\LtwonormAct$-Norm auf dem biventrikulären Gebiet' + label ='tab:ErrorActVolumes' + filename=savePath +'ErrorActVolumes' + else: + cap='Der Fehler $\\errorLV^{j,\ell}$ bzw. $\\errorRV^{j,\ell}$ der Näherungslösungen bezüglich der Orts-Zeit-Grenzwertlösung $\\LV'+'^{\\infty,\\infty,}$ bzw. $\\RV'+'^{\\infty,\\infty,}$ in der $\\LtwonormT$-Norm auf dem biventrikulären Gebiet' + label ='tab:ErrorVolumes' + filename=savePath +'ErrorVolumes' with open(filename+'.tex', 'w') as output_file: output_file.write(self.tab.writeBeginTable('h')) output_file.write(self.tab.writeCaption(cap, label)) - output_file.write(self.tab.writeExtraErrorVolumes(fN,nL)) + output_file.write(self.tab.writeExtraErrorVolumes(fN,nL,inInt)) output_file.write(self.tab.writeEndTable()) def writeErrorExtraVIntTab(self,path,fN,savePath,nL,threshold,case=''): diff --git a/tools/evaluation/utility/reading.py b/tools/evaluation/utility/reading.py index 098d101660a427d0f4f851b8dc1381d466f3b5af..c017bbbcd817964cbb31dbce7df0d2fffc02f59e 100644 --- a/tools/evaluation/utility/reading.py +++ b/tools/evaluation/utility/reading.py @@ -1132,10 +1132,12 @@ def writeIDLists(lL,tL,path): def getActivaitionTimeFromLog(l,j,m, path, p,th, withNearest=False,case=''): (t,V)=getDataFromTXT(path,createFilename(l,j,m)+case,p) tact=-10.0 - if case!='Gamma': + if case=='Ca' or case=='': tact=comp.getActivaitionTimeFromV(t,V,th,withNearest) - else: + elif case=='Gamma' or case=='Volumes': tact=comp.getActivaitionTimeFromGamma(t,V,th,withNearest) + else: + print('read.getActivaitionTimeFromLog: case not defined') return tact