Skip to content
Snippets Groups Projects
Commit f670abd6 authored by AndiGob's avatar AndiGob
Browse files

fuselage_design: - fix of additional fuselage length for running LH2 aircraft

parent e154778a
No related branches found
No related tags found
1 merge request!246fuselage_design: - fix of additional fuselage length for running LH2 aircraft
......@@ -70,15 +70,38 @@ def blended_wing_body_design(paths_and_names, routing_dict, dict_ac_exchange, di
''' Run fuselage design '''
# List all entries in the directory
all_entries = os.listdir(paths_and_names['working_directory'] + '/' +
routing_dict['module_import_name'].replace('.', '/') + '/general/call_functions')
# Filter out only files (ignore directories)
call_function_list = [entry for entry in all_entries
if os.path.isfile(paths_and_names['working_directory'] + '/' +
routing_dict['module_import_name'].replace('.', '/')
+ '/general/call_functions' + '/' + entry)]
# If the script is compiled, sys._MEIPASS gives the temp directory for PyInstaller.
if getattr(sys, 'frozen', False):
# List all entries in the directory.
all_entries = os.listdir(sys._MEIPASS + '/' +
routing_dict['module_import_name'].replace('.', '/') + '/general/call_functions')
# Filter out only files (ignore directories)
call_function_list = [entry for entry in all_entries
if os.path.isfile(sys._MEIPASS + '/' + routing_dict['module_import_name'].replace('.', '/')
+ '/general/call_functions' + '/' + entry)]
# Check if the system prefix is different from the base prefix -> code is runnig in a vitual environment
elif hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
# List all entries in the directory.
all_entries = os.listdir(paths_and_names['working_directory'] + '/' +
routing_dict['module_import_name'].replace('.', '/') + '/general/call_functions')
# Filter out only files (ignore directories).
call_function_list = [entry for entry in all_entries
if os.path.isfile(paths_and_names['working_directory'] + '/' +
routing_dict['module_import_name'].replace('.', '/')
+ '/general/call_functions' + '/' + entry)]
# If running as a regular Python script, use the current directory.
else:
# List all entries in the directory.
all_entries = os.listdir(os.getcwd() + '/' +
routing_dict['module_import_name'].replace('.', '/') + '/general/call_functions')
# Filter out only files (ignore directories).
call_function_list = [entry for entry in all_entries
if os.path.isfile(os.getcwd() + '/' +
routing_dict['module_import_name'].replace('.', '/')
+ '/general/call_functions' + '/' + entry)]
print(paths_and_names['working_directory'])
# Remove unnecessary files from call function list.
for file in files_to_remove:
if file in call_function_list:
......@@ -134,7 +157,7 @@ def blended_wing_body_design(paths_and_names, routing_dict, dict_ac_exchange, di
root_of_module_config_tree = paths_and_names['root_of_module_config_tree']
plot_switch = (eval(root_of_module_config_tree.find('.//plot_output/enable/value').text.capitalize()))
if plot_switch:
plot_payload_tubes(paths_and_names, payload_tube_description, runtime_output)
plot_payload_tubes(paths_and_names, dict_ac_exchange, payload_tube_description, runtime_output)
''' debug print '''
runtime_output.debug('Debug: The blended_wing_body_design function was successfully executed!')
......
......@@ -28,7 +28,7 @@ from numpy import meshgrid
import matplotlib.pyplot as plt
def plot_payload_tubes(project_definition, payload_tube_description, paths_and_names):
def plot_payload_tubes(paths_and_names, dict_ac_exchange, payload_tube_description, project_definition):
# Check path to directory for figure outputs
project_directory = paths_and_names["project_directory"]
plot_directory = project_directory + '/reporting/plots'
......@@ -43,15 +43,15 @@ def plot_payload_tubes(project_definition, payload_tube_description, paths_and_
# generate cylinder coordinates for each passenger tube
for tube in range(0, dict_ac_exchange['number_of_payload_tubes']):
# generate cylinder coordinates for plotting
z = linspace(round(geometry_dict["tube_center_reference_points"][tube][0] * 2.54 / 100, 3),
round(geometry_dict["tube_center_reference_points"][tube][0] * 2.54 / 100, 3)
+ round(geometry_dict["tube_length"][tube] * 2.54 / 100, 3), 50)
z = linspace(round(payload_tube_description["tube_center_reference_points"][tube][0] * 2.54 / 100, 3),
round(payload_tube_description["tube_center_reference_points"][tube][0] * 2.54 / 100, 3)
+ round(payload_tube_description["tube_length"][tube] * 2.54 / 100, 3), 50)
theta = linspace(0, 2 * pi, 50)
theta_grid, z_grid = meshgrid(theta, z)
x_grid = round(geometry_dict["tube_width"][tube] * 2.54 / 100, 3) / 2 * cos(theta_grid) \
+ round(geometry_dict["tube_wall_reference_points"][tube][3][2][1] * 2.54 / 100, 3)
y_grid = round(geometry_dict["tube_width"][tube] * 2.54 / 100, 3) / 2 * sin(theta_grid) \
+ round(geometry_dict["tube_center_reference_points"][tube][1] * 2.54 / 100, 3)
x_grid = round(payload_tube_description["tube_width"][tube] * 2.54 / 100, 3) / 2 * cos(theta_grid) \
+ round(payload_tube_description["tube_wall_reference_points"][tube][3][2][1] * 2.54 / 100, 3)
y_grid = round(payload_tube_description["tube_width"][tube] * 2.54 / 100, 3) / 2 * sin(theta_grid) \
+ round(payload_tube_description["tube_center_reference_points"][tube][1] * 2.54 / 100, 3)
# generate surface plot of passenger tube
ax.plot_surface(y_grid, z_grid, x_grid, alpha=0.3, color='grey')
......
......@@ -179,16 +179,6 @@ def fuselage_design(paths_and_names, routing_dict, dict_ac_exchange, dict_mod_co
constant_section_calculation(dict_ac_exchange, fuselage_description['geometry_description'],
dict_fuselage_deign_output, runtime_output)
# Check if an additional fuselage length exist -> if true: -> add delta in x direction to x-cords of tail section
if dict_ac_exchange['additional_fuselage_length'] is not None:
for i in range(1, len(dict_fuselage_deign_output['tail_section']['x_direction_coordinates']) + 1):
new_x_values_for_tail_section = \
[round(x + (dict_ac_exchange['additional_fuselage_length'] * convert_meter_to_inch), 2)
for x in dict_fuselage_deign_output['tail_section']['x_direction_coordinates'][
'ellipse_number_' + str(i)]]
dict_fuselage_deign_output['tail_section']['x_direction_coordinates']['ellipse_number_' + str(i)] \
= new_x_values_for_tail_section
''' Set total section parameter '''
# cockpit sections
for key, value in dict_fuselage_deign_output['cockpit_section']['output_data']['origin'].items():
......
......@@ -163,8 +163,6 @@ def constant_section_calculation(dict_ac_exchange, geometry_description, dict_fu
i = 0
while i < len(center_coordinates):
constant_section['output_data']['origin']['ellipses_' + str(i)] = {'x': float(), 'y': float(), 'z': float()}
constant_section['output_data']['origin']['ellipses_' + str(i)]['x'] = \
round(x_coordinates[i] * convert_inch_to_meter, 9)
constant_section['output_data']['origin']['ellipses_' + str(i)]['y'] = 0.0
constant_section['output_data']['origin']['ellipses_' + str(i)]['z'] = \
round(center_coordinates[i] * convert_inch_to_meter, 9)
......@@ -175,6 +173,12 @@ def constant_section_calculation(dict_ac_exchange, geometry_description, dict_fu
constant_section['output_data']['width']['ellipses_' + str(i)] = \
round(abs(2 * y_coordinates[i] * convert_inch_to_meter), 9)
i += 1
number_of_cockpit_sections = len(dict_fuselage_deign_output['cockpit_section']['output_data']['origin'])
constant_section['output_data']['origin']['ellipses_0']['x'] = \
dict_fuselage_deign_output['cockpit_section']['output_data']['origin']['ellipses_' + str(number_of_cockpit_sections - 1)]['x']
constant_section['output_data']['origin']['ellipses_1']['x'] = \
dict_fuselage_deign_output['tail_section']['output_data']['origin']['ellipses_0']['x']
''' debug print '''
runtime_output.debug('Debug: The constant_section_calculation function was successfully executed!')
......
......@@ -163,8 +163,14 @@ def tail_section_calculation(dict_ac_exchange, geometry_description, runtime_out
i = 0
while i < len(center_coordinates):
tail_section['output_data']['origin']['ellipses_' + str(i)] = {'x': float(), 'y': float(), 'z': float()}
tail_section['output_data']['origin']['ellipses_' + str(i)]['x'] = \
round(x_coordinates[i] * convert_inch_to_meter, 9)
# Check if an additional fuselage length exist -> if true: -> add delta in x direction to x-cords of tail section
if dict_ac_exchange['additional_fuselage_length'] is not None:
tail_section['output_data']['origin']['ellipses_' + str(i)]['x'] = \
(round(x_coordinates[i] * convert_inch_to_meter, 9)
+ dict_ac_exchange['additional_fuselage_length'])
else:
tail_section['output_data']['origin']['ellipses_' + str(i)]['x'] = \
round(x_coordinates[i] * convert_inch_to_meter, 9)
tail_section['output_data']['origin']['ellipses_' + str(i)]['y'] = 0.0
tail_section['output_data']['origin']['ellipses_' + str(i)]['z'] = \
round(center_coordinates[i] * convert_inch_to_meter, 9)
......
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