Package openmdao.lib

This package contains the OpenMDAO Standard Library. It’s intended to contain all of the plugins that are officially supported and released as part of openmdao.

CASEITERATORS

dbcaseiter.py

class openmdao.lib.caseiterators.dbcaseiter.DBCaseIterator(dbfile=':memory:', selectors=None, connection=None)[source]

Bases: object

Pulls Cases from a relational DB (sqlite). It doesn’t support general sql queries, but it does allow for a series of boolean selectors, e.g., ‘x<=y’, that are ANDed together.

dbfile[source]

The name of the database. This can be a filename or :memory: for an in-memory database.

listcaseiter.py

class openmdao.lib.caseiterators.listcaseiter.ListCaseIterator(cases)[source]

Bases: enthought.traits.has_traits.HasTraits

An iterator that returns Case objects from a passed-in iterator of cases. This can be useful for runtime-generated cases from an optimizer, etc.

CASERECORDERS

dbcaserecorder.py

class openmdao.lib.caserecorders.dbcaserecorder.DBCaseRecorder(dbfile=':memory:', model_id='', append=False)[source]

Bases: object

Records Cases to a relational DB (sqlite). Values other than floats or ints are pickled and are opaque to SQL queries.

get_iterator()[source]

Return a DBCaseIterator that points to our current DB.

record(case)[source]

Record the given Case.

dbfile[source]

The name of the database. This can be a filename or :memory: for an in-memory database.

openmdao.lib.caserecorders.dbcaserecorder.case_db_to_dict(dbname, varnames, case_sql='', var_sql='', include_errors=False)[source]

Retrieve the values of specified variables from a sqlite DB containing Case data.

Returns a dict containing a list of values for each entry, keyed on variable name.

Only data from cases containing ALL of the specified variables will be returned so that all data values with the same index will correspond to the same case.

dbname: str
The name of the sqlite DB file.
varnames: list[str]
iterator of names of variables to be retrieved.
case_sql: str, optional
SQL syntax that will be placed in the WHERE clause for Case retrieval.
var_sql: str, optional
SQL syntax that will be placed in the WHERE clause for variable retrieval.
include_errors: bool, optional [False]
if True, include data from cases that reported an error
openmdao.lib.caserecorders.dbcaserecorder.cmdlineXYplot()[source]

Based on command line options, display an XY plot using data from a sqlite Case DB.

openmdao.lib.caserecorders.dbcaserecorder.displayXY(dbname, xnames, ynames, case_sql=None, var_sql=None, title='', grid=False, xlabel='', ylabel='')[source]

Display an XY plot using Case data from a sqlite DB.

dbname: str
Name of the database file.
xnames: list[str]
Names of X variables.
ynames: list[str]
Names of Y variables.
case_sql: str, optional
SQL syntax that will be placed in the WHERE clause for Case retrieval.
var_sql: str, optional
SQL syntax that will be placed in the WHERE clause for variable retrieval.
title: str, optional
Plot title.
grid: bool, optional
If True, a grid is drawn on the plot.
xlabel: str, optional
X axis label.
ylabel: str, optional
Y axis label.
openmdao.lib.caserecorders.dbcaserecorder.list_db_vars(dbname)[source]

Return the set of the names of the variables found in the specified case DB file.

dbname: str
The name of the sqlite DB file.

dumpcaserecorder.py

class openmdao.lib.caserecorders.dumpcaserecorder.DumpCaseRecorder(out=<open file '<stdout>', mode 'w' at 0x019A0070>)[source]

Bases: object

Dumps cases in a “pretty” form to a file-like object called ‘out’ (defaults to sys.stdout). If out is None, cases will be ignored.

record(case)[source]

Dump the given Case in a “pretty” form.

listcaserecorder.py

class openmdao.lib.caserecorders.listcaserecorder.ListCaseRecorder[source]

Bases: object

Stores cases in a list.

record(case)[source]

Store the case in our internal list.

COMPONENTS

external_code.py

Base class for an external application that needs to be executed.

class openmdao.lib.components.external_code.ExternalCode(*args, **kwargs)[source]

Bases: openmdao.main.component.Component

Run an external code as a component.

Str command

The command to be executed.

  • iotype: ‘in’
Dict env_vars

Environment variables required by the command.

  • iotype: ‘in’
Float poll_delay

Delay between polling for command completion. A value of zero will use an internally computed default.

  • iotype: ‘in’
  • units: ‘s’
  • low: 0.0
Dict resources

Resources required to run this component.

  • iotype: ‘in’
Float timeout

Maximum time to wait for command completion. A value of zero implies an infinite wait.

  • iotype: ‘in’
  • units: ‘s’
  • low: 0.0
Int return_code

Return code from the command.

  • iotype: ‘out’
Bool timed_out

True if the command timed-out.

  • iotype: ‘out’
copy_files(directory, patterns)[source]

Copy files from directory that match patterns to the current directory and ensure they are writable.

directory: string
Directory to copy files from.
patterns: list or string
One or more glob patterns to match against.
copy_inputs(inputs_dir, patterns)[source]

Copy inputs from inputs_dir that match patterns.

inputs_dir: string
Directory to copy files from. Relative paths are evaluated from the component’s execution directory.
patterns: list or string
One or more glob patterns to match against.

This can be useful for resetting problem state.

copy_results(results_dir, patterns)[source]

Copy files from results_dir that match patterns.

results_dir: string
Directory to copy files from. Relative paths are evaluated from the component’s execution directory.
patterns: list or string
One or more glob patterns to match against.

This can be useful for workflow debugging when the external code takes a long time to execute.

execute()[source]

Runs the specified command.

First removes existing output (but not in/out) files. Then if resources have been specified, an appropriate server is allocated and the command is run on that server. Otherwise the command is run locally.

stop()[source]

Stop the external code.

metamodel.py

Metamodel provides basic Meta Modeling capability

class openmdao.lib.components.metamodel.MetaModel(*args, **kwargs)[source]

Bases: openmdao.main.component.Component

A component that provides general Meta Modeling capability.

See Appendix B for additional information on the MetaModel component.

Instance (Component) model

Socket for the Component or Assembly being encapsulated.

  • copy: ‘deep’
Instance (ICaseRecorder) recorder

Records training cases

  • copy: ‘deep’
Instance (ISurrogate) surrogate

An ISurrogate instance that is used as a template for each output surrogate.

  • copy: ‘deep’
List excludes

A list of names of variables to be excluded from the public interface.

  • iotype: ‘in’
  • copy: ‘deep’
List includes

A list of names of variables to be included in the public interface.

  • iotype: ‘in’
  • copy: ‘deep’
exec_counts(compnames)[source]
execute()[source]

If the training flag is set, train the metamodel. Otherwise, predict outputs.

invalidate_deps(compname=None, varnames=None, notify_parent=False)[source]
list_inputs_to_model()[source]

Return the list of names of public inputs that correspond to model inputs.

list_outputs_from_model()[source]

Return the list of names of public outputs that correspond to model outputs.

update_inputs(compname, varnames)[source]
update_model(oldmodel, newmodel)[source]

called whenever the model variable is set.

update_model_inputs()[source]

Copy the values of the MetaModel’s inputs into the inputs of the model. Returns the values of the inputs.

update_outputs_from_model()[source]

Copy output values from the model into the MetaModel’s outputs, and if training, save the output associated with surrogate.

mimic.py

class openmdao.lib.components.mimic.Mimic(*args, **kwargs)[source]

Bases: openmdao.main.component.Component

A Component that encapsulates another Component and mimics its input/output interface.

Instance (Component) model

Socket for the Component or Assembly being encapsulated

  • copy: ‘deep’
List excludes

A list of names of variables to be excluded from the public interface.

  • iotype: ‘in’
  • copy: ‘deep’
List includes

A list of names of variables to be included in the public interface.

  • iotype: ‘in’
  • copy: ‘deep’
execute()[source]

Default execution behavior is to set all inputs in the model, execute it, and update all outputs with the model’s outputs. Other classes can override this function to introduce other behaviors.

list_inputs_to_model()[source]

Return the list of names of public inputs that correspond to model inputs.

list_outputs_from_model()[source]

Return the list of names of public outputs that correspond to model outputs.

update_model(oldmodel, newmodel)[source]

called whenever the model variable is set.

update_model_inputs()[source]

Copy the values of the Mimic’s inputs into the inputs of the model.

update_outputs_from_model()[source]

Copy output values from the model into the Mimic’s outputs.

pareto_filter.py

Pareto Filter – finds non-dominated cases

class openmdao.lib.components.pareto_filter.ParetoFilter(doc=None, directory='')[source]

Bases: openmdao.main.component.Component

Takes a set of cases and filters out the subset of cases which are pareto optimal. Assumes that smaller values for model responses are better, so all problems must be posed as minimization problems.

Instance (ICaseIterator) case_set

CaseIterator with the cases to be filtered to Find the pareto optimal subset.

  • iotype: ‘in’
  • copy: ‘deep’
Array criteria

List of outputs from the case to consider for filtering. Note that only case outputs are allowed as criteria.

  • iotype: ‘in’
  • comparison_mode: 1
Instance (ICaseIterator) dominated_set

Resulting collection of dominated cases.

  • iotype: ‘out’
  • copy: ‘deep’
Instance (ICaseIterator) pareto_set

resulting collection of pareto optimal cases

  • iotype: ‘out’
  • copy: ‘deep’
execute()[source]

Finds and removes pareto optimal points in the given case set. Returns a list of pareto optimal points. Smaller is better for all criteria.

DOEGENERATORS

full_factorial.py

DOEgenerator that performs a full-factorial Design of Experiments. Plugs into the DOEgenerator socket on a DOEdriver.

class openmdao.lib.doegenerators.full_factorial.FullFactorial(num_levels=None, num_parameters=None, *args, **kwargs)[source]

Bases: enthought.traits.has_traits.HasTraits

DOEgenerator that performs a full-factorial Design of Experiments. Plugs into the DOEgenerator socket on a DOEdriver.

Int num_levels

number of levels of values for each parameter

  • iotype: ‘in’
Int num_parameters

number of independent parameters in the DOE

  • iotype: ‘in’

optlh.py

class openmdao.lib.doegenerators.optlh.LatinHypercube(doe, q=2, p=1)[source]

Bases: object

mmphi()[source]

Returns the Morris-Mitchell sampling criterion for this latin hypercube.

perturb(mutation_count)[source]

Interchanges pairs of randomly chosen elements within randomly chosen columns of a doe a number of times. The result of this operation will also be a Latin hypercube.

shape[source]

Size of the LatinHypercube doe (rows,cols).

class openmdao.lib.doegenerators.optlh.OptLatinHypercube(num_samples=None, num_parameters=None, population=None, generations=None)[source]

Bases: enthought.traits.has_traits.HasTraits

IDOEgenerator which provides a latin hypercube DOE sample set. The Morris-Mitchell sampling criterion of the DOE is optimzied using an evolutionary algorithm.

Int generations
Number of generations the optimization will evolve over.
Enum norm_method

Vector norm calculation method. ‘1-norm’ is faster, but less accurate

  • values: [‘1-norm’, ‘2-norm’]
Int num_parameters
Number of parameters, or dimensions, for the DOE.
Int num_sample_points
Number of sample points in the DOE sample set.
Int population
Size of the population used in the evolutionary optimization.

DRIVERS

broydensolver.py

solver.py – Solver based on the nonlinear solvers found in Scipy.Optimize.

See Appendix B for additional information on the BroydenSolver.

class openmdao.lib.drivers.broydensolver.BroydenSolver[source]

Bases: openmdao.main.driver.Driver

MIMO Newton-Raphson Solver with Broyden approximation to the Jacobian. Algorithms are based on those found in scipy.optimize.

Nonlinear solvers

These solvers find x for which F(x)=0. Both x and F are multidimensional.

All solvers have the parameter iter (the number of iterations to compute); some of them have other parameters of the solver. See the particular solver for details.

A collection of general-purpose nonlinear multidimensional solvers.

  • broyden2: Broyden’s second method – the same as broyden1 but updates the inverse Jacobian directly
  • broyden3: Broyden’s second method – the same as broyden2 but instead of directly computing the inverse Jacobian, it remembers how to construct it using vectors. When computing inv(J)*F, it uses those vectors to compute this product, thus avoiding the expensive NxN matrix multiplication.
  • excitingmixing: The excitingmixing algorithm. J=-1/alpha

The broyden2 is the best. For large systems, use broyden3; excitingmixing is also very effective. The remaining nonlinear solvers from SciPy are, in their own words, of “mediocre quality,” so they were not implemented.

Enum algorithm

Algorithm to use. Choose from broyden2, broyden3, and excitingmixing.

  • iotype: ‘in’
  • values: [‘broyden2’, ‘broyden3’, ‘excitingmixing’]
Float alpha

Mixing Coefficient.

  • iotype: ‘in’
Float alphamax

Maximum Mixing Coefficient (only used with excitingmixing.)

  • iotype: ‘in’
Int itmax

Maximum number of iterations before termination.

  • iotype: ‘in’
Float tol

Convergence tolerance. If the norm of the independentvector is lower than this, then terminate successfully.

  • iotype: ‘in’
add_constraint(expr_string)

Adds a constraint in the form of a boolean expression string to the driver.

add_eq_constraint(lhs, rhs)

Adds an equality constraint as two strings, a left hand side and a right hand side.

add_parameter(name, low=None, high=None)

Adds a parameter to the driver.

name: string
Name of the variable the driver should vary during execution.
low: float, optional
Minimum allowed value of the parameter.
high: float, optional
Maximum allowed value of the parameter.

If neither “low” nor “high” is specified, the min and max will default to the values in the metadata of the variable being referenced. If they are not specified in the metadata and not provided as arguments, a ValueError is raised.

add_parameters(param_iter)

Takes an iterator of tuples of the form (param_name, low, high) and adds the parameters to the driver.

clear_constraints()

Removes all constraints.

clear_parameters()

Removes all parameters.

eval_eq_constraints()

Returns a list of tuples of the form (lhs, rhs, comparator, is_violated)

execute()[source]

Solver execution.

execute_broyden2()[source]

From SciPy, Broyden’s second method.

Updates inverse Jacobian by an optimal formula. There is NxN matrix multiplication in every iteration.

The best norm(F(x))=0.003 achieved in ~20 iterations.

execute_broyden3()[source]

from scipy, Broyden’s second (sic) method.

Updates inverse Jacobian by an optimal formula. The NxN matrix multiplication is avoided.

The best norm(F(x))=0.003 achieved in ~20 iterations.

execute_excitingmixing()[source]

from scipy, The excitingmixing method.

J=-1/alpha

The best norm(F(x))=0.005 achieved in ~140 iterations.

Note: SciPy uses 0.1 as the default value for alpha for this algorithm. Ours is set at 0.4, which is appropriate for Broyden2 and Broyden3, so adjust it accordingly if there are problems.

get_eq_constraints()

Returns an ordered dict of constraint objects.

get_parameters()

Returns an ordered dict of parameter objects.

list_constraints()

Return a list of strings containing constraint expressions.

list_parameters()

Returns an alphabetized list of parameter names.

remove_constraint(expr_string)

Removes the constraint with the given string.

remove_parameter(name)

Removes the parameter with the given name.

set_parameters(values)

Pushes the values in the iterator ‘values’ into the corresponding variables in the model.

values: iterator
iterator of input values with an order defined to match the order of parameters returned by the list_parameter method. ‘values’ must support the len() function.

caseiterdriver.py

class openmdao.lib.drivers.caseiterdriver.CaseIterDriverBase(*args, **kwargs)[source]

Bases: openmdao.main.driver.Driver

A base class for Drivers that run sets of cases in a manner similar to the ROSE framework. Concurrent evaluation is supported, with the various evaluations executed across servers obtained from the ResourceAllocationManager.

  • The model to be executed is found in the workflow.
  • The recorder socket is used to record results.
  • If sequential is True, then the cases are evaluated sequentially.
  • If reload_model is True, the model is reloaded between executions.
  • max_retries sets the number of times to retry a failed case.
Instance (ICaseRecorder) recorder

Something to save Cases to.

  • copy: ‘deep’
Int max_retries

Maximum number of times to retry a failed case.

  • iotype: ‘in’
  • low: 0
Bool reload_model

If True, reload the model between executions.

  • iotype: ‘in’
Bool sequential

If True, evaluate cases sequentially.

  • iotype: ‘in’
execute()[source]

Runs all cases and records results in recorder.

get_case_iterator()[source]

Returns a new iterator over the Case set.

resume(remove_egg=True)[source]

Resume execution.

remove_egg: bool
If True, then the egg file created for concurrent evaluation is removed at the end of the run.
setup(replicate=True)[source]

Setup to begin new run.

replicate: bool
If True, then replicate the model and save to an egg file first (for concurrent evaluation).
step()[source]

Evaluate the next case.

stop()[source]

Stop evaluating cases.

class openmdao.lib.drivers.caseiterdriver.CaseIteratorDriver(*args, **kwargs)[source]

Bases: openmdao.lib.drivers.caseiterdriver.CaseIterDriverBase

Run a set of cases provided by an ICaseIterator. Concurrent evaluation is supported, with the various evaluations executed across servers obtained from the ResourceAllocationManager.

Instance (ICaseIterator) iterator

Iterator supplying Cases to evaluate.

  • iotype: ‘in’
  • copy: ‘deep’
get_case_iterator()[source]

Returns a new iterator over the Case set.

conmindriver.py

conmindriver.py - Driver for the CONMIN optimizer.

See Appendix B for additional information on the CONMINDriver.

class openmdao.lib.drivers.conmindriver.CONMINdriver(doc=None)[source]

Bases: openmdao.main.driver.Driver

Driver wrapper of Fortran version of CONMIN.

Todo

Make CONMIN’s handling of user calculated gradients accessible through CONMINdriver

Array cons_is_linear

Array designating whether each constraint is linear.

  • iotype: ‘in’
  • comparison_mode: 1
Float ct

Constraint thickness parameter.

  • iotype: ‘in’
Float ctl

Constraint thickness parameter for linear and side constraints.

  • iotype: ‘in’
Float ctlmin

Minimum absoluate value of ctl used in optimization.

  • iotype: ‘in’
Float ctmin

Minimum absoluate value of ct used in optimization.

  • iotype: ‘in’
Float dabfun

Absolute convergence tolerance.

  • iotype: ‘in’
  • low: 1e-10
Float delfun

Relative convergence tolerance.

  • iotype: ‘in’
  • low: 0.0001
Float fdch

Relative change in parameters when calculating finite difference gradients.

  • iotype: ‘in’
Float fdchm

Minimum absolute step in finite difference gradient calculations.

  • iotype: ‘in’
Float icndir

Conjugate gradient restart parameter.

  • iotype: ‘in’
Enum iprint

Print information during CONMIN solution. Higher values are more verbose.

  • iotype: ‘in’
  • values: [0, 1, 2, 3, 4, 5, 101]
Int itmax

Maximum number of iterations before termination.

  • iotype: ‘in’
Int itrm

Number of consecutive iterations to indicate convergence (relative or absolute).

  • iotype: ‘in’
Int linobj

Linear objective function flag.

  • iotype: ‘in’
Float nfdg

User-defined gradient flag (not yet supported).

  • iotype: ‘in’
Float nscal

Scaling control parameter – controls scaling of decision variables.

  • iotype: ‘in’
Float phi

Participation coefficient - penalty parameter that pushes designs towards the feasible region.

  • iotype: ‘in’
ExpressionList printvars

List of extra variables tooutput in the recorder.

  • iotype: ‘in’
  • copy: ‘deep’
Array scal

Array of scaling factors for the parameters.

  • iotype: ‘in’
  • comparison_mode: 1
Float theta

Mean value of the push-off factor in the method of feasible directions.

  • iotype: ‘in’
add_constraint(expr_string)

Adds a constraint to the driver

add_ineq_constraint(lhs, rel, rhs)

Adds an inequality constraint as three strings; a left hand side, a comparator (‘<’,’>’,’<=’, or ‘>=’), and a right hand side.

add_objective(expr)

Sets the objective of this driver to be the specified expression. If there is a preexisting objective in this driver, it is replaced.

expr: string
String containing the objective expression.
add_parameter(name, low=None, high=None)

Adds a parameter to the driver.

name: string
Name of the variable the driver should vary during execution.
low: float, optional
Minimum allowed value of the parameter.
high: float, optional
Maximum allowed value of the parameter.

If neither “low” nor “high” is specified, the min and max will default to the values in the metadata of the variable being referenced. If they are not specified in the metadata and not provided as arguments, a ValueError is raised.

add_parameters(param_iter)

Takes an iterator of tuples of the form (param_name, low, high) and adds the parameters to the driver.

clear_constraints()

Removes all constraints.

clear_parameters()

Removes all parameters.

continue_iteration()[source]

Returns True if iteration should continue.

eval_ineq_constraints()

Returns a list of constraint values

eval_objective()

Returns the value of the evaluated objective.

get_ineq_constraints()

Returns an ordered dict of inequality constraint objects.

get_objective()

Returns the objective object.

get_parameters()

Returns an ordered dict of parameter objects.

list_constraints()

Return a list of strings containing constraint expressions.

list_objective()

Returns the expression string for the objective.

list_parameters()

Returns an alphabetized list of parameter names.

post_iteration()[source]

Checks CONMIN’s return status and writes out cases

pre_iteration()[source]

Checks or RunStopped and evaluates objective

remove_constraint(expr_string)

Removes the constraint with the given string.

remove_parameter(name)

Removes the parameter with the given name.

run_iteration()[source]

The CONMIN driver iteration

set_parameters(values)

Pushes the values in the iterator ‘values’ into the corresponding variables in the model.

values: iterator
iterator of input values with an order defined to match the order of parameters returned by the list_parameter method. ‘values’ must support the len() function.
start_iteration()[source]

Perform initial setup before iteration loop begins.

doedriver.py

doedriver.py – Driver that executes a Design of Experiments.

See Appendix B for additional information on the DOEdriver.

class openmdao.lib.drivers.doedriver.DOEdriver(*args, **kwargs)[source]

Bases: openmdao.lib.drivers.caseiterdriver.CaseIterDriverBase

Driver for Design of Experiments

Instance (IDOEgenerator) DOEgenerator

Iterator supplying normalized DOE values

  • iotype: ‘in’
  • copy: ‘deep’
  • required: True
List case_outputs

A list of outputs to be saved with each case.

  • iotype: ‘in’
  • copy: ‘deep’
add_parameter(name, low=None, high=None)

Adds a parameter to the driver.

name: string
Name of the variable the driver should vary during execution.
low: float, optional
Minimum allowed value of the parameter.
high: float, optional
Maximum allowed value of the parameter.

If neither “low” nor “high” is specified, the min and max will default to the values in the metadata of the variable being referenced. If they are not specified in the metadata and not provided as arguments, a ValueError is raised.

add_parameters(param_iter)

Takes an iterator of tuples of the form (param_name, low, high) and adds the parameters to the driver.

clear_parameters()

Removes all parameters.

get_case_iterator()[source]

Returns a new iterator over the Case set.

get_parameters()

Returns an ordered dict of parameter objects.

list_parameters()

Returns an alphabetized list of parameter names.

remove_parameter(name)

Removes the parameter with the given name.

set_parameters(values)

Pushes the values in the iterator ‘values’ into the corresponding variables in the model.

values: iterator
iterator of input values with an order defined to match the order of parameters returned by the list_parameter method. ‘values’ must support the len() function.

genetic.py

A simple Pyevolve-based driver for OpenMDAO

See Appendix B for additional information on the Genetic driver.

class openmdao.lib.drivers.genetic.Genetic(doc=None)[source]

Bases: openmdao.main.driver.Driver

Genetic algorithm for the OpenMDAO framework, based on the Pyevolve Genetic algorithm module.

Float crossover_rate

The crossover rate used when two parent genomes reproduce to form a child genome.

  • iotype: ‘in’
  • low: 0.0
  • high: 1.0
Bool elitism

Controls the use of elitism in the creation of new generations.

  • iotype: ‘in’
Int generations

The maximum number of generations the algorithm will evolve to before stopping.

  • iotype: ‘in’
Float mutation_rate

The mutation rate applied to population members.

  • iotype: ‘in’
  • low: 0.0
  • high: 1.0
Enum opt_type

Sets the optimization to either minimize or maximize the objective function.

  • iotype: ‘in’
  • values: [‘minimize’, ‘maximize’]
Int population_size

The size of the population in each generation.

  • iotype: ‘in’
Int seed

Random seed for the optimizer. Set to a specific value for repeatable results; otherwise leave as None for truly random seeding.

  • iotype: ‘in’
Enum selection_method

The selection method used to pick population members who will survive for breeding into the next generation.

  • iotype: ‘in’
  • values: (‘roulette_wheel’, ‘tournament’, ‘rank’, ‘uniform’)
Instance (GenomeBase) best_individual

The genome with the best score from the optimization.

  • iotype: ‘out’
  • copy: ‘deep’
add_objective(expr)

Sets the objective of this driver to be the specified expression. If there is a preexisting objective in this driver, it is replaced.

expr: string
String containing the objective expression.
add_parameter(name, low=None, high=None)

Adds a parameter to the driver.

name: string
Name of the variable the driver should vary during execution.
low: float, optional
Minimum allowed value of the parameter.
high: float, optional
Maximum allowed value of the parameter.

If neither “low” nor “high” is specified, the min and max will default to the values in the metadata of the variable being referenced. If they are not specified in the metadata and not provided as arguments, a ValueError is raised.

add_parameters(param_iter)

Takes an iterator of tuples of the form (param_name, low, high) and adds the parameters to the driver.

clear_parameters()

Removes all parameters.

eval_objective()

Returns the value of the evaluated objective.

execute()[source]

Perform the optimization

get_objective()

Returns the objective object.

get_parameters()

Returns an ordered dict of parameter objects.

list_objective()

Returns the expression string for the objective.

list_parameters()

Returns an alphabetized list of parameter names.

remove_parameter(name)

Removes the parameter with the given name.

set_parameters(values)

Pushes the values in the iterator ‘values’ into the corresponding variables in the model.

values: iterator
iterator of input values with an order defined to match the order of parameters returned by the list_parameter method. ‘values’ must support the len() function.

iterate.py

A simple iteration driver. Basically runs a workflow, passing the output to the input for the next iteration. Relative change and number of iterations are used as termination criteria.

class openmdao.lib.drivers.iterate.FixedPointIterator(doc=None)[source]

Bases: openmdao.main.driver.Driver

A simple fixed point iteration driver, which runs a workflow and passes the value from the output to the input for the next iteration. Relative change and number of iterations are used as termination criterea.

Int max_iteration

Maximum number of iterations before termination.

  • iotype: ‘in’
Float tolerance

Absolute convergence tolerance between iterations.

  • iotype: ‘in’
Expression x_out

loop output to pass to input.

  • iotype: ‘in’
Expression x_in

loop input, taken from the input.

  • iotype: ‘out’
execute()[source]

Perform the iteration.

multi_crit_ei.py

Multi Crit EI

class openmdao.lib.drivers.multi_crit_ei.MuliCritEI(*args, **kwargs)[source]

Bases: openmdao.main.driver.Driver

The Multi Crit Expected Improvement method

Instance (ICaseIterator) best_cases

CaseIterator which Contains pareto optimal cases, representing the target objective values.

  • iotype: ‘in’
  • copy: ‘deep’
Str infill

Infill criterion about which to maximize.

  • iotype: ‘in’
Expression objective

String representing the objectives about which the infill criterion is maximized. Must be a NormalDistrubtion type.

  • iotype: ‘in’
Str objectives

Names of the output from cases to be used as the objectives.

  • iotype: ‘in’
Instance (ICaseIterator) next_case

CaseIterator which contains the case that maximizes specified infill criterion.

  • iotype: ‘out’
  • copy: ‘deep’
add_parameter(param_name, low, high)[source]
clear_parameters()[source]
execute()[source]

Optimize the infill criterion and return the next point to run.

list_parameters()[source]
remove_parameter(param_name)[source]

simplecid.py

A simple driver that runs cases from a CaseIterator and records them with a CaseRecorder

class openmdao.lib.drivers.simplecid.SimpleCaseIterDriver(*args, **kwargs)[source]

Bases: openmdao.main.driver.Driver

A Driver that sequentially runs a set of cases provided by an ICaseIterator and records the results in a CaseRecorder. This is intended for test cases or very simple models only. For a more full- featured Driver with similar functionality, see CaseIteratorDriver.

  • The iterator socket provides the cases to be evaluated.
  • The recorder socket is used to record results.

For each case coming from the iterator, the workflow will be executed once.

Instance (ICaseIterator) iterator

Source of Cases.

  • required: True
  • copy: ‘deep’
Instance (ICaseRecorder) recorder

Where Case results are recorded.

  • required: True
  • copy: ‘deep’
execute()[source]

Run each case in iterator and record results in recorder.

single_crit_ei.py

Driver that implements the Expected Improvement process for single criteria problems

class openmdao.lib.drivers.single_crit_ei.SingleCritEI(*args, **kwargs)[source]

Bases: openmdao.main.driver.Driver

Driver which implements the Expected Improvement(EI) process for single criteria problems. It uses components whose outputs are instances of NormalDistribution, combined with a provided optimal case, to find the point in the design space with the best Expected Improvement.

Instance (ICaseIterator) best_case

CaseIterator which contains a single case, representing the criteria value.

  • iotype: ‘in’
  • copy: ‘deep’
Expression criteria

Name of the variable to maximize the expected improvement around. Must be a NormalDistrubtion type.

  • iotype: ‘in’
Float EI

The expected improvement of the next_case

  • iotype: ‘out’
Instance (ICaseIterator) next_case

CaseIterator that contains the case which maximizes expected improvement.

  • iotype: ‘out’
  • copy: None
add_parameter(param_name, low=None, high=None)[source]

Adds a parameter to the list of parameters.

add_parameters(param_iter)

Takes an iterator of tuples of the form (param_name, low, high) and adds the parameters to the driver.

clear_parameters()

Removes all parameters.

execute()[source]

Optimize the Expected Improvement and calculate the next training point to run.

get_parameters()

Returns an ordered dict of parameter objects.

list_parameters()

Returns an alphabetized list of parameter names.

remove_parameter(param_name)[source]

Removes a parameter from the list of parameters.

set_parameters(values)

Pushes the values in the iterator ‘values’ into the corresponding variables in the model.

values: iterator
iterator of input values with an order defined to match the order of parameters returned by the list_parameter method. ‘values’ must support the len() function.

SURROGATEMODELS

kriging_surrogate.py

Surrogate model based on Kriging

class openmdao.lib.surrogatemodels.kriging_surrogate.KrigingSurrogate(X=None, Y=None)[source]

Bases: enthought.traits.has_traits.HasTraits

get_uncertain_value(value)[source]

Returns a NormalDistribution centered around the value, with a standard deviation of 0.

predict(new_x)[source]

Calculates a predicted value of the response based on the current trained model for the supplied list of inputs.

train(X, Y)[source]

Train the surrogate model with the given set of inputs and outputs.

DATATYPES

array.py

Trait for numpy array variables, with optional units.

class openmdao.lib.datatypes.array.Array(default_value=None, dtype=None, shape=None, iotype=None, desc=None, units=None, **metadata)[source]

Bases: enthought.traits.trait_numeric.Array

A variable wrapper for a numpy array with optional units. The unit applies to the entire array.

error(obj, name, value)[source]

Returns a string describing the type handled by Array.

get_val_meta_wrapper()[source]

Return a TraitValMetaWrapper object. Its value attribute will be filled in by the caller.

validate(obj, name, value)[source]

Validates that a specified value is valid for this trait. Units are converted as needed.

domain.py

class openmdao.lib.datatypes.domain.domain.DomainObj[source]

Bases: object

A DomainObj represents a (possibly multi-zoned) mesh and data related to that mesh.

add_domain(other, prefix='', make_copy=False)[source]

Add zones from other to self, retaining names where possible.

other: DomainObj
Source for new zone data.
prefix: string
String prepended to zone names.
make_copy: bool
If True, then a deep copy of each zone is made rather than just referring to a shared instance.
add_zone(name, zone, prefix='', make_copy=False)[source]

Add a Zone. Returns the added zone.

name: string
Name for the zone. If None or blank, then a default of the form zone_N is used.
prefix: string
String prepended to the zone name.
make_copy: bool
If True, then a deep copy of each zone is made rather than just referring to a shared instance.
copy()[source]

Returns a deep copy of self.

deallocate()[source]

Deallocate resources.

is_equivalent(other, logger=None, tolerance=0.0)[source]

Test if self and other are equivalent.

other: DomainObj
The domain to check against.
logger: Logger or None
Used to log debug messages that will indicate what if anything is not equivalent
tolerance: float
The maximum relative difference in array values to be considered equivalent.
make_cartesian(axis='z')[source]

Convert to cartesian coordinate system.

axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
make_cylindrical(axis='z')[source]

Convert to cylindrical coordinate system.

axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
make_left_handed()[source]

Convert to left-handed coordinate system.

make_right_handed()[source]

Convert to right-handed coordinate system.

remove_zone(zone)[source]

Remove a zone. Returns the removed zone.

zone: string or DomainObj
Zone to be removed.
rename_zone(name, zone)[source]

Rename a zone.

name: string
New name for the zone.
zone: DomainObj
Zone to be renamed.
rotate_about_x(deg)[source]

Rotate about the X axis.

deg: float (degrees)
Amount of rotation.
rotate_about_y(deg)[source]

Rotate about the Y axis.

deg: float (degrees)
Amount of rotation.
rotate_about_z(deg)[source]

Rotate about the Z axis.

deg: float (degrees)
Amount of rotation.
translate(delta_x, delta_y, delta_z)[source]

Translate coordinates.

delta_x, delta_y, delta_z: float
Amount of translation along the corresponding axis.
zone_name(zone)[source]

Return name that a zone is bound to.

zone: DomainObj
Zone whose name is to be returned.
extent[source]

List of coordinate ranges for each zone.

shape[source]

List of coordinate index limits for each zone.

enum.py

Trait for enumerations, with optional alias list

class openmdao.lib.datatypes.enum.Enum(default_value=None, values=(), iotype=None, aliases=(), desc=None, **metadata)[source]

Bases: enthought.traits.trait_handlers.TraitType

A variable wrapper for an enumeration, which is a variable that can assume one value from a set of specified values.

error(obj, name, value)[source]

Returns a general error string for Enum.

validate(obj, name, value)[source]

Validates that a specified value is valid for this trait.

file.py

Support for files, either as File or external files.

class openmdao.lib.datatypes.file.File(default_value=None, iotype=None, desc=None, **metadata)[source]

Bases: enthought.traits.trait_handlers.TraitType

A trait wrapper for a FileRef object. For input files legal_types may be set to a list of expected ‘content_type’ strings. Then upon assignment the actual ‘content_type’ must match one of the legal_types strings. Also for input files, if local_path is set, then upon assignent the associated file will be copied to that path.

post_setattr(obj, name, value)[source]

If ‘local_path’ is set on an input, then copy the source FileRef’s file to that path.

validate(obj, name, value)[source]

Verify that value is a FileRef of a legal type.

float.py

Trait for floating point variables, with optional min, max, and units

class openmdao.lib.datatypes.float.Float(default_value=None, iotype=None, desc=None, low=None, high=None, exclude_low=False, exclude_high=False, units=None, **metadata)[source]

Bases: enthought.traits.trait_handlers.TraitType

A Variable wrapper for floating point number valid within a specified range of values.

error(obj, name, value)[source]

Returns a string describing the type handled by Float.

get_val_meta_wrapper()[source]

Return a TraitValMetaWrapper object. Its value attribute will be filled in by the caller.

validate(obj, name, value)[source]

Validates that a specified value is valid for this trait. Units are converted as needed.

flow.py

class openmdao.lib.datatypes.domain.flow.FlowSolution[source]

Bases: object

Contains solution variables for a Zone. All variables have the same shape and grid location.

add_array(name, array)[source]

Add a numpy.ndarray of scalar data and bind to name. Returns the added array.

name: string
Name for the added array.
array: ndarray
Scalar data.
add_vector(name, vector)[source]

Add a Vector and bind to name. Returns the added vector.

name: string
Name for the added array.
vector: Vector
Vector data.
flip_z()[source]

Convert to other-handed coordinate system.

is_equivalent(other, logger, tolerance=0.0)[source]

Test if self and other are equivalent.

other: FlowSolution
The flowfield to check against.
logger: Logger or None
Used to log debug messages that will indicate what if anything is not equivalent.
tolerance: float
The maximum relative difference in array values to be considered equivalent.
make_cartesian(grid, axis='z')[source]

Convert to cartesian coordinate system.

grid: GridCoordinates
Must be in cylindrical form.
axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
make_cylindrical(grid, axis='z')[source]

Convert to cylindrical coordinate system.

grid: GridCoordinates
Must be in cylindrical form.
axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
name_of_obj(obj)[source]

Return name of object or None if not found.

rotate_about_x(deg)[source]

Rotate about the X axis.

deg: float (degrees)
Amount of rotation.
rotate_about_y(deg)[source]

Rotate about the Y axis.

deg: float (degrees)
Amount of rotation.
rotate_about_z(deg)[source]

Rotate about the Z.

deg: float (degrees)
Amount of rotation.
arrays[source]

List of scalar data arrays.

ghosts

Number of ghost cells for each index direction.

grid_location

Position at which data is located.

vectors[source]

List of vector data.

grid.py

class openmdao.lib.datatypes.domain.grid.GridCoordinates[source]

Bases: openmdao.lib.datatypes.domain.vector.Vector

Coordinate data for a Zone.

is_equivalent(other, logger, tolerance=0.0)[source]

Test if self and other are equivalent.

other: GridCoordinates
The grid to check against.
logger: Logger or None
Used to log debug messages that will indicate what if anything is not equivalent.
tolerance: float
The maximum relative difference in array values to be considered equivalent.
make_cartesian(axis='z')[source]

Convert to cartesian coordinate system.

axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
make_cylindrical(axis='z')[source]

Convert to cylindrical coordinate system.

axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
translate(delta_x, delta_y, delta_z)[source]

Translate coordinates.

delta_x, delta_y, delta_z: float
Amount of translation along the corresponding axis.
ghosts

Number of ghost cells for each index direction.

int.py

Trait for floating point variables, with optional min and max

class openmdao.lib.datatypes.int.Int(default_value=None, iotype=None, desc=None, low=None, high=None, exclude_low=False, exclude_high=False, **metadata)[source]

Bases: enthought.traits.trait_handlers.TraitType

A variable wrapper for an integer valid within a specified range of values.

error(obj, name, value)[source]

Returns a string describing the type handled by Int.

validate(obj, name, value)[source]

Validates that a specified value is valid for this trait.

plot3d.py

Functions to read and write a DomainObj in Plot3D format. Many function arguments are common:

multiblock: bool
If True, then the file is assumed to have a multiblock header.
dim: int
Specifies the expected dimensionality of the blocks.
blanking: bool
If True, then blanking data is expected.
planes: bool
If True, then the data is expected in planar, not whole, format.
binary: bool
If True, the data is in binary, not text, form.
big_endian: bool
If True, the data bytes are in ‘big-endian’ order. Only meaningful if binary.
single_precision: bool
If True, floating-point data is 32 bits, not 64. Only meaningful if binary.
unformatted: bool
If True, the data is surrounded by Fortran record length markers. Only meaningful if binary.
logger: Logger or None
Used to record progress.

Default argument values are set for a typical 3D multiblock single-precision Fortran unformatted file. When writing, zones are assumed in Cartesian coordinates with data located at the vertices.

openmdao.lib.datatypes.domain.plot3d.read_plot3d_f(grid_file, f_file, varnames=None, multiblock=True, dim=3, blanking=False, planes=False, binary=True, big_endian=False, single_precision=True, unformatted=True, logger=None)[source]

Returns a DomainObj initialized from Plot3D grid_file and f_file. Variables are assigned to names of the form f_N.

grid_file: string
Grid filename.
f_file: string
Function data filename.
openmdao.lib.datatypes.domain.plot3d.read_plot3d_grid(grid_file, multiblock=True, dim=3, blanking=False, planes=False, binary=True, big_endian=False, single_precision=True, unformatted=True, logger=None)[source]

Returns a DomainObj initialized from Plot3D grid_file.

grid_file: string
Grid filename.
openmdao.lib.datatypes.domain.plot3d.read_plot3d_q(grid_file, q_file, multiblock=True, dim=3, blanking=False, planes=False, binary=True, big_endian=False, single_precision=True, unformatted=True, logger=None)[source]

Returns a DomainObj initialized from Plot3D grid_file and q_file. Q variables are assigned to ‘density’, ‘momentum’, and ‘energy_stagnation_density’. Scalars are assigned to ‘mach’, ‘alpha’, ‘reynolds’, and ‘time’.

grid_file: string
Grid filename.
q_file: string
Q data filename.
openmdao.lib.datatypes.domain.plot3d.read_plot3d_shape(grid_file, multiblock=True, dim=3, binary=True, big_endian=False, unformatted=True, logger=None)[source]

Returns a list of zone dimensions from Plot3D grid_file.

grid_file: string
Grid filename.
openmdao.lib.datatypes.domain.plot3d.write_plot3d_f(domain, grid_file, f_file, varnames=None, planes=False, binary=True, big_endian=False, single_precision=True, unformatted=True, logger=None)[source]

Writes domain to grid_file and f_file in Plot3D format. If varnames is None, then all arrays and then all vectors are written.

domain: DomainObj
The domain to be written.
grid_file: string
Grid filename.
f_file: string
Function data filename.
openmdao.lib.datatypes.domain.plot3d.write_plot3d_grid(domain, grid_file, planes=False, binary=True, big_endian=False, single_precision=True, unformatted=True, logger=None)[source]

Writes domain to grid_file in Plot3D format.

domain: DomainObj
The domain to be written.
grid_file: string
Grid filename.
openmdao.lib.datatypes.domain.plot3d.write_plot3d_q(domain, grid_file, q_file, planes=False, binary=True, big_endian=False, single_precision=True, unformatted=True, logger=None)[source]

Writes domain to grid_file and q_file in Plot3D format. Requires ‘density’, ‘momentum’, and ‘energy_stagnation_density’ variables as well as ‘mach’, ‘alpha’, ‘reynolds’, and ‘time’ scalars.

domain: DomainObj
The domain to be written.
grid_file: string
Grid filename.
q_file: string
Q data filename.

probe.py

openmdao.lib.datatypes.domain.probe.register_surface_probe(name, function, integrate)[source]

Register a surface probe function.

name: string
The name of the metric calculated.
function: callable
The function to call. The passed arguments are (domain, surface, weights, reference_state).
integrate: bool
If True, then function values are integrated, not averaged.
openmdao.lib.datatypes.domain.probe.surface_probe(domain, surfaces, variables, weighting_scheme='area')[source]

Calculate metrics on mesh surfaces. Currently only supports 3D structured grids with cell-centered data.

domain: DomainObj
The domain to be processed.
surfaces: list
List of (zone_name,imin,imax,jmin,jmax,kmin,kmax) mesh surface specifications to be used for the calculation. Indices start at 0. Negative indices are relative to the end of the array.
variables: list
List of (metric_name, units) tuples. Legal metric names are ‘area’, ‘mass_flow’, ‘corrected_mass_flow’, ‘pressure’, ‘pressure_stagnation’, ‘temperature’, and ‘temperature_stagnation’.
weighting_scheme: string
Specifies how individual values are weighted. Legal values are ‘area’ for area averaging and ‘mass’ for mass averaging.

Returns a list of metric values in the order of the variables list.

vector.py

class openmdao.lib.datatypes.domain.vector.Vector[source]

Bases: object

Vector data for a FlowSolution. In cartesian coordinates, array indexing order is x,y,z; so an ‘i-face’ is a y,z surface. In cylindrical coordinates, array indexing order is z,r,t; so an ‘i-face’ is a r,t surface.

flip_z()[source]

Convert to other-handed coordinate system.

is_equivalent(other, name, logger, tolerance=0.0)[source]

Test if self and other are equivalent.

other: Vector
The vector to check against.
name: string
Name of this vector, used for reporting differences.
logger: Logger or None
Used to log debug messages that will indicate what if anything is not equivalent.
tolerance: float
The maximum relative difference in array values to be considered equivalent.
make_cartesian(grid, axis='z')[source]

Convert to cartesian coordinate system.

grid: GridCoordinates
Must be in cylindrical form.
axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
make_cylindrical(grid, axis='z')[source]

Convert to cylindrical coordinate system.

grid: GridCoordinates
Must be in cylindrical form.
axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
rotate_about_x(deg)[source]

Rotate about the X axis.

deg: float (degrees)
Amount of rotation.
rotate_about_y(deg)[source]

Rotate about the Y axis.

deg: float (degrees)
Amount of rotation.
rotate_about_z(deg)[source]

Rotate about the Z axis.

deg: float (degrees)
Amount of rotation.
extent[source]

Tuple of component ranges.

shape[source]

Tuple of index limits.

zone.py

class openmdao.lib.datatypes.domain.zone.Zone[source]

Bases: object

One zone in a possibly multi-zone DomainObj.

is_equivalent(other, logger, tolerance=0.0)[source]

Test if self and other are equivalent.

other: Zone
Zone to check against.
logger: Logger or None
Used to log debug messages that will indicate what if anything is not equivalent.
tolerance: float
The maximum relative difference in array values to be considered equivalent.
make_cartesian(axis='z')[source]

Convert to cartesian coordinate system.

axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
make_cylindrical(axis='z')[source]

Convert to cylindrical coordinate system.

axis: string
Specifies which is the cylinder axis (‘z’ or ‘x’).
make_left_handed()[source]

Convert to left-handed coordinate system.

make_right_handed()[source]

Convert to right-handed coordinate system.

rotate_about_x(deg)[source]

Rotate about the X axis.

deg: float (degrees)
Amount of rotation.
rotate_about_y(deg)[source]

Rotate about the Y axis.

deg: float (degrees)
Amount of rotation.
rotate_about_z(deg)[source]

Rotate about the Z axis.

deg: float (degrees)
Amount of rotation.
translate(delta_x, delta_y, delta_z)[source]

Translate coordinates.

delta_x, delta_y, delta_z: float
Amount of translation along the corresponding axis.
coordinate_system

Coordinate system in use.

extent[source]

Tuple of coordinate ranges.

shape[source]

Tuple of coordinate index limits.