2010-03-18 22:32:24 -07:00
|
|
|
#!/usr/bin/python2.6
|
|
|
|
|
|
|
|
import sys
|
|
|
|
from grid.DDD import simple_random_grid
|
|
|
|
from baker import get_phis_3D, run_baker_3D
|
|
|
|
from baker.tools import exact_func_3D
|
|
|
|
|
|
|
|
try:
|
|
|
|
total_points = int(sys.argv[1])
|
|
|
|
except:
|
2010-03-18 22:50:40 -07:00
|
|
|
total_points = 20
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
|
|
|
|
print total_points
|
2010-03-18 22:32:24 -07:00
|
|
|
g = simple_random_grid(total_points)
|
|
|
|
|
|
|
|
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
|
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
X = [0.3, 0.3, 0.4]
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
R, S = g.get_simplex_and_nearest_points(X, extra_points = 6, simplex_size=4)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
print "R\n", R
|
|
|
|
print "S\n", S
|
2010-03-18 22:32:24 -07:00
|
|
|
|
|
|
|
exact = exact_func_3D(X)
|
|
|
|
print "exact solution: %0.6f" % exact
|
|
|
|
|
2010-03-18 22:50:40 -07:00
|
|
|
phis = get_phis_3D(X, R.points)
|
2010-03-19 20:27:51 -07:00
|
|
|
print "phi values (should all be positive): ", phis, sum(phis)
|
2010-03-18 22:50:40 -07:00
|
|
|
if [i for i in phis if i < 0.0]:
|
|
|
|
print "problems"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2010-03-18 22:32:24 -07:00
|
|
|
r = run_baker_3D(X, R, S)
|
|
|
|
|
|
|
|
print 'qlin' , r['qlin']
|
|
|
|
print 'error', r['error']
|
|
|
|
print 'final', r['final']
|
|
|
|
|
|
|
|
if abs(r['final'] - exact) <= abs(r['qlin'] - exact):
|
|
|
|
print "win"
|
2010-03-18 22:50:40 -07:00
|
|
|
sys.exit(0)
|
2010-03-18 22:32:24 -07:00
|
|
|
else:
|
|
|
|
print "failure"
|
2010-03-18 22:50:40 -07:00
|
|
|
sys.exit(2)
|