From 9a9f1ebb18d60829d5b6375b4a833ee532fa107e Mon Sep 17 00:00:00 2001 From: SHUBHAM PURBEY Date: Wed, 10 Jun 2026 18:24:37 +0530 Subject: [PATCH] Fixed: OMC parse error (Expected RBRACE, got 'formate') --- src/main/python/OMChem/Flowsheet.py | 4 ++-- src/main/python/utils/UnitOperations.py | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/python/OMChem/Flowsheet.py b/src/main/python/OMChem/Flowsheet.py index 117eb48..a29af27 100644 --- a/src/main/python/OMChem/Flowsheet.py +++ b/src/main/python/OMChem/Flowsheet.py @@ -327,8 +327,8 @@ def safe_streams(stms): # --- Define compounds --- for c in self.compounds: - c_title = c.title() - self.data.append(f"parameter Simulator.Files.Chemsep_Database.{c_title} {c_title};\n") + norm = _normalize_compound_name(c) + self.data.append(f"parameter Simulator.Files.Chemsep_Database.{norm} {norm};\n") self.data.append(unitop.OM_Flowsheet_Initialize()) diff --git a/src/main/python/utils/UnitOperations.py b/src/main/python/utils/UnitOperations.py index 5d31611..56a09b8 100644 --- a/src/main/python/utils/UnitOperations.py +++ b/src/main/python/utils/UnitOperations.py @@ -5,7 +5,7 @@ parentPath = os.path.dirname(parent) sys.path.append(parentPath) -from python.OMChem.Flowsheet import Flowsheet +from python.OMChem.Flowsheet import Flowsheet, _normalize_compound_name from python.OMChem.EngStm import EngStm from python.utils.ComponentSelector import * from python.utils.Container import * @@ -138,8 +138,7 @@ def OM_Flowsheet_Initialize(self): self.OM_data_init += self.for_naming[i] + str(self.counter) + ' ' + self.for_naming + '(Nc = ' + str(len(self.compounds)) - C = str(self.compounds).strip('[').strip(']') - C = C.replace("'", "") + C = ', '.join(_normalize_compound_name(c) for c in self.compounds) self.OM_data_init += ',C = {' + C + '}' for k in self.parameters: @@ -153,8 +152,7 @@ def OM_Flowsheet_Initialize(self): else: self.OM_data_init += 'Simulator.UnitOperations.' + self.type + ' ' + self.name + '(Nc = ' + str(len(self.compounds)) - C = str(self.compounds).strip('[').strip(']') - C = C.replace("'", "") + C = ', '.join(_normalize_compound_name(c) for c in self.compounds) self.OM_data_init += ',C = {' + C + '}' for k in self.parameters: @@ -518,8 +516,7 @@ def OM_Flowsheet_Initialize(self): self.OM_data_init = self.OM_data_init + ( "Simulator.UnitOperations.CompoundSeparator " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (", C = {") - comp = str(self.compounds).strip('[').strip(']') - comp = comp.replace("'", "") + comp = ', '.join(_normalize_compound_name(c) for c in self.compounds) self.OM_data_init = self.OM_data_init + comp + ("},") self.OM_data_init = self.OM_data_init + ("SepFact_c = " + SepFact + ",SepStrm = " + SepStrm + ");\n")