def test_lipidcane(): from biorefineries import lipidcane as lc lc.load() units = UnitGroup('Biorefinery', lc.lipidcane_tea.units) assert np.allclose(lc.lipidcane_tea.IRR, 0.1783634347376759, rtol=1e-2) assert np.allclose(lc.lipidcane_tea.sales, 102410581.5597974, rtol=1e-2) assert np.allclose(lc.lipidcane_tea.material_cost, 61762971.048900105, rtol=1e-2) assert np.allclose(lc.lipidcane_tea.installed_equipment_cost, 139559824.39299855, rtol=1e-2) assert np.allclose(lc.lipidcane_tea.utility_cost, -25886609.91411801, rtol=1e-2) assert np.allclose(units.get_heating_duty(), 197.74264093327824, rtol=1e-2) assert np.allclose(units.get_cooling_duty(), 305.1670349131174, rtol=1e-2) assert np.allclose(units.get_electricity_consumption(), 9.65815356491132, rtol=1e-2) assert np.allclose(units.get_electricity_production(), 92.62805713580244, rtol=1e-2)
def test_sugarcane(): from biorefineries import sugarcane as sc sc.load() units = UnitGroup('Biorefinery', sc.sugarcane_tea.units) assert np.allclose(sc.sugarcane_tea.IRR, 0.10319729375184486, rtol=1e-2) assert np.allclose(sc.sugarcane_tea.sales, 87641104.25548652, rtol=1e-2) assert np.allclose(sc.sugarcane_tea.material_cost, 60096508.050463505, rtol=1e-2) assert np.allclose(sc.sugarcane_tea.installed_equipment_cost, 111512561.90122335, rtol=1e-2) assert np.allclose(sc.sugarcane_tea.utility_cost, -8589365.38733437, rtol=1e-2) assert np.allclose(units.get_heating_duty(), 272.4872352787688, rtol=1e-2) assert np.allclose(units.get_cooling_duty(), 344.88392082847315, rtol=1e-2) assert np.allclose(units.get_electricity_consumption(), 9.853875285162502, rtol=1e-2) assert np.allclose(units.get_electricity_production(), 37.383892552259844, rtol=1e-2)
def test_wheatstraw(): from biorefineries import wheatstraw as ws ws.load() MESP = ws.wheatstraw_tea.solve_price(ws.ethanol) units = UnitGroup('Biorefinery', ws.wheatstraw_tea.units) assert np.allclose(MESP, 0.8988122216128204, rtol=1e-2) assert np.allclose(ws.wheatstraw_tea.sales, 126993140.05266903, rtol=1e-2) assert np.allclose(ws.wheatstraw_tea.material_cost, 63299710.08900007, rtol=1e-2) assert np.allclose(ws.wheatstraw_tea.installed_equipment_cost, 244243473.75764972, rtol=1e-2) assert np.allclose(ws.wheatstraw_tea.utility_cost, -8089087.901156843, rtol=1e-2) assert np.allclose(units.get_heating_duty(), 186.2281059784184, rtol=1e-2) assert np.allclose(units.get_cooling_duty(), 270.20290353471364, rtol=1e-2) assert np.allclose(units.get_electricity_consumption(), 22.924114167705298, rtol=1e-2) assert np.allclose(units.get_electricity_production(), 39.74032666884628, rtol=1e-2)
def test_LAOs(): from biorefineries import LAOs as laos laos.load() MPSP = laos.get_LAOs_MPSP() units = UnitGroup('Biorefinery', laos.LAOs_tea.units) assert np.allclose(MPSP, 1226.0016718824597, rtol=1e-2) assert np.allclose(laos.LAOs_tea.sales, 168789574.412942, rtol=1e-2) assert np.allclose(laos.LAOs_tea.material_cost, 135661583.58974993, rtol=1e-2) assert np.allclose(laos.LAOs_tea.installed_equipment_cost, 76661769.51734665, rtol=0.05) assert np.allclose(laos.LAOs_tea.utility_cost, 3811246.803774001, rtol=1e-2) assert np.allclose(units.get_heating_duty(), 59.19501587183199, rtol=1e-2) assert np.allclose(units.get_cooling_duty(), 134.66774238880174, rtol=1e-2) assert np.allclose(units.get_electricity_consumption(), 3.689496361470118, rtol=1e-2) assert np.allclose(units.get_electricity_production(), 3.6894963614701215, rtol=1e-2)
def test_cornstover(): from biorefineries import cornstover as cs cs.load() MESP = cs.cornstover_tea.solve_price(cs.ethanol) units = UnitGroup('Biorefinery', cs.cornstover_tea.units) assert np.allclose(MESP, 0.7383610895500932, rtol=1e-2) assert np.allclose(cs.cornstover_tea.sales, 134055638.87837549, rtol=1e-2) assert np.allclose(cs.cornstover_tea.material_cost, 82902092.80482696, rtol=1e-2) assert np.allclose(cs.cornstover_tea.installed_equipment_cost, 220012587.48251432, rtol=1e-2) assert np.allclose(cs.cornstover_tea.utility_cost, -11047774.698866017, rtol=1e-2) assert np.allclose(units.get_heating_duty(), 318.05635812416523, rtol=1e-2) assert np.allclose(units.get_cooling_duty(), 365.67806026618115, rtol=1e-2) assert np.allclose(units.get_electricity_consumption(), 22.371322764496814, rtol=1e-2) assert np.allclose(units.get_electricity_production(), 45.33827889984683, rtol=1e-2)
def test_example_sugarcane_subsystem(): """ Test BioSTEAM by creating a conventional sugarcane fermentation and ethanol separation process. Examples -------- >>> # Simply run this test and make sure not errors are raised >>> test_example_sugarcane_subsystem() """ from biosteam.examples import ethanol_subsystem_example ethanol_sys = ethanol_subsystem_example() biorefinery = UnitGroup('Biorefinery', ethanol_sys.units) assert np.allclose(biorefinery.get_installed_cost(), 13.57808163192647) assert np.allclose(biorefinery.get_heating_duty(), 156.8807334325833) assert np.allclose(biorefinery.get_cooling_duty(), 104.4639430479312) assert np.allclose(biorefinery.get_electricity_consumption(), 0.40116044433570186) assert np.allclose(biorefinery.get_electricity_production(), 0.)
import biosteam as bst from biorefineries import lipidcane as lc from biosteam.evaluation import Model, Metric from biosteam.evaluation.evaluation_tools import triang from biosteam.process_tools import UnitGroup from biosteam import plots import pandas as pd import numpy as np np.random.seed(1234) # %% Create metrics ethanol_density = 2.9866 # kg/gallon tea = lc.lipidcane_tea ugroup = UnitGroup('Biorefinery', tea.units) get_steam_demand = lambda: sum([i.flow for i in lc.BT.steam_utilities] ) * 18.01528 * tea._annual_factor / 1000 get_electricity_consumption = ugroup.get_electricity_consumption get_electricity_production = ugroup.get_electricity_production get_excess_electricity = lambda: get_electricity_production( ) - get_electricity_consumption() get_ethanol_production = lambda: lc.ethanol.F_mass * tea._annual_factor / 907.185 get_biodiesel_production = lambda: lc.biodiesel.F_mass * tea._annual_factor / 907.185 get_MESP = lambda: tea.solve_price(lc.ethanol) * ethanol_density get_MFPP = lambda: tea.solve_price(lc.lipidcane) get_IRR = lambda: tea.solve_IRR() * 100 get_FCI = lambda: tea.FCI / 10**6 metrics = (Metric('IRR', get_IRR, '%'), Metric('MFPP', get_MFPP, 'USD/kg'), Metric('MESP', get_MESP,
# -*- coding: utf-8 -*- """ Created on Sun May 26 11:21:31 2019 @author: yoelr """ from biosteam.evaluation import Model, Metric from biosteam.evaluation.evaluation_tools import triang from biosteam.process_tools import UnitGroup import biorefineries.sugarcane as sc __all__ = ('sugarcane_model', ) tea = sc.sugarcane_tea ugroup = UnitGroup('Biorefinery', tea.units) ethanol = sc.ethanol products = (ethanol, ) get_prodcost = lambda: float(tea.production_cost(products)) get_FCI = lambda: tea._FCI_cached get_prod = lambda: ethanol.F_mass * tea._annual_factor get_steam = lambda: sum([i.flow for i in sc.BT.steam_utilities] ) * 18.01528 * tea._annual_factor / 1000 get_electricity_consumption = lambda: tea._annual_factor * ugroup.get_electricity_consumption( ) get_electricity_production = lambda: tea._annual_factor * ugroup.get_electricity_production( ) get_excess_electricity = lambda: get_electricity_production( ) - get_electricity_consumption() metrics = (Metric('Internal rate of return', sc.sugarcane_tea.solve_IRR, '%'),
# ============================================================================= # Feedstock preprocessing # ============================================================================= feedstock = Stream('feedstock', baseline_feedflow.copy(), units='kg/hr', price=price['Feedstock']) U101 = units.FeedstockPreprocessing('U101', ins=feedstock) # Handling costs/utilities included in feedstock cost thus not considered here U101.cost_items['System'].cost = 0 U101.cost_items['System'].kW = 0 process_groups = [] feedstock_group = UnitGroup('feedstock_group', units=(U101, )) process_groups.append(feedstock_group) # %% # ============================================================================= # Pretreatment streams # ============================================================================= # For pretreatment, 93% purity sulfuric_acid_T201 = Stream('sulfuric_acid_T201', units='kg/hr') # To be mixed with sulfuric acid, flow updated in SulfuricAcidMixer water_M201 = Stream('water_M201', T=114 + 273.15, units='kg/hr') # To be used for feedstock conditioning water_M202 = Stream('water_M202', T=95 + 273.15, units='kg/hr')
# as the default value (default_total_flow, 104180 kg/hr) acid_total_flow = [] # These lists store output results acid_conversions_C6 = [] acid_conversions_C5 = [] acid_ethanol_yields = [] acid_produced_electricity = [] acid_MESPs = [] acid_MFPPs = [] # Run assumed compositions (varying cellulose, hemicellulose, and lignin compositions # while keeping compositions of other components unchanged). # The first composition in the file is the default one as in refs [1-3] feedstock_dry_mass = acid.feedstock.F_mass - acid.feedstock.imass['Water'] acid_group = UnitGroup('Acid pretreatment', acid.ethanol_sys.units) acid_factor = acid.ethanol_no_CHP_tea._annual_factor for i in range(0, simulated_composition.shape[0]): # Update feedstock flow update_feedstock_flows(acid.feedstock, simulated_composition.iloc[i]) # Adjust cellulose conversion lignin_percent = acid.feedstock.imass['Lignin'] / feedstock_dry_mass # 0.04 and 0.012 are cellulose (glucan) conversion to other products, # subtract 1e-6 to avoid getting tiny negatives, # 1.04-1.37*lignin_percent is the developed correlation C6_conversion = min(1-0.04-0.012-1e-6, max(0, (1.04-1.37*lignin_percent))) acid.R301.saccharification_rxns_C6[2].X = C6_conversion # Adjust hemicellulose conversion # 0.05 and 0.024 are cellulose (glucan) conversion to other products,