Commit 3a7bb3cc authored by Jan Dinkelbach's avatar Jan Dinkelbach
Browse files

add DP example with slack, line, load and PF init

parent 1887b365
......@@ -16,6 +16,8 @@ set(CIRCUIT_SOURCES
Circuits/DP_DecouplingLine.cpp
Circuits/DP_Diakoptics.cpp
Circuits/DP_VSI.cpp
Circuits/DP_Slack_PiLine_PQLoad_with_PF_Init.cpp
# Powerflow examples
Circuits/PF_Slack_PiLine_PQLoad.cpp
# EMT examples
......
/* 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>
using namespace DPsim;
using namespace CPS;
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 finalTime = 2.0;
// ----- POWERFLOW FOR INITIALIZATION -----
Real timeStepPF = 2.0;
Real finalTimePF = finalTime+timeStepPF;
String simNamePF = "DP_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, 0);
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 timeStepDP = 0.001;
Real finalTimeDP = finalTime+timeStepDP;
String simNameDP = "DP_Slack_PiLine_PQLoad_with_PF_Init_DP";
Logger::setLogDir("logs/" + simNameDP);
// Components
auto n1DP = SimNode<Complex>::make("n1", PhaseType::Single);
auto n2DP = SimNode<Complex>::make("n2", PhaseType::Single);
auto extnetDP = DP::Ph1::NetworkInjection::make("Slack", Logger::Level::debug);
extnetDP->setParameters(Complex(Vnom,0));
auto lineDP = DP::Ph1::PiLine::make("PiLine", Logger::Level::debug);
lineDP->setParameters(lineResistance, lineInductance);
auto loadDP = DP::Ph1::RXLoad::make("Load", Logger::Level::debug);
loadDP->setParameters(pLoadNom, qLoadNom, Vnom);
loadDP->setParameters(pLoadNom, qLoadNom, Vnom);
// Topology
extnetDP->connect({ n1DP });
lineDP->connect({ n1DP, n2DP });
loadDP->connect({ n2DP });
auto systemDP = SystemTopology(50,
SystemNodeList{n1DP, n2DP},
SystemComponentList{extnetDP, lineDP, loadDP});
// Initialization of dynamic topology (actually necessary here? node objects the same)
CIM::Reader reader(simNameDP, Logger::Level::debug);
reader.initDynamicSystemTopologyWithPowerflow(systemPF, systemDP);
// Logging
auto loggerDP = DataLogger::make(simNameDP);
loggerDP->addAttribute("v1", n1DP->attribute("v"));
loggerDP->addAttribute("v2", n2DP->attribute("v"));
// Simulation
Simulation sim(simNameDP, Logger::Level::debug);
sim.setSystem(systemDP);
sim.setTimeStep(timeStepDP);
sim.setFinalTime(finalTimeDP);
sim.setDomain(Domain::DP);
sim.doPowerFlowInit(false);
sim.addLogger(loggerDP);
sim.run();
}
......@@ -181,7 +181,7 @@ namespace CIM {
}
///
void initDynamicSystemTopologyWithPowerflow(SystemTopology& systemPF, SystemTopology& systemEMT);
void initDynamicSystemTopologyWithPowerflow(SystemTopology& systemPF, SystemTopology& system);
// #### shunt component settings ####
/// set shunt capacitor value
......
......@@ -50,6 +50,10 @@ namespace SP {namespace Ph1 {
/// Defines UID, name, component parameters and logging level
Shunt(String uid, String name, Logger::Level logLevel = Logger::Level::off);
/// Defines name and logging level
Shunt(String name, Logger::Level logLevel = Logger::Level::off)
: Shunt(name, name, logLevel) { }
// #### General ####
/// Set shunt specific parameters
void setParameters(Real conductance, Real susceptance);
......
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