Ejemplo n.º 1
0
    def run(self):
        """
        run the voltage collapse simulation
        @return:
        """
        print('Running voltage collapse...')

        nc = compile_snapshot_circuit(
            circuit=self.grid,
            apply_temperature=self.pf_options.apply_temperature_correction,
            branch_tolerance_mode=self.pf_options.
            branch_impedance_tolerance_mode,
            opf_results=self.opf_results)

        islands = nc.split_into_islands(ignore_single_node_islands=self.
                                        pf_options.ignore_single_node_islands)

        result_series = list()

        for island in islands:

            self.progress_text.emit('Running voltage collapse at circuit ' +
                                    str(nc) + '...')

            if len(island.vd) > 0 and len(island.pqpv) > 0:

                results = continuation_nr(
                    Ybus=island.Ybus,
                    Cf=island.Cf,
                    Ct=island.Ct,
                    Yf=island.Yf,
                    Yt=island.Yt,
                    branch_rates=island.branch_rates,
                    Sbase=island.Sbase,
                    Ibus_base=island.Ibus,
                    Ibus_target=island.Ibus,
                    Sbus_base=self.inputs.Sbase[island.original_bus_idx],
                    Sbus_target=self.inputs.Starget[island.original_bus_idx],
                    V=self.inputs.Vbase[island.original_bus_idx],
                    distributed_slack=self.pf_options.distributed_slack,
                    bus_installed_power=island.bus_installed_power,
                    vd=island.vd,
                    pv=island.pv,
                    pq=island.pq,
                    step=self.options.step,
                    approximation_order=self.options.approximation_order,
                    adapt_step=self.options.adapt_step,
                    step_min=self.options.step_min,
                    step_max=self.options.step_max,
                    error_tol=self.options.error_tol,
                    tol=self.options.tol,
                    max_it=self.options.max_it,
                    stop_at=self.options.stop_at,
                    control_q=self.pf_options.control_Q,
                    qmax_bus=island.Qmax_bus,
                    qmin_bus=island.Qmin_bus,
                    original_bus_types=island.bus_types,
                    base_overload_number=self.inputs.base_overload_number,
                    verbose=False,
                    call_back_fx=self.progress_callback)

                # store the result series
                result_series.append(results)

        # analyze the result series to compact all the results into one object
        if len(result_series) > 0:
            max_len = max([len(r) for r in result_series])
        else:
            max_len = 0

            # declare results
        self.results = ContinuationPowerFlowResults(
            nval=max_len,
            nbus=nc.nbus,
            nbr=nc.nbr,
            bus_names=nc.bus_names,
            branch_names=nc.branch_names,
            bus_types=nc.bus_types)

        for i in range(len(result_series)):
            if len(result_series[i]) > 0:
                self.results.apply_from_island(result_series[i],
                                               islands[i].original_bus_idx,
                                               islands[i].original_branch_idx)

        print('done!')
        self.progress_text.emit('Done!')
        self.done_signal.emit()
    def run(self):
        """
        run the voltage collapse simulation
        @return:
        """
        print('Running voltage collapse...')
        nbus = self.circuit.get_bus_number()

        numerical_circuit = compile_snapshot_circuit(
            circuit=self.circuit,
            apply_temperature=self.pf_options.apply_temperature_correction,
            branch_tolerance_mode=self.pf_options.
            branch_impedance_tolerance_mode,
            opf_results=self.opf_results)

        numerical_input_islands = split_into_islands(
            numeric_circuit=numerical_circuit,
            ignore_single_node_islands=self.pf_options.
            ignore_single_node_islands)

        self.results = VoltageCollapseResults(
            nbus=numerical_circuit.nbus,
            nbr=numerical_circuit.nbr,
            bus_names=numerical_circuit.bus_names)

        self.results.bus_types = numerical_circuit.bus_types

        for nc, numerical_island in enumerate(numerical_input_islands):

            self.progress_text.emit('Running voltage collapse at circuit ' +
                                    str(nc) + '...')

            if len(numerical_island.vd) > 0:
                Voltage_series, Lambda_series, \
                normF, success = continuation_nr(Ybus=numerical_island.Ybus,
                                                 Ibus_base=numerical_island.Ibus,
                                                 Ibus_target=numerical_island.Ibus,
                                                 Sbus_base=self.inputs.Sbase[numerical_island.original_bus_idx],
                                                 Sbus_target=self.inputs.Starget[numerical_island.original_bus_idx],
                                                 V=self.inputs.Vbase[numerical_island.original_bus_idx],
                                                 pv=numerical_island.pv,
                                                 pq=numerical_island.pq,
                                                 step=self.options.step,
                                                 approximation_order=self.options.approximation_order,
                                                 adapt_step=self.options.adapt_step,
                                                 step_min=self.options.step_min,
                                                 step_max=self.options.step_max,
                                                 error_tol=self.options.error_tol,
                                                 tol=self.options.tol,
                                                 max_it=self.options.max_it,
                                                 stop_at=self.options.stop_at,
                                                 verbose=False,
                                                 call_back_fx=self.progress_callback)

                # nbus can be zero, because all the arrays are going to be overwritten
                res = VoltageCollapseResults(
                    nbus=numerical_island.nbus,
                    nbr=numerical_island.nbr,
                    bus_names=numerical_island.bus_names)
                res.voltages = np.array(Voltage_series)
                res.lambdas = np.array(Lambda_series)
                res.error = normF
                res.converged = bool(success)
            else:
                res = VoltageCollapseResults(
                    nbus=numerical_island.nbus,
                    nbr=numerical_island.nbr,
                    bus_names=numerical_island.bus_names)
                res.voltages = np.array([[0] * numerical_island.nbus])
                res.lambdas = np.array([[0] * numerical_island.nbus])
                res.error = [0]
                res.converged = True

            if len(res.voltages) > 0:
                # compute the island branch results
                Sbranch, Ibranch, Vbranch, \
                loading, losses, flow_direction, \
                Sbus = power_flow_post_process(calculation_inputs=numerical_island,
                                               Sbus=self.inputs.Starget[numerical_island.original_bus_idx],
                                               V=res.voltages[-1],
                                               branch_rates=numerical_island.branch_rates)

                # update results
                self.results.apply_from_island(
                    voltage_collapse_res=res,
                    Sbranch=Sbranch,
                    Ibranch=Ibranch,
                    loading=loading,
                    losses=losses,
                    Sbus=Sbus,
                    bus_original_idx=numerical_island.original_bus_idx,
                    branch_original_idx=numerical_island.original_branch_idx,
                    nbus_full=nbus)
            else:
                print('No voltage values!')
        print('done!')
        self.progress_text.emit('Done!')
        self.done_signal.emit()
Ejemplo n.º 3
0
    def run(self):
        """
        run the voltage collapse simulation
        @return:
        """
        print('Running voltage collapse...')
        nbus = len(self.circuit.buses)
        nbr = len(self.circuit.branches)
        self.results = VoltageCollapseResults(nbus=nbus, nbr=nbr)

        # compile the numerical circuit
        numerical_circuit = self.circuit.compile_snapshot()
        numerical_input_islands = numerical_circuit.compute()

        self.results.bus_types = numerical_circuit.bus_types

        for nc, numerical_island in enumerate(numerical_input_islands):

            self.progress_text.emit('Running voltage collapse at circuit ' +
                                    str(nc) + '...')

            if len(numerical_island.ref) > 0:
                Voltage_series, Lambda_series, \
                normF, success = continuation_nr(Ybus=numerical_island.Ybus,
                                                 Ibus_base=numerical_island.Ibus,
                                                 Ibus_target=numerical_island.Ibus,
                                                 Sbus_base=self.inputs.Sbase[numerical_island.original_bus_idx],
                                                 Sbus_target=self.inputs.Starget[numerical_island.original_bus_idx],
                                                 V=self.inputs.Vbase[numerical_island.original_bus_idx],
                                                 pv=numerical_island.pv,
                                                 pq=numerical_island.pq,
                                                 step=self.options.step,
                                                 approximation_order=self.options.approximation_order,
                                                 adapt_step=self.options.adapt_step,
                                                 step_min=self.options.step_min,
                                                 step_max=self.options.step_max,
                                                 error_tol=self.options.error_tol,
                                                 tol=self.options.tol,
                                                 max_it=self.options.max_it,
                                                 stop_at=self.options.stop_at,
                                                 verbose=False,
                                                 call_back_fx=self.progress_callback)

                # nbus can be zero, because all the arrays are going to be overwritten
                res = VoltageCollapseResults(nbus=numerical_island.nbus,
                                             nbr=numerical_island.nbr)
                res.voltages = np.array(Voltage_series)
                res.lambdas = np.array(Lambda_series)
                res.error = normF
                res.converged = bool(success)
            else:
                res = VoltageCollapseResults(nbus=numerical_island.nbus,
                                             nbr=numerical_island.nbr)
                res.voltages = np.array([[0] * numerical_island.nbus])
                res.lambdas = np.array([[0] * numerical_island.nbus])
                res.error = [0]
                res.converged = True

            if len(res.voltages) > 0:
                # compute the island branch results
                branch_res = numerical_island.compute_branch_results(
                    res.voltages[-1])

                self.results.apply_from_island(
                    res, branch_res, numerical_island.original_bus_idx,
                    numerical_island.original_branch_idx, nbus)
            else:
                print('No voltage values!')
        print('done!')
        self.progress_text.emit('Done!')
        self.done_signal.emit()