def load_surfaces(self): try: surface_list = read_lifting_surface_objects() if len(surface_list) == 0: self.new_surfaces() else: for l in surface_list: design_type_, surface_type_ = get_surface_object_data(l) if design_type_ == unconventional_design: self.surfaca_tab_ = lifting_surface_pane( l, surface_type_, design_type_) self.surfaces.append(self.surfaca_tab_) self.inputArea.addTab(self.surfaca_tab_, l) self.indexes.append(l) elif design_type_ == conventional_design: if surface_type_ == fin: self.surfaca_tab_ = v_stab_tab( l, surface_type_, design_type_) self.surfaces.append(self.surfaca_tab_) self.inputArea.addTab(self.surfaca_tab_, l) self.indexes.append(l) elif surface_type_ == tailplane: self.surfaca_tab_ = h_stab_tab( l, surface_type_, design_type_) self.surfaces.append(self.surfaca_tab_) self.inputArea.addTab(self.surfaca_tab_, l) self.indexes.append(l) else: self.surfaca_tab_ = wing_tab( l, surface_type_, design_type_) self.surfaces.append(self.surfaca_tab_) self.inputArea.addTab(self.surfaca_tab_, l) self.indexes.append(l) except: self.new_surfaces()
def show_default_values(self, root_location_x_=0, root_location_y_=0, root_location_z_=0, rot_x_=0, rot_y_=0, rot_z_=0, span_=0, chord_=0, parent__=""): self.span_text.setText(str(span_)) try: self.itemsComboBox.setCurrentIndex( read_lifting_surface_objects().index(parent__)) except: pass self.chord_length_text.setText(str(chord_)) self.rotation_x_text.setText(str(rot_x_)) self.rotation_y_text.setText(str(rot_y_)) self.rotation_z_text.setText(str(rot_z_)) self.vtp_position_x_text.setText(str(root_location_x_)) self.vtp_position_y_text.setText(str(root_location_y_)) self.Wing_postion_z_text.setText(str(root_location_z_))
def __init__(self, name=""): super().__init__() self.name = name layout = QFormLayout(self) self.tab = self self.selection_ = None ########################################################################## ################################################################################## ########################################################################## layout.addRow(QLabel("Select Lifting Surface to attach to")) self.itemsComboBox = QComboBox() self.itemsComboBox.addItems(read_lifting_surface_objects()) self.itemsComboBox.currentIndexChanged.connect(self.selectionChanged) layout.addRow(self.itemsComboBox) ################################################################################## self.span_label = QLabel("Span") self.span_text = QLineEdit() layout.addRow(self.span_label, self.span_text) ############################################################################## self.chord_length_label = QLabel("Chord Length") self.chord_length_text = QLineEdit() layout.addRow(self.chord_length_label, self.chord_length_text) self.rotation_label = QLabel("Rotation(XYZ)") layout.addRow(self.rotation_label) self.rotation_x_label = QLabel("X") self.rotation_x_text = QLineEdit() layout.addRow(self.rotation_x_label, self.rotation_x_text) self.rotation_y_label = QLabel("Y") self.rotation_y_text = QLineEdit() layout.addRow(self.rotation_y_label, self.rotation_y_text) self.rotation_z_label = QLabel("Z") self.rotation_z_text = QLineEdit() layout.addRow(self.rotation_z_label, self.rotation_z_text) ################################################################################## self.Wing_postion_tlabel = QLabel("Position") layout.addWidget(self.Wing_postion_tlabel) self.Wing_postion_x_label = QLabel("X") self.vtp_position_x_text = QLineEdit() layout.addRow(self.Wing_postion_x_label, self.vtp_position_x_text) self.Wing_postion_y_label = QLabel("Y") self.vtp_position_y_text = QLineEdit() layout.addRow(self.Wing_postion_y_label, self.vtp_position_y_text) self.Wing_postion_z_label = QLabel("Z") self.Wing_postion_z_text = QLineEdit() layout.addRow(self.Wing_postion_z_label, self.Wing_postion_z_text) self.zero_all_textfields()
def update_surface_lower_3d(config=None): surface_list = read_lifting_surface_objects() lofts = {} for l in surface_list: design_type_, surface_type_ = get_surface_object_data(l) lofts.update({ l: generate_wing_lower_3D(config, l, surface_type_, design_type_) }) return lofts
def get_surface_for_vlm(): from aerosandbox_legacy_v0 import WingXSec, Wing, Airfoil from Utils.data_objects.lifting_surface_placeholder import wing wings = [] surface_list = read_lifting_surface_objects() for l in surface_list: design_type_, surface_type_ = get_surface_object_data(l) if design_type_ == unconventional_design: from aerosandbox_legacy_v0 import Wing x, y, z, chords, twist_, profile_, root_location_x, root_location_y, root_location_z, xz_mirror_ = get_parameters_for_unconventional( l) xsecs = [] for x_, y_, z_, chord_, t in zip(x, y, z, chords, twist_): xsecs.append( WingXSec( # Root xyz_le=[x_, y_, z_], chord=chord_, twist=t, airfoil=Airfoil(name=profile_))) wings.append( Wing( name=l, xyz_le=[root_location_x, root_location_y, root_location_z], # Coordinates of the wing's leading edge symmetric=xz_mirror_, xsecs=xsecs)) elif design_type_ == conventional_design: x, y, z, chords, twist, profile_, root_location_x, root_location_y, root_location_z = get_parameters_for_conventional( l, surface_type_) xsecs = [] for x_, y_, z_, chord_ in zip(x, y, z, chords): if surface_type_ == wing or surface_type_ == tailplane: xsecs.append( WingXSec( # Root xyz_le=[x_, y_, z_], chord=chord_, twist=twist, airfoil=Airfoil(name=profile_))) elif surface_type_ == fin: print(fin) xsecs.append( WingXSec( # Root xyz_le=[x_, z_, y_], chord=chord_, twist=twist, airfoil=Airfoil(name=profile_))) wings.append( Wing( name=l, xyz_le=[root_location_x, root_location_y, root_location_z], symmetric=True if surface_type_ == wing or surface_type_ == tailplane else False, xsecs=xsecs)) return wings
def init_action(self): self.parameters = { control_surface: { self.name: { root_le_position_x: float(self.vtp_position_x_text.text()), root_le_position_y: float(self.vtp_position_y_text.text()), root_le_position_z: float(self.Wing_postion_z_text.text()), parent_: self.selection_ if self.selection_ is not None else read_lifting_surface_objects()[ self.itemsComboBox.currentIndex()], span: float(self.span_text.text()), rotation_x: float(self.rotation_x_text.text()), rotation_y: float(self.rotation_y_text.text()), rotation_z: float(self.rotation_z_text.text()), chord: float(self.chord_length_text.text()), } } } try: database.update_aircraft_specifications( key=control_surface, value=self.parameters[control_surface]) except: database.write_aircraft_specification(self.parameters) write_control_surface_objects(value=self.name) write_control_surface_to_objects( surface_name=self.name, parent__=self.selection_ if self.selection_ is not None else read_lifting_surface_objects()[self.itemsComboBox.currentIndex()]) return self.parameters
def __init__(self): super().__init__() self.selection_ = None self.layout = QFormLayout(self) self.itemsComboBox = QComboBox() self.itemsComboBox.addItems(read_lifting_surface_objects()) self.itemsComboBox.currentIndexChanged.connect(self.selectionChanged) self.layout.addRow(self.itemsComboBox) self.buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.layout.addRow(self.buttons) self.setLayout(self.layout)
def build_datcom_input(): surface_list = read_lifting_surface_objects() ls_statements = [] boom_statements = [] synths={} for l in surface_list: design_type_, surface_type_ = get_surface_object_data(l) span_, tip_chord, root_chord, dihedral_, sweep_ = 0, 0, 0, 0, 0 profile_="0012" if design_type_ == unconventional_design: span_, tip_chord, root_chord, dihedral_, sweep_,profile_ = get_parameters_from_sections_lifting_surface(l) elif design_type_ == conventional_design: print(l) span_, tip_chord, root_chord, dihedral_, sweep_,profile_ = get_parameters_from_conventional_wing(l) print(profile_.split("naca")) if surface_type_ == wing: synths.update({"wing": span_ / 2}) ls_statements.append(set_planform_parameters( type_1="W,G", tip_chord=tip_chord, root_chord=root_chord, semi_span=(span_ / 2), sweep_angle=sweep_, dihedral_=1.2, profile=profile_.split("naca")[1] )) elif surface_type_ == fin: synths.update({"vtp":span_ / 2}) ls_statements.append(set_planform_parameters( type_1="V,T", tip_chord=tip_chord, root_chord=root_chord, semi_span=(span_ / 2), sweep_angle=sweep_, dihedral_=1.3, profile=profile_.split("naca")[1] )) else: synths.update({"vtp": span_ / 2}) ls_statements.append(set_planform_parameters( type_1="H,T", tip_chord=tip_chord, root_chord=root_chord, semi_span=(span_ / 2), sweep_angle=sweep_, dihedral_=1.3, profile=profile_.split("naca")[1] )) try: boom_list = read_boom_objects() for l in boom_list: design_type_, surface_type_ = get_boom_object_data(l) if design_type_ == unconventional_design: pass elif design_type_ == conventional_design: radii, x, z = get_parameters_from_conventional_boom(l) boom_statements.append(set_body_parameters_radius(section_positions=x, radius_of_sections=radii, iter_=(boom_list.index(l) + 1))) except: pass mesh = get_center_of_mass() try: value=synths["vtp"] except: synths.update({"vtp":0}) try: value=synths["htp"] except: synths.update({"htp":0}) input_ = "".join([set_flight_conditions(mach_numbers=get_mach_number(), angle_of_attack=get_aoa_range(), altitude=get_altitude()), set_synths_parameters(center_of_gravity_x=round(mesh["x"],2),center_of_gravity_z=round(mesh["z"],2), vtp_tip_position_x=round(synths.get("vtp"),2), htp_tip_position_x=round(synths.get("htp"),2)), "".join(ls_statements), "".join(boom_statements), create_footer()]) database.write_datcom_input(input=input_)
def selectionChanged(self, i): self.selection_ = read_lifting_surface_objects()[i]
def update_surface_3D(workflow=None): surface_list = read_lifting_surface_objects() for l in surface_list: design_type_, surface_type_ = get_surface_object_data(l) generate_wing_3D(workflow, l, surface_type_, design_type_)
def accept_inputs(self): if self.selection_ is None: self.selection_ = read_lifting_surface_objects()[ self.itemsComboBox.currentIndex()] return (self.selection_)