fastoad.openmdao.problem module

class fastoad.openmdao.problem.FASTOADProblem(*args, **kwargs)[source]

Bases: openmdao.core.problem.Problem

Vanilla OpenMDAO Problem except that it can write its outputs to a file.

It also runs ValidityDomainChecker after each run_model() or run_driver() (but it does nothing if no check has been registered).

Initialize attributes.

input_file_path

File path where read_inputs() will read inputs

output_file_path

File path where write_outputs() will write outputs

additional_variables

Variables that are not part of the problem but that should be written in output file.

run_model(case_prefix=None, reset_iter_counts=True)[source]

Run the model by calling the root system’s solve_nonlinear.

Parameters
  • case_prefix (str or None) – Prefix to prepend to coordinates when recording. None means keep the preexisting prefix.

  • reset_iter_counts (bool) – If True and model has been run previously, reset all iteration counters.

run_driver(case_prefix=None, reset_iter_counts=True)[source]

Run the driver on the model.

Parameters
  • case_prefix (str or None) – Prefix to prepend to coordinates when recording. None means keep the preexisting prefix.

  • reset_iter_counts (bool) – If True and model has been run previously, reset all iteration counters.

Returns

Failure flag; True if failed to converge, False is successful.

Return type

bool

setup(*args, **kwargs)[source]

Set up the problem before run.

write_needed_inputs(source_file_path: Optional[str] = None, source_formatter: Optional[fastoad.io.formatter.IVariableIOFormatter] = None)[source]

Writes the input file of the problem using its unconnected inputs.

Written value of each variable will be taken:

  1. from input_data if it contains the variable

  2. from defined default values in component definitions

Parameters
  • source_file_path – if provided, variable values will be read from it

  • source_formatter – the class that defines format of input file. if not provided, expected format will be the default one.

write_outputs()[source]

Writes all outputs in the configured output file.

read_inputs()[source]

Reads inputs of the problem.

property analysis: fastoad.openmdao.problem.ProblemAnalysis

Information about inner structure of this problem.

The collected data (internally stored) are used in several steps of the computation.

This analysis is performed once. Each subsequent usage reuses the obtained data.

To ensure the analysis is run again, use reset_analysis().

reset_analysis()[source]

Ensure a new problem analysis is done at new usage of analysis.

class fastoad.openmdao.problem.AutoUnitsDefaultGroup(**kwargs)[source]

Bases: openmdao.core.group.Group

OpenMDAO group that automatically use self.set_input_defaults() to resolve declaration conflicts in variable units.

Set the solvers to nonlinear and linear block Gauss–Seidel by default.

configure()[source]

Configure this group to assign children settings.

This method may optionally be overidden by your Group’s method.

You may only use this method to change settings on your children subsystems. This includes setting solvers in cases where you want to override the defaults.

You can assume that the full hierarchy below your level has been instantiated and has already called its own configure methods.

Available attributes:

name pathname comm options system hieararchy with attribute access

class fastoad.openmdao.problem.FASTOADModel(**kwargs)[source]

Bases: fastoad.openmdao.problem.AutoUnitsDefaultGroup

OpenMDAO group that defines active submodels after the initialization of all its subsystems, and inherits from AutoUnitsDefaultGroup for resolving declaration conflicts in variable units.

It allows to have a submodel choice in the initialize() method of a FAST-OAD module, but to possibly override it with the definition of active_submodels (i.e. from the configuration file).

Set the solvers to nonlinear and linear block Gauss–Seidel by default.

active_submodels

Definition of active submodels that will be applied during setup()

setup()[source]

Build this group.

This method should be overidden by your Group’s method. The reason for using this method to add subsystem is to save memory and setup time when using your Group while running under MPI. This avoids the creation of systems that will not be used in the current process.

You may call ‘add_subsystem’ to add systems to this group. You may also issue connections, and set the linear and nonlinear solvers for this group level. You cannot safely change anything on children systems; use the ‘configure’ method instead.

Available attributes:

name pathname comm options

fastoad.openmdao.problem.get_variable_list_from_system(system: openmdao.core.system.System, get_promoted_names: bool = True, promoted_only: bool = True, io_status: str = 'all') fastoad.openmdao.variables.variable_list.VariableList[source]

Creates a VariableList instance containing inputs and outputs of any OpenMDAO System.

Convenience method that creates a FASTOADProblem problem with only provided system and uses from_problem().

class fastoad.openmdao.problem.ProblemAnalysis(problem: openmdao.core.problem.Problem)[source]

Bases: object

Class for retrieving information about the input OpenMDAO problem.

At least one setup operation is done on a copy of the problem. Two setup operations will be done if the problem has unfed dynamically shaped inputs.

problem: openmdao.core.problem.Problem

The analyzed problem

problem_variables: fastoad.openmdao.variables.variable_list.VariableList

All variables of the problem

dynamic_input_vars: fastoad.openmdao.variables.variable_list.VariableList

List variables that are inputs OF THE PROBLEM and dynamically shaped.

subsystem_order: list

Order of subsystems

ivc_var_names: list

Names of variables that are output of an IndepVarComp

analyze()[source]

Gets information about inner structure of the associated problem.

fills_dynamically_shaped_inputs(problem: openmdao.core.problem.Problem)[source]

Adds to the problem an IndepVarComp, that provides dummy variables to fit the dynamically shaped inputs of the analyzed problem.

Adding this IVC to the problem will allow to complete the setup operation.

The input problem should be the analyzed problem or a copy of it.