2010-03-18 22:32:24 -07:00
|
|
|
#!/usr/bin/python2.6
|
|
|
|
|
|
|
|
import sys
|
2010-03-20 16:10:02 -07:00
|
|
|
from grid.DDD import random_grid
|
2010-03-18 22:32:24 -07:00
|
|
|
from baker import get_phis_3D, run_baker_3D
|
2010-04-23 08:58:30 -07:00
|
|
|
from baker.tools import exact_func_3D, smberror, evaluate_answer
|
2010-03-18 22:32:24 -07:00
|
|
|
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-20 16:10:02 -07:00
|
|
|
g = random_grid(total_points)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2010-03-20 16:10:02 -07:00
|
|
|
try:
|
|
|
|
r = run_baker_3D(X, R, S)
|
2010-04-23 08:58:30 -07:00
|
|
|
evaluate_answer(r, exact)
|
|
|
|
except smberror as e:
|
|
|
|
print e
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
answer = g.run_baker(X)
|
|
|
|
evaluate_answer(answer, exact)
|
2010-03-20 16:10:02 -07:00
|
|
|
except smberror as e:
|
|
|
|
print e
|