UtilityAgent#

class UtilityAgent(ID='', phase='l', T=298.15, P=101325.0, units=None, thermo=None, T_limit=None, heat_transfer_price=0.0, regeneration_price=0.0, heat_transfer_efficiency=1.0, isfuel=False, dT=0, **chemical_flows)[source]#

Create a UtilityAgent object that defines a utility option.

Parameters:
  • ID (str, optional) – A unique identification. If ID is None, stream will not be registered. If no ID is given, stream will be registered with a unique ID.

  • flow – All flow rates corresponding to defined chemicals.

  • phase (str, optional) – ‘g’ for gas, ‘l’ for liquid, and ‘s’ for solid. Defaults to ‘l’.

  • T (float, optional) – Temperature [K]. Defaults to 298.15.

  • P (float, optional) – Pressure [Pa]. Defaults to 101325.

  • units (str, optional) – Flow rate units of measure (only mass, molar, and volumetric flow rates are valid). Defaults to ‘kmol/hr’.

  • thermo (Thermo, optional) – Thermo object to initialize input and output streams. Defaults to settings.thermo.

  • T_limit (float, optional) – Temperature limit of outlet utility streams [K]. If no limit is given, phase change is assumed. If utility agent heats up, T_limit is the maximum temperature. If utility agent cools down, T_limit is the minimum temperature.

  • heat_transfer_price (float) – Price of transferred heat [USD/kJ]. Defautls to 1.

  • regeneration_price (float) – Price of regenerating the fluid for reuse [USD/kmol]. Defaults to 0.

  • heat_transfer_efficiency (float) – Fraction of heat transferred accounting for losses to the environment (must be between 0 to 1). Defaults to 1.

  • isfuel (bool) – Whether to burn the agent as a isfuel for heat.

  • dT (float, optional) – Minimum temperature change between inlet and outlet utility. A positive value prevents near infinite flows when utility agents use sensible heats.

  • **chemical_flows (float) – ID - flow pairs.

property iscooling_agent: bool#

Whether the agent is a cooling agent.

property isheating_agent: bool#

Whether the agent is a heating agent.

property price#

Price of stream per unit mass [USD/kg].

property cost#

Total cost of stream [USD/hr].

to_stream(ID=None)[source]#

Return a copy as a Stream object.

Examples

>>> import biosteam as bst
>>> bst.settings.set_thermo(['Water', 'Ethanol'])
>>> cooling_water = bst.HeatUtility.get_agent('cooling_water')
>>> cooling_water_copy = cooling_water.to_stream('cooling_water_copy')
>>> cooling_water_copy.show(flow='kg/hr')
Stream: cooling_water_copy
phase: 'l', T: 305.37 K, P: 101325 Pa
flow (kg/hr): Water  18
property heat_transfer_price: float#

Price of transfered heat [USD/kJ].

property regeneration_price: float#

Price of regenerating the fluid for reuse [USD/kmol].

property C: float#

Isobaric heat capacity flow rate [kJ/K/hr].

property Cn: float#

Molar isobaric heat capacity [J/mol/K].

property Cp: float#

Isobaric heat capacity [J/g/K].

property F_mass: float#

Total mass flow rate [kg/hr].

property F_mol: float#

Total molar flow rate [kmol/hr].

property F_vol: float#

Total volumetric flow rate [m3/hr].

property H: float#

Enthalpy flow rate [kJ/hr].

property HHV: float#

Higher heating value flow rate [kJ/hr].

property Hf: float#

Enthalpy of formation flow rate [kJ/hr].

property Hnet: float#

Total enthalpy flow rate (including heats of formation) [kJ/hr].

property Hvap: float#

Enthalpy of vaporization flow rate [kJ/hr].

property ID#

Unique identification (str). If set as ‘’, it will choose a default ID.

property LHV: float#

Lower heating value flow rate [kJ/hr].

property MW: float#

Overall molecular weight.

property P: float#

Pressure [Pa].

property P_vapor: float#

Vapor pressure of liquid.

property Pr: float#

Prandtl number [-].

property S: float#

Absolute entropy flow rate [kJ/hr/K].

property T: float#

Temperature [K].

property V: float#

Molar volume [m^3/mol].

property alpha: float#

Thermal diffusivity [m^2/s].

as_stream()#

Does nothing.

property available_chemicals: list[Chemical]#

All chemicals with nonzero flow.

bubble_point_at_P(P=None, IDs=None)#

Return a BubblePointResults object with all data on the bubble point at constant pressure.

Parameters:

IDs (Sequence`[:py:class:`str], optional) – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.bubble_point_at_P()
BubblePointValues(T=357.14, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.492 0.508])
bubble_point_at_T(T=None, IDs=None)#

Return a BubblePointResults object with all data on the bubble point at constant temperature.

Parameters:
  • T (float, optional) – Temperature [K].

  • IDs (Sequence`[:py:class:`str], optional) – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.bubble_point_at_T()
BubblePointValues(T=350.00, P=76463, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.488 0.512])
characterization_factors: dict[str, float]#

Characterization factors for life cycle assessment [impact/kg].

copy(ID=None, thermo=None)#

Return a copy of the stream.

Examples

Create a copy of a new stream:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1_copy = s1.copy('s1_copy')
>>> s1_copy.show(flow='kg/hr')
Stream: s1_copy
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10

Warning

Prices, and LCA characterization factors are not copied.

copy_flow(other, IDs=Ellipsis, *, remove=False, exclude=False)#

Copy flow rates of another stream to self.

Parameters:
  • other (Stream) – Flow rates will be copied from here.

  • IDs (Sequence`[:py:class:`str], str, None]) – Chemical IDs.

  • remove (bool, optional) – If True, copied chemicals will be removed from stream.

  • exclude (bool, optional) – If True, exclude designated chemicals when copying.

Examples

Initialize streams:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')

Copy all flows:

>>> s2.copy_flow(s1)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10

Reset and copy just water flow:

>>> s2.empty()
>>> s2.copy_flow(s1, 'Water')
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  20

Reset and copy all flows except water:

>>> s2.empty()
>>> s2.copy_flow(s1, 'Water', exclude=True)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Ethanol  10

Cut and paste flows:

>>> s2.copy_flow(s1, remove=True)
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
>>> s1.show()
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0

Its also possible to copy flows from a multistream:

>>> s1.phases = ('g', 'l')
>>> s1.imol['g', 'Water'] = 10
>>> s2.copy_flow(s1, remove=True)
>>> s2.show()
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water  10
>>> s1.show()
MultiStream: s1
phases: ('g', 'l'), T: 298.15 K, P: 101325 Pa
 flow: 0

Copy flows except except water and remove water:

>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.copy_flow(s1, 'Water', exclude=True, remove=True)
>>> s1.show('wt')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  20
>>> s2.show('wt')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Ethanol  10
copy_like(other)#

Copy all conditions of another stream.

Examples

Copy data from another stream with the same property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=2, units='kg/hr')
>>> s1.copy_like(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  2

Copy data from another stream with a different property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s2 = tmo.Stream('s2', Water=2, units='kg/hr')
>>> s1.copy_like(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  2
copy_phase(other)#

Copy phase from another stream.

copy_thermal_condition(other)#

Copy thermal conditions (T and P) of another stream.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=2, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=1, units='kg/hr', T=300.00)
>>> s1.copy_thermal_condition(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 300 K, P: 101325 Pa
flow (kg/hr): Water  2
dew_point_at_P(P=None, IDs=None)#

Return a DewPointResults object with all data on the dew point at constant pressure.

Parameters:

IDs (Sequence`[:py:class:`str], optional) – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.dew_point_at_P()
DewPointValues(T=368.62, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], x=[0.983 0.017])
dew_point_at_T(T=None, IDs=None)#

Return a DewPointResults object with all data on the dew point at constant temperature.

Parameters:

IDs (Sequence`[:py:class:`str], optional) – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.dew_point_at_T()
DewPointValues(T=350.00, P=49058, IDs=('Water', 'Ethanol'), z=[0.836 0.164], x=[0.984 0.016])
disconnect()#

Disconnect stream from unit.

disconnect_sink()#

Disconnect stream from sink.

disconnect_source()#

Disconnect stream from source.

display_units = DisplayUnits(T='K', P='Pa', flow='kmol/hr', composition=False, sort=False, N=7)#

Units of measure for IPython display (class attribute)

empty()#

Empty stream flow rates.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.empty()
>>> s1.F_mol
0
empty_negative_flows()#

Replace flows of all components with negative values with 0.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1, Ethanol=-1)
>>> s1.empty_negative_flows()
>>> s1.show()
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water  1
property epsilon: float#

Relative permittivity [-].

flow_proxy(ID=None)#

Return a new stream that shares flow rate data with this one.

See also

link_with, proxy

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.flow_proxy()
>>> s2.mol is s1.mol
True
get_CF(key, basis=None, units=None)#

Returns the life-cycle characterization factor on a kg basis given the impact indicator key.

Parameters:
  • key (str) – Key of impact indicator.

  • basis (str, optional) – Basis of characterization factor. Mass is the only valid dimension (for now). Defaults to ‘kg’.

  • units (str, optional) – Units of impact indicator. Before using this argument, the default units of the impact indicator should be defined with settings.define_impact_indicator. Units must also be dimensionally consistent with the default units.

get_atomic_flow(symbol)#

Return flow rate of atom [kmol / hr] given the atomic symbol.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream(Water=1)
>>> stream.get_atomic_flow('H') # kmol/hr of H
2.0
>>> stream.get_atomic_flow('O') # kmol/hr of O
1.0
get_atomic_flows()#

Return dictionary of atomic flow rates [kmol / hr].

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream(Water=1)
>>> stream.get_atomic_flows()
{'H': 2.0, 'O': 1.0}
get_bubble_point(IDs=None)#

Return a BubblePoint object capable of computing bubble points.

Parameters:

IDs (Sequence`[:py:class:`str], optional) – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.get_bubble_point()
BubblePoint([Water, Ethanol])
get_concentration(IDs, units=None)#

Return concentration of given chemicals.

Parameters:
  • IDs (Sequence`[:py:class:`str]) – IDs of chemicals.

  • units (str, optional) – Units of measure. Defaults to kmol/m3.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_concentration(['Water', 'Ethanol']) # kg/m3
array([27.673,  4.261])
>>> s1.get_concentration(['Water', 'Ethanol'], 'g/L')
array([498.532, 196.291])
get_data()#

Return a StreamData object containing data on material flow rates, temperature, pressure, and phase(s).

See also

Stream.set_data

Examples

Get and set data from stream at different conditions

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream('stream', Water=10)
>>> data = stream.get_data()
>>> stream.vle(V=0.5, P=101325)
>>> data_vle = stream.get_data()
>>> stream.set_data(data)
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water  10
>>> stream.set_data(data_vle)
>>> stream.show()
MultiStream: stream
phases: ('g', 'l'), T: 373.12 K, P: 101325 Pa
flow (kmol/hr): (g) Water  5
                (l) Water  5

Note that only StreamData objects are valid for this method:

>>> stream.set_data({'T': 298.15})
Traceback (most recent call last):
ValueError: stream_data must be a StreamData object; not dict
get_dew_point(IDs=None)#

Return a DewPoint object capable of computing dew points.

Parameters:

IDs (Sequence`[:py:class:`str], optional) – Chemicals that participate in equilibrium. Defaults to all chemicals in equilibrium.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, T=350, units='kg/hr')
>>> s1.get_dew_point()
DewPoint([Water, Ethanol])
get_downstream_units(ends=None, facilities=True)#

Return a set of all units downstream.

get_flow(units, key=Ellipsis)#

Return an flow rates in requested units.

Parameters:
  • units (str) – Units of measure.

  • key (Sequence`[:py:class:`str], str, None]) – Chemical identifiers.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.get_flow('kg/hr', 'Water')
20.0
get_impact(key)#

Return hourly rate of the impact indicator given the key.

get_mass_composition(IDs)#

Return mass fraction of given chemicals.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_mass_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
get_mass_fraction(IDs)#

Return mass fraction of given chemicals.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_mass_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
get_molar_composition(IDs)#

Return molar fraction of given chemicals.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_molar_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
get_molar_fraction(IDs)#

Return molar fraction of given chemicals.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_molar_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
get_normalized_mass(IDs)#

Return normalized mass fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kg/hr')
>>> s1.get_normalized_mass(('Water', 'Ethanol'))
array([0.667, 0.333])
get_normalized_mol(IDs)#

Return normalized molar fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='kmol/hr')
>>> s1.get_normalized_mol(('Water', 'Ethanol'))
array([0.667, 0.333])
get_normalized_vol(IDs)#

Return normalized mass fractions of given chemicals. The sum of the result is always 1.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals to be normalized.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_normalized_vol(('Water', 'Ethanol'))
array([0.667, 0.333])
get_property(name, units=None)#

Return property in requested units.

Parameters:
  • name (str) – Name of property.

  • units (str, optional) – Units of measure. Defaults to the property’s original units of measure.

get_total_flow(units)#

Get total flow rate in given units.

Parameters:

units (str) – Units of measure.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.get_total_flow('kg/hr')
30.0
get_upstream_units(ends=None, facilities=True)#

Return a set of all units upstream.

get_volumetric_composition(IDs)#

Return volumetric fraction of given chemicals.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_volumetric_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
get_volumetric_fraction(IDs)#

Return volumetric fraction of given chemicals.

Parameters:

IDs (Sequence`[:py:class:`str]) – IDs of chemicals.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, Methanol=10, units='m3/hr')
>>> s1.get_volumetric_fraction(('Water', 'Ethanol'))
array([0.5 , 0.25])
property h: float#

Specific enthalpy [kJ/kmol].

property imass: Indexer#

Flow rate indexer with data [kg/hr].

property imol: Indexer#

Flow rate indexer with data [kmol/hr].

in_thermal_equilibrium(other)#

Return whether or not stream is in thermal equilibrium with another stream.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> stream = Stream(Water=1, T=300)
>>> other = Stream(Water=1, T=300)
>>> stream.in_thermal_equilibrium(other)
True
isempty()#

Return whether or not stream is empty.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> stream = tmo.Stream()
>>> stream.isempty()
True
isfeed()#

Return whether stream has a sink but no source.

isproduct()#

Return whether stream has a source but no sink.

property ivol: Indexer#

Flow rate indexer with data [m3/hr].

property kappa: float#

Thermal conductivity [W/m/k].

Link with another stream.

Parameters:
  • other (Stream)

  • flow (bool, optional) – Whether to link the flow rate data. Defaults to True.

  • phase (bool, optional) – Whether to link the phase. Defaults to True.

  • TP (bool, optional) – Whether to link the temperature and pressure. Defaults to True.

See also

flow_proxy, proxy

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.link_with(s1)
>>> s1.mol is s2.mol
True
>>> s2.thermal_condition is s1.thermal_condition
True
>>> s1.phase = 'g'
>>> s2.phase
'g'
property liquid_fraction: float#

Molar liquid fraction.

property lle: LLE#

An object that can perform liquid-liquid equilibrium on the stream.

property lle_chemicals: list[Chemical]#

Chemicals cabable of vapor-liquid equilibrium.

property main_chemical: str#

ID of chemical with the largest mol fraction in stream.

property mass: SparseVector | SparseArray#

Mass flow rates [kg/hr].

mix_from(others, energy_balance=True, vle=False, Q=0.0, conserve_phases=False)#

Mix all other streams into this one, ignoring its initial contents.

Notes

When streams at different pressures are mixed, BioSTEAM assumes valves reduce the pressure of the streams being mixed to prevent backflow (pressure needs to decrease in the direction of flow according to Bernoulli’s principle). The outlet pressure will be the minimum pressure of all streams being mixed.

Examples

Mix two streams with the same thermodynamic property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.copy('s2')
>>> s1.mix_from([s1, s2])
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

It’s also possible to mix streams with different property packages so long as all chemicals are defined in the mixed stream’s property package:

>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1', Water=40, units='kg/hr')
>>> tmo.settings.set_thermo(['Ethanol'], cache=True)
>>> s2 = tmo.Stream('s2', Ethanol=20, units='kg/hr')
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s_mix = tmo.Stream('s_mix')
>>> s_mix.mix_from([s1, s2])
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

Mixing empty streams is fine too:

>>> s1.empty(); s2.empty(); s_mix.mix_from([s1, s2])
>>> s_mix.show()
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow: 0
property mol: ndarray[Any, dtype[float]]#

Molar flow rates [kmol/hr].

property mu: float#

Hydrolic viscosity [Pa*s].

property nu: float#

Kinematic viscosity [m^2/s].

property phase: str#

Phase of stream.

property phases: tuple[str, ...]#

All phases present.

print(units=None)#

Print in a format that you can use recreate the stream.

Parameters:

units (str, optional) – Units of measure for material flow rates. Defaults to ‘kmol/hr’

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream(ID='s1',
...                 Water=20, Ethanol=10, units='kg/hr',
...                 T=298.15, P=101325, phase='l')
>>> s1.print(units='kg/hr')
Stream(ID='s1', phase='l', T=298.15, P=101325, Water=20, Ethanol=10, units='kg/hr')
>>> s1.print() # Units default to kmol/hr
Stream(ID='s1', phase='l', T=298.15, P=101325, Water=1.11, Ethanol=0.2171, units='kmol/hr')
proxy(ID=None)#

Return a new stream that shares all data with this one.

See also

link_with, flow_proxy

Warning

Price and characterization factor data is not shared

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = s1.proxy()
>>> s2.imol is s1.imol and s2.thermal_condition is s1.thermal_condition
True
receive_vent(other, energy_balance=True, ideal=False)#

Receive vapors from another stream by vapor-liquid equilibrium between a gas and liquid stream assuming only a small amount of chemicals in vapor-liquid equilibrium is present

Examples

The energy balance is performed by default:

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol', 'Methanol', tmo.Chemical('N2', phase='g')], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s1 = tmo.Stream('s1', N2=20, units='m3/hr', phase='g', T=330)
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=2, T=330)
>>> s1.receive_vent(s2)
>>> s1.show(flow='kmol/hr')
Stream: s1
phase: 'g', T: 323.12 K, P: 101325 Pa
flow (kmol/hr): Water    0.0799
                Ethanol  0.0887
                N2       0.739

Set energy balance to false to receive vent isothermally:

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol', 'Methanol', tmo.Chemical('N2', phase='g')], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s1 = tmo.Stream('s1', N2=20, units='m3/hr', phase='g', T=330)
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=2, T=330)
>>> s1.receive_vent(s2, energy_balance=False)
>>> s1.show(flow='kmol/hr')
Stream: s1
phase: 'g', T: 330 K, P: 101325 Pa
flow (kmol/hr): Water    0.112
                Ethanol  0.123
                N2       0.739
reduce_phases()#

Remove empty phases.

rescale(scale)#

Multiply flow rate by given scale.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.scale(100)
>>> s1.F_mol
100.0
reset_cache()#

Reset cache regarding equilibrium methods.

reset_flow(phase=None, units=None, total_flow=None, **chemical_flows)#

Convinience method for resetting flow rate data.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.reset_flow(Ethanol=1, phase='g', units='kg/hr', total_flow=2)
>>> s1.show('cwt')
Stream: s1
phase: 'g', T: 298.15 K, P: 101325 Pa
composition (%): Ethanol  100
                 -------  2 kg/hr
property rho: float#

Density [kg/m^3].

sanity_check()#

Raise an InfeasibleRegion error if flow rates are infeasible.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1')
>>> s1.sanity_check()
>>> s1.mol[0] = -1.
>>> s1.sanity_check()
Traceback (most recent call last):
InfeasibleRegion: negative material flow rate is infeasible
scale(scale)#

Multiply flow rate by given scale.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=1)
>>> s1.scale(100)
>>> s1.F_mol
100.0
separate_out(other, energy_balance=True)#

Separate out given stream from this one.

Examples

Separate out another stream with the same thermodynamic property package:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=30, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2', Water=10, Ethanol=5, units='kg/hr')
>>> s1.separate_out(s2)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  5

It’s also possible to separate out streams with different property packages so long as all chemicals are defined in the mixed stream’s property package:

>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1', Water=40, units='kg/hr')
>>> tmo.settings.set_thermo(['Ethanol'], cache=True)
>>> s2 = tmo.Stream('s2', Ethanol=20, units='kg/hr')
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s_mix = tmo.Stream.sum([s1, s2], 's_mix')
>>> s_mix.separate_out(s2)
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  40

Removing empty streams is fine too:

>>> s1.empty(); s_mix.separate_out(s1)
>>> s_mix.show(flow='kg/hr')
Stream: s_mix
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  40
set_CF(key, value, basis=None, units=None)#

Set the life-cycle characterization factor on a kg basis given the impact indicator key and the units of measure.

Parameters:
  • key (str) – Key of impact indicator.

  • value (float) – Characterization factor value.

  • basis (str, optional) – Basis of characterization factor. Mass is the only valid dimension (for now). Defaults to ‘kg’.

  • units (str, optional) – Units of impact indicator. Before using this argument, the default units of the impact indicator should be defined with settings.define_impact_indicator. Units must also be dimensionally consistent with the default units.

set_data(stream_data)#

Set material flow rates, temperature, pressure, and phase(s) through a StreamData object

See also

Stream.get_data

set_flow(data, units, key=Ellipsis)#

Set flow rates in given units.

Parameters:
  • data (Any, dtype`[:py:class:`float]] | float) – Flow rate data.

  • units (str) – Units of measure.

  • key (Sequence`[:py:class:`str], str, None]) – Chemical identifiers.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream(ID='s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.set_flow(10, 'kg/hr', 'Water')
>>> s1.get_flow('kg/hr', 'Water')
10.0
set_property(name, value, units=None)#

Set property in given units.

Parameters:
  • name (str) – Name of property.

  • value (float) – New value of property.

  • units (str, optional) – Units of measure.

set_total_flow(value, units)#

Set total flow rate in given units keeping the composition constant.

Parameters:
  • value (float) – New total flow rate.

  • units (str) – Units of measure.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s1.set_total_flow(1.0,'kg/hr')
>>> s1.get_total_flow('kg/hr')
0.9999999999999999
shares_flow_rate_with(other)#

Return whether other stream shares data with this one.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> s1 = tmo.Stream('s1')
>>> other = s1.flow_proxy()
>>> s1.shares_flow_rate_with(other)
True
>>> s1 = tmo.MultiStream('s1', phases=('l', 'g'))
>>> s1['g'].shares_flow_rate_with(s1)
True
>>> s2 = tmo.MultiStream('s2', phases=('l', 'g'))
>>> s1['g'].shares_flow_rate_with(s2)
False
>>> s1['g'].shares_flow_rate_with(s2['g'])
False
>>> s1 = tmo.MultiStream('s1')
>>> other = s1.flow_proxy()
>>> s1.shares_flow_rate_with(other)
True
>>> s1 = tmo.MultiStream('s1', phases=('l', 'g'))
>>> s1.shares_flow_rate_with(s1['g'])
True
>>> s2 = tmo.MultiStream('s2', phases=('l', 'g'))
>>> s2.shares_flow_rate_with(s1['g'])
False
>>> s1.shares_flow_rate_with(s2)
False
show(layout=None, T=None, P=None, flow=None, composition=None, N=None, IDs=None, sort=None, df=None)#

Print all specifications.

Parameters:
  • layout (str, optional) – Convenience paramater for passing flow, composition, and N. Must have the form {‘c’ or ‘’}{‘wt’, ‘mol’ or ‘vol’}{# or ‘’}. For example: ‘cwt100’ corresponds to compostion=True, flow=’kg/hr’, and N=100.

  • T (str, optional) – Temperature units.

  • P (str, optional) – Pressure units.

  • flow (str, optional) – Flow rate units.

  • composition (bool, optional) – Whether to show composition.

  • N (int, optional) – Number of compounds to display.

  • IDs (Sequence`[:py:class:`str], optional) – IDs of compounds to display. Defaults to all chemicals.

  • sort (bool, optional) – Whether to sort flows in descending order.

  • df (bool, optional) – Whether to return a pandas DataFrame.

Examples

Show a stream’s composition by weight for only the top 2 chemicals with the highest mass fractions:

>>> import biosteam as bst
>>> bst.settings.set_thermo(['Water', 'Ethanol', 'Methanol', 'Propanol'])
>>> stream = bst.Stream('stream', Water=0.5, Ethanol=1.5, Methanol=0.2, Propanol=0.3, units='kg/hr')
>>> stream.show('cwt2s') # Alternatively: stream.show(composition=True, flow='kg/hr', N=2, sort=True)
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
composition (%): Ethanol  60
                 Water    20
                 ...      20
                 -------  2.5 kg/hr
property sigma: float#

Surface tension [N/m].

property sink: AbstractUnit#

Inlet location.

property sle: SLE#

An object that can perform solid-liquid equilibrium on the stream.

property solid_fraction: float#

Molar solid fraction.

property source: AbstractUnit#

Outlet location.

split_to(s1, s2, split, energy_balance=True)#

Split molar flow rate from this stream to two others given the split fraction or an array of split fractions.

Examples

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol'], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> s = tmo.Stream('s', Water=20, Ethanol=10, units='kg/hr')
>>> s1 = tmo.Stream('s1')
>>> s2 = tmo.Stream('s2')
>>> split = chemicals.kwarray(dict(Water=0.5, Ethanol=0.1))
>>> s.split_to(s1, s2, split)
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    10
              Ethanol  1
>>> s2.show(flow='kg/hr')
Stream: s2
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    10
              Ethanol  9
classmethod sum(streams, ID=None, thermo=None, energy_balance=True, vle=False)#

Return a new Stream object that represents the sum of all given streams.

Examples

Sum two streams:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s_sum = tmo.Stream.sum([s1, s1], 's_sum')
>>> s_sum.show(flow='kg/hr')
Stream: s_sum
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20

Sum two streams with new property package:

>>> thermo = tmo.Thermo(['Water', 'Ethanol', 'Methanol'], cache=True)
>>> s_sum = tmo.Stream.sum([s1, s1], 's_sum', thermo)
>>> s_sum.show(flow='kg/hr')
Stream: s_sum
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    40
              Ethanol  20
property thermal_condition: ThermalCondition#

Contains the temperature and pressure conditions of the stream.

Unlink stream from other streams.

Examples

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)
>>> s1 = tmo.Stream('s1', Water=20, Ethanol=10, units='kg/hr')
>>> s2 = tmo.Stream('s2')
>>> s2.link_with(s1)
>>> s1.unlink()
>>> s2.mol is s1.mol
False
>>> s1.phases = s2.phases = ('l', 'g')
>>> s2.link_with(s1)
>>> s1.imol.data is s2.imol.data
True
>>> s1.unlink()
>>> s1.imol.data is s2.imol.data
False

MultiStream phases cannot be unlinked:

>>> s1 = tmo.MultiStream(None, phases=('l', 'g'))
>>> s1['g'].unlink()
Traceback (most recent call last):
RuntimeError: phase is locked; stream cannot be unlinked
property vapor_fraction: float#

Molar vapor fraction.

property vle: VLE#

An object that can perform vapor-liquid equilibrium on the stream.

property vle_chemicals: list[Chemical]#

Chemicals cabable of liquid-liquid equilibrium.

vlle(T, P)#

Estimate vapor-liquid-liquid equilibrium.

Warning

This method may be as slow as 1 second.

property vol: SparseVector | SparseArray#

Volumetric flow rates [m3/hr].

property z_mass: ndarray[Any, dtype[float]]#

Mass composition.

property z_mol: ndarray[Any, dtype[float]]#

Molar composition.

property z_vol: ndarray[Any, dtype[float]]#

Volumetric composition.