示例#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)
示例#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')
示例#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')
示例#4
0
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)
plt.axis([1,1e4,1e-12,1e-0])
plt.show()
示例#5
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()
示例#6
0
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()
示例#7
0
    if line.startswith('N'): N = int(line.strip().split('=')[1])
    elif line.startswith('ref'):
        ref = line.strip().split('=')[1].split(',')
        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.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)
示例#8
0
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)
plt.axis([10, 1e4, 1e-6, 1e1])
plt.show()
示例#9
0
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)
plt.axis([10,1e4,1e-6,1e1])
plt.show()
示例#10
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()
示例#11
0
  if line.startswith('N'):N=int(line.strip().split('=')[1])
  elif line.startswith('ref'):
    ref=line.strip().split('=')[1].split(',')
    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.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)