def test_genCFile(tmp_path): dyn = Parameters.Dynamics() geo = Parameters.Geometry() d = tmp_path / "sub" d.mkdir() #p = d / "hello.txt" #p.write_text("Stuff in txt file") folder_path = Parameters.FilePath(str(d)) UDF = CFile_Generation.genCFile(folder_path, geo, dyn)
def genCFile(FilePath, FoilGeo, FoilDyn): if Parameters.query_yes_no( "Are these the parameters you want to use to generate a user defined function?" ) == False: sys.exit( "\nPlease enter the desired foil parameters into the input form") parameter_search = np.array([[FoilGeo.chord, 'C_chord_length'], [FoilDyn.rho, 'C_fluid_density'], [FoilDyn.freq, 'C_heaving_frequency'], [FoilDyn.h0, 'C_heaving_amplitude'], [FoilDyn.theta0, 'C_pitching_amplitude'], [FoilDyn.velocity_inf, 'C_velocity_inf']]) UDF_file = open( os.path.dirname(os.path.abspath(__file__)) + "\\AnsysFiles\\Rigid_TemPlate.c", "r").readlines() for param in parameter_search: UDF_file = [w.replace(param[1], param[0]).strip() for w in UDF_file] with open(FilePath.data_path + "\\modRigidPlateFile.c", "w") as new_UDF_file: for lineitem in UDF_file: new_UDF_file.write('%s\n' % lineitem) print('\nUDF has been generated.\n') if hasattr(__main__, '__file__'): if "test" in __main__.__file__.lower(): return UDF_file return FilePath
def directory_Request(FilePath, dirReq): if dirReq == 0: Folder_Path = Parameters.path_check( FilePath.folder_path, "\nStore simulation files to %s?\nA) Yes, use/create the folder and save to it \nB) No, I want to specify a different folder directory \nC) No, I want to cancel this process\nPick an answer of A, B, or C: ", 0) FilePath.newFolderPath(Folder_Path)
def test_Dynamics(): k = 0.08 freq = 1.6 chord = 0.15 dyn = Parameters.Dynamics(k, freq, 0.075, 70, chord, 1000, 1, 1.225) assert dyn.velocity_inf == freq * chord / k assert np.allclose(dyn.theta[250], -dyn.theta0) assert np.allclose(dyn.theta[1000], 0)
def test_processWallshear(): folder_path = os.path.dirname(os.path.abspath(__file__)) k = 0.12 freq = 1.6 chord = 0.15 time_step = 1130 vortex_xC = 0.053220586717218 #vortex_xC is the x position relative to the chord length that the vortex is being shed dyn = Parameters.Dynamics(k, freq, 0.075, 70, chord, 1000, 2, 1.225) output = processWallshear.wallshearData(folder_path + r"\Assets", dyn) assert output[0] == time_step assert np.allclose(output[1], vortex_xC)
def main(files, geo, dyn, axs=2, x=2, CollectData=False): """Runs simulation from reading in input form to processing end data""" if len(os.listdir(files.folder_path)) == 0: Folder_Path = Parameters.path_check( files.folder_path, "\nStore simulation files to %s?\nA) Yes, use/create the folder and save to it \nB) No, I want to specify a different folder directory \nC) No, I want to cancel this process\nPick an answer of A, B, or C: ", 0) files.newFolderPath(Folder_Path) ## Generate Journal Files talkToAnsys.generateMesh_wbjn(files, geo, 1) talkToAnsys.generateFluent_wbjn(files, dyn, 1) if hasattr(files, 'WB_path'): talkToAnsys.run_wbjn(files.WB_path, files.wbjnMesh_path, '-B') yesNo( "Project with Mesh file has been generated. Begin simulation? (This will take a long time)" ) ## Generate C File files = CFile_Generation.genCFile(files, geo, dyn) talkToAnsys.run_wbjn(files.WB_path, files.wbjnFluent_path, '-B')
def genCFile(FilePath, FoilGeo, FoilDyn): print(FoilGeo) print(FoilDyn) if Parameters.query_yes_no("Are these the parameters you want to use to generate a user defined function?")== False: sys.exit("\nPlease enter the desired foil parameters into the input form") # Folder_Path = Parameters.path_check(FilePath.folder_path, "\nStore simulation files to %s?\nA) Yes, use/create the folder and save to it \nB) No, I want to specify a different folder directory \nC) No, I want to cancel this process\nPick an answer of A, B, or C: ") # FilePath.newFolderPath(Folder_Path) parameter_search = np.array([[FoilGeo.chord, 'C_chord_length'], [FoilDyn.rho, 'C_fluid_density'], [FoilDyn.freq, 'C_heaving_frequency'], [FoilDyn.h0, 'C_heaving_amplitude'], [FoilDyn.theta0, 'C_pitching_amplitude'], [FoilDyn.velocity_inf, 'C_velocity_inf']]) UDF_file = open(os.path.dirname(os.path.abspath(__file__)) + "\\AnsysFiles\\Rigid_TemPlate.c", "r").readlines() for param in parameter_search: UDF_file = [w.replace(param[1], param[0]).strip() for w in UDF_file] with open(FilePath.folder_path + "\\modRigidPlateFile.c", "w") as new_UDF_file: for lineitem in UDF_file: new_UDF_file.write('%s\n' % lineitem) print('\nUDF has been generated.\n') if hasattr(__main__, '__file__'): if "test" in __main__.__file__.lower(): return UDF_file return FilePath
import sys from RigidFoilSimer import Parameters from RigidFoilSimer import RigidFoilSimer ## Reading in input form FilePaths = Parameters.FilePath("C:/Users/vicki/Desktop", "githubVersion") FoilGeo = Parameters.Geometry() FoilDyn = Parameters.Dynamics() RigidFoilSimer.main(FilePaths, FoilGeo, FoilDyn)
def test_Geometry(): geo = Parameters.Geometry(0.15, 0.15 * 0.075, 0.15 * 0.3, 0.001, 0.006) assert geo.chord == 0.15 assert np.allclose(geo.trailing_ellipse_origin, 0.069)
def yesNo(prompt): if Parameters.query_yes_no(prompt) == False: sys.exit("Done.")