option_to_var.py

option_to_var.py#

Utilities to create a component that converts an option into an output.

aviary.utils.option_to_var.add_opts2vals(Group: Group, OptionsToValues, aviary_options: AviaryValues)[source]

Add the OptionsToValues component to the specified Group.

Parameters:
  • Group (Group) – The group or model the component should be added to.

  • OptionsToValues (ExplicitComponent) – This is the explicit component that was created by create_opts2vals.

  • aviary_options (AviaryValues) – aviary_options is an AviaryValues object that contains all of the options that need to be converted to outputs.

Returns:

Opts2Vals – A group that wraps the OptionsToValues component in order to rename its variables with a prefix to keep them separate from any similarly named variables in the original group the component is being added to.

Return type:

Group

aviary.utils.option_to_var.create_opts2vals(all_options: list, output_units: dict = {})[source]

create_opts2vals creates a component that converts options to outputs.

Parameters:
  • all_options (list of strings) – Each string is the name of an option in aviary_options.

  • output_units (dict of units, optional) – This optional input allows the user to specify the units that will be used while adding the outputs. Only the outputs that shouldn’t use their default units need to be specified. Each key should match one of the names in all_options, and each value must be a string representing a valid unit in openMDAO.

Returns:

OptionsToValues – An explicit component that takes in an AviaryValues object that contains any options that need to be converted to outputs. There are no inputs to this component, only outputs. If the resulting component is added directly to a Group, the output variables will have the same name as the options they represent. If you need to rename them to prevent conflicting names in the group, running add_opts2vals will add the prefix “option:” to the name.

Return type:

ExplicitComponent