Plot Simfile and SimulationData


In [1]:
import sys,os

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]:
'/home/zfmgpu/.config/matplotlib'

Plot Simulation Data


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_7500DampedTest/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=1.8,d_{N}^{-1}=d_{T}^{-1}=1e-7, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);


folderNumber=1
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1.8,d_{N}^{-1}=d_{T}^{-1}=1e-4, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);


folderNumber=2
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1.1,d_{N}^{-1}=d_{T}^{-1}=1e-4, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);


folderNumber=3
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.1,d_{N}^{-1}=d_{T}^{-1}=1e-6, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);


folderNumber=4
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='k'
pltOpt['label']=r'$\alpha=1.1,d_{N}^{-1}=d_{T}^{-1}=1e-7, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);



plt.title(r'Simulation Test Problem 7500 Balls, UCFD Model, $\mu=0.3$' +  '\n Term. Crit.: Velocity')
plt.legend()
plt.xlabel('Iteration (without minIter)')
plt.ylabel(r'max. Residual $\| x^{k+1} -x^k\|$')
plt.gca().margins(0.05)
plt.gcf().tight_layout()
plt.gcf().canvas.draw()
plt.savefig('ResidualPlot1Velocity.pdf')


DataRange: [0, 8965]
Orig. Iterations:  (8966,)
Clamped Iterations:  (8966,)
DataRange: [0, 10000]
Orig. Iterations:  (11033,)
Clamped Iterations:  (5001,)
DataRange: [0, 89]
Orig. Iterations:  (90,)
Clamped Iterations:  (90,)
DataRange: [0, 8659]
Orig. Iterations:  (8660,)
Clamped Iterations:  (8660,)
DataRange: [0, 20000]
Orig. Iterations:  (64111,)
Clamped Iterations:  (5001,)

In [4]:
plt.figure()

folderNumber=5
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='r'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1},d_{T}^{-1}=10^{-4}, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);


folderNumber=6
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1},d_{T}^{-1}=10^{-5}, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);


folderNumber=7
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1},d_{T}^{-1}=10^{-6}, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);


folderNumber=8
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=d_{T}^{-1}=10^{-5} \rightarrow 10^{-6} (warm), \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);


folderNumber=9
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='k'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=d_{T}^{-1}=10^{-5} \rightarrow 10^{-6} (warm), \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,10000],5000,pltOpt);



plt.title(r'Simulation Test Problem 7500 Balls, UCFD Model, $\mu=0.3$' +  '\n Term. Crit.: Lambda')
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')


DataRange: [0, 68]
Orig. Iterations:  (69,)
Clamped Iterations:  (69,)
DataRange: [0, 691]
Orig. Iterations:  (692,)
Clamped Iterations:  (692,)
DataRange: [0, 5083]
Orig. Iterations:  (5084,)
Clamped Iterations:  (5084,)
DataRange: [0, 5543]
Orig. Iterations:  (5544,)
Clamped Iterations:  (5544,)
DataRange: [0, 5168]
Orig. Iterations:  (5169,)
Clamped Iterations:  (5169,)

In [5]:
plt.figure()

folderNumber=10
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='r'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-7},d_{T}^{-1}=10^{-3}, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);

folderNumber=11
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-8},d_{T}^{-1}=10^{-2}, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);


folderNumber=12
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-10},d_{T}^{-1}=10^{-2}, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);

folderNumber=13
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-10},d_{T}^{-1}=10^{-4}, \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);


plt.title(r'Simulation Test Problem 7500 Balls, UCFD Model, $\mu=0.3$' +  '\n Term. Crit.: Lambda')
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')


DataRange: [0, 2339]
Orig. Iterations:  (2340,)
Clamped Iterations:  (2340,)
DataRange: [0, 1309]
Orig. Iterations:  (1310,)
Clamped Iterations:  (1310,)
DataRange: [0, 1321]
Orig. Iterations:  (1322,)
Clamped Iterations:  (1322,)
DataRange: [0, 9918]
Orig. Iterations:  (9919,)
Clamped Iterations:  (9919,)

In [6]:
plt.figure()

folderNumber=14
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='r'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-6},d_{T}^{-1}=10^{-6} (\Lambda^{k+1}-\Lambda^{k}), \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);

folderNumber=15
folderPath = "SimData_7500DampedTest/Test%d/" % folderNumber
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='g'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-6},d_{T}^{-1}=10^{-6} (+\mathbf{M}^{-1}\mathbf{W} \Lambda^k ), \quad T%d$' % folderNumber
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,20000],5000,pltOpt);


plt.title(r'Simulation Test Problem 7500 Balls, UCFD Model, $\mu=0.3$' +  '\n Term. Crit.: Lambda')
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('ResidualPlot4Auslöschung.pdf')


DataRange: [0, 5083]
Orig. Iterations:  (5084,)
Clamped Iterations:  (5084,)
DataRange: [0, 5083]
Orig. Iterations:  (5084,)
Clamped Iterations:  (5084,)

In [7]:
plt.figure()

pltOpt = {'color':'r', 'marker':'.', 'markersize': 2,'markeredgewidth': 0, 'markeredgecolor':'none', 'linewidth':0.4}

folderPath = "../SimFiles/SimDataRECORD_0/"
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='b'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-10},d_{T}^{-1}=10^{-4},m=1$' 
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,100000],5000,pltOpt);

# folderPath = "../SimFiles/SimDataRECORD_24/"
# simDataIterationFile = folderPath + "SimDataIteration.dat";
# pltOpt['color']='r'
# pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-10},d_{T}^{-1}=10^{-4},m=1$' 
# simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
# plotDataIteration(simDataIteration,[0,100000],5000,pltOpt);

# folderPath = "../SimFiles/SimDataRECORD_25/"
# simDataIterationFile = folderPath + "SimDataIteration.dat";
# pltOpt['color']='g'
# pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-10},d_{T}^{-1}=10^{-4},m=1$'
# simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
# plotDataIteration(simDataIteration,[0,100000],5000,pltOpt);

folderPath = "../SimFiles/SimDataRECORD_41/"
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-10},d_{T}^{-1}=10^{-4},descending$' 
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,100000],5000,pltOpt);

folderPath = "../SimFiles/SimDataRECORD_42/"
simDataIterationFile = folderPath + "SimDataIteration.dat";
pltOpt['color']='y'
pltOpt['label']=r'$\alpha=1.5,d_{N}^{-1}=10^{-10},d_{T}^{-1}=10^{-4},ascending$'
simDataIteration = ReadInSimDataIterationFile(simDataIterationFile)
plotDataIteration(simDataIteration,[0,100000],5000,pltOpt);

plt.title(r'Simulation Test Problem 7500 Balls, UCFD Model, $\mu=0.3$' +  '\n Term. Crit.: Lambda')
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('ResidualPlot5UCFCD.pdf')


DataRange: [0, 8152]
Orig. Iterations:  (8153,)
Clamped Iterations:  (8153,)
DataRange: [0, 18679]
Orig. Iterations:  (18680,)
Clamped Iterations:  (6227,)
DataRange: [0, 12993]
Orig. Iterations:  (12994,)
Clamped Iterations:  (6497,)

In [7]: