This commit is contained in:
Stephen Mardson McQuay 2011-02-02 11:52:53 -07:00
parent 046e24b67d
commit 2329479a64
4 changed files with 32 additions and 29 deletions

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
from grid.DDD import random_grid from interp.grid.DDD import random_grid
from baker import get_phis_3D, run_baker_3D from interp.baker import get_phis, run_baker
from baker.tools import smblog from interp.tools import log
from baker.tools import exact_func_3D, smberror, improved_answer from interp.tools import exact_func_3D, improved_answer
from grid.simplex import contains from interp.grid.simplex import contains
try: try:
total_points = int(sys.argv[1]) total_points = int(sys.argv[1])
@ -13,7 +13,7 @@ except:
total_points = 20 total_points = 20
smblog.info(total_points) log.info(total_points)
g = random_grid(total_points) g = random_grid(total_points)
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull()) open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
@ -21,25 +21,26 @@ 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 = 6, simplex_size=4)
smblog.info("Containing Simplex: %s" % contains(X, R.points)) sys.exit()
log.info("Containing Simplex: %s" % contains(X, R.points))
exact = exact_func_3D(X) exact = exact_func_3D(X)
smblog.info("exact solution: %0.6f" % exact) log.info("exact solution: %0.6f" % exact)
phis = get_phis_3D(X, R.points) phis = get_phis(X, R.points)
smblog.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]:
smblog.error("problems") log.error("problems")
try: try:
r = run_baker_3D(X, R, S) r = run_baker(X, R, S)
smblog.info("run_baker manual: %s" % improved_answer(r, exact)) log.info("run_baker manual: %s" % improved_answer(r, exact))
except smberror as e: except Exception as e:
smblog.error(e) log.error(e)
try: try:
answer = g.run_baker(X) answer = g.run_baker(X)
smblog.info("run_baker from grid: %s" % improved_answer(answer, exact)) log.info("run_baker from grid: %s" % improved_answer(answer, exact))
except smberror as e: except Exception as e:
smblog.error(e) log.error(e)

View File

@ -75,21 +75,19 @@ def get_phis(X, R):
def qlinear(X, R): def qlinear(X, R):
""" """
this calculates the linear portion of q from X to R this calculates the linear portion of q from R to X
also, this is baker eq 3 also, this is baker eq 3
X = destination point X = destination point
R = simplex points R = simplex points
q = CFD quantities of interest at the simplex points q = quantity of interest at the simplex points
""" """
phis = get_phis(X, R.verts) phis = get_phis(X, R.verts)
qlin = np.sum([q_i * phi_i for q_i, phi_i in zip(R.q, phis)]) qlin = np.sum([q_i * phi_i for q_i, phi_i in zip(R.q, phis)])
return phis, qlin return phis, qlin
qlinear_3D = qlinear
def get_error(phi, R, S, order = 2): def get_error(phi, R, S, order = 2):
log.debug("len(phi): %d"% len(phi)) log.debug("len(phi): %d"% len(phi))
B = [] # baker eq 9 B = [] # baker eq 9
@ -150,6 +148,7 @@ def run_baker(X, R, S, order=2):
S = extra points S = extra points
""" """
log.debug("order = %d" % order) log.debug("order = %d" % order)
log.debug("extra points = %d" % len(S.verts))
answer = { answer = {
'qlin': None, 'qlin': None,

View File

@ -4,15 +4,20 @@ from setuptools import setup, find_packages
setup( setup(
name = 'smbinterp', name = 'smbinterp',
version = '0.01', version = '0.02',
packages = find_packages(), packages = find_packages(),
install_requires = [ install_requires = [
'numpy', 'numpy',
'scipy', 'scipy',
'Delny',
], ],
# entry_points = {'console_scripts': ['booze = baker.booze:main',]},
author = "Stephen M. McQuay", author = "Stephen M. McQuay",
author_email = "stephen@mcquay.me", author_email = "stephen@mcquay.me",
url = "https://mcquay.me/hg/research", url = "https://mcquay.me/hg/research",
license = "GPL", license = "GPL",
# entry_points = {'console_scripts': ['booze = baker.booze:main',]},
) )

View File

@ -37,8 +37,6 @@ class TestSequenceFunctions(unittest.TestCase):
self.exact = exact_func(self.X) self.exact = exact_func(self.X)
self.accuracy = 8
def test_R_contains_X(self): def test_R_contains_X(self):
self.assertTrue(contains(self.X, self.R.verts)) self.assertTrue(contains(self.X, self.R.verts))