{ "cells": [ { "cell_type": "markdown", "id": "header", "metadata": {}, "source": [ "# Quick Overview \n", "\n", "*Click the badge below to try this tutorial interactively in your browser:*\n", "\n", "[![Launch Binder](../images/custom_binder_logo.svg)](https://mybinder.org/v2/gh/QSD-Group/QSDsan-env/main?urlpath=git-pull%3Frepo%3Dhttps%253A%252F%252Fgithub.com%252FQSD-group%252FQSDsan%26urlpath%3Dlab%252Ftree%252FQSDsan%252Fdocs%252Fsource%252Ftutorials%26branch%3Dmain)\n", "\n", "*You can also run this tutorial in [Google Colab](https://colab.research.google.com). It takes a one-time setup per session: follow the [Colab instructions](https://qsdsan.readthedocs.io/en/latest/tutorials/index.html#run-in-colab).*\n", "\n", "- **Prepared by:**\n", "\n", " - [Yalin Li](https://github.com/yalinli2)\n", "\n", "- **Learning objectives.** After this tutorial, you will be able to:\n", "\n", " - See how the main `QSDsan` classes (`Component`, `WasteStream`, `SanUnit`, `System`, `TEA`, `LCA`, `Process`) fit together\n", " - Preview the typical workflow from defining components to running an analysis\n", " - Decide which subsequent tutorials to read based on what you want to build" ] }, { "cell_type": "markdown", "id": "intro", "metadata": {}, "source": [ "`QSDsan` is a Python platform for the quantitative sustainable design of sanitation and resource recovery systems. Built on `BioSTEAM`, it lets you assemble treatment trains as connected unit operations, compute techno-economic and life-cycle impact metrics, and explore uncertainty and sensitivity across designs.\n", "\n", "This tutorial is a brief tour of the main pieces. Each class shown here has its own dedicated tutorial; pointers are at the end." ] }, { "cell_type": "markdown", "id": "s1-head", "metadata": {}, "source": [ "\n", "\n", "## Setup\n", "\n", "Import `QSDsan` and confirm the installed version." ] }, { "cell_type": "code", "execution_count": 1, "id": "s1-code", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This tutorial was made with qsdsan v1.5.3 and exposan v1.5.3\n" ] } ], "source": [ "import qsdsan as qs, exposan\n", "print(f'This tutorial was made with qsdsan v{qs.__version__} and exposan v{exposan.__version__}')" ] }, { "cell_type": "markdown", "id": "s2-head", "metadata": {}, "source": [ "## 1. The pieces of QSDsan \n", "\n", "`QSDsan` groups its functionality into a small set of core classes:\n", "\n", "![QSDsan UML diagram](../images/uml.png)\n", "\n", "*Thermosteam, BioSTEAM, and BW2QSD are external packages that QSDsan leverages.*\n", "\n", "| Class | What it represents |\n", "| --- | --- |\n", "| `Component` | A chemical or biological species, with thermodynamic and biological properties |\n", "| `WasteStream` | A flow of components, with composition and thermodynamic state |\n", "| `SanUnit` | A unit operation, with `_run`, `_design`, and `_cost` methods |\n", "| `System` | A connected set of units representing a treatment train |\n", "| `Process` | Rate expressions and stoichiometry for dynamic biokinetic models |\n", "| `TEA` | Techno-economic analysis on a `System` |\n", "| `LCA` | Life cycle assessment on a `System` |\n", "| `Model` | Parameters and metrics for uncertainty and sensitivity analyses |\n", "\n", "The rest of this tour shows each one briefly." ] }, { "cell_type": "markdown", "id": "s3-head", "metadata": {}, "source": [ "## 2. Components and Streams \n", "\n", "A `Component` describes one species (a chemical, a microbial group, or an aggregate parameter such as COD). A `Components` registry defines the thermodynamic basis for the model and must be set as the active thermo before building streams. See the [Component](https://qsdsan.readthedocs.io/en/latest/tutorials/2_Component.html) tutorial for more information." ] }, { "cell_type": "code", "execution_count": 2, "id": "s3-cmps", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CompiledComponents([\n", " S_H2, S_CH4, S_CH3OH, S_Ac, \n", " S_Prop, S_F, S_U_Inf, S_U_E, \n", " C_B_Subst, C_B_BAP, C_B_UAP, C_U_Inf, \n", " X_B_Subst, X_OHO_PHA, X_GAO_PHA, X_PAO_PHA,\n", " X_GAO_Gly, X_PAO_Gly, X_OHO, X_AOO, \n", " X_NOO, X_AMO, X_PAO, X_MEOLO, \n", " X_FO, X_ACO, X_HMO, X_PRO, \n", " X_U_Inf, X_U_OHO_E, X_U_PAO_E, X_Ig_ISS, \n", " X_MgCO3, X_CaCO3, X_MAP, X_HAP, \n", " X_HDP, X_FePO4, X_AlPO4, X_AlOH, \n", " X_FeOH, X_PAO_PP_Lo, X_PAO_PP_Hi, S_NH4, \n", " S_NO2, S_NO3, S_PO4, S_K, \n", " S_Ca, S_Mg, S_CO3, S_N2, \n", " S_O2, S_CAT, S_AN, H2O, \n", "])\n" ] } ], "source": [ "cmps = qs.Components.load_default()\n", "qs.set_thermo(cmps)\n", "cmps.show()" ] }, { "cell_type": "markdown", "id": "s3-one-cmp-md", "metadata": {}, "source": [ "Each component carries a rich set of properties:" ] }, { "cell_type": "code", "execution_count": 3, "id": "s3-one-cmp", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Component: S_CH4 (phase_ref='g')\n", "[Names] CAS: 74-82-8\n", " InChI: CH4/h1H4\n", " InChI_key: VNWKTOKETHGBQD-U...\n", " common_name: methane\n", " iupac_name: ('methane',)\n", " pubchemid: 297\n", " smiles: C\n", " formula: CH4\n", "[Groups] Dortmund: \n", " UNIFAC: \n", " PSRK: \n", " NIST: \n", "[Data] MW: 16.042 g/mol\n", " Tm: 90.75 K\n", " Tb: 111.67 K\n", " Tt: 90.694 K\n", " Tc: 190.56 K\n", " Pt: 11696 Pa\n", " Pc: 4.5992e+06 Pa\n", " Vc: 9.8628e-05 m^3/mol\n", " Hf: -74534 J/mol\n", " S0: 186.3 J/K/mol\n", " LHV: 8.0257e+05 J/mol\n", " HHV: 8.9059e+05 J/mol\n", " Hfus: 940 J/mol\n", " Sfus: 0\n", " omega: 0.01142\n", " dipole: 0 Debye\n", " similarity_variable: 0.31167\n", " iscyclic_aliphatic: 0\n", " combustion: {'CO2': 1, 'O2'...\n", "Component-specific properties:\n", "[Others] measured_as: COD\n", " description: Dissolved Methane\n", " particle_size: Dissolved gas\n", " degradability: Readily\n", " organic: True\n", " i_C: 0.18767 g C/g COD\n", " i_N: 0 g N/g COD\n", " i_P: 0 g P/g COD\n", " i_K: 0 g K/g COD\n", " i_Mg: 0 g Mg/g COD\n", " i_Ca: 0 g Ca/g COD\n", " i_mass: 0.25067 g mass/g COD\n", " i_charge: 0 mol +/g COD\n", " i_COD: 1 g COD/g COD\n", " i_NOD: 0 g NOD/g COD\n", " f_BOD5_COD: 0\n", " f_uBOD_COD: 0\n", " f_Vmass_Totmass: 1\n", " chem_MW: 16.042\n" ] } ], "source": [ "cmps.S_CH4.show(chemical_info=True)" ] }, { "cell_type": "markdown", "id": "s3-ws-md", "metadata": {}, "source": [ "`QSDsan` provides three stream classes in a hierarchy. The [Stream](https://biosteam.readthedocs.io/en/latest/API/thermosteam/Stream.html) class is from Thermosteam (BioSTEAM's thermodynamic engine), which represents a generic material flow. `SanStream` adds stream-level life cycle impact functionalit, and `WasteStream` adds wastewater-modeling functionality on top of `SanStream`. See this [comparison page](https://qsdsan.readthedocs.io/en/latest/api/major_classes/streams.html) and the [WasteStream](https://qsdsan.readthedocs.io/en/latest/tutorials/3_WasteStream.html) tutorial for more information." ] }, { "cell_type": "markdown", "id": "c218dc51", "metadata": {}, "source": [ "A `WasteStream` holds component flows plus the thermodynamic state. Several convenience initializers are available; for example, a typical municipal influent can be built from a COD-based model:" ] }, { "cell_type": "code", "execution_count": 4, "id": "s3-ws", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WasteStream: ww\n", "phase: 'l', T: 298.15 K, P: 101325 Pa\n", "flow (g/hr): S_F 7.5\n", " S_U_Inf 3.25\n", " C_B_Subst 4\n", " X_B_Subst 22.7\n", " X_U_Inf 5.58\n", " X_Ig_ISS 5.23\n", " S_NH4 2.5\n", " S_PO4 0.8\n", " S_K 2.8\n", " S_Ca 14\n", " S_Mg 5\n", " S_CO3 12\n", " S_N2 1.8\n", " S_CAT 0.3\n", " S_AN 1.2\n", " ... 9.96e+04\n", " WasteStream-specific properties:\n", " pH : 7.0\n", " Alkalinity : 10.0 mmol/L\n", " COD : 430.0 mg/L\n", " BOD : 249.4 mg/L\n", " TC : 265.0 mg/L\n", " TOC : 137.6 mg/L\n", " TN : 40.0 mg/L\n", " TP : 10.0 mg/L\n", " TK : 28.0 mg/L\n", " TSS : 209.3 mg/L\n", " Component concentrations (mg/L):\n", " S_F 75.0\n", " S_U_Inf 32.5\n", " C_B_Subst 40.0\n", " X_B_Subst 226.7\n", " X_U_Inf 55.8\n", " X_Ig_ISS 52.3\n", " S_NH4 25.0\n", " S_PO4 8.0\n", " S_K 28.0\n", " S_Ca 140.0\n", " S_Mg 50.0\n", " S_CO3 120.0\n", " S_N2 18.0\n", " S_CAT 3.0\n", " S_AN 12.0\n", " ...\n" ] } ], "source": [ "ww = qs.WasteStream.codbased_inf_model('ww', flow_tot=100)\n", "ww.show()" ] }, { "cell_type": "markdown", "id": "s4-head", "metadata": {}, "source": [ "## 3. Unit Operations \n", "\n", "A `SanUnit` is a unit operation. `QSDsan` have many pre-built subclasses (clarifiers, anaerobic digesters, membrane filters, etc.) that are often used for sanitation and resource recovery facilities. You can also subclass `SanUnit` to model your own; see the [basic](https://qsdsan.readthedocs.io/en/latest/tutorials/4_SanUnit_basic.html) and [advanced](https://qsdsan.readthedocs.io/en/latest/tutorials/5_SanUnit_advanced.html) tutorials for more information." ] }, { "cell_type": "code", "execution_count": 5, "id": "s4-code", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "qsdsan ships 132 unit operations. A few examples:\n", " - A1junction\n", " - ADM1ptomASM2d\n", " - ADM1toASM2d\n", " - ADMjunction\n", " - ADMtoASM\n", " - ASM2dtoADM1\n", " - ASM2dtomADM1\n", " - ASMtoADM\n", " - ActivatedSludgeProcess\n", " - AdiabaticMultiStageVLEColumn\n" ] } ], "source": [ "# A small sample of built-in unit operations\n", "# See the list of unit operations in the documentation for more details:\n", "# https://qsdsan.readthedocs.io/en/latest/api/unit_operations/index.html\n", "ops = sorted(i for i in dir(qs.unit_operations) if not i.startswith('_'))\n", "print(f'qsdsan ships {len(ops)} unit operations. A few examples:')\n", "for o in ops[:10]:\n", " print(f' - {o}')" ] }, { "cell_type": "markdown", "id": "s5-head", "metadata": {}, "source": [ "## 4. Process Models \n", "\n", "A `Process` represents a single reaction defined by a rate expression and component stoichiometry. A `Processes` instance groups related `Process` objects into a complete dynamic model such as ASM1, ASM2d, or ADM1. See the [Process](https://qsdsan.readthedocs.io/en/latest/tutorials/10_Process.html) tutorial for more information." ] }, { "cell_type": "markdown", "id": "36057fe5", "metadata": {}, "source": [ "**Note.** If your model is steady-state, i.e., flows and unit behavior do not change with time, you do not need `Process`. It is only needed when you need to capture time-varying behavior. The dynamic-modeling tutorials in Part III cover this in depth." ] }, { "cell_type": "code", "execution_count": 6, "id": "s5-code", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " rate_equation\n", "aero_growth_hetero 4.0*S_NH*S_O*S_S*X_BH/((S_NH + ...\n", "anox_growth_hetero 0.64*S_NH*S_NO*S_S*X_BH/((S_NH ...\n", "aero_growth_auto 0.5*S_NH*S_O*X_BA/((S_NH + 1.0)...\n", "decay_hetero 0.3*X_BH\n", "decay_auto 0.05*X_BA\n", "ammonification 0.05*S_ND*X_BH\n", "hydrolysis 3.0*X_BH*X_S*(0.16*S_NO/((S_NO ...\n", "hydrolysis_N 3.0*X_BH*X_ND*(0.16*S_NO/((S_NO...\n" ] } ], "source": [ "asm1_cmps = qs.process_models.create_asm1_cmps(set_thermo=True)\n", "asm1 = qs.process_models.ASM1()\n", "print(asm1.rate_equations)" ] }, { "cell_type": "markdown", "id": "s6-head", "metadata": {}, "source": [ "## 5. Assembling Unit Operations into a System \n", "\n", "Units connect via influent and effluent streams to form a `System`. Below is an example from `EXPOsan` (the companion package of established systems). The `bwaise` study models sanitation for Bwaise, an unplanned settlement in Kampala, Uganda. See the [System](https://qsdsan.readthedocs.io/en/latest/tutorials/6_System.html) tutorial for more information." ] }, { "cell_type": "code", "execution_count": 7, "id": "s6-load", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "99861589150:c->99861616909:c\n", "\n", "\n", "\n", " urine\n", "\n", "\n", "\n", "\n", "\n", "99861589150:c->99861616909:c\n", "\n", "\n", "\n", " feces\n", "\n", "\n", "\n", "\n", "\n", "99861616909:c->99861643211:c\n", "\n", "\n", "\n", " mixed waste\n", "\n", "\n", "\n", "\n", "\n", "99861616909:c->99861611467:c\n", "\n", "\n", "\n", " A2 CH4\n", "\n", "\n", "\n", "\n", "\n", "99861616909:c->99861589714:c\n", "\n", "\n", "\n", " A2 N2O\n", "\n", "\n", "\n", "\n", "\n", "99861616909:c->99860132959:w\n", "\n", "\n", " leachate\n", "\n", "\n", "\n", "\n", "\n", "99861643211:c->99861642281:c\n", "\n", "\n", "\n", " transported\n", "\n", "\n", "\n", "\n", "\n", "99861643211:c->99860133319:w\n", "\n", "\n", " conveyance\n", " loss\n", "\n", "\n", "\n", "\n", "\n", "99861642281:c->99861589465:c\n", "\n", "\n", "\n", " ws1\n", "\n", "\n", "\n", "\n", "\n", "99861589465:c->99861589342:c\n", "\n", "\n", "\n", " liq\n", "\n", "\n", "\n", "\n", "\n", "99861589465:c->99861589993:c\n", "\n", "\n", "\n", " sol\n", "\n", "\n", "\n", "\n", "\n", "99861589465:c->99861611467:c\n", "\n", "\n", "\n", " A5 CH4\n", "\n", "\n", "\n", "\n", "\n", "99861589465:c->99861589714:c\n", "\n", "\n", "\n", " A5 N2O\n", "\n", "\n", "\n", "\n", "\n", "99861589342:c->99861590011:c\n", "\n", "\n", "\n", " anaerobic treated\n", "\n", "\n", "\n", "\n", "\n", "99861589342:c->99861611467:c\n", "\n", "\n", "\n", " A6 CH4\n", "\n", "\n", "\n", "\n", "\n", "99861589342:c->99861589714:c\n", "\n", "\n", "\n", " A6 N2O\n", "\n", "\n", "\n", "\n", "\n", "99861590011:c->99861611164:c\n", "\n", "\n", "\n", " facultative\n", " treated\n", "\n", "\n", "\n", "\n", "\n", "99861590011:c->99861611467:c\n", "\n", "\n", "\n", " A7 CH4\n", "\n", "\n", "\n", "\n", "\n", "99861590011:c->99861589714:c\n", "\n", "\n", "\n", " A7 N2O\n", "\n", "\n", "\n", "\n", "\n", "99861589993:c->99861611467:c\n", "\n", "\n", "\n", " A8 CH4\n", "\n", "\n", "\n", "\n", "\n", "99861589993:c->99861589714:c\n", "\n", "\n", "\n", " A8 N2O\n", "\n", "\n", "\n", "\n", "\n", "99861589993:c->99861610747:w\n", "\n", "\n", "\n", " dried sludge\n", "\n", "\n", "\n", "\n", "\n", "99861589993:c->99860133999:w\n", "\n", "\n", " evaporated\n", "\n", "\n", "\n", "\n", "\n", "99861611164:c->99861589717:w\n", "\n", "\n", "\n", " liquid fertilizer\n", "\n", "\n", "\n", "\n", "\n", "99861611164:c->99860134439:w\n", "\n", "\n", " reuse loss\n", "\n", "\n", "\n", "\n", "\n", "99861611467:e->99868385779:w\n", "\n", "\n", " CH4\n", "\n", "\n", "\n", "\n", "\n", "99861589714:e->99868385819:w\n", "\n", "\n", " N2O\n", "\n", "\n", "\n", "\n", "\n", "99861610747:c->99868384819:w\n", "\n", "\n", " sol N\n", "\n", "\n", "\n", "\n", "\n", "99861610747:c->99868385939:w\n", "\n", "\n", " sol P\n", "\n", "\n", "\n", "\n", "\n", "99861610747:c->99868386099:w\n", "\n", "\n", " sol K\n", "\n", "\n", "\n", "\n", "\n", "99861610747:c->99860134479:w\n", "\n", "\n", " sol non fertilizers\n", "\n", "\n", "\n", "\n", "\n", "99861589717:c->99868385539:w\n", "\n", "\n", " liq N\n", "\n", "\n", "\n", "\n", "\n", "99861589717:c->99868385499:w\n", "\n", "\n", " liq P\n", "\n", "\n", "\n", "\n", "\n", "99861589717:c->99868385859:w\n", "\n", "\n", " liq K\n", "\n", "\n", "\n", "\n", "\n", "99861589717:c->99860133519:w\n", "\n", "\n", " liq non fertilizers\n", "\n", "\n", "\n", "\n", "\n", "99868386019:e->99861616909:c\n", "\n", "\n", " toilet paper\n", "\n", "\n", "\n", "\n", "\n", "99868386059:e->99861616909:c\n", "\n", "\n", " flushing water\n", "\n", "\n", "\n", "\n", "\n", "99868386139:e->99861616909:c\n", "\n", "\n", " cleansing water\n", "\n", "\n", "\n", "\n", "\n", "99868386179:e->99861616909:c\n", "\n", "\n", " desiccant\n", "\n", "\n", "\n", "\n", "\n", "99861589150\n", "\n", "\n", "A1\n", "Excretion\n", "\n", "\n", "\n", "\n", "\n", "99861616909\n", "\n", "\n", "A2\n", "Pit latrine\n", "\n", "\n", "\n", "\n", "\n", "99861643211\n", "\n", "\n", "A3\n", "Trucking\n", "\n", "\n", "\n", "\n", "\n", "99861642281\n", "\n", "\n", "A4\n", "Lumped WWTP cost\n", "\n", "\n", "\n", "\n", "\n", "99861589465\n", "\n", "\n", "A5\n", "Sedimentation\n", "\n", "\n", "\n", "\n", "\n", "99861589342\n", "\n", "\n", "A6\n", "Anaerobic lagoon\n", "\n", "\n", "\n", "\n", "\n", "99861590011\n", "\n", "\n", "A7\n", "Facultative lagoon\n", "\n", "\n", "\n", "\n", "\n", "99861589993\n", "\n", "\n", "A8\n", "Unplanted drying bed\n", "\n", "\n", "\n", "\n", "\n", "99861611164\n", "\n", "\n", "A9\n", "Crop application\n", "\n", "\n", "\n", "\n", "\n", "99861611467\n", "\n", "\n", "A10\n", "fugitive CH4 mixer\n", "\n", "\n", "\n", "\n", "\n", "99861589714\n", "\n", "\n", "A11\n", "fugitive N2O mixer\n", "\n", "\n", "\n", "\n", "\n", "99861610747\n", "\n", "\n", "A12\n", "Component splitter\n", "\n", "\n", "\n", "\n", "\n", "99861589717\n", "\n", "\n", "A13\n", "Component splitter\n", "\n", "\n", "\n", "\n", "\n", "99868385779\n", "\n", "\n", "\n", "\n", "99868385819\n", "\n", "\n", "\n", "\n", "99868384819\n", "\n", "\n", "\n", "\n", "99868385539\n", "\n", "\n", "\n", "\n", "99868386019\n", "\n", "\n", "\n", "\n", "99868386059\n", "\n", "\n", "\n", "\n", "99868386139\n", "\n", "\n", "\n", "\n", "99868386179\n", "\n", "\n", "\n", "\n", "99860132959\n", "\n", "\n", "\n", "\n", "99860133999\n", "\n", "\n", "\n", "\n", "99868385939\n", "\n", "\n", "\n", "\n", "99868385499\n", "\n", "\n", "\n", "\n", "99860133319\n", "\n", "\n", "\n", "\n", "99860134439\n", "\n", "\n", "\n", "\n", "99868386099\n", "\n", "\n", "\n", "\n", "99868385859\n", "\n", "\n", "\n", "\n", "99860134479\n", "\n", "\n", "\n", "\n", "99860133519\n", "\n", "\n", "\n", "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from exposan import bwaise as bw\n", "bw.load()\n", "bw.sysA.diagram()" ] }, { "cell_type": "markdown", "id": "s6-res-md", "metadata": {}, "source": [ "Once simulated, you can read per-unit results:" ] }, { "cell_type": "code", "execution_count": 8, "id": "s6-res", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Pit latrine Units A2\n", "Design Number of users per toilet 16\n", " Parallel toilets 2.85e+04\n", " Emptying period yr 0.8\n", " Single pit volume m3 3.66\n", " Single pit area m2 0.8\n", " Single pit depth m 4.57\n", " Cement kg 2e+07\n", " Sand kg 9.05e+07\n", " Gravel kg 3.65e+07\n", " Brick kg 6.47e+06\n", " Plastic kg 2.88e+05\n", " Steel kg 9.58e+05\n", " Wood m3 5.42e+03\n", " Excavation m3 1.04e+05\n", "Purchase cost Total toilets USD 1.28e+07\n", "Total purchase cost USD 1.28e+07\n", "Utility cost USD/hr 0\n", "Additional OPEX USD/hr 73.1\n" ] } ], "source": [ "print(bw.A2.results())" ] }, { "cell_type": "markdown", "id": "s7-head", "metadata": {}, "source": [ "## 6. Techno-Economic Analysis and Life Cycle Assessment (TEA/LCA) \n", "\n", "A `TEA` runs the techno-economics on a `System`; an `LCA` runs the impact assessment. Both attach to the same `System` and read its simulation results. See the [TEA](https://qsdsan.readthedocs.io/en/latest/tutorials/7_TEA.html) and [LCA](https://qsdsan.readthedocs.io/en/latest/tutorials/8_LCA.html) tutorials for more information." ] }, { "cell_type": "code", "execution_count": 9, "id": "s7-tea", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "For sysA in the Bwaise study:\n", "\n", " - NPV: -42,012,131 USD\n", " - EAC: 6,706,210 USD/yr\n", " - CAPEX: 31,421,918 USD\n", " - AOC: 1,844,554 USD/yr\n", " - sales: 206,017 USD/yr\n", " - net_earnings: -1,638,537 USD/yr\n" ] } ], "source": [ "c = qs.currency\n", "print('For sysA in the Bwaise study:\\n')\n", "for attr in ('NPV', 'EAC', 'CAPEX', 'AOC', 'sales', 'net_earnings'):\n", " uom = c if attr in ('NPV', 'CAPEX') else f'{c}/yr'\n", " print(f' - {attr}: {getattr(bw.teaA, attr):,.0f} {uom}')" ] }, { "cell_type": "markdown", "id": "s7-lca-md", "metadata": {}, "source": [ "The `LCA` object summarizes impacts by category and contributor:" ] }, { "cell_type": "code", "execution_count": 10, "id": "s7-lca", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "LCA: sysA (lifetime 8 yr)\n", "Impacts:\n", " Construction Transportation Stream Others Total\n", "GlobalWarming (kg CO2-eq) 3.13e+07 9.57e+05 1.82e+08 5.19e+04 2.14e+08\n" ] } ], "source": [ "bw.lcaA" ] }, { "cell_type": "markdown", "id": "s8-head", "metadata": {}, "source": [ "## 7. Uncertainty and Sensitivity Analyses \n", "\n", "To perform uncertainty and sensitiviy analysis, a `Model` object is built on a `System` to add uncertain distributions of the input parameters and define output metrics of interest. The `Model` object can be then used to run Monte Carlo (for uncertainty) and sensitivity analyses. See the [Uncertainty and Sensitivity Analyses](https://qsdsan.readthedocs.io/en/latest/tutorials/9_Uncertainty_and_Sensitivity_Analyses.html) for more information." ] }, { "cell_type": "code", "execution_count": 11, "id": "s8-code", "metadata": {}, "outputs": [], "source": [ "bw.modelA # shows the declared uncertainty parameters" ] }, { "cell_type": "markdown", "id": "s8-stats", "metadata": {}, "source": [ "`QSDsan` also includes a [stats](https://qsdsan.readthedocs.io/en/latest/api/statistics.html) module for statistical analysis (e.g., global sensitivity analysis), including and visualization helpers." ] }, { "cell_type": "markdown", "id": "where-next", "metadata": {}, "source": [ "## Where to go next \n", "\n", "The tutorials are organized in three parts. You just finished **Part I**.\n", "\n", "**Part II.** QSDsan's core classes. Each tutorial dives into one or a few of the classes you just saw.\n", "\n", "- [2. Component](https://qsdsan.readthedocs.io/en/latest/tutorials/2_Component.html)\n", "- [3. WasteStream](https://qsdsan.readthedocs.io/en/latest/tutorials/3_WasteStream.html)\n", "- [4. SanUnit (basic)](https://qsdsan.readthedocs.io/en/latest/tutorials/4_SanUnit_basic.html)\n", "- [5. SanUnit (advanced)](https://qsdsan.readthedocs.io/en/latest/tutorials/5_SanUnit_advanced.html)\n", "- [6. System](https://qsdsan.readthedocs.io/en/latest/tutorials/6_System.html)\n", "- [7. TEA](https://qsdsan.readthedocs.io/en/latest/tutorials/7_TEA.html)\n", "- [8. LCA](https://qsdsan.readthedocs.io/en/latest/tutorials/8_LCA.html)\n", "- [9. Uncertainty and Sensitivity Analyses](https://qsdsan.readthedocs.io/en/latest/tutorials/9_Uncertainty_and_Sensitivity_Analyses.html)\n", "- [10. Process](https://qsdsan.readthedocs.io/en/latest/tutorials/10_Process.html)\n", "\n", "**Part III.** Integrating process models. Build dynamic, multi-component models on top of QSDsan.\n", "\n", "- [11. Dynamic Simulation](https://qsdsan.readthedocs.io/en/latest/tutorials/11_Dynamic_Simulation.html)\n", "- [12. ADM1 Case Study](https://qsdsan.readthedocs.io/en/latest/tutorials/12_Anaerobic_Digestion_Model_No_1.html)\n", "- [13. Process Modeling 101](https://qsdsan.readthedocs.io/en/latest/tutorials/13_Process_Modeling_101.html)" ] }, { "cell_type": "markdown", "id": "nav-footer", "metadata": {}, "source": [ "\n", "\n", "---\n", "\n", "↑ Back to top" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }