Skip to content

Commit

Permalink
enforce setting of domain argument for initWithPowerflow
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Dinkelbach <[email protected]>
  • Loading branch information
dinkelbachjan committed Nov 29, 2023
1 parent 981abc6 commit 234b3f9
Show file tree
Hide file tree
Showing 51 changed files with 321 additions and 321 deletions.
2 changes: 1 addition & 1 deletion dpsim-models/include/dpsim-models/SystemTopology.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace CPS {
void addComponents(const IdentifiedObject::List& components);

/// Initialize nodes and SG power from PowerFlow
void initWithPowerflow(const SystemTopology& systemPF, CPS::Domain domain = CPS::Domain::DP);
void initWithPowerflow(const SystemTopology& systemPF, CPS::Domain domain);

/// Adds component and initializes frequencies
void addTearComponent(IdentifiedObject::Ptr component);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/CIM/DP_CIGRE_MV_withDG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char** argv){
CIM::Reader reader2(simName, Logger::Level::debug, Logger::Level::debug);
SystemTopology systemDP = reader2.loadCIM(scenario.systemFrequency, filenames, CPS::Domain::DP);
Examples::Grids::CIGREMV::addInvertersToCIGREMV(systemDP, scenario, Domain::DP);
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, CPS::Domain::DP);

auto logger = DPsim::DataLogger::make(simName);

Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/CIM/DP_CIGRE_MV_withDG_withLoadStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char** argv){
CIM::Reader reader2(simName, Logger::Level::info, Logger::Level::debug);
SystemTopology systemDP = reader2.loadCIM(scenario.systemFrequency, filenames, CPS::Domain::DP);
Examples::Grids::CIGREMV::addInvertersToCIGREMV(systemDP, scenario, Domain::DP);
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, CPS::Domain::DP);

auto logger = DPsim::DataLogger::make(simName);

Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/CIM/DP_CIGRE_MV_withoutDG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int main(int argc, char** argv){
Logger::setLogDir("logs/" + simName);
CIM::Reader reader2(simName, Logger::Level::debug, Logger::Level::debug);
SystemTopology systemDP = reader2.loadCIM(systemFrequency, filenames, CPS::Domain::DP);
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, CPS::Domain::DP);

auto logger = DPsim::DataLogger::make(simName);

Expand Down
4 changes: 2 additions & 2 deletions dpsim/examples/cxx/CIM/DP_WSCC-9bus_IdealVS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) {
CPS::CIM::Reader reader(simNamePF, Logger::Level::debug, Logger::Level::debug);
SystemTopology systemPF = reader.loadCIM(60, filenames, Domain::SP, PhaseType::Single, CPS::GeneratorType::PVNode);
systemPF.component<CPS::SP::Ph1::SynchronGenerator>("GEN1")->modifyPowerFlowBusType(CPS::PowerflowBusType::VD);

// define logging
auto loggerPF = DPsim::DataLogger::make(simNamePF);
for (auto node : systemPF.mNodes)
Expand All @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) {

CPS::CIM::Reader reader2(simName, Logger::Level::debug, Logger::Level::debug);
SystemTopology sys = reader2.loadCIM(60, filenames, Domain::DP, PhaseType::Single, CPS::GeneratorType::IdealVoltageSource);
sys.initWithPowerflow(systemPF);
sys.initWithPowerflow(systemPF, CPS::Domain::DP);

// Logging
auto logger = DataLogger::make(simName);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/CIM/DP_WSCC9bus_SGReducedOrderIter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) {
sys.addComponent(faultDP);
}

sys.initWithPowerflow(systemPF);
sys.initWithPowerflow(systemPF, Domain::DP);
for (auto comp : sys.mComponents) {
if (auto genReducedOrder = std::dynamic_pointer_cast<CPS::Base::ReducedOrderSynchronGenerator<Complex>>(comp))
genReducedOrder->scaleInertiaConstant(inertiaScalingFactor);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/CIM/DP_WSCC9bus_SGReducedOrderVBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) {
sys.addComponent(faultDP);
}

sys.initWithPowerflow(systemPF);
sys.initWithPowerflow(systemPF, Domain::DP);
for (auto comp : sys.mComponents) {
if (auto genReducedOrder = std::dynamic_pointer_cast<CPS::Base::ReducedOrderSynchronGenerator<Complex>>(comp)) {
genReducedOrder->scaleInertiaConstant(inertiaScalingFactor);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/CIM/SP_WSCC9bus_SGReducedOrderVBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) {
sys.addComponent(faultSP);
}

sys.initWithPowerflow(systemPF);
sys.initWithPowerflow(systemPF, Domain::SP);
for (auto comp : sys.mComponents) {
if (auto genReducedOrder = std::dynamic_pointer_cast<CPS::Base::ReducedOrderSynchronGenerator<Complex>>(comp))
genReducedOrder->scaleInertiaConstant(inertiaScalingFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) {
SystemComponentList{extnetDP, lineDP, loadDP});

// Initialization of dynamic topology
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);

// Logging
auto loggerDP = DataLogger::make(simNameDP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int main(int argc, char* argv[]) {
SystemComponentList{extnetDP, lineDP, pv});

// Initialization of dynamic topology with values from powerflow
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);

// Logging
auto loggerDP = DataLogger::make(simName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) {
SystemComponentList{extnetDP, lineDP, pv});

// Initialization of dynamic topology with values from powerflow
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);

// Logging
auto loggerDP = DataLogger::make(simNameDP);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/Circuits/DP_SynGenTrStab_3Bus_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void DP_SynGenTrStab_3Bus_Fault(String simName, Real timeStep, Real finalTime, b
SystemComponentList{gen1DP, gen2DP, loadDP, line12DP, line13DP, line23DP, faultDP});

// Initialization of dynamic topology
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);

// Logging
auto loggerDP = DataLogger::make(simNameDP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void DP_SynGenTrStab_3Bus_SteadyState(String simName, Real timeStep, Real finalT
SystemComponentList{gen1DP, gen2DP, loadDP, line12DP, line13DP, line23DP});

// Initialization of dynamic topology
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);

// Logging
auto loggerDP = DataLogger::make(simNameDP);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/Circuits/DP_SynGenTrStab_SMIB_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void DP_1ph_SynGenTrStab_Fault(String simName, Real timeStep, Real finalTime, bo
SystemComponentList{genDP, lineDP, extnetDP, faultDP});

// Initialization of dynamic topology
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);


// Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void DP_1ph_SynGenTrStab_SteadyState(String simName, Real timeStep, Real finalTi
SystemComponentList{genDP, lineDP, extnetDP});

// Initialization of dynamic topology
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);


// Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void simulateDP(SystemTopology& systemPF, String waveform) {
SystemComponentList{extnetDP, lineDP, loadDP});

// Initialization of dynamic topology
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);

// Logging
auto loggerDP = DataLogger::make(simNameDP);
Expand Down Expand Up @@ -163,7 +163,7 @@ void simulateSP(SystemTopology& systemPF, String waveform) {
SystemComponentList{extnetSP, lineSP, loadSP});

// Initialization of dynamic topology with values from powerflow
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void simulateDP(SystemTopology& systemPF, String waveform) {
SystemComponentList{extnetDP, lineDP, loadDP});

// Initialization of dynamic topology
systemDP.initWithPowerflow(systemPF);
systemDP.initWithPowerflow(systemPF, Domain::DP);

// Logging
auto loggerDP = DataLogger::make(simNameDP);
Expand Down Expand Up @@ -163,7 +163,7 @@ void simulateSP(SystemTopology& systemPF, String waveform) {
SystemComponentList{extnetSP, lineSP, loadSP});

// Initialization of dynamic topology with values from powerflow
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void DP_1ph_SynGenTrStab_Fault(Real timeStep, Real finalTime, bool startFaultEve
SystemComponentList{gen, line, fault, extnet});

// Initialization of dynamic topology
system.initWithPowerflow(systemPF);
system.initWithPowerflow(systemPF, CPS::Domain::DP);


// Logging
Expand Down Expand Up @@ -424,7 +424,7 @@ void SP_1ph_SynGenTrStab_Fault(Real timeStep, Real finalTime, bool startFaultEve
SystemComponentList{gen, line, fault, extnet});

// Initialization of dynamic topology
system.initWithPowerflow(systemPF);
system.initWithPowerflow(systemPF, CPS::Domain::SP);

// Logging
auto logger = DataLogger::make(simName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) {
SystemComponentList{extnetSP, lineSP, loadSP});

// Initialization of dynamic topology with values from powerflow
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) {
SystemComponentList{extnetSP, lineSP, pv});

// Initialization of dynamic topology with values from powerflow
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) {
SystemComponentList{extnetSP, lineSP, pv});

// Initialization of dynamic topology with values from powerflow
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/Circuits/SP_SynGenTrStab_3Bus_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void SP_SynGenTrStab_3Bus_Fault(String simName, Real timeStep, Real finalTime, b
SystemComponentList{gen1SP, gen2SP, loadSP, line12SP, line13SP, line23SP, faultSP});

// Initialization of dynamic topology
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void SP_SynGenTrStab_3Bus_SteadyState(String simName, Real timeStep, Real finalT
SystemComponentList{gen1SP, gen2SP, loadSP, line12SP, line13SP, line23SP});

// Initialization of dynamic topology
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
2 changes: 1 addition & 1 deletion dpsim/examples/cxx/Circuits/SP_SynGenTrStab_SMIB_Fault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void SP_1ph_SynGenTrStab_Fault(String simName, Real timeStep, Real finalTime, bo
SystemComponentList{genSP, lineSP, extnetSP, faultSP});

// Initialization of dynamic topology
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void SP_1ph_SynGenTrStab_Fault(String simName, Real timeStep, Real finalTime, Re
SystemComponentList{genSP, trafoSP, lineSP, extnetSP, faultSP});

// Initialization of dynamic topology
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void SP_1ph_SynGenTrStab_SteadyState(String simName, Real timeStep, Real finalTi
SystemComponentList{genSP, lineSP, extnetSP});

// Initialization of dynamic topology
systemSP.initWithPowerflow(systemPF);
systemSP.initWithPowerflow(systemPF, Domain::SP);

// Logging
auto loggerSP = DataLogger::make(simNameSP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void SP_1ph_SynGenTrStab_Fault(Real timeStep, Real finalTime, bool startFaultEve
SystemComponentList{gen, line, fault, extnet});

// Initialization of dynamic topology
system.initWithPowerflow(systemPF);
system.initWithPowerflow(systemPF, CPS::Domain::SP);


// Logging
Expand Down Expand Up @@ -285,7 +285,7 @@ void DP_1ph_SynGenTrStab_Fault(Real timeStep, Real finalTime, bool startFaultEve
SystemComponentList{gen, line, fault, extnet});

// Initialization of dynamic topology
system.initWithPowerflow(systemPF);
system.initWithPowerflow(systemPF, CPS::Domain::DP);


// Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void SP_1ph_SynGenTrStab_Fault(Real timeStep, Real finalTime, bool startFaultEve


// Initialization of dynamic topology
system.initWithPowerflow(systemPF);
system.initWithPowerflow(systemPF, CPS::Domain::SP);


// Logging
Expand Down Expand Up @@ -338,7 +338,7 @@ void DP_1ph_SynGenTrStab_Fault(Real timeStep, Real finalTime, bool startFaultEve
SystemComponentList{gen, line1, line21, fault, line22, extnet});

// Initialization of dynamic topology
system.initWithPowerflow(systemPF);
system.initWithPowerflow(systemPF, CPS::Domain::DP);


// Logging
Expand Down
2 changes: 1 addition & 1 deletion dpsim/src/pybind/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ PYBIND11_MODULE(dpsimpy, m) {
.def_readwrite("components_at_node", &DPsim::SystemTopology::mComponentsAtNode)
.def_readonly("tear_components", &DPsim::SystemTopology::mTearComponents)
.def("list_idobjects", &DPsim::SystemTopology::listIdObjects)
.def("init_with_powerflow", &DPsim::SystemTopology::initWithPowerflow, "systemPF"_a, "domain"_a=CPS::Domain::DP)
.def("init_with_powerflow", &DPsim::SystemTopology::initWithPowerflow, "systemPF"_a, "domain"_a)
.def_readonly("components_at_node", &DPsim::SystemTopology::mComponentsAtNode);

py::class_<DPsim::Interface, std::shared_ptr<DPsim::Interface>>(m, "Interface");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
" logger.log_attribute('Te', 'Te', gen)\n",
"\n",
" # init node voltages and SG power with power flow\n",
" system.init_with_powerflow(systemPF=system_pf)\n",
" system.init_with_powerflow(system_pf, dpsimpy.Domain.DP)\n",
" \n",
" ### Simulation\n",
" sim = dpsimpy.Simulation(name, dpsimpy.LogLevel.debug)\n",
Expand Down
Loading

0 comments on commit 234b3f9

Please sign in to comment.