Commit b3140d67 authored by Adam Larat's avatar Adam Larat

After JEARA 2018 presentation

parent 6a29c259
Pipeline #6488 failed with stages
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 6 18:23:14 2016
@author: larat
"""
import sys
import numpy as np
from scipy import stats
import pylab as plt
plt.close('all')
if(len(sys.argv)==1):
print "Usage: pyton convergencPerNorm.py rootName NumberOfMoments"
rootName = "Convergence.dat"
print "Since you have provided none, I have provided the arguments for you:"
print rootName
elif(len(sys.argv)==2):
rootName = str(sys.argv[1])
else:
print "Usage: python convergencePerNorm.py rootName NumberOfMoments"
sys.exit(-1)
### Must contain on each line : N m1_L1 ... mk_L1 m1_L2 ... mk_L2 m1_Linf ... mk_Linf
conv = np.loadtxt(rootName)
nMom = (np.shape(conv)[-1]-1)/3
NMin = np.min(conv[:,0])
NMax = np.max(conv[:,0])
lconv = np.log(conv)
x = np.linspace(NMin,NMax,10)
### Slopes computed on M0
Slope1, inter1, r1, p1, err1 = stats.linregress(lconv[:,0],lconv[:,1])
Slope2, inter2, r2, p2, err2 = stats.linregress(lconv[:,0],lconv[:,1+nMom])
SlopeInf, interInf, rInf, pInf, errInf = stats.linregress(lconv[:,0],lconv[:,1+2*nMom])
### L1 Norm
plt.figure()
for i in np.arange(nMom):
plt.loglog(conv[:,0],conv[:,1+i],'r+-',lw=1,ms=16,label='M'+str(i))
plt.loglog(x,np.exp(Slope1*np.log(x)+inter1),'r-',lw=3,label="Slope = "+("%.2f"%Slope1))
plt.ylabel('Error L1')
plt.xlabel('# Cells')
plt.title('Convergence in the L1 Norm')
plt.legend()
plt.savefig(rootName[:-4]+'_L1Norm'+'.png')
### L2 Norm
plt.figure()
for i in np.arange(nMom):
plt.loglog(conv[:,0],conv[:,1+nMom+i],'bx-',lw=1,ms=16,label='M'+str(i))
plt.loglog(x,np.exp(Slope2*np.log(x)+inter2),'b-',lw=3,label="Slope = "+("%.2f"%Slope2))
plt.ylabel('Error L2')
plt.xlabel('# Cells')
plt.title('Convergence in the L2 Norm')
plt.legend()
plt.savefig(rootName[:-4]+'_L2Norm'+'.png')
### LInf Norm
plt.figure()
for i in np.arange(nMom):
plt.loglog(conv[:,0],conv[:,1+2*nMom+i],'gd-',lw=1,ms=16,label='M'+str(i))
plt.loglog(x,np.exp(SlopeInf*np.log(x)+interInf),'g-',lw=3,label="Slope = "+("%.2f"%SlopeInf))
plt.ylabel('Error LInf')
plt.xlabel('# Cells')
plt.title('Convergence in the LInf Norm')
plt.legend()
plt.savefig(rootName[:-4]+'_LInfNorm'+'.png')
#!/bin/bash
for T in {Beta,Gamma,Border}
do
for O in {2,3}
for O in {1,2,3}
do
for M in {2..8}
do
rootname="momentsAdv-moments${T}_Order${O}"
path="Order${O}/Convergence_${M}Moments"
echo "Treating Order${O}/Convergence_${M}Moments/out_${rootname}.log"
cat ${path}/out_${rootname}.log | grep -e ^[NL] | grep -v "Norm" | grep -v "Loss" | sed -e 's/inf/i/'| sed -e ':z;N;s/\]*\nL[1|2|i] Error = \[//;bz' | sed -e 's/Number of Cells: N = //' -e 's/\]$//' > ${path}/Convergence_${rootname}.dat
python convergence.py ${path}/Convergence_${rootname}.dat
done
rootname="momentsAdv-moments${T}_Order${O}"
echo ${rootname}
cat out_${rootname}.log | grep -e ^[NL] | grep -v "Norm" | grep -v "Loss" | sed -e 's/inf/i/'| sed -e ':z;N;s/\]*\nL[1|2|i] Error = \[//;bz' | sed -e 's/Number of Cells: N = //' -e 's/\]$//' > Convergence_${rootname}.dat
python convergence.py Convergence_${rootname}.dat
python convergencePerNorm.py Convergence_${rootname}.dat
done
done
#!/bin/bash
rm -Rf Convergence_*Moments
for M in {2..8}
for T in {Beta,Gamma,Border}
do
mkdir Convergence_${M}Moments
done
for T in {Border,Gamma,Beta}
do
for O in 1 #{1,2,3}
do
for M in {2..8}
for O in {1,2,3}
do
for N in {32,64,128,256,512} #{40,80,100,200,400}
do
for N in {32,64,128,256,512,1024} #{40,80,100,200,400}
do
echo "***********************************"
echo "** T = "$T", O = "$O", N = "$N" **"
echo "***********************************"
sed -e "s/NNN/${N}/" -e "s/TTT/${T}/" -e "s/MMM/${M}/" parametersNT${O}.py > ../parameters.py
sleep 1
cd ..;
python main.py
cd data
done | tee Convergence_${M}Moments/out_momentsAdv-moments${T}_Order${O}.log
done
echo "***********************************"
echo "** T = "$T", O = "$O", N = "$N" **"
echo "***********************************"
sed -e "s/NNN/${N}/" -e "s/TTT/${T}/" parametersNT${O}.py > ../parameters.py
sleep 1
cd ..;
python main.py
cd data
done | tee out_momentsAdv-moments${T}_Order${O}.log
done
done
......@@ -38,7 +38,7 @@ class parameters:
""" *** Initial Condition ***
cos4x, gaussian, hat, periodicCosine, localizedCosine, mixed
see initFct.py..."""
self.initFunction = initFct.momentsAdvection(self,'Border',MMM)
self.initFunction = initFct.momentsAdvection(self,'Border',8)
""" *** Equation to be solved ***
Now instantiated by initFunction.
......@@ -48,7 +48,7 @@ class parameters:
""" *** ODE integrator ***
FE, RK2Direct, RK2SSP
See timeStepping.py..."""
self.timeIntegration = timeStepping.RK3SSP()
self.timeIntegration = timeStepping.RKSSP(3)
""" *** Semi-discretization in space ***
upwind, centered, downwind, Godunov, LaxFriedrichs, MUSCL, MusclHancock,
......
......@@ -38,7 +38,7 @@ class parameters:
""" *** Initial Condition ***
cos4x, gaussian, hat, periodicCosine, localizedCosine, mixed
see initFct.py..."""
self.initFunction = initFct.momentsAdvection(self,'TTT',MMM)
self.initFunction = initFct.momentsAdvection(self,'TTT',8)
""" *** Equation to be solved ***
Now instantiated by initFunction.
......@@ -48,7 +48,7 @@ class parameters:
""" *** ODE integrator ***
FE, RK2Direct, RK2SSP
See timeStepping.py..."""
self.timeIntegration = timeStepping.FE()
self.timeIntegration = timeStepping.RKSSP(1)
""" *** Semi-discretization in space ***
upwind, centered, downwind, Godunov, LaxFriedrichs, MUSCL, MusclHancock,
......
......@@ -38,7 +38,7 @@ class parameters:
""" *** Initial Condition ***
cos4x, gaussian, hat, periodicCosine, localizedCosine, mixed
see initFct.py..."""
self.initFunction = initFct.momentsAdvection(self,'TTT',MMM)
self.initFunction = initFct.momentsAdvection(self,'TTT',8)
""" *** Equation to be solved ***
Now instantiated by initFunction.
......@@ -48,7 +48,7 @@ class parameters:
""" *** ODE integrator ***
FE, RK2Direct, RK2SSP
See timeStepping.py..."""
self.timeIntegration = timeStepping.RK2SSP()
self.timeIntegration = timeStepping.RKSSP(2)
""" *** Semi-discretization in space ***
upwind, centered, downwind, Godunov, LaxFriedrichs, MUSCL, MusclHancock,
......
......@@ -38,7 +38,7 @@ class parameters:
""" *** Initial Condition ***
cos4x, gaussian, hat, periodicCosine, localizedCosine, mixed
see initFct.py..."""
self.initFunction = initFct.momentsAdvection(self,'TTT',MMM)
self.initFunction = initFct.momentsAdvection(self,'TTT',8)
""" *** Equation to be solved ***
Now instantiated by initFunction.
......@@ -48,7 +48,7 @@ class parameters:
""" *** ODE integrator ***
FE, RK2Direct, RK2SSP
See timeStepping.py..."""
self.timeIntegration = timeStepping.RK3SSP()
self.timeIntegration = timeStepping.RKSSP(3)
""" *** Semi-discretization in space ***
upwind, centered, downwind, Godunov, LaxFriedrichs, MUSCL, MusclHancock,
......
......@@ -3,7 +3,7 @@ do
### root contain filename without extension
root=$(echo ${file} | sed -e 's/.dat//')
### final time is read from first line of the file
time=$(head -n 1 ${file} | cut -b 9-)
time=$(head -n 1 ${file} | cut -b 20-)
### equation name is read from the first 4 caracters of the file name
eq=$(echo ${file}| cut -b -4)
### name of the test case is read from the second item of the file name
......@@ -21,7 +21,7 @@ do
else
gnuplot -e "${format} set ylabel 'u'; plot '${file}' u 1:2 w lp ls 3 t '${scheme}'" > ${root}.png
fi
elif [ ${eq} == "vecA" ];
elif [ ${eq} == "vecA" ] || [ ${eq} == "mome" ];
then
### get each init function name, separated by white spaces
inits=$(echo ${file} | cut -d "-" -f 2 | sed -e 's/_/ /g')
......@@ -48,8 +48,8 @@ do
then
plotCommand=${plotCommand}", "
fi
plotCommand=${plotCommand}" '${file}' u 1:${counter} w lp t '${init}-${scheme}'"
gnuplot -e "${format} set ylabel 'solutions'; set yrange [0:1]; ${plotCommand}" > ${root}.png
plotCommand=${plotCommand}" '${file}' u 1:${counter} w lp lw 6 ps 2 t '${init}'" #-${scheme}'"
gnuplot -e "${format} set ylabel 'solutions'; set yrange [0:1.1]; ${plotCommand}" > ${root}.png
done
elif [ ${eq} == "PGD-" ];
then
......
......@@ -52,19 +52,21 @@ I = np.array([1,0,2]) ### Dofs order
# plt.plot(m[I,x,2+nMom],m[I,x,3+nMom],'g+-',ms=16,lw=3)
# plt.plot(m[I,x,2],m[I,x,3],'rx-',ms=12)
#plt.plot(mBar[:,2+nMom],mBar[:,3+nMom],'go',label="Exact",ms=18)
plt.plot(mBar[:,2],mBar[:,3],'ro-',label="Mean Values",ms=14)
plt.plot(mBar[1::2,2],mBar[1::2,3],'ro-',label="Mean Values",ms=8)
#m1Min,m1Max = plt.xlim()
m1Min = 0.0;m1Max = 0.05
m1Min = 0.0;m1Max = 0.6
m1 = np.linspace(m1Min,m1Max,1000)
plt.plot(m1,m1**2,'k-',lw=5,label="Border")
plt.xlabel('m1/m0')
plt.ylabel('m2/m0')
plt.title("time = "+str(time))
plt.legend()
plt.xlim([m1Min,m1Max])
plt.ylim([m1Min**2,m1Max**2])
#plt.xlim([m1Min,m1Max])
#plt.ylim([m1Min**2,m1Max**2])
plt.xlim([0.0,0.02])
plt.ylim([0.0,0.001])
#rootName[:10] = "redMoments"
plt.savefig(rootName[:-4]+'.png')
plt.savefig(rootName[:-4]+'-Zoom.png')
......
......@@ -21,7 +21,7 @@ class parameters:
self.xMax = 1.0
self.dx = (self.xMax-self.xMin)/self.N
### Time Quantities
self.CFL = 0.3
self.CFL = 0.2
self.tMax = 1.0
self.nbSaveMax = 10
......@@ -33,12 +33,12 @@ class parameters:
""" *** Numerical Flux ***
FStar (Godunov or Exact), LaxFriedrichs, LaxWendroff,...
see equations.py..."""
self.numFlux = "LxF"
self.numFlux = "God"
""" *** Initial Condition ***
cos4x, gaussian, hat, periodicCosine, localizedCosine, mixed
see initFct.py..."""
self.initFunction = initFct.localizedCosine(self,1.0)
self.initFunction = initFct.localizedCosine(self) #momentsAdvection(self,'Border',8)
""" *** Equation to be solved ***
Now instantiated by initFunction.
......@@ -48,21 +48,20 @@ class parameters:
""" *** ODE integrator ***
FE, RK2Direct, RK2SSP
See timeStepping.py..."""
self.timeIntegration = timeStepping.RK2SSP()
self.timeIntegration = timeStepping.RKSSP(3)
""" *** Semi-discretization in space ***
upwind, centered, downwind, Godunov, LaxFriedrichs, MUSCL, MusclHancock,
DG2, DG3
See schemes.py..."""
self.scheme = schemes.DG2();#LaxFriedrichs()#upwind()
self.scheme = schemes.DG3()#upwind()
### Computation rootName
self.rootName = ("data/"
+self.equation.name()+"-"
+self.initFunction.name()+"-"
+self.timeIntegration.name()+"-"
+self.scheme.name()+(self.numFlux if self.scheme.usesFStar() else "") +"-"
+"N"+str(NCells)+"-")
+self.scheme.name()+(self.numFlux if self.scheme.usesFStar() else "") +"-")
### Computation Variables
self.t = 0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment