deltaFlow
OutputFile Namespace Reference

Functions for writing solver output, status, message, and data files. 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.
 
bool writeOutputFile (const std::string &jobName, const std::string &inputFile, const std::string &solverName, const std::string &formatName, const BusData &busData, const BranchData &branchData, const Eigen::MatrixXcd &Y, int iterations, double finalError, double tolerance, double elapsedSec, double basemva=100.0)
 Writes the main output file (.out) with full analysis results.
 
bool writeStatusFile (const std::string &jobName, const std::string &inputFile, const std::string &solverName, const std::string &formatName, int nBus, int nBranch, int iterations, double finalError, double tolerance, bool converged, double elapsedSec)
 Writes the status file (.sta) with a compact solver summary.
 
bool writeMessageFile (const std::string &jobName, const std::string &solverName, const std::vector< std::pair< int, double > > &iterationHistory, double tolerance, bool converged)
 Writes the message file (.msg) with iteration history.
 
bool writeDatFile (const std::string &jobName, const std::string &inputFile, const std::string &solverName, const std::string &formatName, const BusData &busData, const BranchData &branchData, const std::vector< std::pair< int, double > > &iterationHistory, int totalIterations, double finalError, double tolerance, bool converged, double elapsedSec, double basemva=100.0)
 Writes the detailed data file (.dat) with full input/output records.
 

Detailed Description

Functions for writing solver output, status, message, and data files.

Function Documentation

◆ dateStr()

std::string OutputFile::dateStr ( )
inline

Returns the current date string.

Definition at line 83 of file OutputFile.H.

83 {
84 auto now = std::time(nullptr);
85 return fmt::format("{:%d-%b-%Y}", fmt::localtime(now));
86 }
Here is the caller graph for this function:

◆ hostname()

std::string OutputFile::hostname ( )
inline

Returns the current hostname.

Definition at line 60 of file OutputFile.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 OutputFile::timestamp ( )
inline

Returns the current timestamp string.

Definition at line 75 of file OutputFile.H.

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

◆ timeStr()

std::string OutputFile::timeStr ( )
inline

Returns the current time string.

Definition at line 91 of file OutputFile.H.

91 {
92 auto now = std::time(nullptr);
93 return fmt::format("{:%H:%M:%S}", fmt::localtime(now));
94 }
Here is the caller graph for this function:

◆ writeDatFile()

bool OutputFile::writeDatFile ( const std::string &  jobName,
const std::string &  inputFile,
const std::string &  solverName,
const std::string &  formatName,
const BusData busData,
const BranchData branchData,
const std::vector< std::pair< int, double > > &  iterationHistory,
int  totalIterations,
double  finalError,
double  tolerance,
bool  converged,
double  elapsedSec,
double  basemva = 100.0 
)
inline

Writes the detailed data file (.dat) with full input/output records.

Parameters
jobNameJob name (used as output filename stem).
inputFilePath to the input data file.
solverNameName of the solver method used.
formatNameName of the input file format.
busDataSolved bus data.
branchDataBranch data.
iterationHistoryVector of (iteration, error) pairs.
totalIterationsTotal number of iterations performed.
finalErrorFinal convergence error.
toleranceConvergence tolerance.
convergedWhether the solver converged.
elapsedSecWall-clock time in seconds.
basemvaSystem base MVA (default: 100).
Returns
true on success, false if file could not be opened.

Definition at line 457 of file OutputFile.H.

471 {
472 std::string datFile = jobName + ".dat";
473 std::ofstream out(datFile);
474 if (!out.is_open()) return false;
475
476 int nBus = busData.V.size();
477 int nBranch = branchData.From.size();
478 int W = Display::pageWidth;
479
480 out << Display::fileBanner();
481 out << fmt::format("\n deltaFlow v{:<32s}Date {:>14s} Time {:>8s}\n",
482 deltaFlow_VERSION, dateStr(), timeStr());
483
484 out << Display::sectionHeader("I N P U T P R O C E S S I N G");
485 out << fmt::format(" Input File : {}\n", inputFile);
486 out << fmt::format(" Input Format : {}\n", formatName);
487
488 int nSlack = 0, nPV = 0, nPQ = 0;
489 for (int i = 0; i < nBus; ++i) {
490 if (busData.Type(i) == 1) nSlack++;
491 else if (busData.Type(i) == 2) nPV++;
492 else nPQ++;
493 }
494
495 out << fmt::format(" Number of Buses : {:>6d}\n", nBus);
496 out << fmt::format(" Slack Buses : {:>6d}\n", nSlack);
497 out << fmt::format(" PV Buses : {:>6d}\n", nPV);
498 out << fmt::format(" PQ Buses : {:>6d}\n", nPQ);
499 out << fmt::format(" Number of Branches : {:>6d}\n", nBranch);
500 out << fmt::format(" Base MVA : {:>10.1f}\n", basemva);
501
502 std::string solverBanner;
503 for (const char &c : solverName) {
504 solverBanner += std::toupper(c);
505 solverBanner += ' ';
506 }
507 out << Display::sectionHeader(solverBanner + " S O L V E R E X E C U T I O N");
508 out << fmt::format(" Method : {}\n", solverName);
509 out << fmt::format(" Max Iterations : {:>6d}\n", static_cast<int>(iterationHistory.size()) > 0 ?
510 static_cast<int>(iterationHistory.back().first) : totalIterations);
511 out << fmt::format(" Convergence Tol. : {:.6e}\n", tolerance);
512 out << "\n";
513
514 out << fmt::format(" {:>6s} {:>16s} {:>12s} {:>8s}\n",
515 "Iter", "Max Mismatch", "Tolerance", "Status");
516 out << " " << std::string(W - 4, '-') << "\n";
517
518 for (const auto& [iter, error] : iterationHistory) {
519 std::string status;
520 if (error < tolerance)
521 status = "CONV";
522 else
523 status = "----";
524 out << fmt::format(" {:>6d} {:>16.6e} {:>12.6e} {:>8s}\n",
525 iter, error, tolerance, status);
526 }
527
528 out << " " << std::string(W - 4, '-') << "\n";
529 out << "\n";
530
531 if (converged) {
532 out << fmt::format(" {} CONVERGED after {} iterations.\n", solverName, totalIterations);
533 out << fmt::format(" Final max mismatch = {:.6e}\n", finalError);
534 } else {
535 out << fmt::format(" *** WARNING: {} DID NOT CONVERGE after {} iterations.\n", solverName, totalIterations);
536 out << fmt::format(" Final max mismatch = {:.6e}\n", finalError);
537 }
538
539 out << Display::sectionHeader("B U S D A T A R E S U L T S");
540 out << fmt::format(" {:>4s} {:>9s} {:>9s} {:>10s} {:>10s} {:>10s} {:>10s} {:>10s}\n",
541 "Bus", "Voltage", "Angle", "Load", "Load", "Gen", "Gen", "Injected");
542 out << fmt::format(" {:>4s} {:>9s} {:>9s} {:>10s} {:>10s} {:>10s} {:>10s} {:>10s}\n",
543 "No.", "Mag.", "Degree", "MW", "Mvar", "MW", "Mvar", "Mvar");
544 out << " " << std::string(W - 4, '=') << "\n";
545
546 for (int i = 0; i < nBus; ++i) {
547 double injectedMvar = busData.Qg(i) - busData.Ql(i);
548 out << fmt::format(" {:>4d} {:>9.4f} {:>9.4f} {:>10.4f} {:>10.4f} {:>10.4f} {:>10.4f} {:>10.4f}\n",
549 i + 1, busData.V(i), busData.delta(i),
550 busData.Pl(i), busData.Ql(i), busData.Pg(i), busData.Qg(i), injectedMvar);
551 }
552
553 out << " " << std::string(W - 4, '=') << "\n";
554
555 double totalPl = busData.Pl.sum();
556 double totalQl = busData.Ql.sum();
557 double totalPg = busData.Pg.sum();
558 double totalQg = busData.Qg.sum();
559 double totalInjected = totalQg - totalQl;
560
561 out << fmt::format(" Total{:>27.4f} {:>10.4f} {:>10.4f} {:>10.4f} {:>10.4f}\n",
562 totalPl, totalQl, totalPg, totalQg, totalInjected);
563
564 out << "\n\n";
565 out << " JOB TIME SUMMARY\n";
566 out << fmt::format(" TOTAL CPU TIME (SEC) = {:>12.5f}\n", elapsedSec);
567 out << fmt::format(" WALLCLOCK TIME (SEC) = {:>12d}\n", static_cast<int>(std::round(elapsedSec)));
568 out << "\n";
569
570 out << Display::sectionHeader("A N A L Y S I S C O M P L E T E");
571 if (converged) {
572 out << Display::center("THE ANALYSIS HAS BEEN COMPLETED SUCCESSFULLY") << "\n";
573 } else {
574 out << Display::center("*** THE ANALYSIS HAS NOT CONVERGED ***") << "\n";
575 }
576 out << "\n";
577
578 out.close();
579 return true;
580 }
std::string center(const std::string &text)
Returns a centered string within the page width.
Definition Display.H:91
constexpr int pageWidth
Standard output page width.
Definition Display.H:51
std::string sectionHeader(const std::string &title)
Returns a section header for output files.
Definition Display.H:226
std::string fileBanner()
Returns a full plain-text banner for output/log files.
Definition Display.H:217
std::string timeStr()
Returns the current time string.
Definition OutputFile.H:91
std::string dateStr()
Returns the current date string.
Definition OutputFile.H:83
Eigen::VectorXi From
From bus indices.
Definition Data.H:84
Eigen::VectorXd Ql
Reactive power load [MVAr or p.u.].
Definition Data.H:65
Eigen::VectorXd V
Voltage magnitude [p.u.].
Definition Data.H:60
Eigen::VectorXd Pg
Active power generation [MW or p.u.].
Definition Data.H:62
Eigen::VectorXd delta
Voltage angle [rad or deg].
Definition Data.H:61
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
Eigen::VectorXi Type
Bus type (1=Slack, 2=PV, 3=PQ)
Definition Data.H:58

References Display::center(), dateStr(), BusData::delta, Display::fileBanner(), BranchData::From, Display::pageWidth, BusData::Pg, BusData::Pl, BusData::Qg, BusData::Ql, Display::sectionHeader(), timeStr(), BusData::Type, and BusData::V.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeMessageFile()

bool OutputFile::writeMessageFile ( const std::string &  jobName,
const std::string &  solverName,
const std::vector< std::pair< int, double > > &  iterationHistory,
double  tolerance,
bool  converged 
)
inline

Writes the message file (.msg) with iteration history.

Parameters
jobNameJob name (used as output filename stem).
solverNameName of the solver method used.
iterationHistoryVector of (iteration, error) pairs.
toleranceConvergence tolerance.
convergedWhether the solver converged.
Returns
true on success, false if file could not be opened.

Definition at line 397 of file OutputFile.H.

403 {
404 std::string msgFile = jobName + ".msg";
405 std::ofstream out(msgFile);
406 if (!out.is_open()) return false;
407
408 out << Display::fileBanner();
409
410 out << fmt::format("\n deltaFlow v{:<32s}Date {:>14s} Time {:>8s}\n",
411 deltaFlow_VERSION, dateStr(), timeStr());
412 out << "\n";
413
414 out << Display::sectionHeader("I T E R A T I O N H I S T O R Y");
415
416 out << fmt::format(" {:>6s} {:>16s} {:>12s} {:>8s}\n",
417 "Iter", "Max Mismatch", "Tolerance", "Status");
418 out << " " << std::string(Display::pageWidth - 4, '-') << "\n";
419
420 for (const auto& [iter, error] : iterationHistory) {
421 std::string status = (error < tolerance) ? "CONV" : "";
422 out << fmt::format(" {:>6d} {:>16.6e} {:>12.6e} {:>8s}\n",
423 iter, error, tolerance, status);
424 }
425
426 out << " " << std::string(Display::pageWidth - 4, '-') << "\n";
427 out << "\n";
428
429 if (converged) {
430 out << " " << solverName << " CONVERGED\n";
431 } else {
432 out << " *** WARNING: " << solverName << " DID NOT CONVERGE\n";
433 }
434
435 out << "\n";
436 out.close();
437 return true;
438 }

References dateStr(), Display::fileBanner(), Display::pageWidth, Display::sectionHeader(), and timeStr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeOutputFile()

bool OutputFile::writeOutputFile ( const std::string &  jobName,
const std::string &  inputFile,
const std::string &  solverName,
const std::string &  formatName,
const BusData busData,
const BranchData branchData,
const Eigen::MatrixXcd &  Y,
int  iterations,
double  finalError,
double  tolerance,
double  elapsedSec,
double  basemva = 100.0 
)
inline

Writes the main output file (.out) with full analysis results.

Parameters
jobNameJob name (used as output filename stem).
inputFilePath to the input data file.
solverNameName of the solver method used.
formatNameName of the input file format.
busDataSolved bus data.
branchDataBranch data.
YBus admittance matrix.
iterationsNumber of solver iterations performed.
finalErrorFinal convergence error.
toleranceConvergence tolerance.
elapsedSecWall-clock time in seconds.
basemvaSystem base MVA (default: 100).
Returns
true on success, false if file could not be opened.

Definition at line 112 of file OutputFile.H.

125 {
126 std::string outFile = jobName + ".out";
127 std::ofstream out(outFile);
128 if (!out.is_open()) return false;
129
130 int nBus = busData.V.size();
131 int nBranch = branchData.From.size();
132 int W = Display::pageWidth;
133
134 out << Display::fileBanner();
135
136 out << fmt::format("\n deltaFlow v{:<32s}Date {:>14s} Time {:>8s}\n",
137 deltaFlow_VERSION, dateStr(), timeStr());
138 out << "\n";
139
140 out << Display::sectionHeader("S Y S T E M I N F O R M A T I O N");
141 out << fmt::format(" Hostname : {}\n", hostname());
142 out << fmt::format(" CMake Version : {}\n", CMake_VERSION);
143 out << fmt::format(" Compiler Version : GCC {}\n", gcc_VERSION);
144 out << fmt::format(" deltaFlow Version : {}\n", deltaFlow_VERSION);
145 out << "\n";
146
147 out << Display::sectionHeader("J O B P A R A M E T E R S");
148 out << fmt::format(" Job Name : {}\n", jobName);
149 out << fmt::format(" Input File : {}\n", inputFile);
150 out << fmt::format(" Input Format : {}\n", formatName);
151 out << fmt::format(" Solver Method : {}\n", solverName);
152 out << fmt::format(" Convergence Tol. : {:.6e}\n", tolerance);
153 out << "\n";
154
155 out << Display::sectionHeader("M O D E L S U M M A R Y");
156
157 int nSlack = 0, nPV = 0, nPQ = 0;
158 for (int i = 0; i < nBus; ++i) {
159 if (busData.Type(i) == 1) nSlack++;
160 else if (busData.Type(i) == 2) nPV++;
161 else nPQ++;
162 }
163
164 out << fmt::format(" Number of Buses : {:>6d}\n", nBus);
165 out << fmt::format(" Slack Buses : {:>6d}\n", nSlack);
166 out << fmt::format(" PV Buses : {:>6d}\n", nPV);
167 out << fmt::format(" PQ Buses : {:>6d}\n", nPQ);
168 out << fmt::format(" Number of Branches : {:>6d}\n", nBranch);
169 out << fmt::format(" Base MVA : {:>10.1f}\n", basemva);
170 out << "\n";
171
172 out << Display::sectionHeader("S O L V E R S U M M A R Y");
173 out << fmt::format(" Method : {}\n", solverName);
174 out << fmt::format(" Iterations : {:>6d}\n", iterations);
175 out << fmt::format(" Final Error : {:.6e}\n", finalError);
176 out << fmt::format(" Tolerance : {:.6e}\n", tolerance);
177 out << fmt::format(" Status : CONVERGED\n");
178 out << fmt::format(" Elapsed Time (sec) : {:.3f}\n", elapsedSec);
179 out << "\n";
180
181 out << Display::sectionHeader("B U S D A T A R E S U L T S");
182 out << fmt::format(" {:>4s} {:>9s} {:>9s} {:>10s} {:>10s} {:>10s} {:>10s} {:>10s}\n",
183 "Bus", "Voltage", "Angle", "Load", "Load", "Gen", "Gen", "Injected");
184 out << fmt::format(" {:>4s} {:>9s} {:>9s} {:>10s} {:>10s} {:>10s} {:>10s} {:>10s}\n",
185 "No.", "Mag.", "Degree", "MW", "Mvar", "MW", "Mvar", "Mvar");
186 out << " " << std::string(W - 4, '=') << "\n";
187
188 for (int i = 0; i < nBus; ++i) {
189 double injectedMvar = busData.Qg(i) - busData.Ql(i);
190 out << fmt::format(" {:>4d} {:>9.4f} {:>9.4f} {:>10.4f} {:>10.4f} {:>10.4f} {:>10.4f} {:>10.4f}\n",
191 i + 1, busData.V(i), busData.delta(i),
192 busData.Pl(i), busData.Ql(i), busData.Pg(i), busData.Qg(i), injectedMvar);
193 }
194
195 double totalPl = busData.Pl.sum();
196 double totalQl = busData.Ql.sum();
197 double totalPg = busData.Pg.sum();
198 double totalQg = busData.Qg.sum();
199 double totalInjected = totalQg - totalQl;
200
201 out << " " << std::string(W - 4, '=') << "\n";
202 out << fmt::format(" Total{:>27.4f} {:>10.4f} {:>10.4f} {:>10.4f} {:>10.4f}\n",
203 totalPl, totalQl, totalPg, totalQg, totalInjected);
204 out << "\n";
205
206 out << Display::sectionHeader("L I N E F L O W A N D L O S S E S");
207 out << fmt::format(" {:>4s} {:>4s} {:>9s} {:>9s} {:>9s} {:>9s} {:>9s} {:>9s}\n",
208 "From", "To", "MW", "Mvar", "MVA", "Loss MW", "Loss Mvar", "Tap");
209 out << " " << std::string(W - 4, '=') << "\n";
210
211 auto Bc = branchData.B;
212 int nLine = nBranch;
213
214 Eigen::VectorXcd Vc(nBus);
215 Eigen::VectorXcd S(nBus);
216 for (int i = 0; i < nBus; ++i) {
217 double mag = busData.V(i);
218 double ang_rad = busData.delta(i) * M_PI / 180.0;
219 Vc(i) = std::polar(mag, ang_rad);
220 double P = busData.Pg(i) - busData.Pl(i);
221 double Q = busData.Qg(i) - busData.Ql(i);
222 S(i) = std::complex<double>(P, Q);
223 }
224
225 std::complex<double> SLT = 0.0;
226
227 for (int n = 1; n <= nBus; ++n) {
228 int n_idx = n - 1;
229 bool busprt = false;
230
231 for (int L = 0; L < nLine; ++L) {
232 if (!busprt) {
233 double P_inj = busData.Pg(n_idx) - busData.Pl(n_idx);
234 double Q_inj = busData.Qg(n_idx) - busData.Ql(n_idx);
235 double S_mag = std::abs(S(n_idx)) * basemva;
236 out << fmt::format(" {:>4d} {:>9.3f} {:>9.3f} {:>9.3f}\n",
237 n, P_inj, Q_inj, S_mag);
238 busprt = true;
239 }
240
241 auto writeLineFlow = [&](int from, int to, int L) {
242 int f_idx = from - 1;
243 int t_idx = to - 1;
244 double aL = (branchData.tapRatio(L) == 0.0) ? 1.0 : branchData.tapRatio(L);
245
246 std::complex<double> In, Ik;
247 if (branchData.From(L) == from) {
248 In = (Vc(f_idx) - aL * Vc(t_idx)) * Y(L) / (aL * aL) + Bc(L) / (aL * aL) * Vc(f_idx);
249 Ik = (Vc(t_idx) - Vc(f_idx) / aL) * Y(L) + Bc(L) * Vc(t_idx);
250 } else {
251 In = (Vc(f_idx) - Vc(t_idx) / aL) * Y(L) + Bc(L) * Vc(f_idx);
252 Ik = (Vc(t_idx) - aL * Vc(f_idx)) * Y(L) / (aL * aL) + Bc(L) / (aL * aL) * Vc(t_idx);
253 }
254 std::complex<double> Snk = Vc(f_idx) * std::conj(In) * basemva;
255 std::complex<double> Skn = Vc(t_idx) * std::conj(Ik) * basemva;
256 std::complex<double> SL = Snk + Skn;
257 SLT += SL;
258
259 if (aL != 1.0) {
260 out << fmt::format(" {:>4d} {:>9.3f} {:>9.3f} {:>9.3f} {:>9.3f} {:>9.3f} {:>9.3f}\n",
261 to, std::real(Snk), std::imag(Snk), std::abs(Snk),
262 std::real(SL), std::imag(SL), aL);
263 } else {
264 out << fmt::format(" {:>4d} {:>9.3f} {:>9.3f} {:>9.3f} {:>9.3f} {:>9.3f}\n",
265 to, std::real(Snk), std::imag(Snk), std::abs(Snk),
266 std::real(SL), std::imag(SL));
267 }
268 };
269
270 if (branchData.From(L) == n) {
271 writeLineFlow(n, branchData.To(L), L);
272 } else if (branchData.To(L) == n) {
273 writeLineFlow(n, branchData.From(L), L);
274 }
275 }
276 }
277
278 SLT /= 2.0;
279 out << "\n";
280 out << fmt::format(" Total loss {:>9.3f} {:>9.3f}\n",
281 std::real(SLT), std::imag(SLT));
282 out << "\n";
283
284 out << "\n";
285 out << "\n";
286 out << " JOB TIME SUMMARY\n";
287 out << fmt::format(" TOTAL CPU TIME (SEC) = {:>12.5f}\n", elapsedSec);
288 out << fmt::format(" WALLCLOCK TIME (SEC) = {:>12d}\n", static_cast<int>(std::round(elapsedSec)));
289 out << "\n";
290
291 out << Display::sectionHeader("A N A L Y S I S C O M P L E T E");
292 out << Display::center("THE ANALYSIS HAS BEEN COMPLETED SUCCESSFULLY") << "\n";
293 out << "\n";
294
295 out.close();
296 return true;
297 }
std::string hostname()
Returns the current hostname.
Definition OutputFile.H:60
Eigen::VectorXd tapRatio
Transformer tap ratio ($$ a $$)
Definition Data.H:90
Eigen::VectorXd B
Line susceptance ($$ B $$) [p.u.].
Definition Data.H:89
Eigen::VectorXi To
To bus indices.
Definition Data.H:85

References BranchData::B, Display::center(), dateStr(), BusData::delta, Display::fileBanner(), BranchData::From, hostname(), Display::pageWidth, BusData::Pg, BusData::Pl, BusData::Qg, BusData::Ql, Display::sectionHeader(), BranchData::tapRatio, timeStr(), BranchData::To, BusData::Type, and BusData::V.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeStatusFile()

bool OutputFile::writeStatusFile ( const std::string &  jobName,
const std::string &  inputFile,
const std::string &  solverName,
const std::string &  formatName,
int  nBus,
int  nBranch,
int  iterations,
double  finalError,
double  tolerance,
bool  converged,
double  elapsedSec 
)
inline

Writes the status file (.sta) with a compact solver summary.

Parameters
jobNameJob name (used as output filename stem).
inputFilePath to the input data file.
solverNameName of the solver method used.
formatNameName of the input file format.
nBusNumber of buses.
nBranchNumber of branches.
iterationsNumber of solver iterations performed.
finalErrorFinal convergence error.
toleranceConvergence tolerance.
convergedWhether the solver converged.
elapsedSecWall-clock time in seconds.
Returns
true on success, false if file could not be opened.

Definition at line 314 of file OutputFile.H.

326 {
327 std::string staFile = jobName + ".sta";
328 std::ofstream out(staFile);
329 if (!out.is_open()) return false;
330
331 out << fmt::format("deltaFlow v{:<36s}Date {:>14s} Time {:>8s}\n",
332 deltaFlow_VERSION, dateStr(), timeStr());
333
334 out << " SUMMARY OF JOB INFORMATION:\n";
335 out << fmt::format(" {:>6s} {:>6s} {:>10s} {:>12s} {:>12s} {:>8s}\n",
336 "ITER", "STATUS", "ERROR", "TOLERANCE", "ELAPSED", "RESULT");
337
338 out << fmt::format(" {:>6d} {:>6s} {:>10.3e} {:>12.3e} {:>12.3f} {:>8s}\n",
339 iterations,
340 converged ? "CONV" : "FAIL",
341 finalError,
342 tolerance,
343 elapsedSec,
344 converged ? "OK" : "FAILED");
345
346 out << "\n";
347 if (converged) {
348 out << " THE ANALYSIS HAS COMPLETED SUCCESSFULLY\n";
349 } else {
350 out << " THE ANALYSIS HAS FAILED TO CONVERGE\n";
351 }
352
353 out << "\n";
354 out << "Jobinfo File:\n";
355 out << fmt::format("Inputfile: {}\n", inputFile);
356 out << fmt::format("Solver: {}\n", solverName);
357 out << fmt::format("Format: {}\n", formatName);
358 out << fmt::format("Hostname: {}\n", hostname());
359 out << "\n";
360
361 out << "solver and hardware info\n";
362 out << "------------------------\n";
363 out << fmt::format("version : {}\n", deltaFlow_VERSION);
364 out << fmt::format("compiler : GCC {}\n", gcc_VERSION);
365 out << fmt::format("cmake : {}\n", CMake_VERSION);
366 out << fmt::format("hostname : {}\n", hostname());
367 out << "\n";
368
369 out << "model info\n";
370 out << "----------\n";
371 out << fmt::format(" # of buses : {}\n", nBus);
372 out << fmt::format(" # of branches : {}\n", nBranch);
373 out << "\n";
374
375 out << "run and timing info\n";
376 out << "-------------------\n";
377 out << fmt::format("simulation end : {}\n", timestamp());
378 out << fmt::format("elapsed time : {:.3f} seconds\n", elapsedSec);
379 out << fmt::format("iterations : {}\n", iterations);
380 out << fmt::format("final error : {:.6e}\n", finalError);
381 out << fmt::format("termination status: {}\n", converged ? "normal" : "failed");
382 out << "\n";
383
384 out.close();
385 return true;
386 }
std::string timestamp()
Returns the current timestamp string.
Definition OutputFile.H:75

References dateStr(), hostname(), timestamp(), and timeStr().

Here is the call graph for this function:
Here is the caller graph for this function: