dict_indepvarcomp.py

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

Bases: 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

A structured dictionary object with input data to read from.

Type:

dict

__init__(data_dict, **kwargs)

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)

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

class openconcept.utilities.dict_indepvarcomp.DymosDesignParamsFromDict(data_dict, dymos_traj)

Bases: object

Create Dymos parameters from an external file with a Python dictionary.

_data_dict

A structured dictionary object with input data to read from.

Type:

dict

__init__(data_dict, dymos_traj)

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

  • dymos_traj (Dymos trajectory) – A Dymos trajectory object with phases already added

add_output_from_dict(structured_name, separator='|', opt=False, dynamic=False, **kwargs)

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