def test_estimator(self): with open(os.path.join(TEST_DIR, 'Estimator.mo'), 'r') as f: txt = f.read() ast_tree = parser.parse(txt) text = gen_sympy.generate(ast_tree, 'Estimator') with open(os.path.join(TEST_DIR, 'generated/Estimator.py'), 'w') as f: f.write(text) from test.generated.Estimator import Estimator as Estimator e = Estimator() e.linearize_symbolic() e.linearize() # noinspection PyUnusedLocal res = e.simulate(x0=[1.0]) self.flush()
def test_quad(self): with open(os.path.join(TEST_DIR, 'Quad.mo'), 'r') as f: txt = f.read() # noinspection PyUnusedLocal ast_tree = parser.parse(txt) text = gen_sympy.generate(ast_tree, 'Quad') with open(os.path.join(TEST_DIR, 'generated/Quad.py'), 'w') as f: f.write(text) from test.generated.Quad import Quad as Quad e = Quad() e.linearize_symbolic() e.linearize() # noinspection PyUnusedLocal res = e.simulate() self.flush()
def test_aircraft(self): with open(os.path.join(TEST_DIR, 'Aircraft.mo'), 'r') as f: txt = f.read() # noinspection PyUnusedLocal ast_tree = parser.parse(txt) text = gen_sympy.generate(ast_tree, 'Aircraft') with open(os.path.join(TEST_DIR, 'generated/Aircraft.py'), 'w') as f: f.write(text) from test.generated.Aircraft import Aircraft as Aircraft e = Aircraft() e.linearize_symbolic() e.linearize() # noinspection PyUnusedLocal res = e.simulate() self.flush()
def test_spring(self): with open(os.path.join(TEST_DIR, 'SpringSystem.mo'), 'r') as f: txt = f.read() ast_tree = parser.parse(txt) flat_tree = tree.flatten(ast_tree, ast.ComponentRef(name='SpringSystem')) print(flat_tree) text = gen_sympy.generate(ast_tree, 'SpringSystem') with open(os.path.join(TEST_DIR, 'generated/Spring.py'), 'w') as f: f.write(text) from test.generated.Spring import SpringSystem as SpringSystem e = SpringSystem() e.linearize_symbolic() e.linearize() # noinspection PyUnusedLocal res = e.simulate(x0=[1.0, 1.0]) self.flush()