Ejemplo n.º 1
0
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.MP = MatrixPool()

        epsAxis = Axis({
            'name': 'eps',
            'valueL': [10., 20., 30., 40., 50.],
            'units': '',
            'transform': 'log10'
        })
        pcAxis = Axis({
            'name': 'pc',
            'valueL': [100., 200., 300, 400],
            'units': 'psia',
            'transform': 'log10'
        })
        mrAxis = Axis({
            'name': 'mr',
            'valueL': [1, 2, 3],
            'units': '',
            'transform': ''
        })
        for A in [epsAxis, pcAxis, mrAxis]:
            self.MP.add_axis(A)

        M = self.MP.add_matrix(name='cea_isp',
                               units='sec',
                               axisNameL=['eps', 'pc', 'mr'])
        for eps in epsAxis:
            for pc in pcAxis:
                for mr in mrAxis:
                    M.setByName(pc=pc, eps=eps, mr=mr, val=eps + pc + mr)
Ejemplo n.º 2
0
class MyTest(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.MP = MatrixPool()

        epsAxis = Axis({
            'name': 'eps',
            'valueL': [10., 20., 30., 40., 50.],
            'units': '',
            'transform': 'log10'
        })
        pcAxis = Axis({
            'name': 'pc',
            'valueL': [100., 200., 300, 400],
            'units': 'psia',
            'transform': 'log10'
        })
        mrAxis = Axis({
            'name': 'mr',
            'valueL': [1, 2, 3],
            'units': '',
            'transform': ''
        })
        for A in [epsAxis, pcAxis, mrAxis]:
            self.MP.add_axis(A)

        M = self.MP.add_matrix(name='cea_isp',
                               units='sec',
                               axisNameL=['eps', 'pc', 'mr'])
        for eps in epsAxis:
            for pc in pcAxis:
                for mr in mrAxis:
                    M.setByName(pc=pc, eps=eps, mr=mr, val=eps + pc + mr)

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        del (self.MP)

    def test_should_always_pass_cleanly(self):
        """Should always pass cleanly."""
        pass

    def test_MP_existence(self):
        """Check that MP exists"""
        result = self.MP

        # See if the self.MP object exists
        self.assertTrue(result)

    def test_interp(self):
        """Check interpolation"""
        M = self.MP.get_matrix_by_name('cea_isp')
        val = M.interp(order=2, pc=200, eps=20, mr=2.0)
        self.assertAlmostEqual(val, 222.0, places=7)

        val = M.interp(order=2, pc=100, eps=10, mr=1.0)
        self.assertAlmostEqual(val, 111.0, places=7)

        val = M.interp(order=2, pc=150, eps=15, mr=1.5)
        self.assertAlmostEqual(val, 166.56398645, places=5)
Ejemplo n.º 3
0
class MyTest(unittest.TestCase):

    def setUp(self):
        unittest.TestCase.setUp(self)
        self.MP = MatrixPool()

        epsAxis = Axis({'name':'eps', 'valueL':[10., 20., 30., 40., 50.], 'units':'', 'transform':'log10'})
        pcAxis = Axis({'name':'pc', 'valueL':[100.,200.,300,400], 'units':'psia', 'transform':'log10'})
        mrAxis = Axis({'name':'mr', 'valueL':[1,2,3], 'units':'', 'transform':''})
        for A in [epsAxis, pcAxis, mrAxis]:
            self.MP.add_axis( A )
        
        M = self.MP.add_matrix( name='cea_isp', units='sec', axisNameL=['eps','pc','mr'] )
        for eps in epsAxis:
            for pc in pcAxis:
                for mr in mrAxis:
                    M.setByName( pc=pc, eps=eps, mr=mr, val=eps+pc+mr )

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        del( self.MP )

    def test_should_always_pass_cleanly(self):
        """Should always pass cleanly."""
        pass

    def test_MP_existence(self):
        """Check that MP exists"""
        result = self.MP

        # See if the self.MP object exists
        self.assertTrue(result)

    def test_interp(self):
        """Check interpolation"""
        M = self.MP.get_matrix_by_name( 'cea_isp' )
        val = M.interp(order=2, pc=200, eps=20, mr=2.0)
        self.assertAlmostEqual(val, 222.0, places=7)

        val = M.interp(order=2, pc=100, eps=10, mr=1.0)
        self.assertAlmostEqual(val, 111.0, places=7)

        val = M.interp(order=2, pc=150, eps=15, mr=1.5)
        self.assertAlmostEqual(val, 166.56398645, places=5)
Ejemplo n.º 4
0
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.MP = MatrixPool()

        epsAxis = Axis({'name':'eps', 'valueL':[10., 20., 30., 40., 50.], 'units':'', 'transform':'log10'})
        pcAxis = Axis({'name':'pc', 'valueL':[100.,200.,300,400], 'units':'psia', 'transform':'log10'})
        mrAxis = Axis({'name':'mr', 'valueL':[1,2,3], 'units':'', 'transform':''})
        for A in [epsAxis, pcAxis, mrAxis]:
            self.MP.add_axis( A )
        
        M = self.MP.add_matrix( name='cea_isp', units='sec', axisNameL=['eps','pc','mr'] )
        for eps in epsAxis:
            for pc in pcAxis:
                for mr in mrAxis:
                    M.setByName( pc=pc, eps=eps, mr=mr, val=eps+pc+mr )
Ejemplo n.º 5
0
from m_pool.matrix_pool import MatrixPool
from m_pool.axis_obj import Axis
import itertools

MP = MatrixPool(name='N2O4_MMH')
epsAxis = Axis({
    'name': 'eps',
    'valueL': [10., 20., 30., 40., 50.],
    'units': '',
    'transform': 'log10'
})
pcAxis = Axis({
    'name': 'pc',
    'valueL': [100., 200., 300, 400],
    'units': 'psia',
    'transform': 'log10'
})
mrAxis = Axis({
    'name': 'mr',
    'valueL': [1, 2, 3],
    'units': '',
    'transform': ''
})
for A in [epsAxis, pcAxis, mrAxis]:
    MP.add_axis(A)

M = MP.add_matrix(name='cea_isp', units='sec', axisNameL=['eps', 'pc', 'mr'])
for eps in epsAxis:
    for pc in pcAxis:
        for mr in mrAxis:
            M.setByName(pc=pc, eps=eps, mr=mr, val=eps + pc + mr)
Ejemplo n.º 6
0
from m_pool.matrix_pool import MatrixPool
from m_pool.axis_obj import Axis
import itertools

MP = MatrixPool(name='N2O4_MMH')
epsAxis = Axis({'name':'eps', 'valueL':[10., 20., 30., 40., 50.], 'units':'', 'transform':'log10'})
pcAxis = Axis({'name':'pc', 'valueL':[100.,200.,300,400], 'units':'psia', 'transform':'log10'})
mrAxis = Axis({'name':'mr', 'valueL':[1,2,3], 'units':'', 'transform':''})
for A in [epsAxis, pcAxis, mrAxis]:
    MP.add_axis( A )

M = MP.add_matrix( name='cea_isp', units='sec', axisNameL=['eps','pc','mr'] )
for eps in epsAxis:
    for pc in pcAxis:
        for mr in mrAxis:
            M.setByName( pc=pc, eps=eps, mr=mr, val=eps+pc+mr )

print M

print '_'*55

newM = M.get_sub_matrix( pc=200. )
print newM

print '_'*55
newM = M.get_sub_matrix( pc=300., eps=50.0 )
print newM
Ejemplo n.º 7
0
from m_pool.matrix_pool import MatrixPool
from m_pool.axis_obj import Axis
from math import log10

MP = MatrixPool(name='CHECK')
epsAxis = Axis({
    'name': 'eps',
    'valueL': [10., 20., 30., 40., 50.],
    'units': '',
    'transform': 'log10'
})
pcAxis = Axis({
    'name': 'pc',
    'valueL': [100., 200., 300, 400],
    'units': 'psia',
    'transform': 'log10'
})
mrAxis = Axis({
    'name': 'mr',
    'valueL': [1, 2, 3],
    'units': '',
    'transform': ''
})
for A in [epsAxis, pcAxis, mrAxis]:
    MP.add_axis(A)


def chkfunc(pc, eps, mr):
    return log10(eps)**2 + 2.0 * log10(pc)**2 + 0.1 * mr

Ejemplo n.º 8
0
from m_pool.matrix_pool import MatrixPool
from m_pool.axis_obj import Axis
from math import log10

MP = MatrixPool(name='CHECK')
epsAxis = Axis({'name':'eps', 'valueL':[10., 20., 30., 40., 50.], 'units':'', 'transform':'log10'})
pcAxis = Axis({'name':'pc', 'valueL':[100.,200.,300,400], 'units':'psia', 'transform':'log10'})
mrAxis = Axis({'name':'mr', 'valueL':[1,2,3], 'units':'', 'transform':''})
for A in [epsAxis, pcAxis, mrAxis]:
    MP.add_axis( A )

def chkfunc(pc, eps, mr):
    return log10(eps)**2 + 2.0*log10(pc)**2 + 0.1*mr 

M = MP.add_matrix( name='cea_isp', units='sec', axisNameL=['eps','pc','mr'] )
for eps in epsAxis:
    for pc in pcAxis:
        for mr in mrAxis:
            val = chkfunc(pc, eps, mr)
            M.setByName( pc=pc, eps=eps, mr=mr, val=val )
            
MP.save_to_pickle()  # Saves to "CHECK_matrix.pool"

D = {'pc':250., 'eps':35.0, 'mr':1.5}
#val = M.interp(order=2, **{'pc':250., 'eps':35.0, 'mr':1.5})

#print M
print 'len(M.shape()) =',len(M.shape())

val = M.interp(order=1, **D)
print 'type(val) =',type(val)
Ejemplo n.º 9
0
from m_pool.matrix_pool import MatrixPool

MP = MatrixPool(name='CHECK')
MP.read_from_pickle() # Opens "CHECK_matrix.pool"
print MP
print MP.matrixD

M = MP.get_matrix_by_name( 'cea_isp' )

print 'len(M.shape()) =',len(M.shape())

D = {'pc':250., 'eps':35.0, 'mr':1.5}
val = M.interp(order=1, **D)
print 'type(val) =',type(val)
print 'interp_1  =',val

val = M.interp(order=2, pc=250, eps=35, mr=1.5)
print 'interp_2  =',val

val = M.interp(order=3, **D)
print 'interp_3  =',val

Ejemplo n.º 10
0
from m_pool.matrix_pool import MatrixPool
from m_pool.axis_obj import Axis

MP = MatrixPool(name='N2O4_MMH')
epsAxis = Axis({'name':'eps', 'valueL':[10., 20., 30., 40., 50.], 'units':'', 'transform':'log10'})
pcAxis = Axis({'name':'pc', 'valueL':[100.,200.,300,400], 'units':'psia', 'transform':'log10'})
mrAxis = Axis({'name':'mr', 'valueL':[1,2,3], 'units':'', 'transform':''})
for A in [epsAxis, pcAxis, mrAxis]:
    MP.add_axis( A )

M = MP.add_matrix( name='cea_isp', units='sec', axisNameL=['eps','pc','mr'] )
for eps in epsAxis:
    for pc in pcAxis:
        for mr in mrAxis:
            M.setByName( pc=pc, eps=eps, mr=mr, val=eps+pc+mr )


M = MP.add_matrix( name='SEA_isp', units='sec', axisNameL=['eps','pc','mr'] )
for eps in epsAxis:
    for pc in pcAxis:
        for mr in mrAxis:
            M.setByName( pc=pc, eps=eps, mr=mr, val=eps+pc+mr+0.321 )


print MP
MP.save_to_pickle()
Ejemplo n.º 11
0
from m_pool.matrix_pool import MatrixPool

MP = MatrixPool(name='CHECK')
MP.read_from_pickle() # Opens "CHECK_matrix.pool"
print(MP)
print(MP.matrixD)

M = MP.get_matrix_by_name( 'cea_isp' )

print('len(M.shape()) =',len(M.shape()))

D = {'pc':250., 'eps':35.0, 'mr':1.5}
val = M.interp(order=1, **D)
print('type(val) =',type(val))
print('interp_1  =',val)

val = M.interp(order=2, pc=250, eps=35, mr=1.5)
print('interp_2  =',val)

val = M.interp(order=3, **D)
print('interp_3  =',val)