added resolution study script

This commit is contained in:
Stephen Mardson McQuay 2011-05-06 11:02:24 -06:00
parent ff28008eb5
commit cbe1a778c9
1 changed files with 45 additions and 0 deletions

45
bin/resolution.py Normal file
View File

@ -0,0 +1,45 @@
import sys
import numpy as np
from interp.grid.delaunay import dgrid
from interp.tools import baker_exact_3D
from interp.tools import rms
from progressbar import *
attempts = 1000
widgets = ['submit jobs: ', Percentage(), ' ', Bar(), ' ', ETA()]
results = {}
for r in xrange(2,8):
resolution = float("1e%d" % r)
v = np.random.random((resolution,3))
q = [baker_exact_3D(x) for x in v]
g = dgrid(v,q)
pbar = ProgressBar(widgets = widgets, maxval = attempts)
pbar.start()
start = time.time()
errors = []
i = 0
outside = 0
while i < attempts:
try:
X = np.random.random((1,3))[0]
e = g.run_baker(X)['final'] - baker_exact_3D(X)
errors.append(e)
pbar.update(i+1)
i += 1
except Exception as e:
# print X, i, resolution
outside += 1
pbar.finish()
print "\n"
end = time.time()
rmserror = rms(errors)
results[resolution] = rmserror
print resolution, rmserror, outside, end - start