def create_base_biorefinery(preprocessed, include_adipic_process=True, recover_sodium_sulfate=True):
    flowsheet = bst.Flowsheet('base')
    bst.main_flowsheet.set_flowsheet(flowsheet)
    s = flowsheet.stream
    u = flowsheet.unit
    feedstock = preprocessed.copy('feedstock')
    feedstock.price = preprocessed.price
    get_flow_tpd = (lambda : (((feedstock.F_mass - feedstock.imass['H2O']) * 24) / _kg_per_ton))
    groups = []
    (flowsheet, groups) = create_base_pretreatment_process(flowsheet, groups, feedstock)
    (flowsheet, groups) = create_ethanol_process(flowsheet, groups, (u.P202 - 0))
    u.M301.enzyme_load = 10
    u.M301.solid_loading = 0.25
    u.R301.C5_saccharification = True
    if include_adipic_process:
        (flowsheet, groups) = create_adipic_process(flowsheet, groups, (u.P201 - 0), (u.S401 - 0))
        wwt_streams = ((u.D402_P - 0), (u.S401 - 1), (u.S701 - 1), (u.S702 - 0), '')
        (flowsheet, groups) = create_wastewater_process(flowsheet, groups, get_flow_tpd, wwt_streams, need_ammonia=True, bypass_R501=True, recover_sodium_sulfate=recover_sodium_sulfate)
        CHP_wastes1 = ((u.R701 - 1), (u.S504 - 1))
        CHP_biogas = ''
        process_water_streams = {'adipid': (s.water_R702,)}
    else:
        wwt_streams = ((u.P201 - 0), (u.D402_P - 0), (u.S401 - 1), '')
        (flowsheet, groups) = create_wastewater_process(flowsheet, groups, get_flow_tpd, wwt_streams, need_ammonia=False, bypass_R501=False, recover_sodium_sulfate=recover_sodium_sulfate)
        CHP_wastes1 = ((u.S401 - 0), (u.S504 - 1))
        CHP_biogas = (u.R501 - 0)
        process_water_streams = {}
    CHP_wastes2 = (((u.S506 - 1),) if recover_sodium_sulfate else ())
    CHP_wastes = (*CHP_wastes1, *CHP_wastes2)
    CHP_side_streams = ()
    process_water_streams['pretreatment'] = (s.water_R201,)
    process_water_streams['ethanol'] = (s.water_M301, s.water_U401)
    recycled_water = (u.S505 - 0)
    (flowsheet, groups) = create_facilities(flowsheet, groups, get_flow_tpd, CHP_wastes, CHP_biogas, CHP_side_streams, process_water_streams, recycled_water, if_HXN=False, if_BDM=True)
    (flowsheet, teas, funcs) = create_biorefinery(flowsheet, groups, get_flow_tpd)
    return (flowsheet, groups, teas, funcs)
def create_base_biorefinery(preprocessed, include_adipic_process=True, recover_sodium_sulfate=True):
    flowsheet = bst.Flowsheet('base')
    bst.main_flowsheet.set_flowsheet(flowsheet)
    s = flowsheet.stream
    u = flowsheet.unit
    feedstock = preprocessed.copy('feedstock')
    feedstock.price = preprocessed.price
    get_flow_tpd = (lambda : (((feedstock.F_mass - feedstock.imass['H2O']) * 24) / _kg_per_ton))
    groups = []
    (flowsheet, groups) = create_base_pretreatment_process(flowsheet, groups, feedstock)
    (flowsheet, groups) = create_ethanol_process(flowsheet, groups, (u.P202 - 0))
    u.M301.enzyme_load = 10
    u.M301.solid_loading = 0.25
    u.R301.C5_saccharification = True
    if include_adipic_process:
        (flowsheet, groups) = create_adipic_process(flowsheet, groups, (u.P201 - 0), (u.S401 - 0))
        wwt_streams = ((u.D402_P - 0), (u.S401 - 1), (u.S701 - 1), (u.S702 - 0), )
        (flowsheet, groups) = create_wastewater_process(flowsheet, groups, get_flow_tpd, wwt_streams, need_ammonia=True, bypass_R501=True, recover_sodium_sulfate=recover_sodium_sulfate)
        CHP_wastes1 = ((u.R701 - 1), (u.S504 - 1))
        CHP_biogas = 
        process_water_streams = {'adipid': (s.water_R702,)}
    else:
        wwt_streams = ((u.P201 - 0), (u.D402_P - 0), (u.S401 - 1), )
        (flowsheet, groups) = create_wastewater_process(flowsheet, groups, get_flow_tpd, wwt_streams, need_ammonia=False, bypass_R501=False, recover_sodium_sulfate=recover_sodium_sulfate)
        CHP_wastes1 = ((u.S401 - 0), (u.S504 - 1))
        CHP_biogas = (u.R501 - 0)
        process_water_streams = {}
    CHP_wastes2 = (((u.S506 - 1),) if recover_sodium_sulfate else ())
    CHP_wastes = (*CHP_wastes1, *CHP_wastes2)
    CHP_side_streams = ()
    process_water_streams['pretreatment'] = (s.water_R201,)
    process_water_streams['ethanol'] = (s.water_M301, s.water_U401)
    recycled_water = (u.S505 - 0)
    (flowsheet, groups) = create_facilities(flowsheet, groups, get_flow_tpd, CHP_wastes, CHP_biogas, CHP_side_streams, process_water_streams, recycled_water, if_HXN=False, if_BDM=True)
    (flowsheet, teas, funcs) = create_biorefinery(flowsheet, groups, get_flow_tpd)
    return (flowsheet, groups, teas, funcs)