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

Emt syngen trstab #185

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cab7c3a
wip
gnakti Aug 2, 2021
0f34b41
add first working version
gnakti Aug 19, 2021
14961ab
fix initialisation of internal voltage
gnakti Aug 20, 2021
cbb2b29
add comments
gnakti Aug 20, 2021
32b7462
update EMT SMIB fault example
gnakti Aug 20, 2021
dab4652
update namespace of SMIB examples
gnakti Aug 24, 2021
9ec4fdb
remove emt line model in 1ph
gnakti Aug 25, 2021
0d3ffa6
comment out emt part in SMIB notebooks
gnakti Aug 26, 2021
dac3a6c
add EMT varResSwitch model
gnakti Sep 15, 2021
c358b1a
use varResSwitch in EMT SMIB example
gnakti Sep 15, 2021
dfff59f
add EMT 3Bus examples
gnakti Sep 16, 2021
801e572
add model flags
gnakti Sep 22, 2021
d12cf28
use three bus parameters of Marti paper
gnakti Mar 14, 2022
eed69f5
update to version used in publication
gnakti Mar 14, 2022
862c1d2
fix pipeline build error
gnakti Mar 14, 2022
e737682
use new method getOptionReal from utils
gnakti Mar 14, 2022
617ba72
post-rebase remaining adaption to new attribute system
gnakti Nov 28, 2022
3c40464
add emt 3ph SynGenTrStab to pybind
gnakti Nov 28, 2022
97f8707
fix attribute and task system
gnakti Jan 20, 2023
efe5e87
set correct frequency of external network injection
gnakti Jan 20, 2023
c681774
use new task system
gnakti Jan 26, 2023
ad70800
add EMT simulation to jupyter notebooks
gnakti Jan 31, 2023
38a061d
rename notebooks
gnakti Jan 31, 2023
dbdc663
fix and clean up C++ examples
gnakti Jan 31, 2023
1d441ab
remove unused attributes from EMT varResSwitch
gnakti Jan 31, 2023
217dae7
pybind: update EMT SynGenTrStab functions
gnakti Jan 31, 2023
f6bd2cf
add new task function of composite components
gnakti Jan 31, 2023
0258838
replace regular switch with varResSwitch
gnakti Jan 31, 2023
02b4287
fix prestep task order for DP SynGenTrStab
gnakti Jan 31, 2023
2dd95e2
[post rebase fixes]: Attributes, SPDLOG & MNA interface
gnakti Jul 16, 2023
bac8ad8
[post rebase fixes] solver
gnakti Jul 16, 2023
c5cb0f9
[Post rebase fixes] notebooks
gnakti Jul 16, 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
3 changes: 3 additions & 0 deletions dpsim-models/include/dpsim-models/Base/Base_Ph3_Switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ namespace Ph3 {
}
void closeSwitch() { **mSwitchClosed = true; }
void openSwitch() { **mSwitchClosed = false; }

/// Check if switch is closed
Bool isClosed() { return **mSwitchClosed; }
};
}
}
Expand Down
1 change: 1 addition & 0 deletions dpsim-models/include/dpsim-models/Components.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#include <dpsim-models/EMT/EMT_Ph3_Transformer.h>
#include <dpsim-models/EMT/EMT_Ph3_NetworkInjection.h>
#include <dpsim-models/EMT/EMT_Ph3_Switch.h>
#include <dpsim-models/EMT/EMT_Ph3_varResSwitch.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGeneratorTrStab.h>

#include <dpsim-models/Signal/DecouplingLine.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ namespace Ph3 {
Matrix mStates;
/// Nominal system angle
Real mThetaN = 0;

/// Flag for usage of attribute of w_ref (otherwise mNomOmega is used)
Bool mUseOmegaRef = false;
/// Flag for usage of actual mechanical speed for torque conversion (otherwise mNomOmega is used)
Bool mConvertWithOmegaMech = true;

public:
// #### Model specific variables ####
/// emf behind transient reactance
Expand Down Expand Up @@ -73,6 +77,8 @@ namespace Ph3 {
Matrix getParkTransformMatrixPowerInvariant(Real theta);

// #### General Functions ####
/// Flags to modify model behavior
void setModelFlags(Bool convertWithOmegaMech);
///
void setInitialValues(Complex elecPower, Real mechPower);
/// \brief Initializes the machine parameters
Expand Down Expand Up @@ -105,6 +111,8 @@ namespace Ph3 {
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override;
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) override;

void setReferenceOmega(Attribute<Real>::Ptr refOmegaPtr, Attribute<Real>::Ptr refDeltaPtr);

class AddBStep : public Task {
public:
AddBStep(SynchronGeneratorTrStab& generator) :
Expand Down
89 changes: 89 additions & 0 deletions dpsim-models/include/dpsim-models/EMT/EMT_Ph3_varResSwitch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* Copyright 2017-2020 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/MNAInterface.h>
#include <dpsim-models/MNASimPowerComp.h>
#include <dpsim-models/Solver/MNASwitchInterface.h>
#include <dpsim-models/Solver/MNAVariableCompInterface.h>
#include <dpsim-models/Definitions.h>
#include <dpsim-models/Logger.h>
#include <dpsim-models/Base/Base_Ph3_Switch.h>

namespace CPS {
namespace EMT {
namespace Ph3 {
/// \brief
///
/// Switch with variable resistance to avoid numerical oscillations, when an inductive current is suddenly interrupted.
/// It is useful as a fault switch especially on a faulted generator or transformer winding.

/// The switch resistance changes at a defined fixed rate by multiplying previous resistance value with a factor for the rate of change
/// The MNA variable component interface is used to recompute the system Matrix after each change.
class varResSwitch :
public MNASimPowerComp<Real>,
public Base::Ph3::Switch,
public MNAVariableCompInterface,
public MNASwitchInterface,
Comment on lines +32 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need inheritance from both classes? I would assume that we require always system recomputation with varResSwitch and consequently use MNAVariableCompInterface. So can't we drop MNASwitchInterface?

public SharedFactory<varResSwitch> {

protected:

Bool mPrevState=false;
Real mDeltaResClosed = 0;
Real mDeltaResOpen = 1.5;
Matrix mPrevRes; // previous resistance value to multiply with rate of change
// because we change the base value mClosedResistance & mOpenResistance to recompute the system Matrix
// we need to save the initialisation values to use them as target values in the transition
Matrix mInitClosedRes;
Matrix mInitOpenRes;
Comment on lines +38 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve code style, explanatory \\\ comments are missing




public:
/// Defines UID, name, component parameters and logging level
varResSwitch(String uid, String name, Logger::Level logLevel = Logger::Level::off);
/// Defines name, component parameters and logging level
varResSwitch(String name, Logger::Level logLevel = Logger::Level::off)
: varResSwitch(name, name, logLevel) { }

SimPowerComp<Real>::Ptr clone(String name);

// #### General ####
void setInitParameters(Real timestep);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);

// #### General MNA section ####
void mnaCompInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector);
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix);
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix& rightVector);
/// Update interface voltage from MNA system result
void mnaCompUpdateVoltage(const Matrix& leftVector);
/// Update interface current from MNA system result
void mnaCompUpdateCurrent(const Matrix& leftVector);

// #### MNA section for switches ####
/// Check if switch is closed
Bool mnaIsClosed() { return isClosed(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required? Why not use of isClosed from Base::Ph3::Switch?

/// Stamps system matrix considering the defined switch position
void mnaCompApplySwitchSystemMatrixStamp(Bool closed, SparseMatrixRow& systemMatrix, Int freqIdx);

void mnaCompPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) override;

/// Add MNA post step dependencies
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) override;

Bool hasParameterChanged();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add override flag

};
}
}
}
1 change: 1 addition & 0 deletions dpsim-models/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ list(APPEND MODELS_SOURCES
EMT/EMT_Ph3_SynchronGeneratorIdeal.cpp
# EMT/EMT_Ph3_SynchronGeneratorVBRStandalone.cpp
EMT/EMT_Ph3_SynchronGeneratorTrStab.cpp
EMT/EMT_Ph3_varResSwitch.cpp

SP/SP_Ph1_VoltageSource.cpp
SP/SP_Ph1_Capacitor.cpp
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/src/DP/DP_Ph1_SynchronGeneratorTrStab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ void DP::Ph1::SynchronGeneratorTrStab::initializeFromNodesAndTerminals(Real freq
mSubVoltageSource->setVirtualNodeAt(mVirtualNodes[1], 0);
mSubVoltageSource->initialize(mFrequencies);
mSubVoltageSource->initializeFromNodesAndTerminals(frequency);
addMNASubComponent(mSubVoltageSource, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
addMNASubComponent(mSubVoltageSource, MNA_SUBCOMP_TASK_ORDER::TASK_AFTER_PARENT, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);

// Create sub inductor as Xpd
mSubInductor = DP::Ph1::Inductor::make(**mName + "_ind", mLogLevel);
mSubInductor->setParameters(mLpd);
mSubInductor->connect({mVirtualNodes[0], terminal(0)->node()});
mSubInductor->initialize(mFrequencies);
mSubInductor->initializeFromNodesAndTerminals(frequency);
addMNASubComponent(mSubInductor, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);
addMNASubComponent(mSubInductor, MNA_SUBCOMP_TASK_ORDER::TASK_AFTER_PARENT, MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT, true);

SPDLOG_LOGGER_INFO(mSLog, "\n--- Initialize according to powerflow ---"
"\nTerminal 0 voltage: {:e}<{:e}"
Expand Down
Loading