Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/QSD-Group/QSDsan into trial
Browse files Browse the repository at this point in the history
  • Loading branch information
yalinli2 committed Dec 10, 2024
2 parents ceca243 + af5acab commit 90c4f67
Show file tree
Hide file tree
Showing 71 changed files with 11,984 additions and 2,053 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will install Python dependencies, run tests with a variety of Python versions, and report coverage

name: build-dev

on:
push:
branches: [dev]
pull_request:
branches: [dev]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# os: [ubuntu-latest, macos-latest, windows-latest] if want multiple os
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest nbval
pip install --no-cache-dir git+https://github.com/BioSTEAMDevelopmentGroup/thermosteam.git@qsdsan
pip install --no-cache-dir git+https://github.com/BioSTEAMDevelopmentGroup/biosteam.git@qsdsan
pip install --no-cache-dir git+https://github.com/QSD-Group/EXPOsan.git@bsm2
pip install --no-cache-dir -r requirements.txt
- name: Test with pytest
run: |
pytest
27 changes: 27 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ Change Log
This document records notable changes to `QSDsan <https://github.com/QSD-Group/QSDsan>`_. We aim to follow `Semantic Versioning <https://semver.org/>`_.


`1.4.0`_
--------
- A lot of the updates have been focused on the dynamic simulation, now the open-loop Benchmark Simulation Model No. 2 (`BSM2 <https://github.com/QSD-Group/EXPOsan/tree/main/exposan/bsm2>`_) configuration has been implemented with new process models and unit operation including

- :class:`qsdsan.processes.ADM1p`
- :class:`qsdsan.processes.ADM1_p_extension`
- :class:`qsdsan.processes.ModifiedADM1`
- :class:`qsdsan.processes.mASM2d`
- :class:`qsdsan.sanunits.IdealClarifier`
- :class:`qsdsan.sanunits.PrimaryClarifier`
- :class:`qsdsan.sanunits.PrimaryClarifierBSM2`
- :class:`qsdsan.sanunits.GasExtractionMembrane`
- :class:`qsdsan.sanunits.Thickener`
- :class:`qsdsan.sanunits.Centrifuge`
- :class:`qsdsan.sanunits.Incinerator`
- :class:`qsdsan.sanunits.BatchExperiment`
- :class:`qsdsan.sanunits.PFR`
- :class:`qsdsan.sanunits.BeltThickener`
- :class:`qsdsan.sanunits.SludgeCentrifuge`
- :class:`qsdsan.sanunits.SludgeThickener`

- New publications

- Feng et al., *Environmental Science & Technology*, on the sustainability of `hydrothermal liquefaction (HTL) <https://doi.org/10.1021/acs.est.3c07394>`_ for resource recovery from a range of wet organic wastes.


`1.3.0`_
--------
- Enhance and use QSDsan's capacity for dynamic simulation for emerging technologies and benchmark configurations (see EXPOsan METAB and PM2 (on the algae branch, still under development) modules).
Expand Down Expand Up @@ -185,6 +211,7 @@ Official release of ``QSDsan`` v1.0.0!
.. _Trimmer et al.: https://doi.org/10.1021/acs.est.0c03296

.. Commit links
.. _1.4.0: https://github.com/QSD-Group/QSDsan/releases/tag/v1.4.0
.. _1.3.0: https://github.com/QSD-Group/QSDsan/releases/tag/v1.3.0
.. _1.2.0: https://github.com/QSD-Group/QSDsan/releases/tag/v1.2.0
.. _1.1.0: https://github.com/QSD-Group/QSDsan/releases/tag/v1.1.0
Expand Down
20 changes: 20 additions & 0 deletions docs/source/FAQ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ There are multiple possible reasons:
Then when you open the Jupyter Notebook, select the ``<KERNEL NAME>`` kernel when you create a new notebook you can find more details in this post about `enabling multiple kernels in Jupyter Notebook <https://medium.com/@ace139/enable-multiple-kernels-in-jupyter-notebooks-6098c738fe72>`_.


``underlying object has vanished``
**********************************
This error is related to ``numba`` caching, we haven't figured out the exact mechanism, but clearing cache will help resolve it. One/both of the following approaches should work:

1. Clear cache. Remove all ``.pyc``, ``.nbc``, and ``.nbi`` files, you can do this in your CLI using (replace <DIR> with the directory to your ``thermosteam``, ``biosteam``, ``qsdsan``, and ``exposan`` directory):

.. code::
get-childitem . -recurse -include *.pyc, *.nbc, *.nbi | remove-item
2. Uninstalling and reinstalling a different version of ``numba``. Suppose you now have 0.58.1 and the newest version is 0.60.0, you can do:

.. code::
pip uninstall numba
pip install --no-cache-dir numba==0.60.0
The ``--no-cache-dir`` option is to do a fresh installation rather than using previously downloaded packages. Note that you need to exit out your editor/any other programs that are currently using numba. Otherwise the uninstallation is incomplete, you might be prompted to do a manual removal, or this won't work.


``UnicodeDecodeError``
**********************
When using non-English operating systems, you may run into errors similar to (cp949 is the case of Korean Windows):
Expand Down
2 changes: 1 addition & 1 deletion docs/source/Systems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ A variety of other sanitation and resource recovery systems have been developed

#. Modular encapsulated two-stage anaerobic biological (METAB) system

* Manuscript: Zhang et al., Sustainable design of a modular anaerobic system for distributed energy recovery from industrial wastewaters, In Prep.
* Publication: `Zhang <https://doi.org/10.1021/acs.est.4c05389>`_ et al., 2024.
* `metab EXPOsan module <https://github.com/QSD-Group/EXPOsan/tree/main/exposan/metab>`_

#. EcoRecover system: microalgae-based tertiary P recovery process
Expand Down
7 changes: 7 additions & 0 deletions docs/source/api/processes/ADM1p.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Anaerobic Digestion Model No.1 with P extension (ADM1 P/Extension)
==================================================================
.. autoclass:: qsdsan.processes.ADM1_p_extension
:members:

.. autoclass:: qsdsan.processes.ADM1p
:members:
3 changes: 3 additions & 0 deletions docs/source/api/processes/ASM2d.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Activated Sludge Model No.2d (ASM2d)
====================================
.. autoclass:: qsdsan.processes.ASM2d
:members:

.. autoclass:: qsdsan.processes.mASM2d
:members:
14 changes: 12 additions & 2 deletions docs/source/api/processes/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ List of Biological Kinetic Models
| ADM1 | `adm`_ | `Batstone`_ et al., 2002 |
| | | `Rosen and Jeppsson`_, 2006 |
+----------+------------------+-----------------------------+
| ADM1p | `bsm2`_ | `Alex`_ et al., 2008 |
+----------+------------------+-----------------------------+
| mADM1 | | |
+----------+------------------+-----------------------------+
| ASM1 | `asm`_ & `bsm1`_ | `Henze`_ et al., 2006 |
+----------+------------------+-----------------------------+
| ASM2d | `asm`_ & `bsm1`_ | `Henze`_ et al., 2006 |
+----------+------------------+-----------------------------+
| PM2 | `pm2_ecorecover`_| N/A |
| | & `pm2_batch`_ | |
| mASM2d | `bsm2`_ | `Alex`_ et al., 2008 |
+----------+------------------+-----------------------------+
| PM2 | `pm2_ecorecover`_| |
| | & `pm2_batch`_ | |
+----------+------------------+-----------------------------+


Expand All @@ -41,10 +47,12 @@ List of Other Kinetic Modules
.. _adm: https://github.com/QSD-Group/EXPOsan/tree/main/exposan/adm
.. _asm: https://github.com/QSD-Group/EXPOsan/tree/main/exposan/asm
.. _bsm1: https://github.com/QSD-Group/EXPOsan/tree/main/exposan/bsm1
.. _bsm2: https://github.com/QSD-Group/EXPOsan/tree/main/exposan/bsm2
.. _bwaise: https://github.com/QSD-Group/EXPOsan/tree/main/exposan/bwaise
.. _pm2_batch: https://github.com/QSD-Group/EXPOsan/tree/main/exposan/pm2_batch
.. _pm2_ecorecover: https://github.com/QSD-Group/EXPOsan/tree/main/exposan/pm2_ecorecover

.. _Alex: http://iwa-mia.org/wp-content/uploads/2022/09/TR3_BSM_TG_Tech_Report_no_3_BSM2_General_Description.pdf
.. _Batstone: https://iwaponline.com/ebooks/book/152/Anaerobic-Digestion-Model-No-1-ADM1
.. _EPA design manual: https://nepis.epa.gov/Exe/ZyPURL.cgi?Dockey=3000464S.TXT
.. _Henze: https://iwaponline.com/ebooks/book/96/
Expand All @@ -59,9 +67,11 @@ Links to docs
:maxdepth: 1

ADM1
ADM1p
Aeration
ASM1
ASM2d
Decay
KineticReaction
mADM1
PM2
4 changes: 4 additions & 0 deletions docs/source/api/processes/mADM1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Modified Anaerobic Digestion Model No.1 (MADM1)
===============================================
.. autoclass:: qsdsan.processes.ModifiedADM1
:members:
4 changes: 4 additions & 0 deletions docs/source/api/sanunits/MembraneGasExtraction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Membrane Gas Extraction
=======================
.. automodule:: qsdsan.sanunits._membrane_gas_extraction
:members:
3 changes: 3 additions & 0 deletions docs/source/api/sanunits/_index.csv
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ Lagoon,No,No,Completed
LiquidTreatmentBed,No,No,Completed
LumpedCost,No,No,Completed
MembraneDistillation,No,No,Completed
MembraneGasExtraction,No,No,Completed
MixTank,No,No,Completed
Mixer,Yes,Yes,Completed
MURT (multi-unit reinvented toilet),No,No,Completed
PFR (plug flow reactor),Yes,No,Under development
PhaseChanger,No,Yes,Completed
PitLatrine,No,No,Completed
PolishingFilter,No,No,Completed
PrimaryClarifier,Yes,No,Completed
Pump,Yes,No,Completed
Reactor,No,No,Completed
ReversedSplitter,No,Yes,Completed
Expand Down
5 changes: 4 additions & 1 deletion docs/source/api/sanunits/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Individual Unit Operations
DynamicInfluent
ElectrochemicalCell
Excretion
facilities
Flash
heat_exchanging
hydroprocessing
Expand All @@ -48,15 +49,17 @@ Individual Unit Operations
Lagoon
membrane_bioreactor
MembraneDistillation
MembraneGasExtraction
non_reactive
PolishingFilter
pumping
Reactor
Screening
Sedimentation
SepticTank
sludge_thickening
SludgePasteurization
sludge_thickening
sludge_treatment
suspended_growth_bioreactor
tank
toilet
Expand Down
4 changes: 4 additions & 0 deletions docs/source/api/sanunits/facilities.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Distillation
============
.. automodule:: qsdsan.sanunits._facilities
:members:
4 changes: 4 additions & 0 deletions docs/source/api/sanunits/sludge_treatment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Sludge Treatment
================
.. automodule:: qsdsan.sanunits._sludge_treatment
:members:
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# built documents.
#
# The short X.Y version.
version = '1.3.1'
version = '1.4.1'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
2 changes: 1 addition & 1 deletion qsdsan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
Flowsheet = _bst.Flowsheet
main_flowsheet = _bst.main_flowsheet
default_utilities = _bst.default_utilities
CEPCI_by_year = _bst.units.design_tools.CEPCI_by_year

# Global variables
currency = 'USD'
Expand All @@ -54,6 +53,7 @@


from . import utils
CEPCI_by_year = utils.indices.tea_indices['CEPCI']
from ._component import *
from ._components import *
from ._sanstream import *
Expand Down
2 changes: 2 additions & 0 deletions qsdsan/_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ def i_NOD(self, i):
if i == None:
if self.degradability in ('Readily', 'Slowly') or self.formula in ('H3N', 'NH4', 'NH3', 'NH4+', 'H4N+'):
i = self.i_N * molecular_weight({'O':4}) / molecular_weight({'N':1})
elif self.formula == 'N2':
i = self.i_N * molecular_weight({'O':5}) / molecular_weight({'N':2})
elif self.formula in ('NO2-', 'HNO2'):
i = self.i_N * molecular_weight({'O':1}) / molecular_weight({'N':1})
else:
Expand Down
8 changes: 5 additions & 3 deletions qsdsan/_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def extend(self, components):
def compile(self, skip_checks=False):
'''Cast as a :class:`CompiledComponents` object.'''
components = tuple(self)
tmo._chemicals.prepare(components, skip_checks)
setattr(self, '__class__', CompiledComponents)
try: self._compile(components, skip_checks)

try: self._compile(components)
except Exception as error:
setattr(self, '__class__', Components)
setattr(self, '__dict__', {i.ID: i for i in components})
Expand Down Expand Up @@ -614,11 +616,11 @@ def compile(self, skip_checks=False):
pass


def _compile(self, components, skip_checks=False):
def _compile(self, components):
dct = self.__dict__
tuple_ = tuple # this speeds up the code
components = tuple_(dct.values())
CompiledChemicals._compile(self, components, skip_checks)
CompiledChemicals._compile(self, components)
for component in components:
missing_properties = component.get_missing_properties(_key_component_properties)
if not missing_properties: continue
Expand Down
2 changes: 1 addition & 1 deletion qsdsan/_impact_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def linked_stream(self, new_s):
f'is replaced with {self.ID}.')
else:
warn(f'The original `StreamImpactItem` linked to stream {new_s.ID} '
f'is replaced with upon the creation of a new stream.')
f'is replaced upon the creation of a new stream.')
new_s._stream_impact_item = self
self._linked_stream = new_s

Expand Down
Loading

0 comments on commit 90c4f67

Please sign in to comment.