Unit#

class Unit(ID='', ins=None, outs=(), thermo=None, **kwargs)[source]#

Abstract class for Unit objects. Child objects must contain _run, _design and _cost methods to estimate stream outlets of a Unit and find design and cost information.

Parameters:
  • ID (str, optional) – A unique identification. If ID is None, unit will not be registered in flowsheet. By default, a unique ID will be chosen.

  • ins (Stream], optional) – Inlet streams or IDs to initialize inlet streams. If empty tuple, streams with default IDs will be created. By default, streams will be missing.

  • outs (Stream], optional) – Outlet streams or IDs to initialize outlet streams. By default, streams with unique IDs will be created. If None, streams will be missing.

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

Notes

The free on board (f.o.b.) purchase costs and installed equipment costs (i.e. bare-module cost) for each item in the baseline_purchase_costs dictionary and in auxiliary units are automatically added to the purchase_costs and installed_costs dictionaries.

As explained in [1], the f.o.b. purchase cost is given by:

\[C_{P} = C_{Pb}F_{D}F_{P}F_{M}\]

And the installed equipment cost is given by:

\[C_{BM} = C_{Pb} (F_{BM} + F_{D}F_{P}F_{M} - 1)\]
Where:
  • \(C_{Pb}\): Baseline purchase cost.

  • \(F_{BM}\): Bare module factor.

  • \(F_{D}\): Design factor.

  • \(F_{P}\): Pressure factor.

  • \(F_{M}\): Material factor.

Values for the bare-module, design, pressure, and material factors of each equipment should be stored in the F_BM, F_D, F_P, and F_M dictionaries.

Examples

Creating a Unit

-pipe- notation

Inheriting from Unit

References

class Stream(ID='', flow=(), phase='l', T=298.15, P=101325.0, units=None, price=0.0, total_flow=None, thermo=None, characterization_factors=None, vlle=False, **chemical_flows)#

Create a Stream object that defines material flow rates along with its thermodynamic state. Thermodynamic and transport properties of a stream are available as properties, while thermodynamic equilbrium (e.g. VLE, and bubble and dew points) are available as methods.

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 (Sequence`[:py:class:`float]) – 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’.

  • price (float, optional) – Price per unit mass [USD/kg]. Defaults to 0.

  • total_flow (float, optional) – Total flow rate.

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

  • characterization_factors (dict`[:py:class:`str, float], optional) – Characterization factors for life cycle assessment.

  • vlle (bool, optional) – Whether to run rigorous phase equilibrium to determine phases. Defaults to False.

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

Examples

Before creating a stream, first set the chemicals:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)

Create a stream, defining the thermodynamic condition and flow rates:

>>> s1 = tmo.Stream(ID='s1',
...                 Water=20, Ethanol=10, units='kg/hr',
...                 T=298.15, P=101325, phase='l')
>>> s1.show(flow='kg/hr') # Use the show method to select units of display
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
>>> s1.show(composition=True, flow='kg/hr') # Its also possible to show by composition
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
composition (%): Water    66.7
                 Ethanol  33.3
                 -------  30 kg/hr

All flow rates are stored as a sparse array in the mol attribute. These arrays work just like numpy arrays, but are more scalable (saving memory and increasing speed) for sparse chemical data:

>>> s1.mol # Molar flow rates [kmol/hr]
sparse([1.11 , 0.217])

Mass and volumetric flow rates are also available for convenience:

>>> s1.mass
sparse([20., 10.])
>>> s1.vol
sparse([0.02 , 0.013])

The data of these arrays are linked to the molar flows:

>>> # Mass flows are always up to date with molar flows
>>> s1.mol[0] = 1
>>> s1.mass[0]
18.015
>>> # Changing mass flows changes molar flows
>>> s1.mass[0] *= 2
>>> s1.mol[0]
2.0
>>> # New arrays are not linked to molar flows
>>> s1.mass + 2
sparse([38.031, 12.   ])

The temperature, pressure and phase are attributes as well:

>>> (s1.T, s1.P, s1.phase)
(298.15, 101325.0, 'l')

The most convinient way to get and set flow rates is through the get_flow and set_flow methods:

>>> # Set flow
>>> s1.set_flow(1, 'gpm', 'Water')
>>> s1.get_flow('gpm', 'Water')
1.0
>>> # Set multiple flows
>>> s1.set_flow([10, 20], 'kg/hr', ('Ethanol', 'Water'))
>>> s1.get_flow('kg/hr', ('Ethanol', 'Water'))
array([10., 20.])

It is also possible to index using IDs through the imol, imass, and ivol indexers:

>>> s1.imol.show()
ChemicalMolarFlowIndexer (kmol/hr):
 (l) Water    1.11
     Ethanol  0.2171
>>> s1.imol['Water']
1.1101687012358397
>>> s1.imol['Ethanol', 'Water']
array([0.217, 1.11 ])

Thermodynamic properties are available as stream properties:

>>> s1.H # Enthalpy (kJ/hr)
0.0

Note that the reference enthalpy is 0.0 at the reference temperature of 298.15 K, and pressure of 101325 Pa. Retrive the enthalpy at a 10 degC above the reference.

>>> s1.T += 10
>>> s1.H
1083.46

Other thermodynamic properties are temperature and pressure dependent as well:

>>> s1.rho # Density [kg/m3]
909.14

It may be more convinient to get properties with different units:

>>> s1.get_property('rho', 'g/cm3')
0.9091

It is also possible to set some of the properties in different units:

>>> s1.set_property('T', 40, 'degC')
>>> s1.T
313.15

Bubble point and dew point computations can be performed through stream methods:

>>> bp = s1.bubble_point_at_P() # Bubble point at constant pressure
>>> bp
BubblePointValues(T=357.14, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.492 0.508])

The bubble point results contain all results as attributes:

>>> tmo.docround(bp.T) # Temperature [K]
357.1442
>>> bp.y # Vapor composition
array([0.49, 0.51])

Vapor-liquid equilibrium can be performed by setting 2 degrees of freedom from the following list: T [Temperature; in K], P [Pressure; in Pa], V [Vapor fraction], H [Enthalpy; in kJ/hr].

Set vapor fraction and pressure of the stream:

>>> s1.vle(P=101325, V=0.5)
>>> s1.show()
MultiStream: s1
phases: ('g', 'l'), T: 364.78 K, P: 101325 Pa
flow (kmol/hr): (g) Water    0.472
                    Ethanol  0.191
                (l) Water    0.638
                    Ethanol  0.0257

Note that the stream is a now a MultiStream object to manage multiple phases. Each phase can be accessed separately too:

>>> s1['l'].show()
Stream:
phase: 'l', T: 364.78 K, P: 101325 Pa
flow (kmol/hr): Water    0.638
                Ethanol  0.0257
>>> s1['g'].show()
Stream:
phase: 'g', T: 364.78 K, P: 101325 Pa
flow (kmol/hr): Water    0.472
                Ethanol  0.191

We can convert a MultiStream object back to a Stream object by setting the phase:

>>> s1.phase = 'l'
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 364.78 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
characterization_factors: dict[str, float]#

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

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 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])
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, optional) – 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
property cost: float#

Total cost of stream [USD/hr].

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])
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, optional) – 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
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.

property price: float#

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

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 (NDArray[float] | float) – Flow rate data.

  • units (str) – Units of measure.

  • key (Sequence`[:py:class:`str] | str, optional) – 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 sle: SLE#

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

property solid_fraction: float#

Molar solid fraction.

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.

_units: dict[str, str] = {}#

class-attribute Units of measure for design_results dictionary.

_F_BM_default: dict[str, float] = {}#

class-attribute Default bare-module factors for each purchase cost item. Items in this dictionary are copied to the F_BM attribute during initialization.

_materials_and_maintenance: frozen:py:class:set[str] = frozenset({})#

class-attribute Cost items that need to be summed across operation modes for flexible operation (e.g., filtration membranes).

_default_equipment_lifetime: int | dict[str, int] = {}#

class-attribute Lifetime of equipment. Defaults to lifetime of production venture. Use an integer to specify the lifetime for all items in the unit purchase costs. Use a dictionary to specify the lifetime of each purchase cost item.

_design = AbstractMethod#

Add design requirements to the design_results dictionary.

_cost = AbstractMethod#

Add itemized purchase costs to the baseline_purchase_costs dictionary.

class Inlets(sink, size, streams, thermo, fixed_size, stacklevel)#
class MissingStream(source=None, sink=None)#

Create a MissingStream object that acts as a dummy in Inlets and Outlets objects until replaced by an actual Stream object.

materialize_connection(ID=None)#

Disconnect this missing stream from any unit operations and replace it with a material stream.

reset_cache()#

Does nothing, MissingStream objects do not contain cache.

class Stream(ID='', flow=(), phase='l', T=298.15, P=101325.0, units=None, price=0.0, total_flow=None, thermo=None, characterization_factors=None, vlle=False, **chemical_flows)#

Create a Stream object that defines material flow rates along with its thermodynamic state. Thermodynamic and transport properties of a stream are available as properties, while thermodynamic equilbrium (e.g. VLE, and bubble and dew points) are available as methods.

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 (Sequence`[:py:class:`float]) – 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’.

  • price (float, optional) – Price per unit mass [USD/kg]. Defaults to 0.

  • total_flow (float, optional) – Total flow rate.

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

  • characterization_factors (dict`[:py:class:`str, float], optional) – Characterization factors for life cycle assessment.

  • vlle (bool, optional) – Whether to run rigorous phase equilibrium to determine phases. Defaults to False.

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

Examples

Before creating a stream, first set the chemicals:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)

Create a stream, defining the thermodynamic condition and flow rates:

>>> s1 = tmo.Stream(ID='s1',
...                 Water=20, Ethanol=10, units='kg/hr',
...                 T=298.15, P=101325, phase='l')
>>> s1.show(flow='kg/hr') # Use the show method to select units of display
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
>>> s1.show(composition=True, flow='kg/hr') # Its also possible to show by composition
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
composition (%): Water    66.7
                 Ethanol  33.3
                 -------  30 kg/hr

All flow rates are stored as a sparse array in the mol attribute. These arrays work just like numpy arrays, but are more scalable (saving memory and increasing speed) for sparse chemical data:

>>> s1.mol # Molar flow rates [kmol/hr]
sparse([1.11 , 0.217])

Mass and volumetric flow rates are also available for convenience:

>>> s1.mass
sparse([20., 10.])
>>> s1.vol
sparse([0.02 , 0.013])

The data of these arrays are linked to the molar flows:

>>> # Mass flows are always up to date with molar flows
>>> s1.mol[0] = 1
>>> s1.mass[0]
18.015
>>> # Changing mass flows changes molar flows
>>> s1.mass[0] *= 2
>>> s1.mol[0]
2.0
>>> # New arrays are not linked to molar flows
>>> s1.mass + 2
sparse([38.031, 12.   ])

The temperature, pressure and phase are attributes as well:

>>> (s1.T, s1.P, s1.phase)
(298.15, 101325.0, 'l')

The most convinient way to get and set flow rates is through the get_flow and set_flow methods:

>>> # Set flow
>>> s1.set_flow(1, 'gpm', 'Water')
>>> s1.get_flow('gpm', 'Water')
1.0
>>> # Set multiple flows
>>> s1.set_flow([10, 20], 'kg/hr', ('Ethanol', 'Water'))
>>> s1.get_flow('kg/hr', ('Ethanol', 'Water'))
array([10., 20.])

It is also possible to index using IDs through the imol, imass, and ivol indexers:

>>> s1.imol.show()
ChemicalMolarFlowIndexer (kmol/hr):
 (l) Water    1.11
     Ethanol  0.2171
>>> s1.imol['Water']
1.1101687012358397
>>> s1.imol['Ethanol', 'Water']
array([0.217, 1.11 ])

Thermodynamic properties are available as stream properties:

>>> s1.H # Enthalpy (kJ/hr)
0.0

Note that the reference enthalpy is 0.0 at the reference temperature of 298.15 K, and pressure of 101325 Pa. Retrive the enthalpy at a 10 degC above the reference.

>>> s1.T += 10
>>> s1.H
1083.46

Other thermodynamic properties are temperature and pressure dependent as well:

>>> s1.rho # Density [kg/m3]
909.14

It may be more convinient to get properties with different units:

>>> s1.get_property('rho', 'g/cm3')
0.9091

It is also possible to set some of the properties in different units:

>>> s1.set_property('T', 40, 'degC')
>>> s1.T
313.15

Bubble point and dew point computations can be performed through stream methods:

>>> bp = s1.bubble_point_at_P() # Bubble point at constant pressure
>>> bp
BubblePointValues(T=357.14, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.492 0.508])

The bubble point results contain all results as attributes:

>>> tmo.docround(bp.T) # Temperature [K]
357.1442
>>> bp.y # Vapor composition
array([0.49, 0.51])

Vapor-liquid equilibrium can be performed by setting 2 degrees of freedom from the following list: T [Temperature; in K], P [Pressure; in Pa], V [Vapor fraction], H [Enthalpy; in kJ/hr].

Set vapor fraction and pressure of the stream:

>>> s1.vle(P=101325, V=0.5)
>>> s1.show()
MultiStream: s1
phases: ('g', 'l'), T: 364.78 K, P: 101325 Pa
flow (kmol/hr): (g) Water    0.472
                    Ethanol  0.191
                (l) Water    0.638
                    Ethanol  0.0257

Note that the stream is a now a MultiStream object to manage multiple phases. Each phase can be accessed separately too:

>>> s1['l'].show()
Stream:
phase: 'l', T: 364.78 K, P: 101325 Pa
flow (kmol/hr): Water    0.638
                Ethanol  0.0257
>>> s1['g'].show()
Stream:
phase: 'g', T: 364.78 K, P: 101325 Pa
flow (kmol/hr): Water    0.472
                Ethanol  0.191

We can convert a MultiStream object back to a Stream object by setting the phase:

>>> s1.phase = 'l'
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 364.78 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
characterization_factors: dict[str, float]#

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

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 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])
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, optional) – 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
property cost: float#

Total cost of stream [USD/hr].

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])
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, optional) – 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
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.

property price: float#

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

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 (NDArray[float] | float) – Flow rate data.

  • units (str) – Units of measure.

  • key (Sequence`[:py:class:`str] | str, optional) – 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 sle: SLE#

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

property solid_fraction: float#

Molar solid fraction.

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.

class Outlets(source, size, streams, thermo, fixed_size, stacklevel)#
class MissingStream(source=None, sink=None)#

Create a MissingStream object that acts as a dummy in Inlets and Outlets objects until replaced by an actual Stream object.

materialize_connection(ID=None)#

Disconnect this missing stream from any unit operations and replace it with a material stream.

reset_cache()#

Does nothing, MissingStream objects do not contain cache.

class Stream(ID='', flow=(), phase='l', T=298.15, P=101325.0, units=None, price=0.0, total_flow=None, thermo=None, characterization_factors=None, vlle=False, **chemical_flows)#

Create a Stream object that defines material flow rates along with its thermodynamic state. Thermodynamic and transport properties of a stream are available as properties, while thermodynamic equilbrium (e.g. VLE, and bubble and dew points) are available as methods.

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 (Sequence`[:py:class:`float]) – 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’.

  • price (float, optional) – Price per unit mass [USD/kg]. Defaults to 0.

  • total_flow (float, optional) – Total flow rate.

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

  • characterization_factors (dict`[:py:class:`str, float], optional) – Characterization factors for life cycle assessment.

  • vlle (bool, optional) – Whether to run rigorous phase equilibrium to determine phases. Defaults to False.

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

Examples

Before creating a stream, first set the chemicals:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True)

Create a stream, defining the thermodynamic condition and flow rates:

>>> s1 = tmo.Stream(ID='s1',
...                 Water=20, Ethanol=10, units='kg/hr',
...                 T=298.15, P=101325, phase='l')
>>> s1.show(flow='kg/hr') # Use the show method to select units of display
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
>>> s1.show(composition=True, flow='kg/hr') # Its also possible to show by composition
Stream: s1
phase: 'l', T: 298.15 K, P: 101325 Pa
composition (%): Water    66.7
                 Ethanol  33.3
                 -------  30 kg/hr

All flow rates are stored as a sparse array in the mol attribute. These arrays work just like numpy arrays, but are more scalable (saving memory and increasing speed) for sparse chemical data:

>>> s1.mol # Molar flow rates [kmol/hr]
sparse([1.11 , 0.217])

Mass and volumetric flow rates are also available for convenience:

>>> s1.mass
sparse([20., 10.])
>>> s1.vol
sparse([0.02 , 0.013])

The data of these arrays are linked to the molar flows:

>>> # Mass flows are always up to date with molar flows
>>> s1.mol[0] = 1
>>> s1.mass[0]
18.015
>>> # Changing mass flows changes molar flows
>>> s1.mass[0] *= 2
>>> s1.mol[0]
2.0
>>> # New arrays are not linked to molar flows
>>> s1.mass + 2
sparse([38.031, 12.   ])

The temperature, pressure and phase are attributes as well:

>>> (s1.T, s1.P, s1.phase)
(298.15, 101325.0, 'l')

The most convinient way to get and set flow rates is through the get_flow and set_flow methods:

>>> # Set flow
>>> s1.set_flow(1, 'gpm', 'Water')
>>> s1.get_flow('gpm', 'Water')
1.0
>>> # Set multiple flows
>>> s1.set_flow([10, 20], 'kg/hr', ('Ethanol', 'Water'))
>>> s1.get_flow('kg/hr', ('Ethanol', 'Water'))
array([10., 20.])

It is also possible to index using IDs through the imol, imass, and ivol indexers:

>>> s1.imol.show()
ChemicalMolarFlowIndexer (kmol/hr):
 (l) Water    1.11
     Ethanol  0.2171
>>> s1.imol['Water']
1.1101687012358397
>>> s1.imol['Ethanol', 'Water']
array([0.217, 1.11 ])

Thermodynamic properties are available as stream properties:

>>> s1.H # Enthalpy (kJ/hr)
0.0

Note that the reference enthalpy is 0.0 at the reference temperature of 298.15 K, and pressure of 101325 Pa. Retrive the enthalpy at a 10 degC above the reference.

>>> s1.T += 10
>>> s1.H
1083.46

Other thermodynamic properties are temperature and pressure dependent as well:

>>> s1.rho # Density [kg/m3]
909.14

It may be more convinient to get properties with different units:

>>> s1.get_property('rho', 'g/cm3')
0.9091

It is also possible to set some of the properties in different units:

>>> s1.set_property('T', 40, 'degC')
>>> s1.T
313.15

Bubble point and dew point computations can be performed through stream methods:

>>> bp = s1.bubble_point_at_P() # Bubble point at constant pressure
>>> bp
BubblePointValues(T=357.14, P=101325, IDs=('Water', 'Ethanol'), z=[0.836 0.164], y=[0.492 0.508])

The bubble point results contain all results as attributes:

>>> tmo.docround(bp.T) # Temperature [K]
357.1442
>>> bp.y # Vapor composition
array([0.49, 0.51])

Vapor-liquid equilibrium can be performed by setting 2 degrees of freedom from the following list: T [Temperature; in K], P [Pressure; in Pa], V [Vapor fraction], H [Enthalpy; in kJ/hr].

Set vapor fraction and pressure of the stream:

>>> s1.vle(P=101325, V=0.5)
>>> s1.show()
MultiStream: s1
phases: ('g', 'l'), T: 364.78 K, P: 101325 Pa
flow (kmol/hr): (g) Water    0.472
                    Ethanol  0.191
                (l) Water    0.638
                    Ethanol  0.0257

Note that the stream is a now a MultiStream object to manage multiple phases. Each phase can be accessed separately too:

>>> s1['l'].show()
Stream:
phase: 'l', T: 364.78 K, P: 101325 Pa
flow (kmol/hr): Water    0.638
                Ethanol  0.0257
>>> s1['g'].show()
Stream:
phase: 'g', T: 364.78 K, P: 101325 Pa
flow (kmol/hr): Water    0.472
                Ethanol  0.191

We can convert a MultiStream object back to a Stream object by setting the phase:

>>> s1.phase = 'l'
>>> s1.show(flow='kg/hr')
Stream: s1
phase: 'l', T: 364.78 K, P: 101325 Pa
flow (kg/hr): Water    20
              Ethanol  10
characterization_factors: dict[str, float]#

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

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 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])
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, optional) – 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
property cost: float#

Total cost of stream [USD/hr].

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])
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, optional) – 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
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.

property price: float#

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

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 (NDArray[float] | float) – Flow rate data.

  • units (str) – Units of measure.

  • key (Sequence`[:py:class:`str] | str, optional) – 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 sle: SLE#

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

property solid_fraction: float#

Molar solid fraction.

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.

heat_utilities: list[HeatUtility, ...]#

All heat utilities associated to unit. Cooling and heating requirements are stored here (including auxiliary requirements).

power_utility: PowerUtility#

Electric utility associated to unit (including auxiliary requirements).

F_BM: dict[str, float]#

All bare-module factors for each purchase cost. Defaults to values in the class attribute _F_BM_default.

F_D: dict[str, float]#

All design factors for each purchase cost item in baseline_purchase_costs.

F_P: dict[str, float]#

All pressure factors for each purchase cost item in baseline_purchase_costs.

F_M: dict[str, float]#

All material factors for each purchase cost item in baseline_purchase_costs.

design_results: dict[str, object]#

All design requirements excluding utility requirements and detailed auxiliary unit requirements.

baseline_purchase_costs: dict[str, float]#

All baseline purchase costs without accounting for design, pressure, and material factors.

purchase_costs: dict[str, float]#

Itemized purchase costs (including auxiliary units) accounting for design, pressure, and material factors (i.e., F_D, F_P, F_M). Items here are automatically updated at the end of unit simulation.

installed_costs: dict[str, float]#

All installed costs accounting for bare module, design, pressure, and material factors. Items here are automatically updated at the end of unit simulation.

equipment_lifetime: int | dict[str, int]#

Lifetime of equipment. Defaults to values in the class attribute _default_equipment_lifetime. Use an integer to specify the lifetime for all items in the unit purchase costs. Use a dictionary to specify the lifetime of each purchase cost item.

parallel: dict[str, int]#

Name-number pairs of baseline purchase costs and auxiliary unit operations in parallel. Use ‘self’ to refer to the main unit. Capital and heat and power utilities in parallel will become proportional to this value.

responses: set[GenericResponse]#

Unit design decisions that must be solved to satisfy specifications. While adding responses is optional, simulations benefit from responses by being able to predict better guesses.

response(name)[source]#

Register response for convergence model prediction.

property net_power: float#

Net power consumption [kW].

property net_duty: float#

Net duty including heat transfer losses [kJ/hr].

property net_cooling_duty: float#

Net cooling duty including heat transfer losses [kJ/hr].

property net_heating_duty: float#

Net cooling duty including heat transfer losses [kJ/hr].

property feed: Stream#

Equivalent to ins[0] when the number of inlets is 1.

property inlet: Stream#

Equivalent to ins[0] when the number of inlets is 1.

property influent: Stream#

Equivalent to ins[0] when the number of inlets is 1.

property product: Stream#

Equivalent to outs[0] when the number of outlets is 1.

property outlet: Stream#

Equivalent to outs[0] when the number of outlets is 1.

property effluent: Stream#

Equivalent to outs[0] when the number of outlets is 1.

add_power_utility(power)[source]#

Add power utility [kW]. Use a positive value for consumption and a negative for production.

create_heat_utility(agent=None, heat_transfer_efficiency=None)[source]#

Create heat utility object associated to unit.

add_heat_utility(unit_duty, T_in, T_out=None, agent=None, heat_transfer_efficiency=None, hxn_ok=False)[source]#

Add utility requirement given the duty and inlet and outlet temperatures.

Parameters:
  • unit_duty (float) – Unit duty requirement [kJ/hr]

  • T_in (float) – Inlet process stream temperature [K]

  • T_out (float, optional) – Outlet process stream temperature [K]

  • agent (UtilityAgent, optional) – Utility agent to use. Defaults to a suitable agent from predefined heating/cooling utility agents.

  • heat_transfer_efficiency (float, optional) – Enforced fraction of heat transfered from utility (due to losses to environment).

  • hxn_ok (bool, optional) – Whether heat utility can be satisfied within a heat exchanger network.

define_utility(name, stream)[source]#

Define an inlet or outlet stream as a utility by name.

Parameters:
define_credit(name, stream)[source]#

Define an inlet or outlet stream as a fee/credit by name.

Parameters:
define_fee(name, stream)#

Define an inlet or outlet stream as a fee/credit by name.

Parameters:
get_design_result(key, units)[source]#

Return design result in a new set of units of measure.

Parameters:
  • key (str) – Name of design result.

  • units (str) – Units of measure.

Examples

>>> import biosteam as bst
>>> bst.settings.set_thermo(['Water'], cache=True)
>>> feed = bst.Stream(None, Water=100)
>>> tank = bst.StorageTank(None, feed)
>>> tank.simulate()
>>> tank.get_design_result('Total volume', 'm3')
1214.19
>>> tank.get_design_result('Total volume', 'L')
1214191.0
_summary(design_kwargs=None, cost_kwargs=None, lca_kwargs=None)[source]#

Run design/cost/LCA algorithms and compile results.

property specifications: list[ProcessSpecification]#

Process specifications as a list of process specification objects.

See also

add_specification, add_bounded_numerical_specification

property baseline_purchase_cost: float#

Total baseline purchase cost, without accounting for design , pressure, and material factors [USD].

property purchase_cost: float#

Total purchase cost [USD].

property installed_cost: float#

Total installed equipment cost [USD].

property utility_cost: float#

Total utility cost [USD/hr].

mass_balance_error()[source]#

Return error in stoichiometric mass balance. If positive, mass is being created. If negative, mass is being destroyed.

atomic_balance_error()[source]#

Return a dictionary of errors in stoichiometric atomic balances. If value is positive, the atom is being created. If negative, the atom is being destroyed.

empty()[source]#

Empty all unit operation results and outlet flows.

simulate(run=None, design_kwargs=None, cost_kwargs=None)[source]#

Run rigorous simulation and determine all design requirements.

Parameters:
  • run (bool, optional) – Whether to run mass and energy balance or to assume the same inlet and outlet conditions. Defaults to True.

  • design_kwargs (dict, optional) – Keyword arguments passed to _design method.

  • cost_kwargs (dict, optional) – Keyword arguments passed to _cost method.

results(with_units=True, include_utilities=True, include_total_cost=True, include_installed_cost=False, include_zeros=True, external_utilities=None, key_hook=None)[source]#

Return key results from simulation as a DataFrame if with_units is True or as a Series otherwise.

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

Molar flows going in [kmol/hr].

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

Molar flows going out [kmol/hr].

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

Molar fractions going in [kmol/hr].

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

Molar fractions going in.

property F_mol_in: float#

Net molar flow going in [kmol/hr].

property F_mol_out: float#

Net molar flow going out [kmol/hr].

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

Mass flows going in [kg/hr].

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

Mass flows going out [kg/hr].

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

Mass fractions going in.

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

Mass fractions going out.

property F_mass_in: float#

Net mass flow going in [kg/hr].

property F_mass_out: float#

Net mass flow going out [kg/hr].

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

Volumetric flows going in [m3/hr].

property F_vol_in: float#

Net volumetric flow going in [m3/hr].

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

Volumetric fractions going in.

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

Volumetric flows going out [m3/hr].

property F_vol_out: float#

Net volumetric flow going out [m3/hr].

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

Volumetric fractions going out.

property H_in: float#

Enthalpy flow going in [kJ/hr].

property H_out: float#

Enthalpy flow going out [kJ/hr].

property Hf_in: float#

Enthalpy of formation flow going in [kJ/hr].

property Hf_out: float#

Enthalpy of formation flow going out [kJ/hr].

property Hnet: float#

Net enthalpy flow, including enthalpies of formation [kJ/hr].

class SuperpositionInlet(port, sink=None)#
property C#

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

property Cn#

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

property Cp#

Isobaric heat capacity [J/g/K].

property F_mass#

Total mass flow rate [kg/hr].

property F_mol#

Total molar flow rate [kmol/hr].

property F_vol#

Total volumetric flow rate [m3/hr].

property H#

Enthalpy flow rate [kJ/hr].

property HHV#

Higher heating value flow rate [kJ/hr].

property Hf#

Enthalpy of formation flow rate [kJ/hr].

property Hnet#

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

property Hvap#

Enthalpy of vaporization flow rate [kJ/hr].

property LHV#

Lower heating value flow rate [kJ/hr].

property MW#

Overall molecular weight.

property P#

Pressure [Pa].

property P_vapor#

Vapor pressure of liquid.

property Pr#

Prandtl number [-].

property S#

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

property T#

Temperature [K].

property V#

Molar volume [m^3/mol].

property alpha#

Thermal diffusivity [m^2/s].

property as_stream#

Does nothing.

property available_chemicals#

All chemicals with nonzero flow.

property bubble_point_at_P#

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

Parameters:

IDs – 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])
property bubble_point_at_T#

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

Parameters:
  • T – Temperature [K].

  • IDs – 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])
property characterization_factors#
property copy#

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.

property copy_flow#

Copy flow rates of another stream to self.

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

  • IDs – Chemical IDs.

  • remove – If True, copied chemicals will be removed from stream.

  • exclude – 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
property copy_like#

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
property copy_phase#

Copy phase from another stream.

property copy_thermal_condition#

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
property cost#

Total cost of stream [USD/hr].

property dew_point_at_P#

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

Parameters:

IDs – 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])
property dew_point_at_T#

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

Parameters:

IDs – 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])
property display_notation#

Create a DisplayNotation object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_notation.flow = '.2g'
>>> stream = tmo.Stream('stream', Water=1.324, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water  0.073
>>> # Change back to kmol/hr
>>> tmo.Stream.display_notation.flow = '.3g'
property display_units#

Create a DisplayUnits object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_units.flow = 'kg/hr'
>>> stream = tmo.Stream('stream', Water=1, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  1
>>> # Change back to kmol/hr
>>> tmo.Stream.display_units.flow = 'kmol/hr'
property 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
property 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#

Relative permittivity [-].

property flow_proxy#

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
property get_CF#

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

Parameters:
  • key – Key of impact indicator.

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

  • units – 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.

property get_atomic_flow#

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
property 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}
property get_bubble_point#

Return a BubblePoint object capable of computing bubble points.

Parameters:

IDs – 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])
property get_concentration#

Return concentration of given chemicals.

Parameters:
  • IDs – IDs of chemicals.

  • units – 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])
property 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
property get_dew_point#

Return a DewPoint object capable of computing dew points.

Parameters:

IDs – 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])
property get_downstream_units#

Return a set of all units downstream.

property get_flow#

Return an flow rates in requested units.

Parameters:
  • units – Units of measure.

  • key – 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
property get_impact#

Return hourly rate of the impact indicator given the key.

property get_mass_composition#

Return mass fraction of given chemicals.

Parameters:

IDs – 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])
property get_mass_fraction#

Return mass fraction of given chemicals.

Parameters:

IDs – 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])
property get_molar_composition#

Return molar fraction of given chemicals.

Parameters:

IDs – 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])
property get_molar_fraction#

Return molar fraction of given chemicals.

Parameters:

IDs – 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])
property get_normalized_mass#

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

Parameters:

IDs – 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])
property get_normalized_mol#

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

Parameters:

IDs – 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])
property get_normalized_vol#

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

Parameters:

IDs – 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])
property get_property#

Return property in requested units.

Parameters:
  • name – Name of property.

  • units – Units of measure. Defaults to the property’s original units of measure.

property get_total_flow#

Get total flow rate in given units.

Parameters:

units – 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
property get_upstream_units#

Return a set of all units upstream.

property get_volumetric_composition#

Return volumetric fraction of given chemicals.

Parameters:

IDs – 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 get_volumetric_fraction#

Return volumetric fraction of given chemicals.

Parameters:

IDs – 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#

Specific enthalpy [kJ/kmol].

property imass#

Flow rate indexer with data [kg/hr].

property imol#

Flow rate indexer with data [kmol/hr].

property in_thermal_equilibrium#

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
property 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
property ivol#

Flow rate indexer with data [m3/hr].

property kappa#

Thermal conductivity [W/m/k].

Link with another stream.

Parameters:
  • other

  • flow – Whether to link the flow rate data. Defaults to True.

  • phase – Whether to link the phase. Defaults to True.

  • TP – 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#

Molar liquid fraction.

property lle#

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

property lle_chemicals#

Chemicals cabable of vapor-liquid equilibrium.

property main_chemical#

ID of chemical with the largest mol fraction in stream.

property mass#

Mass flow rates [kg/hr].

property mix_from#

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#

Molar flow rates [kmol/hr].

property mu#

Hydrolic viscosity [Pa*s].

property nu#

Kinematic viscosity [m^2/s].

property phase#

Phase of stream.

property phases#

All phases present.

property price#

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

property print#

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

Parameters:

units – 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')
property proxy#

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
property receive_vent#

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
property reduce_phases#

Remove empty phases.

property rescale#

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
property reset_cache#

Reset cache regarding equilibrium methods.

property reset_flow#

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#

Density [kg/m^3].

property 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
property 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
property separate_out#

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
property set_CF#

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

Parameters:
  • key – Key of impact indicator.

  • value – Characterization factor value.

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

  • units – 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.

property set_data#

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

See also

Stream.get_data

property set_flow#

Set flow rates in given units.

Parameters:
  • data – Flow rate data.

  • units – Units of measure.

  • key – 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
property set_property#

Set property in given units.

Parameters:
  • name – Name of property.

  • value – New value of property.

  • units – Units of measure.

property set_total_flow#

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

Parameters:
  • value – New total flow rate.

  • units – 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
property shares_flow_rate_with#

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
property show#

Print all specifications.

Parameters:
  • layout – 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 – Temperature units.

  • P – Pressure units.

  • flow – Flow rate units.

  • composition – Whether to show composition.

  • N – Number of compounds to display.

  • IDs – IDs of compounds to display. Defaults to all chemicals.

  • sort – Whether to sort flows in descending order.

  • df – 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#

Surface tension [N/m].

property sle#

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

property solid_fraction#

Molar solid fraction.

property split_to#

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
property sum#

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#

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#

Molar vapor fraction.

property vle#

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

property vle_chemicals#

Chemicals cabable of liquid-liquid equilibrium.

property vlle#

Estimate vapor-liquid-liquid equilibrium.

Warning

This method may be as slow as 1 second.

property vol#

Volumetric flow rates [m3/hr].

property z_mass#

Mass composition.

property z_mol#

Molar composition.

property z_vol#

Volumetric composition.

class SuperpositionOutlet(port, source=None)#
property C#

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

property Cn#

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

property Cp#

Isobaric heat capacity [J/g/K].

property F_mass#

Total mass flow rate [kg/hr].

property F_mol#

Total molar flow rate [kmol/hr].

property F_vol#

Total volumetric flow rate [m3/hr].

property H#

Enthalpy flow rate [kJ/hr].

property HHV#

Higher heating value flow rate [kJ/hr].

property Hf#

Enthalpy of formation flow rate [kJ/hr].

property Hnet#

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

property Hvap#

Enthalpy of vaporization flow rate [kJ/hr].

property LHV#

Lower heating value flow rate [kJ/hr].

property MW#

Overall molecular weight.

property P#

Pressure [Pa].

property P_vapor#

Vapor pressure of liquid.

property Pr#

Prandtl number [-].

property S#

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

property T#

Temperature [K].

property V#

Molar volume [m^3/mol].

property alpha#

Thermal diffusivity [m^2/s].

property as_stream#

Does nothing.

property available_chemicals#

All chemicals with nonzero flow.

property bubble_point_at_P#

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

Parameters:

IDs – 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])
property bubble_point_at_T#

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

Parameters:
  • T – Temperature [K].

  • IDs – 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])
property characterization_factors#
property copy#

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.

property copy_flow#

Copy flow rates of another stream to self.

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

  • IDs – Chemical IDs.

  • remove – If True, copied chemicals will be removed from stream.

  • exclude – 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
property copy_like#

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
property copy_phase#

Copy phase from another stream.

property copy_thermal_condition#

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
property cost#

Total cost of stream [USD/hr].

property dew_point_at_P#

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

Parameters:

IDs – 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])
property dew_point_at_T#

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

Parameters:

IDs – 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])
property display_notation#

Create a DisplayNotation object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_notation.flow = '.2g'
>>> stream = tmo.Stream('stream', Water=1.324, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water  0.073
>>> # Change back to kmol/hr
>>> tmo.Stream.display_notation.flow = '.3g'
property display_units#

Create a DisplayUnits object where default units for representation are stored.

Examples

Its possible to change the default units of measure for the Stream show method:

>>> import thermosteam as tmo
>>> tmo.settings.set_thermo(['Water'], cache=True)
>>> tmo.Stream.display_units.flow = 'kg/hr'
>>> stream = tmo.Stream('stream', Water=1, units='kg/hr')
>>> stream.show()
Stream: stream
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kg/hr): Water  1
>>> # Change back to kmol/hr
>>> tmo.Stream.display_units.flow = 'kmol/hr'
property 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
property 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#

Relative permittivity [-].

property flow_proxy#

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
property get_CF#

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

Parameters:
  • key – Key of impact indicator.

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

  • units – 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.

property get_atomic_flow#

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
property 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}
property get_bubble_point#

Return a BubblePoint object capable of computing bubble points.

Parameters:

IDs – 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])
property get_concentration#

Return concentration of given chemicals.

Parameters:
  • IDs – IDs of chemicals.

  • units – 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])
property 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
property get_dew_point#

Return a DewPoint object capable of computing dew points.

Parameters:

IDs – 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])
property get_downstream_units#

Return a set of all units downstream.

property get_flow#

Return an flow rates in requested units.

Parameters:
  • units – Units of measure.

  • key – 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
property get_impact#

Return hourly rate of the impact indicator given the key.

property get_mass_composition#

Return mass fraction of given chemicals.

Parameters:

IDs – 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])
property get_mass_fraction#

Return mass fraction of given chemicals.

Parameters:

IDs – 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])
property get_molar_composition#

Return molar fraction of given chemicals.

Parameters:

IDs – 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])
property get_molar_fraction#

Return molar fraction of given chemicals.

Parameters:

IDs – 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])
property get_normalized_mass#

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

Parameters:

IDs – 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])
property get_normalized_mol#

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

Parameters:

IDs – 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])
property get_normalized_vol#

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

Parameters:

IDs – 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])
property get_property#

Return property in requested units.

Parameters:
  • name – Name of property.

  • units – Units of measure. Defaults to the property’s original units of measure.

property get_total_flow#

Get total flow rate in given units.

Parameters:

units – 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
property get_upstream_units#

Return a set of all units upstream.

property get_volumetric_composition#

Return volumetric fraction of given chemicals.

Parameters:

IDs – 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 get_volumetric_fraction#

Return volumetric fraction of given chemicals.

Parameters:

IDs – 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#

Specific enthalpy [kJ/kmol].

property imass#

Flow rate indexer with data [kg/hr].

property imol#

Flow rate indexer with data [kmol/hr].

property in_thermal_equilibrium#

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
property 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
property ivol#

Flow rate indexer with data [m3/hr].

property kappa#

Thermal conductivity [W/m/k].

Link with another stream.

Parameters:
  • other

  • flow – Whether to link the flow rate data. Defaults to True.

  • phase – Whether to link the phase. Defaults to True.

  • TP – 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#

Molar liquid fraction.

property lle#

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

property lle_chemicals#

Chemicals cabable of vapor-liquid equilibrium.

property main_chemical#

ID of chemical with the largest mol fraction in stream.

property mass#

Mass flow rates [kg/hr].

property mix_from#

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#

Molar flow rates [kmol/hr].

property mu#

Hydrolic viscosity [Pa*s].

property nu#

Kinematic viscosity [m^2/s].

property phase#

Phase of stream.

property phases#

All phases present.

property price#

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

property print#

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

Parameters:

units – 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')
property proxy#

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
property receive_vent#

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
property reduce_phases#

Remove empty phases.

property rescale#

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
property reset_cache#

Reset cache regarding equilibrium methods.

property reset_flow#

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#

Density [kg/m^3].

property 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
property 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
property separate_out#

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
property set_CF#

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

Parameters:
  • key – Key of impact indicator.

  • value – Characterization factor value.

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

  • units – 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.

property set_data#

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

See also

Stream.get_data

property set_flow#

Set flow rates in given units.

Parameters:
  • data – Flow rate data.

  • units – Units of measure.

  • key – 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
property set_property#

Set property in given units.

Parameters:
  • name – Name of property.

  • value – New value of property.

  • units – Units of measure.

property set_total_flow#

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

Parameters:
  • value – New total flow rate.

  • units – 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
property shares_flow_rate_with#

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
property show#

Print all specifications.

Parameters:
  • layout – 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 – Temperature units.

  • P – Pressure units.

  • flow – Flow rate units.

  • composition – Whether to show composition.

  • N – Number of compounds to display.

  • IDs – IDs of compounds to display. Defaults to all chemicals.

  • sort – Whether to sort flows in descending order.

  • df – 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#

Surface tension [N/m].

property sle#

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

property solid_fraction#

Molar solid fraction.

property split_to#

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
property sum#

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#

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#

Molar vapor fraction.

property vle#

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

property vle_chemicals#

Chemicals cabable of liquid-liquid equilibrium.

property vlle#

Estimate vapor-liquid-liquid equilibrium.

Warning

This method may be as slow as 1 second.

property vol#

Volumetric flow rates [m3/hr].

property z_mass#

Mass composition.

property z_mol#

Molar composition.

property z_vol#

Volumetric composition.

get_ash_disposal_cost()#

Return the ash disposal cost [USD/hr].

get_ash_disposal_flow()#

Return the ash disposal flow rate [kg/hr].

get_natural_gas_cost()#

Return the natural gas cost [USD/hr].

get_natural_gas_flow()#

Return the natural gas flow rate [kg/hr].

get_process_water_cost()#

Return the process water cost [USD/hr].

get_process_water_flow()#

Return the process water flow rate [kg/hr].

get_reverse_osmosis_water_cost()#

Return the reverse osmosis water cost [USD/hr].

get_reverse_osmosis_water_flow()#

Return the reverse osmosis water flow rate [kg/hr].