### Install ThermoSTEAM from Git Source: https://github.com/biosteamdevelopmentgroup/thermosteam/blob/master/README.rst Clone the git repository and install ThermoSTEAM locally. Use --depth 100 to clone only the last 100 commits for faster installation. ```bash git clone --depth 100 git://github.com/BioSTEAMDevelopmentGroup/thermosteam cd thermosteam pip install . ``` -------------------------------- ### Install ThermoSTEAM using pip Source: https://github.com/biosteamdevelopmentgroup/thermosteam/blob/master/README.rst Install the latest version of ThermoSTEAM from PyPI using pip. ```bash pip install thermosteam ``` -------------------------------- ### Install ThermoSTEAM from Git with all branches Source: https://github.com/biosteamdevelopmentgroup/thermosteam/blob/master/README.rst Clone the git repository including all branches by adding the --no-single-branch flag. This may take longer. ```bash git clone --depth 100 --no-single-branch git://github.com/BioSTEAMDevelopmentGroup/thermosteam ``` -------------------------------- ### Set and Get Stream Flows in Specific Units Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Allows setting and retrieving stream flow rates using specified units and component order. ```python # Set and get flows in any units s1.set_flow([10, 20], 'kg/hr', ('Ethanol', 'Water')) print(s1.get_flow('kg/hr', ('Ethanol', 'Water'))) ``` -------------------------------- ### Compare Equilibrium Predictions with Ideal and Real Thermo Packages Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Compares equilibrium predictions between an ideal (Raoult's law) and a modified Raoult's law split using different thermo packages. Demonstrates setting thermo globally and directly on a stream. ```python ideal = tmo.IdealThermo(['Ethanol', 'Water'], cache=True) # Compare equilibrium predictions tmo.settings.set_thermo(ideal) s_ideal = tmo.Stream('s_ideal', Water=100, Ethanol=100) s_ideal.vle(T=361, P=101325) s_ideal.show() # ideal split tmo.settings.set_thermo(thermo) s_real = tmo.Stream('s_real', Water=100, Ethanol=100) s_real.vle(T=361, P=101325) s_real.show() # modified Raoult's law split (activity coefficients applied) # Set thermo directly on a stream (overrides global default) s_custom = tmo.Stream('s_custom', Water=50, thermo=ideal) print(s_custom.thermo is ideal) # True ``` -------------------------------- ### Save and Reload Property Package Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Demonstrates how to save a ThermoSteam property package to disk and then reload it. ```python tmo.utils.save(thermo, "EthanolWater_pkg") thermo_loaded = tmo.utils.load("EthanolWater_pkg") ``` -------------------------------- ### Persist and Restore Property Packages Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Demonstrates how to save a Thermo property package to a file and then load it back. This is useful for persisting thermodynamic models. ```python # Persist and restore property packages tmo.utils.save(thermo, 'my_thermo_pkg') thermo2 = tmo.utils.load('my_thermo_pkg') ``` -------------------------------- ### Create and Show a Single-Phase Stream Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Initializes a single-phase material stream with specified components and flow rates, then displays its properties. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) # Create a stream with keyword flow rates (default units: kmol/hr) s1 = tmo.Stream(ID='s1', Water=20, Ethanol=10, units='kg/hr', T=298.15, P=101325, phase='l') s1.show(flow='kg/hr') ``` -------------------------------- ### Configure Global Thermodynamic Property Package Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Sets the process-wide default `Thermo` object. Use `cache=True` to reuse previously loaded data. The `show()` method displays the resulting property package details. ```python import thermosteam as tmo # Set thermo from a list of chemical names; cache=True reuses previously loaded data tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose', 'CO2'], cache=True) # Inspect the resulting property package tmo.settings.thermo.show() # Thermo( # chemicals=CompiledChemicals([Water, Ethanol, Glucose, CO2]), # mixture=IdealMixture(...), # Gamma=DortmundActivityCoefficients, # Phi=IdealFugacityCoefficients, # PCF=MockPoyintingCorrectionFactors # ) # Access compiled chemicals and mixture model print(tmo.settings.chemicals) # CompiledChemicals([Water, Ethanol, Glucose, CO2]) print(tmo.settings.mixture) # IdealMixture(...) ``` -------------------------------- ### Create a Multi-Phase Stream Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Initializes a multi-phase material stream with specified components and flow rates for the liquid phase. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) # Directly create a multi-phase stream s1 = tmo.MultiStream(ID='s1', T=298.15, P=101325, l=[('Water', 20), ('Ethanol', 10)], units='kg/hr') s1.show(flow='kg/hr') ``` -------------------------------- ### Access Stream Thermodynamic Properties Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Demonstrates how to access and modify thermodynamic properties like enthalpy and density, and set temperature in different units. ```python # Thermodynamic properties s1.T += 10 print(s1.H) # Enthalpy [kJ/hr] print(s1.rho) # Density [kg/m³] print(s1.get_property('rho', 'g/cm3')) # 0.909... s1.set_property('T', 40, 'degC') ``` -------------------------------- ### Calculate bubble point at constant temperature Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculate the bubble point pressure for a given temperature. Requires setting up thermosteam with relevant chemicals. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s = tmo.Stream('s', Water=0.836, Ethanol=0.164, units='mol/s', T=300, phase='l') bp_T = s.bubble_point_at_T() # bubble point at constant temperature print(bp_P.P) # bubble pressure [Pa] ``` -------------------------------- ### Calculate bubble point at constant pressure Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculate the bubble point temperature and vapor composition at a fixed pressure. Requires setting up thermosteam with relevant chemicals. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s = tmo.Stream('s', Water=0.836, Ethanol=0.164, units='mol/s', T=300, phase='l') bp_P = s.bubble_point_at_P() # bubble point at constant pressure print(bp_P.T) # bubble temp [K] print(bp_P.y) # vapor composition: array([y_Water, y_Ethanol]) ``` -------------------------------- ### Mix streams and split with moisture content constraint Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Use separations.mix_and_split_with_moisture_content to enforce a target weight fraction of water in the retentate stream after mixing and splitting. ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose'], cache=True) ins = [tmo.Stream(Water=10, Ethanol=5), tmo.Stream(Water=5, Glucose=3)] out1 = tmo.Stream('retentate') out2 = tmo.Stream('permeate') split = [0.8, 0.1, 0.9] separations.mix_and_split_with_moisture_content( ins, out1, out2, split=split, moisture_content=0.5 ) ``` -------------------------------- ### Perform Vapor-Liquid Equilibrium (VLE) Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculates the vapor-liquid equilibrium for a stream by specifying pressure and vapor fraction, then displays the resulting phases. ```python # Vapor-liquid equilibrium (2 degrees of freedom: T, P, V, or H) s1.vle(P=101325, V=0.5) # set vapor fraction and pressure s1.show() ``` -------------------------------- ### Compile Chemicals and Create Thermo Packages Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Builds a `Chemicals` collection and compiles it into `CompiledChemicals` for optimized lookups. A `Thermo` object wraps compiled chemicals with mixture and activity models. ```python import thermosteam as tmo # Build a Chemicals collection chems = tmo.Chemicals(['H2O', 'Ethanol', 'CO2', 'O2'], cache=True) # Access by attribute or index print(chems.H2O) # Chemical: H2O print(chems[0]) # Chemical: H2O # Compile for use in streams / equilibrium chems.compile() print(type(chems)) # # Create a full Thermo property package (Dortmund-UNIFAC by default) thermo = tmo.Thermo(['Ethanol', 'Water'], cache=True) thermo.show() # Thermo( # chemicals=CompiledChemicals([Ethanol, Water]), # mixture=IdealMixture(...), # Gamma=DortmundActivityCoefficients, # ... # ) # Create an ideal (Raoult's law) variant ideal = thermo.ideal() ideal.show() ``` -------------------------------- ### Separations Module Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Utility functions for stream splitting, partitioning, and material balance calculations. ```APIDOC ## Mix and Split Streams ### Description Mixes inlet streams and distributes them to outlets based on split fractions. ### Function `separations.mix_and_split(ins, out1, out2, split)` ### Parameters - `ins` (list of Stream): Inlet streams. - `out1` (Stream): First outlet stream. - `out2` (Stream): Second outlet stream. - `split` (list of float): Split fractions for each chemical. ### Example ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose'], cache=True) ins = [tmo.Stream(Water=10, Ethanol=5), tmo.Stream(Water=5, Glucose=3)] out1 = tmo.Stream('retentate') out2 = tmo.Stream('permeate') split = [0.8, 0.1, 0.9] # split fractions per chemical: [Water, Ethanol, Glucose] separations.mix_and_split(ins, out1, out2, split) out1.show() # retentate out2.show() # permeate ``` ## Mix and Split with Moisture Content ### Description Mixes inlet streams and distributes them to outlets, enforcing a target moisture content in the retentate. ### Function `separations.mix_and_split_with_moisture_content(ins, out1, out2, split, moisture_content)` ### Parameters - `ins` (list of Stream): Inlet streams. - `out1` (Stream): Retentate outlet stream. - `out2` (Stream): Permeate outlet stream. - `split` (list of float): Split fractions for each chemical. - `moisture_content` (float): Target moisture content (wt fraction of water) in the retentate. ### Example ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose'], cache=True) ins = [tmo.Stream(Water=10, Ethanol=5), tmo.Stream(Water=5, Glucose=3)] out1 = tmo.Stream('retentate') out2 = tmo.Stream('permeate') split = [0.8, 0.1, 0.9] separations.mix_and_split_with_moisture_content( ins, out1, out2, split=split, moisture_content=0.5 ) ``` ## Partition Streams ### Description Distributes a stream between two outlet phases using partition coefficients. ### Function `separations.partition(feed, top, bot, IDs, Ks, phi)` ### Parameters - `feed` (Stream): The inlet stream to partition. - `top` (Stream): The outlet stream for the top phase. - `bot` (Stream): The outlet stream for the bottom phase. - `IDs` (list of str): Chemical IDs. - `Ks` (list of float): Partition coefficients (top/bottom) for each chemical. - `phi` (float): Fraction of the feed going to the top phase. ### Example ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose'], cache=True) feed = tmo.Stream('feed', Water=50, Ethanol=50, Glucose=10, phase='l') top = tmo.Stream('top') bot = tmo.Stream('bot') IDs = ['Water', 'Ethanol', 'Glucose'] Ks = [0.5, 2.0, 0.1] # top/bottom partition coefficients phi = 0.4 # fraction going to top phase separations.partition(feed, top, bot, IDs, Ks, phi) top.show() ``` ## Material Balance ### Description Solves an under-determined material balance given known split fractions. ### Function `separations.material_balance(chemical_IDs, variable_inlets, constant_inlets, constant_outlets, is_divided)` ### Parameters - `chemical_IDs` (list of str): IDs of the chemicals involved. - `variable_inlets` (list of Stream): Inlet streams with unknown flow rates. - `constant_inlets` (list of Stream): Inlet streams with known flow rates. - `constant_outlets` (list of Stream): Outlet streams with known flow rates. - `is_divided` (bool): Whether the system is divided. ### Example ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) feed2 = tmo.Stream('feed2', Water=100, Ethanol=100) out_a = tmo.Stream('out_a') out_b = tmo.Stream('out_b') separations.material_balance( chemical_IDs=['Water', 'Ethanol'], variable_inlets=[feed2], constant_inlets=[], constant_outlets=[out_a], is_divided=False, ) ``` ``` -------------------------------- ### Combine reactions running in parallel Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Use ParallelReaction to simulate reactions that occur independently with different reactants and conversions. Ensure all necessary chemicals are set in thermosteam settings. ```python import thermosteam as tmo tmo.settings.set_thermo(['H2', 'CH4', 'O2', 'CO2', 'H2O'], cache=True) parallel = tmo.ParallelReaction([ tmo.Reaction('2H2 + O2 -> 2H2O', reactant='H2', X=0.7), tmo.Reaction('CH4 + O2 -> CO2 + 2H2O', reactant='CH4', X=0.1), ]) s = tmo.Stream('s', H2=10, CH4=5, O2=100, H2O=100, T=373.15, phase='g') parallel.adiabatic_reaction(s) s.show() # T ~666 K after parallel adiabatic combustion ``` -------------------------------- ### Mix streams and split using fractions Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Use separations.mix_and_split to combine multiple inlet streams and distribute them to two outlet streams based on specified split fractions for each chemical. ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose'], cache=True) ins = [tmo.Stream(Water=10, Ethanol=5), tmo.Stream(Water=5, Glucose=3)] out1 = tmo.Stream('retentate') out2 = tmo.Stream('permeate') split = [0.8, 0.1, 0.9] # split fractions per chemical: [Water, Ethanol, Glucose] separations.mix_and_split(ins, out1, out2, split) out1.show() # retentate out2.show() # permeate ``` -------------------------------- ### Calculate dew point at constant pressure Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculate the dew point temperature and liquid composition at a fixed pressure. Requires setting up thermosteam with relevant chemicals. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s = tmo.Stream('s', Water=0.836, Ethanol=0.164, units='mol/s', T=300, phase='l') dp_P = s.dew_point_at_P() print(dp_P.T) # dew point temperature [K] print(dp_P.x) # liquid composition ``` -------------------------------- ### Access Individual Phases of a Multi-Phase Stream Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Shows how to access and display the properties of individual liquid ('l') and gas ('g') phases within a multi-phase stream. ```python # Access individual phases s1['l'].show() # liquid phase as a Stream s1['g'].show() # gas phase as a Stream ``` -------------------------------- ### Build a Thermo object with Dortmund-UNIFAC Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Create a Thermo object, which bundles chemicals with mixture and activity coefficient models. Dortmund-UNIFAC is the default activity coefficient model. ```python import thermosteam as tmo # Build with Dortmund-UNIFAC (default) thermo = tmo.Thermo(['Ethanol', 'Water', 'Glucose'], cache=True) thermo.show() # Thermo( # chemicals=CompiledChemicals([Ethanol, Water, Glucose]), # mixture=IdealMixture(...), # Gamma=DortmundActivityCoefficients, # Phi=IdealFugacityCoefficients, # PCF=MockPoyintingCorrectionFactors # ) ``` -------------------------------- ### Perform VLE calculation with fixed T and P Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculate vapor-liquid equilibrium by specifying temperature and pressure. The stream object will be updated with phase compositions. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s2 = tmo.Stream('s2', Water=100, Ethanol=100) s2.vle(T=361, P=101325) s2.show() # MultiStream: s2 # phases: ('g', 'l'), T: 361 K, P: 101325 Pa # flow (kmol/hr): (g) Ethanol ... # (l) Water ... ``` -------------------------------- ### Create and Use Chemical Objects Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Creates an object storing pure component thermodynamic properties. Chemicals can be looked up by various identifiers. Temperature-dependent properties can be accessed and custom models can be added. ```python import thermosteam as tmo # Create a Chemical by common name water = tmo.Chemical('Water') # Constant properties print(water.MW) # 18.01528 [g/mol] print(water.Tb) # 373.124 [K] print(water.Tc) # 647.14 [K] print(water.Pc) # 22048320 [Pa] print(water.CAS) # '7732-18-5' # Temperature-dependent properties print(water.Psat(T=373.15)) # ~101418 [Pa] vapor pressure print(water.sigma(T=298.15)) # ~0.0719 [N/m] surface tension print(water.V(phase='l', T=298.15, P=101325)) # ~1.806e-5 [m³/mol] molar volume # Enthalpy at reference state is 0 by definition print(water.H(T=298.15, phase='l')) # 0.0 [J/mol] # Functional groups for UNIFAC activity coefficient estimation print(water.Dortmund) # # Add a custom vapor pressure model (Antoine equation) def antoine(T): return 10.0 ** (10.116 - 1687.537 / (T - 42.98)) water.Psat.add_method(f=antoine, Tmin=273.20, Tmax=473.20) print(water.Psat(T=373.15)) # result from USER_METHOD # Create a custom chemical with user-specified properties solvent = tmo.Chemical('MySolvent', search_ID=False, MW=100.0, Tb=400.0, Tc=550.0, Pc=3e6, Cn=lambda T: 150.0, default=True) ``` -------------------------------- ### Chain reactions in series Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Use SeriesReaction to simulate reactions where the product of one reaction feeds into the next. Ensure all necessary chemicals are set in thermosteam settings. ```python import thermosteam as tmo tmo.settings.set_thermo(['CH4', 'CO', 'O2', 'CO2', 'H2O'], cache=True) series = tmo.SeriesReaction([ tmo.Reaction('2CH4 + 3O2 -> 2CO + 4H2O', reactant='CH4', X=0.7), tmo.Reaction('2CO + O2 -> 2CO2', reactant='CO', X=0.1), ]) s = tmo.Stream('s', CH4=5, O2=100, H2O=100, T=373.15, phase='g') series.adiabatic_reaction(s) s.show() ``` -------------------------------- ### Partition a stream between two phases Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Use separations.partition to distribute a feed stream between two outlet streams (phases) based on partition coefficients and a specified fraction going to the top phase. ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose'], cache=True) feed = tmo.Stream('feed', Water=50, Ethanol=50, Glucose=10, phase='l') top = tmo.Stream('top') bot = tmo.Stream('bot') IDs = ['Water', 'Ethanol', 'Glucose'] Ks = [0.5, 2.0, 0.1] # top/bottom partition coefficients phi = 0.4 # fraction going to top phase separations.partition(feed, top, bot, IDs, Ks, phi) top.show() ``` -------------------------------- ### Perform VLE calculation with specified vapor fraction Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculate vapor-liquid equilibrium by specifying pressure and vapor fraction. The stream object will be updated with phase compositions. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s2 = tmo.Stream('s2', Water=100, Ethanol=100) s2.vle(P=101325, V=0.3) # specify vapor fraction instead of T ``` -------------------------------- ### Calculate Bubble Point Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Computes the bubble point temperature and vapor composition at a constant pressure for a given stream. ```python # Bubble point at constant pressure bp = s1.bubble_point_at_P() print(bp) # BubblePointValues(T=357.14, P=101325, ...) print(bp.T) # bubble point temperature [K] print(bp.y) # vapor composition array ``` -------------------------------- ### Solve material balance for under-determined system Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Use separations.material_balance to solve an under-determined material balance problem when given known inlet streams and some outlet streams, with specified split fractions. ```python import thermosteam as tmo from thermosteam import separations tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose'], cache=True) feed2 = tmo.Stream('feed2', Water=100, Ethanol=100) out_a = tmo.Stream('out_a') out_b = tmo.Stream('out_b') separations.material_balance( chemical_IDs=['Water', 'Ethanol'], variable_inlets=[feed2], constant_inlets=[], constant_outlets=[out_a], is_divided=False, ) ``` -------------------------------- ### MultiStream Class Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Extends the Stream class to handle multiple simultaneous phases (e.g., gas, liquid, solid). Provides access to individual phases via indexing and computes thermodynamic properties on a total-stream basis. ```APIDOC ## MultiStream Class ### Description Extends `Stream` to hold simultaneous multiple phases (e.g., gas + liquid + solid). Each phase is accessible via bracket indexing. All thermodynamic properties are computed on a total-stream basis. ### Usage ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) # Directly create a multi-phase stream s1 = tmo.MultiStream(ID='s1', T=298.15, P=101325, l=[('Water', 20), ('Ethanol', 10)], units='kg/hr') s1.show(flow='kg/hr') # Phase-indexed flow access print(s1.imol['l', 'Water']) # ~1.11 [kmol/hr] print(s1.imol['l', ('Ethanol', 'Water')]) # array([0.217, 1.11]) # Total (summed across phases) molar flow print(s1.mol) # sparse([1.11, 0.217]) (read-only) # Add a gas phase component s1.imol['g', 'Ethanol'] = 0.1 s1.show(flow='kmol/hr') # VLLE (three-phase equilibrium) tmo.settings.set_thermo(['Water', 'Ethanol', 'Octane'], cache=True) ms = tmo.MultiStream(phases=('g', 'l', 'L'), l=[('Water', 50), ('Ethanol', 10), ('Octane', 5)]) ms.vlle(T=350, P=101325) ms.show() ``` ``` -------------------------------- ### Perform VLE calculation with specified enthalpy Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculate vapor-liquid equilibrium by specifying temperature and enthalpy. The stream object will be updated with phase compositions. ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s2 = tmo.Stream('s2', Water=100, Ethanol=100) s2.vle(T=365, H=s2.H) # specify enthalpy instead of P ``` -------------------------------- ### Perform Vapor-Liquid-Liquid Equilibrium (VLLE) Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Calculates the vapor-liquid-liquid equilibrium for a multi-component system at a specified temperature and pressure. ```python # VLLE (three-phase equilibrium) tmo.settings.set_thermo(['Water', 'Ethanol', 'Octane'], cache=True) ms = tmo.MultiStream(phases=('g', 'l', 'L'), l=[('Water', 50), ('Ethanol', 10), ('Octane', 5)]) ms.vlle(T=350, P=101325) ms.show() ``` -------------------------------- ### VLE / BubblePoint / DewPoint Solvers Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Functions for computing vapor-liquid equilibrium, bubble points, and dew points. These solvers are called by Stream.vle() and can compute bubble and dew points at fixed pressure or temperature. ```APIDOC ## Bubble Point Calculations ### Description Computes the bubble point at constant pressure or temperature. ### Methods - `bubble_point_at_P()`: Computes bubble point at constant pressure. - `bubble_point_at_T()`: Computes bubble point at constant temperature. ### Parameters - `Stream` object: The stream for which to compute the bubble point. ### Response - Returns a value object with temperature, pressure, and composition results. ### Example ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s = tmo.Stream('s', Water=0.836, Ethanol=0.164, units='mol/s', T=300, phase='l') bp_P = s.bubble_point_at_P() # bubble point at constant pressure print(bp_P.T) # bubble temp [K] print(bp_P.y) # vapor composition: array([y_Water, y_Ethanol]) bp_T = s.bubble_point_at_T() # bubble point at constant temperature print(bp_T.P) # bubble pressure [Pa] ``` ## Dew Point Calculations ### Description Computes the dew point at constant pressure or temperature. ### Methods - `dew_point_at_P()`: Computes dew point at constant pressure. ### Parameters - `Stream` object: The stream for which to compute the dew point. ### Response - Returns a value object with temperature, pressure, and composition results. ### Example ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s = tmo.Stream('s', Water=0.836, Ethanol=0.164, units='mol/s', T=300, phase='l') dp_P = s.dew_point_at_P() print(dp_P.T) # dew point temperature [K] print(dp_P.x) # liquid composition ``` ## VLE via Stream Method ### Description Solves vapor-liquid equilibrium for a stream with two degrees of freedom. ### Method `Stream.vle(T=None, P=None, V=None, H=None)` ### Parameters - `T` (float, optional): Temperature in K. - `P` (float, optional): Pressure in Pa. - `V` (float, optional): Vapor fraction. - `H` (float, optional): Enthalpy. ### Example ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) s2 = tmo.Stream('s2', Water=100, Ethanol=100) s2.vle(T=361, P=101325) s2.show() s2.vle(P=101325, V=0.3) # specify vapor fraction instead of T s2.vle(T=365, H=s2.H) # specify enthalpy instead of P ``` ``` -------------------------------- ### Define a Stoichiometric Reaction with Conversion Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Defines a chemical reaction using a string representation and specifies the conversion percentage for a given reactant. ```python import thermosteam as tmo tmo.settings.set_thermo(['H2O', 'H2', 'O2'], cache=True) # Define a reaction with 70% water conversion (electrolysis) rxn = tmo.Reaction('2H2O,l -> 2H2,g + O2,g', reactant='H2O', X=0.7) rxn.show() ``` -------------------------------- ### IdealTPMixtureModel for Molar-Weighted Ideal Mixture Properties Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Computes mixture thermodynamic properties as the mole-fraction-weighted sum of pure-component property values. Used internally by IdealMixture objects but can be instantiated directly for custom calculations. ```python from thermosteam.mixture import IdealTPMixtureModel from thermosteam import Chemicals # Prepare pure-component volume models chems = Chemicals(['Water', 'Ethanol']) V_models = [c.V for c in chems] # Build mixture model mix_V = IdealTPMixtureModel(V_models, 'V') print(mix_V) # V [m^3/mol]> # Evaluate at 80 mol% Ethanol, 20 mol% Water, 350 K, 1 atm import thermosteam as tmo tmo.settings.set_thermo(chems) mol = [0.2, 0.8] # [Water, Ethanol] in kmol/hr V_mix = mix_V('l', mol, 350, 101325) print(f"Mixture molar volume: {V_mix:.4e} m³/mol") # ~5.36e-05 # Use within a Thermo package context thermo = tmo.Thermo(['Water', 'Ethanol'], cache=True) tmo.settings.set_thermo(thermo) s = tmo.Stream('s', Water=0.2, Ethanol=0.8, phase='l', T=350) print(s.get_property('V', 'm^3/mol')) # mixture molar volume via stream ``` -------------------------------- ### Thermo / IdealThermo Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Configuration object for thermodynamic property calculations, bundling chemicals with mixture and activity coefficient models. ```APIDOC ## Thermo Property Package ### Description Bundles compiled chemicals with a mixture model, activity coefficient model, fugacity coefficient model, and Poynting correction factor model. Acts as the central configuration object for equilibrium and property calculations. ### Class `tmo.Thermo(chemicals, cache=True, **kwargs)` ### Parameters - `chemicals` (list): List of chemical names or objects. - `cache` (bool, optional): Whether to cache the thermo object. Defaults to True. - `**kwargs`: Additional keyword arguments for configuring mixture, Gamma, Phi, and PCF models. ### Example ```python import thermosteam as tmo # Build with Dortmund-UNIFAC (default) thermo = tmo.Thermo(['Ethanol', 'Water', 'Glucose'], cache=True) thermo.show() # Thermo( # chemicals=CompiledChemicals([Ethanol, Water, Glucose]), # mixture=IdealMixture(...), # Gamma=DortmundActivityCoefficients, # Phi=IdealFugacityCoefficients, # PCF=MockPoyintingCorrectionFactors # ) ``` ``` -------------------------------- ### Stream Class Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Represents a single-phase material stream with thermodynamic properties. Allows for setting and accessing flow rates, temperature, pressure, and other properties. Supports phase equilibrium calculations like bubble point. ```APIDOC ## Stream Class ### Description Represents a single-phase material stream with molar, mass, and volumetric flow rate indexers and thermodynamic/transport properties computed from the active `Thermo` package. Phase equilibrium methods (VLE, bubble/dew point) are available as instance methods. ### Usage ```python import thermosteam as tmo tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) # Create a stream with keyword flow rates (default units: kmol/hr) s1 = tmo.Stream(ID='s1', Water=20, Ethanol=10, units='kg/hr', T=298.15, P=101325, phase='l') s1.show(flow='kg/hr') # Access molar, mass, and volumetric flows print(s1.mol) # sparse([1.11, 0.217]) [kmol/hr] print(s1.mass) # sparse([20., 10.]) [kg/hr] print(s1.vol) # sparse([0.02, 0.013]) [m³/hr] # Set and get flows in any units s1.set_flow([10, 20], 'kg/hr', ('Ethanol', 'Water')) print(s1.get_flow('kg/hr', ('Ethanol', 'Water'))) # array([10., 20.]) # Thermodynamic properties s1.T += 10 print(s1.H) # Enthalpy [kJ/hr] print(s1.rho) # Density [kg/m³] print(s1.get_property('rho', 'g/cm3')) # 0.909... s1.set_property('T', 40, 'degC') # Bubble point at constant pressure bp = s1.bubble_point_at_P() print(bp) # BubblePointValues(T=357.14, P=101325, ...) print(bp.T) # bubble point temperature [K] print(bp.y) # vapor composition array # Vapor-liquid equilibrium (2 degrees of freedom: T, P, V, or H) s1.vle(P=101325, V=0.5) # set vapor fraction and pressure s1.show() # Access individual phases s1['l'].show() # liquid phase as a Stream s1['g'].show() # gas phase as a Stream # Convert back to single-phase s1.phase = 'l' ``` ``` -------------------------------- ### Apply Reaction to a Stream Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Applies a defined stoichiometric reaction to a stream, modifying its component flow rates in-place based on the specified conversion. ```python # Apply reaction to a stream feed = tmo.Stream('feed', H2O=100) feed.phases = ('g', 'l') rxn(feed) feed.show() ``` -------------------------------- ### Chemicals / CompiledChemicals Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Manages collections of `Chemical` objects. The `compile()` method creates an immutable `CompiledChemicals` object optimized for internal use. The `Thermo` class wraps compiled chemicals with mixture and activity models. ```APIDOC ## Chemicals / CompiledChemicals — Chemical collection and property package compilation ### Description `Chemicals` is an ordered, mutable collection of `Chemical` objects. Calling `.compile()` produces a `CompiledChemicals` object with immutable, index-optimized lookups used internally by streams and equilibrium solvers. `Thermo` wraps a compiled set with mixture and activity models. ### Method ```python import thermosteam as tmo # Build a Chemicals collection chems = tmo.Chemicals(['H2O', 'Ethanol', 'CO2', 'O2'], cache=True) # Access by attribute or index print(chems.H2O) # Chemical: H2O print(chems[0]) # Chemical: H2O # Compile for use in streams / equilibrium chems.compile() print(type(chems)) # # Create a full Thermo property package (Dortmund-UNIFAC by default) thermo = tmo.Thermo(['Ethanol', 'Water'], cache=True) thermo.show() # Thermo( # chemicals=CompiledChemicals([Ethanol, Water]), # mixture=IdealMixture(...), # Gamma=DortmundActivityCoefficients, # ... # ) # Create an ideal (Raoult's law) variant ideal = thermo.ideal() ideal.show() ``` ``` -------------------------------- ### Convert Multi-Phase Stream to Single-Phase Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Resets the phase of a multi-phase stream to a single phase, typically liquid. ```python # Convert back to single-phase s1.phase = 'l' ``` -------------------------------- ### Perform Adiabatic Reaction Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Applies a reaction to a stream under adiabatic conditions, allowing the stream's temperature to adjust to maintain energy balance. ```python # Adiabatic reaction (stream temperature adjusts to maintain energy balance) tmo.settings.set_thermo(['H2', 'O2', 'H2O'], cache=True) rxn2 = tmo.Reaction('2H2 + O2 -> 2H2O', reactant='H2', X=0.7) s = tmo.Stream('s', H2=10, O2=20, H2O=1000, T=373.15, phase='g') rxn2.adiabatic_reaction(s) s.show() # T will increase to ~421.6 K ``` -------------------------------- ### Access Phase-Indexed Molar Flows in MultiStream Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Retrieves molar flow rates for specific components within a particular phase of a MultiStream object. ```python # Phase-indexed flow access print(s1.imol['l', 'Water']) # ~1.11 [kmol/hr] print(s1.imol['l', ('Ethanol', 'Water')]) # array([0.217, 1.11]) ``` -------------------------------- ### Access Stream Flow Rates Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Retrieves molar, mass, and volumetric flow rates from a Stream object in their default units. ```python # Access molar, mass, and volumetric flows print(s1.mol) # sparse([1.11, 0.217]) [kmol/hr] print(s1.mass) # sparse([20., 10.]) [kg/hr] print(s1.vol) # sparse([0.02, 0.013]) [m³/hr] ``` -------------------------------- ### Add Component to Gas Phase in MultiStream Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Adds a specified molar flow rate of a component to the gas phase of an existing MultiStream object. ```python # Add a gas phase component s1.imol['g', 'Ethanol'] = 0.1 s1.show(flow='kmol/hr') ``` -------------------------------- ### Chemical Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Creates a pure component thermodynamic data object storing constant and temperature/pressure-dependent properties. Chemicals can be identified by name, CAS number, InChI, SMILES, or PubChem CID. ```APIDOC ## Chemical — Pure component thermodynamic data object ### Description Creates an object that stores constant chemical properties (MW, Tb, Tc, Pc, etc.) together with temperature- and pressure-dependent property models (vapor pressure, heat capacity, viscosity, etc.). Chemicals can be looked up by name, CAS number, InChI, SMILES, or PubChem CID. ### Method ```python import thermosteam as tmo # Create a Chemical by common name water = tmo.Chemical('Water') # Constant properties print(water.MW) # 18.01528 [g/mol] print(water.Tb) # 373.124 [K] print(water.Tc) # 647.14 [K] print(water.Pc) # 22048320 [Pa] print(water.CAS) # '7732-18-5' # Temperature-dependent properties print(water.Psat(T=373.15)) # ~101418 [Pa] vapor pressure print(water.sigma(T=298.15)) # ~0.0719 [N/m] surface tension print(water.V(phase='l', T=298.15, P=101325)) # ~1.806e-5 [m³/mol] molar volume # Enthalpy at reference state is 0 by definition print(water.H(T=298.15, phase='l')) # 0.0 [J/mol] # Functional groups for UNIFAC activity coefficient estimation print(water.Dortmund) # # Add a custom vapor pressure model (Antoine equation) def antoine(T): return 10.0 ** (10.116 - 1687.537 / (T - 42.98)) water.Psat.add_method(f=antoine, Tmin=273.20, Tmax=473.20) print(water.Psat(T=373.15)) # result from USER_METHOD # Create a custom chemical with user-specified properties solvent = tmo.Chemical('MySolvent', search_ID=False, MW=100.0, Tb=400.0, Tc=550.0, Pc=3e6, Cn=lambda T: 150.0, default=True) ``` ``` -------------------------------- ### settings.set_thermo Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Configures the global thermodynamic property package for process-wide use. This function sets the default Thermo object, allowing Stream and reaction objects to be used without explicit property package references. ```APIDOC ## settings.set_thermo — Configure the global thermodynamic property package ### Description Sets the process-wide default `Thermo` object (or compiles one from a list of chemical identifiers), making it available to all `Stream`, `MultiStream`, and reaction objects created afterward without requiring explicit `thermo=` arguments. ### Method ```python import thermosteam as tmo # Set thermo from a list of chemical names; cache=True reuses previously loaded data tmo.settings.set_thermo(['Water', 'Ethanol', 'Glucose', 'CO2'], cache=True) # Inspect the resulting property package tmo.settings.thermo.show() # Thermo( # chemicals=CompiledChemicals([Water, Ethanol, Glucose, CO2]), # mixture=IdealMixture(...), # Gamma=DortmundActivityCoefficients, # Phi=IdealFugacityCoefficients, # PCF=MockPoyintingCorrectionFactors # ) # Access compiled chemicals and mixture model print(tmo.settings.chemicals) # CompiledChemicals([Water, Ethanol, Glucose, CO2]) print(tmo.settings.mixture) # IdealMixture(...) ``` ``` -------------------------------- ### Access Total Molar Flow in MultiStream Source: https://context7.com/biosteamdevelopmentgroup/thermosteam/llms.txt Retrieves the total molar flow rate, summed across all phases, for a MultiStream object. ```python # Total (summed across phases) molar flow print(s1.mol) # sparse([1.11, 0.217]) (read-only) ```