removed test file
This commit is contained in:
parent
7f0d8e0589
commit
d8f297fcc6
54
bin/test.py
54
bin/test.py
@ -1,54 +0,0 @@
|
|||||||
#!/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 baker_exact_3D, improved_answer
|
|
||||||
from interp.grid.simplex import contains
|
|
||||||
|
|
||||||
import interp
|
|
||||||
import logging
|
|
||||||
log = logging.getLogger("interp")
|
|
||||||
|
|
||||||
try:
|
|
||||||
total_points = int(sys.argv[1])
|
|
||||||
except:
|
|
||||||
total_points = 20
|
|
||||||
|
|
||||||
|
|
||||||
log.info(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())
|
|
||||||
|
|
||||||
X = [0.5, 0.3, 0.4]
|
|
||||||
|
|
||||||
R, S = g.get_simplex_and_nearest_points(X, extra_points = 16, simplex_size=4)
|
|
||||||
|
|
||||||
log.info("Containing Simplex: %s" % contains(X, R.verts))
|
|
||||||
|
|
||||||
exact = baker_exact_3D(X)
|
|
||||||
log.info("exact solution: %0.6f" % exact)
|
|
||||||
|
|
||||||
phis = get_phis(X, R.verts)
|
|
||||||
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")
|
|
||||||
|
|
||||||
|
|
||||||
print exact
|
|
||||||
try:
|
|
||||||
r = run_baker(X, R, S, order = 2)
|
|
||||||
print r
|
|
||||||
print "run_baker manual: %s" % improved_answer(r, exact)
|
|
||||||
except Exception as e:
|
|
||||||
log.error(e)
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
answer = g.run_baker(X, order = 2, extra_points = 16)
|
|
||||||
print answer
|
|
||||||
print "run_baker from grid: %s" % improved_answer(answer, exact)
|
|
||||||
except Exception as e:
|
|
||||||
log.error(e)
|
|
@ -1,48 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
from interp.baker import run_baker
|
|
||||||
from interp.tools import improved_answer
|
|
||||||
|
|
||||||
from interp.tools import log
|
|
||||||
|
|
||||||
from interp.grid.DD import grid
|
|
||||||
from interp.grid.simplex import contains
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
def exact_func(X):
|
|
||||||
x = X[0]
|
|
||||||
y = X[0]
|
|
||||||
return 1 - np.sin(np.power((x-0.5), 2) + np.power((y-0.5), 2))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
points = [
|
|
||||||
[ 0.25, 0.40], # 0
|
|
||||||
[ 0.60, 0.80], # 1
|
|
||||||
[ 0.65, 0.28], # 2
|
|
||||||
[ 0.28, 0.65], # 3
|
|
||||||
[ 1.00, 0.75], # 4
|
|
||||||
[ 0.30, 0.95], # 5
|
|
||||||
[ 0.80, 0.50], # 6
|
|
||||||
[ 0.35, 0.15], # 7
|
|
||||||
]
|
|
||||||
q = [exact_func(p) for p in points]
|
|
||||||
|
|
||||||
X = [0.55, 0.45]
|
|
||||||
|
|
||||||
g = grid(points, q)
|
|
||||||
R = g.create_mesh(range(3))
|
|
||||||
|
|
||||||
try:
|
|
||||||
extra = int(sys.argv[1])
|
|
||||||
except:
|
|
||||||
extra = 3
|
|
||||||
|
|
||||||
S = g.create_mesh(range(3, 3 + extra))
|
|
||||||
|
|
||||||
for i in xrange(1,4):
|
|
||||||
answer = run_baker(X, R, S, i)
|
|
||||||
exact = exact_func(X)
|
|
||||||
log.debug(improved_answer(answer, exact))
|
|
||||||
|
|
||||||
log.debug(improved_answer(g.run_baker(X), exact))
|
|
Loading…
Reference in New Issue
Block a user