Skip to content

Commit

Permalink
Reduced-order syngen models (#213)
Browse files Browse the repository at this point in the history
This PR covers the implementation of iterative reduced-order synchronous
generator models, namely the PCM and TPM models. Besides, it removes the
DCIM implementations, which are covered now by PCM models with zero
iterations in the DP domain. It also refactors the VBR model
implementations and involves a new DP-DQ interface, which is used by all
DP reduced-order synchronous generator models (PCM, TPM, VBR) and shall
be reused by other DQ based components in the future. Furthermore, it
adds several validation notebooks to compare the different reduced-order
models against each other and to compare the results of the 4th order
VBR model in the WSCC benchmark system against results from PSAT.

Based on #199 
Rebase of #207  
Related to #75, #221 and #225
  • Loading branch information
dinkelbachjan authored Jul 4, 2023
2 parents 1f7dfc7 + 8cab9ee commit b511424
Show file tree
Hide file tree
Showing 74 changed files with 4,122 additions and 735 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace Base {
virtual ~ReducedOrderSynchronGenerator() { }
/// modelAsCurrentSource=true --> SG is modeled as current source, otherwise as voltage source
/// Both implementations are equivalent, but the current source implementation is more efficient
virtual void setModelAsCurrentSource(Bool modelAsCurrentSource);
virtual void setModelAsNortonSource(Bool modelAsCurrentSource);
///
void setBaseParameters(Real nomPower, Real nomVolt, Real nomFreq);
/// Initialization for 3 Order SynGen
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace Base {
void initializeFromNodesAndTerminals(Real frequency);
/// Function to initialize the specific variables of each SG model
virtual void specificInitialization() = 0;
///
/// Model specific step
virtual void stepInPerUnit() = 0;

// ### MNA Section ###
Expand All @@ -128,9 +128,8 @@ namespace Base {
virtual void mnaCompPostStep(const Matrix& leftVector) = 0;
/// Stamps system matrix
virtual void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) = 0;
/// Model flag indicating whether the machine is modeled as current or voltage source
/// Default: currentsource (recommended)
Bool mModelAsCurrentSource = true;
/// Model flag indicating whether the machine is modelled as Norton or Thevenin equivalent
Bool mModelAsNortonSource;
// Model flag indicating the SG order to be used
SGOrder mSGOrder;

Expand Down
5 changes: 4 additions & 1 deletion dpsim-models/include/dpsim-models/Components.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <dpsim-models/SP/SP_Ph1_SynchronGenerator4OrderVBR.h>
#include <dpsim-models/SP/SP_Ph1_SynchronGenerator6aOrderVBR.h>
#include <dpsim-models/SP/SP_Ph1_SynchronGenerator6bOrderVBR.h>
#include <dpsim-models/SP/SP_Ph1_SynchronGenerator4OrderDCIM.h>
#include <dpsim-models/SP/SP_Ph1_varResSwitch.h>

#include <dpsim-models/SP/SP_Ph3_Capacitor.h>
Expand All @@ -58,8 +57,11 @@
#include <dpsim-models/DP/DP_Ph1_ReducedOrderSynchronGeneratorVBR.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator3OrderVBR.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator4OrderVBR.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator4OrderPCM.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator4OrderTPM.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator6aOrderVBR.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator6bOrderVBR.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator6OrderPCM.h>
#include <dpsim-models/DP/DP_Ph1_Inverter.h>
#include <dpsim-models/DP/DP_Ph1_NetworkInjection.h>
#include <dpsim-models/DP/DP_Ph1_AvVoltageSourceInverterDQ.h>
Expand Down Expand Up @@ -97,6 +99,7 @@
#include <dpsim-models/EMT/EMT_Ph3_ReducedOrderSynchronGeneratorVBR.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator3OrderVBR.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator4OrderVBR.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator4OrderPCM.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator6aOrderVBR.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator6bOrderVBR.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGeneratorDQ.h>
Expand Down
52 changes: 52 additions & 0 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_DPDQInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/

#pragma once

#include <dpsim-models/Definitions.h>

namespace CPS {
namespace DP {
namespace Ph1 {
/// @brief Class providing interface with DP domain for all components in DQ domain
class DPDQInterface {

protected:
/// Transform from DQ to DP domain
MatrixFixedSize<2,2> mDQToDPTransform;
/// Transform from DP to DQ domain
MatrixFixedSize<2,2> mDPToDQTransform;

/// Shifting frequency of the DP domain (assumed to be constant)
Real mOmegaShift;

public:
/// Constructor
DPDQInterface() {}

/// Setter for shit frequency
void setDPShiftFrequency(const Real & omegaShift);

/// Getter for transform from DQ to DP domain
MatrixFixedSize<2,2> DQToDPTransform() { return mDQToDPTransform; };
/// Getter for transform from DP to DQ domain
MatrixFixedSize<2,2> DPToDQTransform() { return mDPToDQTransform; };

/// Update transformation matrix from DQ to DP
void updateDQToDPTransform(const Real & thetaDQ, const Real & simTime);
/// Update transformation matrix from DP to DQ
void updateDPToDQTransform(const Real & thetaDQ, const Real & simTime);

/// Apply transform to obtain current complex DP
Complex applyDQToDPTransform(const MatrixFixedSize<2,1> & dqMatrix);
/// Apply transform to obtain current DQ vector
MatrixFixedSize<2,1> applyDPToDQTransform(const Complex& dpComplex);
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <dpsim-models/Base/Base_ReducedOrderSynchronGenerator.h>
#include <dpsim-models/Solver/MNAVariableCompInterface.h>
#include <dpsim-models/DP/DP_Ph1_DPDQInterface.h>

namespace CPS {
namespace DP {
Expand All @@ -27,30 +28,12 @@ namespace Ph1 {
Complex mIvbr;

protected:
/// Interface used to transform between DP and DQ vars
DPDQInterface mDomainInterface;
/// Resistance matrix in dq reference frame
Matrix mResistanceMatrixDq;
/// Conductance matrix phase A
MatrixFixedSize<2, 2> mConductanceMatrix;
/// Ka Matrix
MatrixComp mKa;
/// Kb Matrix
MatrixComp mKb;
/// Kb Matrix
MatrixComp mKc;
/// Constant part of Resistance matrix in abc reference frame
Matrix mResistanceMatrix_const;
/// phase a equivalent part of mKa
Complex mKa_1ph;
/// phase a equivalent part of mKb
Complex mKb_1ph;
/// phase a equivalent part of mResistanceMatrix_const
Complex mR_const_1ph;
/// Vector to create abc vector from a component
MatrixComp mShiftVector;
/// complex conjugate of mShiftVector
MatrixComp mShiftVectorConj;
/// Matrix to convert Evbr from dq domain to abc domain (only phase a)
MatrixComp mKvbr;

/// Constructor
ReducedOrderSynchronGeneratorVBR(const String & uid, const String & name, Logger::Level logLevel);
Expand All @@ -59,16 +42,12 @@ namespace Ph1 {
// #### General Functions ####
/// Specific component initialization
virtual void specificInitialization() override =0;
///
void initializeResistanceMatrix() override;
///
virtual void stepInPerUnit() override =0;
///
void calculateConductanceMatrix();
/// Calculate Ka, Kb and Kvbr
void calculateAuxiliarVariables();
virtual void calculateConductanceMatrix();
///
Matrix get_parkTransformMatrix() const;
void initializeResistanceMatrix() final {};

// ### MNA Section ###
void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/

#pragma once

#include <dpsim-models/Solver/MNASyncGenInterface.h>
#include <dpsim-models/Base/Base_ReducedOrderSynchronGenerator.h>
#include <dpsim-models/DP/DP_Ph1_DPDQInterface.h>

namespace CPS {
namespace DP {
namespace Ph1 {
/// @brief 4 Order Synchronous generator model for transient stability analysis
///
/// This model is based on Eremia section 2.1.6.
/// Modeling approach: delayed current injection + predictor corrector method
class SynchronGenerator4OrderPCM :
public Base::ReducedOrderSynchronGenerator<Complex>,
public MNASyncGenInterface,
public SharedFactory<SynchronGenerator4OrderPCM> {
public:
///
SynchronGenerator4OrderPCM(const String& uid, const String& name, Logger::Level logLevel = Logger::Level::off);
///
SynchronGenerator4OrderPCM(const String& name, Logger::Level logLevel = Logger::Level::off);
///
SimPowerComp<Complex>::Ptr clone(const String& name);

// #### General Functions ####
///
void specificInitialization() override;
///
void calculateStateSpaceMatrices();
///
void stepInPerUnit() override;
//
void correctorStep() override;
///
void updateVoltage(const Matrix& leftVector) override;
///
bool requiresIteration() override;
///
void initializeResistanceMatrix() final {};

/// Warning if this method is applied: the model is exclusively implemented as current source and this setter will have no impact!
void setModelAsNortonSource(Bool modelAsCurrentSource) override {
SPDLOG_LOGGER_WARN(mSLog, "This model can exclusively be used as current source. The setter setModelAsNortonSource will have no impact on the model!");
}

// #### MNA Functions ####
///
void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) final;
///
void mnaCompPostStep(const Matrix& leftVector) final;
///
void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) final {};

protected:
/// Interface used to transform between DP and DQ vars
DPDQInterface mDomainInterface;

// #### Model specific variables ####
/// Transient emf
const Attribute<Matrix>::Ptr mEdq_t;

// Variables saving values for later use
/// Trapedzoidal based state space matrix Ad
Matrix mAdTrapezoidal;
/// Trapedzoidal based state space matrix Bd
Matrix mBdTrapezoidal;
/// Trapedzoidal based state space matrix Cd
Matrix mCdTrapezoidal;
/// Edqt at k
Matrix mEdqtPrevStep;
/// Idq at k
Matrix mIdqPrevStep;
/// Vdq at k
Matrix mVdqPrevStep;
/// Vdq at j-1
Matrix mVdqPrevIter;

/// A matrix of continuous time state space model
Matrix mAStateSpace = Matrix::Zero(2,2);
/// B matrix of continuous time state space model
Matrix mBStateSpace = Matrix::Zero(2,2);
/// C matrix of continuous time state space model
Matrix mCStateSpace = Matrix::Zero(2,1);
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/

#pragma once

#include <dpsim-models/Solver/MNASyncGenInterface.h>
#include <dpsim-models/Base/Base_ReducedOrderSynchronGenerator.h>
#include <dpsim-models/DP/DP_Ph1_DPDQInterface.h>

namespace CPS {
namespace DP {
namespace Ph1 {
/// @brief 4 Order Synchronous generator model for transient stability analysis
///
/// This model is based on Eremia section 2.1.6.
/// Modeling approach: thevenin prediction method
class SynchronGenerator4OrderTPM :
public Base::ReducedOrderSynchronGenerator<Complex>,
public MNASyncGenInterface,
public SharedFactory<SynchronGenerator4OrderTPM> {
protected:
/// Interface used to transform between DP and DQ vars
DPDQInterface mDomainInterface;

/// Constant part as conductance matrix
Matrix mConductanceMatrixConst = Matrix::Zero(2,2);
/// Varying part as resistance matrix
Matrix mResistanceMatrixVarying = Matrix::Zero(2,2);

// #### Model specific variables ####
/// Transient emf
const Attribute<Matrix>::Ptr mEdq_t;
/// Original history voltage of VBR model
Matrix mEh = Matrix::Zero(2,1);
/// Modified history voltage of TPM model
const Attribute<Complex>::Ptr mEhMod;
/// Norton equivalent current of EhMod
Complex mIhMod;

// Variables saving values for later use
/// Trapedzoidal based state space matrix Ad
Matrix mAdStateSpace;
/// Trapedzoidal based state space matrix Bd
Matrix mBdStateSpace;
/// Trapedzoidal based state space matrix Cd
Matrix mCdStateSpace;
/// Idp at k-1
MatrixComp mIdpTwoPrevStep;
/// Vdq at k
Matrix mVdqPrevStep;
/// Vdq at j-1
Matrix mVdqPrevIter;
/// Edq_t at k
Matrix mEdqtPrevStep;

/// A matrix of continuous time state space model
Matrix mAStateSpace = Matrix::Zero(2,2);
/// B matrix of continuous time state space model
Matrix mBStateSpace = Matrix::Zero(2,2);
/// C matrix of continuous time state space model
Matrix mCStateSpace = Matrix::Zero(2,1);
public:
///
SynchronGenerator4OrderTPM(String uid, String name, Logger::Level logLevel = Logger::Level::off);
///
SynchronGenerator4OrderTPM(String name, Logger::Level logLevel = Logger::Level::off);
///
SimPowerComp<Complex>::Ptr clone(String name);

// #### General Functions ####
/// Initializes component from power flow data
void specificInitialization() override;
///
void calculateStateSpaceMatrices();
///
void calculateConstantConductanceMatrix();
///
void stepInPerUnit() override;
///
void correctorStep() override;
///
void updateVoltage(const Matrix& leftVector) override;
///
bool requiresIteration() override;

///
void initializeResistanceMatrix() final {};

// #### MNA Functions ####
///
void mnaCompApplyRightSideVectorStamp(Matrix& rightVector) override;
///
void mnaCompPostStep(const Matrix& leftVector) override;
///
void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) override;

void setOperationalParametersPerUnit(Real nomPower,
Real nomVolt, Real nomFreq, Real H, Real Ld, Real Lq, Real L0,
Real Ld_t, Real Lq_t, Real Td0_t, Real Tq0_t);
};
}
}
}
Loading

0 comments on commit b511424

Please sign in to comment.