Fix: Post-Simulation GUI Crashes & Results Parsing#88
Merged
Conversation
…ch will prevent future crashes.
…DockWidgetMaterial, added a safe method in ext_data() in Flowsheet.py, Fixed post sim updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 forMaterialStreamcomponents.Changes
1. Missing Variable Definitions
Fm_p[2](Liquid Mass Flow) andFm_p[3](Vapour Mass Flow) keys to theMaterialStreamvariablesdictionary inutils/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
xm_pc(mass fraction) andFm_pc(mass flow) were being used inget_start_values()wherejson.dumps(x_pcarr)ofutils/Streams.py, it now correctly usesxm_pcarrandFm_pcarr.KeyErrorbug inget_start_values()inutils/Streams.py. The method previously tried to accessMW_p[2]andCp_p[2]directly, which do not exist in thevariablesdict. This caused the method to abort early and skip setting valid starting guesses forH_p,S_p, andF_p. Replaced direct access with a safe.get()fallback.3. Defensive Simulation Value Parsing
ext_data()inFlowsheet.pyto skip parsing ifresult_datahas fewer than 2 rows.utils/Container.py: moved theupdate_tooltip_selectedVar()call into theif simulation_successful:block. Tooltips will no longer try to update using stale or failed string values if a simulation fails.4. Safe Rendering
Streams.pyreplaced barefloat(val)conversions inparam_getterandparam_getter_tooltip_selectedVarwith a_safe_float()helper function. This preventsValueErrorcrashes if bad data accidentally enters the variable dictionary.DockWidgetMaterialStream.pyrefactored the inlinestr(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.