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

#include <MathUtils.h>

Classes

class  ScopedZeroSkipping
 

Public Types

typedef Real(* DeriveFnPtr) (Matrix inputs)
 

Static Public Member Functions

static Bool zeroSkippingEnabled ()
 
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 addToMatrixElement (SparseMatrixCompRow &mat, Matrix::Index row, Matrix::Index column, Complex value)
 
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 prepareSparseMatrixValueCache (SparseMatrixRow &mat)
 
static void clearSparseMatrixValueCache (SparseMatrixRow &mat)
 
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 Matrix StateSpaceTrapezoidalNoCopy (const Matrix &states, const Matrix &A, const Matrix &B, Real dt, const Matrix &u_new, const Matrix &u_old)
 
static Matrix StateSpaceTrapezoidalNoCopy (const Matrix &states, const Matrix &A, const Matrix &B, const Matrix &C, Real dt, const Matrix &u_new, const Matrix &u_old)
 
static Matrix StateSpaceTrapezoidalNoCopy (const Matrix &states, const Matrix &A, const Matrix &B, Real dt, const Matrix &u)
 
static Matrix StateSpaceTrapezoidalNoCopy (const Matrix &states, const Matrix &A, const Matrix &B, const Matrix &C, Real dt, const Matrix &u)
 
static Matrix StateSpaceTrapezoidalNoCopy (const Matrix &states, const Matrix &A, const 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 Matrix StateSpaceEulerNoCopy (const Matrix &states, const Matrix &A, const Matrix &B, Real dt, const Matrix &u)
 
static Matrix StateSpaceEulerNoCopy (const Matrix &states, const Matrix &A, const Matrix &B, const Matrix &C, Real dt, const Matrix &u)
 
static Matrix StateSpaceEulerNoCopy (const Matrix &states, const Matrix &A, const 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, Real > pccPowerFromFilterPowerReference (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 33 of file MathUtils.h.

Member Function Documentation

◆ abs() [1/2]

Real Math::abs ( Complex value)
static

Definition at line 71 of file MathUtils.cpp.

◆ abs() [2/2]

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

Definition at line 73 of file MathUtils.cpp.

◆ addToMatrixElement() [1/6]

void Math::addToMatrixElement ( SparseMatrixCompRow & mat,
Matrix::Index row,
Matrix::Index column,
Complex value )
static

Definition at line 254 of file MathUtils.cpp.

◆ addToMatrixElement() [2/6]

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

Definition at line 182 of file MathUtils.cpp.

◆ addToMatrixElement() [3/6]

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

Definition at line 205 of file MathUtils.cpp.

◆ addToMatrixElement() [4/6]

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

Definition at line 244 of file MathUtils.cpp.

◆ addToMatrixElement() [5/6]

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

Definition at line 238 of file MathUtils.cpp.

◆ addToMatrixElement() [6/6]

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

Definition at line 277 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 127 of file MathUtils.cpp.

◆ addToVectorElement() [2/2]

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

Definition at line 147 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 508 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 476 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 493 of file MathUtils.cpp.

◆ clearSparseMatrixValueCache()

void Math::clearSparseMatrixValueCache ( SparseMatrixRow & mat)
static

Definition at line 273 of file MathUtils.cpp.

◆ complexFromVectorElement()

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

Definition at line 138 of file MathUtils.cpp.

◆ degToRad()

Real Math::degToRad ( Real deg)
static

Definition at line 65 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 55 of file MathUtils.h.

◆ FFT()

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

Definition at line 517 of file MathUtils.cpp.

◆ inverseParkTransformMatrixPowerInvariant()

Matrix Math::inverseParkTransformMatrixPowerInvariant ( Real theta)
static

Definition at line 585 of file MathUtils.cpp.

◆ inverseParkTransformPowerInvariant()

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

Definition at line 581 of file MathUtils.cpp.

◆ invertMatrix()

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

Definition at line 283 of file MathUtils.cpp.

◆ isFinite() [1/2]

bool Math::isFinite ( Complex value)
static

Definition at line 113 of file MathUtils.cpp.

◆ isFinite() [2/2]

bool Math::isFinite ( Real value)
static

Definition at line 107 of file MathUtils.cpp.

◆ parkTransformMatrixPowerInvariant()

Matrix Math::parkTransformMatrixPowerInvariant ( Real theta)
static

Definition at line 568 of file MathUtils.cpp.

◆ parkTransformPowerInvariant()

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

Definition at line 564 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 338 of file MathUtils.cpp.

◆ phase() [1/2]

Real Math::phase ( Complex value)
static

Definition at line 67 of file MathUtils.cpp.

◆ phase() [2/2]

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

Definition at line 86 of file MathUtils.cpp.

◆ phaseDeg()

Real Math::phaseDeg ( Complex value)
static

Definition at line 69 of file MathUtils.cpp.

◆ polar()

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

Definition at line 99 of file MathUtils.cpp.

◆ polarDeg()

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

Definition at line 103 of file MathUtils.cpp.

◆ prepareSparseMatrixValueCache()

void Math::prepareSparseMatrixValueCache ( SparseMatrixRow & mat)
static

Definition at line 261 of file MathUtils.cpp.

◆ radtoDeg()

Real Math::radtoDeg ( Real rad)
static

Definition at line 63 of file MathUtils.cpp.

◆ realFromVectorElement()

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

Definition at line 155 of file MathUtils.cpp.

◆ rotatingFrame2to1()

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

Definition at line 557 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 159 of file MathUtils.cpp.

◆ setMatrixElement() [2/2]

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

Definition at line 228 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 117 of file MathUtils.cpp.

◆ setVectorElement() [2/2]

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

Definition at line 151 of file MathUtils.cpp.

◆ singlePhaseParameterToThreePhase()

Matrix Math::singlePhaseParameterToThreePhase ( Real parameter)
static

To convert single phase parameters to symmetrical three phase ones.

Definition at line 326 of file MathUtils.cpp.

◆ singlePhasePowerToThreePhase()

Matrix Math::singlePhasePowerToThreePhase ( Real power)
static

To convert single phase power to symmetrical three phase.

Definition at line 332 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 320 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 442 of file MathUtils.cpp.

◆ StateSpaceEuler() [2/5]

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

Definition at line 437 of file MathUtils.cpp.

◆ StateSpaceEuler() [3/5]

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

Definition at line 447 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 466 of file MathUtils.cpp.

◆ StateSpaceEuler() [5/5]

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

Definition at line 456 of file MathUtils.cpp.

◆ StateSpaceEulerNoCopy() [1/3]

Matrix Math::StateSpaceEulerNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & B,
const Matrix & C,
Real dt,
const Matrix & u )
static

Definition at line 460 of file MathUtils.cpp.

◆ StateSpaceEulerNoCopy() [2/3]

Matrix Math::StateSpaceEulerNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & B,
Real dt,
const Matrix & u )
static

Definition at line 451 of file MathUtils.cpp.

◆ StateSpaceEulerNoCopy() [3/3]

Matrix Math::StateSpaceEulerNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & input,
Real dt )
static

Definition at line 471 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 377 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 367 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [3/7]

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

Definition at line 372 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 362 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [5/7]

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

Definition at line 382 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 409 of file MathUtils.cpp.

◆ StateSpaceTrapezoidal() [7/7]

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

Definition at line 429 of file MathUtils.cpp.

◆ StateSpaceTrapezoidalNoCopy() [1/5]

Matrix Math::StateSpaceTrapezoidalNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & B,
const Matrix & C,
Real dt,
const Matrix & u )
static

Definition at line 402 of file MathUtils.cpp.

◆ StateSpaceTrapezoidalNoCopy() [2/5]

Matrix Math::StateSpaceTrapezoidalNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & B,
const Matrix & C,
Real dt,
const Matrix & u_new,
const Matrix & u_old )
static

Definition at line 394 of file MathUtils.cpp.

◆ StateSpaceTrapezoidalNoCopy() [3/5]

Matrix Math::StateSpaceTrapezoidalNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & B,
Real dt,
const Matrix & u )
static

Definition at line 418 of file MathUtils.cpp.

◆ StateSpaceTrapezoidalNoCopy() [4/5]

Matrix Math::StateSpaceTrapezoidalNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & B,
Real dt,
const Matrix & u_new,
const Matrix & u_old )
static

Reference-based variants for hot internal call sites that already own their matrices. The legacy by-value overloads above remain available.

Definition at line 387 of file MathUtils.cpp.

◆ StateSpaceTrapezoidalNoCopy() [5/5]

Matrix Math::StateSpaceTrapezoidalNoCopy ( const Matrix & states,
const Matrix & A,
const Matrix & input,
Real dt )
static

Definition at line 424 of file MathUtils.cpp.

◆ zeroSkippingEnabled()

Bool Math::zeroSkippingEnabled ( )
static

Definition at line 60 of file MathUtils.cpp.


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