Esempio n. 1
0
def plot(case,ref,r):
  MC  = 'MC_'+case+'.samples'
  HCs = ['HC_'+case+'.moments']
  TDs = ['TD_'+case+'.moments']
  xs=[]
  ys=[]
  lbl=[]

  x,y=pltMC(MC,'MC',ref=ref,r=r)
  xs.append(x)
  ys.append(y)
  lbl.append('MC_'+case)

  for h in HCs:
    x,y=addPlot(h,'HC_iso',ref=ref,r=r)#+h.split('.')[0].split('_')[1],ref=ref)
    xs.append(x)
    ys.append(y)
    lbl.append('HC_iso_'+case)
  for h in TDs:
    x,y=addPlot(h,'TD_iso',ref=ref,r=r)#+h.split('.')[0].split('_')[1],ref=ref)
    xs.append(x)
    ys.append(y)
    lbl.append('TD_iso_'+case)

  pk.dump([xs,ys,lbl],file(case+'.pk','w'))

  plt.title(case)
  plt.xlabel(r'PDE Solves $\eta$')
  plt.ylabel('Rel. Error')
  plt.legend(loc=3)
Esempio n. 2
0
def slnerrplot(cases, title, N, xlim, sylim, eylim, ref, mom, alpha=0.5):
    slnplot = plt.figure()
    errplot = plt.figure()
    plt.figure(errplot.number)

    for cname, cfile in cases.iteritems():
        ary = cname.split('.')[0].split('_')
        if ary[0] == 'MC':
            pltMC(cname,
                  cfile,
                  'MC',
                  ref=ref,
                  r=mom,
                  slnfig=slnplot,
                  alpha=alpha)
        elif ary[0] in ['HC', 'TD'] and 'anis' not in ary:
            ary = ary[0]  #.remove(ary[1])
            addPlot(cname, cfile, ary, ref=ref, r=mom, slnfig=slnplot)
        elif ary[0] == 'hdmr' and 'anis' not in ary:
            namelist = cname.split('.')[0].split('_')
            name = '_'.join([namelist[0], namelist[1], namelist[-1]])
            addHDMR(cname, cfile, name, ref=ref, r=mom, slnfig=slnplot)
        elif 'anis' in ary and 'hdmr' not in ary:
            lbl = ary[0] + '_aniso'
            addAnis(cname, cfile, lbl, ref=ref, r=mom, slnfig=slnplot)


    plt.title(r'Error in $\mathbb{E}[u^%i]$; %s, $N$=%i'\
                       %(mom,title,N))
    plt.xlabel(r'PDE Solves $\eta$')
    plt.ylabel('Rel. Error')
    plt.xlim(xlim)
    plt.ylim(eylim)
    plt.legend(loc=3)

    plt.figure(slnplot.number)
    plt.title(r'Solution for $\mathbb{E}[u^%i]$; %s, $N$=%i'\
                       %(mom,title,N))
    plt.xlabel(r'PDE Solves $\eta$')
    plt.ylabel(r'$\mathbb{E}[u^%i]$' % mom)
    plt.legend(loc=4)
    plt.xlim(xlim)
    plt.ylim(sylim)
    plt.gca().set_xscale('log')
Esempio n. 3
0
def slnerrplot(cases,title,N,xlim,sylim,eylim,ref,mom,alpha=0.5):
    slnplot=plt.figure()
    errplot=plt.figure()
    plt.figure(errplot.number)

    for cname,cfile in cases.iteritems():
      ary=cname.split('.')[0].split('_')
      if ary[0]=='MC':
        pltMC(cname,cfile,'MC',ref=ref,r=mom,slnfig=slnplot,alpha=alpha)
      elif ary[0] in ['HC','TD'] and 'anis' not in ary:
        ary=ary[0]#.remove(ary[1])
        addPlot(cname,cfile,ary,ref=ref,r=mom,slnfig=slnplot)
      elif ary[0]=='hdmr' and 'anis' not in ary:
        namelist = cname.split('.')[0].split('_')
        name = '_'.join([namelist[0],namelist[1],namelist[-1]])
        addHDMR(cname,cfile,name,ref=ref,r=mom,slnfig=slnplot)
      elif 'anis' in ary and 'hdmr' not in ary:
        lbl=ary[0]+'_aniso'
        addAnis(cname,cfile,lbl,ref=ref,r=mom,slnfig=slnplot)


    plt.title(r'Error in $\mathbb{E}[u^%i]$; %s, $N$=%i'\
                       %(mom,title,N))
    plt.xlabel(r'PDE Solves $\eta$')
    plt.ylabel('Rel. Error')
    plt.xlim(xlim)
    plt.ylim(eylim)
    plt.legend(loc=3)

    plt.figure(slnplot.number)
    plt.title(r'Solution for $\mathbb{E}[u^%i]$; %s, $N$=%i'\
                       %(mom,title,N))
    plt.xlabel(r'PDE Solves $\eta$')
    plt.ylabel(r'$\mathbb{E}[u^%i]$' %mom)
    plt.legend(loc=4)
    plt.xlim(xlim)
    plt.ylim(sylim)
    plt.gca().set_xscale('log')
Esempio n. 4
0
from plot1 import addPlot
from plotMC import addPlot as pltMC
import matplotlib.pyplot as plt
import numpy as np

MC = 'MC_h5_iso.samples'
plots= ['HC_h5_iso.moments',
        'HC_h5_1-1-2-1-1.moments',
        'HC_h5_1-1-4-4-8.moments',
        'HC_h5_1-1-2-2-4.moments',
        'HC_h5_8-8-4-4-1.moments']

ref=[0,1.0013454858344246,1.8647257169268627e-04]

for p in plots:
  addPlot(p,p.split('_')[2].split('.')[0],ref=ref,r=2)
pltMC(MC,'MC',ref=ref,r=2)

xs=np.linspace(2,32000,3)
ysMC = 1e-2/np.sqrt(xs)
ysHC1 = 1e-0*xs**(-3)
#ysHC2 = 5e-5*xs**(-0.5)
#plt.loglog(xs,ysMC,'k:',label=r'$c\ \eta^{-1/2}$')
#plt.loglog(xs,ysHC1,'k-.',label=r'$c\ \eta^{-4}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
plt.title(r'Error in $k$; $N$=5, $h\sim$0.018')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend(loc=3)
plt.axis([1,1e4,1e-7,2])
plt.show()
Esempio n. 5
0
        ref[1] = float(ref[1])
        ref[2] = float(ref[2])

slnplot = plt.figure()
errplot = plt.figure()
plt.figure(errplot.number)

for line in file('list.inp', 'r'):
    fname = line.strip()
    ary = fname.split('.')[0].split('_')
    if ary[0] == 'MC':
        pltMC(fname, 'MC', ref=ref, slnfig=slnplot)
    elif ary[0] in ['HC', 'TD']:
        ary.remove(ary[1])
        print ary
        addPlot(fname, '_'.join(ary), ref=ref, slnfig=slnplot)
    elif ary[0] == 'hdmr':
        addHDMR(fname, fname.split('.')[0], ref=ref, slnfig=slnplot)

#addPlot(MC,'MC',ref=ref)
#for h in HCs:
#  addPlot(h,'HC_iso',ref=ref,slnfig=slnplot)
#for h in TDs:
#  addPlot(h,'TD_iso',ref=ref,slnfig=slnplot)

#for h in anis:
#  addPlot(h,h.split('_')[0]+'_aniso',ref=ref)#+h.split('.')[0].split('_')[1],ref=ref)
#pltMC(MC,'MC',ref=ref,slnfig=slnplot)

#xs=np.linspace(2,32000,3)
#ysMC = 1e-2/np.sqrt(xs)
Esempio n. 6
0
r = 2
MC = 'MC_h5_iso.samples'
isos = ['HC_h5_iso.moments', 'TD_h5_iso.moments']
anis = ['HC_h5_aniso.moments', 'TD_h5_aniso.moments']

#HCs = ['HC_h1_iso.moments',
#       'HC_h3_iso.moments',
#       'HC_h5_iso.moments']

#ref=[0,1.0025998595112884,1.7000448118653644e-04]
ref = [6661, 1.0013454858344246e+00, 1.8647257169268627e-04]

#addPlot(MC,'MC',ref=ref)
for h in isos:
    addPlot(h, h.split('_')[0] + '_iso', ref=ref, r=r)
for h in anis:
    addPlot(h, h.split('_')[0] + '_aniso', ref=ref, r=r)
pltMC(MC, 'MC', ref=ref, r=r)

xs = np.linspace(2, 32000, 3)
ysMC = 2e-0 / np.sqrt(xs)
ysHC1 = 2e1 * xs**(-2)
#ysHC2 = 5e-5*xs**(-0.5)
#plt.loglog(xs,ysMC,'k:',label=r'$c\ \eta^{-1/2}$')
#plt.loglog(xs,ysHC1,'k-.',label=r'$c\ \eta^{-2}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
plt.title(r'Error in var($k$); $N$=5, $h\sim$0.018')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend(loc=3)
Esempio n. 7
0
MC = 'MC_h5_iso.samples'
isos = ['HC_h5_iso.moments',
        'TD_h5_iso.moments']
anis = ['HC_h5_aniso.moments',
        'TD_h5_aniso.moments']

#HCs = ['HC_h1_iso.moments',
#       'HC_h3_iso.moments',
#       'HC_h5_iso.moments']

#ref=[0,1.0025998595112884,1.7000448118653644e-04]
ref=[6661,1.0013454858344246e+00,1.8647257169268627e-04]

#addPlot(MC,'MC',ref=ref)
for h in isos:
  addPlot(h,h.split('_')[0]+'_iso',ref=ref,r=r)
for h in anis:
  addPlot(h,h.split('_')[0]+'_aniso',ref=ref,r=r)
pltMC(MC,'MC',ref=ref,r=r)

xs=np.linspace(2,32000,3)
ysMC = 2e-0/np.sqrt(xs)
ysHC1 = 2e1*xs**(-2)
#ysHC2 = 5e-5*xs**(-0.5)
#plt.loglog(xs,ysMC,'k:',label=r'$c\ \eta^{-1/2}$')
#plt.loglog(xs,ysHC1,'k-.',label=r'$c\ \eta^{-2}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
plt.title(r'Error in var($k$); $N$=5, $h\sim$0.018')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend(loc=3)
Esempio n. 8
0
import matplotlib.pyplot as plt
import numpy as np

MC = 'MC_h5_iso.samples'
HCs = ['HC_h5_iso.moments']
anis = ['HC_h5_1124244884.moments',
        'HC_h5_1234244554.moments']
#HCs = ['HC_h1_iso.moments',
#       'HC_h3_iso.moments',
#       'HC_h5_iso.moments']

ref=[0,9.3045730355252931e-01,1.2261150319231584e-03]

#addPlot(MC,'MC',ref=ref)
for h in HCs:
  addPlot(h,'HC_iso',ref=ref)#+h.split('.')[0].split('_')[1],ref=ref)
#for h in TDs:
#  addPlot(h,'TD_iso',ref=ref)#+h.split('.')[0].split('_')[1],ref=ref)
for h in anis:
  addPlot(h,h.split('_')[0]+'_'+h.split('_')[-1].split('.')[0],ref=ref)#+h.split('.')[0].split('_')[1],ref=ref)
pltMC(MC,'MC',ref=ref)

#xs=np.linspace(2,32000,3)
#ysMC = 1e-2/np.sqrt(xs)
#ysHC1 = 1e-0*xs**(-3)
#ysHC2 = 5e-5*xs**(-0.5)
#plt.loglog(xs,ysMC,'k:',label=r'$c\ \eta^{-1/2}$')
#plt.loglog(xs,ysHC1,'k-.',label=r'$c\ \eta^{-4}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
plt.title(r'Error in $k$; $N$=5, $h\sim$0.018')
plt.xlabel(r'PDE Solves $\eta$')
Esempio n. 9
0
from plotMC import addPlot as pltMC
import matplotlib.pyplot as plt
import numpy as np

MC = 'MC_h5_iso.samples'
HCs = ['HC_h5_iso.moments']
r = 2
#HCs = ['HC_h1_iso.moments',
#       'HC_h3_iso.moments',
#       'HC_h5_iso.moments']

ref = [0, 1.0013454858344246, 1.8647257169268627e-04]

#addPlot(MC,'MC',ref=ref)
for h in HCs:
    addPlot(h, 'HC', ref=ref, r=r)  #+h.split('.')[0].split('_')[1],ref=ref)
pltMC(MC, 'MC', ref=ref, r=r)

xs = np.linspace(2, 32000, 3)
ysMC = 1e-2 / np.sqrt(xs)
ysHC1 = 2e-4 * xs**(-1)
#ysHC2 = 5e-5*xs**(-0.5)
plt.loglog(xs, ysMC, 'k:', label=r'$c\ \eta^{-1/2}$')
plt.loglog(xs, ysHC1, 'k-.', label=r'$c\ \eta^{-1}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
plt.title(r'Error in $k$; $N$=5, $h\sim$0.018')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend(loc=3)
plt.show()
Esempio n. 10
0
from plot1 import addPlot
import matplotlib.pyplot as plt
import numpy as np

varNs = [
    '1xc2', '1xf2', '2xc2', '2xf2', '3xc2', '3xf2', '4xc2', '4xf2', '5D2',
    '5xc2'
]

keys = ['b-o', 'b:o', 'r-o', 'r:o', 'g-o', 'g:o', 'y-o', 'y:o', 'k-o', 'k:o']

for v, var in enumerate(varNs):
    inpN = 'HC_h5_' + var + '.moments'
    addPlot(inpN, var, key=keys[v])

plt.legend(loc=1)
plt.axis([1, 20, 1e-11, 1e-2])
plt.show()
Esempio n. 11
0
from plot1 import addPlot
from plotMC import addPlot as pltMC
import matplotlib.pyplot as plt
import numpy as np

MC = 'MC_h5_iso.samples'
plots = [
    'HC_h5_iso.moments', 'HC_h5_1-1-2-1-1.moments', 'HC_h5_1-1-4-4-8.moments',
    'HC_h5_1-1-2-2-4.moments', 'HC_h5_8-8-4-4-1.moments'
]

ref = [0, 1.0013454858344246, 1.8647257169268627e-04]

for p in plots:
    addPlot(p, p.split('_')[2].split('.')[0], ref=ref, r=2)
pltMC(MC, 'MC', ref=ref, r=2)

xs = np.linspace(2, 32000, 3)
ysMC = 1e-2 / np.sqrt(xs)
ysHC1 = 1e-0 * xs**(-3)
#ysHC2 = 5e-5*xs**(-0.5)
#plt.loglog(xs,ysMC,'k:',label=r'$c\ \eta^{-1/2}$')
#plt.loglog(xs,ysHC1,'k-.',label=r'$c\ \eta^{-4}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
plt.title(r'Error in $k$; $N$=5, $h\sim$0.018')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend(loc=3)
plt.axis([1, 1e4, 1e-7, 2])
plt.show()
Esempio n. 12
0
        ref[0] = int(ref[0])
        ref[1] = float(ref[1])
        ref[2] = float(ref[2])

slnplot = plt.figure()
errplot = plt.figure()
plt.figure(errplot.number)

for line in file('list.inp', 'r'):
    fname = line.strip()
    ary = fname.split('.')[0].split('_')
    if ary[0] == 'MC':
        pltMC(fname, 'MC', ref=ref, slnfig=slnplot)
    elif ary[0] in ['HC', 'TD']:
        ary = ary[0]  #.remove(ary[1])
        addPlot(fname, ary, ref=ref, slnfig=slnplot)
    elif ary[0] == 'hdmr':
        addHDMR(fname, fname.split('.')[0], ref=ref, slnfig=slnplot)

#addPlot(MC,'MC',ref=ref)
#for h in HCs:
#  addPlot(h,'HC_iso',ref=ref,slnfig=slnplot)
#for h in TDs:
#  addPlot(h,'TD_iso',ref=ref,slnfig=slnplot)

#for h in anis:
#  addPlot(h,h.split('_')[0]+'_aniso',ref=ref)#+h.split('.')[0].split('_')[1],ref=ref)
#pltMC(MC,'MC',ref=ref,slnfig=slnplot)

#xs=np.linspace(2,32000,3)
#ysMC = 1e-2/np.sqrt(xs)
Esempio n. 13
0
    ref[1]=float(ref[1])
    ref[2]=float(ref[2])

slnplot=plt.figure()
errplot=plt.figure()
plt.figure(errplot.number)

for line in file('list.inp','r'):
  fname = line.strip()
  ary=fname.split('.')[0].split('_')
  if ary[0]=='MC':
    pltMC(fname,'MC',ref=ref,slnfig=slnplot)
  elif ary[0] in ['HC','TD']:
    ary.remove(ary[1])
    print ary
    addPlot(fname,'_'.join(ary),ref=ref,slnfig=slnplot)
  elif ary[0]=='hdmr':
    addHDMR(fname,fname.split('.')[0],ref=ref,slnfig=slnplot)

#addPlot(MC,'MC',ref=ref)
#for h in HCs:
#  addPlot(h,'HC_iso',ref=ref,slnfig=slnplot)
#for h in TDs:
#  addPlot(h,'TD_iso',ref=ref,slnfig=slnplot)

#for h in anis:
#  addPlot(h,h.split('_')[0]+'_aniso',ref=ref)#+h.split('.')[0].split('_')[1],ref=ref)
#pltMC(MC,'MC',ref=ref,slnfig=slnplot)

#xs=np.linspace(2,32000,3)
#ysMC = 1e-2/np.sqrt(xs)
Esempio n. 14
0
from plot1 import addPlot
from plotMC import addPlot as pltMC
import matplotlib.pyplot as plt
import numpy as np

MC = 'MC_h47_src.samples'
HC = 'TD_h47_src.moments'

ref=[0,0.019354814806,3.85792294471e-07]

#addPlot(MC,'MC',ref=ref)
addPlot(HC,'HC',ref=ref)
pltMC(MC,'MC',ref=ref)

xs=np.linspace(2,32000,3)
ysMC = 1e-2/np.sqrt(xs)
ysHC = 1e-3*xs**(-0.3)
plt.loglog(xs,ysMC,'k:',label=r'$C_1\eta^{-1/2}$')
plt.loglog(xs,ysHC,'k-.',label=r'$C_2\eta^{-3/10}$')
plt.title(r'Error in $k$; $N$=2, $h$=3/55')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend()
plt.show()
Esempio n. 15
0
from plot1 import addPlot
from plotMC import addPlot as pltMC
import matplotlib.pyplot as plt
import numpy as np

MC = 'MC_h47_src.samples'
HC = 'TD_h47_src.moments'

ref = [0, 0.019354814806, 3.85792294471e-07]

#addPlot(MC,'MC',ref=ref)
addPlot(HC, 'HC', ref=ref)
pltMC(MC, 'MC', ref=ref)

xs = np.linspace(2, 32000, 3)
ysMC = 1e-2 / np.sqrt(xs)
ysHC = 1e-3 * xs**(-0.3)
plt.loglog(xs, ysMC, 'k:', label=r'$C_1\eta^{-1/2}$')
plt.loglog(xs, ysHC, 'k-.', label=r'$C_2\eta^{-3/10}$')
plt.title(r'Error in $k$; $N$=2, $h$=3/55')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend()
plt.show()
Esempio n. 16
0
HCs = []  #'HC_h5_N5_iso.moments']
TDs = []  #'TD_h1_thirty15.moments']
hdmr = ['hdmr_TD_N30_H1.out', 'hdmr_TD_N30_H2.out', 'hdmr_TD_N30_H3.out']
#        'hdmr_TD_N15_H5.out']
#'hdmr_TD_N5_H2.out']
#HCs = ['HC_h1_iso.moments',
#       'HC_h3_iso.moments',
#       'HC_h5_iso.moments']

N = 30
ref = [0, (0.2 * N * (np.exp(-1. / N) - np.exp(-6. / N)))**N]
print 'mean', ref[1]

pltMC(MC, 'MC', ref=ref)
for h in HCs:
    addPlot(h, 'HC_iso', ref=ref)  #+h.split('.')[0].split('_')[1],ref=ref)
for h in TDs:
    addPlot(h, 'TD_iso', ref=ref)  #+h.split('.')[0].split('_')[1],ref=ref)
for h in hdmr:
    addHDMR(h, h.split('.')[0], ref=ref)
#for h in anis:
#  addPlot(h,h.split('_')[0]+'_aniso',ref=ref)#+h.split('.')[0].split('_')[1],ref=ref)
#pltMC(MC,'MC',ref=ref)

#xs=np.linspace(10,32000,3)
#ysMC = 2e-0/np.sqrt(xs)
#ysHC1 = 1e-0*xs**(-3)
#ysHC2 = 5e-5*xs**(-0.5)
#plt.loglog(xs,ysMC,'k:',label=r'$c\ \eta^{-1/2}$')
#plt.loglog(xs,ysHC1,'k-.',label=r'$c\ \eta^{-4}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
Esempio n. 17
0
import matplotlib.pyplot as plt
import numpy as np

r=2

MC = 'MC_h5_N1_iso.samples'
HCs = ['HC_h5_N1_iso.moments']
TDs = ['TD_h5_N1_iso.moments']
#HCs = ['HC_h1_iso.moments',
#       'HC_h3_iso.moments',
#       'HC_h5_iso.moments']

ref=[0,1.0010574538553680e+00,7.1917735918303194e-05]

for h in HCs:
  addPlot(h,'HC_iso',ref=ref,r=r)#+h.split('.')[0].split('_')[1],ref=ref)
for t in TDs:
  addPlot(t,'TD_iso',ref=ref,r=r)#+h.split('.')[0].split('_')[1],ref=ref)
pltMC(MC,'MC',ref=ref)

#xs=np.linspace(2,32000,3)
#ysMC = 1e-2/np.sqrt(xs)
#ysHC1 = 1e-0*xs**(-3)
#ysHC2 = 5e-5*xs**(-0.5)
#plt.loglog(xs,ysMC,'k:',label=r'$c\ \eta^{-1/2}$')
#plt.loglog(xs,ysHC1,'k-.',label=r'$c\ \eta^{-4}$')
#plt.loglog(xs,ysHC2,'k:')#,label=r'$C_2\eta^{-1/2}$')
plt.title(r'Error in var($k$); $N$=1, $h\sim$0.018')
plt.xlabel(r'PDE Solves $\eta$')
plt.ylabel('Rel. Error')
plt.legend(loc=3)
Esempio n. 18
0
from plot1 import addPlot
import matplotlib.pyplot as plt
import numpy as np

varNs = ['1xc2','1xf2',
         '2xc2','2xf2',
         '3xc2','3xf2',
         '4xc2','4xf2',
         '5D2','5xc2']

keys = ['b-o','b:o',
        'r-o','r:o',
        'g-o','g:o',
        'y-o','y:o',
        'k-o','k:o']

for v,var in enumerate(varNs):
  inpN = 'HC_h5_'+var+'.moments'
  addPlot(inpN,var,key=keys[v])

plt.legend(loc=1)
plt.axis([1,20,1e-11,1e-2])
plt.show()