11 #include <dpsim-models/Definitions.h>
17 typedef Real (*DeriveFnPtr)(Matrix inputs);
20 static Real radtoDeg(Real rad);
22 static Real degToRad(Real deg);
24 static Real phase(Complex value);
26 static Real phaseDeg(Complex value);
28 static Real abs(Complex value);
30 static Matrix abs(
const MatrixComp &mat);
32 static Matrix phase(
const MatrixComp &mat);
34 static Complex polar(Real abs, Real phase);
35 static Complex polarDeg(Real abs, Real phase);
44 static void setVectorElement(Matrix &mat, Matrix::Index row, Complex value,
45 Int maxFreq = 1, Int freqIdx = 0,
46 Matrix::Index colOffset = 0);
48 static void addToVectorElement(Matrix &mat, Matrix::Index row, Complex value,
49 Int maxFreq = 1, Int freqIdx = 0);
51 static Complex complexFromVectorElement(
const Matrix &mat, Matrix::Index row,
52 Int maxFreq = 1, Int freqIdx = 0);
54 static void addToVectorElement(Matrix &mat, Matrix::Index row, Real value);
55 static void setVectorElement(Matrix &mat, Matrix::Index row, Real value);
57 static Real realFromVectorElement(
const Matrix &mat, Matrix::Index row);
65 static void setMatrixElement(SparseMatrixRow &mat, Matrix::Index row,
66 Matrix::Index column, Complex value,
67 Int maxFreq = 1, Int freqIdx = 0);
69 static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row,
70 Matrix::Index column, Complex value,
71 Int maxFreq = 1, Int freqIdx = 0);
73 static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row,
74 Matrix::Index column, Matrix value,
75 Int maxFreq = 1, Int freqIdx = 0);
77 static void setMatrixElement(SparseMatrixRow &mat, Matrix::Index row,
78 Matrix::Index column, Real value);
80 static void addToMatrixElement(SparseMatrixRow &mat, std::vector<UInt> rows,
81 std::vector<UInt> columns, Complex value);
83 static void addToMatrixElement(SparseMatrixRow &mat, Matrix::Index row,
84 Matrix::Index column, Real value);
85 static void addToMatrixElement(SparseMatrixRow &mat, std::vector<UInt> rows,
86 std::vector<UInt> columns, Real value);
88 static void invertMatrix(
const Matrix &mat, Matrix &matInv);
91 static Matrix StateSpaceTrapezoidal(Matrix states, Matrix A, Matrix B,
92 Real dt, Matrix u_new, Matrix u_old);
93 static Matrix StateSpaceTrapezoidal(Matrix states, Matrix A, Matrix B,
94 Matrix C, Real dt, Matrix u_new,
96 static Matrix StateSpaceTrapezoidal(Matrix states, Matrix A, Matrix B,
98 static Matrix StateSpaceTrapezoidal(Matrix states, Matrix A, Matrix B,
99 Matrix C, Real dt, Matrix u);
100 static Matrix StateSpaceTrapezoidal(Matrix states, Matrix A, Matrix input,
102 static Real StateSpaceTrapezoidal(Real states, Real A, Real B, Real C,
104 static Real StateSpaceTrapezoidal(Real states, Real A, Real B, Real dt,
107 static Matrix StateSpaceEuler(Matrix states, Matrix A, Matrix B, Real dt,
109 static Matrix StateSpaceEuler(Matrix states, Matrix A, Matrix B, Matrix C,
111 static Matrix StateSpaceEuler(Matrix states, Matrix A, Matrix input, Real dt);
112 static Real StateSpaceEuler(Real states, Real A, Real B, Real dt, Real u);
113 static Real StateSpaceEuler(Real states, Real A, Real B, Real C, Real dt,
120 const Real &dt, Matrix &Ad,
121 Matrix &Bd, Matrix &Cd);
126 const Matrix &statesPrevStep,
127 const Matrix &inputCurrStep,
128 const Matrix &inputPrevStep);
130 static void FFT(std::vector<Complex> &samples);
132 static Complex rotatingFrame2to1(Complex f2, Real theta1, Real theta2);
static Matrix singlePhasePowerToThreePhase(Real power)
To convert single phase power to symmetrical three phase.
static void calculateStateSpaceTrapezoidalMatrices(const Matrix &A, const Matrix &B, const Matrix &C, const Real &dt, Matrix &Ad, Matrix &Bd, Matrix &Cd)
Calculate the discretized state space matrices Ad, Bd, Cd using trapezoidal rule.
static Matrix applyStateSpaceTrapezoidalMatrices(const Matrix &Ad, const Matrix &Bd, const Matrix &Cd, const Matrix &statesPrevStep, const Matrix &inputCurrStep, const Matrix &inputPrevStep)
Apply the trapezoidal based state space matrices Ad, Bd, Cd to get the states at the current time ste...
static Matrix singlePhaseParameterToThreePhase(Real parameter)
To convert single phase parameters to symmetrical three phase ones.
static MatrixComp singlePhaseVariableToThreePhase(Complex var_1ph)
To convert single phase complex variables (voltages, currents) to symmetrical three phase ones.