def test_set_time(self): htcfile = HTCFile(self.testfilepath + "test.htc") htcfile.set_time(10, 20, 0.2) self.assertEqual(htcfile.simulation.time_stop[0], 20) self.assertEqual(htcfile.simulation.newmark.deltat[0], 0.2) self.assertEqual(htcfile.wind.scale_time_start[0], 10) self.assertEqual(htcfile.output.time[:2], [10, 20])
def main(): if __name__ == '__main__': # ====================================================================== # load existing htc file # ====================================================================== path = os.path.dirname(test_files.__file__) + "/simulation_setup/DTU10MWRef6.0/" htc = HTCFile(path + "htc/DTU_10MW_RWT.htc") # ====================================================================== # modify wind speed and turbulence intensity # ====================================================================== htc.wind.wsp = 10 # access wind section and change turbulence intensity wind = htc.wind wind.tint = .1 #======================================================================= # print contents #======================================================================= print(htc) # print htc file print(htc.keys()) # print htc sections print(wind) # print wind section #======================================================================= # change tilt angle #======================================================================= orientation = htc.new_htc_structure.orientation # Two ways to access the relative orientation between towertop and shaft # 1) Knowning that it is the second relative section: rel_tt_shaft = orientation.relative__2 # 2) Knowning that the section contains a field "body1" with value "topertop" rel_tt_shaft = orientation.get_subsection_by_name(name='towertop', field='body1') rel_tt_shaft.body2_eulerang__2 = 6, 0, 0 print(rel_tt_shaft.body2_eulerang__2) # ====================================================================== # set time, name and save # ====================================================================== # set time of simulation, first output section and wind.scale_time_start htc.set_time(start=5, stop=10, step=0.1) # change name of logfile, animation, visualization and first output section htc.set_name("tmp_wsp10_tint0.1_tilt6") htc.save() # Save htc modified htcfile as "tmp_wsp10_tint0.1_tilt6"
def test_add_turb_export(self): htc = HTCFile() htc.add_mann_turbulence(30.1, 1.1, 3.3, 102, False) htc.set_time(100, 700, 0.01) htc.add_turb_export() s = """begin turb_export; filename_u\texport_u.turb; filename_v\texport_v.turb; filename_w\texport_w.turb; samplefrq\t3; time_start\t100; nsteps\t60000.0; box_dim_v\t32 3.125; box_dim_w\t32 3.125; end turb_export;""" for a, b in zip(s.split("\n"), str(htc.wind.turb_export).split("\n")): self.assertEqual(a.strip(), b.strip())