Measurement Model

For further information on this topic, please see the Measurement Model section of the Manual. Below, we have provided a list of functions that can be used to create, save, and manipulate with measurement devices.


Measurement Data
Voltmeter
Ammeter
Wattmeter
Varmeter
PMU

To load measurement model API functionalities into the current scope, utilize the following command:

using JuliaGrid

Measurement Data

JuliaGrid.measurementFunction
measurement(file::String)

The function builds the composite type Measurement and populates voltmeter, ammeter, wattmeter, varmeter, and pmu fields. In general, once the composite type Measurement has been created, it is possible to add new measurement devices, or modify the parameters of existing ones.

Argument

It requires a string path to the HDF5 file with the .h5 extension.

Returns

The Measurement composite type with the following fields:

  • voltmeter: bus voltage magnitude measurements;
  • ammeter: branch current magnitude measurements;
  • wattmeter: active power injection and active power flow measurements;
  • varmeter: reactive power injection and reactive power flow measurements;
  • pmu: bus voltage and branch current phasor measurements.

Units

JuliaGrid stores all data in per-units and radians format.

Example

device = measurement("measurement14.h5")
source
measurement()

Alternatively, the Measurement composite type can be initialized by calling the function without any arguments. This allows the model to be built from scratch and modified as needed.

Example

device = measurement()
source
JuliaGrid.saveMeasurementFunction
saveMeasurement(device::Measurement; path::String, reference::String, note::String)

The function saves the measurement's data in the HDF5 file using the fields voltmeter, ammeter, wattmeter, varmeter, and pmu from the Measurement composite type.

Keywords

The location and file name of the HDF5 file is specified by the mandatory keyword path in the format of "path/name.h5". Additional information can be provided by the optional keywords reference and note, which can be saved along with the power system data.

View HDF5 File

To view the saved HDF5 file, you can use the HDFView software.

Example

system = powerSystem("case14.m")
acModel!(system)
analysis = acOptimalPowerFlow(system, Ipopt.Optimizer)
solve!(system, analysis)
power!(system, analysis)

device = measurement()
addVoltmeter!(system, device, analysis)
addWattmeter!(system, device, analysis)

saveMeasurement(device; path = "D:/measurement14.h5")
source
JuliaGrid.status!Function
status!(system::PowerSystem, device::Measurement; inservice, outservice, redundancy)

The function generates a set of measurements, assigning measurement devices randomly to either in-service or out-of-service states based on specified keywords.

Keywords

These keywords allow the user to configure the measurement set as follows:

  • inservice: sets the number of in-service devices;
  • outservice: sets the number of out-of-service devices;
  • redundancy: determines in-service devices based on redundancy.

If a user employs multiple keywords for configuration, only the first keyword in the hierarchical order will be considered, and the other keywords will be disregarded.

Updates

The function updates all the status fields within the Measurement type.

Examples

Creating a measurement set with a specific number of in-service devices:

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
power!(system, analysis)

device = measurement()

addVoltmeter!(system, device, analysis)
addWattmeter!(system, device, analysis)

status!(system, device; inservice = 30)

Creating a measurement set using redundancy:

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
power!(system, analysis)

device = measurement()

addVoltmeter!(system, device, analysis)
addWattmeter!(system, device, analysis)
addVarmeter!(system, device, analysis)

status!(system, device; redundancy = 2.5)
source

Voltmeter

JuliaGrid.addVoltmeter!Method
addVoltmeter!(system::PowerSystem, device::Measurement; label, bus, magnitude, variance,
    noise, status)

The function adds a new voltmeter that measures bus voltage magnitude to the Measurement composite type within a given PowerSystem type. The voltmeter can be added to an already defined bus.

Keywords

The voltmeter is defined with the following keywords:

  • label: a unique label for the voltmeter;
  • bus: the label of the bus to which the voltmeter is connected;
  • magnitude (pu or V): the bus voltage magnitude value;
  • variance (pu or V): the variance of the bus voltage magnitude measurement;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the magnitude;
    • noise = false: uses the magnitude value only;
  • status: the operating status of the voltmeter:
    • status = 1: in-service;
    • status = 0: out-of-service.

Updates

The function updates the voltmeter field of the Measurement composite type.

Default Settings

Default settings for certain keywords are as follows: variance = 1e-2, noise = false, status = 1, and users can modify these default settings using the @voltmeter macro.

Units

The default units for the magnitude and variance keywords are per-units (pu). However, users can choose to use volts (V) as the units by applying the @voltage macro.

Examples

Adding a voltmeter using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)

addVoltmeter!(system, device; label = "Voltmeter 1", bus = "Bus 1", magnitude = 1.1)

Adding a voltmeter using a custom unit system:

@voltage(kV, rad, kV)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132.0)

addVoltmeter!(system, device; label = "Voltmeter 1", bus = "Bus 1", magnitude = 145.2)
source
JuliaGrid.addVoltmeter!Method
addVoltmeter!(system::PowerSystem, device::Measurement, analysis::AC; variance, noise,
    status)

The function incorporates voltmeters into the Measurement composite type for every bus within the PowerSystem type. These measurements are derived from the exact bus voltage magnitudes defined in the AC abstract type.

Keywords

Users have the option to configure the following keywords:

  • variance (pu or V): the variance of bus voltage magnitude measurements;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the voltage magnitudes;
    • noise = false: uses the magnitude value only;
  • status: the operating status of the voltmeters:
    • status = 1: in-service;
    • status = 0: out-of-service.

Updates

The function updates the voltmeter field of the Measurement composite type.

Default Settings

Default settings for keywords are as follows: variance = 1e-2, noise = false, and status = 1, and users can modify these default settings using the @voltmeter macro.

Units

By default, the unit for variance is per-unit (pu). However, users can choose to use volts (V) as the units by applying the @voltage macro.

Example

Adding voltmeters using exact values from the AC power flow:

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end

device = measurement()

@voltmeter(label = "Voltmeter ?")
addVoltmeter!(system, device, analysis; variance = 1e-3, noise = true)
source
JuliaGrid.updateVoltmeter!Function
updateVoltmeter!(system::PowerSystem, device::Measurement, analysis::Analysis; kwargs...)

The function allows for the alteration of parameters for a voltmeter.

Arguments

If the Analysis type is omitted, the function applies changes to the Measurement composite type only. However, when including the Analysis type, it updates both the Measurement and Analysis types. This streamlined process avoids the need to completely rebuild vectors and matrices when adjusting these parameters.

Keywords

To update a specific voltmeter, provide the necessary kwargs input arguments in accordance with the keywords specified in the addVoltmeter! function, along with their respective values. Ensure that the label keyword matches the label of the existing voltmeter you want to modify. If any keywords are omitted, their corresponding values will remain unchanged.

Updates

The function updates the voltmeter field within the Measurement composite type. Furthermore, it guarantees that any modifications to the parameters are transmitted to the Analysis type.

Units

Units for input parameters can be changed using the same method as described for the addVoltmeter! function.

Example

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)

addVoltmeter!(system, device; label = "Voltmeter 1", bus = "Bus 1", magnitude = 1.1)
updateVoltmeter!(system, device; label = "Voltmeter 1", magnitude = 0.9)
source
JuliaGrid.statusVoltmeter!Function
statusVoltmeter!(system::PowerSystem, device::Measurement; inservice, outservice,
    redundancy)

The function generates a set of voltmeters, assigning voltmeters randomly to either in-service or out-of-service states based on specified keywords.

Keywords

These keywords allow the user to configure the voltmeter set as follows:

  • inservice: sets the number of in-service devices;
  • outservice: sets the number of out-of-service devices;
  • redundancy: determines in-service devices based on redundancy.

If a user employs multiple keywords for configuration, only the first keyword in the hierarchical order will be considered, and the other keywords will be disregarded.

Updates

The function updates the status field within the Voltmeter type.

Examples

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end

device = measurement()

addVoltmeter!(system, device, analysis)
statusVoltmeter!(system, device; inservice = 10)
source
JuliaGrid.@voltmeterMacro
@voltmeter(label, variance, noise, status)

The macro generates a template for a voltmeter, which can be utilized to define a voltmeter using the addVoltmeter! function.

Keywords

To establish the voltmeter template, users can specify default values for the variance, noise, and status keywords, along with pattern for labels using the label keyword.

Units

By default, the unit for variance is per-unit (pu). However, users can choose to use volts (V) as the units by applying the @voltage macro.

Examples

Adding a voltmeter using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)

@voltmeter(label = "Voltmeter ?", variance = 1e-5)
addVoltmeter!(system, device; bus = "Bus 1", magnitude = 1.1)

Adding a voltmeter using a custom unit system:

@voltage(kV, rad, kV)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132.0)

@voltmeter(label = "Voltmeter ?", variance = 0.00132)
addVoltmeter!(system, device; bus = "Bus 1", magnitude = 145.2)
source

Ammeter

JuliaGrid.addAmmeter!Method
addAmmeter!(system::PowerSystem, device::Measurement; label, from, to, magnitude,
    variance, noise, status)

The function adds a new ammeter that measures branch current magnitude to the Measurement type within a given PowerSystem type. The ammeter can be added to an already defined branch.

Keywords

The ammeter is defined with the following keywords:

  • label: a unique label for the ammeter;
  • from: the label of the branch if the ammeter is located at the from-bus end;
  • to: the label of the branch if the ammeter is located at the to-bus end;
  • magnitude (pu or A): the branch current magnitude value;
  • variance (pu or A): the variance of the branch current magnitude measurement;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the magnitude;
    • noise = false: uses the magnitude value only;
  • status: the operating status of the ammeter:
    • status = 1: in-service;
    • status = 0: out-of-service.

Updates

The function updates the ammeter field of the Measurement composite type.

Default Settings

Default settings for certain keywords are as follows: variance = 1e-2, noise = false, status = 1, which apply to ammeters located at both the from-bus and to-bus ends. Users can fine-tune these settings by explicitly specifying the variance and status for ammeters positioned on either the from-bus or to-bus ends of branches using the @ammeter macro.

Units

The default units for the magnitude and variance keywords are per-units (pu). However, users can choose to use amperes (A) as the units by applying the @current macro.

Examples

Adding ammeters using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addAmmeter!(system, device; label = "Ammeter 1", from = "Branch 1", magnitude = 1.1)
addAmmeter!(system, device; label = "Ammeter 2", to = "Branch 1", magnitude = 1.0)

Adding ammeters using a custom unit system:

@current(A, rad)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addAmmeter!(system, device; label = "Ammeter 1", from = "Branch 1", magnitude = 481.125)
addAmmeter!(system, device; label = "Ammeter 2", to = "Branch 1", magnitude = 437.386)
source
JuliaGrid.addAmmeter!Method
addAmmeter!(system::PowerSystem, device::Measurement, analysis::AC; varianceFrom,
    statusFrom, varianceTo, statusTo, noise)

The function incorporates ammeters into the Measurement type for every branch within the PowerSystem type. These measurements are derived from the exact branch current magnitudes defined in the AC abstract type. These exact values are perturbed by white Gaussian noise with the specified variance to obtain measurement data.

Keywords

Users have the option to configure the following keywords:

  • varianceFrom (pu or A): the measurement variance for ammeters at the from-bus ends;
  • statusFrom: the operating status of the ammeters at the from-bus ends:
    • statusFrom = 1: in-service;
    • statusFrom = 0: out-of-service;
  • varianceTo (pu or A): the measurement variance for ammeters at the to-bus ends;
  • statusTo: the operating status of the ammeters at the to-bus ends:
    • statusTo = 1: in-service;
    • statusTo = 0: out-of-service;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the current magnitudes;
    • noise = false: uses the magnitude value only.

Updates

The function updates the ammeter field of the Measurement composite type.

Default Settings

Default settings for keywords are as follows: varianceFrom = 1e-2, statusFrom = 1, varianceTo = 1e-2, statusTo = 1, and noise = false. Users can change these default settings using the @ammeter macro.

Units

The default units for the varianceFrom and varianceTo keywords are per-units (pu). However, users can choose to use amperes (A) as the units by applying the @current macro.

Example

Adding ammeters using exact values from the AC power flow:

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
current!(system, analysis)

device = measurement()

@ammeter(label = "Ammeter ?")
addAmmeter!(system, device, analysis; varianceFrom = 1e-3, statusTo = 0)
source
JuliaGrid.updateAmmeter!Function
updateAmmeter!(system::PowerSystem, device::Measurement, analysis::Analysis; kwargs...)

The function allows for the alteration of parameters for an ammeter.

Arguments

If the Analysis type is omitted, the function applies changes to the Measurement composite type only. However, when including the Analysis type, it updates both the Measurement and Analysis types. This streamlined process avoids the need to completely rebuild vectors and matrices when adjusting these parameters.

Keywords

To update a specific ammeter, provide the necessary kwargs input arguments in accordance with the keywords specified in the addAmmeter! function, along with their respective values. Ensure that the label keyword matches the label of the existing ammeter you want to modify. If any keywords are omitted, their corresponding values will remain unchanged.

Updates

The function updates the ammeter field within the Measurement composite type. Furthermore, it guarantees that any modifications to the parameters are transmitted to the Analysis type.

Units

Units for input parameters can be changed using the same method as described for the addAmmeter! function.

Example

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addAmmeter!(system, device; label = "Ammeter 1", from = "Branch 1", magnitude = 1.1)
updateAmmeter!(system, device; label = "Ammeter 1", magnitude = 1.2, variance = 1e-4)
source
JuliaGrid.statusAmmeter!Function
statusAmmeter!(system::PowerSystem, ammeter::Ammeter; inservice, inserviceFrom,
    inserviceTo, outservice, outserviceFrom, outserviceTo, redundancy, redundancyFrom,
    redundancyTo)

The function generates a set of ammeters, assigning ammeters randomly to either in-service or out-of-service states based on specified keywords.

Keywords

These keywords allow the user to configure the ammeter set as follows:

  • inservice: sets the number of in-service ammeters or allows fine-tuning:
    • inserviceFrom: sets only ammeters loacted at the from-bus end;
    • inserviceTo: sets only ammeters loacted at the to-bus end;
  • outservice: sets the number of out-of-service ammeters or allows fine-tuning:
    • outserviceFrom: sets only ammeters loacted at the from-bus end;
    • outserviceTo: sets only ammeters loacted at the to-bus end;
  • redundancy: determines in-service ammeters based on redundancy or allows fine-tuning:
    • redundancyFrom: determines only ammeters loacted at the from-bus end;
    • redundancyTo: determines only ammeters loacted at the to-bus end.

In case a user employs multiple keywords from the set inservice, outservice, and redundancy, only the first keyword in the hierarchical order will be taken into consideration, and the remaining keywords will be ignored. Furthermore, in this scenario, all fine-tuning keywords will not be considered.

If a user chooses fine-tuning without specifying any of the primary keywords, only one keyword from each of the two sets will be executed, and the remaining keywords within each set will be ignored. These sets are as follows:

  • inserviceFrom, outserviceFrom, redundancyFrom;
  • inserviceTo, outserviceTo, redundancyTo.

Updates

The function updates the status field within the Ammeter type.

Examples

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
current!(system, analysis)

device = measurement()

addAmmeter!(system, device, analysis)
statusAmmeter!(system, device; inserviceFrom = 5, inserviceTo = 10)
source
JuliaGrid.@ammeterMacro
@ammeter(label, varianceFrom, statusFrom, varianceTo, statusTo, noise)

The macro generates a template for an ammeter, which can be utilized to define an ammeter using the addAmmeter! function.

Keywords

To establish the ammeter template, users can set default variance and status values for ammeters at both the from-bus and to-bus ends of branches using varianceFrom and statusFrom for the former and varianceTo and statusTo for the latter. Users can also configure label patterns with the label keyword, as well as specify the noise type.

Units

The default units for the varianceFrom and varianceTo keywords are per-units (pu). However, users can choose to use amperes (A) as the units by applying the @current macro.

Examples

Adding an ammeter using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@ammeter(label = "Ammeter ?", varianceTo = 1e-3, statusTo = 0)
addAmmeter!(system, device; to = "Branch 1", magnitude = 1.1)

Adding an ammeter using a custom unit system:

@current(A, rad)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@ammeter(label = "Ammeter ?", varianceTo = 0.004374, statusTo = 0)
addAmmeter!(system, device; label = "Ammeter 1", to = "Branch 1", magnitude = 481.125)
source

Wattmeter

JuliaGrid.addWattmeter!Method
addWattmeter!(system::PowerSystem, device::Measurement; label, bus, from, to, active,
    variance, noise, status)

The function adds a new wattmeter that measures active power injection or active power flow to the Measurement composite type within a given PowerSystem type. The wattmeter can be added to an already defined bus or branch.

Keywords

The wattmeter is defined with the following keywords:

  • label: a unique label for the wattmeter;
  • bus: the label of the bus if the wattmeter is located at the bus;
  • from: the label of the branch if the wattmeter is located at the from-bus end;
  • to: the label of the branch if the wattmeter is located at the to-bus end;
  • active (pu or W): the active power value;
  • variance (pu or W): the variance of the active power measurement;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the active;
    • noise = false: uses the active value only;
  • status: the operating status of the wattmeter:
    • status = 1: in-service;
    • status = 0: out-of-service.

Updates

The function updates the wattmeter field of the Measurement composite type.

Default Settings

Default settings for certain keywords are as follows: variance = 1e-2, noise = false, and status = 1, which apply to wattmeters located at the bus, as well as at both the from-bus and to-bus ends. Users can fine-tune these settings by explicitly specifying the variance and status for wattmeters positioned at the buses, from-bus ends, or to-bus ends of branches using the @wattmeter macro.

Units

The default units for the active and variance keywords are per-units (pu). However, users can choose to use watts (W) as the units by applying the @power macro.

Examples

Adding wattmeters using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addWattmeter!(system, device; label = "Wattmeter 1", bus = "Bus 2", active = 0.4)
addWattmeter!(system, device; label = "Wattmeter 2", from = "Branch 1", active = 0.1)

Adding wattmeters using a custom unit system:

@power(MW, pu, pu)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addWattmeter!(system, device; label = "Wattmeter 1", bus = "Bus 2", active = 40.0)
addWattmeter!(system, device; label = "Wattmeter 2", from = "Branch 1", active = 10.0)
source
JuliaGrid.addWattmeter!Method
addWattmeter!(system::PowerSystem, device::Measurement, analysis::AC;
    varianceBus, statusBus, varianceFrom, statusFrom, varianceTo, statusTo, noise)

The function incorporates wattmeters into the Measurement composite type for every bus and branch within the PowerSystem type. These measurements are derived from the exact active power injections at buses and active power flows in branches defined in the AC abstract type. These exact values are perturbed by white Gaussian noise with the specified variance to obtain measurement data.

Keywords

Users have the option to configure the following keywords:

  • varianceBus (pu or W): the measurement variance for wattmeters at the buses;
  • statusBus: the operating status of the wattmeters at the buses:
    • statusBus = 1: in-service;
    • statusBus = 0: out-of-service;
  • varianceFrom (pu or W): the measurement variance for wattmeters at the from-bus ends;
  • statusFrom: the operating status of the wattmeters at the from-bus ends:
    • statusFrom = 1: in-service;
    • statusFrom = 0: out-of-service;
  • varianceTo (pu or W): the measurement variance for wattmeters at the to-bus ends;
  • statusTo: the operating status of the wattmeters at the to-bus ends:
    • statusTo = 1: in-service;
    • statusTo = 0: out-of-service;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the active powers;
    • noise = false: uses the magnitude value only.

Updates

The function updates the wattmeter field of the Measurement composite type.

Default Settings

Default settings for keywords are as follows: varianceBus = 1e-2, statusBus = 1, varianceFrom = 1e-2, statusFrom = 1, varianceTo = 1e-2, statusTo = 1, and noise = false. Users can change these default settings using the @wattmeter macro.

Units

The default units for the varianceBus, varianceFrom, and varianceTo keywords are per-units (pu). However, users can choose to use watts (W) as the units by applying the @power macro.

Example

Adding wattmeters using exact values from the AC power flow:

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
power!(system, analysis)

device = measurement()

@wattmeter(label = "Wattmeter ?")
addWattmeter!(system, device, analysis; varianceBus = 1e-3, statusFrom = 0)
source
JuliaGrid.updateWattmeter!Function
updateWattmeter!(system::PowerSystem, device::Measurement, analysis::Analysis; kwargs...)

The function allows for the alteration of parameters for a wattmeter.

Arguments

If the Analysis type is omitted, the function applies changes to the Measurement composite type only. However, when including the Analysis type, it updates both the Measurement and Analysis types. This streamlined process avoids the need to completely rebuild vectors and matrices when adjusting these parameters.

Keywords

To update a specific wattmeter, provide the necessary kwargs input arguments in accordance with the keywords specified in the addWattmeter! function, along with their respective values. Ensure that the label keyword matches the label of the existing wattmeter you want to modify. If any keywords are omitted, their corresponding values will remain unchanged.

Updates

The function updates the wattmeter field within the Measurement composite type. Furthermore, it guarantees that any modifications to the parameters are transmitted to the Analysis type.

Units

Units for input parameters can be changed using the same method as described for the addWattmeter! function.

Example

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addWattmeter!(system, device; label = "Wattmeter 1", from = "Branch 1", active = 1.1)
updateWattmeter!(system, device; label = "Wattmeter 1", active = 1.2, variance = 1e-4)
source
JuliaGrid.statusWattmeter!Function
statusWattmeter!(system::PowerSystem, device::Measurement; inservice, inserviceBus,
    inserviceFrom, inserviceTo, outservice, outserviceBus outserviceFrom, outserviceTo,
    redundancy, redundancyBus, redundancyFrom, redundancyTo)

The function generates a set of wattmeters, assigning wattmeters randomly to either in-service or out-of-service states based on specified keywords.

Keywords

These keywords allow the user to configure the wattmeter set as follows:

  • inservice: sets the number of in-service wattmeters or allows fine-tuning:
    • inserviceBus: sets only wattmeters loacted at the bus;
    • inserviceFrom: sets only wattmeters loacted at the from-bus end;
    • inserviceTo: sets only wattmeters loacted at the to-bus end;
  • outservice: sets the number of out-of-service wattmeters or allows fine-tuning:
    • outserviceBus: sets only wattmeters loacted at the bus;
    • outserviceFrom: sets only wattmeters loacted at the from-bus end;
    • outserviceTo: sets only wattmeters loacted at the to-bus end;
  • redundancy: determines in-service wattmeters based on redundancy or allows fine-tuning:
    • redundancyBus: determines only wattmeters loacted at the bus;
    • redundancyFrom: determines only wattmeters loacted at the from-bus end;
    • redundancyTo: determines only wattmeters loacted at the to-bus end.

In case a user employs multiple keywords from the set inservice, outservice, and redundancy, only the first keyword in the hierarchical order will be taken into consideration, and the remaining keywords will be ignored. Furthermore, in this scenario, all fine-tuning keywords will not be considered.

If a user chooses fine-tuning without specifying any of the primary keywords, only one keyword from each of the three sets will be executed, and the remaining keywords within each set will be ignored. These sets are as follows:

  • inserviceBus, outserviceBus, redundancyBus;
  • inserviceFrom, outserviceFrom, redundancyFrom;
  • inserviceTo, outserviceTo, redundancyTo.

Updates

The function updates the status field within the Wattmeter type.

Examples

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
power!(system, analysis)

device = measurement()

addWattmeter!(system, device, analysis)
statusWattmeter!(system, device; outserviceBus = 14, inserviceFrom = 10, outserviceTo = 2)
source
JuliaGrid.@wattmeterMacro
@wattmeter(label, varianceBus, statusBus, varianceFrom, statusFrom, varianceTo, statusTo,
    noise)

The macro generates a template for a wattmeter, which can be utilized to define a wattmeter using the addWattmeter! function.

Keywords

To establish the wattmeter template, users can set default variance and status values for wattmeters at buses using varianceBus and statusBus, and at both the from-bus and to-bus ends of branches using varianceFrom and statusFrom for the former and varianceTo and statusTo for the latter. Users can also configure label patterns with the label keyword, as well as specify the noise type.

Units

The default units for the varianceBus, varianceFrom, and varianceTo keywords are per-units (pu). However, users can choose to use watts (W) as the units by applying the @power macro.

Examples

Adding wattmeters using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@wattmeter(label = "Wattmeter ?", varianceBus = 1e-3, varianceFrom = 1e-4)
addWattmeter!(system, device; bus = "Bus 2", active = 0.4)
addWattmeter!(system, device; from = "Branch 1", active = 0.1)

Adding wattmeters using a custom unit system:

@power(MW, pu, pu)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@wattmeter(label = "Wattmeter ?", varianceBus = 1e-1, varianceFrom = 1e-2)
addWattmeter!(system, device; bus = "Bus 2", active = 40.0)
addWattmeter!(system, device; from = "Branch 1", active = 10.0)
source

Varmeter

JuliaGrid.addVarmeter!Method
addVarmeter!(system::PowerSystem, device::Measurement; label, bus, from, to, reactive,
    variance, noise, status)

The function adds a new varmeter that measures reactivepower injection or reactive power flow to the Measurement composite type within a given PowerSystem type. The varmeter can be added to an already defined bus or branch.

Keywords

The varmeter is defined with the following keywords:

  • label: a unique label for the varmeter;
  • bus: the label of the bus if the varmeter is located at the bus;
  • from: the label of the branch if the varmeter is located at the from-bus end;
  • to: the label of the branch if the varmeter is located at the to-bus end;
  • reactive (pu or VAr): the reactive power value;
  • variance (pu or VAr): the variance of the reactive power measurement;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the reactive;
    • noise = false: uses the reactive value only;
  • status: the operating status of the varmeter:
    • status = 1: in-service;
    • status = 0: out-of-service.

Updates

The function updates the varmeter field of the Measurement composite type.

Default Settings

Default settings for certain keywords are as follows: variance = 1e-2, noise = false, and status = 1, which apply to varmeters located at the bus, as well as at both the from-bus and to-bus ends. Users can fine-tune these settings by explicitly specifying the variance and status for varmeters positioned at the buses, from-bus ends, or to-bus ends of branches using the @varmeter macro.

Units

The default units for the reactive and variance keywords are per-units (pu). However, users can choose to use volt-amperes reactive (VAr) as the units by applying the @power macro.

Examples

Adding varmeters using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addVarmeter!(system, device; label = "Varmeter 1", bus = "Bus 2", reactive = 0.4)
addVarmeter!(system, device; label = "Varmeter 2", from = "Branch 1", reactive = 0.1)

Adding varmeters using a custom unit system:

@power(MW, pu, pu)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addVarmeter!(system, device; label = "Varmeter 1", bus = "Bus 2", reactive = 40.0)
addVarmeter!(system, device; label = "Varmeter 2", from = "Branch 1", reactive = 10.0)
source
JuliaGrid.addVarmeter!Method
addVarmeter!(system::PowerSystem, device::Measurement, analysis::AC;
    varianceBus, statusBus, varianceFrom, statusFrom, varianceTo, statusTo, noise)

The function incorporates varmeters into the Measurement composite type for every bus and branch within the PowerSystem type. These measurements are derived from the exact reactive power injections at buses and reactive power flows in branches defined in the AC abstract type. These exact values are perturbed by white Gaussian noise with the specified variance to obtain measurement data.

Keywords

  • varianceBus (pu or VAr): the measurement variance for varmeters at the buses;
  • statusBus: the operating status of the varmeters at the buses:
    • statusBus = 1: in-service;
    • statusBus = 0: out-of-service;
  • varianceFrom (pu or VAr): the measurement variance for varmeters at the from-bus ends;
  • statusFrom: the operating status of the varmeters at the from-bus ends:
    • statusFrom = 1: in-service;
    • statusFrom = 0: out-of-service;
  • varianceTo (pu or VAr): the measurement variance for varmeters at the to-bus ends;
  • statusTo: the operating status of the varmeters at the to-bus ends:
    • statusTo = 1: in-service;
    • statusTo = 0: out-of-service;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the reactive powers;
    • noise = false: uses the magnitude value only.

Updates

The function updates the varmeter field of the Measurement composite type.

Default Settings

Default settings for keywords are as follows: varianceBus = 1e-2, statusBus = 1, varianceFrom = 1e-2, statusFrom = 1, varianceTo = 1e-2, statusTo = 1, and noise = false. Users can change these default settings using the @varmeter macro.

Units

The default units for the varianceBus, varianceFrom, and varianceTo keywords are per-units (pu). However, users can choose to use volt-amperes reactive (VAr) as the units by applying the @power macro.

Example

Adding varmeters using exact values from the AC power flow:

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
power!(system, analysis)

device = measurement()

@varmeter(label = "Varmeter ?")
addVarmeter!(system, device, analysis; varianceFrom = 1e-3, statusBus = 0)
source
JuliaGrid.updateVarmeter!Function
updateVarmeter!(system::PowerSystem, device::Measurement, analysis::Analysis; kwargs...)

The function allows for the alteration of parameters for a varmeter.

Arguments

If the Analysis type is omitted, the function applies changes to the Measurement composite type only. However, when including the Analysis type, it updates both the Measurement and Analysis types. This streamlined process avoids the need to completely rebuild vectors and matrices when adjusting these parameters.

Keywords

To update a specific varmeter, provide the necessary kwargs input arguments in accordance with the keywords specified in the addVarmeter! function, along with their respective values. Ensure that the label keyword matches the label of the existing varmeter you want to modify. If any keywords are omitted, their corresponding values will remain unchanged.

Updates

The function updates the varmeter field within the Measurement composite type. Furthermore, it guarantees that any modifications to the parameters are transmitted to the Analysis type.

Units

Units for input parameters can be changed using the same method as described for the addVarmeter! function.

Example

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addVarmeter!(system, device; label = "Varmeter 1", from = "Branch 1", reactive = 1.1)
updateVarmeter!(system, device; label = "Varmeter 1", reactive = 1.2, variance = 1e-4)
source
JuliaGrid.statusVarmeter!Function
statusVarmeter!(system::PowerSystem, device::Measurement; inservice, inserviceBus,
    inserviceFrom, inserviceTo, outservice, outserviceBus outserviceFrom, outserviceTo,
    redundancy, redundancyBus, redundancyFrom, redundancyTo)

The function generates a set of varmeters, assigning varmeters randomly to either in-service or out-of-service states based on specified keywords.

Keywords

These keywords allow the user to configure the varmeter set as follows:

  • inservice: sets the number of in-service varmeters or allows fine-tuning:
    • inserviceBus: sets only varmeters loacted at the bus;
    • inserviceFrom: sets only varmeters loacted at the from-bus end;
    • inserviceTo: sets only varmeters loacted at the to-bus end;
  • outservice: sets the number of out-of-service varmeters or allows fine-tuning:
    • outserviceBus: sets only varmeters loacted at the bus;
    • outserviceFrom: sets only varmeters loacted at the from-bus end;
    • outserviceTo: sets only varmeters loacted at the to-bus end;
  • redundancy: determines in-service varmeters based on redundancy or allows fine-tuning:
    • redundancyBus: determines only varmeters loacted at the bus;
    • redundancyFrom: determines only varmeters loacted at the from-bus end;
    • redundancyTo: determines only varmeters loacted at the to-bus end.

In case a user employs multiple keywords from the set inservice, outservice, and redundancy, only the first keyword in the hierarchical order will be taken into consideration, and the remaining keywords will be ignored. Furthermore, in this scenario, all fine-tuning keywords will not be considered.

If a user chooses fine-tuning without specifying any of the primary keywords, only one keyword from each of the three sets will be executed, and the remaining keywords within each set will be ignored. These sets are as follows:

  • inserviceBus, outserviceBus, redundancyBus;
  • inserviceFrom, outserviceFrom, redundancyFrom;
  • inserviceTo, outserviceTo, redundancyTo.

Updates

The function updates the status field within the Varmeter type.

Examples

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
power!(system, analysis)

device = measurement()

addVarmeter!(system, device, analysis)
statusVarmeter!(system, device; inserviceFrom = 20)
source
JuliaGrid.@varmeterMacro
@varmeter(label, varinaceBus, varianceFrom, varianceTo, statusBus, statusFrom, statusTo,
    noise)

The macro generates a template for a varmeter, which can be utilized to define a varmeter using the addVarmeter! function.

Keywords

To establish the varmeter template, users can set default variance and status values for varmeters at buses using varianceBus and statusBus, and at both the from-bus and to-bus ends of branches using varianceFrom and statusFrom for the former and varianceTo and statusTo for the latter. Users can also configure label patterns with the label keyword, as well as specify the noise type.

Units

The default units for the varianceBus, varianceFrom, and varianceTo keywords are per-units (pu). However, users can choose to usevolt-amperes reactive (VAr) as the units by applying the @power macro.

Examples

Adding varmeters using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@varmeter(label = "Varmeter ?", varianceBus = 1e-3, varianceFrom = 1e-4)
addVarmeter!(system, device; bus = "Bus 2", reactive = 0.4)
addVarmeter!(system, device; from = "Branch 1", reactive = 0.1)

Adding varmeters using a custom unit system:

@power(MW, pu, pu)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1")
addBus!(system; label = "Bus 2")
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@varmeter(label = "Varmeter ?", varianceBus = 1e-1, varianceFrom = 1e-2)
addVarmeter!(system, device; bus = "Bus 2", reactive = 40.0)
addVarmeter!(system, device; from = "Branch 1", reactive = 10.0)
source

PMU

JuliaGrid.addPmu!Method
addPmu!(system::PowerSystem, device::Measurement; label, bus, from, to, magnitude,
    varianceMagnitude, statusMagnitude, angle, varianceAngle, statusAngle,
    noise, correlated, polar)

The function adds a new PMU to the Measurement composite type within a given PowerSystem type. The PMU can be added to an already defined bus or branch. When defining the PMU, it is essential to provide the bus voltage magnitude and angle if the PMU is located at a bus or the branch current magnitude and angle if the PMU is located at a branch.

Keywords

The PMU is defined with the following keywords:

  • label: a unique label for the PMU;
  • bus: the label of the bus if the PMU is located at the bus;
  • from: the label of the branch if the PMU is located at the from-bus end;
  • to: the label of the branch if the PMU is located at the to-bus end;
  • magnitude (pu or V, A): the bus voltage or branch current magnitude value;
  • varianceMagnitude (pu or V, A): the magnitude measurement variance;
  • statusMagnitude: the operating status of PMU magnitude measurement:
    • statusMagnitude = 1: in-service;
    • statusMagnitude = 0: out-of-service;
  • angle (rad or deg): the bus voltage or branch current angle value;
  • varianceAngle (rad or deg): the angle measurement variance;
  • statusAngle: the operating status of PMU angle measurement:
    • statusAngle = 1: in-service;
    • statusAngle = 0: out-of-service;
  • noise: specifies how to generate the measurement means:
    • noise = true: adds white Gaussian noises with variances to the magnitude and angle;
    • noise = false: uses the magnitude and angle values only;
  • correlated: specifies error correlation for PMUs for algorithms utilizing rectangular coordinates:
    • correlated = true: considers correlated errors;
    • correlated = false: disregards correlations between errors;
  • polar: chooses the coordinate system for including phasor measurements in AC state estimation:
    • polar = true: adopts the polar coordinate system;
    • polar = false: adopts the rectangular coordinate system.

Updates

The function updates the pmu field of the Measurement composite type.

Default Settings

Default settings for certain keywords are as follows: varianceMagnitude = 1e-5, statusMagnitude = 1, varianceAngle = 1e-5, statusAngle = 1, noise = false, correlated = false, and polar = false, which apply to PMUs located at the bus, as well as at both the from-bus and to-bus ends. Users can fine-tune these settings by explicitly specifying the variance and status for PMUs positioned at the buses, from-bus ends, or to-bus ends of branches using the @pmu macro.

Units

The default units for the magnitude, varianceMagnitude, and angle, varianceAngle keywords are per-units (pu) and radians (rad). However, users have the option to switch to volts (V) and degrees (deg) when the PMU is located at a bus using the @voltage macro, or amperes (A) and degrees (deg) when the PMU is located at a branch through the use of the @current macro.

Examples

Adding PMUs using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addPmu!(system, device; label = "PMU 1", bus = "Bus 1", magnitude = 1.1, angle = -0.1)
addPmu!(system, device; label = "PMU 2", from = "Branch 1", magnitude = 1.1, angle = 0.1)

Adding PMUs using a custom unit system:

@voltage(kV, deg, kV)
@current(A, deg)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132.0)
addBus!(system; label = "Bus 2", base = 132.0)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

addPmu!(system, device; label = "PMU 1", bus = "Bus 1", magnitude = 145.2, angle = -5.7)
addPmu!(system, device; label = "PMU 2", from = "Branch 1", magnitude = 481.1, angle = 5.7)
source
JuliaGrid.addPmu!Method
addPmu!(system::PowerSystem, device::Measurement, analysis::AC;
    varianceMagnitudeBus, statusMagnitudeBus, varianceAngleBus, statusAngleBus,
    varianceMagnitudeFrom, statusMagnitudeFrom, varianceAngleFrom, statusAngleFrom,
    varianceMagnitudeTo, statusMagnitudeTo, varianceAngleTo, statusAngleTo,
    correlated, polar, noise)

The function incorporates PMUs into the Measurement composite type for every bus and branch within the PowerSystem type. These measurements are derived from the exact bus voltage magnitudes and angles, as well as branch current magnitudes and angles defined in the AC abstract type. These exact values are then perturbed by white Gaussian noise with the specified varianceMagnitude and varianceAngle to obtain measurement data.

Keywords

Users have the option to configure the following keywords:

  • varianceMagnitudeBus (pu or V): variance of PMU magnitude measurements at buses;
  • statusMagnitudeBus: the operating status of PMU magnitude measurements at buses:
    • statusMagnitudeBus = 1: in-service;
    • statusMagnitudeBus = 0: out-of-service;
  • varianceAngleBus (rad or deg): variance of PMU angle measurements at buses;
  • statusAngleBus: the operating status of PMU agle measurements at buses:
    • statusAngleBus = 1: in-service;
    • statusAngleBus = 0: out-of-service;
  • varianceMagnitudeFrom (pu or A): variance of PMU magnitude measurements at the from-bus ends;
  • statusMagnitudeFrom: the operating status of PMU magnitude measurements at the from-bus ends:
    • statusMagnitudeFrom = 1: in-service;
    • statusMagnitudeFrom = 0: out-of-service;
  • varianceAngleFrom (rad or deg): variance of PMU angle measurements at the from-bus ends;
  • statusAngleFrom: the operating status of PMU angle measurements at the from-bus ends:
    • statusAngleFrom = 1: in-service;
    • statusAngleFrom = 0: out-of-service;
  • varianceMagnitudeTo (pu or A): variance of PMU magnitude measurements at the to-bus ends;
  • statusMagnitudeTo: the operating status of PMU magnitude measurements at the to-bus ends:
    • statusMagnitudeTo = 1: in-service;
    • statusMagnitudeTo = 0: out-of-service;
  • varianceAngleTo (rad or deg): variance of PMU angle measurements at the to-bus ends;
  • statusAngleTo: the operating status of PMU angle measurements at the to-bus ends:
    • statusAngleTo = 1: in-service;
    • statusAngleTo = 0: out-of-service;
  • correlated: specifies error correlation for PMUs for algorithms utilizing rectangular coordinates:
    • correlated = true: considers correlated errors;
    • correlated = false: disregards correlations between errors;
  • polar: chooses the coordinate system for including phasor measurements in AC state estimation:
    • polar = true: adopts the polar coordinate system;
    • polar = false: adopts the rectangular coordinate system;
  • noise: specifies how to generate the measurement mean:
    • noise = true: adds white Gaussian noise with the variance to the magnitudes and angles;
    • noise = false: uses the magnitude value only.

Updates

The function updates the pmu field of the Measurement composite type.

Default Settings

Default settings for variance keywords are established at 1e-5, with all statuses set to 1, polar = false, correlated = false, and noise = false. Users can change these default settings using the @pmu macro.

Units

The default units for the variance keywords are in per-units (pu) and radians (rad). However, users have the option to switch to volts (V) and degrees (deg) when the PMU is located at a bus using the @voltage macro, or amperes (A) and degrees (deg) when the PMU is located at a branch through the use of the @current macro.

Example

Adding PMUs using exact values from the AC power flow:

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
current!(system, analysis)

device = measurement()

@pmu(label = "PMU ?")
addPmu!(system, device, analysis; varianceMagnitudeBus = 1e-3)
source
JuliaGrid.updatePmu!Function
updatePmu!(system::PowerSystem, device::Measurement, analysis::Analysis; kwargs...)

The function allows for the alteration of parameters for a PMU.

Arguments

If the Analysis type is omitted, the function applies changes to the Measurement composite type only. However, when including the Analysis type, it updates both the Measurement and Analysis types. This streamlined process avoids the need to completely rebuild vectors and matrices when adjusting these parameters.

Keywords

To update a specific PMU, provide the necessary kwargs input arguments in accordance with the keywords specified in the addPmu! function, along with their respective values. Ensure that the label keyword matches the label of the existing PMU you want to modify. If any keywords are omitted, their corresponding values will remain unchanged.

Updates

The function updates the pmu field within the Measurement composite type. Furthermore, it guarantees that any modifications to the parameters are transmitted to the Analysis type.

Units

Units for input parameters can be changed using the same method as described for the addPmu! function.

Example

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)

addPmu!(system, device; label = "PMU 1", bus = "Bus 1", magnitude = 1.1, angle = -0.1)
updatePmu!(system, device; label = "PMU 1", magnitude = 1.05)
source
JuliaGrid.statusPmu!Function
statusPmu!(system::PowerSystem, device::Measurement; inservice, inserviceBus,
    inserviceFrom, inserviceTo, outservice, outserviceBus outserviceFrom, outserviceTo,
    redundancy, redundancyBus, redundancyFrom, redundancyTo)

The function generates a set of PMUs, assigning PMUs randomly to either in-service or out-of-service states based on specified keywords. It is important to note that when we refer to PMU, we encompass both magnitude and angle measurements.

Keywords

These keywords allow the user to configure the PMU set as follows:

  • inservice: sets the number of in-service PMUs or allows fine-tuning:
    • inserviceBus: sets only PMUs loacted at the bus;
    • inserviceFrom: sets only PMUs loacted at the from-bus end;
    • inserviceTo: sets only PMUs loacted at the to-bus end;
  • outservice: sets the number of out-of-service PMUs or allows fine-tuning:
    • outserviceBus: sets only PMUs loacted at the bus;
    • outserviceFrom: sets only PMUs loacted at the from-bus end;
    • outserviceTo: sets only PMUs loacted at the to-bus end;
  • redundancy: determines in-service PMUs based on redundancy or allows fine-tuning:
    • redundancyBus: determines only PMUs loacted at the bus;
    • redundancyFrom: determines only PMUs loacted at the from-bus end;
    • redundancyTo: determines only PMUs loacted at the to-bus end.

In case a user employs multiple keywords from the set inservice, outservice, and redundancy, only the first keyword in the hierarchical order will be taken into consideration, and the remaining keywords will be ignored. Furthermore, in this scenario, all fine-tuning keywords will not be considered.

If a user chooses fine-tuning without specifying any of the primary keywords, only one keyword from each of the three sets will be executed, and the remaining keywords within each set will be ignored. These sets are as follows:

  • inserviceBus, outserviceBus, redundancyBus;
  • inserviceFrom, outserviceFrom, redundancyFrom;
  • inserviceTo, outserviceTo, redundancyTo.

Updates

The function updates the status fields within the PMU type.

Examples

system = powerSystem("case14.h5")
acModel!(system)

analysis = newtonRaphson(system)
for i = 1:10
    stopping = mismatch!(system, analysis)
    if all(stopping .< 1e-8)
        break
    end
    solve!(system, analysis)
end
current!(system, analysis)

device = measurement()

addPmu!(system, device, analysis)
statusPmu!(system, device; inserviceBus = 14)
source
JuliaGrid.@pmuMacro
@pmu(label, varianceMagnitudeBus, statusMagnitudeBus, varianceAngleBus, statusAngleBus,
    varianceMagnitudeFrom, statusMagnitudeFrom, varianceAngleFrom, statusAngleFrom,
    varianceMagnitudeTo, statusMagnitudeTo, varianceAngleTo, statusAngleTo, noise,
    correlated, polar)

The macro generates a template for a PMU, which can be utilized to define a PMU using the addPmu! function.

Keywords

To establish the PMU template, users have the option to set default values for magnitude and angle variances, as well as statuses for each component of the phasor. This can be done for PMUs located at the buses using the varianceMagnitudeBus, varianceAngleBus, statusMagnitudeBus, and statusAngleBus keywords.

The same configuration can be applied at both the from-bus ends of the branches using the varianceMagnitudeFrom, varianceAngleFrom, statusMagnitudeFrom, and statusAngleFrom keywords.

For PMUs located at the to-bus ends of the branches, users can use the varianceMagnitudeTo, varianceAngleTo, statusMagnitudeTo, and statusAngleTo keywords.

Additionally, users can configure the pattern for labels using the label keyword, specify the type of noise, and indicate the correlated and polar system utilized for managing phasors during state estimation.

Units

By default, the units for variances are per-units (pu) and radians (rad). However, users have the option to switch to volts (V) and degrees (deg) as the units for PMUs located at the buses by using the @voltage macro, or they can switch to amperes (A) and degrees (deg) as the units for PMUs located at the branches by using the @current macro.

Examples

Adding PMUs using the default unit system:

system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132e3)
addBus!(system; label = "Bus 2", base = 132e3)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@pmu(label = "PMU ?", varianceAngleBus = 1e-6, varianceMagnitudeFrom = 1e-4)
addPmu!(system, device; bus = "Bus 1", magnitude = 1.1, angle = -0.1)
addPmu!(system, device; from = "Branch 1", magnitude = 1.1, angle = -0.2)

Adding PMUs using a custom unit system:

@voltage(kV, deg, kV)
@current(A, deg)
system = powerSystem()
device = measurement()

addBus!(system; label = "Bus 1", base = 132.0)
addBus!(system; label = "Bus 2", base = 132.0)
addBranch!(system; label = "Branch 1", from = "Bus 1", to = "Bus 2", reactance = 0.2)

@pmu(label = "PMU ?", varianceAngleBus = 5.73e-5, varianceMagnitudeFrom = 0.0481)
addPmu!(system, device; bus = "Bus 1", magnitude = 145.2, angle = -5.73)
addPmu!(system, device; from = "Branch 1", magnitude = 481.125, angle = -11.46)
source