Skip to content

Commit

Permalink
Merge pull request #50 from QSD-Group/saf
Browse files Browse the repository at this point in the history
Merge in SAF unit
  • Loading branch information
yalinli2 authored Dec 6, 2024
2 parents 93d4173 + 55059e7 commit bae4387
Show file tree
Hide file tree
Showing 33 changed files with 9,324 additions and 50 deletions.
10 changes: 10 additions & 0 deletions exposan/biobinder/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
=============================================================================
biobinder: Renewable Biobinder from Hydrothermal Conversion of Organic Wastes
=============================================================================

NOT READY FOR USE
-----------------

Summary
-------
This module includes a hydrothermal liquefaction (HTL)-based system for the production of biobinders and valuable coproducts (biobased fuel additives and fertilizers) from wet organic wastes (food waste and swine manure) based on a project funded by `USDA <https://cris.nifa.usda.gov/cgi-bin/starfinder/0?path=fastlink1.txt&id=anon&pass=&search=R=98256&format=WEBLINK>`_.
76 changes: 76 additions & 0 deletions exposan/biobinder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
EXPOsan: Exposition of sanitation and resource recovery systems
This module is developed by:
Yalin Li <mailto.yalin.li@gmail.com>
This module is under the University of Illinois/NCSA Open Source License.
Please refer to https://github.com/QSD-Group/EXPOsan/blob/main/LICENSE.txt
for license details.
'''

import os, qsdsan as qs
from exposan.utils import _init_modules

biobinder_path = os.path.dirname(__file__)
module = os.path.split(biobinder_path)[-1]
data_path, results_path = _init_modules(module, include_data_path=True)


# %%

# =============================================================================
# Load components and systems
# =============================================================================

from . import _components
from ._components import *
_components_loaded = False
def _load_components(reload=False):
global components, _components_loaded
if not _components_loaded or reload:
components = create_components()
qs.set_thermo(components)
_components_loaded = True

from . import _process_settings
from ._process_settings import *

from . import _units
from ._units import *

from . import systems
from .systems import *

_system_loaded = False
def load():
global sys, tea, lca, flowsheet, _system_loaded
sys = create_system()
tea = sys.TEA
lca = sys.LCA
flowsheet = sys.flowsheet
_system_loaded = True
dct = globals()
dct.update(sys.flowsheet.to_dict())

def __getattr__(name):
if not _components_loaded or not _system_loaded:
raise AttributeError(
f'Module {__name__} does not have the attribute "{name}" '
'and the module has not been loaded, '
f'loading the module with `{__name__}.load()` may solve the issue.')



__all__ = (
'biobinder_path',
'data_path',
'results_path',
*_components.__all__,
*_process_settings.__all__,
*_units.__all__,
*systems.__all__,
)
38 changes: 38 additions & 0 deletions exposan/biobinder/_components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
EXPOsan: Exposition of sanitation and resource recovery systems
This module is developed by:
Yalin Li <mailto.yalin.li@gmail.com>
This module is under the University of Illinois/NCSA Open Source License.
Please refer to https://github.com/QSD-Group/EXPOsan/blob/main/LICENSE.txt
for license details.
'''

from qsdsan import Components, set_thermo as qs_set_thermo
from exposan.saf import create_components as create_saf_components

__all__ = ('create_components',)

def create_components(set_thermo=True):
saf_cmps = create_saf_components(set_thermo=False)
biobinder_cmps = Components([i for i in saf_cmps])

biobinder_cmps.compile()
biobinder_cmps.set_alias('H2O', 'Water')
biobinder_cmps.set_alias('H2O', '7732-18-5')
biobinder_cmps.set_alias('Carbohydrates', 'Carbs')
biobinder_cmps.set_alias('C', 'Carbon')
biobinder_cmps.set_alias('N', 'Nitrogen')
biobinder_cmps.set_alias('P', 'Phosphorus')
biobinder_cmps.set_alias('K', 'Potassium')
biobinder_cmps.set_alias('C16H34', 'Biofuel') # Tb = 559 K
biobinder_cmps.set_alias('TRICOSANE', 'Biobinder') # Tb = 654 K

if set_thermo: qs_set_thermo(biobinder_cmps)

return biobinder_cmps
47 changes: 47 additions & 0 deletions exposan/biobinder/_process_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
EXPOsan: Exposition of sanitation and resource recovery systems
This module is developed by:
Yalin Li <mailto.yalin.li@gmail.com>
Ali Ahmad <aa3056@scarletmail.rutgers.edu>
This module is under the University of Illinois/NCSA Open Source License.
Please refer to https://github.com/QSD-Group/EXPOsan/blob/main/LICENSE.txt
for license details.
'''

from exposan.saf import _process_settings
from exposan.saf._process_settings import *

__all__ = [i for i in _process_settings.__all__ if i is not 'dry_flowrate']
__all__.extend(['central_dry_flowrate', 'pilot_dry_flowrate'])

moisture = 0.7566
ash = (1-moisture)*0.0571
feedstock_composition = {
'Water': moisture,
'Lipids': (1-moisture)*0.6245,
'Proteins': (1-moisture)*0.0238,
'Carbohydrates': (1-moisture)*0.2946,
'Ash': ash,
}

central_dry_flowrate = dry_flowrate # 110 tpd converted to kg/hr
pilot_dry_flowrate = 11.46 # kg/hr

# Salad dressing waste
HTL_yields = {
'gas': 0.1756,
'aqueous': 0.2925,
'biocrude': 0.5219,
'char': 1-0.1756-0.2925-0.5219,
}

# https://idot.illinois.gov/doing-business/procurements/construction-services/transportation-bulletin/price-indices.html
# bitumnous, IL
price_dct['biobinder'] = 0.67
171 changes: 171 additions & 0 deletions exposan/biobinder/_to_be_removed/_components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
EXPOsan: Exposition of sanitation and resource recovery systems
This module is developed by:
Yalin Li <mailto.yalin.li@gmail.com>
This module is under the University of Illinois/NCSA Open Source License.
Please refer to https://github.com/QSD-Group/EXPOsan/blob/main/LICENSE.txt
for license details.
'''

from qsdsan import Component, Components, set_thermo as qs_set_thermo
# from exposan.utils import add_V_from_rho
from exposan.saf import create_components as create_saf_components

__all__ = ('create_components',)


# def estimate_heating_values(component):
# '''
# Estimate the HHV of a component based on the Dulong's equation (MJ/kg):

# HHV [kJ/g] = 33.87*C + 122.3*(H-O/8) + 9.4*S

# where C, H, O, and S are the wt% of these elements.

# Estimate the LHV based on the HHV as:

# LHV [kJ/g] = HHV [kJ/g] – 2.51*(W + 9H)/100

# where W and H are the wt% of moisture and H in the fuel

# References
# ----------
# [1] https://en.wikipedia.org/wiki/Heat_of_combustion
# [2] https://www.sciencedirect.com/science/article/abs/pii/B9780128203606000072

# '''
# atoms = component.atoms
# MW = component.MW
# HHV = (33.87*atoms.get('C', 0)*12 +
# 122.3*(atoms.get('H', 0)-atoms.get('O', 0)/8) +
# 9.4*atoms.get('S', 0)*32
# )/MW
# LHV = HHV - 2.51*(9*atoms.get('H', 0)/MW)

# return HHV*MW*1000, LHV*MW*1000

def create_components(set_thermo=True):
saf_cmps = create_saf_components(set_thermo=False)
biobinder_cmps = Components([i for i in saf_cmps])

# htl_cmps = htl.create_components()

# # Components in the feedstock
# Lipids = htl_cmps.Sludge_lipid.copy('Lipids')
# Proteins = htl_cmps.Sludge_protein.copy('Proteins')
# Carbohydrates = htl_cmps.Sludge_carbo.copy('Carbohydrates')
# Ash = htl_cmps.Sludge_ash.copy('Ash')

# # Generic components for HTL products
# Biocrude = htl_cmps.Biocrude
# HTLaqueous = htl_cmps.HTLaqueous
# Hydrochar = htl_cmps.Hydrochar

# # Components in the biocrude
# org_kwargs = {
# 'particle_size': 'Soluble',
# 'degradability': 'Slowly',
# 'organic': True,
# }
# biocrude_dct = { # ID, search_ID (CAS#)
# '1E2PYDIN': '2687-91-4',
# # 'C5H9NS': '10441-57-3',
# 'ETHYLBEN': '100-41-4',
# '4M-PHYNO': '106-44-5',
# '4EPHYNOL': '123-07-9',
# 'INDOLE': '120-72-9',
# '7MINDOLE': '933-67-5',
# 'C14AMIDE': '638-58-4',
# 'C16AMIDE': '629-54-9',
# 'C18AMIDE': '124-26-5',
# 'C16:1FA': '373-49-9',
# 'C16:0FA': '57-10-3',
# 'C18FACID': '112-80-1',
# 'NAPHATH': '91-20-3',
# 'CHOLESOL': '57-88-5',
# 'AROAMINE': '74-31-7',
# 'C30DICAD': '3648-20-2',
# }
# biocrude_cmps = {}
# for ID, search_ID in biocrude_dct.items():
# cmp = Component(ID, search_ID=search_ID, **org_kwargs)
# if not cmp.HHV or not cmp.LHV:
# HHV, LHV = estimate_heating_values(cmp)
# cmp.HHV = cmp.HHV or HHV
# cmp.LHV = cmp.LHV or LHV
# biocrude_cmps[ID] = cmp

# # # Add missing properties
# # # http://www.chemspider.com/Chemical-Structure.500313.html?rid=d566de1c-676d-4064-a8c8-2fb172b244c9
# # C5H9NS = biocrude_cmps['C5H9NS']
# # C5H9NO = Component('C5H9NO')
# # C5H9NS.V.l.add_method(C5H9NO.V.l)
# # C5H9NS.copy_models_from(C5H9NO) #!!! add V.l.
# # C5H9NS.Tb = 273.15+(151.6+227.18)/2 # avg of ACD and EPIsuite
# # C5H9NS.Hvap.add_method(38.8e3) # Enthalpy of Vaporization, 38.8±3.0 kJ/mol
# # C5H9NS.Psat.add_method((3.6+0.0759)/2*133.322) # Vapour Pressure, 3.6±0.3/0.0756 mmHg at 25°C, ACD/EPIsuite
# # C5H9NS.Hf = -265.73e3 # C5H9NO, https://webbook.nist.gov/cgi/cbook.cgi?ID=C872504&Mask=2

# # Rough assumption based on the formula
# biocrude_cmps['7MINDOLE'].Hf = biocrude_cmps['INDOLE'].Hf
# biocrude_cmps['C30DICAD'].Hf = biocrude_cmps['CHOLESOL'].Hf

# # Components in the aqueous product
# H2O = htl_cmps.H2O
# C = Component('C', search_ID='Carbon', particle_size='Soluble',
# degradability='Undegradable', organic=False)
# N = Component('N', search_ID='Nitrogen', particle_size='Soluble',
# degradability='Undegradable', organic=False)
# NH3 = htl_cmps.NH3
# P = Component('P', search_ID='Phosphorus', particle_size='Soluble',
# degradability='Undegradable', organic=False)
# for i in (C, N, P): i.at_state('l')

# # Components in the gas product
# CO2 = htl_cmps.CO2
# CH4 = htl_cmps.CH4
# C2H6 = htl_cmps.C2H6
# O2 = htl_cmps.O2
# N2 = htl_cmps.N2

# # Other needed components
# Biofuel = htl_cmps.C16H34.copy('Biofuel') # Tb = 559 K
# Biobinder = htl_cmps.TRICOSANE.copy('Biobinder') # Tb = 654 K

# # Compile components
# biobinder_cmps = Components([
# Lipids, Proteins, Carbohydrates, Ash,
# Biocrude, HTLaqueous, Hydrochar,
# *biocrude_cmps.values(),
# H2O, C, N, NH3, P,
# CO2, CH4, C2H6, O2, N2,
# Biofuel, Biobinder,
# ])

# for i in biobinder_cmps:
# for attr in ('HHV', 'LHV', 'Hf'):
# if getattr(i, attr) is None: setattr(i, attr, 0)
# i.default() # default properties to those of water

biobinder_cmps.compile()
biobinder_cmps.set_alias('H2O', 'Water')
biobinder_cmps.set_alias('H2O', '7732-18-5')
biobinder_cmps.set_alias('Carbohydrates', 'Carbs')
biobinder_cmps.set_alias('C', 'Carbon')
biobinder_cmps.set_alias('N', 'Nitrogen')
biobinder_cmps.set_alias('P', 'Phosphorus')
biobinder_cmps.set_alias('K', 'Potassium')
biobinder_cmps.set_alias('C16H34', 'Biofuel') # Tb = 559 K
biobinder_cmps.set_alias('TRICOSANE', 'Biobinder') # Tb = 654 K
# Biofuel = biobinder_cmps.C16H34.copy('Biofuel') # Tb = 559 K
# Biobinder = saf_cmps.TRICOSANE.copy('Biobinder') # Tb = 654 K

if set_thermo: qs_set_thermo(biobinder_cmps)

return biobinder_cmps
Loading

0 comments on commit bae4387

Please sign in to comment.