Skip to content

Add SU2_LIVE: terminal residual monitor with convergence diagnosis - #3023

Open
Syphonicc wants to merge 1 commit into
su2code:developfrom
Syphonicc:add-su2-live
Open

Syphonicc wants to merge 1 commit into
su2code:developfrom
Syphonicc:add-su2-live

Conversation

@Syphonicc

Copy link
Copy Markdown
Contributor

Proposed Changes

Adds SU2_LIVE, a terminal counterpart to SU2_MON (#2988). It follows the history file while SU2 runs, plots the residuals with braille characters, and classifies the run as converging (with a rate and an estimate of the iterations and time left), stalled, frozen, in a limit cycle or diverging.

It uses only the Python standard library, so it works over SSH, on cluster login nodes and in containers without a display or PyQt5/matplotlib. This came out of the Show and tell discussion #2879.

SU2_LIVE inv_channel.cfg                                   # run SU2_CFD and plot live
SU2_LIVE case.cfg -e "mpirun -n 8 SU2_CFD"                 # any solver command
SU2_LIVE -f history.csv                                    # follow an existing or finished run
SU2_LIVE -f history.csv -o Rho,RhoE                        # only some residuals
SU2_LIVE -l -f history.csv                                 # list the residual columns

Details:

  • The residual columns are read from the header, so Euler, SA, SST and the multizone summary (bgs[...][zone]) work without configuration.
  • When given a config, the history file name follows CConfig::GetHistory_FileName and CMultizoneOutput: CONV_FILENAME or the config name for multizone, the restart iteration for unsteady restarts, and .csv or .dat from TABULAR_FORMAT.
  • Both the CSV and the Tecplot history formats are read, including the older VARIABLES = "..." header.
  • If Inner_Iter is not monotonic (unsteady runs, or multizone runs where it stays at 0), the x axis switches to Time_Iter, Outer_Iter or the row number.
  • The convergence target is taken from CONV_RESIDUAL_MINVAL, and can be overridden with --target.
  • The default mode draws in place and keeps the scrollback; -F uses the full screen.

Files:

  • bin/SU2_LIVE: the tool, a single executable script, installed to bin from SU2_PY/meson.build like SU2_MON.
  • SU2_PY/tests/test_live.py: unit tests (classification, CSV/Tecplot/multizone parsing, incremental reads, history file naming), run in the existing Python Tests workflow. No dependencies needed.

Related Work

#2988 (SU2_MON), discussion #2879.

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

Testing

  • python3 SU2_PY/tests/test_live.py: 31 tests pass on Python 3.11 and 3.14.
  • Live runs:
Case Result
euler/channel/inv_channel_RK.cfg with TABULAR_FORMAT= TECPLOT, 4 ranks reads history.dat, converging -1.51 dec/1k
coupled_cht/comp_2d (multizone CHT), 4 ranks reads cht_2d_3cylinders.csv, plots Rho[0] ... T[3], converging
Supersonic biparabolic, ROE + Venkatakrishnan limit cycle, oscillating +/-0.19 about -3.82
Supersonic biparabolic, JST + MG 3 converging -22.1 dec/1k

Comment thread bin/SU2_LIVE
for name, idx in self.candidates.items():
try:
self.alt.setdefault(name, []).append(int(float(parts[idx])))
except (IndexError, ValueError):
Comment thread bin/SU2_LIVE
m = pattern.match(line)
if m:
value = m.group(1).split("%")[0].strip()
except OSError:
Comment thread bin/SU2_LIVE
if os.path.exists(hist_file):
try:
os.replace(hist_file, hist_file + ".prev")
except OSError:
@Syphonicc

Copy link
Copy Markdown
Contributor Author

Here are some pictures
screenshot-select png
screenshot-frozen png
screenshot-live png

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants