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

add EMT_Slack_PiLine_PQLoad

parent 08666bb7
......@@ -18,6 +18,7 @@ set(CIRCUIT_SOURCES
Circuits/DP_VSI.cpp
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
# 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[]) {
// Parameters
Real Vnom = 20e3;
Real pLoadNom = 100e3;
Real qLoadNom = 50e3;
Real lineResistance = 0.05;
Real lineInductance = 0.1;
Real lineCapacitance = 0.1e-6;
Real finalTime = 2.0;
// ----- POWERFLOW FOR INITIALIZATION -----
Real timeStepPF = 2.0;
Real finalTimePF = finalTime+timeStepPF;
String simNamePF = "EMT_Slack_PiLine_PQLoad_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(Vnom);
extnetPF->setBaseVoltage(Vnom);
extnetPF->modifyPowerFlowBusType(PowerflowBusType::VD);
auto linePF = SP::Ph1::PiLine::make("PiLine", Logger::Level::debug);
linePF->setParameters(lineResistance, lineInductance, lineCapacitance);
linePF->setBaseVoltage(Vnom);
auto loadPF = SP::Ph1::Shunt::make("Load", Logger::Level::debug);
loadPF->setParameters(pLoadNom / std::pow(Vnom, 2), - qLoadNom / std::pow(Vnom, 2));
loadPF->setBaseVoltage(Vnom);
// 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 = 0.0001;
Real finalTimeEMT = finalTime+timeStepEMT;
String simNameEMT = "EMT_Slack_PiLine_PQLoad_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(lineResistance), Reader::singlePhaseParameterToThreePhase(lineInductance), Reader::singlePhaseParameterToThreePhase(lineCapacitance));
auto loadEMT = EMT::Ph3::RXLoad::make("Load", Logger::Level::debug);
loadEMT->setParameters(Reader::singlePhasePowerToThreePhase(pLoadNom), Reader::singlePhasePowerToThreePhase(qLoadNom), Vnom);
// Topology
extnetEMT->connect({ n1EMT });
lineEMT->connect({ n1EMT, n2EMT });
loadEMT->connect({ n2EMT });
auto systemEMT = SystemTopology(50,
SystemNodeList{n1EMT, n2EMT},
SystemComponentList{extnetEMT, lineEMT, loadEMT});
// 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();
}
......@@ -178,6 +178,10 @@ namespace CIM {
///
void initDynamicSystemTopologyWithPowerflow(SystemTopology& systemPF, SystemTopology& system);
///
static Matrix singlePhaseParameterToThreePhase(Real parameter);
///
static Matrix singlePhasePowerToThreePhase(Real power);
// #### shunt component settings ####
/// set shunt capacitor value
......
......@@ -70,6 +70,8 @@ namespace CPS {
SimPowerComp<Real>::Ptr clone(String name);
// #### General ####
///
void setParameters(Matrix activePower, Matrix reactivePower, Real volt);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
......
......@@ -86,7 +86,6 @@ TopologicalPowerComp::Ptr Reader::mapComponent(BaseClass* obj) {
return nullptr;
}
///
Matrix Reader::singlePhaseParameterToThreePhase(Real parameter) {
Matrix param_3ph = Matrix::Zero(3, 3);
param_3ph <<
......@@ -96,6 +95,15 @@ Matrix Reader::singlePhaseParameterToThreePhase(Real parameter) {
return param_3ph;
}
Matrix Reader::singlePhasePowerToThreePhase(Real power) {
Matrix power_3ph = Matrix::Zero(3, 3);
power_3ph <<
power/3., 0., 0.,
0., power/3., 0.,
0, 0., power/3.;
return power_3ph;
}
void Reader::addFiles(const fs::path &filename) {
if (!mModel->addCIMFile(filename.string()))
mSLog->error("Failed to read file {}", filename);
......
......@@ -47,6 +47,21 @@ EMT::Ph3::RXLoad::RXLoad(String name,
initPowerFromTerminal = false;
}
void EMT::Ph3::RXLoad::setParameters(Matrix activePower, Matrix reactivePower, Real volt) {
mActivePower = activePower;
mReactivePower = reactivePower;
// complex power
mPower = MatrixComp::Zero(3, 3);
mPower(0, 0) = { mActivePower(0, 0), mReactivePower(0, 0) };
mPower(1, 1) = { mActivePower(1, 1), mReactivePower(1, 1) };
mPower(2, 2) = { mActivePower(2, 2), mReactivePower(2, 2) };
mNomVoltage = volt;
initPowerFromTerminal = false;
}
SimPowerComp<Real>::Ptr EMT::Ph3::RXLoad::clone(String name) {
// everything set by initializeFromNodesAndTerminals
return RXLoad::make(name, mLogLevel);
......@@ -87,7 +102,7 @@ void EMT::Ph3::RXLoad::initializeFromNodesAndTerminals(Real frequency) {
if (mReactivePower(0, 0) != 0)
mReactance = std::pow(mNomVoltage/sqrt(3), 2) * mReactivePower.inverse();
else
mReactance = Matrix::Zero(0, 0);
mReactance = Matrix::Zero(1, 1);
if (mReactance(0,0) > 0) {
mInductance = mReactance / (2 * PI * frequency);
......
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