diff --git a/thermosteam/_phase.py b/thermosteam/_phase.py index ce903588..71f369c5 100644 --- a/thermosteam/_phase.py +++ b/thermosteam/_phase.py @@ -19,7 +19,7 @@ 'S': 'SOLID', 'L': 'LIQUID', } -index = {j: i for i,j in enumerate(valid_phases)} +index = {j: i for i,j in enumerate(sorted(valid_phases))} def check_phase(phase): """ @@ -38,7 +38,8 @@ def check_phase(phase): raise RuntimeError( f"invalid phase {repr(phase)} encountered; valid phases are " "'s' (solid), 'l' (liquid), 'g' (gas), 'S' (SOLID), and 'L' (LIQUID)" - ) + ) + return phase def phase_tuple(phases): """ diff --git a/thermosteam/indexer.py b/thermosteam/indexer.py index f465c8be..2391b7a1 100644 --- a/thermosteam/indexer.py +++ b/thermosteam/indexer.py @@ -1320,17 +1320,19 @@ def group_vol_composition(self): def by_mass(self): """Return a ChemicalMassFlowIndexer that references this object's molar data.""" try: - mass = self._data_cache['mass'] + mass = self._data_cache['mass', self._phase] except: chemicals = self.chemicals - self._data_cache['mass'] = mass = \ + self._data_cache['mass', self._phase] = mass = \ ChemicalMassFlowIndexer.from_data( SparseVector.from_dict( MassFlowDict(self.data.dct, chemicals.MW), chemicals.size ), - self._phase, chemicals, - False + self._phase, + chemicals, + False, + True, ) return mass ChemicalMolarFlowIndexer.by_mass = by_mass @@ -1367,12 +1369,12 @@ def by_volume(self, TP): """ try: - vol = self._data_cache['vol', TP] + vol = self._data_cache['vol', TP, self._phase] except: chemicals = self._chemicals V = [i.V for i in chemicals] phase = self._phase - self._data_cache['vol', TP] = \ + self._data_cache['vol', TP, self._phase] = \ vol = ChemicalVolumetricFlowIndexer.from_data( SparseVector.from_dict( VolumetricFlowDict(self.data.dct, TP, V, None, self, {}),