diff --git a/UNICADOworkflow/src/clean_up/clean_up_temporary_results.py b/UNICADOworkflow/src/clean_up/clean_up_temporary_results.py index c807607b94ff775ce64663a827d934969b180ed7..338ceb41b10fab905bff1d37c3b1811e3b492e6d 100644 --- a/UNICADOworkflow/src/clean_up/clean_up_temporary_results.py +++ b/UNICADOworkflow/src/clean_up/clean_up_temporary_results.py @@ -249,11 +249,10 @@ def clean_up_temporary_results(paths_and_names, parameter_for_design_case, contr # call function to write parameter study output data to output csv-file if not skip_saving_flag: - status_csv_output, log_file_list = write_parameter_study_csv_output(path_of_working_directory_rce, - path_of_working_directory, - copy_target_path, - parameter_for_design_case, - log_file_list, current_workflow_name) + _, log_file_list = write_parameter_study_csv_output(path_of_working_directory_rce, + path_of_working_directory, copy_target_path, + parameter_for_design_case, log_file_list, + current_workflow_name) ''' copy tool error list log-file to log-file results ''' if not skip_saving_flag: diff --git a/UNICADOworkflow/src/parameter_study/initialize_parameter_study.py b/UNICADOworkflow/src/parameter_study/initialize_parameter_study.py index 91753f87d9b047b51c55f8f457a7bfc1e5e57048..9811794f7381eee03cad010bbd2b1c2d557497ba 100644 --- a/UNICADOworkflow/src/parameter_study/initialize_parameter_study.py +++ b/UNICADOworkflow/src/parameter_study/initialize_parameter_study.py @@ -142,13 +142,12 @@ def initialize_parameter_study(paths_and_names, log_file_list): if reproduce_output_file_from_old_study == 1: # check if the working directory of old study is existing # -> if true: -> set path of old study to path of current + corrected_path_is_absolute, path_to_folder_old_study = path_check(path_to_folder_old_study) + if not corrected_path_is_absolute: + path_to_folder_old_study = path_of_working_directory_rce + path_to_folder_old_study if os.path.isdir(path_to_folder_old_study): - # call function to check the path of old study - _, path_to_folder_old_study = path_check(path_to_folder_old_study) - # set path to reference case of old parameter study to resume path_to_folder_old_reference = path_to_folder_old_study + 'reference_aircraft/' - # check if the reference aircraft directory exist -> if true perform the resume of the parameter study if os.path.isdir(path_to_folder_old_reference): temporary_working_directory = path_of_working_directory_rce + current_workflow_name @@ -156,11 +155,11 @@ def initialize_parameter_study(paths_and_names, log_file_list): paths_and_names, abort_parameter_study_flag, log_file_list =\ prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_reference, temporary_working_directory, log_file_list) - - # call function to check which parameter is next to analyse - abort_parameter_study_flag, number_of_total_steps, log_file_list = \ - set_parameter_for_resume_parameter_study(paths_and_names, path_to_folder_old_study, - log_file_list) + if not abort_parameter_study_flag: + # call function to check which parameter is next to analyse + abort_parameter_study_flag, number_of_total_steps, log_file_list = \ + set_parameter_for_resume_parameter_study(paths_and_names, path_to_folder_old_study, + log_file_list) # else condition: the reference aircraft directory does not exist -> abort parameter study else: diff --git a/UNICADOworkflow/src/parameter_study/prepare_resume_of_parameter_study.py b/UNICADOworkflow/src/parameter_study/prepare_resume_of_parameter_study.py index 7cac7875347697eb1eae82b991955660f0af7ac4..0827eb45f49e9ae911fc0d416551a3b44a8d80e8 100644 --- a/UNICADOworkflow/src/parameter_study/prepare_resume_of_parameter_study.py +++ b/UNICADOworkflow/src/parameter_study/prepare_resume_of_parameter_study.py @@ -115,13 +115,16 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere list_of_temporary_files = os.listdir(temporary_working_directory) for list_element in list_of_temporary_files: # check if current list element is a directory -> if true: -> delete directory and sub folder if exist - if os.path.isdir(temporary_working_directory + '/' + list_element): + if (os.path.isdir(temporary_working_directory + '/' + list_element) + and not list_element == 'fuselage_design_lib' + and not list_element == 'landing_gear_lib'): shutil.rmtree(temporary_working_directory + '/' + list_element) # else condition: current list element is a file -> delete file else: # check if the current file is not the workflow log file -> if true: -> delete file - if not list_element == 'unicado_workflow.log': + if (os.path.isfile(temporary_working_directory + '/' + list_element) + and not list_element == 'unicado_workflow.log'): os.remove(temporary_working_directory + '/' + list_element) # read name of aircraft project from old parameter study @@ -130,7 +133,7 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere # create new aircraft project folder in temporary working directory if not os.path.isdir(temporary_working_directory + '/' + aircraft_project[:-4]): - os.makedirs(temporary_working_directory + '/' + aircraft_project[:-4] + '/cleanSheetDesign') + os.makedirs(temporary_working_directory + '/' + aircraft_project[:-4] + '/clean_sheet_design') # create new temporary result folder in temporary working directory if not os.path.isdir(temporary_working_directory + '/temporaryResults'): @@ -140,9 +143,11 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere if not os.path.isdir(temporary_working_directory + '/temp'): os.mkdir(temporary_working_directory + '/temp') - # read elements from old parameter study directory + # read elements from old parameter study directory and check of required files are there list_of_elements = os.listdir(path_to_folder_old_reference) - if not 'parameter_study_conf.xml' in list_of_elements: + if (not 'parameter_study_conf.xml' in list_of_elements + or not 'config_files/preExecution' in list_of_elements + or not 'engine_data' in list_of_elements): abort_parameter_study_flag = True for element in list_of_elements: @@ -179,18 +184,12 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere temporary_working_directory + '/' + aircraft_project[:-4] + '/' xml_tree.write(path, encoding='utf-8') - else: - abort_parameter_study_flag = True - # reset engine files to files of old parameter study if element == 'engine_data': shutil.copytree(path_to_folder_old_reference + element, temporary_working_directory + '/' + aircraft_project[:-4] + '/engine_data') - else: - abort_parameter_study_flag = True - - # reset all lean sheet design files to files of old parameter study + # reset all clean sheet design files to files of old parameter study if element == 'results': list_of_results = os.listdir(path_to_folder_old_reference + element) for result in list_of_results: @@ -214,9 +213,6 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere shutil.copyfile(path_to_folder_old_reference + element, temporary_working_directory + '/' + aircraft_project[:-4] + '/' + element) - else: - abort_parameter_study_flag = True - # check if the current element contains the string 'CPACS' # -> if true: -> copy aircraft exchange file to project folder if 'start' in element: diff --git a/UNICADOworkflow/src/parameter_study/write_parameter_study_csv_output.py b/UNICADOworkflow/src/parameter_study/write_parameter_study_csv_output.py index 27bfcbc13bdd82a0054188ca1a294aacc8d47bb6..3e59036a15b164ec1116f9a98e7475b32bc25266 100644 --- a/UNICADOworkflow/src/parameter_study/write_parameter_study_csv_output.py +++ b/UNICADOworkflow/src/parameter_study/write_parameter_study_csv_output.py @@ -100,7 +100,7 @@ def write_parameter_study_csv_output(path_of_working_directory_rce, path_of_work "./ProgramSettings/ParameterSettings/OutputParameters").text) ''' write header to output csv-file of current parameter ''' - if global_loop_counter == 1 or study_counter == 1: + if global_loop_counter == 1 or study_counter <= 1: if global_loop_counter == 1: header_string = '# ID;' + 'reference aircraft;' print('Header string of reference case successfully writen to parameter study output csv-file!') @@ -108,7 +108,7 @@ def write_parameter_study_csv_output(path_of_working_directory_rce, path_of_work 'Header string of reference case successfully writen to parameter study ' 'output csv-file!') - if study_counter == 1: + if study_counter <= 1: header_string = '# ID;' + parameter_name + ';' print('Header string of current input parameter successfully writen to parameter study output csv-file.') log_file_list.append(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S')) + ': ' @@ -197,6 +197,8 @@ def write_parameter_study_csv_output(path_of_working_directory_rce, path_of_work # generate the first two entries of output string if global_loop_counter == 1: value_string = 'run_' + str(global_loop_counter) + ';' + 'refCase;' + elif study_counter == 0: + value_string = 'run_' + str(study_counter + 1) + ';' + str(new_value_of_input) + ';' else: value_string = 'run_' + str(study_counter) + ';' + str(new_value_of_input) + ';' diff --git a/UNICADOworkflow/src/pre_condition/check_design_logic.py b/UNICADOworkflow/src/pre_condition/check_design_logic.py index 71ddeba88531cb4859ce18de1f1626813365b486..3201d86eaf1dc3b7604d6391278909e84abbef3a 100644 --- a/UNICADOworkflow/src/pre_condition/check_design_logic.py +++ b/UNICADOworkflow/src/pre_condition/check_design_logic.py @@ -476,13 +476,19 @@ def check_design_logic(paths_and_names, parameter_for_design_case, control_setti # call function to initialize parameter study abort_parameter_study_flag, outer_loop_counter, log_file_list = initialize_parameter_study(paths_and_names, log_file_list) - print(' * ------ end initialize parameter study ------') - log_file_list.append(' * ------ end initialize parameter study ------') # check if the abort_parameter_study_flag is equal to True -> if true: -> set parameter_study_mode switch to 0 if abort_parameter_study_flag: + print('Error in preparation of parameter_study.' + ' Abort parameter_study and continue with standard aircraft design!') + log_file_list.append('Error in preparation of parameter_study.' + ' Abort parameter_study and continue with standard aircraft design!') outer_loop_counter = back_up_outer_loop_counter - ([item for item in parameter_for_design_case if 'parameter_study_mode' in item])[-1][-1] = int(0) + ([item for item in parameter_for_design_case if 'program_mode' in item])[-1][-1] =\ + 'standard_aircraft_design' + + print(' * ------ end initialize parameter study ------') + log_file_list.append(' * ------ end initialize parameter study ------') ''' write log-file to system ''' log_file_list.append('********************************************** end check design logic '