# Power Module

The power module contains a set of functions to calculate quantities of interest for power production and power quality.

Note

The names of the functions below are of the convention `path.path.function`. Only the function name is used when calling the function in MATLAB. For example, to call on `mhkit.wave.io.read_NDBC_file` simply use `read_NDBC_file`.

## Characteristics

The characteristics submodule calculates power quantities of interest from voltage and current timseries.

Functions

Description

`instantaneous_frequency`

Calculates instantaneous frequency of measured voltage

`dc_power`

Calculates the real power from DC voltage and current.

`ac_power_three_phase`

Calculates the real power from three phase ac voltage and current.

mhkit.power.characteristics.ac_power_three_phase(voltage, current, power_factor, varargin)

Calculates the real power from three phase ac voltage and current.

Parameters
• voltage (`Time series of all three measured voltages [V]`) –

Pandas data frame

To make a pandas data frame from user supplied frequency and spectra use py.mhkit_python_utils.pandas_dataframe.spectra_to_pandas(time,voltage)

OR

structure of form:

voltage.voltage : matrix of all three phases

voltage.time : time vector

• current (`Time series of all three measured current [A]`) –

Pandas data frame

To make a pandas data frame from user supplied frequency and spectra use py.mhkit_python_utils.pandas_dataframe.spectra_to_pandas(time,current)

OR

structure of form:

current.current : matrix of all three phases

current.time : time vector

power_factorfloat

power factor for the system

line_to_line: bool (Optional)

set true if the given voltage measuremtn is line_to_line

Returns

P (Structure)

P.power [W]

P.time

mhkit.power.characteristics.dc_power(voltage, current)

Calculates the real power from DC voltage and current.

Parameters
• voltage (`Time series of  measured voltages [V]`) –

Pandas data frame

To make a pandas data frame from user supplied frequency and spectra use py.mhkit_python_utils.pandas_dataframe.spectra_to_pandas(time,voltage)

OR

structure of form:

voltage.voltage : matrix or vector

voltage.time : time vector

• current (`Time series of current [A]`) –

Pandas data frame

To make a pandas data frame from user supplied frequency and spectra use py.mhkit_python_utils.pandas_dataframe.spectra_to_pandas(time,current)

OR

structure of form:

current.current : matrix or vector

current.time : time vector

Returns

P (Structure)

P.power [W]

P.gross: gross power from all lines [W]

P.time

mhkit.power.characteristics.instantaneous_frequency(voltage)

Calcultes the instantaneous frequency of a measured voltage

Parameters

um (`structure with handles- um.voltage and um.time`) – measured voltage source (V) with each timeseries in its own column

Returns

frequency (structure) – frequency of the measured voltage with handles frequency.time and frequency.frequency

## Quality

The quality submodule functions assess power quality, including harmonics, interharmonics, and distortion. Calculations are based on IEC TS 62600-30:2018 ED1 and IEC TS 61000-4-7:2008 ED2.

Functions

Description

`harmonics`

Calculates the harmonics from time series of voltage or current based on IEC 61000-4-7.

`harmonic_subgroups`

Calculates the harmonic subgroups based on IEC 61000-4-7

`total_harmonic_current_distortion`

Calculates the total harmonic current distortion (THC) based on IEC/TS 62600-30

`interharmonics`

Calculates the interharmonics from the harmonics of current

mhkit.power.quality.harmonics(x, freq, grid_freq)

Calculates the harmonics from time series of voltage or current based on IEC 61000-4-7.

Parameters
• x (`structure with x.time and x.current or x.voltage as values`) – Time-series of voltage [V] or current [A]

• freq (`double`) – Frequency of the time-series data [Hz]

• grid_freq (`int`) – Value indicating if the power supply is 50 or 60 Hz. Options = 50 or 60

Returns

harmonics (structure) – harmonic amplitude and frequency of the time-series data

mhkit.power.quality.total_harmonic_current_distortion(harmonic_subgroups, rated_current)

Calculates the total harmonic current distortion (THC) based on IEC/TS 62600-30

Parameters
• harmonic_subgroups (`structure with handles- harmonic_subgroups.amplitude and harmonic_subgroups.harmonic`) – Subgrouped current harmonics amplitude indexed by harmonic order

• rated_current (`double`) – Rated current of the energy device in Amps

Returns

THCD (double) – Total harmonic current distortion

mhkit.power.quality.harmonic_subgroups(harmonics, grid_freq)

Calculates the harmonic subgroups from the harmonics of current

Parameters
• harmonics (`structure with handles- harmonics.amplitude and harmonics.harmonic`) – harmonic amplitude with each timeseries in its own column

• grid_freq (`int`) – value indicating if the power supply is 50 or 60 Hz. Valid input are 50 and 60

Returns

harmonic_subgroups (structure with handles harmonic_subgroups.amplitude and) – harmonic_subgroups.harmonic

mhkit.power.quality.interharmonics(harmonics, grid_freq)

Calculates the interharmonics from the harmonics of current based on IEC 61000-4-7.

Parameters
• harmonics (`structure with handles- harmonics.amplitude and harmonics.harmonic`) – Harmonic amplitude with each timeseries in its own column

• grid_freq (`int`) – Value indicating if the power supply is 50 or 60 Hz. Options = 50 or 60

Returns

interharmonics (structure with handles interharmonics.amplitude and) – interharmonics.harmonic