Skip to content

Commit 13489a0

Browse files
committed
Use new parser in pflow
1 parent 476dd54 commit 13489a0

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

include/private/psse.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ class BusMapping {
244244
void Resolve(std::size_t &bus_number, std::string &bus_name,
245245
Optional opt = Optional{false}) const;
246246

247+
const auto &GetIdToIdMap() const { return id_map_; }
248+
const auto &GetNameToIdMap() const { return name_map_; }
249+
247250
private:
248251
std::vector<Bus> &buses_;
249252
std::unordered_map<std::size_t, std::size_t> id_map_;

src/pflow/pflow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "exago_config.h"
22
#include <private/pflowimpl.h>
33
#include <private/psimpl.h>
4+
#include <psse.hpp>
45

56
const char *const PFLOWOutputFormatTypes[] = {
67
"MATPOWER", "CSV", "JSON", "MINIMAL", "OutputFormat", "", NULL};
@@ -105,7 +106,8 @@ PetscErrorCode PFLOWReadPSSERawData(PFLOW pflow, const char netfile[]) {
105106

106107
PetscFunctionBegin;
107108
/* Read MatPower data file and populate the PS data structure */
108-
ierr = PSReadPSSERawData(pflow->ps, netfile);
109+
auto nw = exago::psse::ParseNetwork(netfile);
110+
ierr = exago::psse::ConvertToPS(pflow->ps, nw);
109111
CHKERRQ(ierr);
110112
PetscFunctionReturn(0);
111113
}

src/ps/psse.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,12 @@ PetscErrorCode ConvertToPS(PS ps, const Network &nw) {
461461
ps->Nbus = ps->nbus = nw.buses.size();
462462
ierr = PetscCalloc1(ps->Nbus, &ps->bus);
463463
CHKERRQ(ierr);
464+
std::size_t maxbusi = 0;
464465
for (int i = 0; i < ps->Nbus; ++i) {
465466
auto &dbus = ps->bus[i];
466467
const auto &sbus = nw.buses[i];
467468
dbus.bus_i = sbus.i;
469+
maxbusi = std::max(maxbusi, sbus.i);
468470
strcpy(dbus.name, sbus.name.c_str());
469471
dbus.basekV = sbus.baskv;
470472
dbus.ide = sbus.ide;
@@ -496,6 +498,16 @@ PetscErrorCode ConvertToPS(PS ps, const Network &nw) {
496498
dbus.MVAbasetot = 0.0;
497499
}
498500

501+
ps->maxbusnum = maxbusi;
502+
ierr = PetscCalloc1(ps->maxbusnum + 1, &ps->busext2intmap);
503+
CHKERRQ(ierr);
504+
for (int i = 0; i < ps->maxbusnum + 1; i++) {
505+
ps->busext2intmap[i] = -1;
506+
}
507+
for (const auto &[ext_i, int_i] : nw.bus_mapping.GetIdToIdMap()) {
508+
ps->busext2intmap[ext_i] = int_i;
509+
}
510+
499511
// loads
500512
ps->Nload = ps->nload = nw.loads.size();
501513
ierr = PetscCalloc1(ps->Nload, &ps->load);

0 commit comments

Comments
 (0)