Skip to content
Snippets Groups Projects
Commit 8d27c055 authored by Florian Schültke's avatar Florian Schültke
Browse files

rce_workflow (schueltke):

 - fixed resume of parameter_study
parent eac2d9e9
No related tags found
No related merge requests found
...@@ -249,11 +249,10 @@ def clean_up_temporary_results(paths_and_names, parameter_for_design_case, contr ...@@ -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 # call function to write parameter study output data to output csv-file
if not skip_saving_flag: if not skip_saving_flag:
status_csv_output, log_file_list = write_parameter_study_csv_output(path_of_working_directory_rce, _, log_file_list = write_parameter_study_csv_output(path_of_working_directory_rce,
path_of_working_directory, path_of_working_directory, copy_target_path,
copy_target_path, parameter_for_design_case, log_file_list,
parameter_for_design_case, current_workflow_name)
log_file_list, current_workflow_name)
''' copy tool error list log-file to log-file results ''' ''' copy tool error list log-file to log-file results '''
if not skip_saving_flag: if not skip_saving_flag:
......
...@@ -142,13 +142,12 @@ def initialize_parameter_study(paths_and_names, log_file_list): ...@@ -142,13 +142,12 @@ def initialize_parameter_study(paths_and_names, log_file_list):
if reproduce_output_file_from_old_study == 1: if reproduce_output_file_from_old_study == 1:
# check if the working directory of old study is existing # check if the working directory of old study is existing
# -> if true: -> set path of old study to path of current # -> 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): 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 # set path to reference case of old parameter study to resume
path_to_folder_old_reference = path_to_folder_old_study + 'reference_aircraft/' 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 # 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): if os.path.isdir(path_to_folder_old_reference):
temporary_working_directory = path_of_working_directory_rce + current_workflow_name 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): ...@@ -156,11 +155,11 @@ def initialize_parameter_study(paths_and_names, log_file_list):
paths_and_names, abort_parameter_study_flag, 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, prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_reference,
temporary_working_directory, log_file_list) temporary_working_directory, log_file_list)
if not abort_parameter_study_flag:
# call function to check which parameter is next to analyse # call function to check which parameter is next to analyse
abort_parameter_study_flag, number_of_total_steps, log_file_list = \ 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, set_parameter_for_resume_parameter_study(paths_and_names, path_to_folder_old_study,
log_file_list) log_file_list)
# else condition: the reference aircraft directory does not exist -> abort parameter study # else condition: the reference aircraft directory does not exist -> abort parameter study
else: else:
......
...@@ -115,13 +115,16 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere ...@@ -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) list_of_temporary_files = os.listdir(temporary_working_directory)
for list_element in list_of_temporary_files: 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 # 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) shutil.rmtree(temporary_working_directory + '/' + list_element)
# else condition: current list element is a file -> delete file # else condition: current list element is a file -> delete file
else: else:
# check if the current file is not the workflow log file -> if true: -> delete file # 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) os.remove(temporary_working_directory + '/' + list_element)
# read name of aircraft project from old parameter study # 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 ...@@ -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 # create new aircraft project folder in temporary working directory
if not os.path.isdir(temporary_working_directory + '/' + aircraft_project[:-4]): 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 # create new temporary result folder in temporary working directory
if not os.path.isdir(temporary_working_directory + '/temporaryResults'): 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 ...@@ -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'): if not os.path.isdir(temporary_working_directory + '/temp'):
os.mkdir(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) 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 abort_parameter_study_flag = True
for element in list_of_elements: for element in list_of_elements:
...@@ -179,18 +184,12 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere ...@@ -179,18 +184,12 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere
temporary_working_directory + '/' + aircraft_project[:-4] + '/' temporary_working_directory + '/' + aircraft_project[:-4] + '/'
xml_tree.write(path, encoding='utf-8') xml_tree.write(path, encoding='utf-8')
else:
abort_parameter_study_flag = True
# reset engine files to files of old parameter study # reset engine files to files of old parameter study
if element == 'engine_data': if element == 'engine_data':
shutil.copytree(path_to_folder_old_reference + element, shutil.copytree(path_to_folder_old_reference + element,
temporary_working_directory + '/' + aircraft_project[:-4] + '/engine_data') temporary_working_directory + '/' + aircraft_project[:-4] + '/engine_data')
else: # reset all clean sheet design files to files of old parameter study
abort_parameter_study_flag = True
# reset all lean sheet design files to files of old parameter study
if element == 'results': if element == 'results':
list_of_results = os.listdir(path_to_folder_old_reference + element) list_of_results = os.listdir(path_to_folder_old_reference + element)
for result in list_of_results: for result in list_of_results:
...@@ -214,9 +213,6 @@ def prepare_resume_of_parameter_study(paths_and_names, path_to_folder_old_refere ...@@ -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, shutil.copyfile(path_to_folder_old_reference + element,
temporary_working_directory + '/' + aircraft_project[:-4] + '/' + element) temporary_working_directory + '/' + aircraft_project[:-4] + '/' + element)
else:
abort_parameter_study_flag = True
# check if the current element contains the string 'CPACS' # check if the current element contains the string 'CPACS'
# -> if true: -> copy aircraft exchange file to project folder # -> if true: -> copy aircraft exchange file to project folder
if 'start' in element: if 'start' in element:
......
...@@ -100,7 +100,7 @@ def write_parameter_study_csv_output(path_of_working_directory_rce, path_of_work ...@@ -100,7 +100,7 @@ def write_parameter_study_csv_output(path_of_working_directory_rce, path_of_work
"./ProgramSettings/ParameterSettings/OutputParameters").text) "./ProgramSettings/ParameterSettings/OutputParameters").text)
''' write header to output csv-file of current parameter ''' ''' 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: if global_loop_counter == 1:
header_string = '# ID;' + 'reference aircraft;' header_string = '# ID;' + 'reference aircraft;'
print('Header string of reference case successfully writen to parameter study output csv-file!') 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 ...@@ -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 ' 'Header string of reference case successfully writen to parameter study '
'output csv-file!') 'output csv-file!')
if study_counter == 1: if study_counter <= 1:
header_string = '# ID;' + parameter_name + ';' header_string = '# ID;' + parameter_name + ';'
print('Header string of current input parameter successfully writen to parameter study output csv-file.') 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')) + ': ' 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 ...@@ -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 # generate the first two entries of output string
if global_loop_counter == 1: if global_loop_counter == 1:
value_string = 'run_' + str(global_loop_counter) + ';' + 'refCase;' 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: else:
value_string = 'run_' + str(study_counter) + ';' + str(new_value_of_input) + ';' value_string = 'run_' + str(study_counter) + ';' + str(new_value_of_input) + ';'
......
...@@ -476,13 +476,19 @@ def check_design_logic(paths_and_names, parameter_for_design_case, control_setti ...@@ -476,13 +476,19 @@ def check_design_logic(paths_and_names, parameter_for_design_case, control_setti
# call function to initialize parameter study # call function to initialize parameter study
abort_parameter_study_flag, outer_loop_counter, log_file_list = initialize_parameter_study(paths_and_names, abort_parameter_study_flag, outer_loop_counter, log_file_list = initialize_parameter_study(paths_and_names,
log_file_list) 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 # 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: 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 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 ''' ''' write log-file to system '''
log_file_list.append('********************************************** end check design logic ' log_file_list.append('********************************************** end check design logic '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment