<jupyter_start><jupyter_text>Getting started  Get thermodynamic and material properties using Chemical objects Chemical objects are an extension of the [thermo.Chemical](http://thermo.readthedocs.io/en/latest/thermo.chemical.html) class from the Chemical Engineering Design Library. Initiallize a Chemical object with an ID:<jupyter_code>import biosteam as bst
Water = bst.compounds.Chemical('Water')
Water<jupyter_output>Chemical: Water
 phase: 'l', T: 298.15 K, P: 101325 Pa<jupyter_text>Chemical objects have a temperature `T`, pressure `P`, and `phase`:<jupyter_code>Water.T, Water.P, Water.phase<jupyter_output><empty_output><jupyter_text>You can view in different units with `show`:<jupyter_code>Water.show(T='degC', P='atm')<jupyter_output>Chemical: Water
 phase: 'l', T: 25 degC, P: 1 atm<jupyter_text>Chemical objects contain thermodynamic properties:<jupyter_code>Water.rho # (kg/m3)<jupyter_output><empty_output><jupyter_text>These properties are dependent on temperature (T), pressure (P) and phase:<jupyter_code>Water.T = 350 # (Kelvin)
Water.rho # (kg/m3)<jupyter_output><empty_output><jupyter_text>Note how the density changed with temperature. Many more material properties are available. Please read the [thermo.Chemical](http://thermo.readthedocs.io/en/latest/thermo.chemical.html) documentation to learn more.  Group Chemical objects with a Species object Initiallize a [Species](https://biosteam.readthedocs.io/en/latest/Species.html) object with IDs:<jupyter_code>species = bst.Species('Methanol', 'Glycerol')
species<jupyter_output><empty_output><jupyter_text>The Chemical objects are stored as attributes:<jupyter_code>species.Methanol, species.Glycerol<jupyter_output><empty_output><jupyter_text>Set chemical attributes:<jupyter_code>species.Water = Water
species<jupyter_output><empty_output><jupyter_text>Material flows and mixture properties with Stream objects First set the working species of all [Stream](https://biosteam.readthedocs.io/en/latest/Stream.html) objects:<jupyter_code>bst.Stream.species = species # From before<jupyter_output><empty_output><jupyter_text>A Stream is initialized with an ID, specie-flow rate pairs, temperature, pressure and phase:<jupyter_code>feed = bst.Stream(ID='feed', Methanol=1, Glycerol=2, Water=3)
feed<jupyter_output>Stream: feed
 phase: 'l', T: 298.15 K, P: 101325 Pa
 flow (kmol/hr): Methanol  1
                 Glycerol  2
                 Water     3<jupyter_text>Alternatively, flow rates can be given as an iterable:<jupyter_code>feed = bst.Stream(ID='feed', flow=(1,2,3), T=300, P=101325)
feed<jupyter_output>Stream: feed
 phase: 'l', T: 300 K, P: 101325 Pa
 flow (kmol/hr): Methanol  1
                 Glycerol  2
                 Water     3<jupyter_text>View with different units using the `show` method:<jupyter_code>feed.show(flow='kg/hr', T='degC', P='atm')<jupyter_output>Stream: feed
 phase: 'l', T: 26.85 degC, P: 1 atm
 flow (kg/hr): Methanol  32
               Glycerol  184
               Water     54<jupyter_text>Flow rates can be conviniently get and set:<jupyter_code>feed.setflow(Water=50, units='kg/hr')
feed.getflow('Methanol', 'Water', units='kg/hr')<jupyter_output><empty_output><jupyter_text>Stream objects contain T, P, and phase dependent properties:<jupyter_code>feed.H # kJ/hr with reference at STP
feed.T = 350
feed.H<jupyter_output><empty_output><jupyter_text>Vapor liquid equilibrium is just a line away:<jupyter_code># Set pressure and duty
feed.VLE(P=101325, Q=0)
feed
# Set vapor fraction and pressure
feed.VLE(V=0.5, P=101325)
feed<jupyter_output>MixedStream: feed
 phase: 'lg', T: 382.24 K, P: 101325 Pa
         species   kmol/hr
 liquid: Methanol  0.222
         Glycerol  2
         Water     0.667

 vapor:  Methanol  0.778
         Glycerol  0.000981
         Water     2.11<jupyter_text>The stream is cast to a [MixedStream](https://biosteam.readthedocs.io/en/latest/MixedStream.html) object. Mixed streams contain multiple phases:<jupyter_code>feed.phase<jupyter_output><empty_output><jupyter_text>Please refer to the [MixedStream objects and thermodynamic equilibrium example](https://biosteam.readthedocs.io/en/latest/MixedStream objects and thermodynamic equilibrium.html) for more details.  Process settings **Process settings include price of feeds and products, conditions of utilities, and the chemical engineering plant cost index. These should be set before simulating a system.** Set the chemical engineering plant cost index:<jupyter_code>bst.CE # Default year is 2017
bst.CE = 603.1 # To year 2018<jupyter_output><empty_output><jupyter_text>Set price of streams:<jupyter_code>feed.price # Default price is zero
feed.price = 0.50<jupyter_output><empty_output><jupyter_text>Set [PowerUtility](https://biosteam.readthedocs.io/en/latest/PowerUtility.html) options:<jupyter_code>bst.PowerUtility.price # Default price
bst.PowerUtility.price = 0.065 # Adjust price<jupyter_output><empty_output><jupyter_text>Set [HeatUtility](https://biosteam.readthedocs.io/en/latest/HeatUtility.html) options:<jupyter_code>bst.HeatUtility.cooling_agents # Dictionary of available cooling agents
cw = bst.HeatUtility.cooling_agents['Cooling water']
cw # A UtilityAgent

# Data is stored as attributes
(cw.species, cw.molfrac, cw.T, cw.P, cw.phase, cw.T_limit, cw.price_kJ, cw.price_kmol, cw.efficiency)
cw.T = 302 # Change temperature (K)
bst.HeatUtility.heating_agents # Dictionary of available heating agents
bst.HeatUtility.heating_agents['Low pressure steam'] # A UtilityAgent
bst.HeatUtility.heating_agents['Low pressure steam'].price_kmol = 0.20 # Change price (USD/kmol)<jupyter_output><empty_output><jupyter_text>Find design requirements and cost with Unit objects [Creating a Unit](https://biosteam.readthedocs.io/en/latest/Creating a Unit.html) can be flexible. But in summary, a [Unit](https://biosteam.readthedocs.io/en/latest/Unit.html) object is initialized with an ID, and unit specific arguments:<jupyter_code># Specify vapor fraction and isobaric conditions
F1 = bst.units.Flash('F1', V=0.5, P=101325)
F1<jupyter_output><empty_output><jupyter_text>Note that, by default, Missing Stream objects are given to inputs, `ins`, and empty streams to outputs, `outs`:<jupyter_code>F1.ins
F1.outs<jupyter_output><empty_output><jupyter_text>You can connect streams by setting the `ins` and `outs`:<jupyter_code>F1.ins[0] = bst.Stream(Water=220, Glycerol=180)
F1<jupyter_output><empty_output><jupyter_text>To simulate the flash, use the `simulate` method:<jupyter_code>F1.simulate()
F1.show()<jupyter_output>Flash: F1
ins...
[0] d3
    phase: 'l', T: 298.15 K, P: 101325 Pa
    flow (kmol/hr): Glycerol  180
                    Water     220
outs...
[0] d1
    phase: 'g', T: 421.36 K, P: 101325 Pa
    flow (kmol/hr): Glycerol  0.921
                    Water     199
[1] d2
    phase: 'l', T: 421.36 K, P: 101325 Pa
    flow (kmol/hr): Glycerol  179
                    Water     20.9<jupyter_text>The `results` method returns simulation results:<jupyter_code>F1.results() # Default returns DataFrame object with units
F1.results(with_units=False) # Returns Series object without units<jupyter_output><empty_output><jupyter_text>Solve recycle loops and process specifications with System objects **Designing a chemical process is no easy task. A simple recycle process consisting of a flash with a partial liquid recycle is presented here.** Create a [Mixer](https://biosteam.readthedocs.io/en/latest/Mixer.html) object and a [Splitter](https://biosteam.readthedocs.io/en/latest/Splitter.html) object:<jupyter_code>M1 = bst.units.Mixer('M1')
S1 = bst.units.Splitter('S1', split=0.5) # Split to 0th output stream
F1.outs[0].ID = 'product'<jupyter_output><empty_output><jupyter_text>You can [find unit operations and manage flowsheets](https://biosteam.readthedocs.io/en/master/tutorial/Managing%20flowsheets.html) with `find`:<jupyter_code>bst.find.diagram()<jupyter_output><empty_output><jupyter_text>Connect streams and make a recycle loop using [-pipe- notation](https://biosteam.readthedocs.io/en/latest/Using -pipe- notation.html):<jupyter_code>feed = bst.Stream('feed', Glycerol=100, Water=450)

# Broken down -pipe- notation
[S1-0, feed]-M1     # M1.ins[:] = [S1.outs[0], feed]
M1-F1               # F1.ins[:] = M1.outs
F1-1-S1             # S1.ins[:] = [F1.outs[1]]

# All together
[S1-0, feed]-M1-F1-1-S1;<jupyter_output><empty_output><jupyter_text>Create [System](https://biosteam.readthedocs.io/en/latest/System.html) object by specifying an ID, a `recycle` stream and a `network` of units:<jupyter_code>sys1 = bst.System('sys1', network=(M1, F1, S1), recycle=S1-0) # recycle=S1.outs[0]
sys1<jupyter_output><empty_output><jupyter_text>View the System object as a Graphviz diagram:<jupyter_code>sys1.diagram()<jupyter_output><empty_output><jupyter_text>Simulate the System object:<jupyter_code>sys1.simulate()
sys1.show()
F1.show()
F1.results()<jupyter_output><empty_output><jupyter_text>Save a system report:<jupyter_code>sys1.save_report('Example.xlsx') # Try this on your computer and open excel<jupyter_output>C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:1: RuntimeWarning: Cannot find TEA object in <System: sys1>. Ignoring TEA sheets.
  """Entry point for launching an IPython kernel.
{'fraction_non_alphanumeric': 0.11779991338241663, 'fraction_numerical': 0.031831961888263316, 'mean_word_length': 5.423504867872045, 'pattern_counts': {'":': 0, '<': 122, '<?xml version=': 0, '>': 122, 'https://': 13, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '32', 'dir': 'jupyter-structured-clean-dedup', 'id': '55441', 'license': 'MIT', 'n_tokens_mistral': 3497, 'n_tokens_neox': 3201, 'n_words': 768, 'path': 'docs/tutorial/.ipynb_checkpoints/Getting started-checkpoint.ipynb', 'repo_name': 'lilanyu/biosteam', 'size': '9236'}