dict_indepvarcomp.py

class openconcept.utilities.dict_indepvarcomp.DictIndepVarComp(data_dict, **kwargs)[source]

Bases: openmdao.core.indepvarcomp.IndepVarComp

Create indep variables from an external file with a Python dictionary.

Outputs from this component are read from a Python dictionary and given a name matching their location in the data tree.

For example, let’s assume we have stored some data about a vehicle in a dictionary which can be accessed using the Python expression vehicledata[‘wheels’][‘diameter’]. The structured_name in this case is ‘wheels|diameter’.

The user instantiates a component as DictIndepVarComp(vehicledata) and adds an output as follows: component_instance.add_output_from_dict(‘wheels|diameter’).

Outputs are created after initialization and are user-defined.

_data_dict

dict – A structured dictionary object with input data to read from.

__init__(data_dict, **kwargs)[source]

Initialize the component and store the data dictionary as an attribute.

Parameters:data_dict (dict) – A structured dictionary object with input data to read from
add_output_from_dict(structured_name, separator='|', **kwargs)[source]

Create a new output based on data from the data dictionary

Parameters:
  • structured_name (string) – A string matching the file structure in the dictionary object Pipe symbols indicate treeing down one level Example ‘aero:CLmax_flaps30’ accesses data_dict[‘aero’][‘CLmax_flaps30’]
  • separator (string) – Separator to tree down into the data dict. Default ‘:’ probably shouldn’t be overridden