예제 #1
0
def remove_bad_data(net,
                    init='flat',
                    tolerance=1e-6,
                    maximum_iterations=10,
                    calculate_voltage_angles=True,
                    rn_max_threshold=3.0,
                    ref_power=1e6):
    """
    Wrapper function for bad data removal.

    INPUT:
        **net** - The net within this line should be created.

        **init** - (string) Initial voltage for the estimation. 'flat' sets 1.0 p.u. / 0° for all
        buses, 'results' uses the values from *res_bus_est* if available and 'slack' considers the
        slack bus voltage (and optionally, angle) as the initial values. Default is 'flat'.

    OPTIONAL:
        **tolerance** - (float) - When the maximum state change between iterations is less than
        tolerance, the process stops. Default is 1e-6.

        **maximum_iterations** - (integer) - Maximum number of iterations. Default is 10.

        **calculate_voltage_angles** - (boolean) - Take into account absolute voltage angles and phase
        shifts in transformers, if init is 'slack'. Default is True.

        **rn_max_threshold** (float) - Identification threshold to determine
        if the largest normalized residual reflects a bad measurement
        (default value of 3.0)

        **chi2_prob_false** (float) - probability of error / false alarms
        (default value: 0.05)

    OUTPUT:
        **successful** (boolean) - Was the state estimation successful?
    """
    wls = state_estimation(tolerance,
                           maximum_iterations,
                           net,
                           ref_power=ref_power)
    v_start = None
    delta_start = None
    if init == 'results':
        v_start = net.res_bus_est.vm_pu
        delta_start = net.res_bus_est.va_degree
    elif init == 'slack':
        res_bus = estimate_voltage_vector(net)
        v_start = res_bus.vm_pu.values
        if calculate_voltage_angles:
            delta_start = res_bus.va_degree.values
    elif init != 'flat':
        raise UserWarning("Unsupported init value. Using flat initialization.")
    return wls.perform_rn_max_test(v_start, delta_start,
                                   calculate_voltage_angles, rn_max_threshold)
예제 #2
0
def chi2_analysis(net,
                  init='flat',
                  tolerance=1e-6,
                  maximum_iterations=10,
                  calculate_voltage_angles=True,
                  chi2_prob_false=0.05):
    """
    Wrapper function for the chi-squared test.

    INPUT:
        **net** - The net within this line should be created.

        **init** - (string) Initial voltage for the estimation. 'flat' sets 1.0 p.u. / 0° for all
        buses, 'results' uses the values from *res_bus_est* if available and 'slack' considers the
        slack bus voltage (and optionally, angle) as the initial values. Default is 'flat'.

    OPTIONAL:
        **tolerance** - (float) - When the maximum state change between iterations is less than
        tolerance, the process stops. Default is 1e-6.

        **maximum_iterations** - (integer) - Maximum number of iterations. Default is 10.

        **calculate_voltage_angles** - (boolean) - Take into account absolute voltage angles and phase
        shifts in transformers, if init is 'slack'. Default is True.

        **chi2_prob_false** (float) - probability of error / false alarms
        (default value: 0.05)

    OUTPUT:
        **bad_data_detected** (boolean) - Returns true if bad data has been detected
    """
    wls = state_estimation(tolerance, maximum_iterations, net)
    v_start = None
    delta_start = None
    if init == 'results':
        v_start = net.res_bus_est.vm_pu
        delta_start = net.res_bus_est.va_degree
    elif init == 'slack':
        res_bus = estimate_voltage_vector(net)
        v_start = res_bus.vm_pu.values
        if calculate_voltage_angles:
            delta_start = res_bus.va_degree.values
    elif init != 'flat':
        raise UserWarning("Unsupported init value. Using flat initialization.")
    return wls.perform_chi2_test(v_start, delta_start,
                                 calculate_voltage_angles, chi2_prob_false)
예제 #3
0
def estimate(net,
             init='flat',
             tolerance=1e-6,
             maximum_iterations=10,
             calculate_voltage_angles=True,
             ref_power=1e6):
    """
    Wrapper function for WLS state estimation.

    INPUT:
        **net** - The net within this line should be created.

        **init** - (string) Initial voltage for the estimation. 'flat' sets 1.0 p.u. / 0° for all
        buses, 'results' uses the values from *res_bus_est* if available and 'slack' considers the
        slack bus voltage (and optionally, angle) as the initial values. Default is 'flat'.

    OPTIONAL:
        **tolerance** - (float) - When the maximum state change between iterations is less than
        tolerance, the process stops. Default is 1e-6.

        **maximum_iterations** - (integer) - Maximum number of iterations. Default is 10.

        **calculate_voltage_angles** - (boolean) - Take into account absolute voltage angles and phase
        shifts in transformers, if init is 'slack'. Default is True.

    OUTPUT:
        **successful** (boolean) - Was the state estimation successful?
    """
    wls = state_estimation(tolerance,
                           maximum_iterations,
                           net,
                           ref_power=ref_power)
    v_start = None
    delta_start = None
    if init == 'results':
        v_start = net.res_bus_est.vm_pu
        delta_start = net.res_bus_est.va_degree
    elif init == 'slack':
        res_bus = estimate_voltage_vector(net)
        v_start = res_bus.vm_pu.values
        if calculate_voltage_angles:
            delta_start = res_bus.va_degree.values
    elif init != 'flat':
        raise UserWarning("Unsupported init value. Using flat initialization.")
    return wls.estimate(v_start, delta_start, calculate_voltage_angles)
예제 #4
0
def estimate(net,
             algorithm='wls',
             init='flat',
             tolerance=1e-6,
             maximum_iterations=10,
             calculate_voltage_angles=True,
             zero_injection='aux_bus',
             fuse_buses_with_bb_switch='all'):
    """
    Wrapper function for WLS state estimation.

    INPUT:
        **net** - The net within this line should be created

        **init** - (string) Initial voltage for the estimation. 'flat' sets 1.0 p.u. / 0° for all
        buses, 'results' uses the values from *res_bus_est* if available and 'slack' considers the
        slack bus voltage (and optionally, angle) as the initial values. Default is 'flat'

    OPTIONAL:
        **tolerance** - (float) - When the maximum state change between iterations is less than
        tolerance, the process stops. Default is 1e-6

        **maximum_iterations** - (integer) - Maximum number of iterations. Default is 10

        **calculate_voltage_angles** - (boolean) - Take into account absolute voltage angles and phase
        shifts in transformers, if init is 'slack'. Default is True
        
        **zero_injection** - (str, iterable, None) - Defines which buses are zero injection bus or the method
        to identify zero injection bus, with 'wls_estimator' virtual measurements will be added, with 
        'wls_estimator with zero constraints' the buses will be handled as constraints
        "auto": all bus without p,q measurement, without p, q value (load, sgen...) and aux buses will be
            identified as zero injection bus  
        "aux_bus": only aux bus will be identified as zero injection bus
        None: no bus will be identified as zero injection bus
        iterable: the iterable should contain index of the zero injection bus and also aux bus will be identified
            as zero-injection bus

        **fuse_buses_with_bb_switch** - (str, iterable, None) - Defines how buses with closed bb switches should 
        be handled, if fuse buses will only fused to one for calculation, if not fuse, an auxiliary bus and 
        auxiliary line will be automatically added to the network to make the buses with different p,q injection
        measurements identifieble
        "all": all buses with bb-switches will be fused, the same as the default behaviour in load flow
        None: buses with bb-switches and individual p,q measurements will be reconfigurated
            by auxiliary elements
        iterable: the iterable should contain the index of buses to be fused, the behaviour is contigous e.g.
            if one of the bus among the buses connected through bb switch is given, then all of them will still
            be fused

    OUTPUT:
        **successful** (boolean) - Was the state estimation successful?
    """

    if algorithm not in ESTIMATOR_MAPPING:
        raise UserWarning(
            "Algorithm {} is not a valid estimator".format(algorithm))

    wls = StateEstimation(net,
                          tolerance,
                          maximum_iterations,
                          algorithm=algorithm)
    v_start = None
    delta_start = None
    if init == 'results':
        v_start = net.res_bus_est.vm_pu
        delta_start = net.res_bus_est.va_degree
    elif init == 'slack':
        res_bus = estimate_voltage_vector(net)
        v_start = res_bus.vm_pu.values
        if calculate_voltage_angles:
            delta_start = res_bus.va_degree.values
    elif init != 'flat':
        raise UserWarning("Unsupported init value. Using flat initialization.")
    return wls.estimate(v_start,
                        delta_start,
                        calculate_voltage_angles,
                        zero_injection=zero_injection,
                        fuse_buses_with_bb_switch=fuse_buses_with_bb_switch)