From 5c1ee8cca8c62cd72aebc2840c7b1f1d29bc1794 Mon Sep 17 00:00:00 2001 From: pipeacosta Date: Wed, 30 Oct 2024 08:43:05 +0000 Subject: [PATCH] Remove SP_Ph1_CurrentSource component. Signed-off-by: pipeacosta --- .../include/dpsim-models/Components.h | 1 - .../dpsim-models/SP/SP_Ph1_CurrentSource.h | 72 ------------ dpsim-models/src/CMakeLists.txt | 1 - dpsim-models/src/SP/SP_Ph1_CurrentSource.cpp | 111 ------------------ 4 files changed, 185 deletions(-) delete mode 100644 dpsim-models/include/dpsim-models/SP/SP_Ph1_CurrentSource.h delete mode 100644 dpsim-models/src/SP/SP_Ph1_CurrentSource.cpp diff --git a/dpsim-models/include/dpsim-models/Components.h b/dpsim-models/include/dpsim-models/Components.h index 7f9c3f4d4b..d92170fe28 100644 --- a/dpsim-models/include/dpsim-models/Components.h +++ b/dpsim-models/include/dpsim-models/Components.h @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/dpsim-models/include/dpsim-models/SP/SP_Ph1_CurrentSource.h b/dpsim-models/include/dpsim-models/SP/SP_Ph1_CurrentSource.h deleted file mode 100644 index 93782d7e3c..0000000000 --- a/dpsim-models/include/dpsim-models/SP/SP_Ph1_CurrentSource.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2017-2024 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 -#include -#include -#include - -namespace CPS { -namespace SP { -namespace Ph1 { -/// \brief Static phasor ideal current source -/// -/// A positive current is flowing out of node1 and into node2. -class CurrentSource : public MNASimPowerComp, - public SharedFactory { -public: - const Attribute::Ptr mCurrentRef; - /// Defines UID, name and logging level - CurrentSource(String uid, String name, - Logger::Level loglevel = Logger::Level::off); - /// Defines name and logging level - CurrentSource(String name, Logger::Level logLevel = Logger::Level::off) - : CurrentSource(name, name, logLevel) {} - /// Defines name, component parameters and logging level - CurrentSource(String name, Complex current, - Logger::Level logLevel = Logger::Level::off); - - void setParameters(Complex current); - - SimPowerComp::Ptr clone(String copySuffix) override; - - // #### General #### - /// Initializes component from power flow data - void initializeFromNodesAndTerminals(Real frequency) override; - - // #### MNA section #### - /// - void mnaCompInitialize(Real omega, Real timeStep, - Attribute::Ptr leftVector) override; - /// Stamps system matrix - void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override {} - /// Stamps right side (source) vector - void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override; - /// - void mnaCompUpdateVoltage(const Matrix &leftVector) override; - - /// Add MNA pre step dependencies - void - mnaCompAddPreStepDependencies(AttributeBase::List &prevStepDependencies, - AttributeBase::List &attributeDependencies, - AttributeBase::List &modifiedAttributes) override; - /// Add MNA post step dependencies - void - mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, - AttributeBase::List &attributeDependencies, - AttributeBase::List &modifiedAttributes, - Attribute::Ptr &leftVector) override; - void mnaCompPreStep(Real time, Int timeStepCount) override; - void mnaCompPostStep(Real time, Int timeStepCount, - Attribute::Ptr &leftVector) override; -}; -} // namespace Ph1 -} // namespace SP -} // namespace CPS diff --git a/dpsim-models/src/CMakeLists.txt b/dpsim-models/src/CMakeLists.txt index d432c6ce5d..795c44cd97 100644 --- a/dpsim-models/src/CMakeLists.txt +++ b/dpsim-models/src/CMakeLists.txt @@ -104,7 +104,6 @@ list(APPEND MODELS_SOURCES EMT/EMT_Ph3_SynchronGeneratorTrStab.cpp SP/SP_Ph1_VoltageSource.cpp - SP/SP_Ph1_CurrentSource.cpp SP/SP_Ph1_Capacitor.cpp SP/SP_Ph1_Inductor.cpp SP/SP_Ph1_Resistor.cpp diff --git a/dpsim-models/src/SP/SP_Ph1_CurrentSource.cpp b/dpsim-models/src/SP/SP_Ph1_CurrentSource.cpp deleted file mode 100644 index 0539b1a4f7..0000000000 --- a/dpsim-models/src/SP/SP_Ph1_CurrentSource.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright 2017-2024 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/. - *********************************************************************************/ - -#include - -using namespace CPS; - -SP::Ph1::CurrentSource::CurrentSource(String uid, String name, - Logger::Level logLevel) - : MNASimPowerComp(uid, name, true, true, logLevel), - mCurrentRef(mAttributes->createDynamic("I_ref")) { - setTerminalNumber(2); - **mIntfVoltage = MatrixComp::Zero(1, 1); - **mIntfCurrent = MatrixComp::Zero(1, 1); -} - -SP::Ph1::CurrentSource::CurrentSource(String name, Complex current, - Logger::Level logLevel) - : CurrentSource(name, logLevel) { - setParameters(current); -} - -void SP::Ph1::CurrentSource::setParameters(Complex current) { - **mCurrentRef = current; - mParametersSet = true; -} - -SimPowerComp::Ptr SP::Ph1::CurrentSource::clone(String name) { - auto copy = CurrentSource::make(name, mLogLevel); - copy->setParameters(**mCurrentRef); - return copy; -} - -void SP::Ph1::CurrentSource::initializeFromNodesAndTerminals(Real frequency) { - - (**mIntfVoltage)(0, 0) = initialSingleVoltage(0) - initialSingleVoltage(1); - (**mIntfCurrent)(0, 0) = **mCurrentRef; - - SPDLOG_LOGGER_INFO(mSLog, - "\n--- Initialization from powerflow ---" - "\nVoltage across: {:s}" - "\nCurrent: {:s}" - "\nTerminal 0 voltage: {:s}" - "\nTerminal 1 voltage: {:s}" - "\n--- Initialization from powerflow finished ---", - Logger::phasorToString((**mIntfVoltage)(0, 0)), - Logger::phasorToString((**mIntfCurrent)(0, 0)), - Logger::phasorToString(initialSingleVoltage(0)), - Logger::phasorToString(initialSingleVoltage(1))); -} - -void SP::Ph1::CurrentSource::mnaCompInitialize( - Real omega, Real timeStep, Attribute::Ptr leftVector) { - updateMatrixNodeIndices(); - (**mIntfCurrent)(0, 0) = **mCurrentRef; -} - -void SP::Ph1::CurrentSource::mnaCompAddPreStepDependencies( - AttributeBase::List &prevStepDependencies, - AttributeBase::List &attributeDependencies, - AttributeBase::List &modifiedAttributes) { - attributeDependencies.push_back(mCurrentRef); - modifiedAttributes.push_back(mRightVector); - modifiedAttributes.push_back(mIntfCurrent); -} - -void SP::Ph1::CurrentSource::mnaCompPreStep(Real time, Int timeStepCount) { - mnaCompApplyRightSideVectorStamp(**mRightVector); -} - -void SP::Ph1::CurrentSource::mnaCompApplyRightSideVectorStamp( - Matrix &rightVector) { - (**mIntfCurrent)(0, 0) = **mCurrentRef; - - if (terminalNotGrounded(0)) - Math::setVectorElement(rightVector, matrixNodeIndex(0), - -(**mIntfCurrent)(0, 0)); - if (terminalNotGrounded(1)) - Math::setVectorElement(rightVector, matrixNodeIndex(1), - (**mIntfCurrent)(0, 0)); -} - -void SP::Ph1::CurrentSource::mnaCompAddPostStepDependencies( - AttributeBase::List &prevStepDependencies, - AttributeBase::List &attributeDependencies, - AttributeBase::List &modifiedAttributes, - Attribute::Ptr &leftVector) { - attributeDependencies.push_back(leftVector); - modifiedAttributes.push_back(mIntfVoltage); -} - -void SP::Ph1::CurrentSource::mnaCompPostStep( - Real time, Int timeStepCount, Attribute::Ptr &leftVector) { - mnaCompUpdateVoltage(**leftVector); -} - -void SP::Ph1::CurrentSource::mnaCompUpdateVoltage(const Matrix &leftVector) { - (**mIntfVoltage)(0, 0) = 0; - if (terminalNotGrounded(0)) - (**mIntfVoltage)(0, 0) = - Math::complexFromVectorElement(leftVector, matrixNodeIndex(0)); - if (terminalNotGrounded(1)) - (**mIntfVoltage)(0, 0) = - (**mIntfVoltage)(0, 0) - - Math::complexFromVectorElement(leftVector, matrixNodeIndex(1)); -}