got this test file to work appropriately
This commit is contained in:
parent
b8cb32d819
commit
7f0d8e0589
30
bin/test.py
30
bin/test.py
@ -3,10 +3,13 @@
|
|||||||
import sys
|
import sys
|
||||||
from interp.grid.DDD import random_grid
|
from interp.grid.DDD import random_grid
|
||||||
from interp.baker import get_phis, run_baker
|
from interp.baker import get_phis, run_baker
|
||||||
from interp.tools import log
|
from interp.tools import baker_exact_3D, improved_answer
|
||||||
from interp.tools import exact_func_3D, improved_answer
|
|
||||||
from interp.grid.simplex import contains
|
from interp.grid.simplex import contains
|
||||||
|
|
||||||
|
import interp
|
||||||
|
import logging
|
||||||
|
log = logging.getLogger("interp")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
total_points = int(sys.argv[1])
|
total_points = int(sys.argv[1])
|
||||||
except:
|
except:
|
||||||
@ -15,32 +18,37 @@ except:
|
|||||||
|
|
||||||
log.info(total_points)
|
log.info(total_points)
|
||||||
g = random_grid(total_points)
|
g = random_grid(total_points)
|
||||||
|
g.q = [baker_exact_3D(i) for i in g.verts]
|
||||||
|
|
||||||
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
|
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
|
||||||
|
|
||||||
X = [0.5, 0.3, 0.4]
|
X = [0.5, 0.3, 0.4]
|
||||||
|
|
||||||
R, S = g.get_simplex_and_nearest_points(X, extra_points = 6, simplex_size=4)
|
R, S = g.get_simplex_and_nearest_points(X, extra_points = 16, simplex_size=4)
|
||||||
sys.exit()
|
|
||||||
log.info("Containing Simplex: %s" % contains(X, R.points))
|
|
||||||
|
|
||||||
exact = exact_func_3D(X)
|
log.info("Containing Simplex: %s" % contains(X, R.verts))
|
||||||
|
|
||||||
|
exact = baker_exact_3D(X)
|
||||||
log.info("exact solution: %0.6f" % exact)
|
log.info("exact solution: %0.6f" % exact)
|
||||||
|
|
||||||
phis = get_phis(X, R.points)
|
phis = get_phis(X, R.verts)
|
||||||
log.info("phi values (should all be positive): %s %s" % (phis, sum(phis)))
|
log.info("phi values (should all be positive): %s %s" % (phis, sum(phis)))
|
||||||
if [i for i in phis if i < 0.0]:
|
if [i for i in phis if i < 0.0]:
|
||||||
log.error("problems")
|
log.error("problems")
|
||||||
|
|
||||||
|
|
||||||
|
print exact
|
||||||
try:
|
try:
|
||||||
r = run_baker(X, R, S)
|
r = run_baker(X, R, S, order = 2)
|
||||||
log.info("run_baker manual: %s" % improved_answer(r, exact))
|
print r
|
||||||
|
print "run_baker manual: %s" % improved_answer(r, exact)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e)
|
log.error(e)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
answer = g.run_baker(X)
|
answer = g.run_baker(X, order = 2, extra_points = 16)
|
||||||
log.info("run_baker from grid: %s" % improved_answer(answer, exact))
|
print answer
|
||||||
|
print "run_baker from grid: %s" % improved_answer(answer, exact)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e)
|
log.error(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user