def add_V_from_rho(component, rho, rho_unit='kg/m3'): ''' Add a constant molar volume model to the component with the given rho. Parameters ---------- component : obj The component for which the molar volume model will be added. rho : float The density of the component. rho_unit : str Unit of the density rho. Examples -------- >>> from qsdsan import Component >>> from qsdsan.utils import add_V_from_rho >>> P4O10 = Component('P4O10', phase='s', organic=False, ... particle_size='Particulate', degradability='Undegradable') >>> add_V_from_rho(P4O10, 2.39, rho_unit='g/mL') # http://www.chemspider.com/Chemical-Structure.14128.html >>> P4O10.V VolumeSolid(CASRN="16752-60-6 (P4O10)", MW=283.889048, extrapolation="linear", method="USER_METHOD") >>> P4O10.V(330) # doctest: +ELLIPSIS 0.0001187... ''' rho = auom(rho_unit).convert(rho, 'kg/m3') V_model = rho_to_V(rho, component.MW) try: component.V.add_model(V_model) except AttributeError: handle = getattr(component.V, component.locked_state) handle.add_model(V_model)
def set_rho(single_phase_chemical, rho): V = fn.rho_to_V(rho, single_phase_chemical.MW) single_phase_chemical.V.add_model(V, top_priority=True)
Solids = create_new_chemical('Solids', MW=1.) DryYeast = create_new_chemical('DryYeast', MW=1., CAS='Yeast') CaO = create_new_chemical('CaO', formula='CaO') # %% Fill missing properties # Insolubles occupy a significant volume insoluble_solids = (Ash, Cellulose, Hemicellulose, Flocculant, Lignin, Solids, DryYeast, P4O10) # Solubles don't occupy much volume soluble_solids = (CaO, H3PO4, Glucose, Sucrose) for chemical in insoluble_solids: V = fn.rho_to_V(rho=1540, MW=chemical.MW) chemical.V.add_model(V, top_priority=True) for chemical in soluble_solids: V = fn.rho_to_V(rho=1e5, MW=chemical.MW) chemical.V.add_model(V, top_priority=True) # Add constant models for molar heat capacity of solids Ash.Cn.add_model(0.09 * 4.184 * Ash.MW) CaO.Cn.add_model(1.02388 * CaO.MW) Cellulose.Cn.add_model(1.364 * Cellulose.MW) Hemicellulose.Cn.add_model(1.364 * Hemicellulose.MW) Flocculant.Cn.add_model(4.184 * Flocculant.MW) Lignin.Cn.add_model(1.364 * Lignin.MW) Solids.Cn.add_model(1.100 * Solids.MW)
Lipid.Dortmund.set_group_counts_by_name({ 'CH3': 3, 'CH2': 41, 'CH': 1, 'CH=CH': 3, 'CH2COO': 3 }) # %% Fill missing properties # Assume properties are similar for trioleate and tripalmitin Tripalmitin = tmo.Chemical('Tripalmitin').at_state(phase='l', copy=True) Lipid.copy_models_from(Tripalmitin, ['V', 'sigma', 'kappa', 'Cn']) # Assume a constant volume for lipid lipid_molar_volume = fn.rho_to_V(rho=900, MW=Lipid.MW) Lipid.V.add_model(lipid_molar_volume) # Insolubles occupy a significant volume insoluble_solids = (Ash, Cellulose, Hemicellulose, Flocculant, Lignin, Solids, DryYeast, P4O10) # Solubles don't occupy much volume soluble_solids = (CaO, HCl, NaOH, H3PO4, Glucose, Sucrose) for chemical in insoluble_solids: V = fn.rho_to_V(rho=1540, MW=chemical.MW) chemical.V.add_model(V, top_priority=True) for chemical in soluble_solids: V = fn.rho_to_V(rho=1e5, MW=chemical.MW)
def add_V_from_rho(cmp, rho): V_model = rho_to_V(rho, cmp.MW) try: cmp.V.add_model(V_model) except: handle = getattr(cmp.V, cmp.locked_state) handle.add_model(V_model)
def create_chemicals(): ### Define common chemicals ### Biodiesel = tmo.Chemical('Biodiesel', search_ID='Methyl oleate') lipidcane_chemicals = tmo.Chemicals([ 'Water', 'Methanol', 'Ethanol', 'Glycerol', 'Glucose', 'Sucrose', 'H3PO4', 'P4O10', 'CO2', 'Octane', 'O2', Biodiesel, 'CH4' ]) (Water, Methanol, Ethanol, Glycerol, Glucose, Sucrose, H3PO4, P4O10, CO2, Octane, O2, Biodiesel, CH4) = lipidcane_chemicals O2.at_state(phase='g') CH4.at_state(phase='g') CO2.at_state(phase='g') H3PO4.at_state(phase='s') P4O10.at_state(phase='s') Glucose.at_state(phase='s') Sucrose.at_state(phase='s') ### Define new chemicals ### def create_new_chemical(ID, phase='s', **constants): solid = tmo.Chemical.blank(ID, phase=phase, **constants) lipidcane_chemicals.append(solid) return solid Ash = create_new_chemical('Ash', MW=1.) Cellulose = create_new_chemical( 'Cellulose', formula="C6H10O5", # Glucose monomer minus water Hf=-975708.8) Hemicellulose = create_new_chemical( 'Hemicellulose', formula="C5H8O5", # Xylose monomer minus water Hf=-761906.4) Flocculant = create_new_chemical('Flocculant', MW=1.) Lignin = create_new_chemical( 'Lignin', formula='C8H8O3', # Vainillin Hf=-452909.632) Solids = create_new_chemical('Solids', MW=1.) DryYeast = create_new_chemical('DryYeast', MW=1., CAS='Yeast') CaO = create_new_chemical('CaO', formula='CaO') HCl = create_new_chemical('HCl', formula='HCl') NaOH = create_new_chemical('NaOH', formula='NaOH') NaOCH3 = create_new_chemical('NaOCH3', formula='NaOCH3') Lipid = create_new_chemical('Lipid', phase='l', formula='C57H104O6', Hf=-2193.7e3) Lipid.Dortmund.set_group_counts_by_name({ 'CH3': 3, 'CH2': 41, 'CH': 1, 'CH=CH': 3, 'CH2COO': 3 }) ### Fill missing properties ### # Assume properties are similar for trioleate and tripalmitin Tripalmitin = tmo.Chemical('Tripalmitin').at_state(phase='l', copy=True) Lipid.copy_models_from(Tripalmitin, ['V', 'sigma', 'kappa', 'Cn']) # Assume a constant volume for lipid lipid_molar_volume = fn.rho_to_V(rho=900, MW=Lipid.MW) Lipid.V.add_model(lipid_molar_volume) # Insolubles occupy a significant volume insoluble_solids = (Ash, Cellulose, Hemicellulose, Flocculant, Lignin, Solids, DryYeast, P4O10) # Solubles don't occupy much volume soluble_solids = (CaO, HCl, NaOH, H3PO4, Glucose, Sucrose) for chemical in insoluble_solids: V = fn.rho_to_V(rho=1540, MW=chemical.MW) chemical.V.add_model(V, top_priority=True) for chemical in soluble_solids: V = fn.rho_to_V(rho=1e5, MW=chemical.MW) chemical.V.add_model(V, top_priority=True) # Assume sodium methoxide has some of the same properities as methanol LiquidMethanol = Methanol.at_state(phase='l', copy=True) NaOCH3.copy_models_from(LiquidMethanol, ['V', 'sigma', 'kappa', 'Cn']) # Add constant models for molar heat capacity of solids Ash.Cn.add_model(0.09 * 4.184 * Ash.MW) CaO.Cn.add_model(1.02388 * CaO.MW) Cellulose.Cn.add_model(1.364 * Cellulose.MW) Hemicellulose.Cn.add_model(1.364 * Hemicellulose.MW) Flocculant.Cn.add_model(4.184 * Flocculant.MW) Lignin.Cn.add_model(1.364 * Lignin.MW) Solids.Cn.add_model(1.100 * Solids.MW) for chemical in lipidcane_chemicals: chemical.default() lipidcane_chemicals.compile() lipidcane_chemicals.set_synonym('Water', 'H2O') return lipidcane_chemicals
def create_ethanol_subsystem_example(): """ Test BioSTEAM by creating a conventional sugarcane fermentation and ethanol purification process. Examples -------- >>> ethanol_sys = create_ethanol_subsystem_example() >>> # The sugarcane_example_subsystem flowsheet may help for accessing units >>> from biosteam import main_flowsheet as F >>> fs = F.flowsheet['ethanol_subsystem_example'] >>> fs.unit # Check unit operation registry Register: <Fermentation: R301> <StorageTank: T301> <VentScrubber: D301> <SolidsCentrifuge: C301> <Mixer: M302> <Pump: P301> <HXprocess: H302> <BinaryDistillation: D302> <Pump: P302> <Mixer: M303> <BinaryDistillation: D303> <Pump: P303> <HXutility: H303> <MolecularSieve: U301> >>> R301 = fs.unit.R301 # Get unit operation """ original_flowsheet = main_flowsheet.get_flowsheet() main_flowsheet.set_flowsheet('ethanol_subsystem_example') ### Create property package ### chemicals = tmo.Chemicals( ['Water', 'Ethanol', 'Glucose', 'Sucrose', 'H3PO4', 'P4O10', 'CO2', 'Octane', 'O2'] ) Water, Ethanol, Glucose, Sucrose, H3PO4, P4O10, CO2, Octane, O2 = chemicals CO2.at_state(phase='g') H3PO4.at_state(phase='s') P4O10.at_state(phase='s') Glucose.at_state(phase='s') Sucrose.at_state(phase='s') DryYeast = tmo.Chemical('DryYeast', MW=1., phase='s', search_db=False, default=True, CAS='Yeast') chemicals.append(DryYeast) Ash = tmo.Chemical('Ash', MW=1., search_db=False, phase='s', default=True) chemicals.append(Ash) # Insolubles occupy a significant volume insoluble_solids = (Ash, DryYeast) # Solubles don't occupy much volume soluble_solids = (H3PO4, Glucose, Sucrose) for chemical in insoluble_solids: V = fn.rho_to_V(rho=1540, MW=chemical.MW) chemical.V.add_model(V, top_priority=True) for chemical in soluble_solids: V = fn.rho_to_V(rho=1e5, MW=chemical.MW) chemical.V.add_model(V, top_priority=True) # Add constant models for molar heat capacity of solids Ash.Cn.add_model(0.09 * 4.184 * Ash.MW) for chemical in chemicals: chemical.default() bst.settings.set_thermo(chemicals) chemicals.set_synonym('Water', 'H2O') ### Create fresh streams ### # Fresh water stripping_water = bst.Stream('stripping_water', Water=5000, units='kg/hr') fermentation_feed = bst.Stream('fermentation_feed', phase='l', Glucose=21.11, Sucrose=125.9, Water=1370 + 4409, H3PO4=0.7575, DryYeast=1.03e+04) # Ethanol Production R301 = units.Fermentation('R301', outs=('CO2', ''), tau=9, efficiency=0.90, N=4) T301 = units.StorageTank('T301', tau=4, vessel_material='Carbon steel') T301.line = 'Beer tank' D301 = units.VentScrubber('D301', ins=(stripping_water, R301-0), gas=('CO2',)) # Separate 99% of yeast C301 = units.SolidsCentrifuge('C301', outs=('recycle_yeast', ''), split=(1, 0.99999, 1, 0.96, 0.01), order=('Ethanol', 'Glucose', 'H3PO4', 'Water', 'DryYeast'), solids=('DryYeast',)) C301.split[:] = 1. - C301.split # Mix in Water M302 = units.Mixer('M302') P301 = units.Pump('P301') # Heat up before beer column # Exchange heat with stillage H302 = units.HXprocess('H302', outs=('', 'stillage'), phase0='l', phase1='l', U=1.28) # Beer column x_bot = 3.910570816782338e-06 y_top = 0.34508430224337167 D302 = units.BinaryDistillation('D302', P=101325, y_top=y_top, x_bot=x_bot, k=1.25, LHK=('Ethanol', 'Water')) D302.tray_material = 'Stainless steel 304' D302.vessel_material = 'Stainless steel 304' D302.boiler.U = 1.85 P302 = units.Pump('P302') # Mix ethanol Recycle (Set-up) M303 = units.Mixer('M303') x_bot = 3.910570816782338e-06 y_top = 0.7906528373264998 D303 = units.BinaryDistillation('D303', P=101325, y_top=y_top, x_bot=x_bot, k=1.25, LHK=('Ethanol', 'Water'), tray_material='Stainless steel 304', vessel_material='Stainless steel 304', is_divided=True) D303.boiler.U = 1.85 P303 = units.Pump('P303') # Superheat vapor for mol sieve H303 = units.HXutility('H303', T=115+273.15, V=1) # Molecular sieve U301 = units.MolecularSieve('U301', split=(2165.14/13356.04, 1280.06/1383.85), order=('Ethanol', 'Water')) fermentation_feed-R301-1-T301-0-C301 (C301-1, D301-1)-M302-P301 (P301-0, P302-0)-H302-0-D302-1-P302 (D302-0, U301-0)-M303-0-D303-0-H303-U301 D303-1-P303 ethanol_subsystem_example = main_flowsheet.create_system('ethanol_subsystem_example') ethanol_subsystem_example.simulate() main_flowsheet.set_flowsheet(original_flowsheet) return ethanol_subsystem_example