Skip to content

Fix: Post-Simulation GUI Crashes & Results Parsing#88

Merged
Koyandechirag merged 2 commits into
FOSSEE:masterfrom
shubham148-st:conn
Jun 18, 2026
Merged

Fix: Post-Simulation GUI Crashes & Results Parsing#88
Koyandechirag merged 2 commits into
FOSSEE:masterfrom
shubham148-st:conn

Conversation

@shubham148-st

Copy link
Copy Markdown
Contributor

This PR resolves a series of intertwined bugs causing KeyError, ValueError, and Segmentation Faults when interacting with the GUI after a simulation fails, or when rendering results for MaterialStream components.

Changes

1. Missing Variable Definitions

  • Added missing Fm_p[2] (Liquid Mass Flow) and Fm_p[3] (Vapour Mass Flow) keys to the MaterialStream variables dictionary in utils/Streams.py. This was absent and was causing MaterialStream: 'Fm_p[2]'` error and associated Segmentation Faults when clicking on output streams.

2. Equation Initialization Data Corruption

  • Deprecated keywords xm_pc (mass fraction) and Fm_pc (mass flow) were being used in get_start_values() where json.dumps(x_pcarr) of utils/Streams.py, it now correctly uses xm_pcarr and Fm_pcarr.
  • Fixed a silent KeyError bug in get_start_values() in utils/Streams.py. The method previously tried to access MW_p[2] and Cp_p[2] directly, which do not exist in the variables dict. This caused the method to abort early and skip setting valid starting guesses for H_p, S_p, and F_p. Replaced direct access with a safe .get() fallback.

3. Defensive Simulation Value Parsing

  • Added a safety check in ext_data() in Flowsheet.py to skip parsing if result_data has fewer than 2 rows.
  • In utils/Container.py: moved the update_tooltip_selectedVar() call into the if simulation_successful: block. Tooltips will no longer try to update using stale or failed string values if a simulation fails.

4. Safe Rendering

  • In Streams.py replaced bare float(val) conversions in param_getter and param_getter_tooltip_selectedVar with a _safe_float() helper function. This prevents ValueError crashes if bad data accidentally enters the variable dictionary.
  • In DockWidgetMaterialStream.py refactored the inline str(round(float(resultval), 4)) UI item rendering logic into a cleaner _safe_result() local helper function. It safely validates that the string is actually numeric using an advanced .isdigit() check before parsing, protecting the Results Tree/Table from crashing.
Screenshot 2026-06-18 133656

…DockWidgetMaterial, added a safe method in ext_data() in Flowsheet.py, Fixed post sim updates
@Koyandechirag Koyandechirag merged commit 599c9e4 into FOSSEE:master Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants