fortran_to_aviary.py

fortran_to_aviary.py#

fortran_to_aviary.py is used to read in Fortran based vehicle decks and convert them to Aviary decks.

FLOPS, GASP, or Aviary names can be used for variables (Ex WG or Mission:Design:GROSS_MASS) When specifying variables from FORTRAN, they should be in the appropriate NAMELIST. Aviary variable names should be specified outside any NAMELISTS. Names are not case-sensitive. Units can be specified using any of the openMDAO valid units. Comments can be added using ! Lists can be entered by separating values with commas. Individual list elements can be specified by adding an index after the variable name. (NOTE: 1 indexing is used inside NAMELISTS, while 0 indexing is used outside NAMELISTS)

Example inputs: aircraft:fuselage:pressure_differential = .5, atm !DELP in GASP, but using atmospheres instead of psi ARNGE(1) = 3600 !target range in nautical miles

aviary.utils.fortran_to_aviary.fortran_to_aviary(fortran_deck: str, legacy_code=None, out_file=None, force=False, verbosity=Verbosity.BRIEF)[source]

Create an Aviary CSV file from a Fortran input deck Required input is the filepath to the input deck and legacy code. Optionally, a deck of default values can be specified, this is useful if an input deck assumes certain values for any unspecified variables If an invalid filepath is given, pre-packaged resources will be checked for input decks with a matching name.

aviary.utils.fortran_to_aviary.generate_aviary_names(legacy_code)[source]

Create a dictionary that maps the specified Fortran code to Aviary variable names. Each Aviary variable will have a list of matching Fortran names

aviary.utils.fortran_to_aviary.parse_input_file(fortran_deck, vehicle_data, alternate_names, default_values, unused_vars, legacy_code, verbosity=Verbosity.BRIEF)[source]

parse_input_file reads the data in fortran_deck and adds it to vehicle_data.

Lines are read one by one, comments are removed, and namelists are tracked. Lines with multiple variable-data pairs are supported, but the last value per variable must be followed by a trailing comma.

aviary.utils.fortran_to_aviary.process_and_store_data(data, var_name, legacy_code, current_namelist, alternate_names, default_values, vehicle_data, unused_vars, comment='', verbosity=Verbosity.BRIEF)[source]

process_and_store_data takes in a string that contains the data, the current variable’s name and namelist, the dictionary of alternate names, and the current vehicle data. It will convert the string of data into a list, get units, check whether the data specified is part of a list or a single element, and update the current name to it’s equivalent Aviary name. The variables are also sorted based on whether they will set an Aviary variable or they are for initial guessing

aviary.utils.fortran_to_aviary.set_value(var_name, var_value, units=None, value_dict: NamedValues = None, var_ind=None)[source]

set_value will update the current value of a variable in a value dictionary that contains a value and it’s associated units. If units are specified for the new value, they will be used, otherwise the current units in the value dictionary or the default units from _MetaData are used. If the new variable is part of a list, the current list will be extended if needed.

aviary.utils.fortran_to_aviary.update_aviary_options(vehicle_data)[source]

Special handling for variables that occurs for either legacy code

aviary.utils.fortran_to_aviary.update_flops_options(vehicle_data)[source]

Handles variables that are affected by the values of others

aviary.utils.fortran_to_aviary.update_flops_scaler_variables(var_name, input_values: NamedValues)[source]

The following parameters are used to modify or override internally computed weights and areas for various components as follows: < 0., negative of starting weight which will be modified as appropriate during optimization or parametric variation, lb or ft**2 = 0., no weight for that component > 0. but < 5., scale factor applied to internally computed weight or area > 5., actual fixed weight for component, lb or ft**2 Same rules also applied to various other FLOPS scaler parameters

aviary.utils.fortran_to_aviary.update_gasp_options(vehicle_data)[source]

Handles variables that are affected by the values of others

aviary.utils.fortran_to_aviary.update_gasp_scaler_variables(var_name, input_values: NamedValues)[source]

The following parameters are used to modify or override internally computed weights and areas for various components as follows: < 0., negative of starting weight which will be modified as appropriate during optimization or parametric variation, lb or ft**2 = 0., no weight/area for that component > 0. but < 10., scale factor applied to internally computed weight > 10., actual fixed weight for component, lb or ft**2 Same rules also applied to various other FLOPS scaler parameters

aviary.utils.fortran_to_aviary.update_name(alternate_names, var_name, verbosity=Verbosity.BRIEF)[source]

update_name will convert a Fortran name to a list of equivalent Aviary names.