DPsim
Loading...
Searching...
No Matches
CPS::Math Class Reference

#include <MathUtils.h>

Public Types

typedef Real(* DeriveFnPtr) (Matrix inputs)
 

Static Public Member Functions

static Real radtoDeg (Real rad)
 
static Real degToRad (Real deg)
 
static Real phase (Complex value)
 
static Real phaseDeg (Complex value)
 
static Real abs (Complex value)
 
static Matrix abs (const MatrixComp &mat)
 
static Matrix phase (const MatrixComp &mat)
 
static Complex polar (Real abs, Real phase)
 
static Complex polarDeg (Real abs, Real phase)
 
template<typename DerivedA, typename DerivedB>
static auto elementwiseProduct (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Elementwise product of two same-shaped Eigen expressions.
 
static bool isFinite (Real value)
 
static bool isFinite (Complex value)
 
static void setVectorElement (Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0, Matrix::Index colOffset=0)
 
static void addToVectorElement (Matrix &mat, Matrix::Index row, Complex value, Int maxFreq=1, Int freqIdx=0)
 
static Complex complexFromVectorElement (const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
 
static void addToVectorElement (Matrix &mat, Matrix::Index row, Real value)
 
static void setVectorElement (Matrix &mat, Matrix::Index row, Real value)
 
static Real realFromVectorElement (const Matrix &mat, Matrix::Index row)
 
static void setMatrixElement (SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
 
static void addToMatrixElement (SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Complex value, Int maxFreq=1, Int freqIdx=0)
 
static void addToMatrixElement (SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Matrix value, Int maxFreq=1, Int freqIdx=0)
 
static void setMatrixElement (SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Real value)
 
static void addToMatrixElement (SparseMatrixRow &mat, std::vector< UInt > rows, std::vector< UInt > columns, Complex value)
 
static void addToMatrixElement (SparseMatrixRow &mat, Matrix::Index row, Matrix::Index column, Real value)
 
static void addToMatrixElement (SparseMatrixRow &mat, std::vector< UInt > rows, std::vector< UInt > columns, Real value)
 
static void invertMatrix (const Matrix &mat, Matrix &matInv)
 
static Matrix StateSpaceTrapezoidal (Matrix states, Matrix A, Matrix B, Real dt, Matrix u_new, Matrix u_old)
 
static Matrix StateSpaceTrapezoidal (Matrix states, Matrix A, Matrix B, Matrix C, Real dt, Matrix u_new, Matrix u_old)
 
static Matrix StateSpaceTrapezoidal (Matrix states, Matrix A, Matrix B, Real dt, Matrix u)
 
static Matrix StateSpaceTrapezoidal (Matrix states, Matrix A, Matrix B, Matrix C, Real dt, Matrix u)
 
static Matrix StateSpaceTrapezoidal (Matrix states, Matrix A, Matrix input, Real dt)
 
static Real StateSpaceTrapezoidal (Real states, Real A, Real B, Real C, Real dt, Real u)
 
static Real StateSpaceTrapezoidal (Real states, Real A, Real B, Real dt, Real u)
 
static Matrix StateSpaceEuler (Matrix states, Matrix A, Matrix B, Real dt, Matrix u)
 
static Matrix StateSpaceEuler (Matrix states, Matrix A, Matrix B, Matrix C, Real dt, Matrix u)
 
static Matrix StateSpaceEuler (Matrix states, Matrix A, Matrix input, Real dt)
 
static Real StateSpaceEuler (Real states, Real A, Real B, Real dt, Real u)
 
static Real StateSpaceEuler (Real states, Real A, Real B, Real C, Real dt, Real u)
 
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 void calculateStateSpaceTrapezoidalMatrices (const Matrix &A, const Matrix &B, const Real &dt, Matrix &Ad, Matrix &Bd)
 
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 step.
 
static void FFT (std::vector< Complex > &samples)
 
static Complex rotatingFrame2to1 (Complex f2, Real theta1, Real theta2)
 
static MatrixComp singlePhaseVariableToThreePhase (Complex var_1ph)
 To convert single phase complex variables (voltages, currents) to symmetrical three phase ones.
 
static Matrix singlePhaseParameterToThreePhase (Real parameter)
 To convert single phase parameters to symmetrical three phase ones.
 
static Matrix singlePhasePowerToThreePhase (Real power)
 To convert single phase power to symmetrical three phase.
 
static std::pair< Real, RealpccPowerFromFilterPowerReference (Real pFilterRef, Real qFilterRef, Real rc, Real vGridRmsLL)
 
static Matrix parkTransformPowerInvariant (Real theta, const Matrix &fabc)
 
static Matrix parkTransformMatrixPowerInvariant (Real theta)
 
static Matrix inverseParkTransformPowerInvariant (Real theta, const Matrix &fdq)
 
static Matrix inverseParkTransformMatrixPowerInvariant (Real theta)
 

Detailed Description

Definition at line 17 of file MathUtils.h.

Member Typedef Documentation

◆ DeriveFnPtr

typedef Real(* CPS::Math::DeriveFnPtr) (Matrix inputs)

Definition at line 19 of file MathUtils.h.

Member Function Documentation

◆ abs() [1/2]

Real Math::abs ( Complex value)
static

Definition at line 27 of file MathUtils.cpp.

◆ abs() [2/2]

Matrix Math::abs ( const MatrixComp & mat)
static

Definition at line 29 of file MathUtils.cpp.

◆ addToMatrixElement() [1/5]

void Math::addToMatrixElement ( SparseMatrixRow & mat,
Matrix::Index row,
Matrix::Index column,
Complex value,
Int maxFreq = 1,
Int freqIdx = 0 )
static

Definition at line 130 of file MathUtils.cpp.

◆ addToMatrixElement() [2/5]

void Math::addToMatrixElement ( SparseMatrixRow & mat,
Matrix::Index row,
Matrix::Index column,
Matrix value,
Int maxFreq = 1,
Int freqIdx = 0 )
static

Definition at line 146 of file MathUtils.cpp.

◆ addToMatrixElement() [3/5]

void Math::addToMatrixElement ( SparseMatrixRow & mat,
Matrix::Index row,
Matrix::Index column,
Real value )
static

Definition at line 172 of file MathUtils.cpp.

◆ addToMatrixElement() [4/5]

void Math::addToMatrixElement ( SparseMatrixRow & mat,
std::vector< UInt > rows,
std::vector< UInt > columns,
Complex value )
static

Definition at line 166 of file MathUtils.cpp.

◆ addToMatrixElement() [5/5]

void Math::addToMatrixElement ( SparseMatrixRow & mat,
std::vector< UInt > rows,
std::vector< UInt > columns,
Real value )
static

Definition at line 177 of file MathUtils.cpp.

◆ addToVectorElement() [1/2]

void Math::addToVectorElement ( Matrix & mat,
Matrix::Index row,
Complex value,
Int maxFreq = 1,
Int freqIdx = 0 )
static

Definition at line 83 of file MathUtils.cpp.

◆ addToVectorElement() [2/2]

void Math::addToVectorElement ( Matrix & mat,
Matrix::Index row,
Real value )
static

Definition at line 103 of file MathUtils.cpp.

◆ applyStateSpaceTrapezoidalMatrices()

Matrix Math::applyStateSpaceTrapezoidalMatrices ( const Matrix & Ad,
const Matrix & Bd,
const Matrix & Cd,
const Matrix & statesPrevStep,
const Matrix & inputCurrStep,
const Matrix & inputPrevStep )
static

Apply the trapezoidal based state space matrices Ad, Bd, Cd to get the states at the current time step.

Definition at line 395 of file MathUtils.cpp.

◆ calculateStateSpaceTrapezoidalMatrices() [1/2]

void Math::calculateStateSpaceTrapezoidalMatrices ( const Matrix & A,
const Matrix & B,
const Matrix & C,
const Real & dt,
Matrix & Ad,
Matrix & Bd,
Matrix & Cd )
static

Calculate the discretized state space matrices Ad, Bd, Cd using trapezoidal rule.

Definition at line 363 of file MathUtils.cpp.

◆ calculateStateSpaceTrapezoidalMatrices() [2/2]

void Math::calculateStateSpaceTrapezoidalMatrices ( const Matrix & A,
const Matrix & B,
const Real & dt,
Matrix & Ad,
Matrix & Bd )
static

Definition at line 380 of file MathUtils.cpp.

◆ complexFromVectorElement()

Complex Math::complexFromVectorElement ( const Matrix & mat,
Matrix::Index row,
Int maxFreq = 1,
Int freqIdx = 0 )
static

Definition at line 94 of file MathUtils.cpp.

◆ degToRad()

Real Math::degToRad ( Real deg)
static

Definition at line 21 of file MathUtils.cpp.

◆ elementwiseProduct()

template<typename DerivedA, typename DerivedB>
static auto CPS::Math::elementwiseProduct ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )
inlinestatic

Elementwise product of two same-shaped Eigen expressions.

Definition at line 41 of file MathUtils.h.

◆ FFT()

void Math::FFT ( std::vector< Complex > & samples)
static

Definition at line 404 of file MathUtils.cpp.

◆ inverseParkTransformMatrixPowerInvariant()

Matrix Math::inverseParkTransformMatrixPowerInvariant ( Real theta)
static

Definition at line 472 of file MathUtils.cpp.

◆ inverseParkTransformPowerInvariant()

Matrix Math::inverseParkTransformPowerInvariant ( Real theta,
const Matrix & fdq )
static

Definition at line 468 of file MathUtils.cpp.

◆ invertMatrix()

void Math::invertMatrix ( const Matrix & mat,
Matrix & matInv )
static

Definition at line 183 of file MathUtils.cpp.

◆ isFinite() [1/2]

bool Math::isFinite ( Complex value)
static

Definition at line 69 of file MathUtils.cpp.

◆ isFinite() [2/2]

bool Math::isFinite ( Real value)
static

Definition at line 63 of file MathUtils.cpp.

◆ parkTransformMatrixPowerInvariant()

Matrix Math::parkTransformMatrixPowerInvariant ( Real theta)
static

Definition at line 455 of file MathUtils.cpp.

◆ parkTransformPowerInvariant()

Matrix Math::parkTransformPowerInvariant ( Real theta,
const Matrix & fabc )
static

Definition at line 451 of file MathUtils.cpp.

◆ pccPowerFromFilterPowerReference()

std::pair< Real, Real > Math::pccPowerFromFilterPowerReference ( Real pFilterRef,
Real qFilterRef,
Real rc,
Real vGridRmsLL )
static

PCC-side injected power from an averaged-VSI filter-side power reference, correcting the loss across the coupling resistance rc (S = 1.5*Vpeak*I*).

Definition at line 238 of file MathUtils.cpp.

◆ phase() [1/2]

Real Math::phase ( Complex value)
static

Definition at line 23 of file MathUtils.cpp.

◆ phase() [2/2]

Matrix Math::phase ( const MatrixComp & mat)
static

Definition at line 42 of file MathUtils.cpp.

◆ phaseDeg()

Real Math::phaseDeg ( Complex value)
static

Definition at line 25 of file MathUtils.cpp.

◆ polar()

Complex Math::polar ( Real abs,
Real phase )
static

Definition at line 55 of file MathUtils.cpp.

◆ polarDeg()

Complex Math::polarDeg ( Real abs,
Real phase )
static

Definition at line 59 of file MathUtils.cpp.

◆ radtoDeg()

Real Math::radtoDeg ( Real rad)
static

Definition at line 19 of file MathUtils.cpp.

◆ realFromVectorElement()

Real Math::realFromVectorElement ( const Matrix & mat,
Matrix::Index row )
static

Definition at line 111 of file MathUtils.cpp.

◆ rotatingFrame2to1()

Complex Math::rotatingFrame2to1 ( Complex f2,
Real theta1,
Real theta2 )
static

Definition at line 444 of file MathUtils.cpp.

◆ setMatrixElement() [1/2]

void Math::setMatrixElement ( SparseMatrixRow & mat,
Matrix::Index row,
Matrix::Index column,
Complex value,
Int maxFreq = 1,
Int freqIdx = 0 )
static

Definition at line 115 of file MathUtils.cpp.

◆ setMatrixElement() [2/2]

void Math::setMatrixElement ( SparseMatrixRow & mat,
Matrix::Index row,
Matrix::Index column,
Real value )
static

Definition at line 161 of file MathUtils.cpp.

◆ setVectorElement() [1/2]

void Math::setVectorElement ( Matrix & mat,
Matrix::Index row,
Complex value,
Int maxFreq = 1,
Int freqIdx = 0,
Matrix::Index colOffset = 0 )
static

Definition at line 73 of file MathUtils.cpp.

◆ setVectorElement() [2/2]

void Math::setVectorElement ( Matrix & mat,
Matrix::Index row,
Real value )
static

Definition at line 107 of file MathUtils.cpp.

◆ singlePhaseParameterToThreePhase()

Matrix Math::singlePhaseParameterToThreePhase ( Real parameter)
static

To convert single phase parameters to symmetrical three phase ones.

Definition at line 226 of file MathUtils.cpp.

◆ singlePhasePowerToThreePhase()

Matrix Math::singlePhasePowerToThreePhase ( Real power)
static

To convert single phase power to symmetrical three phase.

Definition at line 232 of file MathUtils.cpp.

◆ singlePhaseVariableToThreePhase()

MatrixComp Math::singlePhaseVariableToThreePhase ( Complex var_1ph)
static

To convert single phase complex variables (voltages, currents) to symmetrical three phase ones.

Definition at line 220 of file MathUtils.cpp.

◆ StateSpaceEuler() [1/5]

Matrix Math::StateSpaceEuler ( Matrix states,
Matrix A,
Matrix B,
Matrix C,
Real dt,
Matrix u )
static

Definition at line 349 of file MathUtils.cpp.

◆ StateSpaceEuler() [2/5]

Matrix Math::StateSpaceEuler ( Matrix states,
Matrix A,
Matrix B,
Real dt,
Matrix u )
static

Definition at line 340 of file MathUtils.cpp.

◆ StateSpaceEuler() [3/5]

Matrix Math::StateSpaceEuler ( Matrix states,
Matrix A,
Matrix input,
Real dt )
static

Definition at line 359 of file MathUtils.cpp.

◆ StateSpaceEuler() [4/5]

Real Math::StateSpaceEuler ( Real states,
Real A,
Real B,
Real C,
Real dt,
Real u )
static

Definition at line 354 of file MathUtils.cpp.

◆ StateSpaceEuler() [5/5]

Real Math::StateSpaceEuler ( Real states,
Real A,
Real B,
Real dt,
Real u )
static

Definition at line 345 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [1/7]

Matrix Math::StateSpaceTrapezoidal ( Matrix states,
Matrix A,
Matrix B,
Matrix C,
Real dt,
Matrix u )
static

Definition at line 287 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [2/7]

Matrix Math::StateSpaceTrapezoidal ( Matrix states,
Matrix A,
Matrix B,
Matrix C,
Real dt,
Matrix u_new,
Matrix u_old )
static

Definition at line 274 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [3/7]

Matrix Math::StateSpaceTrapezoidal ( Matrix states,
Matrix A,
Matrix B,
Real dt,
Matrix u )
static

Definition at line 308 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [4/7]

Matrix Math::StateSpaceTrapezoidal ( Matrix states,
Matrix A,
Matrix B,
Real dt,
Matrix u_new,
Matrix u_old )
static

Definition at line 262 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [5/7]

Matrix Math::StateSpaceTrapezoidal ( Matrix states,
Matrix A,
Matrix input,
Real dt )
static

Definition at line 320 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [6/7]

Real Math::StateSpaceTrapezoidal ( Real states,
Real A,
Real B,
Real C,
Real dt,
Real u )
static

Definition at line 299 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [7/7]

Real Math::StateSpaceTrapezoidal ( Real states,
Real A,
Real B,
Real dt,
Real u )
static

Definition at line 332 of file MathUtils.cpp.


The documentation for this class was generated from the following files: