Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced-order syngen models #213

Merged
merged 68 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
e492673
add wscc reduced order examples
dinkelbachjan May 11, 2022
0012849
add smib reduced order load step examples
dinkelbachjan May 12, 2022
23c18d7
added iterative 4 Order SG for EMT and DP domain
martinmoraga Jun 15, 2022
af20536
small changes in study case LoadStep
martinmoraga Sep 15, 2022
86373aa
minimal changes in iterative procedure
martinmoraga Sep 21, 2022
4eb1cac
add SG 6 order iterative
martinmoraga Nov 7, 2022
f314ec7
add DP_SG4OrderDCIM
martinmoraga Nov 7, 2022
c8c9d84
refactor iterative SG 4Order
martinmoraga Nov 16, 2022
469867e
add trapezoidal method for predictor step
martinmoraga Nov 17, 2022
65a9def
add SG 4 Order TPM
martinmoraga Jan 10, 2023
9e26dc9
rename SGIter -> SGPCM
martinmoraga Jan 10, 2023
79bbd40
add SG TPM to CIM reader
martinmoraga Jan 10, 2023
cab75ab
add WSCC9bus example using iterative SG models
martinmoraga Jan 10, 2023
25cd911
fix downsampling configuration in dp smib load step example with pcm …
dinkelbachjan Feb 7, 2023
ea3319d
enable zero iterations with tpm syngen
dinkelbachjan Feb 8, 2023
2e73540
refactor tpm syngen model
dinkelbachjan Feb 10, 2023
3747a4e
revise args and logging of dp wscc reduced order iter
dinkelbachjan Feb 14, 2023
bd0317d
improve comments pcm model
dinkelbachjan Mar 7, 2023
446730b
improve notebook name for sp vbr validation against psat
dinkelbachjan Mar 7, 2023
7103c11
improve comments tpm model
dinkelbachjan Mar 8, 2023
c9ba597
fixes after rebase related to dcim/pcm/tpm models
dinkelbachjan Mar 8, 2023
61c1dba
cleanup in dcim models
dinkelbachjan Mar 8, 2023
56fac7e
fix mechanical calculation of tpm after rebase
dinkelbachjan Mar 9, 2023
d376e3d
add validation notebook tpm versus vbr
dinkelbachjan Mar 9, 2023
2bf7b35
remove redundant declaration of constants from tpm
dinkelbachjan Mar 9, 2023
f2e6cc3
add smib load step with tpm and vbr to test sources
dinkelbachjan Mar 9, 2023
9e9e859
use explicit expression for Rconst in tpm model
dinkelbachjan Mar 9, 2023
4f0990d
avoid meaningless recomputation of Rvar in tpm model
dinkelbachjan Mar 9, 2023
a98071a
use explicit expression for Rvar in tpm model
dinkelbachjan Mar 9, 2023
6cbfea1
remove unused variables of PCM models
martinmoraga Mar 9, 2023
891e967
fix rebase errors of PCM models
martinmoraga Mar 9, 2023
1f3553d
improve naming of vars in tpm model
dinkelbachjan Mar 10, 2023
e28834f
add missing update of internal iterative model vars after prediction …
dinkelbachjan Mar 10, 2023
24171f4
remove recomputation emf for prev iter according to system solution i…
dinkelbachjan Mar 10, 2023
590f24b
update thresholds in tpm validation notebook
dinkelbachjan Mar 10, 2023
b51aede
improve namiv of vars in pcm models
martinmoraga Mar 10, 2023
cdaf006
fix iterative example after rebase
dinkelbachjan Mar 10, 2023
29a6f15
add higher number of iter to tpm model validation notebook
dinkelbachjan Mar 10, 2023
0903d0d
unify and simplify dq to dp transforms in tpm model
dinkelbachjan Mar 10, 2023
992de9a
use state space with voltage input in corrector step of tpm model
dinkelbachjan Mar 10, 2023
0f67466
further naming improvements tpm model
dinkelbachjan Mar 13, 2023
408c2c9
Use mEdq_s, mEdq_t instead of mEdq
martinmoraga Mar 12, 2023
9741c0f
PCM: Remove TR on mechanical variables in correctorStep
martinmoraga Mar 12, 2023
8e1a7db
PCM SG models: Unify and simplify DQ to DP transform
martinmoraga Mar 14, 2023
c45c1d3
fix error in SG 6 Order PCM
martinmoraga Mar 16, 2023
cc96faa
add iterative SG models to dpsimpy
martinmoraga Mar 16, 2023
3e5af48
add validation notebook for PCM models
martinmoraga Mar 16, 2023
b6dc021
PCM and TPM: remove Ef from state matrices
martinmoraga Mar 17, 2023
e49a6fe
refactor iteration check of pcm model
dinkelbachjan Mar 17, 2023
fd4691f
reduce vbr ref timestep in pcm validation notebook
dinkelbachjan Mar 17, 2023
41e06e0
remove deprecated dp dcim models replaced by dp pcm models with zero …
dinkelbachjan Mar 18, 2023
2a9ecb4
apply stamp on sparse system matrices with pcm and tpm models
dinkelbachjan Mar 18, 2023
5be342a
add dp-dq interface class and use in tpm model
dinkelbachjan Mar 20, 2023
e6fcd7a
use dp-dq interface class and explicit reactance matrix expressions i…
dinkelbachjan Mar 20, 2023
7452b61
use dp-dq interface class in dp pcm models
dinkelbachjan Mar 20, 2023
792d448
updated assertions for linear solver validation notebooks
Mar 21, 2023
e0999c4
improve prints for linear solver validation notebook
dinkelbachjan Mar 29, 2023
998cd45
improve logging and method naming for setting reduced-order SG models…
dinkelbachjan Mar 30, 2023
e1d0857
add tpm model as norton source
dinkelbachjan Mar 30, 2023
979007b
reuse of discretized state space matrices to speed up tpm model compu…
dinkelbachjan Mar 31, 2023
87826ed
reuse discretized trapezoidal state space matrices in pcm models
dinkelbachjan Mar 31, 2023
fc0da3b
increase resolution of step time logging
dinkelbachjan Apr 3, 2023
49d46b7
fix cim reader for 3rd and 6th order models in emt
dinkelbachjan May 30, 2023
9d485fc
add wscc 4th order validation against psat
dinkelbachjan Jun 9, 2023
13a7d86
refactor EMT_Ph3_SynchronGenerator4OrderPCM
martinmoraga Jun 23, 2023
84dc8e4
remove unused methods and variables of MNASyncGenInterface
martinmoraga Jun 23, 2023
c7f7f2f
remove unused variable in MNASolverDirect
martinmoraga Jun 23, 2023
8cab9ee
remove deprecate dcim model in sp
dinkelbachjan Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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