9 #include <dpsim-models/EMT/EMT_Ph3_SynchronGeneratorIdeal.h>
14 String uid, String name, Logger::Level logLevel,
15 CPS::GeneratorType sourceType)
17 mRefVoltage(mAttributes->createDynamic<MatrixComp>(
"V_ref")) {
18 mPhaseType = PhaseType::ABC;
19 mSourceType = sourceType;
21 if (mSourceType == CPS::GeneratorType::IdealVoltageSource)
22 setVirtualNodeNumber(1);
24 setVirtualNodeNumber(0);
32 Logger::Level logLevel)
36 return SynchronGeneratorIdeal::make(name, mLogLevel);
42 if (mSourceType == CPS::GeneratorType::IdealVoltageSource) {
44 EMT::Ph3::VoltageSource::make(**mName +
"_vs", mLogLevel);
45 addMNASubComponent(mSubVoltageSource,
46 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
47 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
50 EMT::Ph3::CurrentSource::make(**mName +
"_cs", mLogLevel);
51 addMNASubComponent(mSubCurrentSource,
52 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
53 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
56 mSubComponents[0]->connect({SimNode::GND, node(0)});
58 if (mSourceType == CPS::GeneratorType::IdealVoltageSource)
59 mSubComponents[0]->setVirtualNodeAt(mVirtualNodes[0], 0);
61 if (mSourceType == CPS::GeneratorType::IdealCurrentSource)
62 mSubComponents[0]->setTerminalAt(terminal(0), 1);
64 mSubComponents[0]->initialize(mFrequencies);
65 mSubComponents[0]->initializeFromNodesAndTerminals(frequency);
67 if (mSourceType == CPS::GeneratorType::IdealVoltageSource)
68 mRefVoltage->setReference(
69 mSubComponents[0]->attributeTyped<MatrixComp>(
"V_ref"));
71 SPDLOG_LOGGER_INFO(mSLog,
72 "\n--- Initialization from powerflow ---"
73 "\nTerminal 0 voltage: {:s}"
74 "\nTerminal 0 power: {:s}"
75 "\n--- Initialization from powerflow finished ---",
76 Logger::phasorToString(initialSingleVoltage(0)),
77 Logger::complexToString(terminal(0)->singlePower()));
81 AttributeBase::List &prevStepDependencies,
82 AttributeBase::List &attributeDependencies,
83 AttributeBase::List &modifiedAttributes) {
84 prevStepDependencies.push_back(mIntfCurrent);
85 prevStepDependencies.push_back(mIntfVoltage);
86 modifiedAttributes.push_back(mRightVector);
91 mnaCompApplyRightSideVectorStamp(**mRightVector);
95 AttributeBase::List &prevStepDependencies,
96 AttributeBase::List &attributeDependencies,
97 AttributeBase::List &modifiedAttributes,
99 attributeDependencies.push_back(leftVector);
100 modifiedAttributes.push_back(mIntfVoltage);
101 modifiedAttributes.push_back(mIntfCurrent);
106 mnaCompUpdateCurrent(**leftVector);
107 mnaCompUpdateVoltage(**leftVector);
111 const Matrix &leftvector) {
112 **mIntfCurrent = **mSubComponents[0]->mIntfCurrent;
116 const Matrix &leftVector) {
117 **mIntfVoltage = **mSubComponents[0]->mIntfVoltage;
Base class for composite power components.
Ideal voltage source representing a synchronous generator.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates current through the component.
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
Add MNA pre step dependencies.
void mnaParentPreStep(Real time, Int timeStepCount) override
MNA pre step operations.
SynchronGeneratorIdeal(String uid, String name, Logger::Level logLevel=Logger::Level::off, CPS::GeneratorType sourceType=CPS::GeneratorType::IdealVoltageSource)
Defines UID, name, component parameters and logging level.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates voltage across component.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
Base class for all components that are transmitting power.
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
Voltage between terminals.