@@ -443,6 +443,23 @@ static void PrintJSONArray(FILE *fd, const char *name, int nvals,
443443 PrintJSONArrayEnd (fd, trail_comma);
444444}
445445
446+ static void PrintJSONArrayInt (FILE *fd, int value, bool trail_comma) {
447+ std::string str = trail_comma ? " ," : " " ;
448+ fprintf (fd, " %s%d%s\n " , tabstring, value, str.c_str ());
449+ }
450+
451+ static void PrintJSONIntArray (FILE *fd, const char *name, int nvals,
452+ int *values, bool trail_comma) {
453+ PrintJSONArrayBegin (fd, name);
454+
455+ for (int i = 0 ; i < nvals - 1 ; i++) {
456+ PrintJSONArrayInt (fd, values[i], true );
457+ }
458+ PrintJSONArrayInt (fd, values[nvals - 1 ], false );
459+
460+ PrintJSONArrayEnd (fd, trail_comma);
461+ }
462+
446463static void PrintGenData (FILE *fd, PSBUS bus, bool trail_comma,
447464 PetscScalar MVAbase) {
448465 PSGEN gen;
@@ -522,6 +539,19 @@ static void PrintLineData(FILE *fd, PSLINE line, bool trail_comma,
522539 PrintJSONDouble (fd, " RATE_A" , (line->rateA > 1e5 ) ? 10000 : line->rateA ,
523540 true );
524541
542+ // Zones for from and to bus
543+ // Zone from bus
544+ PrintJSONInt (fd, " ZONE_FBUS" , line->zonef , true );
545+
546+ // Zone to bus
547+ PrintJSONInt (fd, " ZONE_TBUS" , line->zonet , true );
548+
549+ // Area from bus
550+ PrintJSONInt (fd, " AREA_FBUS" , line->areaf , true );
551+
552+ // Zone to bus
553+ PrintJSONInt (fd, " AREA_TBUS" , line->areat , true );
554+
525555 // PF,QF, PT, QT
526556 PrintJSONDouble (fd, " PF" , line->pf * MVAbase, true );
527557 PrintJSONDouble (fd, " QF" , line->qf * MVAbase, true );
@@ -573,6 +603,12 @@ static void PrintBusData(FILE *fd, PSSUBST subst, bool trail_comma,
573603 // Base KV
574604 PrintJSONDouble (fd, " BASE_KV" , bus->basekV , true );
575605
606+ // Zone
607+ PrintJSONInt (fd, " ZONE" , bus->zone , true );
608+
609+ // Area
610+ PrintJSONInt (fd," AREA" ,bus->area , true );
611+
576612 // PD
577613 if (bus->nload ) {
578614 PSBUSGetLoad (bus, 0 , &load);
@@ -665,6 +701,8 @@ PetscErrorCode PSSaveSolution_JSON(PS ps, const char outfile[]) {
665701 snprintf (subst->name , 64 , " %d" , ps->bus [i].bus_i );
666702 subst->nbus = 1 ;
667703 subst->nkvlevels = 1 ;
704+ subst->zone = ps->bus [i].zone ;
705+ subst->area = ps->bus [i].area ;
668706 /* Circular distribution of lats and long from some location with .5
669707 * degrees deviation. This is completely random baseless lat/long creation
670708 */
@@ -714,6 +752,12 @@ PetscErrorCode PSSaveSolution_JSON(PS ps, const char outfile[]) {
714752 PrintJSONString (fd, " gicfile" , " not given" , true );
715753 }
716754
755+ /* Print number of zones */
756+ PrintJSONInt (fd, " nzones" , ps->nzones , true );
757+
758+ /* Print number of zones */
759+ PrintJSONInt (fd, " nareas" , ps->nareas , true );
760+
717761 /* Print number of lines */
718762 PrintJSONInt (fd, " nbranch" , ps->Nline , true );
719763
@@ -723,6 +767,12 @@ PetscErrorCode PSSaveSolution_JSON(PS ps, const char outfile[]) {
723767 /* Print Number of bus */
724768 PrintJSONInt (fd, " nbus" , ps->Nbus , true );
725769
770+ /* Print zones */
771+ PrintJSONIntArray (fd, " zones" , ps->nzones , ps->zones , true );
772+
773+ /* Print areas */
774+ PrintJSONIntArray (fd, " areas" , ps->nareas , ps->areas , true );
775+
726776 /* Print KV levels */
727777 PrintJSONArray (fd, " KVlevels" , ps->nkvlevels , ps->kvlevels , true );
728778
@@ -757,6 +807,12 @@ PetscErrorCode PSSaveSolution_JSON(PS ps, const char outfile[]) {
757807 // Name
758808 PrintJSONString (fd, " NAME" , ps->substations [i].name , true );
759809
810+ // Zone number
811+ PrintJSONInt (fd, " zone" , ps->substations [i].zone , true );
812+
813+ // Area number
814+ PrintJSONInt (fd, " area" , ps->substations [i].area , true );
815+
760816 // Number of buses
761817 PrintJSONInt (fd, " nbus" , ps->substations [i].nbus , true );
762818
@@ -883,6 +939,8 @@ PetscErrorCode PSSaveSolution_MINIMAL(PS ps, const char outfile[]) {
883939 fprintf (fd, " \t Total Load Shed P, Q: %9g, %9g\n " ,
884940 ps->sys_info .total_loadshed [0 ], ps->sys_info .total_loadshed [1 ]);
885941 fprintf (fd, " \t Solve Time: %5g\n " , ps->solve_real_time );
942+ fprintf (fd, " \t Nzones: %d\n " ,ps->nzones );
943+ fprintf (fd, " \t Nareas: %d\n " ,ps->nareas );
886944
887945 fclose (fd);
888946
0 commit comments