fastoad.openmdao.variables.variable module

Class for managing an OpenMDAO variable.

class fastoad.openmdao.variables.variable.Variable(name, **kwargs)[source]

Bases: Hashable

A class for storing data of OpenMDAO variables.

Instantiation is expected to be done through keyword arguments only.

Beside the mandatory parameter ‘name, kwargs is expected to have keys ‘value’, ‘units’ and ‘desc’, that are accessible respectively through properties name(), value(), units() and description().

Other keys are possible. They match the definition of OpenMDAO’s method Component.add_output() described here.

These keys can be listed with class method get_openmdao_keys(). Any other key in kwargs will be silently ignored.

Special behaviour: description() will return the content of kwargs[‘desc’] unless these 2 conditions are met:

  • kwargs[‘desc’] is None or ‘desc’ key is missing

  • a description exists in FAST-OAD internal data for the variable name

Then, the internal description will be returned by description()

Parameters

kwargs – the attributes of the variable, as keyword arguments

name

Name of the variable

metadata: Dict

Dictionary for metadata of the variable

classmethod read_variable_descriptions(file_parent: str, update_existing: bool = True)[source]

Reads variable descriptions in indicated folder or package, if it contains some.

The file variable_descriptions.txt is looked for. Nothing is done if it is not found (no error raised also).

Each line of the file should be formatted like:

my:variable||The description of my:variable, as long as needed, but on one line.
Parameters
  • file_parent – the folder path or the package name that should contain the file

  • update_existing – if True, previous descriptions will be updated. if False, previous descriptions will be erased.

classmethod update_variable_descriptions(variable_descriptions: Union[Mapping[str, str], Iterable[Tuple[str, str]]])[source]

Updates description of variables.

Parameters

variable_descriptions – dict-like object with variable names as keys and descriptions as values

classmethod get_openmdao_keys()[source]
Returns

the keys that are used in OpenMDAO variables

property value

value of the variable

property val

value of the variable (alias of property “value”)

property units

units associated to value (or None if not found)

property description

description of the variable (or None if not found)

property desc

description of the variable (or None if not found) (alias of property “description”)

property is_input

I/O status of the variable.

  • True if variable is a problem input

  • False if it is an output

  • None if information not found