deltaFlow
OutputFileCommon Namespace Reference

Small pieces of business/formatting logic shared by all OutputFile writers. More...

Classes

struct  BusTotals
 Aggregate bus totals (load/gen) used in the bus-data result tables. More...
 
struct  BusTypeCounts
 Bus type counts (Slack/PV/PQ). More...
 

Functions

std::string hostname ()
 Returns the current hostname.
 
std::string timestamp ()
 Returns the current timestamp string.
 
std::string dateStr ()
 Returns the current date string.
 
std::string timeStr ()
 Returns the current time string.
 
BusTypeCounts countBusTypes (const BusData &busData)
 Counts buses by type (1=Slack, 2=PV, else PQ).
 
BusTotals computeBusTotals (const BusData &busData)
 Computes total load/gen/injected Mvar across all buses.
 

Detailed Description

Small pieces of business/formatting logic shared by all OutputFile writers.

Function Documentation

◆ computeBusTotals()

BusTotals OutputFileCommon::computeBusTotals ( const BusData busData)
inline

Computes total load/gen/injected Mvar across all buses.

Definition at line 119 of file OutputFileCommon.H.

119 {
120 BusTotals t;
121 t.totalPl = busData.Pl.sum();
122 t.totalQl = busData.Ql.sum();
123 t.totalPg = busData.Pg.sum();
124 t.totalQg = busData.Qg.sum();
125 t.totalInjected = t.totalQg - t.totalQl;
126 return t;
127 }
Eigen::VectorXd Ql
Reactive power load [MVAr or p.u.].
Definition Data.H:65
Eigen::VectorXd Pg
Active power generation [MW or p.u.].
Definition Data.H:62
Eigen::VectorXd Pl
Active power load [MW or p.u.].
Definition Data.H:64
Eigen::VectorXd Qg
Reactive power generation [MVAr or p.u.].
Definition Data.H:63
Aggregate bus totals (load/gen) used in the bus-data result tables.

References BusData::Pg, BusData::Pl, BusData::Qg, BusData::Ql, OutputFileCommon::BusTotals::totalInjected, OutputFileCommon::BusTotals::totalPg, OutputFileCommon::BusTotals::totalPl, OutputFileCommon::BusTotals::totalQg, and OutputFileCommon::BusTotals::totalQl.

Here is the caller graph for this function:

◆ countBusTypes()

BusTypeCounts OutputFileCommon::countBusTypes ( const BusData busData)
inline

Counts buses by type (1=Slack, 2=PV, else PQ).

Definition at line 98 of file OutputFileCommon.H.

98 {
99 BusTypeCounts counts;
100 int nBus = static_cast<int>(busData.Type.size());
101 for (int i = 0; i < nBus; ++i) {
102 if (busData.Type(i) == 1) counts.nSlack++;
103 else if (busData.Type(i) == 2) counts.nPV++;
104 else counts.nPQ++;
105 }
106 return counts;
107 }
Eigen::VectorXi Type
Bus type (1=Slack, 2=PV, 3=PQ)
Definition Data.H:58
Bus type counts (Slack/PV/PQ).

References OutputFileCommon::BusTypeCounts::nPQ, OutputFileCommon::BusTypeCounts::nPV, OutputFileCommon::BusTypeCounts::nSlack, and BusData::Type.

Here is the caller graph for this function:

◆ dateStr()

std::string OutputFileCommon::dateStr ( )
inline

Returns the current date string.

Definition at line 79 of file OutputFileCommon.H.

79 {
80 auto now = std::time(nullptr);
81 return fmt::format("{:%d-%b-%Y}", fmt::localtime(now));
82 }
Here is the caller graph for this function:

◆ hostname()

std::string OutputFileCommon::hostname ( )
inline

Returns the current hostname.

Definition at line 60 of file OutputFileCommon.H.

60 {
61 #ifdef _WIN32
62 char buf[MAX_COMPUTERNAME_LENGTH + 1];
63 DWORD bufLen = sizeof(buf);
64 if (GetComputerNameA(buf, &bufLen)) return std::string(buf);
65 #else
66 char buf[256];
67 if (gethostname(buf, sizeof(buf)) == 0) return std::string(buf);
68 #endif
69 return "unknown";
70 }
Here is the caller graph for this function:

◆ timestamp()

std::string OutputFileCommon::timestamp ( )
inline

Returns the current timestamp string.

Definition at line 73 of file OutputFileCommon.H.

73 {
74 auto now = std::time(nullptr);
75 return fmt::format("{:%d-%b-%Y %H:%M:%S}", fmt::localtime(now));
76 }
Here is the caller graph for this function:

◆ timeStr()

std::string OutputFileCommon::timeStr ( )
inline

Returns the current time string.

Definition at line 85 of file OutputFileCommon.H.

85 {
86 auto now = std::time(nullptr);
87 return fmt::format("{:%H:%M:%S}", fmt::localtime(now));
88 }
Here is the caller graph for this function: