DPsim
Loading...
Searching...
No Matches
EMT_Ph3_GFL.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
4#include <cmath>
5#include <stdexcept>
6
9
10using namespace CPS;
11
13 : CompositePowerComp<Real>(uid, name, true, true, logLevel),
14 mVcd(mAttributes->create<Real>("vc_d", 0.0)),
15 mVcq(mAttributes->create<Real>("vc_q", 0.0)),
16 mIgridD(mAttributes->create<Real>("igrid_d", 0.0)),
17 mIgridQ(mAttributes->create<Real>("igrid_q", 0.0)),
18 mPInst(mAttributes->create<Real>("p_inst", 0.0)),
19 mQInst(mAttributes->create<Real>("q_inst", 0.0)),
20 mOmegaPLL(mAttributes->create<Real>("omega_pll", 0.0)),
21 mVsref(mAttributes->create<Matrix>("vs_ref", Matrix::Zero(3, 1))),
22 mVs(mAttributes->createDynamic<Matrix>("vs")),
23 mPllOutput(mAttributes->createDynamic<Matrix>("pll_output")),
24 mPowerctrlInputs(mAttributes->createDynamic<Matrix>("powerctrl_inputs")),
26 mAttributes->createDynamic<Matrix>("powerctrl_outputs")),
27 mPowerctrlStates(mAttributes->createDynamic<Matrix>("powerctrl_states")) {
28
30
31 // Two internal nodes are used for source, resistor, and inductor connection.
34
35 **mIntfVoltage = Matrix::Zero(3, 1);
36 **mIntfCurrent = Matrix::Zero(3, 1);
37
38 SPDLOG_LOGGER_INFO(mSLog, "Create {} {}", type(), name);
39
40 // -------------------------------------------------------------------------
41 // Electrical subcomponents
42 // -------------------------------------------------------------------------
45
47
49
51
54
57
60
61 // The controlled voltage source pre-step is handled explicitly by the
62 // parent so its voltage reference can be updated immediately beforehand.
66
67 // -------------------------------------------------------------------------
68 // Control subcomponents
69 // -------------------------------------------------------------------------
71
73 **mName + "_PowerControllerVSI", mLogLevel);
74
75 // Actual internal source voltage for logging.
76 mVs->setReference(mSubControlledVoltageSource->mIntfVoltage);
77
78 // PLL input is the PCC q-axis voltage.
79 mPLL->mInputRef->setReference(mVcq);
80 mPllOutput->setReference(mPLL->mOutputCurr);
81
82 // Power controller measurements:
83 // Vc = PCC voltage
84 // Igrid = positive converter-to-grid current
85 mPowerControllerVSI->mVc_d->setReference(mVcd);
86 mPowerControllerVSI->mVc_q->setReference(mVcq);
87 mPowerControllerVSI->mIrc_d->setReference(mIgridD);
88 mPowerControllerVSI->mIrc_q->setReference(mIgridQ);
89
90 mPowerctrlInputs->setReference(mPowerControllerVSI->mInputCurr);
91 mPowerctrlStates->setReference(mPowerControllerVSI->mStateCurr);
92 mPowerctrlOutputs->setReference(mPowerControllerVSI->mOutputCurr);
93}
94
96 auto copy = GFL::make(name, mLogLevel);
97
98 copy->setParameters(mOmegaN, mVnom, mPRef, mQRef);
99
100 copy->setControllerParameters(mKpPLL, mKiPLL, mKpPowerCtrl, mKiPowerCtrl,
102
103 copy->setFilterParameters(mLf, mCf, mRf);
104
106 copy->setInitialStateValues(mPInitManual, mQInitManual, mPhiDInitManual,
109 }
110
111 copy->withControl(mWithControl);
112
113 return copy;
114}
115
116void EMT::Ph3::GFL::setParameters(Real sysOmega, Real sysVoltNom, Real pRef,
117 Real qRef) {
118
119 if (!Math::isFinite(sysOmega) || !Math::isFinite(sysVoltNom) ||
120 !Math::isFinite(pRef) || !Math::isFinite(qRef))
121 throw std::invalid_argument("GFL parameters must be finite.");
122
123 if (sysOmega <= 0.0)
124 throw std::invalid_argument(
125 "GFL nominal angular frequency must be positive.");
126
127 if (sysVoltNom <= 0.0)
128 throw std::invalid_argument("GFL nominal voltage must be positive.");
129
130 mOmegaN = sysOmega;
131 mVnom = sysVoltNom;
132 mPRef = pRef;
133 mQRef = qRef;
134
135 mPowerControllerVSI->setParameters(mPRef, mQRef);
136
137 mParametersSet = true;
138
139 SPDLOG_LOGGER_INFO(mSLog,
140 "GFL general parameters:"
141 "\n V_nom = {} V"
142 "\n omega_nom = {} rad/s"
143 "\n P_ref = {} W"
144 "\n Q_ref = {} var",
146}
147
149 Real kpPowerCtrl, Real kiPowerCtrl,
150 Real kpCurrCtrl, Real kiCurrCtrl,
151 Real omegaCutoff) {
152
153 if (!mParametersSet)
154 throw std::logic_error("GFL::setParameters() must be called before "
155 "setControllerParameters().");
156
157 if (!Math::isFinite(kpPLL) || !Math::isFinite(kiPLL) ||
158 !Math::isFinite(kpPowerCtrl) || !Math::isFinite(kiPowerCtrl) ||
159 !Math::isFinite(kpCurrCtrl) || !Math::isFinite(kiCurrCtrl) ||
160 !Math::isFinite(omegaCutoff))
161 throw std::invalid_argument("GFL controller parameters must be finite.");
162
163 if (kiPLL == 0.0)
164 throw std::invalid_argument("GFL PLL integral gain must be non-zero.");
165
166 if (kiPowerCtrl == 0.0)
167 throw std::invalid_argument(
168 "GFL power-controller integral gain must be non-zero.");
169
170 if (kiCurrCtrl == 0.0)
171 throw std::invalid_argument(
172 "GFL current-controller integral gain must be non-zero.");
173
174 if (omegaCutoff <= 0.0)
175 throw std::invalid_argument(
176 "GFL power-filter cutoff frequency must be positive.");
177
178 mKpPLL = kpPLL;
179 mKiPLL = kiPLL;
180
181 mKpPowerCtrl = kpPowerCtrl;
182 mKiPowerCtrl = kiPowerCtrl;
183
184 mKpCurrCtrl = kpCurrCtrl;
185 mKiCurrCtrl = kiCurrCtrl;
186
187 mOmegaCutoff = omegaCutoff;
188
189 // Fix relative to the legacy class:
190 // PLL nominal frequency is omega_nom, NOT the power-filter cutoff.
191 mPLL->setParameters(mKpPLL, mKiPLL, mOmegaN);
192 mPLL->composeStateSpaceMatrices();
193
194 mPowerControllerVSI->setControllerParameters(
196
198}
199
201
202 if (!Math::isFinite(lf) || !Math::isFinite(cf) || !Math::isFinite(rf))
203 throw std::invalid_argument("GFL filter parameters must be finite.");
204
205 if (lf <= 0.0)
206 throw std::invalid_argument("GFL filter inductance Lf must be positive.");
207
208 if (cf <= 0.0)
209 throw std::invalid_argument("GFL filter capacitance Cf must be positive.");
210
211 if (rf < 0.0)
212 throw std::invalid_argument(
213 "GFL filter resistance Rf must be non-negative.");
214
215 mLf = lf;
216 mCf = cf;
217 mRf = rf;
218
220
222
224
226
227 SPDLOG_LOGGER_INFO(mSLog,
228 "GFL filter parameters:"
229 "\n Lf = {} H"
230 "\n Cf = {} F"
231 "\n Rf = {} Ohm"
232 "\n Rc = removed",
233 mLf, mCf, mRf);
234}
235
237 Real phiQInit, Real gammaDInit,
238 Real gammaQInit) {
239
240 if (!Math::isFinite(pInit) || !Math::isFinite(qInit) ||
241 !Math::isFinite(phiDInit) || !Math::isFinite(phiQInit) ||
242 !Math::isFinite(gammaDInit) || !Math::isFinite(gammaQInit))
243 throw std::invalid_argument("GFL initial state values must be finite.");
244
245 mPInitManual = pInit;
246 mQInitManual = qInit;
247 mPhiDInitManual = phiDInit;
248 mPhiQInitManual = phiQInit;
249 mGammaDInitManual = gammaDInit;
250 mGammaQInitManual = gammaQInit;
251
253
254 mPowerControllerVSI->setInitialStateValues(pInit, qInit, phiDInit, phiQInit,
255 gammaDInit, gammaQInit);
256}
257
259
260 Matrix transform = Matrix::Zero(2, 3);
261
262 const Real k = std::sqrt(2.0 / 3.0);
263
264 transform << k * std::cos(theta), k * std::cos(theta - 2.0 * PI / 3.0),
265 k * std::cos(theta + 2.0 * PI / 3.0),
266
267 -k * std::sin(theta), -k * std::sin(theta - 2.0 * PI / 3.0),
268 -k * std::sin(theta + 2.0 * PI / 3.0);
269
270 return transform;
271}
272
273Matrix
275
276 Matrix transform = Matrix::Zero(3, 2);
277
278 const Real k = std::sqrt(2.0 / 3.0);
279
280 transform << k * std::cos(theta), -k * std::sin(theta),
281
282 k * std::cos(theta - 2.0 * PI / 3.0),
283 -k * std::sin(theta - 2.0 * PI / 3.0),
284
285 k * std::cos(theta + 2.0 * PI / 3.0),
286 -k * std::sin(theta + 2.0 * PI / 3.0);
287
288 return transform;
289}
290
292 const Matrix &fabc) const {
293
294 return getParkTransformMatrixPowerInvariant(theta) * fabc;
295}
296
297Matrix
303
305
306 // Correct voltage measurement:
307 // capacitor voltage == PCC voltage because Rc has been removed and Cf is
308 // connected directly at the external terminal.
309 const Matrix vPccAbc = **mIntfVoltage;
310
311 // Correct current measurement:
312 // mIntfCurrent follows DPsim's component convention and points from the
313 // external network into the converter. The GFL controller uses positive
314 // converter-to-grid injection.
315 const Matrix iGridAbc = -**mIntfCurrent;
316
317 const Matrix vDq = parkTransformPowerInvariant(theta, vPccAbc);
318
319 const Matrix iDq = parkTransformPowerInvariant(theta, iGridAbc);
320
321 **mVcd = vDq(0, 0);
322 **mVcq = vDq(1, 0);
323
324 **mIgridD = iDq(0, 0);
325 **mIgridQ = iDq(1, 0);
326}
327
329 **mPInst = **mVcd * **mIgridD + **mVcq * **mIgridQ;
330
331 **mQInst = -**mVcd * **mIgridQ + **mVcq * **mIgridD;
332
333 // PLL output is [theta, phi_pll].
334 const Real phiPLL = (**mPllOutput)(1, 0);
335
336 **mOmegaPLL = mOmegaN + mKpPLL * **mVcq + mKiPLL * phiPLL;
337}
338
340
341 if (!mParametersSet)
342 throw std::logic_error(
343 "GFL::setParameters() must be called before initialization.");
344
346 throw std::logic_error(
347 "GFL::setFilterParameters() must be called before initialization.");
348
350 throw std::logic_error(
351 "GFL::setControllerParameters() must be called before initialization.");
352
353 const Real omega = 2.0 * PI * frequency;
354
355 const Complex j(0.0, 1.0);
356
357 // -------------------------------------------------------------------------
358 // PCC voltage from power flow
359 // -------------------------------------------------------------------------
360 MatrixComp vPcc = MatrixComp::Zero(3, 1);
361
362 vPcc(0, 0) = RMS3PH_TO_PEAK1PH * initialSingleVoltage(0);
363
364 vPcc(1, 0) = vPcc(0, 0) * SHIFT_TO_PHASE_B;
365
366 vPcc(2, 0) = vPcc(0, 0) * SHIFT_TO_PHASE_C;
367
368 if (std::abs(vPcc(0, 0)) < 1e-12)
369 throw std::runtime_error("GFL cannot initialize from zero PCC voltage.");
370
371 // -------------------------------------------------------------------------
372 // Positive converter-to-grid current from requested P/Q
373 // -------------------------------------------------------------------------
374 const Complex sRef(mPRef, mQRef);
375
376 const Complex iGridA = std::conj((2.0 / 3.0) * sRef / vPcc(0, 0));
377
378 MatrixComp iGrid = MatrixComp::Zero(3, 1);
379
380 iGrid(0, 0) = iGridA;
381 iGrid(1, 0) = iGridA * SHIFT_TO_PHASE_B;
382 iGrid(2, 0) = iGridA * SHIFT_TO_PHASE_C;
383
384 // Filter steady state.
385 const MatrixComp iCf = j * omega * mCf * vPcc;
386
387 const MatrixComp iF = iGrid + iCf;
388
389 const MatrixComp vInductorInput = vPcc + j * omega * mLf * iF;
390
391 const MatrixComp vSource = vInductorInput + mRf * iF;
392
393 // Parent virtual nodes.
394 mVirtualNodes[0]->setInitialVoltage(PEAK1PH_TO_RMS3PH * vSource);
395
396 mVirtualNodes[1]->setInitialVoltage(PEAK1PH_TO_RMS3PH * vInductorInput);
397
398 // Parent external interface.
399 **mIntfVoltage = vPcc.real();
400
401 // DPsim interface current points from grid into component.
402 **mIntfCurrent = -iGrid.real();
403
404 // -------------------------------------------------------------------------
405 // Controlled source
406 // -------------------------------------------------------------------------
408 0.0);
409
411
412 mSubResistorF->connect({mVirtualNodes[0], mVirtualNodes[1]});
413
414 mSubInductorF->connect({mVirtualNodes[1], mTerminals[0]->node()});
415
416 mSubCapacitorF->connect({mTerminals[0]->node(), SimNode::GND});
417
418 // Subcomponents are initialized recursively by CompositePowerComp.
419
420 // -------------------------------------------------------------------------
421 // Controller steady-state initialization
422 // -------------------------------------------------------------------------
423 const Real theta0 = std::arg(vPcc(0, 0));
424
425 const Matrix vPccAbc0 = vPcc.real();
426
427 const Matrix iGridAbc0 = iGrid.real();
428
429 const Matrix vSourceAbc0 = vSource.real();
430
431 const Matrix vDq0 = parkTransformPowerInvariant(theta0, vPccAbc0);
432
433 const Matrix iDq0 = parkTransformPowerInvariant(theta0, iGridAbc0);
434
435 const Matrix vSourceDq0 = parkTransformPowerInvariant(theta0, vSourceAbc0);
436
437 **mVcd = vDq0(0, 0);
438
439 **mVcq = vDq0(1, 0);
440
441 **mIgridD = iDq0(0, 0);
442
443 **mIgridQ = iDq0(1, 0);
444
445 const Real pInit = **mVcd * **mIgridD + **mVcq * **mIgridQ;
446
447 const Real qInit = -**mVcd * **mIgridQ + **mVcq * **mIgridD;
448
449 // PLL state = [theta, phi_pll].
450 Matrix pllStateInit = Matrix::Zero(2, 1);
451
452 Matrix pllOutputInit = Matrix::Zero(2, 1);
453
454 pllStateInit(0, 0) = theta0;
455
456 pllStateInit(1, 0) = (omega - mOmegaN) / mKiPLL;
457
458 pllOutputInit = pllStateInit;
459
460 mPLL->setInitialValues(**mVcq, pllStateInit, pllOutputInit);
461
463 // Choose controller integrators so that:
464 // i_ref_dq = i_grid_dq
465 // v_ref_dq = required steady-state source voltage.
466 const Real phiDInit =
467 (**mIgridD + mKpPowerCtrl * (pInit - mPRef)) / mKiPowerCtrl;
468
469 const Real phiQInit =
470 (**mIgridQ - mKpPowerCtrl * (qInit - mQRef)) / mKiPowerCtrl;
471
472 const Real iRefD = mKpPowerCtrl * (mPRef - pInit) + mKiPowerCtrl * phiDInit;
473
474 const Real iRefQ = mKpPowerCtrl * (qInit - mQRef) + mKiPowerCtrl * phiQInit;
475
476 const Real gammaDInit =
477 (vSourceDq0(0, 0) + mKpCurrCtrl * (**mIgridD - iRefD)) / mKiCurrCtrl;
478
479 const Real gammaQInit =
480 (vSourceDq0(1, 0) + mKpCurrCtrl * (**mIgridQ - iRefQ)) / mKiCurrCtrl;
481
482 mPowerControllerVSI->setInitialStateValues(pInit, qInit, phiDInit, phiQInit,
483 gammaDInit, gammaQInit);
484 }
485
486 // Avoid a zero source command before the first mnaParentPreStep().
487 **mVsref = vSourceAbc0;
488
490
491 SPDLOG_LOGGER_INFO(
492 mSLog,
493 "\n--- EMT_Ph3_GFL initialization ---"
494 "\nPCC voltage abc: {:s}"
495 "\nGrid injection abc: {:s}"
496 "\nFilter current abc: {:s}"
497 "\nSource voltage abc: {:s}"
498 "\nP/Q init: [{:.6e}, {:.6e}]"
499 "\nVc dq: [{:.6e}, {:.6e}]"
500 "\nIgrid dq: [{:.6e}, {:.6e}]"
501 "\n--- Initialization finished ---",
503 Logger::matrixToString(iF.real()), Logger::matrixToString(vSourceAbc0),
504 pInit, qInit, **mVcd, **mVcq, **mIgridD, **mIgridQ);
505}
506
508 Attribute<Matrix>::Ptr leftVector) {
509
510 mTimeStep = timeStep;
511
512 // Initialize power controller first. Its initial output is the desired
513 // source voltage in dq when the automatically computed states are used.
514 mPowerControllerVSI->initializeStateSpaceModel(omega, timeStep, leftVector);
515
516 // PowerControllerVSI::initializeStateSpaceModel() currently assigns its
517 // internal cutoff member from the system omega argument. Restore the
518 // explicitly configured controller cutoff so this GFL also works correctly
519 // when omegaCutoff != omega_nom.
520 mPowerControllerVSI->setControllerParameters(
522
523 mPLL->setSimulationParameters(timeStep);
524
525 // Keep the PF-derived source-voltage command from initialization.
527
528 mMnaTasks.push_back(std::make_shared<ControlPreStep>(*this));
529
530 mMnaTasks.push_back(std::make_shared<ControlStep>(*this));
531}
532
534 AttributeBase::List &prevStepDependencies,
535 AttributeBase::List &attributeDependencies,
536 AttributeBase::List &modifiedAttributes) {
537
538 mPLL->signalAddPreStepDependencies(prevStepDependencies,
539 attributeDependencies, modifiedAttributes);
540
541 mPowerControllerVSI->signalAddPreStepDependencies(
542 prevStepDependencies, attributeDependencies, modifiedAttributes);
543}
544
545void EMT::Ph3::GFL::controlPreStep(Real time, Int timeStepCount) {
546
547 mPLL->signalPreStep(time, timeStepCount);
548
549 mPowerControllerVSI->signalPreStep(time, timeStepCount);
550}
551
553 AttributeBase::List &prevStepDependencies,
554 AttributeBase::List &attributeDependencies,
555 AttributeBase::List &modifiedAttributes) {
556
557 // Measurements are updated inside controlStep() to avoid scheduler cycles.
558 mPLL->signalAddStepDependencies(prevStepDependencies, attributeDependencies,
559 modifiedAttributes);
560
561 mPowerControllerVSI->signalAddStepDependencies(
562 prevStepDependencies, attributeDependencies, modifiedAttributes);
563
564 // The control calculation needs the solved PCC quantities from the network.
565 attributeDependencies.push_back(mIntfCurrent);
566
567 attributeDependencies.push_back(mIntfVoltage);
568
569 // Only the externally consumed controller output is a scheduler-visible
570 // modification of this parent task.
571 modifiedAttributes.push_back(mVsref);
572}
573
574void EMT::Ph3::GFL::controlStep(Real time, Int timeStepCount) {
575
576 // Predict PLL angle to the measurement instant.
577 Real thetaMeasurement = mPLL->mOutputPrev->get()(0, 0);
578
579 if (timeStepCount > 0) {
580 const Real phiPLLPrev = mPLL->mOutputPrev->get()(1, 0);
581
582 const Real omegaPLLPrev = mOmegaN + mKpPLL * **mVcq + mKiPLL * phiPLLPrev;
583
584 thetaMeasurement += mTimeStep * omegaPLLPrev;
585 }
586
587 updateMeasurementAttributes(thetaMeasurement);
588
589 // Update PLL and cascaded P/Q-current controller.
590 mPLL->signalStep(time, timeStepCount);
591
592 mPowerControllerVSI->signalStep(time, timeStepCount);
593
594 // Rotate the command to the next EMT sample.
595 const Real thetaPLL = (**mPllOutput)(0, 0);
596
597 const Real phiPLL = (**mPllOutput)(1, 0);
598
599 const Real omegaPLL = mOmegaN + mKpPLL * **mVcq + mKiPLL * phiPLL;
600
601 const Real thetaCommand = thetaPLL + mTimeStep * omegaPLL;
602
603 **mVsref =
605
607}
608
610 AttributeBase::List &prevStepDependencies,
611 AttributeBase::List &attributeDependencies,
612 AttributeBase::List &modifiedAttributes) {
613
614 prevStepDependencies.push_back(mVsref);
615
616 prevStepDependencies.push_back(mIntfCurrent);
617
618 prevStepDependencies.push_back(mIntfVoltage);
619
620 attributeDependencies.push_back(mPowerControllerVSI->mOutputPrev);
621
622 attributeDependencies.push_back(mPLL->mOutputPrev);
623
624 modifiedAttributes.push_back(mRightVector);
625}
626
627void EMT::Ph3::GFL::mnaParentPreStep(Real time, Int timeStepCount) {
628
629 if (mWithControl) {
630 // VoltageSource::mVoltageRef uses RMS line-line-equivalent scaling,
631 // whereas mVsref stores instantaneous phase-peak abc values.
633 }
634
635 std::dynamic_pointer_cast<MNAInterface>(mSubControlledVoltageSource)
636 ->mnaPreStep(time, timeStepCount);
637
639}
640
642 AttributeBase::List &prevStepDependencies,
643 AttributeBase::List &attributeDependencies,
644 AttributeBase::List &modifiedAttributes,
645 Attribute<Matrix>::Ptr &leftVector) {
646
647 attributeDependencies.push_back(leftVector);
648
649 modifiedAttributes.push_back(mIntfVoltage);
650
651 modifiedAttributes.push_back(mIntfCurrent);
652}
653
655 Attribute<Matrix>::Ptr &leftVector) {
656
657 // Subcomponent post-step tasks run before the parent, so the inductor current
658 // has already been updated when this executes.
659 mnaCompUpdateCurrent(**leftVector);
660
661 mnaCompUpdateVoltage(**leftVector);
662}
663
665
666 // Net current entering the complete converter component.
667 **mIntfCurrent =
668 mSubInductorF->mIntfCurrent->get() - mSubCapacitorF->mIntfCurrent->get();
669}
670
672
673 for (auto virtualNode : mVirtualNodes)
674 virtualNode->mnaUpdateVoltage(leftVector);
675
676 **mIntfVoltage = Matrix::Zero(3, 1);
677
678 if (terminalNotGrounded(0)) {
679 (**mIntfVoltage)(0, 0) =
681
682 (**mIntfVoltage)(1, 0) =
684
685 (**mIntfVoltage)(2, 0) =
687 }
688}
std::vector< Ptr > List
Definition Attribute.h:123
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
void addMNASubComponent(typename SimPowerComp< Real >::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)
Matrix parkTransformPowerInvariant(Real theta, const Matrix &fabc) const
void setInitialStateValues(Real pInit, Real qInit, Real phiDInit, Real phiQInit, Real gammaDInit, Real gammaQInit)
const Attribute< Real >::Ptr mIgridQ
const Attribute< Matrix >::Ptr mPowerctrlStates
const Attribute< Matrix >::Ptr mPowerctrlInputs
Power-controller logging vectors.
void controlPreStep(Real time, Int timeStepCount)
void mnaParentPreStep(Real time, Int timeStepCount) override
void updateMeasurementAttributes(Real theta)
void addControlStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes)
SimPowerComp< Real >::Ptr clone(String name) override
Returns a modified copy of the component with the given suffix added to the name and without.
Matrix inverseParkTransformPowerInvariant(Real theta, const Matrix &fdq) const
void mnaCompUpdateCurrent(const Matrix &leftVector) override
Matrix getInverseParkTransformMatrixPowerInvariant(Real theta) const
void mnaCompUpdateVoltage(const Matrix &leftVector) override
std::shared_ptr< EMT::Ph3::Capacitor > mSubCapacitorF
Definition EMT_Ph3_GFL.h:90
void addControlPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes)
const Attribute< Matrix >::Ptr mPowerctrlOutputs
void setFilterParameters(Real lf, Real cf, Real rf)
Filter parameters. No Rc exists in this model.
const Attribute< Real >::Ptr mVcd
PCC voltage in controller dq frame.
const Attribute< Real >::Ptr mVcq
void setControllerParameters(Real kpPLL, Real kiPLL, Real kpPowerCtrl, Real kiPowerCtrl, Real kpCurrCtrl, Real kiCurrCtrl, Real omegaCutoff)
Controller parameters.
const Attribute< Real >::Ptr mPInst
Instantaneous controller-frame active/reactive power.
Bool mControllerParametersSet
Definition EMT_Ph3_GFL.h:68
void setParameters(Real sysOmega, Real sysVoltNom, Real pRef, Real qRef)
General operating parameters.
const Attribute< Matrix >::Ptr mPllOutput
PLL output [theta, phi_pll].
void mnaParentPostStep(Real time, Int timeStepCount, Attribute< Matrix >::Ptr &leftVector) override
std::shared_ptr< Signal::PLL > mPLL
Definition EMT_Ph3_GFL.h:81
std::shared_ptr< EMT::Ph3::Inductor > mSubInductorF
Definition EMT_Ph3_GFL.h:89
const Attribute< Real >::Ptr mOmegaPLL
Estimated PLL angular frequency [rad/s].
void initializeParentFromNodesAndTerminals(Real frequency) override
const Attribute< Matrix >::Ptr mVs
Actual controlled source voltage.
std::shared_ptr< Signal::PowerControllerVSI > mPowerControllerVSI
Definition EMT_Ph3_GFL.h:82
const Attribute< Matrix >::Ptr mVsref
Controlled source voltage reference in abc instantaneous peak values.
std::shared_ptr< EMT::Ph3::VoltageSource > mSubControlledVoltageSource
Definition EMT_Ph3_GFL.h:87
const Attribute< Real >::Ptr mIgridD
Positive converter-to-grid current in controller dq frame.
void mnaParentAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute< Matrix >::Ptr &leftVector) override
void controlStep(Real time, Int timeStepCount)
std::shared_ptr< EMT::Ph3::Resistor > mSubResistorF
Definition EMT_Ph3_GFL.h:88
Matrix getParkTransformMatrixPowerInvariant(Real theta) const
void updatePowerAndFrequencyAttributes()
void mnaParentInitialize(Real omega, Real timeStep, Attribute< Matrix >::Ptr leftVector) override
void mnaParentAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) override
const Attribute< Real >::Ptr mQInst
GFL(String uid, String name, Logger::Level logLevel=Logger::Level::off)
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 matrixToString(const Matrix &mat)
Definition Logger.cpp:31
Attribute< Matrix >::Ptr mRightVector
static Real realFromVectorElement(const Matrix &mat, Matrix::Index row)
static Matrix singlePhaseParameterToThreePhase(Real parameter)
To convert single phase parameters to symmetrical three phase ones.
static bool isFinite(Real value)
Definition MathUtils.cpp:63
static Ptr GND
Definition SimNode.h:35
UInt matrixNodeIndex(UInt nodeIndex)
const Attribute< MatrixVar< Real > >::Ptr mIntfCurrent
SimTerminal< Real >::List mTerminals
void setVirtualNodeNumber(UInt num)
const Attribute< MatrixVar< Real > >::Ptr mIntfVoltage
MatrixComp initialVoltage(UInt index)
SimNode< Real >::Ptr virtualNode(UInt index)
std::shared_ptr< SimPowerComp< VarType > > Ptr
SimNode< Real >::List mVirtualNodes
Bool terminalNotGrounded(UInt index)
Complex initialSingleVoltage(UInt index)
void setTerminalNumber(UInt num)
Logger::Level mLogLevel
Component logger control for internal variables.
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Logger::Log mSLog
Component logger.
static std::shared_ptr< VoltageSource > make(Args &&...args)
Definition PtrFactory.h:19
#define PI
Definition Definitions.h:43
#define RMS3PH_TO_PEAK1PH
Definition Definitions.h:50
#define SHIFT_TO_PHASE_C
Definition Definitions.h:47
#define PEAK1PH_TO_RMS3PH
Definition Definitions.h:51
#define SHIFT_TO_PHASE_B
Definition Definitions.h:46
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
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Definition Definitions.h:84