9 #include <dpsim-models/SP/SP_Ph1_SolidStateTransformer.h>
13 SP::Ph1::SolidStateTransformer::SolidStateTransformer(String uid, String name,
14 Logger::Level logLevel)
16 mPref(mAttributes->create<Real>(
"P_ref",
17 std::numeric_limits<double>::infinity())),
18 mQ1ref(mAttributes->create<Real>(
"Q1_ref")),
19 mQ2ref(mAttributes->create<Real>(
"Q2_ref")) {
20 SPDLOG_LOGGER_INFO(mSLog,
"Create {} of type {}", **mName, this->type());
22 **mIntfVoltage = MatrixComp::Zero(1, 1);
23 **mIntfCurrent = MatrixComp::Zero(1, 1);
29 return SolidStateTransformer::make(name,
mLogLevel);
32 void SP::Ph1::SolidStateTransformer::setParameters(Real nomV1, Real nomV2,
33 Real Pref, Real Q1ref,
35 mNominalVoltageEnd1 = nomV1;
36 mNominalVoltageEnd2 = nomV2;
40 mP2 = -1 * std::sqrt(Pref * Pref + Q1ref * Q1ref - Q2ref * Q2ref);
46 if (std::isinf(mP2)) {
48 ss <<
"SST >>" << this->name()
49 <<
": infinite or nan values. Or initialized before setting parameters.";
50 throw std::invalid_argument(ss.str());
52 if ((**mPref * mP2) > 0) {
53 throw std::invalid_argument(
54 "power at primary and secondary sides should be opposite");
56 mSubLoadSide1 = Load::make(**mName +
"_subLoad1", mLogLevel);
57 mSubLoadSide1->setParameters(**mPref, **mQ1ref, mNominalVoltageEnd1);
58 mSubLoadSide2 = Load::make(**mName +
"_subLoad2", mLogLevel);
59 mSubLoadSide2->setParameters(mP2, **mQ2ref, mNominalVoltageEnd2);
60 mSubLoadSide1->connect({mTerminals[0]->node()});
61 mSubLoadSide2->connect({mTerminals[1]->node()});
63 addMNASubComponent(mSubLoadSide1, MNA_SUBCOMP_TASK_ORDER::NO_TASK,
64 MNA_SUBCOMP_TASK_ORDER::NO_TASK,
false);
65 addMNASubComponent(mSubLoadSide2, MNA_SUBCOMP_TASK_ORDER::NO_TASK,
66 MNA_SUBCOMP_TASK_ORDER::NO_TASK,
false);
68 SPDLOG_LOGGER_INFO(mSLog,
69 "\n--- Initialization from powerflow ---"
70 "\nTerminal 0 power flow: {:s} VA"
71 "\nTerminal 1 power flow: {:s} VA"
72 "\n--- Initialization from powerflow finished ---",
73 Logger::complexToString(Complex(**mPref, **mQ1ref)),
74 Logger::complexToString(Complex(mP2, **mQ2ref)));
77 void SP::Ph1::SolidStateTransformer::calculatePerUnitParameters(
78 Real baseApparentPower, Real baseOmega) {
79 mPref_perUnit = **mPref / baseApparentPower;
80 mP2_perUnit = mP2 / baseApparentPower;
81 mQ1ref_perUnit = **mQ1ref / baseApparentPower;
82 mQ2ref_perUnit = **mQ2ref / baseApparentPower;
83 mSubLoadSide1->calculatePerUnitParameters(baseApparentPower, baseOmega);
84 mSubLoadSide2->calculatePerUnitParameters(baseApparentPower, baseOmega);
87 "\n#### Calculate Per Unit Parameters for {}"
88 "\nTerminal 0 power flow: {:s} p.u."
89 "\nTerminal 1 power flow: {:s} p.u."
90 "\n#### Calculate Per Unit Parameters finished ---",
91 **mName, Logger::complexToString(Complex(mPref_perUnit, mQ1ref_perUnit)),
92 Logger::complexToString(Complex(mP2_perUnit, mQ2ref_perUnit)));
95 Complex SP::Ph1::SolidStateTransformer::getNodalInjection(
96 CPS::TopologicalNode::Ptr node) {
97 if (node->name() == mTerminals[0]->node()->name()) {
100 "\n#### get nodal injection for primary side"
101 "\nreturned {:s} p.u.",
102 Logger::complexToString(Complex(mPref_perUnit, mQ1ref_perUnit)));
103 return Complex(mPref_perUnit, mQ1ref_perUnit);
104 }
else if (node->name() == mTerminals[1]->node()->name()) {
107 "\n#### get nodal injection for secondary side"
108 "\nreturned {:s} p.u.",
109 Logger::complexToString(Complex(mP2_perUnit, mQ2ref_perUnit)));
110 return Complex(mP2_perUnit, mQ2ref_perUnit);
112 throw std::invalid_argument(
113 "Failed to process nodal power injection of Solid State Transformer" +
Base class for composite power components.
Base class for all components that are transmitting power.
Logger::Level mLogLevel
Component logger control for internal variables.