OpenMDAO

raw JSON →
3.43.0 verified Fri May 01 auth: no python

OpenMDAO is an open-source high-performance computing framework for multidisciplinary analysis and optimization. It enables efficient decomposition of coupled systems into components, automatic differentiation, and parallel computing. Current version 3.43.0, requires Python >=3.10. Release cadence is approximately monthly.

pip install openmdao
error ImportError: cannot import name 'IndepVarComp' from 'openmdao.api'
cause openmdao.api is deprecated; import path changed.
fix
Use 'from openmdao.core.indepvarcomp import IndepVarComp' or keep openmdao.api but this will break in future versions.
error NameError: name 'ExecComp' is not defined
cause Forgot to import ExecComp; it's not a built-in.
fix
Add 'from openmdao.components.exec_comp import ExecComp' or use 'om.ExecComp' if using openmdao.api.
error ValueError: The model is already set up. Cannot change configuration after setup.
cause Attempting to modify model after setup() call.
fix
Make all model changes before calling setup(). If needed, create a new Problem instance.
breaking OpenMDAO 3.x removed support for Python 2.7 and 3.6. Upgrade code to Python >=3.10.
fix Ensure Python interpreter is 3.10 or higher; update deprecated API calls.
breaking The 'openmdao.api' module is deprecated as of OpenMDAO 3.31.0. Direct imports from submodules are now preferred.
fix Replace 'from openmdao.api import X' with the explicit import path (e.g., 'from openmdao.core.problem import Problem').
deprecated The 'openmdao.core.component.Component' base class has been renamed to 'ExplicitComponent' and 'ImplicitComponent'. Using the old name issues a deprecation warning and will be removed.
fix Use 'from openmdao.core.explicitcomponent import ExplicitComponent' or 'from openmdao.core.implicitcomponent import ImplicitComponent' instead.
gotcha Do not modify a model's structure (add/remove subsystems) after calling setup() or run_model() unless you call final_setup() again. Doing so can cause crashes or undefined behavior.
fix Either restructure before setup() or use a new Problem instance.
gotcha Solver tolerances and options must be set before calling setup() if you want them to take effect. Setting them after setup may be silently ignored.
fix Set solver options on the system's solver object before prob.setup().
pip install openmdao[all]

Minimal example: create a Problem, add an IndepVarComp and an ExecComp, run the model, and print output.

import openmdao.api as om

prob = om.Problem()
prob.model.add_subsystem('indep', om.IndepVarComp('x', 1.0), promotes=['x'])
prob.model.add_subsystem('comp', om.ExecComp('y=x+1'), promotes=['*'])
prob.setup()
prob.run_model()
print(prob.get_val('y'))