DPsim
Loading...
Searching...
No Matches
DP_Ph1_RxLine.cpp
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
10
11using namespace CPS;
12
15 CompositePowerComp<Complex>(uid, name, true, true, logLevel) {
18
19 SPDLOG_LOGGER_INFO(mSLog, "Create {} {}", this->type(), name);
20 **mIntfVoltage = MatrixComp::Zero(1, 1);
21 **mIntfCurrent = MatrixComp::Zero(1, 1);
22}
23
26 auto copy = RxLine::make(name, mLogLevel);
27 copy->setParameters(**mSeriesRes, **mSeriesInd);
28 return copy;
29}
30
33 return;
34 mSubCompCreated = true;
35
37 std::make_shared<DP::Ph1::Resistor>(**mName + "_res", mLogLevel);
38 mSubResistor->setParameters(**mSeriesRes);
39 mSubResistor->connect({mTerminals[0]->node(), mVirtualNodes[0]});
42
44 std::make_shared<DP::Ph1::Inductor>(**mName + "_ind", mLogLevel);
45 mSubInductor->setParameters(**mSeriesInd);
46 mSubInductor->connect({mVirtualNodes[0], mTerminals[1]->node()});
49
51 std::make_shared<DP::Ph1::Resistor>(**mName + "_snubber_res", mLogLevel);
52 mInitialResistor->setParameters(1e6);
53 mInitialResistor->connect({SimNode::GND, mTerminals[1]->node()});
57}
58
60 (**mIntfVoltage)(0, 0) = initialSingleVoltage(1) - initialSingleVoltage(0);
61 (**mIntfCurrent)(0, 0) = 0;
62 mVirtualNodes[0]->setInitialVoltage(initialSingleVoltage(0) +
63 (**mIntfCurrent)(0, 0) * **mSeriesRes);
64
65 SPDLOG_LOGGER_INFO(mSLog,
66 "\n--- Initialization from powerflow ---"
67 "\nVoltage across: {:s}"
68 "\nCurrent: {:s}"
69 "\nTerminal 0 voltage: {:s}"
70 "\nTerminal 1 voltage: {:s}"
71 "\n--- Initialization from powerflow finished ---",
76}
77
81
83 AttributeBase::List &prevStepDependencies,
84 AttributeBase::List &attributeDependencies,
85 AttributeBase::List &modifiedAttributes) {
86 modifiedAttributes.push_back(mRightVector);
87}
88
90 AttributeBase::List &prevStepDependencies,
91 AttributeBase::List &attributeDependencies,
92 AttributeBase::List &modifiedAttributes,
93 Attribute<Matrix>::Ptr &leftVector) {
94 attributeDependencies.push_back(leftVector);
95 modifiedAttributes.push_back(mIntfCurrent);
96 modifiedAttributes.push_back(mIntfVoltage);
97}
98
100 Attribute<Matrix>::Ptr &leftVector) {
101 mnaCompUpdateVoltage(**leftVector);
102 mnaCompUpdateCurrent(**leftVector);
103}
104
106 (**mIntfVoltage)(0, 0) = 0;
107 if (terminalNotGrounded(1))
108 (**mIntfVoltage)(0, 0) =
110 if (terminalNotGrounded(0))
111 (**mIntfVoltage)(0, 0) =
112 (**mIntfVoltage)(0, 0) -
114}
115
117 (**mIntfCurrent)(0, 0) = mSubInductor->intfCurrent()(0, 0);
118}
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:250
PiLine(CPS::AttributeList::Ptr attributeList)
const Attribute< Real >::Ptr mSeriesInd
Inductance along the line [H].
const Attribute< Real >::Ptr mSeriesRes
Resistance along the line [ohms].
void addMNASubComponent(typename SimPowerComp< Complex >::Ptr subc, MNA_SUBCOMP_TASK_ORDER preStepOrder, MNA_SUBCOMP_TASK_ORDER postStepOrder, Bool contributeToRightVector)
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override
CompositePowerComp(String uid, String name, Bool hasPreStep, Bool hasPostStep, Logger::Level logLevel)
void mnaCompUpdateVoltage(const Matrix &leftVector) override
void initializeParentFromNodesAndTerminals(Real frequency) override
Derives values from power flow data and pushes them to subcomponents.
std::shared_ptr< Resistor > mSubResistor
Resistor submodel.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
SimPowerComp< Complex >::Ptr clone(String name) override
DEPRECATED: Delete method.
std::shared_ptr< Inductor > mSubInductor
Inductance submodel.
std::shared_ptr< Resistor > mInitialResistor
Inductor end to ground resistor to facilitate initialization.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre and post step operations.
void createSubComponents() override
Constructs and registers MNA subcomponents; idempotent.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
RxLine(String uid, String name, Logger::Level logLevel=Logger::Level::off)
True after createSubComponents() runs; prevents double-construction.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
const Attribute< String >::Ptr mName
Human readable name.
String uid()
Returns unique id.
String type()
Get component type (cross-platform)
AttributeList::Ptr mAttributes
Attribute List.
spdlog::level::level_enum Level
Definition Logger.h:33
static String phasorToString(const Complex &num)
Definition Logger.cpp:57
Attribute< Matrix >::Ptr mRightVector
static Complex complexFromVectorElement(const Matrix &mat, Matrix::Index row, Int maxFreq=1, Int freqIdx=0)
Definition MathUtils.cpp:94
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
SimTerminal< Complex >::List mTerminals
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
std::shared_ptr< SimPowerComp< VarType > > Ptr
SimNode< Complex >::List mVirtualNodes
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(UInt index)
Logger::Level mLogLevel
Component logger control for internal variables.
Logger::Log mSLog
Component logger.
static std::shared_ptr< RxLine > make(Args &&...args)
Definition PtrFactory.h:19
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Definition Definitions.h:81
std::string String
Definition Definitions.h:65
double Real
Definition Definitions.h:62
int Int
Definition Definitions.h:61
std::complex< Real > Complex
Definition Definitions.h:63