fastoad.openmdao.problem module¶
-
class
fastoad.openmdao.problem.
FASTOADProblem
(*args, **kwargs)[source]¶ Bases:
openmdao.core.problem.Problem
Vanilla OpenMDAO Problem except that it can read and write its variables from/to files.
It also runs
ValidityDomainChecker
after eachrun_model()
orrun_driver()
(but it does nothing if no check has been registered)A classical usage of this class would be:
problem = FASTOADProblem() # instantiation [... configuration as for any OpenMDAO problem ...] problem.input_file_path = "inputs.xml" problem.output_file_path = "outputs.xml" problem.write_needed_inputs() # writes the input file (defined above) with # needed variables so user can fill it with proper values # or problem.write_needed_inputs('previous.xml') # writes the input file with needed variables # and values taken from provided file when # available problem.read_inputs() # reads the input file problem.run_driver() # runs the OpenMDAO problem problem.write_outputs() # writes the output file
Initialize attributes.
- Parameters
model (<System> or None) – The top-level <System>. If not specified, an empty <Group> will be created.
driver (<Driver> or None) – The driver for the problem. If not specified, a simple “Run Once” driver will be used.
comm (MPI.Comm or <FakeComm> or None) – The global communicator.
name (str) – Problem name. Can be used to specify a Problem instance when multiple Problems exist.
**options (named args) – All remaining named args are converted to options.
-
run_model
(case_prefix=None, reset_iter_counts=True)[source]¶ Run the model by calling the root system’s solve_nonlinear.
-
write_needed_inputs
(source_file_path: str = None, source_formatter: fastoad.io.formatter.IVariableIOFormatter = None)[source]¶ Writes the input file of the problem with unconnected inputs of the problem.
Warning
setup()
must have been run on this Problem instance.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
WARNING: if inputs have already been read, they won’t be needed any more and won’t be in written file.
- 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.