9 #include <dpsim-models/DP/DP_Ph1_SynchronGeneratorIdeal.h>
14 Logger::Level logLevel)
16 mVoltageRef(mAttributes->createDynamic<Complex>(
"V_ref")) {
17 setVirtualNodeNumber(1);
24 Logger::Level logLevel)
28 return SynchronGeneratorIdeal::make(name, mLogLevel);
33 mSubVoltageSource = DP::Ph1::VoltageSource::make(**mName +
"_src", mLogLevel);
34 mSubVoltageSource->mVoltageRef->setReference(mVoltageRef);
35 mSubVoltageSource->connect({SimNode::GND, node(0)});
36 mSubVoltageSource->setVirtualNodeAt(mVirtualNodes[0], 0);
37 mSubVoltageSource->initialize(mFrequencies);
38 mSubVoltageSource->initializeFromNodesAndTerminals(frequency);
39 addMNASubComponent(mSubVoltageSource,
40 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
41 MNA_SUBCOMP_TASK_ORDER::TASK_BEFORE_PARENT,
true);
43 SPDLOG_LOGGER_INFO(mSLog,
44 "\n--- Initialization from powerflow ---"
45 "\nVoltage across: {:s}"
47 "\nTerminal 0 voltage: {:s}"
48 "\n--- Initialization from powerflow finished ---",
49 Logger::phasorToString((**mIntfVoltage)(0, 0)),
50 Logger::phasorToString((**mIntfCurrent)(0, 0)),
51 Logger::phasorToString(initialSingleVoltage(0)));
55 AttributeBase::List &prevStepDependencies,
56 AttributeBase::List &attributeDependencies,
57 AttributeBase::List &modifiedAttributes) {
58 prevStepDependencies.push_back(mIntfCurrent);
59 prevStepDependencies.push_back(mIntfVoltage);
60 modifiedAttributes.push_back(mRightVector);
65 mnaCompApplyRightSideVectorStamp(**mRightVector);
69 AttributeBase::List &prevStepDependencies,
70 AttributeBase::List &attributeDependencies,
71 AttributeBase::List &modifiedAttributes,
73 attributeDependencies.push_back(leftVector);
74 modifiedAttributes.push_back(mIntfVoltage);
75 modifiedAttributes.push_back(mIntfCurrent);
80 mnaCompUpdateCurrent(**leftVector);
81 mnaCompUpdateVoltage(**leftVector);
85 const Matrix &leftvector) {
86 **mIntfCurrent = **mSubComponents[0]->mIntfCurrent;
90 const Matrix &leftVector) {
91 **mIntfVoltage = **mSubComponents[0]->mIntfVoltage;
Base class for composite power components.
Ideal voltage source representing a synchronous generator.
SynchronGeneratorIdeal(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Defines UID, name, component parameters and logging level.
void initializeFromNodesAndTerminals(Real frequency) override
Initializes component from power flow data.
void mnaCompUpdateVoltage(const Matrix &leftVector) override
Updates voltage across component.
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.
SimPowerComp< Complex >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
MNA post step operations.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
Add MNA post step dependencies.
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Updates current through the component.
Base class for all components that are transmitting power.
const Attribute< MatrixVar< Complex > >::Ptr mIntfCurrent
Current through component.
const Attribute< MatrixVar< Complex > >::Ptr mIntfVoltage
Voltage between terminals.