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 timseries 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');
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;
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 instantneous frequency, using the loaded voltage and current timeseries.
To compute the active AC power, we will need the power factor. Power factor describes the efficency 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);
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)
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 conected to
% Set the rated current of the device
rated_current = 18.8 % [Amps]
% Calculate the current harmonics
h = harmonics(current, sample_freq, grid_freq);
The harmonic subgroups calculations are based on IEC TS 62600-30. We can clculate them using our grid frequency and harmonics.
% Calcualte 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)