Пример #1
0
def create_dicts_of_ptdf(md,base_point=BasePointType.FLATSTART):
    branches = dict(md.elements(element_type='branch'))
    buses = dict(md.elements(element_type='bus'))
    branch_attrs = md.attributes(element_type='branch')
    bus_attrs = md.attributes(element_type='bus')

    reference_bus = md.data['system']['reference_bus']
    ptdf = tx_calc.calculate_ptdf(branches,buses,branch_attrs['names'],bus_attrs['names'],reference_bus,base_point)
    phi_from, phi_to = tx_calc.calculate_phi_constant(branches,branch_attrs['names'],bus_attrs['names'],ApproximationType.PTDF)

    _len_branch = len(branch_attrs['names'])
    _mapping_branch = {i: branch_attrs['names'][i] for i in list(range(0,_len_branch))}

    _len_bus = len(bus_attrs['names'])
    _mapping_bus = {i: bus_attrs['names'][i] for i in list(range(0,_len_bus))}

    for idx,branch_name in _mapping_branch.items():
        branch = md.data['elements']['branch'][branch_name]
        _row_ptdf = {bus_attrs['names'][i]: ptdf[idx,i] for i in list(range(0,_len_bus))}
        branch['ptdf'] = _row_ptdf

    for idx, bus_name in _mapping_bus.items():
        bus = md.data['elements']['bus'][bus_name]
        _row_phi_from = {branch_attrs['names'][i]: phi_from[idx, i] for i in list(range(0, _len_branch)) if phi_from[idx, i] != 0.}
        bus['phi_from'] = _row_phi_from

        _row_phi_to = {branch_attrs['names'][i]: phi_to[idx, i] for i in list(range(0, _len_branch)) if phi_to[idx, i] != 0.}
        bus['phi_to'] = _row_phi_to
Пример #2
0
    def _calculate_ptdf(self):
        '''
        do the PTDF calculation
        '''
        ## calculate and store the PTDF matrix
        PTDFM = tx_calc.calculate_ptdf(self._branches, self._buses,
                                       self.branches_keys, self.buses_keys,
                                       self._reference_bus, self._base_point)

        ## protect the array using numpy
        PTDFM.flags.writeable = False

        self.PTDFM = PTDFM
Пример #3
0
    def _calculate_ptdf(self):
        '''
        do the PTDF calculation
        '''
        ## calculate and store the PTDF matrix
        PTDFM = tx_calc.calculate_ptdf(
            self._branches,
            self._buses,
            self.branches_keys,
            self.buses_keys,
            self._reference_bus,
            self._base_point,
            mapping_bus_to_idx=self._busname_to_index_map)

        self.PTDFM = PTDFM

        ## protect the array using numpy
        self.PTDFM.flags.writeable = False