Skip to content

Commit f77c1ea

Browse files
committed
Save numits.
1 parent d742c15 commit f77c1ea

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

include/private/psimpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ struct _p_PS {
497497

498498
PetscBool setupcalled; /* Is setup called on PS? */
499499

500-
PetscLogDouble solve_real_time;
500+
PetscLogDouble solve_real_time; /* Solve time */
501+
PetscInt numits; /* Number of solver iterations */
501502
};
502503

503504
extern PetscErrorCode PSCheckTopology(PS);

src/opflow/interface/opflow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,6 +3196,7 @@ PetscErrorCode OPFLOWSetSummaryStats(OPFLOW opflow) {
31963196
CHKERRQ(ierr);
31973197

31983198
ps->solve_real_time = opflow->solve_real_time;
3199+
ps->numits = opflow->numits;
31993200

32003201
PetscFunctionReturn(0);
32013202
}

src/ps/psoutput.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ PetscErrorCode PSSaveSolution_MATPOWER(PS ps, const char outfile[]) {
272272
fprintf(fd, "\n%%%% solve time\n");
273273
fprintf(fd, "%ssolve_time = %.5g;\n", prefix, ps->solve_real_time);
274274

275+
fprintf(fd, "\n%%%% number of iterations\n");
276+
fprintf(fd, "%snum_iter = %d;\n", prefix, ps->numits);
277+
275278
fclose(fd);
276279
PetscFunctionReturn(0);
277280
}
@@ -888,7 +891,8 @@ PetscErrorCode PSSaveSolution_JSON(PS ps, const char outfile[]) {
888891
PrintJSONArray(fd, "LOAD", 2, &ps->sys_info.total_load[0], true);
889892
PrintJSONArray(fd, "LOADSHED", 2, &ps->sys_info.total_loadshed[0], true);
890893

891-
PrintJSONDouble(fd, "SolveRealTime", ps->solve_real_time, false);
894+
PrintJSONDouble(fd, "SolveRealTime", ps->solve_real_time, true);
895+
PrintJSONInt(fd, "NumIter", ps->numits, false);
892896

893897
PrintJSONObjectEnd(fd, false); // System summary object end
894898

@@ -944,6 +948,7 @@ PetscErrorCode PSSaveSolution_MINIMAL(PS ps, const char outfile[]) {
944948
fprintf(fd, "\tTotal Load Shed P, Q: %9g, %9g\n",
945949
ps->sys_info.total_loadshed[0], ps->sys_info.total_loadshed[1]);
946950
fprintf(fd, "\tSolve Time: %5g\n", ps->solve_real_time);
951+
fprintf(fd, "\tNumber of iterations: %d\n", ps->numits);
947952
fprintf(fd, "\tNzones: %d\n", ps->nzones);
948953
fprintf(fd, "\tNareas: %d\n", ps->nareas);
949954

0 commit comments

Comments
 (0)