def load_external_libs(): try: global tixi_h tixi_h = tixiwrapper.Tixi() print("TIXI version: ", tixi_h.version) except Exception as e: print("Could not load TIXI! Error message is: {}".format(e))
def main(): # Init TiXI tixi_h = tixiwrapper.Tixi() tixi_h.open('toolOutput.xml') # Init TiGL tigl_h = tiglwrapper.Tigl() tigl_h.open(tixi_h, 'AircraftModel') # Extract wing: mgr = CCPACSConfigurationManager_get_instance() aircraft_config = mgr.get_configuration(tigl_h._handle.value) wing = aircraft_config.get_wing("wing") wing_shape = wing.get_loft().shape() # Do the slicing: wing_section = slicing(wing_shape, 0.5) # Discretize the section: pnts, face_ids = discretize(wing_section, 1e-5) # Plot results: display, start_display, add_menu, add_function_to_menu = init_display() display.DisplayShape(wing_shape, transparency=0.8, update=True) display.DisplayShape(wing_section, color='red', update=True) start_display() plt.plot(pnts[:, 0], pnts[:, 2], '.') plt.show()
def initialize(file): global tixi, tigl from tixi import tixiwrapper from tigl import tiglwrapper tixi = tixiwrapper.Tixi() tixi.open(file) tigl = tiglwrapper.Tigl() tigl.open(tixi, 'AircraftModel') from . import utils global_namespace = globals() for function in __all__: global_namespace[function] = getattr(utils, function) return tixi, tigl
def simple_test(): file_name = "tests/TestData/simpletest.cpacs.xml" old_cpacs_file = tixiwrapper.Tixi() new_cpacs_file = tixi3wrapper.Tixi3() new_cpacs_file.open(file_name) new_cpacs_file.setCacheEnabled(1) new_cpacs_file.usePrettyPrint(1) uid_manager.register_all_uids(new_cpacs_file) uid_manager.fix_invalid_uids(new_cpacs_file) fix_empty_elements(new_cpacs_file) old_cpacs_file.openString(new_cpacs_file.exportDocumentAsString()) return TestCase(file_name, old_cpacs_file, new_cpacs_file)
def upgrade_2_to_3(cpacs_handle, args): filename = args.input_file if args.fix_errors: file_has_changed = uid_manager.fix_invalid_uids(cpacs_handle) file_has_changed = fix_empty_elements(cpacs_handle) or file_has_changed file_has_changed = fix_guide_curve_profile_element_names(cpacs_handle) or file_has_changed if file_has_changed: logging.info("A fixed cpacs2 file will be stored to '%s'" % (filename + ".fixed")) with open(filename + ".fixed", "w") as text_file: text_file.write(cpacs_handle.exportDocumentAsString()) # copy cpacs file into tixi 2 to make tigl2 happy old_cpacs_file = tixiwrapper.Tixi() old_cpacs_file.openString(cpacs_handle.exportDocumentAsString()) change_cpacs_version(cpacs_handle, "3.0") convert_cpacs_xml(cpacs_handle) # perform geometric conversions using tigl convert_geometry(filename, cpacs_handle, old_cpacs_file)
# -*- coding: utf-8 -*- """ Please read the function`s docstring :) """ import math import bisect import numpy as np from tixi import tixiwrapper from tigl import tiglwrapper tixi = tixiwrapper.Tixi() tixi.open('./aircraft.xml') tigl = tiglwrapper.Tigl() tigl.open(tixi, 'AircraftModel') def get_airfoil_points(wing_uid, eta, npoints=25, *, method='geometric', joint=True, normalize=False): """ Extracts an airfoil of the wing section defined by a relative coordinate eta. Parameters ---------- wing_uid : string uID of the wing ('wing', 'htp', 'vtp'). eta : float Relative coordinate in spanwise direction, must be in range of [0, 1]. npoints : integer, optional Number of points along upper/lower airfoil curve. (Default: 25) method : string, optional
# SIMPLIFIED MASS ESTIMATION MODEL v1 from tixi import tixiwrapper from tigl import tiglwrapper # ---------------------------------------------------------------------------------------------------------------------- # CPACS INFILE = './ToolInput/toolInput.xml' tixi_h = tixiwrapper.Tixi() tigl = tiglwrapper.Tigl() tixi_h.open(INFILE) tigl.open(tixi_h, '') # ---------------------------------------------------------------------------------------------------------------------- # FIRST PART mEngineDry = tixi_h.getDoubleElement('/cpacs/toolspecific/SimplifiedEngineModel/Outputs/EngineDryMass') mEngine = mEngineDry * 1.24 mEngines = mEngine * 2 if tixi_h.checkElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits') == 0: tixi_h.createElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM', 'mPowerUnits') if tixi_h.checkElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits/mEngines') == 0: tixi_h.createElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits','mEngines') if tixi_h.checkElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits/mEngines/mEngine[1]') == 0: tixi_h.createElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits/mEngines','mEngine') if tixi_h.checkElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits/mEngines/mEngine[1]/massDescription') == 0: tixi_h.createElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits/mEngines/mEngine[1]','massDescription') if tixi_h.checkElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits/mEngines/mEngine[1]/massDescription/mass') == 0: tixi_h.createElement('/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits/mEngines/mEngine[1]/massDescription','mass')