ExpandObjects

class expand_objects.ExpandObjects(template=None, expansion_structure='/home/docs/checkouts/readthedocs.org/user_builds/epjson-expandobjects/checkouts/latest/src/resources/template_expansion_structures.yaml', logger_level='WARNING', logger_name='console_only_logger')

Bases: epjson_handler.EPJSON

Class to contain general expansion functions as well as methods to connect template outputs.

Attributes:

expansion_structure: file or dictionary of expansion structure details (from YAML)

template: epJSON dictionary containing HVACTemplate to expand

template_type: HVACTemplate object type

template_name: HVACTemplate unique name

epjson: dictionary of epSJON objects to write to file

unique_name: unique string used to modify to epJSON object names within the class

HVACTemplate fields are stored as class attributes

_apply_build_path_action(build_path, action_instructions)

Mutate a build path list based on a set of action instructions

Parameters
  • build_path – Input build path list

  • action_instructions – Formatted instructions to apply an action. Valid actions are ‘Insert’, ‘Remove’, and ‘Replace’ (case insensitive).

Returns

mutated dictionary with action applied.

_apply_transitions(option_tree_leaf: dict) → list

Set object field values in an OptionTree leaf, which consist of a ‘Objects’, ‘Transitions’, and ‘Mappings’ keys using a supplied Transitions dictionary.

Transitions translates template input values to fields in Objects. A more direct method of transitioning template inputs to object values can be done using field name formatting (e.g. field_name: {template_field}) in the yaml file. This method of application is used to override default values if template inputs are provided.

Mappings maps values from templates to objects. This is necessary when the template input is not a direct transition to an object value.

Parameters

option_tree_leaf – YAML loaded option tree end node with three keys: objects, transitions, mappings

Returns

list of dictionary objects with transitions and mappings applied

_connect_and_convert_build_path_to_object_list(build_path=None, loop_type='AirLoop')

Connect nodes in build path and convert to list of epJSON formatted objects

Parameters
  • build_path – build path of EnergyPlus super objects

  • loop_type – fluid flow path (only AirLoop available)

Returns

object list of modified super objects. The build path is also saved as a class attribute for future reference

_create_availability_manager_assignment_list(epjson: Optional[dict] = None) → dict

Create AvailabilityManagerAssignmentList object from epJSON dictionary This list object is separated from the OptionTree build operations because it will vary based on the presence of AvailabilityManager:.* objects in the epJSON dictionary. Therefore, the list objects must be built afterwards in order to retrieve the referenced objects.

Parameters

epjson – system epJSON formatted dictionary

Returns

epJSON formatted AirLoopHVAC:ControllerList objects. These objects are also stored back to the input epJSON object.

_create_objects(epjson=None)

Create a set of EnergyPlus objects for a given template

Parameters

epjson – epJSON object to use for merge and reference.

Returns

epJSON dictionary of newly created objects. The input epJSON dictionary is also modified to include the newly created objects

_flatten_list(nested_list: list, flat_list: list = [], clear: bool = True) → list

Flattens list of lists to one list of items.

Parameters
  • nested_list – list of nested dictionary objects

  • flat_list – list used to store recursive addition of objects

  • clear – Option to empty the recursive list

Returns

flattened list of objects

_get_option_tree(structure_hierarchy: list) → dict

Retrieve structure from YAML loaded object and verify it is correctly formatted for an option tree :param structure_hierarchy: list representing structure hierarchy :return: structured object as dictionary

_get_option_tree_leaf(option_tree: dict, leaf_path: list) → dict

Return leaf from OptionTree with alternative options formatted in dictionary

Parameters
  • option_tree – Yaml object holding HVACTemplate option tree

  • leaf_path – path to leaf node of option tree

Returns

Formatted dictionary with objects and alternative options to be applied.

_get_option_tree_objects(structure_hierarchy: list) → dict

Return objects from option tree leaves.

Parameters

structure_hierarchy – list representing structure hierarchy

Returns

epJSON dictionary with unresolved complex inputs

_parse_build_path(object_list, epjson=None)

Iterate over build path and check if each object is a super object. If not, commit the object to the input epJSON. Return a build path of only super objects.

Parameters
  • object_list – BuildPath list of objects which may contain mixed combination of regular objects and super objects

  • epjson – input epJSON dictionary

Returns

build path of only super objects

_process_build_path(option_tree)

Create a connected group of objects from the BuildPath branch in the OptionTree. A build path is a list of ‘super objects’ which have an extra layer of structure. These keys are ‘Fields’ and ‘Connectors’. The Fields are regular EnergyPlus field name-value pairs. The connectors are structured dictionaries that provide information on how one object should connect the previous/next object in the build path list. A branch of connected objects is also produced.

Parameters

option_tree – OptionTree to use for build instructions

Returns

list of EnergyPlus super objects. Additional EnergyPlus objects (Branch, Branchlist) that require the build path for their creation.

_resolve_complex_input(field_name: str, input_value: Union[str, int, float, dict, list], epjson: Optional[dict] = None, build_path: Optional[list] = None, recursions: int = 0) → Generator[str, Dict[str, str], None]

Resolve a complex input reference into a field value

Parameters
  • field_name – object field name

  • input_value – field value input

  • epjson – epJSON dictionary of objects

  • build_path – BuildPath to reference for lookup

  • recursions – cumulative count of recursive calls so that a cap can be made. This is a backup in case RecursionError misses an infinite loop.

Returns

resolved field value

_resolve_complex_input_from_build_path(build_path: list, lookup_instructions: dict, connector_path: str = 'AirLoop') → str

Resolve a complex input using a build path and location based instructions.

Parameters
  • build_path – list of EnergyPlus super objects forming a build path

  • lookup_instructions – instructions identifying the node location to return

  • connector_path – fluid flow type path (AirLoop only available)

Returns

Resolved field value

build_compact_schedule(structure_hierarchy: list, insert_values: list, name: Optional[str] = None) → dict

Build a Schedule:Compact schedule from inputs. Save epjJSON object to class dictionary and return to calling function.

Parameters
  • structure_hierarchy – list indicating YAML structure hierarchy

  • insert_values – list of values to insert into object

  • name – (optional) name of object.

Returns

epJSON object of compact schedule

expansion_structure

Verify expansion structure file location or object

get_structure(structure_hierarchy: list, structure=None) → dict

Retrieve structure from YAML loaded object. When retrieving TemplateObjects, the last item in the hierarchy will be matched via regex instead of a direct key call for TemplateObjects. This is done to allow for multiple template options in a single mapping.

Parameters
  • structure_hierarchy – list representing structure hierarchy

  • structure – YAML loaded dictionary, default is loaded yaml loaded object

Returns

structured object as dictionary

rename_attribute(old_attribute, new_attribute)

Change attribute name to commonize variables. Do not perform the operation if the target attribute already has a value.

Parameters
  • old_attribute – old attribute name

  • new_attribute – new attribute name

Returns

None. Old attribute is deleted and new attribute created in class

resolve_objects(epjson, reference_epjson=None)

Resolve complex inputs in epJSON formatted dictionary

Parameters
  • epjson – epJSON dictionary with complex inputs

  • reference_epjson – (optional) epJSON dictionary to be used as reference objects for complex lookups. If None, then the input epjson will be used

Returns

epJSON dictionary with values replacing complex inputs

template

Verify if template dictionary is a valid type and structure

yaml_list_to_epjson_dictionaries(yaml_list: list) → dict

Convert list of YAML dictionaries into epJSON formatted dictionaries.

YAML dictionaries can either be regular or ‘super’ objects which contain ‘Fields’ and ‘Connectors’ :param yaml_list: list of yaml objects to be formatted. :return: epJSON formatted dictionary

ExpandThermostat

class expand_objects.ExpandThermostat(template, logger_level='WARNING', logger_name='console_only_logger', epjson=None)

Bases: expand_objects.ExpandObjects

Thermostat expansion operations

_create_and_set_schedules()

Create, or use existing, schedules. Assign schedule names to class variable

Returns

Cooling and/or Heating schedule variables as class attributes

_create_thermostat_setpoints()

Create ThermostatSetpoint objects based on class setpoint_schedule_name attributes :return: Updated class epJSON dictionary with ThermostatSetpoint objects added.

run()

Perform all template expansion operations and return the class to the parent calling function. :return: Class object with epJSON dictionary as class attribute

ExpandZone

class expand_objects.ExpandZone(template, logger_level='WARNING', logger_name='console_only_logger', epjson=None, system_class_objects=None)

Bases: expand_objects.ExpandObjects

Zone expansion operations

Attributes from Descriptors:

system_transitions

zone_hvac_equipmentlist_object_type

design_specification_outdoor_air_object_status

design_specification_zone_air_distribution_object_status

heating_design_air_flow_method

cooling_design_air_flow_method

humidistat_object_type

fan_powered_reheat_type

cooling_design_air_flow_method

Set a class attribute to set cooling_design_air_flow_method for transitions in the YAML lookup. If the supply_air_maximum_flow_rate has been set to a value, then the cooling_design_air_flow_method field in Sizing:Zone should be ‘Flow/Zone’ with this value as the flow rate.

design_specification_outdoor_air_object_status

Set a class attribute to select the appropriate DesignSpecification:OutdoorAir from TemplateObjects in the YAML lookup.

design_specification_zone_air_distribution_object_status

Set a class attribute to select the appropriate DesignSpecification:ZoneAirDistribution from TemplateObjects in the YAML lookup.

fan_powered_reheat_type

Create a new class attribute from reheat_coil_type, for TemplateObjects in the YAML lookup for FanPowered zone objects. If the system flow_type is parallel then reheat_coil_type_parallel is set. For series, reheat_coil_type_series is set.

heating_design_air_flow_method

Set a class attribute to set heating_design_air_flow_method for transitions in the YAML lookup. If the supply_air_maximum_flow_rate has been set to a value, then the heating_design_air_flow_method field in Sizing:Zone should be ‘Flow/Zone’ with this value as the flow rate.

humidistat_object_type

Set a class attribute, humidistat_object_type, for TemplateObjects in the YAML lookup. Also set the dehumidification and humidification values to a default if not provided

run()

Process zone template :return: Class object with epJSON dictionary as class attribute

system_transitions

Set zone attributes based on system attributes

vrf_type

Create a new class attribute, vrf_type, for TemplateObjects in the YAML lookup for FanPowered zone objects.

zone_hvac_equipmentlist_object_type

Set a class attribute to select the appropriate ZoneHVAC:EquipmentList from TemplateObjects in the YAML lookup.

ExpandSystem

class expand_objects.ExpandSystem(template, logger_level='WARNING', logger_name='console_only_logger', epjson=None)

Bases: expand_objects.ExpandObjects

System expansion operations

Attributes from Descriptors:

airloop_hvac_unitary_object_type

airloop_hvac_object_type

airloop_hvac_unitary_fan_type_and_placement

economizer_type_detailed

mixed_air_setpoint_control_type_detailed

cooling_coil_setpoint_control_type_detailed

heating_coil_setpoint_control_type_detailed

setpoint_control_type: concatenated string of cooling_coil_setpoint_control_type and heating_coil_setpoint_control_type

humidistat_type

outside_air_equipment_type

dehumidification_control_type

dehumidification_control_type_detailed

_create_branch_and_branchlist_from_build_path(build_path: Optional[list] = None, loop_type: str = 'AirLoop', epjson: Optional[dict] = None, include_branchlist: bool = True, modify_build_path: bool = True)

Create Branch and BranchList objects from system build path These objects are separated from the OptionTree build operations because they vary based on the final build path. Also, the Branch object must reference an AirLoopHVAC:OutdoorAirSystem object that is also built after the OptionTree build operations.

Parameters
  • build_path – system build path

  • loop_type – string descriptor of the loop type, AirLoop by default

  • epjson – epJSON dictionary

  • include_branchlist – boolean flag to create branchlist or not

  • modify_build_path – boolean flag to modify build path for outdoor air system

Returns

epJSON formatted Branch and BranchList objects. These objects are also stored back to the input epJSON object.

_create_controller_list_from_epjson(epjson: Optional[dict] = None, build_path: Optional[list] = None, controller_list: tuple = ('Controller:WaterCoil', 'Controller:OutdoorAir')) → dict

Create AirLoopHVAC:ControllerList objects from epJSON dictionary These list objects are separated from the OptionTree build operations because they will vary based on the presence of Controller:WaterCoil and Controller:OutdoorAir objects in the epJSON dictionary. Therefore, the list objects must be built afterwards in order to retrieve the referenced Controller:.* objects.

Parameters
  • epjson – system epJSON formatted dictionary

  • build_path – List of epJSON super objects in build path order

  • controller_list – List of controllers to be included in search

Returns

epJSON formatted AirLoopHVAC:ControllerList objects. These objects are also stored back to the input epJSON object.

_create_outdoor_air_equipment_list_from_build_path(build_path: Optional[list] = None, epjson: Optional[dict] = None) → dict

Create AirLoopHVAC:OutdoorAirSystem:EquipmentList objects from system build path This object is separated from the OptionTree build operations because it varies based on the final build path. Therefore, this object must be built afterwards in order to retrieve the referenced outdoor air equipment objects.

Parameters
  • build_path – system build path

  • epjson – epJSON dictionary

Returns

epJSON formatted AirLoopHVAC:OutdoorAirSystem:EquipmentList objects. These objects are also stored back to the input epJSON object.

_create_outdoor_air_system(epjson: Optional[dict] = None) → dict

Create AirLoopHVAC:OutdoorAirSystem object from epJSON dictionary This list object is separated from the OptionTree build operations because it must seek out the correct ControllerList containing the OutdoorAir:Mixer object.

Parameters

epjson – system epJSON formatted dictionary

Returns

epJSON formatted AirLoopHVAC:OutdoorAirSystem objects. These objects are also stored back to the input epJSON object.

_dual_duct_custom_edits()

Perform customized edits to typical ExpandSystem process for HVACTemplate:DualDuct :return: None. class attributes modified

_modify_build_path_for_equipment(loop_type: str = 'AirLoop', build_path: Optional[list] = None) → list

Modify input build path to use special equipment objects in the build path, rather than individual components. This function loads a structured tuple that contains a list of instructions:

0 - HVACTemplate:System for which the instructions are applied 1 - Regular expression match of the super object to be manipulated. This object has a special format to

prevent it from being connected in earlier steps {Fields: …, Connectors: {AirLoop: False}}

2 - Connectors to be applied to the object 3 - Tuple of objects to be removed from build path.

Parameters

build_path – list of EnergyPlus Super objects

Returns

build path

_modify_build_path_for_outside_air_system(loop_type: str = 'AirLoop', epjson: Optional[dict] = None, build_path: Optional[list] = None) → list

Modify input build path to use AirLoopHVAC:OutdoorAirSystem as the first component, rather than individual outside air system components

Parameters

build_path – list of EnergyPlus Super objects

Returns

build path

airloop_hvac_object_type

Set a class attribute to select the appropriate AirLoopHVAC type from TemplateObjects in the YAML lookup.

airloop_hvac_unitary_fan_type_and_placement

Set a class attribute to select the appropriate fan type and placement from TemplateObjects in the YAML lookup.

airloop_hvac_unitary_object_type

Set a class attribute to select the appropriate unitary equipment type from TemplateObjects in the YAML lookup.

cooling_coil_setpoint_control_type_detailed

set cooling_coil_setpoint_control_type_detailed based on other template attributes for YAML TemplateObjects lookup.

dehumidification_control_type

Modify dehumidification_control_type based on other template attributes for YAML TemplateObjects lookup.

dehumidification_control_type_detailed

Create attribute dehumidification_control_type_detailed based on other template attributes for YAML TemplateObjects lookup.

economizer_type_detailed

set economizer_type_detailed based on other template attributes for YAML TemplateObjects lookup.

heating_coil_setpoint_control_type_detailed

create attribute heating_coil_setpoint_control_type_detailed based on other template attributes for YAML TemplateObjects lookup.

humidistat_type

Create class attribute humidistat_type to select Humidistat type based on other template attributes for YAML TemplateObjects lookup.

mixed_air_setpoint_control_type_detailed

set mixed_air_setpoint_control_type_detailed based on other template attributes for YAML TemplateObjects lookup.

outside_air_equipment_type

Create class attribute to select OA objects for YAML BuildPath actions.

run()

Process system template :return: class object with epJSON dictionary as class attribute

ExpandPlantLoop

class expand_objects.ExpandPlantLoop(template, logger_level='WARNING', logger_name='console_only_logger', epjson=None)

Bases: expand_objects.ExpandObjects

Plant loop expansion operations

Attributes from Descriptors:

primary_pump_flow_and_type

secondary_pump_flow_and_type

primary_pump_flow_and_type
Create class attribute, primary_pump_flow_and_type to select the pump flow type, and configuration

type for YAML TemplateObjects lookup.

run()

Process plant loop template :return: class object with epJSON dictionary as class attribute

secondary_pump_flow_and_type
Create class attribute, secondary_pump_flow_and_type to select the pump flow type, and configuration

type for YAML TemplateObjects lookup.

ExpandPlantEquipment

class expand_objects.ExpandPlantEquipment(template, logger_level='WARNING', logger_name='console_only_logger', plant_loop_class_objects=None, epjson=None)

Bases: expand_objects.ExpandObjects

Plant Equipment operations

Attributes from Descriptors:

template_plant_loop_type

pump_configuration_type

chiller_and_condenser_type

primary_pump_type

chiller_and_condenser_type

Set a class attribute to select the appropriate fan type and placement from TemplateObjects in the YAML lookup.

primary_pump_type

Set a class attribute pump_type that reflects the loop attribute primary_pump_type to use in TemplateObjects in the YAML lookup. This descriptor will only either be None, or ‘PumpPerEquipment’, since those are the only configurations needed to inform the equipment

pump_configuration_type

Set a class attribute pump_configuration_type that reflects the loop attribute of the same name to use in TemplateObjects in the YAML lookup.

run()

Process plant loop template :return: class object with epJSON dictionary as class attribute

template_plant_loop_type

Get and set the a priority list of plant loops for the equipment to serve.