Skip to content

Commit

Permalink
allow chemicals with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelcortes committed Feb 6, 2025
1 parent 1187dde commit 8cd825d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion thermosteam/_chemical.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ def blank(cls, ID, CAS=None, phase_ref=None, phase=None,
for i in _names: setfield(self, i, None)
for i in _data: setfield(self, i, None)
for i in _energy_handles: setfield(self, i, None)
check_valid_ID(ID)
self._phase_ref = phase_ref or phase
self._CAS = CAS or ID
if formula: self.formula = formula
Expand Down
13 changes: 11 additions & 2 deletions thermosteam/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class Stream(AbstractStream):
_flow_cache = {}

def __init__(self, ID: Optional[str]='',
flow: Sequence[float]=(),
flow: Sequence[float]|Sequence[tuple[str, float]]=(),
phase: Optional[str]='l',
T: Optional[float]=298.15,
P: Optional[float]=101325.,
Expand Down Expand Up @@ -809,7 +809,16 @@ def _init_indexer(self, flow, phase, chemicals, chemical_flows):
else:
parent = indexer.parent_indexer(chemicals)
imol = parent.to_chemical_indexer(phase)
imol.data[:] = flow
if isinstance(flow[0], str):
ID, flow = flow
imol[ID] = flow
else:
try:
IDs, flow = zip(*flow)
except:
imol.data[:] = flow
else:
imol[IDs] = flow
self._imol = imol

def reset_cache(self):
Expand Down
2 changes: 1 addition & 1 deletion thermosteam/reaction/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def split_coefficient(nID, sign):
break
else:
if next_letter.isalpha(): break
elif letter.isalpha() or letter in '()[]{}':
elif letter.isalpha() or letter in '`()[]{}':
break
if i:
ID = nID[i:]
Expand Down

0 comments on commit 8cd825d

Please sign in to comment.