### Reaction Initialization and Examples Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/thermosteam/reaction/Reaction.md Demonstrates how to initialize a Reaction object and use its methods with practical examples. ```APIDOC ## Reaction Initialization and Examples ### Initialization `Reaction(reaction_string, reactant, X, chemicals=None)` **Parameters**: - **reaction_string** (str) - The chemical reaction equation. - **reactant** (str) - The reactant associated with the conversion. - **X** (float) - The extent of reaction. - **chemicals** (Chemicals object) - Optional - A collection of chemicals involved in the reaction. ### Examples **1. Balance glucose fermentation to ethanol:** ```pycon >>> import thermosteam as tmo >>> tmo.settings.set_thermo(['Glucose', 'O2', 'CO2', 'Ethanol', 'CH4', 'Water']) >>> fermentation = tmo.Reaction('Glucose + O2 -> Ethanol + CO2', ... reactant='Glucose', ... X=0.9) >>> fermentation.correct_atomic_balance() >>> fermentation.show() Reaction (by mol): stoichiometry reactant X[%] Glucose -> 2 CO2 + 2 Ethanol Glucose 90.00 ``` **2. Balance methane combustion:** ```pycon >>> combustion = tmo.Reaction('CH4 + O2 -> Water + CO2', ... reactant='CH4', ... X=1) >>> combustion.correct_atomic_balance() >>> combustion.show() Reaction (by mol): stoichiometry reactant X[%] 2 O2 + CH4 -> CO2 + 2 Water CH4 100.00 ``` **3. Balance electrolysis of water:** ```pycon >>> electrolysis = tmo.Reaction('H2O,l -> H2,g + O2,g', ... chemicals=tmo.Chemicals(['H2O', 'H2', 'O2']), ... reactant='H2O', ... X=1) >>> electrolysis.correct_atomic_balance() >>> electrolysis.show() Reaction (by mol): stoichiometry reactant X[%] H2O,l -> H2,g + 0.5 O2,g H2O,l 100.00 ``` **4. Handling underspecified reactions:** ```pycon >>> rxn_underspecified = tmo.Reaction('CH4 + Glucose + O2 -> Water + CO2', ... reactant='CH4', ... X=1) >>> rxn_underspecified.correct_atomic_balance() Traceback (most recent call last): RuntimeError: reaction stoichiometry is underspecified; pass the `constants` argument to the `.correct_atomic_balance` method to specify which stoichiometric coefficients to hold constant ``` **5. Specifying constants for underspecified reactions:** ```pycon >>> rxn_underspecified = tmo.Reaction('CH4 + Glucose + O2 -> Water + CO2', ... reactant='CH4', ... X=1) >>> rxn_underspecified.correct_atomic_balance(['Glucose', 'CH4']) >>> rxn_underspecified.show() Reaction (by mol): stoichiometry reactant X[%] Glucose + 8 O2 + CH4 -> 7 CO2 + 8 Water CH4 100.00 ``` ``` -------------------------------- ### Create and Simulate a Vessel with Vacuum System Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/vacuum_system.md Demonstrates how to create a custom unit operation (VacuumVessel) that includes an auxiliary VacuumSystem. This example shows the necessary setup for the vacuum system to function, including defining unit attributes and simulating the process. ```python >>> import biosteam as bst >>> class VacuumVessel(bst.Unit): ... auxiliary_unit_names = ('vacuum_system',) ... _units = {'Total volume': 'm3'} ... P = 1000 ... tau = 4 ... ... def _run(self): ... self.outs[0].P = 1000 ... ... def _design(self): ... self.design_results['Total volume'] = self.feed.F_vol * self.tau ... self.vacuum_system = bst.VacuumSystem(self) ... >>> bst.settings.set_thermo(['Water']) >>> feed = bst.Stream('feed', Water=1e6) >>> V1 = VacuumVessel('V1', ins=feed) >>> V1.simulate() >>> V1.results() Vacuum vessel Units V1 Medium pressure steam Duty kJ/hr 1.04e+07 Flow kmol/hr 288 Cost USD/hr 79.3 Cooling water Duty kJ/hr -9.37e+06 Flow kmol/hr 6.4e+03 Cost USD/hr 3.12 Design Total volume m3 7.23e+04 Purchase cost Vacuum system - Steam-jet ejecto... USD 8.18e+04 Total purchase cost USD 8.18e+04 Installed equipment cost USD 8.18e+04 Utility cost USD/hr 82.4 ``` -------------------------------- ### Pump Example Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/Pump.md Example of simulating a Pump for pressure increase. ```APIDOC ### Examples Simulate Pump for pressure increase: ```pycon >>> from biosteam import Stream, settings >>> from biosteam.units import Pump >>> settings.set_thermo(['Water', 'Ethanol'], cache=True) >>> feed = Stream('feed', Water=200, T=350) >>> P1 = Pump('P1', ins=feed, outs='out', P=2e5) >>> P1.simulate() >>> P1.show() Pump: P1 ins... [0] feed phase: 'l', T: 350 K, P: 101325 Pa flow: 200 kmol/hr Water outs... [0] out phase: 'l', T: 350 K, P: 200000 Pa flow: 200 kmol/hr Water >>> P1.results() Pump Units P1 Electricity Power kW 0.288 Cost USD/hr 0.0225 Design Type Centrifugal Ideal power hp 0.136 Flow rate gpm 16.3 Efficiency 0.352 Power hp 0.386 Head ft 96.3 Motor size hp 0.5 Purchase cost Pump USD 4.37e+03 Motor USD 273 Total purchase cost USD 4.64e+03 Installed equipment cost USD 1.53e+04 Utility cost USD/hr 0.0225 ``` ``` -------------------------------- ### Install BioSTEAM using pip Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/index.md Install the latest version of BioSTEAM from PyPI. This is the recommended method for most users. ```bash pip install biosteam ``` -------------------------------- ### Create and Display HeatUtility Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/HeatUtility.md Instantiate a HeatUtility object and display its initial state. This is a basic setup for the utility object. ```python >>> from biosteam import HeatUtility >>> hu = HeatUtility() >>> hu.show() HeatUtility: None duty: 0 flow: 0 cost: 0 ``` -------------------------------- ### Set up a flash vessel with a numerical specification Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Process_specifications.ipynb This example demonstrates setting up a flash vessel and defining a numerical specification to achieve a target vapor fraction. It requires setting the thermodynamic package, defining a feed stream, and creating the flash unit. ```python # First name a new flowsheet main_flowsheet.set_flowsheet('flash_specification_example') # Set the thermodynamic property package. # In an actual process, much more chemicals # would be defined, but here we keep it short. settings.set_thermo(['Water', 'Ethanol', 'Propanol']) # Feed stream mixture = Stream(T=340, Water=1000, Ethanol=1000, Propanol=1000, units='kg/hr') # Create a flash vessel F1 = units.Flash(ins=mixture, outs=('vapor', 'liquid'), T=373, P=101325) ``` -------------------------------- ### Getting and Setting Properties with Different Units Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/thermosteam/Stream.md Properties can be retrieved or set using different units of measure. For example, density can be obtained in g/cm3, and temperature can be set in degrees Celsius. ```python >>> s1.get_property('rho', 'g/cm3') 0.9091 ``` ```python >>> s1.set_property('T', 40, 'degC') >>> s1.T 313.15 ``` -------------------------------- ### Create and Get Phase of a Chemical Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/thermosteam/Chemical.md Demonstrates how to create a Chemical object for water and retrieve its phase at a specific temperature and pressure. ```python from thermosteam import Chemical Water = Chemical('Water', cache=True) Water.get_phase(T=400, P=101325) ``` -------------------------------- ### Simulate Polytropic Compressor with Hundseid Method Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/compressor.md Simulates polytropic compression of hydrogen using the Hundseid method with 70% efficiency and 200 steps. This example shows the setup and simulation results. ```python >>> K = bst.units.PolytropicCompressor('K1', ins=feed, outs='outlet', P=350e5, eta=0.7, method='hundseid', n_steps=200) >>> K.simulate() >>> K.show() ``` ```python >>> K.results() Polytropic compressor Units K1 Electricity Power kW 6.48 Cost USD/hr 0.507 Design Polytropic work 1.98e+04 Type Reciprocating Compressors in parallel 1 Driver Electric motor Driver efficiency 0.85 Purchase cost Compressor(s) USD 1.54e+03 Total purchase cost USD 1.54e+03 Installed equipment cost USD 3.3e+03 Utility cost USD/hr 0.507 ``` -------------------------------- ### Setup and Simulate Adsorption Column Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/adsorption.md Configure thermodynamic settings, initialize a feed stream, and set up an AdsorptionColumn object. Simulate the column and optionally generate a GIF of the fluid concentration profile. ```python >>> import biosteam as bst >>> bst.settings.set_thermo([ ... 'Water', ... bst.Chemical('Adsorbate', search_db=False, default=True, phase='l'), ... bst.Chemical('ActivatedCarbon', search_db=False, default=True, phase='s') ... ]) >>> feed = bst.Stream(ID='feed', phase='l', T=298, P=1.01e+06, ... Water=1000, Adsorbate=0.001, units='kg/hr') >>> A1 = bst.AdsorptionColumn( ... 'A1', ins=feed, outs='effluent', ... cycle_time=1000, ... superficial_velocity=9.2, ... isotherm_model='Langmuir', ... isotherm_args=(1e3, 7.), # K [g / L], q_max [g / kg] ... k=0.3, # [1 / hr] ... void_fraction=0.525, ... C_final_scaled=0.05, ... adsorbate='Adsorbate', ... particle_diameter=0.004, ... ) >>> A1.simulate() >>> # A1.simulation_gif() # Create a gif of the fluid concentration profile over time. ``` -------------------------------- ### Create Mock Systems Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Creating_a_System.ipynb Instantiate systems with `mockup=True` to create lightweight versions for faster setup and testing. Mock systems only contain inlet, outlet, and unit information. ```python main_flowsheet.clear() # Remove previous unit operations to prevent ID-conflict warnings juicing_sys = create_juicing_system( outs=[sucrose_solution], mockup=True ) sucrose_to_ethanol_sys = create_sucrose_to_ethanol_system( ins=[sucrose_solution, denaturant], mockup=True ) # Note that mock systems don't have anything other than `ins`, `outs`, and `units` juicing_sys.show() sucrose_to_ethanol_sys.show() ``` -------------------------------- ### StorageTank Initialization and Simulation Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/tank.md Demonstrates how to create a StorageTank object, set its properties, simulate its behavior, and view results. ```APIDOC ## StorageTank ### Description Represents a storage tank unit operation in biosteam. ### Parameters * **name** (*str*) - Name of the unit operation. * **ins** (*Stream* or *list of Stream*) - Incoming streams. * **outs** (*Stream* or *list of Stream*) - Outgoing streams. * **tau** (*float*) - Residence time in hours. * **vessel_type** (*str*, optional) - Type of vessel (e.g., 'Floating roof', 'Tank'). Defaults to 'Tank'. * **vessel_material** (*str*, optional) - Material of the vessel (e.g., 'Carbon steel'). Defaults to 'Carbon steel'. ### Example ```pycon >>> from biosteam import units, settings, Stream >>> settings.set_thermo(['Ethanol'], cache=True) >>> feed = Stream('feed', Ethanol=23e3, units='kg/hr') >>> effluent = Stream('effluent') >>> T1 = units.StorageTank('T1', ins=feed, outs=effluent, ... tau=7*24, # In hours ... vessel_type='Floating roof', ... vessel_material='Carbon steel') >>> T1.simulate() >>> T1.show(flow='kg/hr') StorageTank: T1 ins... [0] feed phase: 'l', T: 298.15 K, P: 101325 Pa flow: 2.3e+04 kg/hr Ethanol outs... [0] effluent phase: 'l', T: 298.15 K, P: 101325 Pa flow: 2.3e+04 kg/hr Ethanol >>> T1.results() Storage tank Units T1 Design Residence time hr 168 Total volume m^3 4.92e+03 Purchase cost Tank (x2) USD 8.42e+05 Total purchase cost USD 8.42e+05 Installed equipment cost USD 1.94e+06 Utility cost USD/hr 0 ``` ``` -------------------------------- ### Install BioSTEAM with --user and --ignore-installed Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/index.md Bypass potential dependency conflicts during installation by using the --user and --ignore-installed flags with pip. This can be useful if facing installation issues. ```bash pip install --user --ignore-installed biosteam ``` -------------------------------- ### Initialize and Simulate MultiEffectEvaporator (Overall Vapor Fraction) Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/MultiEffectEvaporator.md Shows how to set up and run a MultiEffectEvaporator simulation where the vapor fraction is defined for the entire unit. Ensure the thermodynamic system is set up prior to running the simulation. ```python >>> import biosteam as bst >>> from biorefineries.cellulosic import create_cellulosic_ethanol_chemicals >>> bst.settings.set_thermo(create_cellulosic_ethanol_chemicals()) >>> feed = bst.Stream('feed', Water=1000, Glucose=100, ... AceticAcid=0.5, HMF=0.1, Furfural=0.1, ... units='kg/hr') >>> E1 = bst.MultiEffectEvaporator('E1', ins=feed, outs=('solids', 'liquid'), ... V=0.1, V_definition='Overall', ... P=(101325, 73581, 50892, 32777, 20000)) >>> E1.simulate() >>> E1.show() MultiEffectEvaporator: E1 ins... [0] feed phase: 'l', T: 298.15 K, P: 101325 Pa flow (kmol/hr): Water 55.5 AceticAcid 0.00833 Furfural 0.00104 HMF 0.000793 Glucose 0.555 outs... [0] solids phase: 'l', T: 354.91 K, P: 50892 Pa flow (kmol/hr): Water 50 AceticAcid 0.0069 Furfural 0.000577 HMF 0.000793 Glucose 0.555 [1] liquid phase: 'l', T: 361.12 K, P: 50892 Pa flow (kmol/hr): Water 5.55 AceticAcid 0.00143 Furfural 0.000464 ``` ```python >>> E1.results() Multi-effect evaporator Units E1 Electricity Power kW 5.72 Cost USD/hr 0.447 Low pressure steam Duty kJ/hr 3.84e+05 Flow kmol/hr 9.94 Cost USD/hr 2.36 Cooling water Duty kJ/hr -1.15e+05 Flow kmol/hr 78.8 Cost USD/hr 0.0384 Design Area m^2 1.62 ``` -------------------------------- ### Create and Simulate HeatExchangerNetwork Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/facilities/HeatExchangerNetwork.md Demonstrates setting up thermodynamics, creating streams and units, initializing a HeatExchangerNetwork, and simulating the system. Use this to see the impact of heat integration on utility loads. ```pycon >>> import biosteam as bst >>> bst.settings.set_thermo(['Water', 'Methanol', 'Glycerol']) >>> feed1 = bst.Stream('feed1', flow=(8000, 100, 25)) >>> feed2 = bst.Stream('feed2', flow=(10000, 1000, 10)) >>> D1 = bst.ShortcutColumn('D1', ins=feed1, ... outs=('distillate', 'bottoms_product'), ... LHK=('Methanol', 'Water'), ... y_top=0.99, x_bot=0.01, k=2, ... is_divided=True) >>> D1_H1 = bst.HXutility('D1_H1', ins = D1.outs[1], T = 300) >>> D1_H2 = bst.HXutility('D1_H2', ins = D1.outs[0], T = 300) >>> F1 = bst.Flash('F1', ins=feed2, ... outs=('vapor', 'liquid'), V = 0.9, P = 101325) >>> HXN = bst.HeatExchangerNetwork('HXN', T_min_app = 5.) >>> sys = bst.System.from_units('sys', units=[D1, D1_H1, D1_H2, F1, HXN]) >>> sys.simulate() >>> # See all results >>> round(HXN.actual_heat_util_load/HXN.original_heat_util_load, 2) 0.82 >>> abs(HXN.energy_balance_percent_error) < 0.01 True >>> HXN.stream_life_cycles [, H_in = 5.38e+06 kJ, H_out = 4.24e+07 kJ> , H_in = 4.24e+07 kJ, H_out = 6.92e+07 kJ> ]>, , H_in = 0 kJ, H_out = 3.34e+04 kJ> , H_in = 3.34e+04 kJ, H_out = 5.06e+06 kJ> , H_in = 5.06e+06 kJ, H_out = 2.3e+07 kJ> , H_in = 2.3e+07 kJ, H_out = 2.79e+08 kJ> ]>, , H_in = 4.52e+07 kJ, H_out = 8.12e+06 kJ> , H_in = 8.12e+06 kJ, H_out = 3.1e+06 kJ> , H_in = 3.1e+06 kJ, H_out = 1.14e+06 kJ> ]>, , H_in = 2.04e+07 kJ, H_out = 2.47e+06 kJ> , H_in = 2.47e+06 kJ, H_out = 2.47e+06 kJ> ]>, , H_in = 7.51e+05 kJ, H_out = 7.18e+05 kJ> , H_in = 7.18e+05 kJ, H_out = 7.18e+05 kJ> ]>] ``` -------------------------------- ### Install Graphviz on Ubuntu Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/index.md Install Graphviz on Ubuntu systems using the apt package manager. This is required for generating diagrams if not using Conda. ```bash sudo apt-get install graphviz ``` -------------------------------- ### Set up Thermo and Create Feed Stream Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Distillation.ipynb Configure the thermodynamic package and create a feed stream for distillation simulation. Ensure the feed is set at its bubble point for accurate VLE calculations. ```python import biosteam as bst import numpy as np bst.nbtutorial() # First set the property package bst.settings.set_thermo(['Water', 'Ethanol', 'Glycerol', 'Yeast'], db='BioSTEAM') # Create the feed at the bubble point feed = bst.Stream( Water=1.08e+03, Ethanol=586, Glycerol=10, Yeast=50, units='kg/hr', ) feed.vle(V=0, P=101325) ``` -------------------------------- ### Install Graphviz with Conda Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/index.md Install the Graphviz package for diagram generation within a Conda environment. This is necessary for visualizing flowsheets and system diagrams. ```bash conda install python-graphviz ``` -------------------------------- ### Create and Simulate a System Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Demonstrates setting up a biosteam system with streams, a splitter, a mixer, and then simulating it to get outlet flows. Requires setting up thermodynamic properties and clearing the main flowsheet before use. ```python >>> from biosteam import Stream, Mixer, Splitter, settings, main_flowsheet >>> settings.set_thermo(['Water', 'Ethanol']) >>> main_flowsheet.clear() >>> S1 = Splitter('S1', Stream(Ethanol=10, units='ton/hr'), split=0.1) >>> M1 = Mixer('M1', ins=[Stream(Water=10, units='ton/hr'), S1-0]) >>> sys = main_flowsheet.create_system(operating_hours=330*24) >>> sys.simulate() >>> sys.get_outlet_flow('Mton') # Sum of all chemicals 0.1584 >>> sys.get_outlet_flow('Mton', 'Water') # Just water 0.0792 ``` -------------------------------- ### Initialize CompiledChemicals and Get Array Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/thermosteam/Chemicals.md Initialize CompiledChemicals with a list of chemical names and enable caching. Then, use the array method to get the data for specified chemicals. ```python from thermosteam import CompiledChemicals chemicals = CompiledChemicals(['Water', 'Ethanol'], cache=True) chemicals.array(['Water'], [2]) ``` -------------------------------- ### Create and Simulate a System Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Creating_a_System.ipynb Demonstrates creating a system, simulating it, and generating a diagram. Use this to visualize the flow of materials within your process. ```python complete_sys = bst.main_flowsheet.create_system() complete_sys.simulate() complete_sys.diagram('cluster', number=True, format='png') ``` -------------------------------- ### Reaction Initialization and Usage Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/thermosteam/reaction/Reaction.md Demonstrates how to initialize a Reaction object, set thermodynamic settings, and apply it to a stream or array. Includes examples for different bases (molar and weight). ```APIDOC ## Reaction Initialization and Application ### Description Initialize a Reaction object with a chemical equation, specify the reactant, and set the conversion rate (X). The reaction can then be applied to a `Stream` object or a NumPy array. ### Example 1: Molar Basis ```python import thermosteam as tmo chemicals = tmo.Chemicals(['H2O', 'H2', 'O2'], cache=True) tmo.settings.set_thermo(chemicals) reaction = tmo.Reaction('2H2O,l -> 2H2,g + O2,g', reactant='H2O', X=0.7) feed = tmo.Stream('feed', H2O=100) feed.phases = ('g', 'l') reaction(feed) # Apply reaction to the stream feed.show() ``` ### Example 2: Weight Basis ```python reaction.basis = 'wt' reaction.show() feed = tmo.Stream('feed', H2O=100) feed.phases = ('g', 'l') reaction(feed) # Apply reaction to the stream feed.show() ``` ### Example 3: Reaction on Array ```python import numpy as np reaction = tmo.Reaction('2H2O -> 2H2 + O2', reactant='H2O', X=0.7) array = np.array([100., 0. , 0.]) reaction(array) print(array) ``` ``` -------------------------------- ### Get HeatUtility Characterization Factor Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/HeatUtility.md Retrieve the characterization factor for a utility agent for a given impact key. The basis can be specified to get the factor in different units. ```python bst.HeatUtility.get_CF('low_pressure_steam', 'GWP [kg CO2e]', basis='Btu') ``` -------------------------------- ### Install a specific BioSTEAM version Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/index.md Install a particular version of BioSTEAM by specifying the version number. This is useful for ensuring compatibility with existing projects or for testing specific releases. ```bash pip install biosteam== ``` -------------------------------- ### Create and Simulate a Simple Recycle Loop Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Convergence.ipynb Set up a basic recycle loop with a feed, mixer, flash, and splitter, then simulate it to observe initial convergence results. This example uses default convergence settings. ```python import biosteam as bst bst.nbtutorial() # Light-mode html diagrams and filter warnings bst.settings.set_thermo(['Water']) feed = bst.Stream(Water=1) recycle = bst.Stream() liquid_product = bst.Stream() mixer = bst.Mixer(ins=[feed, recycle]) flash = bst.Flash(ins=mixer-0, outs=['vapor_product', ''], Q=feed.Hvap, P=101325) splitter = bst.Splitter(ins=flash.liquid, outs=[recycle, liquid_product], split=0.1) # flash.liquid is flash.outs[1] sys = bst.main_flowsheet.create_system() sys.simulate() sys.diagram() sys.show() ``` -------------------------------- ### Get and Apply Baseline Scenario Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Uncertainty_and_sensitivity.ipynb Retrieves the baseline scenario values for all parameters defined in the model. The model can then be evaluated at these baseline conditions to get reference performance metrics. ```python baseline_scenario = model.get_baseline_scenario() model(baseline_scenario) ``` -------------------------------- ### Simulate Binary Distillation Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/distillation.md Demonstrates how to set up and simulate a binary distillation column. Requires importing necessary modules and setting up the feed stream. ```Python >>> from biosteam.units import BinaryDistillation >>> from biosteam import Stream, settings >>> settings.set_thermo(['Water', 'Methanol', 'Glycerol'], cache=True) >>> feed = Stream('feed', flow=(80, 100, 25)) >>> bp = feed.bubble_point_at_P() >>> feed.T = bp.T # Feed at bubble point T >>> D1 = BinaryDistillation('D1', ins=feed, ... outs=('distillate', 'bottoms_product'), ... LHK=('Methanol', 'Water'), ... y_top=0.99, x_bot=0.01, k=2, ... partial_condenser=False, ... is_divided=False) >>> D1.simulate() >>> # See all results >>> D1.results() Distillation Column Units D1 Electricity Power kW 2.48 Cost USD/hr 0.194 Cooling water Duty kJ/hr -8.41e+06 Flow kmol/hr 5.74e+03 Cost USD/hr 2.8 Low pressure steam Duty kJ/hr 1.02e+07 Flow kmol/hr 263 Cost USD/hr 62.6 Design Theoretical feed stage 9 Theoretical stages 13 Minimum reflux Ratio 0.687 Reflux Ratio 1.37 Actual stages 28 Height ft 52.4 Diameter ft 3.97 Wall thickness in 0.312 Weight lb 8.9e+03 Purchase cost Trays USD 2.28e+04 Tower USD 5.76e+04 Platform and ladders USD 1.95e+04 Condenser - Floating head USD 4.35e+04 Pump - Pump USD 4.32e+03 Pump - Motor USD 441 Reboiler - Floating head USD 2.71e+04 Total purchase cost USD 1.75e+05 Utility cost USD/hr 65.6 ``` -------------------------------- ### Simulate the System and Show Results Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Getting_started.ipynb Run the simulation for the created system to solve recycle loops and calculate unit operation performance. The 'show()' method displays the converged results. ```python sys.simulate() sys.show() ``` -------------------------------- ### Set and Get Multiple Chemical Flow Rates Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Thermodynamic_engine.ipynb Demonstrates setting and getting the flow rates for multiple chemicals simultaneously using specified units (kilograms per hour). ```python # Set and get flows of many chemicals # in kilograms per hour s1.set_flow([10, 20], 'kg/hr', ('Ethanol', 'Water')) s1.get_flow('kg/hr', ('Ethanol', 'Water')) ``` -------------------------------- ### Set and Get Single Chemical Flow Rate Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Thermodynamic_engine.ipynb Demonstrates setting and getting the flow rate of a single chemical within a stream using specified units (gallons per minute). ```python # Set and get flow of a single chemical # in gallons per minute s1.set_flow(1, 'gpm', 'Water') s1.get_flow('gpm', 'Water') ``` -------------------------------- ### Instantiate and Get Surface Tension Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/thermosteam/Chemical.md Demonstrates how to import the library, instantiate a chemical object for Water, and retrieve its surface tension at a specific temperature. ```python import thermosteam as tmo Water = tmo.Chemical('Water', cache=True) Water.get_property('sigma', 'N/m', 300.) ``` -------------------------------- ### facilities Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get a tuple of all system facilities. ```APIDOC ## *property* facilities *: tuple[[Facility](Facility.md#biosteam.Facility), ...]* ### Description All system facilities. ``` -------------------------------- ### Set up and Simulate Distillation Column Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Unit_operation_results.ipynb Use this snippet to set up thermodynamic properties, create a feed stream, and simulate a distillation column. Ensure the property package is set before creating streams and units. ```python from biosteam import Stream, settings import biosteam as bst bst.nbtutorial() # First set the property package settings.set_thermo(['Water', 'Ethanol']) # Create the feed at the bubble point feed = Stream(Water=1.08e+03, Ethanol=586) bp = feed.bubble_point_at_P() feed.T = bp.T # Feed at bubble point temperature # Create a distillation column and simulate # Use BinaryDistillation for 2-components # For 3+ components, use ShortcutColumn ``` -------------------------------- ### Instantiate and Diagram a Boiler Unit Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/tutorial/Inheriting_from_Unit.ipynb Set up the thermodynamic system and create a Boiler instance with inlet streams and operating parameters. Use `.diagram()` to visualize the unit. ```python import biosteam as bst bst.settings.set_thermo(['Water']) water = bst.Stream(Water=300) B1 = Boiler(ins=water, outs=('gas', 'liq'), V=0.5, P=101325) B1.diagram() B1.show() ``` -------------------------------- ### UnitGroup.get_installed_cost() Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/process_tools/UnitGroup.md Retrieve the installed equipment cost for the UnitGroup. ```APIDOC ## UnitGroup.get_installed_cost() ### Description Get the installed equipment cost for the UnitGroup. ### Response Example ``` 0.05 ``` ``` -------------------------------- ### products Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get a list of all product streams from the system. ```APIDOC ## *property* products *: list[[Stream](thermosteam/Stream.md#thermosteam.Stream)]* ### Description All products of the system. ``` -------------------------------- ### Initialize and Simulate MultiEffectEvaporator (First Effect Vapor Fraction) Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/MultiEffectEvaporator.md Demonstrates initializing a MultiEffectEvaporator with a feed stream and simulating it with the vapor fraction defined for the first effect. Ensure thermo settings are configured before simulation. ```python >>> import biosteam as bst >>> bst.process_tools.default() >>> from biorefineries.cellulosic import create_cellulosic_ethanol_chemicals >>> bst.settings.set_thermo(create_cellulosic_ethanol_chemicals()) >>> feed = bst.Stream('feed', Water=1000, Glucose=100, ... AceticAcid=0.5, HMF=0.1, Furfural=0.1, ... units='kg/hr') >>> E1 = bst.MultiEffectEvaporator('E1', ins=feed, outs=('solids', 'liquid'), ... V=0.1, V_definition='First-effect', ... P=(101325, 73581, 50892, 32777, 20000)) >>> E1.simulate() >>> E1.show() MultiEffectEvaporator: E1 ins... [0] feed phase: 'l', T: 298.15 K, P: 101325 Pa flow (kmol/hr): Water 55.5 AceticAcid 0.00833 Furfural 0.00104 HMF 0.000793 Glucose 0.555 outs... [0] solids phase: 'l', T: 333.21 K, P: 20000 Pa flow (kmol/hr): Water 20.5 AceticAcid 0.00181 Furfural 5.29e-05 HMF 0.000793 Glucose 0.555 [1] liquid phase: 'l', T: 352.11 K, P: 20000 Pa flow (kmol/hr): Water 35 AceticAcid 0.00651 Furfural 0.000988 ``` ```python >>> E1.results() Multi-effect evaporator Units E1 Electricity Power kW 5.72 Cost USD/hr 0.447 Low pressure steam Duty kJ/hr 5.83e+05 Flow kmol/hr 15.1 Cost USD/hr 3.58 Cooling water Duty kJ/hr -3.5e+05 Flow kmol/hr 239 Cost USD/hr 0.117 Design Area m^2 11 Volume m^3 3.51 Purchase cost Evaporators (x5) USD 9.56e+03 Condenser - Double pipe USD 5.36e+03 Vacuum system - Liquid-ring pump... USD 1.07e+04 Total purchase cost USD 2.56e+04 Installed equipment cost USD 4.2e+04 Utility cost USD/hr 4.15 ``` -------------------------------- ### Simulate LLECentrifuge and show outlet stream Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/liquid_liquid_extraction.md Demonstrates setting up the thermodynamic system, creating a feed stream, initializing an LLECentrifuge, simulating it, and displaying the composition of the 'light' outlet stream. ```pycon >>> from biorefineries.lipidcane import chemicals >>> from biosteam import units, settings, Stream >>> settings.set_thermo(chemicals['Methanol', 'Glycerol', 'Biodiesel', 'TAG']) >>> feed = Stream('feed', T=333.15, ... TAG=0.996, Biodiesel=26.9, ... Methanol=32.9, Glycerol=8.97) >>> C1 = units.LLECentrifuge('C1', ins=feed, outs=('light', 'heavy')) >>> C1.simulate() >>> C1.outs[0].show() Stream: light from phase: 'l', T: 333.15 K, P: 101325 Pa flow (kmol/hr): Methanol 10.2 Glycerol 0.0239 Biodiesel 26.9 TriOlein 0.996 ``` -------------------------------- ### feeds Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get a list of all feed streams to the system. ```APIDOC ## *property* feeds *: list[[Stream](thermosteam/Stream.md#thermosteam.Stream)]* ### Description All feeds to the system. ``` -------------------------------- ### streams Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get a list of all streams within the system. ```APIDOC ## *property* streams *: list[[Stream](thermosteam/Stream.md#thermosteam.Stream)]* ### Description All streams within the system. ``` -------------------------------- ### Create and Simulate Conventional Wastewater Treatment System Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/wastewater/conventional.md Demonstrates how to set up the thermodynamic settings, create a wastewater stream with specific components and units, simulate the wastewater treatment system, and display the results for a specific unit. ```python >>> from biosteam import Stream, create_conventional_wastewater_treatment_system, settings >>> settings.set_thermo(create_conventional_wastewater_treatment_system.fthermo()) >>> feed = Stream( ... ID='wastewater', ... Water=2.634e+04, ... Ethanol=0.07225, ... AceticAcid=24.67, ... Furfural=6.206, ... Glycerol=1.784, ... LacticAcid=17.7, ... SuccinicAcid=3.472, ... DAP=1.001, ... AmmoniumSulfate=17.63, ... HMF=2.366, ... Glucose=2.816, ... Xylose=6.953, ... Arabinose=12.78, ... Extract=65.98, ... Ash=83.52, ... Lignin=1.659, ... SolubleLignin=4.202, ... GlucoseOligomer=6.796, ... GalactoseOligomer=0.01718, ... MannoseOligomer=0.009008, ... XyloseOligomer=2.878, ... ArabinoseOligomer=0.3508, ... Z_mobilis=0.6668, ... Protein=2.569, ... Glucan=0.1555, ... Xylan=0.06121, ... Xylitol=4.88, ... Cellobiose=0.9419, ... Arabinan=0.02242, ... Mannan=0.06448, ... Galactan=0.01504, ... Cellulase=25.4, ... units='kmol/hr' ... ) >>> wwt_sys = create_conventional_wastewater_treatment_system(ins=feed) >>> wwt_sys.simulate() >>> wwt_sys.show('cwt100') ``` -------------------------------- ### subsystems Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get a list of all subsystems within the system. ```APIDOC ## *property* subsystems *: list[[System](#biosteam.System)]* ### Description All subsystems in the system. ``` -------------------------------- ### installed_cost Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Property representing the total installed cost in USD. ```APIDOC ## installed_cost ### Description Property representing the total installed cost in USD. ### Type float ``` -------------------------------- ### Initialize and Copy Flows with MultiStream Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/thermosteam/MultiStream.md Demonstrates initializing a MultiStream with specific components and flows, then copying all flows to another stream. Requires setting up thermodynamic properties first. ```python >>> import thermosteam as tmo >>> tmo.settings.set_thermo(['Water', 'Ethanol'], cache=True) >>> s1 = tmo.MultiStream('s1', l=[('Water', 20), ('Ethanol', 10)], units='kg/hr') >>> s2 = tmo.MultiStream('s2') >>> s2.copy_flow(s1) >>> s2.show(flow='kg/hr') ``` -------------------------------- ### Simulate Storage Tank and Set/Get Design Results Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/Unit.md Demonstrates setting up a stream and a storage tank, simulating its operation, and then setting and retrieving a design result for total volume. Use this to manage and query design parameters of unit operations. ```python >>> 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.set_design_result('Total volume', 'm3', 1000) 1000 >>> tank.get_design_result('Total volume', 'm3') 1000.0 ``` -------------------------------- ### N_runs Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get the number of times the path needs to converge. ```APIDOC ## *property* N_runs *: int | None* ### Description Number of times to converge the path. ``` -------------------------------- ### cost_units Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get a set of all unit operations that have associated costs. ```APIDOC ## *property* cost_units *: set[[Unit](Unit.md#biosteam.Unit)]* ### Description All unit operations with costs. ``` -------------------------------- ### Simulate a Shortcut Distillation Column Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/units/distillation.md Demonstrates how to set up and simulate a ShortcutColumn for a ternary mixture. Ensure thermodynamic settings are configured before simulation. The column is configured for a divided wall setup. ```python >>> from biosteam.units import ShortcutColumn >>> from biosteam import Stream, settings >>> settings.set_thermo(['Water', 'Methanol', 'Glycerol'], cache=True) >>> feed = Stream('feed', flow=(80, 100, 25)) >>> bp = feed.bubble_point_at_P() >>> feed.T = bp.T # Feed at bubble point T >>> D1 = ShortcutColumn('D1', ins=feed, ... outs=('distillate', 'bottoms_product'), ... LHK=('Methanol', 'Water'), ... y_top=0.99, x_bot=0.01, k=2, ... is_divided=True) >>> D1.simulate() >>> # See all results >>> D1.show(T='degC', P='atm', composition=True) ShortcutColumn: D1 ins... [0] feed phase: 'l', T: 76.082 degC, P: 1 atm flow (%): Water 39 Methanol 48.8 Glycerol 12.2 -------- 205 kmol/hr outs... [0] distillate phase: 'g', T: 64.854 degC, P: 1 atm flow (%): Water 1 Methanol 99 -------- 100 kmol/hr [1] bottoms_product phase: 'l', T: 100.02 degC, P: 1 atm flow (%): Water 75.4 Methanol 0.761 Glycerol 23.9 -------- 105 kmol/hr ``` -------------------------------- ### unit_set Source: https://github.com/biosteamdevelopmentgroup/biosteam/blob/master/docs/API/System.md Get a set of all unit operations within the system. ```APIDOC ## *property* unit_set *: set[[Unit](Unit.md#biosteam.Unit)]* ### Description Set of all unit operations. ```