fastoad.openmdao.validity_checker module

For checking validity domain of OpenMDAO variables.

class fastoad.openmdao.validity_checker.CheckRecord(variable_name, status, limit_value, limit_units, value, value_units, source_file, logger_name)

Bases: tuple

A namedtuple that contains result of one variable check

property limit_units

Alias for field number 3

property limit_value

Alias for field number 2

property logger_name

Alias for field number 7

property source_file

Alias for field number 6

property status

Alias for field number 1

property value

Alias for field number 4

property value_units

Alias for field number 5

property variable_name

Alias for field number 0

class fastoad.openmdao.validity_checker.ValidityStatus(value)[source]

Bases: IntEnum

Simple enumeration for validity status.

OK = 0
TOO_LOW = -1
class fastoad.openmdao.validity_checker.ValidityDomainChecker(limits: Optional[Dict[str, tuple]] = None, logger_name: Optional[str] = None)[source]

Bases: object

Decorator class that checks variable values against limit bounds

This class aims at producing a status of out of limits variables at the end of an OpenMDAO computation.

The point is to allow to define limit bounds when defining an OpenMDAO system, but to make the check on the OpenMDAO problem after the run.

When defining an OpenMDAO system, use this class as Python decorator to define validity domains:

class MyComponent(om.explicitComponent):

The above code will check values against lower and upper bounds that have been defined when adding OpenMDAO outputs.

Next code shows how to define lower and upper bounds, for inputs and/or outputs.

        "a:variable:with:two:bounds": (-10.0, 1.0),
        "a:variable:with:lower:bound:only": (0.0, None),
        "a:variable:with:upper:bound:only": (None, 4.2),
class MyComponent(om.explicitComponent):

The defined domain limits supersedes lower and upper bounds from OpenMDAO output definitions, but only in the frame of ValidityDomainChecker. In any case, OpenMDAO process is not affected by usage of ValidityDomainChecker.

Validity status can be obtained through log messages from Python logging module after problem has been run with:


Warnings: - Units of limit values defined in ValidityDomainChecker are assumed to be the

same as in add_input() and add_output() statements of decorated class

  • Validity check currently only applies to scalar values

  • limits – a dictionary where keys are variable names and values are two-values tuples that give lower and upper bound. One bound can be set to None.

  • logger_name – The named of the logger that will be used. If not provided, name of current module (i.e. “__name__””) will be used.

classmethod check_problem_variables(problem: Problem) List[CheckRecord][source]

Checks variable values in provided problem.

Logs warnings for each variable that is out of registered limits.

problem.setup() must have been run.




the list of checks

classmethod check_variables(variables: VariableList) List[CheckRecord][source]

Check values of provided variables against registered limits.




the list of checks

static log_records(records: List[CheckRecord])[source]

Logs warnings through Python logging module for each CheckRecord in provided list if it is not OK.