def __init__(self, htcfile=None, ae_filename=None, pc_filename=None, at_time_filename=None, blade_name=None): if htcfile: if isinstance(htcfile, str): assert htcfile.lower().endswith('.htc') htcfile = HTCFile(htcfile) self.htcfile = htcfile blade_name = blade_name or htcfile.aero.link[2] at_time_filename = at_time_filename or ( "output_at_time" in htcfile and os.path.join(htcfile.modelpath, htcfile.output_at_time.filename[0] + ".dat")) pc_filename = pc_filename or os.path.join( htcfile.modelpath, htcfile.aero.pc_filename[0]) ae_filename = ae_filename or os.path.join( htcfile.modelpath, htcfile.aero.ae_filename[0]) self.hawc2_splines_data = self.hawc2_splines() #mainbodies = [s[k] for k in s.keys() if s[k].name_ == "main_body"] #self.mainbody_blade = [mb for mb in mainbodies if mb.name[0] == blade_name][0] if os.path.isfile(pc_filename) and os.path.isfile(ae_filename): AEFile.__init__(self, ae_filename) PCFile.__init__(self, pc_filename) blade_radius = self.ae_sets[1][-1, 0] if at_time_filename and os.path.isfile(at_time_filename): AtTimeFile.__init__(self, at_time_filename, blade_radius) self.curved_length = self.radius_curved_ac()[-1] else: self.curved_length = None
def test_PCFile_ae(self): pc = PCFile(self.testfilepath + "NREL_5MW_pc.txt") ae = AEFile(self.testfilepath + "NREL_5MW_ae.txt") thickness = ae.thickness(36) self.assertEqual(pc.CL(thickness, 10), 1.358) self.assertEqual(pc.CD(thickness, 10), 0.0255) self.assertEqual(pc.CM(thickness, 10), -0.1103)
def test_PCFile_ae(self): """Verify correct values in values of object loaded from pc file""" pc = PCFile(self.testfilepath + "NREL_5MW_pc.txt") ae = AEFile(self.testfilepath + "NREL_5MW_ae.txt") thickness = ae.thickness(36) self.assertEqual(pc.CL(thickness, 10), 1.358) self.assertEqual(pc.CD(thickness, 10), 0.0255) self.assertEqual(pc.CM(thickness, 10), -0.1103)
def test_str(self): ae = AEFile(testfilepath + "NREL_5MW_ae.txt") ref = """1 r[m] Chord[m] T/C[%] Set no. 1 19 0.00000000000000000e+00 3.54199999999999982e+00 1.00000000000000000e+02 1""" self.assertEqual(str(ae)[:len(ref)], ref)
def test_add_set(self): ae = AEFile(testfilepath + "NREL_5MW_ae.txt") ae.add_set( radius=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], chord=[1.1, 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], thickness=[ 100.0, 100.0, 90.0, 80.0, 70.0, 60.0, 50.0, 40.0, 30.0, 20.0, 10.0 ], pc_set_id=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) ae.add_set(radius=[0.0, 0.1], chord=[1.1, 1.0], thickness=[100.0, 100.0], pc_set_id=[1.0, 1.0], set_id=4) self.assertEqual(ae.thickness(38.950), 21) self.assertEqual(ae.chord(38.950), 3.256) self.assertEqual(ae.pc_set_nr(38.950), 1) np.testing.assert_array_equal(ae.chord( None, 2), [1.1, 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]) np.testing.assert_array_equal(ae.ae_sets[2][:2], ae.ae_sets[4])
def test_save(self): ae = AEFile() ae.add_set( radius=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], chord=[1.1, 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], thickness=[ 100.0, 100.0, 90.0, 80.0, 70.0, 60.0, 50.0, 40.0, 30.0, 20.0, 10.0 ], pc_set_id=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) fn = testfilepath + "tmp/ae_file.txt" ae.save(fn) ae2 = AEFile(fn) assert str(ae) == str(ae2)
def test_multiple_sets(self): ae = AEFile(testfilepath + 'ae_files/HAWC2_ae.dat') self.assertEqual(len(ae.ae_sets), 2)
def test_aefile_interpolate(self): ae = AEFile(testfilepath + "NREL_5MW_ae.txt") self.assertEqual(ae.thickness(32), 23.78048780487805) self.assertEqual(ae.chord(32), 3.673) self.assertEqual(ae.pc_set_nr(32), 1)
def test_aefile(self): ae = AEFile(testfilepath + "NREL_5MW_ae.txt") self.assertEqual(ae.thickness(38.950), 21) self.assertEqual(ae.chord(38.950), 3.256) self.assertEqual(ae.pc_set_nr(38.950), 1)