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
import sys
from grid.DDD import random_grid
from baker import get_phis_3D, run_baker_3D
from baker.tools import smblog
from baker.tools import exact_func_3D, smberror, improved_answer
from grid.simplex import contains
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])
@ -13,7 +13,7 @@ except:
total_points = 20
smblog.info(total_points)
log.info(total_points)
g = random_grid(total_points)
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]
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)
smblog.info("exact solution: %0.6f" % exact)
log.info("exact solution: %0.6f" % exact)
phis = get_phis_3D(X, R.points)
smblog.info("phi values (should all be positive): %s %s" % (phis, sum(phis)))
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]:
smblog.error("problems")
log.error("problems")
try:
r = run_baker_3D(X, R, S)
smblog.info("run_baker manual: %s" % improved_answer(r, exact))
except smberror as e:
smblog.error(e)
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)
smblog.info("run_baker from grid: %s" % improved_answer(answer, exact))
except smberror as e:
smblog.error(e)
log.info("run_baker from grid: %s" % improved_answer(answer, exact))
except Exception as e:
log.error(e)

View File

@ -75,21 +75,19 @@ def get_phis(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
X = destination point
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)
qlin = np.sum([q_i * phi_i for q_i, phi_i in zip(R.q, phis)])
return phis, qlin
qlinear_3D = qlinear
def get_error(phi, R, S, order = 2):
log.debug("len(phi): %d"% len(phi))
B = [] # baker eq 9
@ -150,6 +148,7 @@ def run_baker(X, R, S, order=2):
S = extra points
"""
log.debug("order = %d" % order)
log.debug("extra points = %d" % len(S.verts))
answer = {
'qlin': None,

View File

@ -4,15 +4,20 @@ from setuptools import setup, find_packages
setup(
name = 'smbinterp',
version = '0.01',
version = '0.02',
packages = find_packages(),
install_requires = [
'numpy',
'scipy',
'Delny',
],
# entry_points = {'console_scripts': ['booze = baker.booze:main',]},
author = "Stephen M. McQuay",
author = "Stephen M. McQuay",
author_email = "stephen@mcquay.me",
url = "https://mcquay.me/hg/research",
license = "GPL",
url = "https://mcquay.me/hg/research",
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.accuracy = 8
def test_R_contains_X(self):
self.assertTrue(contains(self.X, self.R.verts))