Some work on double pendulum test, still more to go
import numpy as np
-# import importlib
import unittest
import os
@@ -41,7 +40,7 @@ class TestDoublePendulum(unittest.TestCase):
airfoil[0,:,0] = np.linspace(0.,1.,20)
# Simulation
- numtimesteps = 500
+ numtimesteps = 100
dt = 0.01
# Create the structure
@@ -106,6 +105,7 @@ class TestDoublePendulum(unittest.TestCase):
'InitializeMultibody',
'DynamicCoupled']
SimInfo.solvers['SHARPy']['case'] = 'double_pendulum_geradin'
+ SimInfo.solvers['SHARPy']['write_screen'] = 'off'
SimInfo.solvers['SHARPy']['route'] = os.path.dirname(os.path.realpath(__file__)) + '/'
SimInfo.set_variable_all_dicts('dt', dt)
SimInfo.define_num_steps(numtimesteps)
@@ -181,26 +181,16 @@ class TestDoublePendulum(unittest.TestCase):
beam1.generate_h5_files(SimInfo.solvers['SHARPy']['route'], SimInfo.solvers['SHARPy']['case'])
gc.generate_multibody_file(LC, MB,SimInfo.solvers['SHARPy']['route'], SimInfo.solvers['SHARPy']['case'])
- # def tearDown():
- # pass
-
def test_doublependulum(self):
import sharpy.sharpy_main
solver_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/double_pendulum_geradin.solver.txt')
- print(solver_path)
sharpy.sharpy_main.main(['', solver_path])
# read output and compare
output_path = os.path.dirname(solver_path) + '/output/double_pendulum_geradin/WriteVariablesTime/'
- # quat_data = np.matrix(np.genfromtxt(output_path + 'FoR_00_mb_quat.dat', delimiter=' '))
- pos_tip_data = np.matrix(np.genfromtxt(output_path + "struct_pos_node" + str(11+11-1) + ".dat", delimiter=' '))
+ pos_tip_data = np.atleast_2d(np.genfromtxt(output_path + "struct_pos_node" + str(11+11-1) + ".dat", delimiter=' '))
self.assertAlmostEqual(pos_tip_data[-1, 1], 1.481168, 4)
self.assertAlmostEqual(pos_tip_data[-1, 2], 0.000000, 4)
self.assertAlmostEqual(pos_tip_data[-1, 3], 0.8766285, 4)
-if __name__=='__main__':
-
- T = TestDoublePendulum()
- T.setUp()
- T.test_doublependulum()
