Commit 48b32bc3 authored by Jan Dinkelbach's avatar Jan Dinkelbach Committed by Markus Mirz
Browse files

add EMT_Slack_PiLine_VSI_with_PF_Init

parent c8c9816d
......@@ -19,6 +19,7 @@ set(CIRCUIT_SOURCES
Circuits/DP_Slack_PiLine_PQLoad_with_PF_Init.cpp
Circuits/DP_Slack_PiLine_VSI_with_PF_Init.cpp
Circuits/EMT_Slack_PiLine_PQLoad_with_PF_Init.cpp
Circuits/EMT_Slack_PiLine_VSI_with_PF_Init.cpp
# Powerflow examples
Circuits/PF_Slack_PiLine_PQLoad.cpp
......
/* Copyright 2017-2020 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <DPsim.h>
#include "../Examples.h"
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
int main(int argc, char* argv[]) {
Examples::SGIB::ScenarioConfig scenario;
// Real finalTime = 0.003;
Real finalTime = 10;
Real timeStep = 0.001;
CommandLineArgs args(argc, argv);
if (argc > 1) {
timeStep = args.timeStep;
finalTime = args.duration;
}
// ----- POWERFLOW FOR INITIALIZATION -----
Real timeStepPF = finalTime;
Real finalTimePF = finalTime+timeStepPF;
String simNamePF = "EMT_Slack_PiLine_VSI_with_PF_Init_PF";
Logger::setLogDir("logs/" + simNamePF);
// Components
auto n1PF = SimNode<Complex>::make("n1", PhaseType::Single);
auto n2PF = SimNode<Complex>::make("n2", PhaseType::Single);
auto extnetPF = SP::Ph1::externalGridInjection::make("Slack", Logger::Level::debug);
extnetPF->setParameters(scenario.systemNominalVoltage);
extnetPF->setBaseVoltage(scenario.systemNominalVoltage);
extnetPF->modifyPowerFlowBusType(PowerflowBusType::VD);
auto linePF = SP::Ph1::PiLine::make("PiLine", Logger::Level::debug);
linePF->setParameters(scenario.lineResistance, scenario.lineInductance, 0);
linePF->setBaseVoltage(scenario.systemNominalVoltage);
auto loadPF = SP::Ph1::Load::make("Load", Logger::Level::debug);
loadPF->setParameters(-scenario.pvNominalActivePower, -scenario.pvNominalReactivePower, scenario.systemNominalVoltage);
loadPF->modifyPowerFlowBusType(PowerflowBusType::PQ);
// Topology
extnetPF->connect({ n1PF });
linePF->connect({ n1PF, n2PF });
loadPF->connect({ n2PF });
auto systemPF = SystemTopology(50,
SystemNodeList{n1PF, n2PF},
SystemComponentList{extnetPF, linePF, loadPF});
// Logging
auto loggerPF = DataLogger::make(simNamePF);
loggerPF->addAttribute("v1", n1PF->attribute("v"));
loggerPF->addAttribute("v2", n2PF->attribute("v"));
// Simulation
Simulation simPF(simNamePF, Logger::Level::debug);
simPF.setSystem(systemPF);
simPF.setTimeStep(timeStepPF);
simPF.setFinalTime(finalTimePF);
simPF.setDomain(Domain::SP);
simPF.setSolverType(Solver::Type::NRP);
simPF.doPowerFlowInit(false);
simPF.addLogger(loggerPF);
simPF.run();
// ----- DYNAMIC SIMULATION -----
Real timeStepEMT = timeStep;
Real finalTimeEMT = finalTime+timeStepEMT;
String simNameEMT = "EMT_Slack_PiLine_VSI_with_PF_Init_EMT";
Logger::setLogDir("logs/" + simNameEMT);
// Components
auto n1EMT = SimNode<Real>::make("n1", PhaseType::ABC);
auto n2EMT = SimNode<Real>::make("n2", PhaseType::ABC);
auto extnetEMT = EMT::Ph3::NetworkInjection::make("Slack", Logger::Level::debug);
auto lineEMT = EMT::Ph3::PiLine::make("PiLine", Logger::Level::debug);
lineEMT->setParameters(Reader::singlePhaseParameterToThreePhase(scenario.lineResistance), Reader::singlePhaseParameterToThreePhase(scenario.lineInductance), Reader::singlePhaseParameterToThreePhase(0));
auto pv = EMT::Ph3::AvVoltageSourceInverterDQ::make("pv", "pv", Logger::Level::debug, true);
pv->setParameters(scenario.systemOmega, scenario.pvNominalVoltage, scenario.pvNominalActivePower, scenario.pvNominalReactivePower);
pv->setControllerParameters(scenario.KpPLL, scenario.KiPLL, scenario.KpPowerCtrl, scenario.KiPowerCtrl, scenario.KpCurrCtrl, scenario.KiCurrCtrl, scenario.OmegaCutoff);
pv->setFilterParameters(scenario.Lf, scenario.Cf, scenario.Rf, scenario.Rc);
pv->setTransformerParameters(scenario.systemNominalVoltage, scenario.pvNominalVoltage, scenario.transformerNominalPower, scenario.systemNominalVoltage/scenario.pvNominalVoltage, 0, 0, scenario.transformerInductance, scenario.systemOmega);
pv->setInitialStateValues(scenario.thetaPLLInit, scenario.phiPLLInit, scenario.pvNominalActivePower, scenario.pvNominalReactivePower, scenario.phi_dInit, scenario.phi_qInit, scenario.gamma_dInit, scenario.gamma_qInit);
// Topology
extnetEMT->connect({ n1EMT });
lineEMT->connect({ n1EMT, n2EMT });
pv->connect({ n2EMT });
auto systemEMT = SystemTopology(50,
SystemNodeList{n1EMT, n2EMT},
SystemComponentList{extnetEMT, lineEMT, pv});
// Initialization of dynamic topology (actually necessary here? node objects the same)
CIM::Reader reader(simNameEMT, Logger::Level::debug);
reader.initDynamicSystemTopologyWithPowerflow(systemPF, systemEMT);
// Logging
auto loggerEMT = DataLogger::make(simNameEMT);
loggerEMT->addAttribute("v1", n1EMT->attribute("v"));
loggerEMT->addAttribute("v2", n2EMT->attribute("v"));
// load step sized in absolute terms
// std::shared_ptr<SwitchEvent> loadStepEvent = Examples::createEventAddPowerConsumption("n2", 1-timeStepEMT, 100e3, systemEMT, Domain::EMT, loggerEMT);
// Simulation
Simulation sim(simNameEMT, Logger::Level::debug);
sim.setSystem(systemEMT);
sim.setTimeStep(timeStepEMT);
sim.setFinalTime(finalTimeEMT);
sim.setDomain(Domain::EMT);
sim.doPowerFlowInit(false);
sim.addLogger(loggerEMT);
// sim.addEvent(loadStepEvent);
sim.run();
}
\ No newline at end of file
......@@ -39,6 +39,8 @@ namespace SGIB {
Real OmegaCutoff = 2 * PI * systemFrequency;
// Initial state values
Real thetaPLLInit = 0; // only for debug
Real phiPLLInit = 0; // only for debug
Real phi_dInit = 823.721*scaling_I;
Real phi_qInit = -411.861*scaling_I;
Real gamma_dInit = 131.401*scaling_I;
......
......@@ -77,7 +77,7 @@ namespace Ph3 {
mAttributeDependencies.push_back(line.mSubParallelResistor0->attribute("right_vector"));
mAttributeDependencies.push_back(line.mSubParallelResistor1->attribute("right_vector"));
}
if (line.mParallelCap(0, 0) >= 0) {
if (line.mParallelCap(0, 0) > 0) {
mAttributeDependencies.push_back(line.mSubParallelCapacitor0->attribute("right_vector"));
mAttributeDependencies.push_back(line.mSubParallelCapacitor1->attribute("right_vector"));
}
......
......@@ -154,7 +154,7 @@ void EMT::Ph3::PiLine::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix
subComps.push_back(mSubParallelResistor0);
subComps.push_back(mSubParallelResistor1);
}
if (mParallelCap(0,0) >= 0) {
if (mParallelCap(0,0) > 0) {
mSubParallelCapacitor0->mnaInitialize(omega, timeStep, leftVector);
mSubParallelCapacitor1->mnaInitialize(omega, timeStep, leftVector);
mRightVectorStamps.push_back(&mSubParallelCapacitor0->attribute<Matrix>("right_vector")->get());
......@@ -175,11 +175,11 @@ void EMT::Ph3::PiLine::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix
void EMT::Ph3::PiLine::mnaApplySystemMatrixStamp(Matrix& systemMatrix) {
mSubSeriesResistor->mnaApplySystemMatrixStamp(systemMatrix);
mSubSeriesInductor->mnaApplySystemMatrixStamp(systemMatrix);
if (mParallelCond(0,0) >= 0) {
if (mParallelCond(0,0) > 0) {
mSubParallelResistor0->mnaApplySystemMatrixStamp(systemMatrix);
mSubParallelResistor1->mnaApplySystemMatrixStamp(systemMatrix);
}
if (mParallelCap(0,0) >= 0) {
if (mParallelCap(0,0) > 0) {
mSubParallelCapacitor0->mnaApplySystemMatrixStamp(systemMatrix);
mSubParallelCapacitor1->mnaApplySystemMatrixStamp(systemMatrix);
}
......@@ -217,40 +217,4 @@ void EMT::Ph3::PiLine::mnaUpdateVoltage(const Matrix& leftVector) {
void EMT::Ph3::PiLine::mnaUpdateCurrent(const Matrix& leftVector) {
mIntfCurrent = mSubSeriesInductor->intfCurrent();
}
//
//MNAInterface::List EMT::Ph3::PiLine::mnaTearGroundComponents() {
// MNAInterface::List gndComponents;
//
// if (mParallelCond(0,0) > 0) {
// gndComponents.push_back(mSubParallelResistor0);
// gndComponents.push_back(mSubParallelResistor1);
// }
//
// if (mParallelCap(0,0) > 0) {
// gndComponents.push_back(mSubParallelCapacitor0);
// gndComponents.push_back(mSubParallelCapacitor1);
// }
//
// return gndComponents;
//}
//
//void EMT::Ph3::PiLine::mnaTearInitialize(Real omega, Real timeStep) {
// mSubSeriesResistor->mnaTearSetIdx(mTearIdx);
// mSubSeriesResistor->mnaTearInitialize(omega, timeStep);
// mSubSeriesInductor->mnaTearSetIdx(mTearIdx);
// mSubSeriesInductor->mnaTearInitialize(omega, timeStep);
//}
//
//void EMT::Ph3::PiLine::mnaTearApplyMatrixStamp(Matrix& tearMatrix) {
// mSubSeriesResistor->mnaTearApplyMatrixStamp(tearMatrix);
// mSubSeriesInductor->mnaTearApplyMatrixStamp(tearMatrix);
//}
//
//void EMT::Ph3::PiLine::mnaTearApplyVoltageStamp(Matrix& voltageVector) {
// mSubSeriesInductor->mnaTearApplyVoltageStamp(voltageVector);
//}
//
//void EMT::Ph3::PiLine::mnaTearPostStep(Complex voltage, Complex current) {
// mSubSeriesInductor->mnaTearPostStep(voltage - current * mSeriesRes, current);
//}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment