ansys / pysystem-coupling

Python API to System Coupling
https://systemcoupling.docs.pyansys.com/
MIT License
7 stars 4 forks source link

Convergence charts using matplotlib #312

Closed iboyd-ansys closed 4 months ago

iboyd-ansys commented 5 months ago

This work started as some experiments with using matplotlib to display solution convergence and diagnostic charts but seems to have stabilised enough that some aspects can be exposed.

It uses System Coupling's support for output of chart data in CSV format. In the longer term, we would like to expose a gRPC stream (SyC already has the basics for this in place for other clients).

These are the main aspects of the work:

The visible API is a new command show_plot exposed on the solution API root.

Still todo:

codecov-commenter commented 5 months ago

Codecov Report

Attention: Patch coverage is 45.71843% with 374 lines in your changes are missing coverage. Please review.

Project coverage is 74.27%. Comparing base (270563d) to head (a69e4d0). Report is 26 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #312 +/- ## =========================================== - Coverage 85.05% 74.27% -10.78% =========================================== Files 34 41 +7 Lines 1893 2581 +688 =========================================== + Hits 1610 1917 +307 - Misses 283 664 +381 ```
ochernuk commented 4 months ago

@iboyd-ansys a few notes:

iboyd-ansys commented 4 months ago

@ochernuk, regarding your notes:

@iboyd-ansys a few notes:

  • for steady analysis the x-axis shows "Time" - it should be "Iteration" instead
  • It would be good to have the ability to select only one chart to show and what to show (e.g. only convergence, or only transfer values chart), perhaps via syc.solution.show_plot(interface_name = ..., transfer_name = ..., show_convergence = False, show_transfer_values = True, show_source = False, show_target = True)
  • Regarding multiple interfaces, I think separate plots are ok by default for now (though in the future it'd be good to add flexibility for that, but I see that as fairly low priority)

The first two points here should be addressed now. As far as the third one is concerned, with mutiple interfaces on the same plot, we are likely to end up with a lot of "subplots" and I am not sure how well it will behave once we get beyond a few subplots. I believe it works to call show_plot multiple times with different arguments so that might end up being the recommended approach.