コード例 #1
0
    def _calculate_ptdf(self):
        ptdf_r, ldf, ldf_c = tx_calc.calculate_ptdf_ldf(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 = ptdf_r
        self.LDF = ldf
        self.LDF_C = ldf_c

        ## protect the arrays using numpy
        self.PTDFM.flags.writeable = False
        self.LDF.flags.writeable = False
        self.LDF_C.flags.writeable = False
コード例 #2
0
ファイル: data_utils.py プロジェクト: emma58/Egret
    def _calculate_ptdf(self):
        ptdf_r, ldf, ldf_c = tx_calc.calculate_ptdf_ldf(
            self._branches, self._buses, self.branches_keys, self.buses_keys,
            self._reference_bus, self._base_point)

        ## protect the arrays using numpy
        ptdf_r.flags.writeable = False
        ldf.flags.writeable = False
        ldf_c.flags.writeable = False

        self.PTDFM = ptdf_r
        self.LDF = ldf
        self.LDF_C = ldf_c
コード例 #3
0
ファイル: data_utils.py プロジェクト: wilchesf/Egret
def create_dicts_of_ptdf_losses(md,base_point=BasePointType.SOLUTION):
    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_r, ldf, ldf_c = tx_calc.calculate_ptdf_ldf(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_LOSSES)
    phi_loss_from, phi_loss_to = tx_calc.calculate_phi_loss_constant(branches,branch_attrs['names'],bus_attrs['names'],ApproximationType.PTDF_LOSSES)

    _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_r = {bus_attrs['names'][i]: ptdf_r[idx,i] for i in list(range(0,_len_bus))}
        branch['ptdf_r'] = _row_ptdf_r

        _row_ldf = {bus_attrs['names'][i]: ldf[idx,i] for i in list(range(0,_len_bus))}
        branch['ldf'] = _row_ldf

        branch['ldf_c'] = ldf_c[idx]

    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

        _row_phi_loss_from = {branch_attrs['names'][i]: phi_loss_from[idx,i] for i in list(range(0,_len_branch)) if phi_loss_from[idx, i] != 0.}
        bus['phi_loss_from'] = _row_phi_loss_from

        _row_phi_loss_to = {branch_attrs['names'][i]: phi_loss_to[idx,i] for i in list(range(0,_len_branch)) if phi_loss_to[idx, i] != 0.}
        bus['phi_loss_to'] = _row_phi_loss_to