In [1]:
import sys,os
import math
import numpy as np
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
#this works apparently only for savefig stuff
mpl.rcParams['figure.figsize']=(6.0,4.0) #(6.0,4.0)
mpl.rcParams['font.size']=10 #10
mpl.rcParams['savefig.dpi']=400 #72
mpl.rcParams['figure.subplot.bottom']=.1 #.125
plt.rc('font', family='serif')
plt.rc('text', usetex=True)
#inline Shit
%matplotlib inline
%config InlineBackend.figure_format='svg'
%config InlineBackend.rc = {'figure.facecolor': 'white', 'figure.subplot.bottom': 0.125, 'figure.edgecolor': 'white', 'savefig.dpi': 400, 'figure.figsize': (12.0, 8.0), 'font.size': 10}
#GUi shit
%matplotlib tk
mpl.get_configdir()
Out[1]:
In [2]:
from SimFileReader import *
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 [3]:
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 SimFileReader import *
bodyRange = [0,3]
timeRange = [0,50]
folderNumber=0
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
plt.figure()
pltOpt = {'color':'r', 'marker':'.', 'markersize': 2,'markeredgewidth': 0, 'markeredgecolor':'none', 'linewidth':0.4}
pltOpt['label']=r'$\alpha=0.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=1
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);
folderNumber=2
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);
folderNumber=3
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.7$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);
folderNumber=4
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='k'
pltOpt['label']=r'$\alpha=1.8$, T%d' % folderNumber
pltOpt['linewidth']=3;
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);
plt.title('Simulation Test Problem 7500 Balls, Unilateral Contacts \n Term. Crit.: Velocity')
plt.legend()
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. residual $\| x^{k+1} -x^k\| - \|x^k\| Tol_{rel} - Tol_{abs}$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
plt.savefig('ResidualPlot1Velocity.pdf')
In [4]:
folderNumber=5
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
plt.figure();
pltOpt = {'color':'r', 'marker':'.', 'markersize': 2,'markeredgewidth': 0, 'markeredgecolor':'none', 'linewidth':0.4}
pltOpt['label']=r'$\alpha=0.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,7000],5000,pltOpt);
folderNumber=6
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=7
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=8
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.7$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=9
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='k'
pltOpt['label']=r'$\alpha=1.8$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
plt.title('Simulation Test Problem 7500 Balls, Unilateral Contacts \n Term. Crit.: Lambda')
plt.legend()
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. residual $\| x^{k+1} -x^k\| - \|x^k\| Tol_{rel} - Tol_{abs}$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
plt.savefig('ResidualPlot1Lambda.pdf')
In [5]:
folderNumber=10
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
plt.figure();
pltOpt = {'color':'r', 'marker':'.', 'markersize': 2,'markeredgewidth': 0, 'markeredgecolor':'none', 'linewidth':0.4}
pltOpt['label']=r'$\alpha=0.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,7000],5000,pltOpt);
folderNumber=11
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=12
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=13
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.7$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=14
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='k'
pltOpt['label']=r'$\alpha=1.8$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
plt.title('Simulation Test Problem 7500 Balls, Unilateral Contacts \n Term. Crit.: Velocity')
plt.legend()
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'Residual $\| x^{k+1} -x^k\|$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
plt.savefig('ResidualPlot2Velocity.pdf')
In [6]:
folderNumber=15
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
plt.figure();
pltOpt = {'color':'r', 'marker':'.', 'markersize': 2,'markeredgewidth': 0, 'markeredgecolor':'none', 'linewidth':0.4}
pltOpt['label']=r'$\alpha=0.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,7000],5000,pltOpt);
folderNumber=16
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=17
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1.5$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=18
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.7$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
folderNumber=19
folderPath = "SimData_7500Test/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='k'
pltOpt['label']=r'$\alpha=1.8$, T%d' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,5000],5000,pltOpt);
plt.title('Simulation Test Problem 7500 Balls \n Term. Crit.: Lambda')
params = {'legend.fontsize': 12,
'legend.linewidth': 800}
plt.rcParams.update(params)
plt.legend()
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'Residual $\| x^{k+1} -x^k\|$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
plt.savefig('ResidualPlot2Lambda.pdf')
In [6]: