Skip to content

Fixed: OMC parse error (Expected RBRACE, got 'formate')#85

Open
shubham148-st wants to merge 1 commit into
FOSSEE:masterfrom
shubham148-st:simfix
Open

Fixed: OMC parse error (Expected RBRACE, got 'formate')#85
shubham148-st wants to merge 1 commit into
FOSSEE:masterfrom
shubham148-st:simfix

Conversation

@shubham148-st

Copy link
Copy Markdown
Contributor

This PR resolves a critical OpenModelica (OMC) parsing error (Expected RBRACE) that occurred when simulating chemical compounds containing spaces, hyphens, or special characters. It enforces strict Modelica identifier compatibility by ensuring that all compound names are normalized into valid, single-word identifiers before being passed to the simulation engine.

Changes

  • Function Integration: Integrated the _normalize_compound_name utility function which was previously defined(Flowsheet.py ln 10-24) but was unused into the flowsheet generation logic. This function ensures that any multi-word or special-character compound name (e.g., 'Hydrogen cyanide', 'Carbon-tetrachloride') is programmatically transformed into a valid Modelica identifier (e.g., 'Hydrogencyanide', 'Carbontetrachloride') before compilation.
  • Improved String Handling: Replaced fragile string stripping logic (strip('[').strip(']')) in UnitOperations.py with the _normalize_compound_name function. This prevents structural corruption of the string when handling lists of compounds.

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.

1 participant