Skip to content

Commit 6ecbd62

Browse files
committed
fix issue with bioreactor docs
1 parent ba14254 commit 6ecbd62

5 files changed

Lines changed: 122 additions & 76 deletions

File tree

biosteam/_unit.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ class Unit(AbstractUnit):
145145
max_parallel_units = int(10e3)
146146

147147
def __init_subclass__(cls,
148-
isabstract=False,
149-
new_graphics=True,
150-
does_nothing=None,
151-
default_phenomena=None):
148+
isabstract=False,
149+
new_graphics=True,
150+
does_nothing=None,
151+
default_phenomena=None,
152+
):
152153
super().__init_subclass__()
153154
if getattr(cls, 'decoupled', None): print(cls)
154155
if does_nothing: return
@@ -250,6 +251,8 @@ def __init_subclass__(cls,
250251
bst.units.__dict__[name] = cls
251252
if name not in bst.__dict__:
252253
bst.__dict__[name] = cls
254+
if hasattr(cls, '_finalize_doc'):
255+
cls._finalize_doc()
253256

254257
### Abstract Attributes ###
255258
#: **class-attribute** Units of measure for :attr:`~Unit.design_results` dictionary.
@@ -287,7 +290,7 @@ def __init_subclass__(cls,
287290
#: Add itemized purchase costs to the :attr:`~Unit.baseline_purchase_costs` dictionary.
288291
_cost = AbstractMethod
289292

290-
#: Add embodied emissions (e.g., unit construction) in LCA
293+
#: Add embodied emissions (e.g., unit construction) in LCA.
291294
_lca = AbstractMethod
292295

293296
def _collect_variables(self, key):

biosteam/units/abstract_stirred_tank_reactor.py

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99
.. contents:: :local:
1010
11-
.. autoclass:: biosteam.units.stirred_tank_reactor.AbstractStirredTankReactor
11+
.. autoclass:: biosteam.units.abstract_stirred_tank_reactor.AbstractStirredTankReactor
1212
1313
References
1414
----------
@@ -32,50 +32,50 @@
3232
)
3333

3434
description_doc = '''
35-
The reactor is designed as a pressure vessel with a given aspect ratio and
36-
residence time. A pump-heat exchanger recirculation loop can be used to satisfy
37-
the duty, if any. By default, a turbine agitator is also included if the
38-
power usage,`kW_per_m3` , is positive. A vacuum system is also
39-
automatically added if the operating pressure is at a vacuum.
40-
'''
35+
The reactor is designed as a pressure vessel with a given aspect ratio and
36+
residence time. A pump-heat exchanger recirculation loop can be used to satisfy
37+
the duty, if any. By default, a turbine agitator is also included if the
38+
power usage,`kW_per_m3` , is positive. A vacuum system is also
39+
automatically added if the operating pressure is at a vacuum.
40+
'''[1:]
4141

4242
parameters_doc ='''
43-
tau :
44-
Residence time [hr].
45-
T :
46-
Operating temperature [K].
47-
P :
48-
Operating pressure [Pa].
49-
V_wf :
50-
Fraction of working volume over total volume. Defaults to 0.8.
51-
V_max :
52-
Maximum volume of a reactor [m3]. Defaults to 355.
53-
kW_per_m3:
54-
Power usage of agitator. Defaults to 0.985 [kW / m3] converted from
55-
5 hp/1000 gal as in [1]_, for liquid–liquid reaction or extraction.
56-
vessel_material :
57-
Vessel material. Defaults to 'Stainless steel 316'.
58-
vessel_type :
59-
Vessel type. Valid options are 'Horizontal' or 'Vertical'. Defaults to 'Vertical'
60-
batch :
61-
Whether to use batch operation mode. If False, operation mode is continuous.
62-
Defaults to `continuous`.
63-
tau_0 :
64-
Cleaning and unloading time (if batch mode). Defaults to 3 hr.
65-
N_reactors :
66-
Number of reactors.
67-
heat_exchanger_configuration:
68-
What kind of heat exchanger to default to (if any). Valid options include
69-
'jacketed', 'recirculation loop', and 'internal coil'.
70-
Defaults to 'recirculation loop'.
71-
dT_hx_loop :
72-
Maximum change in temperature for the heat exchanger loop. Defaults to 5 K.
73-
jacket_annular_diameter :
74-
Annular diameter of heat exchanger jacket to vessel [m]. Defaults to 0.1 m.
75-
loading_time :
76-
Loading time of batch reactor. If not given, it will assume each vessel is constantly
43+
tau :
44+
Residence time [hr].
45+
T :
46+
Operating temperature [K].
47+
P :
48+
Operating pressure [Pa].
49+
V_wf :
50+
Fraction of working volume over total volume. Defaults to 0.8.
51+
V_max :
52+
Maximum volume of a reactor [m3]. Defaults to 355.
53+
kW_per_m3:
54+
Power usage of agitator. Defaults to 0.985 [kW / m3] converted from
55+
5 hp/1000 gal as in [1]_, for liquid–liquid reaction or extraction.
56+
vessel_material :
57+
Vessel material. Defaults to 'Stainless steel 316'.
58+
vessel_type :
59+
Vessel type. Valid options are 'Horizontal' or 'Vertical'. Defaults to 'Vertical'
60+
batch :
61+
Whether to use batch operation mode. If False, operation mode is continuous.
62+
Defaults to `continuous`.
63+
tau_0 :
64+
Cleaning and unloading time (if batch mode). Defaults to 3 hr.
65+
N_reactors :
66+
Number of reactors.
67+
heat_exchanger_configuration:
68+
What kind of heat exchanger to default to (if any). Valid options include
69+
'jacketed', 'recirculation loop', and 'internal coil'.
70+
Defaults to 'recirculation loop'.
71+
dT_hx_loop :
72+
Maximum change in temperature for the heat exchanger loop. Defaults to 5 K.
73+
jacket_annular_diameter :
74+
Annular diameter of heat exchanger jacket to vessel [m]. Defaults to 0.1 m.
75+
loading_time :
76+
Loading time of batch reactor. If not given, it will assume each vessel is constantly
7777
being filled.
78-
'''
78+
'''[1:]
7979

8080
notes_doc = '''
8181
The heat exchanger configuration can be one of the following:
@@ -105,10 +105,10 @@
105105
with the added assumption that the temperature at the wall is the
106106
operating temperature. This method is still not implemented in BioSTEAM
107107
yet.
108-
'''
108+
'''[1:]
109109

110110
class AbstractStirredTankReactor(PressureVessel, Unit, isabstract=True):
111-
f'''{description_doc}
111+
'''{description_doc}
112112
113113
Parameters
114114
----------
@@ -209,6 +209,14 @@ class AbstractStirredTankReactor(PressureVessel, Unit, isabstract=True):
209209
Utility cost USD/hr 152
210210
211211
'''
212+
@classmethod
213+
def _finalize_doc(cls):
214+
cls.__doc__ = cls.__doc__.format(
215+
description_doc=description_doc,
216+
parameters_doc=parameters_doc,
217+
notes_doc=notes_doc
218+
)
219+
212220
auxiliary_unit_names = (
213221
'heat_exchanger',
214222
'vacuum_system',
@@ -428,7 +436,7 @@ def _design(self, size_only=False):
428436
N = 2
429437
else:
430438
N = ceil(N)
431-
Design.update(size_batch(v_0, tau, tau_0, N, V_wf, loading_time))
439+
Design.update(size_batch(v_0, tau, tau_0, N, V_wf, self.loading_time))
432440
V_reactor = Design['Reactor volume']
433441
else:
434442
V_total = ins_F_vol * self.tau / self.V_wf

biosteam/units/aerated_bioreactor.py

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@
1818
1919
"""
2020
import biosteam as bst
21-
from .abstract_stirred_tank_reactor import (
22-
AbstractStirredTankReactor,
23-
description_doc,
24-
parameters_doc,
25-
notes_doc,
26-
)
21+
from .abstract_stirred_tank_reactor import AbstractStirredTankReactor
2722
from math import pi
2823
import numpy as np
2924
from scipy.constants import g
@@ -38,7 +33,7 @@
3833
)
3934

4035
class AeratedBioreactor(AbstractStirredTankReactor):
41-
f"""
36+
"""
4237
Create an aerated bioreactor which satisfies the oxygen mass tranfer
4338
requirement of the mass balance.
4439
@@ -399,9 +394,54 @@ def _design(self):
399394

400395
class GasFedBioreactor(AbstractStirredTankReactor):
401396
"""
402-
Same as AbstractStirredTankReactor but includes multiple gas feeds. The agitator power may
403-
vary to minimize the total power requirement of both the compressor and agitator
404-
yet achieve the required oxygen transfer rate.
397+
Create an gas-fed bioreactor which satisfies the substrate mass tranfer
398+
requirement of the mass balance. The gas-fed bioreactor may include
399+
multiple gas feeds. The user-specified `titer` will be satisfied by varying
400+
the flow rates of the `variable_gas_feeds` so long as the
401+
`backward_reactions` are specified. Otherwise, the titer will be estimated
402+
assuming constant gas flow rates.
403+
404+
{description_doc}
405+
406+
Parameters
407+
----------
408+
gas_substrates :
409+
Substrates within the gas phase.
410+
titer :
411+
Dictionary of substrate/titer pairs [g / L].
412+
backward_reactions :
413+
Backwards reactions to get the substrate mass transfer requirement.
414+
variable_gas_feeds :
415+
Feeds that can be varied to meet mass transfer requirement.
416+
theta :
417+
Fraction of gas substrate saturation in the broth. Defaults to 0.5.
418+
Q_consumption :
419+
Forced duty per gas substrate consummed [kJ/kmol].
420+
optimize_power :
421+
If true, the agitator power is solved to minimize the total power
422+
requirement of both the compressor and agitator such that the
423+
required oxygen transfer rate is met.
424+
design :
425+
Bioreactor design configuration. Valid options include 'Stirred tank'
426+
and 'Bubble column'. Defaults to the former.
427+
method :
428+
Method to calculate the overall mass transfer coefficient, kLa.
429+
Can be a name or a function. Valid method names are listed in
430+
`biosteam.aeration.kLa_methods`.
431+
For stirred tanks, defaults to the 'Riet'.
432+
For bubble columns, defaults to 'Dewes'.
433+
kLa_kwargs:
434+
Additional arguments to pass to the kLa method.
435+
cooler_pressure_drop :
436+
Pressure drop at the cooler [Pa]. Defaults to 20684.28 Pa,
437+
a heuristic value for a gas.
438+
compressor_isentropic_efficiency :
439+
Isentropic efficiency of the compressor. Defaults to 0.85.
440+
{parameters_doc}
441+
442+
Notes
443+
-----
444+
{notes_doc}
405445
406446
Examples
407447
--------
@@ -417,7 +457,7 @@ class GasFedBioreactor(AbstractStirredTankReactor):
417457
... 'R1', ins=[media, H2, fluegas], outs=('vent', 'product'), tau=68, V_max=500,
418458
... reactions=rxn, backward_reactions=brxn,
419459
... gas_substrates=('H2', 'CO2'),
420-
... titer={'AceticAcid': 5},
460+
... titer=dict(AceticAcid=5),
421461
... optimize_power=False,
422462
... kW_per_m3=0.,
423463
... )
@@ -479,10 +519,14 @@ def _init(self,
479519
design=None, method=None, kLa_kwargs=None,
480520
theta=0.5, Q_consumption=None,
481521
cooler_pressure_drop=None,
522+
compressor_isentropic_efficiency=None,
482523
# Only for agitated bioreactors (not bubble column)
483524
optimize_power=None,
484525
**kwargs,
485526
):
527+
if compressor_isentropic_efficiency is None: compressor_isentropic_efficiency = 0.85
528+
#: Isentropic efficiency of the compressor. Defaults to 0.85.
529+
self.compressor_isentropic_efficiency = compressor_isentropic_efficiency
486530
self.cooler_pressure_drop = 20684.28 if cooler_pressure_drop is None else cooler_pressure_drop
487531
self.reactions = reactions
488532
self.backward_reactions = backward_reactions
@@ -562,7 +606,8 @@ def load_auxiliaries(self):
562606
for inlet in self.ins:
563607
if inlet.phase != 'g': continue
564608
compressor = self.auxiliary(
565-
'compressors', bst.IsentropicCompressor, inlet, eta=0.85, P=2 * 101325
609+
'compressors', bst.IsentropicCompressor, inlet,
610+
eta=self.compressor_isentropic_efficiency, P=2 * 101325
566611
)
567612
self.auxiliary(
568613
'gas_coolers', bst.HXutility, compressor-0, T=self.T

biosteam/units/anaerobic_bioreactor.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,14 @@
1717
& Ng, M. K. (2017). Product and Process Design Principles. Wiley.
1818
1919
"""
20-
from .abstract_stirred_tank_reactor import (
21-
AbstractStirredTankReactor,
22-
description_doc,
23-
parameters_doc,
24-
notes_doc,
25-
)
20+
from .abstract_stirred_tank_reactor import AbstractStirredTankReactor
2621

2722
__all__ = (
2823
'AnaerobicBioreactor', 'AnBR',
2924
)
3025

3126
class AnaerobicBioreactor(AbstractStirredTankReactor):
32-
f"""
27+
"""
3328
Create an anaerobic bioreactor with a vented stream and an effluent stream .
3429
3530
{description_doc}

biosteam/units/single_phase_reactor.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,14 @@
1616
Ng, M. K. Product and Process Design Principles. Wiley 2017.
1717
1818
"""
19-
from .abstract_stirred_tank_reactor import (
20-
AbstractStirredTankReactor,
21-
description_doc,
22-
parameters_doc,
23-
notes_doc,
24-
)
19+
from .abstract_stirred_tank_reactor import AbstractStirredTankReactor
2520

2621
__all__ = (
2722
'SinglePhaseReactor',
2823
)
2924

3025
class SinglePhaseReactor(AbstractStirredTankReactor):
31-
f'''
26+
'''
3227
Create a stirred tank reactor which assumes a single outlet stream with
3328
no phase equilibrium.
3429

0 commit comments

Comments
 (0)