47 lines
1.1 KiB
Python
Executable File
47 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import sys
|
|
from interp.grid.DDD import random_grid
|
|
from interp.baker import get_phis, run_baker
|
|
from interp.tools import log
|
|
from interp.tools import exact_func_3D, improved_answer
|
|
from interp.grid.simplex import contains
|
|
|
|
try:
|
|
total_points = int(sys.argv[1])
|
|
except:
|
|
total_points = 20
|
|
|
|
|
|
log.info(total_points)
|
|
g = random_grid(total_points)
|
|
|
|
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
|
|
|
|
X = [0.5, 0.3, 0.4]
|
|
|
|
R, S = g.get_simplex_and_nearest_points(X, extra_points = 6, simplex_size=4)
|
|
sys.exit()
|
|
log.info("Containing Simplex: %s" % contains(X, R.points))
|
|
|
|
exact = exact_func_3D(X)
|
|
log.info("exact solution: %0.6f" % exact)
|
|
|
|
phis = get_phis(X, R.points)
|
|
log.info("phi values (should all be positive): %s %s" % (phis, sum(phis)))
|
|
if [i for i in phis if i < 0.0]:
|
|
log.error("problems")
|
|
|
|
try:
|
|
r = run_baker(X, R, S)
|
|
log.info("run_baker manual: %s" % improved_answer(r, exact))
|
|
except Exception as e:
|
|
log.error(e)
|
|
|
|
|
|
try:
|
|
answer = g.run_baker(X)
|
|
log.info("run_baker from grid: %s" % improved_answer(answer, exact))
|
|
except Exception as e:
|
|
log.error(e)
|