Example: MHKiT-MATLAB Power Module
This example will demonstrate the MHKiT Power Module functionality to compute power, instantaneous frequency, and harmonics from time series of voltage and current. Load Power Data
We will begin by reading in timeseries data of measured three phase (a,b,and,c) voltage and current. The IEC TS 62600-30 requires that you perform power quality assessments on a minimum of 10-min timeseries data, but for this example we will only look at a fraction of that.
% Read in timeseries data of voltage (V) and current (I)
power_table = readtable('../examples/data/power/2020224_181521_PowRaw.csv');
power_table
power_table = 8000×7 table
| Time_UTC | MODAQ_Va_V | MODAQ_Vb_V | MODAQ_Vc_V | MODAQ_Ia_I | MODAQ_Ib_I | MODAQ_Ic_I |
---|
1 | 2020-02-24 18:15:21.499 | 1.0653e+04 | -8.4994e+03 | -1.8502e+03 | -23.2137 | 19.2197 | 4.0234 |
---|
2 | 2020-02-24 18:15:21.500 | 1.0691e+04 | -8.4287e+03 | -1.9276e+03 | -23.4048 | 19.1817 | 4.2899 |
---|
3 | 2020-02-24 18:15:21.500 | 1.0733e+04 | -8.3650e+03 | -2.0013e+03 | -23.4930 | 19.0340 | 4.4789 |
---|
4 | 2020-02-24 18:15:21.500 | 1.0776e+04 | -8.3046e+03 | -2.0712e+03 | -23.6801 | 18.9178 | 4.8582 |
---|
5 | 2020-02-24 18:15:21.500 | 1.0818e+04 | -8.2481e+03 | -2.1380e+03 | -23.7379 | 18.7021 | 5.0925 |
---|
6 | 2020-02-24 18:15:21.500 | 1.0865e+04 | -8.2000e+03 | -2.2037e+03 | -23.8255 | 18.5588 | 5.3690 |
---|
7 | 2020-02-24 18:15:21.500 | 1.0912e+04 | -8.1529e+03 | -2.2702e+03 | -23.9285 | 18.4013 | 5.5463 |
---|
8 | 2020-02-24 18:15:21.500 | 1.0957e+04 | -8.1069e+03 | -2.3400e+03 | -24.0253 | 18.1902 | 5.9492 |
---|
9 | 2020-02-24 18:15:21.500 | 1.1005e+04 | -8.0655e+03 | -2.4124e+03 | -24.1026 | 17.9961 | 6.1678 |
---|
10 | 2020-02-24 18:15:21.500 | 1.1046e+04 | -8.0207e+03 | -2.4863e+03 | -24.1380 | 17.7797 | 6.3429 |
---|
11 | 2020-02-24 18:15:21.500 | 1.1086e+04 | -7.9779e+03 | -2.5630e+03 | -24.2041 | 17.5941 | 6.6670 |
---|
12 | 2020-02-24 18:15:21.500 | 1.1124e+04 | -7.9373e+03 | -2.6405e+03 | -24.2233 | 17.4030 | 6.9188 |
---|
13 | 2020-02-24 18:15:21.500 | 1.1158e+04 | -7.8944e+03 | -2.7206e+03 | -24.3034 | 17.1805 | 7.1620 |
---|
14 | 2020-02-24 18:15:21.500 | 1.1190e+04 | -7.8541e+03 | -2.8018e+03 | -24.3639 | 16.9292 | 7.4295 |
---|
⋮ |
---|
To use the MHKiT-MATLAB power module we need to create structures of current and voltage.
current.time = posixtime(power_table.Time_UTC); %setting time in current structure
voltage.time = posixtime(power_table.Time_UTC); %setting time in voltage structure
T2 = mergevars(power_table,[2 3 4]); %combining the voltage time series into one table variable
T3 = mergevars(T2,[3 4 5]); %combining the current time series into one table variable
current.current = T3.Var3;
voltage.voltage = T3.Var2;
Power Characteristics
The MHKiT power characteristics submodule can be used to compute basic quantities of interest from voltage and current time series. In this example we will calculate active AC power and instantaneous frequency, using the loaded voltage and current timeseries.
To compute the active AC power, we will need the power factor. Power factor describes the efficiency of the energy device.
% Set the power factor for the system
% Compute the instantaneous AC power in watts
ac_power = ac_power_three_phase(voltage, current, power_factor);
plot(ac_power.time,ac_power.power);
Instantaneous Frequency
Using the 3 phase voltage measurements we can compute the instantaneous frequency of the voltage timeseries. The time-varying instantaneous frequency is a required metric for power quality assessments.
inst_freq = instantaneous_frequency(voltage)
inst_freq =
frequency: [7999×3 double]
time: [7999×1 double]
plot(inst_freq.time,inst_freq.frequency);
title('Instantaneous Frequency')
Power Quality
The power quality submodule can be used to compute harmonics of current and voltage and current distortions following IEC TS 62600-30 and IEC 61000-4-7. Harmonics and harmonic distortion are required as part of a power quality assessment and characterize the stability of the power being produced.
% Set the sampling frequency of the dataset
sample_freq = 50000 %[Hz]
% Set the frequency of the grid the device would be connected to
% Set the rated current of the device
rated_current = 18.8 % [Amps]
% Calculate the current harmonics
h = harmonics(current, sample_freq, grid_freq);
plot(h.harmonic,h.amplitude);
title('Current Harmonics')
ylabel('Harmonic Amplitude')
Harmonic Subgroups
The harmonic subgroups calculations are based on IEC TS 62600-30. We can calculate them using our grid frequency and harmonics.
% Calculate Harmonic Subgroups
h_s = harmonic_subgroups(h,grid_freq)
Total Harmonic Current Distortion
Compute the THCD from harmonic subgroups and rated current for the device.
% Finally we can compute the total harmonic current distortion as a percentage
THCD = total_harmonic_current_distortion(h_s,rated_current)