In [16]:
# import stuff
import sys,os
import numpy as np
%load_ext autoreload
%autoreload 2
sys.path.append( os.environ["PYTHONSCRIPT_DIR"] )
import matplotlib as mpl
import PlotSettings as pS
pS.loadPlotSettings(mpl)
dLineSettings = pS.defaultLineSettings
dMarkerSize = pS.defaultMarkerSize
from Tools.Parsers.Utilities import parseNDArray
sys.path.append( os.environ["HPCJOBCONFIGURATOR_DIR"])
from JobGenerator.jobGenerators.commonFunctions import CommonFunctions as cf
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import matplotlib.colors as colors
from skimage.io import imread
from skimage.filters import *
from skimage.morphology import *
from skimage import data
from skimage import img_as_float
from skimage.morphology import disk
#GUi shit
%matplotlib tk
# Import General Packages from me
from Tools.Parsers import *
from Tools.BoundingBox import *
In [17]:
def plotDataIteration(simDataIteration,dataRange=[0,1e5],steps=100, plotOpts={'color':'r','marker':'.' }):
#plot first residual
iterationDataTime = simDataIteration[0];
#clamp
dataRange[0] = min(np.shape(iterationDataTime)[0]-1, max(0,dataRange[0]) )
dataRange[1] = max(0,min(np.shape(iterationDataTime)[0]-1,dataRange[1]))
if(dataRange[1]<dataRange[0]):
dataRange[1]=dataRange[0]
print('DataRange:', dataRange)
nth = int((dataRange[1]-dataRange[0]) / steps);
if(nth<=1.0):
nth = 1;
iterationCounter = np.arange(dataRange[0],dataRange[1]+1,nth,dtype=int)
#print(iterationCounter)
print("Orig. Iterations: ", np.shape(iterationDataTime))
#iterationDataTime2 = iterationDataTime[dataRange[0]:dataRange[1]:nth]
print("Clamped Iterations: ", np.shape(iterationCounter))
plt.semilogy(iterationCounter,iterationDataTime[iterationCounter],**plotOpts)
In [18]:
plt.close('all')
scriptpath = "./"
# Add the directory containing your module to the Python path (wants absolute paths)
sys.path.append(os.path.abspath(scriptpath))
from Tools.Parsers.SimFileReader import *
bodyRange = [0,3]
timeRange = [0,50]
def genOpts(color,linestyle='-'):
pltOpt = {'color':color,
'linestyle':linestyle,
# 'marker':'.',
# 'markersize': 2,
# 'markeredgewidth': 0,
# 'markeredgecolor':'none',
'linewidth':1}
legOpt = {'linewidth':2,
'color':color,
'linestyle':linestyle}
return (pltOpt,legOpt);
#First Plot
fig = plt.figure()
plt.title("AlartCurnier vs DeSaxe, $t$=0.7s, 7500 Spheres"+"\n"+r"Term. Crit: InLambda, $\mathbf{R}_{inv}=max$");
legendArtists=[];
legendTitles=[];
folderNumber=0
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=0.5,\alpha=0.7$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=1
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=0.7$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=2
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=0.5,\alpha=1.4$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=3
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1.4$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
plt.gca().legend(legendArtists,legendTitles)
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. residual $\| x^{k+1} -x^k\|$ in $\lambda$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
# plt.savefig('ResidualPlot_7500_InLambda.pdf')
In [19]:
#First Plot
fig = plt.figure()
plt.title("AlartCurnier vs DeSaxe, $t$=0.7s, 7500 Spheres"+"\n"+r"Term. Crit: InLambda, $\mathbf{R}_{inv}=max$");
legendArtists=[];
legendTitles=[];
folderNumber=6
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=1.5,\alpha=0.5$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=7
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=1.5,\alpha=0.5$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=5
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=1.5,\alpha=1$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
plt.gca().legend(legendArtists,legendTitles)
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. residual $\| x^{k+1} -x^k\|$ in $\lambda$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
# plt.savefig('ResidualPlot1Velocity.pdf')
In [20]:
#First Plot
fig = plt.figure()
plt.title("AlartCurnier vs DeSaxe, $t$=0.7s, 7500 Spheres"+"\n"+r"Term. Crit: InVelocityEnergy, $AbsTol,RelTol=10^{-6}$, $\mathbf{R}_{inv}=max$ ");
legendArtists=[];
legendTitles=[];
folderNumber=8
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=0.5,\alpha=1$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=9
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
plt.gca().legend(legendArtists,legendTitles)
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. residual $\| x^{k+1} -x^k\|$ in $\lambda$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
# plt.savefig('ResidualPlot1Velocity.pdf')
In [21]:
#First Plot
fig = plt.figure()
plt.title("AlartCurnier vs DeSaxe, $t$=0.7s, 7500 Spheres"+"\n"+r"Term. Crit: InVelocityEnergy, $AbsTol,RelTol=10^{-9}$, $\mathbf{R}_{inv}=max$ ");
legendArtists=[];
legendTitles=[];
folderNumber=10
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=0.5,\alpha=1$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=11
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=13
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1.2$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=12
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('g','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1.5$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
plt.gca().legend(legendArtists,legendTitles)
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. residual $\| x^{k+1} -x^k\|$ in $\lambda$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
# plt.savefig('ResidualPlot1Velocity.pdf')
In [22]:
#First Plot
fig = plt.figure()
plt.title("AlartCurnier vs DeSaxe, $t=0.7s$, 7500 Spheres"+"\n"+r"Term. Crit: InVelocityEnergy, $AbsTol,RelTol=10^{-9}$");
legendArtists=[];
legendTitles=[];
folderNumber=14
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=0.5,\alpha=1$,\mathbf{R}_{inv}=max$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=15
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('r','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=0.5,\alpha=1,\mathbf{R}_{inv}=sum$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=16
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1,\mathbf{R}_{inv}=max$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=17
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('b','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1,\mathbf{R}_{inv}=sum$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=18
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('k','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$DS,\mu=0.5,\alpha=1,\mathbf{R}_{inv}=sum2$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
folderNumber=19
folderPath = "SimData_7500_AlartCurnierVsDeSaxe/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt,legOpt = genOpts('c','--');
legendArtists.append( plt.Line2D((0,1),(0,0), **legOpt) );
legendTitles.append(r'$AC,\mu=0.5,\alpha=1,\mathbf{R}_{inv}=sum$, T%d' % folderNumber);
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);
plt.gca().legend(legendArtists,legendTitles)
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. residual $\| x^{k+1} -x^k\|$ in $\lambda$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
# plt.savefig('ResidualPlot1Velocity.pdf')
In [ ]: