def test_one_stage(self): # inp = 'one_stage.inp' #comp = set_as_top(AxodCompn(input_filename=inp)) comp = set_as_top(AxodCompn(input_filename='one_stage.inp')) comp.run() # 'desired' from Linux, 'tolerance' for Windows. assert_rel_error(self, comp.hpower, 696.33050537109375, 0.0001) assert_rel_error(self, comp.tott[0], 430.1795, 0.001) assert_rel_error(self, comp.totp[0], 7.0516329, 0.0001) assert_rel_error(self, comp.mflow[0], 7.3931241, 0.0001) assert_rel_error(self, comp.effs[0], 0.96280003, 0.00001) assert_rel_error(self, comp.effr[0], 0.92559999, 0.00001) self.assertEqual(len(comp.results), 3196)
def test_eee_hpt(self): # inp = 'eee_hpt.inp' comp = set_as_top(AxodCompn(input_filename='eee_hpt.inp')) comp.run() # 'desired' from Linux, 'tolerance' for Windows/Mac. assert_rel_error(self, comp.hpower, 3323.77880859375, 0.00015) assert_rel_error(self, comp.tott[0], 757.75458, 0.001) assert_rel_error(self, comp.totp[0], 8.223134, 0.001) assert_rel_error(self, comp.mflow[0], 4.9717932, 0.001) assert_rel_error(self, comp.effs[0], 0.95300001, 0.0001) assert_rel_error(self, comp.effr[0], 0.90600002, 0.0001) self.assertEqual(len(comp.results), 19773)
def test_transdata_input(self): self.top = set_as_top(Assembly()) self.top.add('tempdata', temp_data()) self.top.add('axodcompn', AxodCompn(input_filename='one_stage.inp')) self.top.add('nextdata', next_data()) # self.top.driver.workflow.add(['tempdata', 'axodcompn']) self.top.driver.workflow.add(['tempdata', 'axodcompn', 'nextdata']) self.top.connect('tempdata.ttout', 'axodcompn.Case1.Stage1.ttin') self.top.connect('tempdata.ptout', 'axodcompn.Case1.Stage1.ptin') self.top.connect('axodcompn.hpower', 'nextdata.hpower') try: # execute axod with new output file... self.top.run() # 'desired' from Linux, 'tolerance' for Windows. assert_rel_error(self, self.top.axodcompn.hpower, 696.92260742, 0.0001) assert_rel_error(self, self.top.axodcompn.tott[0], 429.664, 0.001) assert_rel_error(self, self.top.axodcompn.totp[0], 7.05674, 0.0001) assert_rel_error(self, self.top.nextdata.hpower, 696.92260742, 0.0001) except IOError: print ' problem running code'
def test_no_input(self): try: set_as_top(AxodCompn(input_filename='no-such-file')) except IOError, exc: msg = "[Errno 2] No such file or directory: 'no-such-file'" self.assertEqual(str(exc), msg)
# newtest1.py import sys import numpy import subprocess import shutil import os if '.' not in sys.path: sys.path.append('.') from axod_compn import AxodCompn from openmdao.main.api import Component, Container # changing data in input file ............................ # executing using axod component 'AxodCompn' one = AxodCompn(input_filename='eee_hpt.inp') one.Case1.Stage1.ptin = 51.00 one.Case1.Stage1.ttin = 1284.0 #one.Case1.Stage1.vctd = 1.0 #one.Case1.Stage1.rwg = [1.0,1.0895,1.105,1.1759,1.1760] #one.Case1.Stage2.rwg = [1.1759,1.2007,1.2008,1.2009,1.2007] one.Case1.Stage1.seta = [0.953, 0.954, 0.953, 0.954, 0.950] one.Case1.Stage1.rpm = 8000.0 #one.Case3.Stage1.rpm = 4900.0 one.run() print 'one.hpower=', one.hpower print ' COMPLETE ********'
# testaxodn.py import sys if '.' not in sys.path: sys.path.append('.') from axod_compn import AxodCompn from openmdao.main.api import set_as_top # changing data in input file ............................ one = set_as_top(AxodCompn(input_filename='eee_hpt.inp')) one.Case1.Stage1.ptin = 51.00 one.Case1.Stage1.ttin = 1284.0 # one.Case1.Stage1.vctd = 1.0 # one.Case1.Stage1.rwg = [1.0,1.0895,1.105,1.1759,1.1760] # one.Case1.Stage2.rwg = [1.1759,1.2007,1.2008,1.2009,1.2007] one.Case1.Stage1.seta = [0.953, 0.954, 0.953, 0.954, 0.950] one.Case1.Stage1.rpm = 8000.0 # one.Case3.Stage1.rpm = 4900.0 one.run() print 'one.hpower=', one.hpower print ' COMPLETE ********'