Harmony
HARMONic stabilitY assessment of PE-penetrated power systems
Loading...
Searching...
No Matches
DQsym_Conversion_Functions.h File Reference

Dynamic-phasor arithmetic and abc ↔ dqn domain conversions. More...

#include "../../Constants.h"
Include dependency graph for DQsym_Conversion_Functions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ABCResult
 Time-domain abc waveform reconstructed from dqn coefficients. More...
 

Functions

MatrixXcd dq_add (const MatrixXcd &a, const MatrixXcd &b)
 Element-wise addition of two dynamic-phasor coefficient matrices.
 
MatrixXcd dq_subtract (const MatrixXcd &a, const MatrixXcd &b)
 Element-wise subtraction of two dynamic-phasor coefficient matrices.
 
MatrixXcd dq_integrate (MatrixXcd &Zpnz_old, MatrixXcd &Xpnz_old, const MatrixXcd &Xpnz, double dt, double w)
 Integrates a dynamic-phasor signal over one time step.
 
MatrixXcd dq_multiply (const MatrixXcd &x_coef1_in, const MatrixXcd &y_coef1_in)
 Multiplies two dynamic-phasor coefficient matrices (convolution in harmonic domain).
 
void convertToPhasor (const MatrixXcd &A, const MatrixXcd &B, const MatrixXcd &C, const MatrixXcd &D, MatrixXcd &Adc, MatrixXcd &Bdc, MatrixXcd &Cdc, MatrixXcd &Ddc)
 Converts abc-stacked state-space matrices to phasor/sequence domain.
 
MatrixXcd truncateHarmonics (const MatrixXcd &X, int nColsToKeep)
 Truncates harmonic columns beyond nKeep in a coefficient matrix.
 
Vector3d dqn2abc_at_time (const MatrixXcd &Xdcpnz_c, double theta)
 Reconstructs abc phase values from a 3×H dqn block at one angle.
 
std::vector< Vector3d > dqn2abc_groups_at_time (const MatrixXcd &Y, double theta)
 Reconstructs abc values for all 3-row output groups at one angle.
 
ABCResult simulate_dqn2abc (const MatrixXcd &Xdcpnz_c, double freq_hz, double t0, double t1, double Ts)
 Simulates abc waveform reconstruction over a time interval.
 

Detailed Description

Dynamic-phasor arithmetic and abc ↔ dqn domain conversions.

Provides element-wise phasor operations, harmonic truncation, and reconstruction of three-phase abc waveforms from dqn coefficient blocks used by the DQsym solver.

Function Documentation

◆ convertToPhasor()

void convertToPhasor ( const MatrixXcd &  A,
const MatrixXcd &  B,
const MatrixXcd &  C,
const MatrixXcd &  D,
MatrixXcd &  Adc,
MatrixXcd &  Bdc,
MatrixXcd &  Cdc,
MatrixXcd &  Ddc 
)
extern

Converts abc-stacked state-space matrices to phasor/sequence domain.

Parameters
AContinuous-time state matrix (abc layout).
BContinuous-time input matrix (abc layout).
CContinuous-time output matrix (abc layout).
DContinuous-time feed-through matrix (abc layout).
AdcOutput: phasor-domain state matrix.
BdcOutput: phasor-domain input matrix.
CdcOutput: phasor-domain output matrix.
DdcOutput: phasor-domain feed-through matrix.

Converts abc-stacked state-space matrices to phasor/sequence domain.

References j.

Referenced by DQsym::DSSS().

◆ dq_add()

MatrixXcd dq_add ( const MatrixXcd &  a,
const MatrixXcd &  b 
)
extern

Element-wise addition of two dynamic-phasor coefficient matrices.

Parameters
aFirst operand.
bSecond operand.
Returns
a + b in the phasor domain.

Element-wise addition of two dynamic-phasor coefficient matrices.

This function computes the sum of two matrices, a and b. If the matrices have different dimensions, the result matrix is sized to encompass both, effectively zero-padding the smaller matrix before addition.

Parameters
aThe first matrix operand.
bThe second matrix operand.
Returns
A new matrix representing the sum of a and b.

Referenced by example_DQsym_math_operations().

◆ dq_integrate()

MatrixXcd dq_integrate ( MatrixXcd &  Zpnz_old,
MatrixXcd &  Xpnz_old,
const MatrixXcd &  Xpnz,
double  dt,
double  w 
)
extern

Integrates a dynamic-phasor signal over one time step.

Parameters
Zpnz_oldPrevious integrated state (updated in place).
Xpnz_oldPrevious input sample (updated in place).
XpnzCurrent input sample.
dtTime step (s).
wAngular frequency (rad/s).
Returns
Integrated phasor coefficients.

Integrates a dynamic-phasor signal over one time step.

Referenced by example_DQsym_math_operations().

◆ dq_multiply()

MatrixXcd dq_multiply ( const MatrixXcd &  x_coef1_in,
const MatrixXcd &  y_coef1_in 
)
extern

Multiplies two dynamic-phasor coefficient matrices (convolution in harmonic domain).

Parameters
x_coef1_inFirst operand coefficients.
y_coef1_inSecond operand coefficients.
Returns
Product coefficients.

Multiplies two dynamic-phasor coefficient matrices (convolution in harmonic domain).

C++ translation aligned with MATLAB: Zdcpnz_c = SICO_DPs_3ph(x_coef1, y_coef1, N)

Input convention:

  • 3 rows = abc phases
  • column 0 = DC term
  • column k = harmonic k

Output:

  • 3 x (2N+1) matrix in abc basis, where N = max(input harmonic order)

References s, and sgn().

Referenced by example_DQsym_math_operations(), and MMC::simulateInputStep().

◆ dq_subtract()

MatrixXcd dq_subtract ( const MatrixXcd &  a,
const MatrixXcd &  b 
)
extern

Element-wise subtraction of two dynamic-phasor coefficient matrices.

Parameters
aMinuend.
bSubtrahend.
Returns
a - b in the phasor domain.

Element-wise subtraction of two dynamic-phasor coefficient matrices.

This function computes the difference of two matrices, a - b. If the matrices have different dimensions, the result matrix is sized to encompass both, effectively zero-padding the smaller matrix before subtraction.

Parameters
aThe matrix to subtract from (minuend).
bThe matrix to subtract (subtrahend).
Returns
A new matrix representing the difference a - b.

Referenced by example_DQsym_math_operations().

◆ dqn2abc_at_time()

Vector3d dqn2abc_at_time ( const MatrixXcd &  Xdcpnz_c,
double  theta 
)
extern

Reconstructs abc phase values from a 3×H dqn block at one angle.

Parameters
Xdcpnz_cdqn coefficient block (3 rows).
thetaElectrical angle (rad) at which to evaluate.
Returns
Three-phase abc vector [a, b, c].

Reconstructs abc phase values from a 3×H dqn block at one angle.

Input format:

  • rows = 3 : positive, negative, zero sequence
  • cols = harmonic orders, where col(0) is DC and col(h) is harmonic h
Parameters
Xdcpnz_c3 x Nh complex coefficient matrix
thetaelectrical angle [rad]
Returns
Vector3d instantaneous abc values at theta

Referenced by dqn2abc_groups_at_time(), and simulate_dqn2abc().

◆ dqn2abc_groups_at_time()

std::vector< Vector3d > dqn2abc_groups_at_time ( const MatrixXcd &  Y,
double  theta 
)
extern

Reconstructs abc values for all 3-row output groups at one angle.

Parameters
YOutput coefficient matrix with rows grouped in triplets.
thetaElectrical angle (rad) at which to evaluate.
Returns
One abc vector per output group.

Reconstructs abc values for all 3-row output groups at one angle.

Y is expected to have rows grouped as:

  • rows 0..2 : group 1
  • rows 3..5 : group 2
  • rows 6..8 : group 3
  • ...

Each 3-row group is interpreted as a 3xH dynamic-phasor sequence matrix and converted to one instantaneous abc vector at the supplied angle theta.

Parameters
YA matrix with row count equal to 3 * number_of_groups.
thetaElectrical angle [rad] at this one instant in time.
Returns
A vector of abc instantaneous vectors, one per 3-row group.

References dqn2abc_at_time().

Referenced by example_DQsym_DSSS2(), example_DQsym_RLC(), and DQsym::run().

◆ simulate_dqn2abc()

ABCResult simulate_dqn2abc ( const MatrixXcd &  Xdcpnz_c,
double  freq_hz,
double  t0,
double  t1,
double  Ts 
)
extern

Simulates abc waveform reconstruction over a time interval.

Parameters
Xdcpnz_cdqn coefficient block (3 rows × H columns).
freq_hzFundamental frequency in Hz.
t0Start time (s).
t1End time (s).
TsSample period (s).
Returns
Time vector and abc waveform matrix.

Simulates abc waveform reconstruction over a time interval.

Parameters
Xdcpnz_c3 x Nh complex coefficient matrix
freq_hzbase electrical frequency [Hz]
t0start time [s]
t1end time [s]
Tssample time [s]
Returns
ABCResult containing time vector and Nx3 abc waveform matrix

References dqn2abc_at_time(), ABCResult::t, and ABCResult::Xabc.

Referenced by example_DQsym_math_operations().

◆ truncateHarmonics()

MatrixXcd truncateHarmonics ( const MatrixXcd &  X,
int  nColsToKeep 
)
extern

Truncates harmonic columns beyond nKeep in a coefficient matrix.

Parameters
XInput coefficient matrix (3 rows × H columns).
nColsToKeepNumber of harmonic columns to retain.
Returns
Truncated matrix.

Referenced by MMC::simulateInputStep().