Skip to content

Commit

Permalink
update spec path
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelcortes committed Mar 28, 2024
1 parent 29c9748 commit db25f2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion thermosteam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
from ._thermo import Thermo, IdealThermo
from ._settings import settings, ProcessSettings
from ._thermo_data import ThermoData
from ._preferences import preferences
from . import (
indexer,
reaction,
Expand All @@ -70,6 +69,7 @@
from .reaction import *
from .equilibrium import *
from .mixture import *
from ._preferences import preferences

__all__ = ('Chemical', 'ChemicalData', 'Chemicals', 'CompiledChemicals', 'Thermo',
'IdealThermo', 'Stream', 'MultiStream', 'Heat', 'Power', 'ThermalCondition', 'ProcessSettings',
Expand Down
24 changes: 10 additions & 14 deletions thermosteam/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,22 +1844,17 @@ def __call__(self):
else: i.converge() # Must be a system

def compile_path(self, unit):
upstream_units = unit.get_upstream_units()
# For upstream units, recycle loops will take care of it.
impacted_units = [i for i in self.impacted_units if i not in upstream_units]
self.path = unit.path_from(impacted_units, system=unit._system) if impacted_units else ()
self.path = unit.path_from(self.impacted_units, system=unit._system) if self.impacted_units else ()

def create_temporary_connections(self, unit):
# Temporary connections are created first than the path because
# temporary connections may change the system configuration
# such that the path is incorrect.
impacted_units = self.impacted_units
if impacted_units:
downstream_units = unit.get_downstream_units()
upstream_units = unit.get_upstream_units()
for other in impacted_units:
if other in upstream_units or other not in downstream_units:
temporary_connection(unit, other)
if other not in upstream_units: temporary_connection(unit, other)

def __repr__(self):
return f"{type(self).__name__}(f={display_asfunctor(self.f)}, args={self.args}, impacted_units={self.impacted_units})"
Expand Down Expand Up @@ -2257,9 +2252,9 @@ def from_feedstock(cls, feedstock, feeds=(), ends=None, units=None, final=True):
recycle_ends.update(disjunction_streams)
recycle_ends.update(network.get_all_recycles())
recycle_ends.update(tmo.utils.products_from_units(network.units))
network.add_interaction_units()
network.sort(recycle_ends)
# network.sort(recycle_ends)
network.reduce_recycles()
network.add_interaction_units()
return network

@classmethod
Expand Down Expand Up @@ -2312,11 +2307,12 @@ def reduce_recycles(self):
sink = sinks.pop()
if len(sink.outs) == 1:
self.recycle = sink.outs[0]
sources = set([i.source for i in recycle])
if len(sources) == 1:
source = sources.pop()
if len(source.ins) == 1:
self.recycle = source.ins[0]
else:
sources = set([i.source for i in recycle])
if len(sources) == 1:
source = sources.pop()
if len(source.ins) == 1:
self.recycle = source.ins[0]

def add_interaction_units(self, excluded=None):
isa = isinstance
Expand Down

0 comments on commit db25f2b

Please sign in to comment.