Пример #1
0
def get_aero_param(tixi):
    """Add the aeromap variables to the optimisation dictionnary.

    Takes the variables of the aeromap that is used.
    It is checked if the variable has a user-specified initial value, else it
    will assign a default value or the variable will be excluded from the
    problem.

    Args:
        tixi (Tixi3 handle): Handle of the current CPACS file.

    """

    # TODO: This function could probalbly be (partrly) replace by cpacspy

    log.info("Default aeromap parameters will be set")

    aeromap_uid = tixi.getTextElement(OPTIM_XPATH + "/aeroMapUID")
    xpath = tixi.uIDGetXPath(aeromap_uid) + "/aeroPerformanceMap/"

    for name in PARAMS_COEFS:
        xpath_param = xpath + name

        value = str(tixi.getDoubleElement(xpath_param))

        var["Name"].append(name)
        var["init"].append(value)
        var["xpath"].append(xpath_param)

        add_type(name, COEFS, objective, var)
        add_bounds(value, var)
Пример #2
0
def get_aero_param(tixi):
    """Add the aeromap variables to the optimisation dictionnary.

    Takes the variables of the aeromap that is used.
    It is checked if the variable has a user-specified initial value, else it
    will assign a default value or the variable will be excluded from the
    problem.

    Args:
        tixi (Tixi3 handle): Handle of the current CPACS file.

    """

    log.info('Default aeromap parameters will be set')

    am_uid = cpsf.get_value(tixi, OPTIM_XPATH+'aeroMapUID')
    am_index = apmf.get_aeromap_index(tixi, am_uid)

    log.info('Aeromap \"{}\" will be used for the variables.'.format(am_uid))

    xpath = apmf.AEROPERFORMANCE_XPATH + '/aeroMap'\
            + am_index + '/aeroPerformanceMap/'

    for name in apmf.COEF_LIST+apmf.XSTATES:
        xpath_param = xpath+name
        value = str(tixi.getDoubleElement(xpath_param))

        var['Name'].append(name)
        var['init'].append(value)
        var['xpath'].append(xpath_param)

        tls.add_type(name, apmf.COEF_LIST, objective, var)
        tls.add_bounds(value, var)
Пример #3
0
def get_normal_param(tixi, entry, outputs):
    """Add a variable to the optimisation dictionnary.

    It is checked if the variable has a user-specified initial value, else it
    will assign a default value or the variable will be excluded from the
    problem.

    Args:
        tixi (Tixi3 handle): Handle of the current CPACS file.
        entry (object): Current parameter object.

    Returns:
        None.

    """

    value = '-'
    xpath = entry.xpath
    def_val = entry.default_value

    if not def_val:
        if entry.var_type in [float, int]:
            def_val = 0.0
        else:
            def_val = '-'

    if entry.var_name not in banned_entries:
        value = cpsf.get_value_or_default(tixi, xpath, def_val)
        if entry.var_type == int:
            value = int(value)

    if not tls.is_digit(value):
        log.info('Not a digital value')
        value = '-'
    elif entry.var_type == bool:
        log.info('Boolean, not implemented yet')
        value = '-'

    # Ignores values that are not int or float
    if value != '-':
        value = str(value)
        tixi.updateTextElement(xpath, value)

        var['init'].append(value)
        var['xpath'].append(xpath)
        var['Name'].append(entry.var_name)

        tls.add_type(entry, outputs, objective, var)
        tls.add_bounds(value, var)
        log.info('Value : {}'.format(value))
        log.info('Added to variable file')
Пример #4
0
def get_normal_param(tixi, entry, outputs):
    """Add a variable to the optimisation dictionnary.

    It is checked if the variable has a user-specified initial value, else it
    will assign a default value or the variable will be excluded from the
    problem.

    Args:
        tixi (Tixi3 handle): Handle of the current CPACS file.
        entry (object): Current parameter object.

    """

    value = "-"
    xpath = entry.xpath
    def_val = entry.default_value

    if not def_val:
        if entry.var_type in [float, int]:
            def_val = 0.0
        else:
            def_val = "-"

    if entry.var_name not in BANNED_ENTRIES:
        value = get_value_or_default(tixi, xpath, def_val)
        if entry.var_type == int:
            value = int(value)

    if not is_digit(value):
        log.info("Not a digital value")
        value = "-"
    elif entry.var_type == bool:
        log.info("Boolean, not implemented yet")
        value = "-"

    # Ignores values that are not int or float
    if value != "-":
        value = str(value)
        tixi.updateTextElement(xpath, value)

        var["init"].append(value)
        var["xpath"].append(xpath)
        var["Name"].append(entry.var_name)

        add_type(entry, outputs, objective, var)
        add_bounds(value, var)
        log.info("Value : {}".format(value))
        log.info("Added to variable file")
Пример #5
0
def get_aero_param(tixi, xpath, module_name):
    """Add the aeromap variables to the optimisation dictionnary.

    Takes the variables of the aeromap that is used.
    It is checked if the variable has a user-specified initial value, else it
    will assign a default value or the variable will be excluded from the
    problem.

    Args:
        tixi (Tixi3 handle): Handle of the current CPACS file.
        value_name (str): Name of the parameter.
        entry (object): Current parameter object.

    Returns:
        None.

    """
    log.info('Default aeromap parameters will be set')

    # Get name of aeromap that is used
    am_nb = tixi.getNumberOfChilds(AEROMAP_XPATH)
    am_uid = tixi.getTextElement(
        tls.get_aeromap_path([module_name]) + '/aeroMapUID')
    log.info('Aeromap \"{}\" will be used for the variables.'.format(am_uid))

    # Search the aeromap index in the CPACS file if there are more
    if am_nb > 1:
        for i in range(1, am_nb + 1):
            am_xpath = AEROMAP_XPATH + '/aeromap[{}]'.format(i)
            uid = tixi.getTextAttribute(am_xpath, 'uID')
            if uid == am_uid:
                am_index = '[{}]'.format(i)
    else:
        am_index = '[1]'

    outputs = ['cl', 'cd', 'cs', 'cml', 'cmd', 'cms']
    inputs = ['altitude', 'machNumber', 'angleOfAttack', 'angleOfSideslip']
    inputs.extend(outputs)
    for name in inputs:
        xpath_param = xpath.replace('[i]', am_index) + '/' + name
        value = str(tixi.getDoubleElement(xpath_param))

        var['Name'].append(name)
        var['init'].append(value)
        var['xpath'].append(xpath_param)

        tls.add_type(name, outputs, objective, var)
        tls.add_bounds(name, value, var)