Hide code cell content
###############################################################################
# The Institute for the Design of Advanced Energy Systems Integrated Platform
# Framework (IDAES IP) was produced under the DOE Institute for the
# Design of Advanced Energy Systems (IDAES).
#
# Copyright (c) 2018-2023 by the software owners: The Regents of the
# University of California, through Lawrence Berkeley National Laboratory,
# National Technology & Engineering Solutions of Sandia, LLC, Carnegie Mellon
# University, West Virginia University Research Corporation, et al.
# All rights reserved.  Please see the files COPYRIGHT.md and LICENSE.md
# for full copyright and license information.
###############################################################################

Methanol Synthesis Flowsheet Example#

Maintainer: Brandon Paul
Author: Brandon Paul
Updated: 2023-06-01

The purpose of this notebook is to demonstrate flowsheet synthesis integrating IDAES modeling tools, including the Unit Model Library, Property and Reaction Framework, IDAES scaling tools and the Process Costing Framework. The example leverages imports from external flowsheet scripts, and demonstrates implementation of separate VLE and vapor-only property packages to reduce model complexity where applicable.

Simplified Hydrogen Reformation System#

This example demonstrates a steady-state model of methanol synthesis from hydrogen and carbon monoxide. To simulate relevant natural gas components, the reactant vapors are mixed stoichiometrically and brought to optimal reaction conditions prior to entering the gas-phase reactor. Vapor liquid equilibrium is mainly applicable in the post-reactor Flash unit for methanol recovery, and is accounted for by separate vapor and VLE thermophysical property packages. See methanol_flowsheet.py for more information on how to assemble the flowsheet, as well as idaes_examples.mod.methanol.methanol_ideal_VLE.py, idaes_examples.mod.methanol.methanol_ideal_vapor and idaes_examples.mod.methanol.methanol_reactions for more information on the thermophyscial and reaction properties.

This example is a reasonable approximation for gas-phase methanol synthesis systems and does not represent any particular chemical process. To simplify the system and increase tractability, hydrogen and carbon monoxide feeds are considered in lieu of multi-step mechanisms for carbon dioxide conversion to methanol. General process descriptions for gas-phase synthesis, as well as thermophysical and reaction properties for carbon monoxide hydrogenation, were taken from the following publication:

Nieminen, H.; Laari, A.; Koiranen, T. CO2 Hydrogenation to Methanol by a Liquid-Phase Process with Alcoholic Solvents: A Techno-Economic Analysis. Processes 2019, 7, 405. https://doi.org/10.3390/pr7070405

1. Introduction#

This example demonstrates a simulation of methanol synthesis from hydrogen and carbon monoxide. Each methanol flowsheet module includes several built-in methods. This notebook demonstrates building the flowsheet, implementing model scaling, initialization and solving a square problem, costing and final constrained optimization.

The build_model() method creates the Pyomo concrete model and builds the flowsheet by importing thermophysical and reaction properties and unit models and defining stream connections between these units. This method also implements appropriate default scaling on state and property variables.

The set_inputs() method adds the appropriate initial specifications on the feed streams and unit operations. Specifications upstream of the reactor largely remain fixed throughout the optimization.

The scale_flowsheet() method implements generic variable, unit model state variable, unit model constraint and Arc equality constraint scaling via IDAES scaling tools. Scaling factors are hard-coded in the flowsheet scripts to adjust for order of magnitude factors in appropriate constraints and simplify numerical solver calculations.

The initialize_flowsheet() method uses the initial guess to initialize the models sequentially, solving each unit and propagating the results to the outlet stream to converge the next unit more quickly. This occurs just before the flowsheet-level solver call.

The add_costing() method creates new variables and constraints related to unit model capital cost and operating cost calculations, and defines an objective function for the process economics. This method is called after the flowsheet-level solver call, and the flowsheet is resolved once costing is added. Capital costs are estimated using built-in costing methods within IDAES, and operating costs are estimated from a combination of known cost coefficients and surrogate models.

The report() method displays relevant model results after the flowsheet has been fully solved.

2. Problem Statement#

For given raw material flows and optimal reactor conditions, we will calculate the extent of reaction, relevant process results including reactor duty and turbine duty, methanol recovery, and relevant economic results including annual revenue.

2.1. Main Inputs:#

  • Raw material inlets (F - mol/s, P - Pa, h - j/mol, x - mole fraction)

  • Pre-reactor compressor outlet pressure (Pa)

  • Pre-reactor heater outlet temperature (K)

2.2. Main Outputs:#

  • Extent of reaction (mol/s)

  • Reactor duty (W)

  • Turbine duty (W)

  • Methanol recovery (%)

  • Annual revenue (USD/year)

from IPython.display import Image

Image("methanol_flowsheet.png")
../../_images/b997eeaac68a43b2ed9b1ae9e72cdf0ca8203cdd4bb4528210ad0d689321b623.png

3. Import and Solve Flowsheet#

3.1 Import Pyomo and IDAES Libraries#

First, let’s import the relevant Pyomo and IDAES Libraries:

import pytest
import os

# Import Pyomo libraries
from pyomo.environ import (
    Constraint,
    Objective,
    Var,
    Expression,
    Param,
    ConcreteModel,
    TransformationFactory,
    value,
    maximize,
    units as pyunits,
)
from pyomo.environ import TerminationCondition
from pyomo.network import Arc

# Import IDAES core libraries
from idaes.core import FlowsheetBlock
from idaes.core.solvers import get_solver
from idaes.core.util import scaling as iscale
from idaes.core.util.model_statistics import degrees_of_freedom
from idaes.core.util.initialization import propagate_state

# Import required property modules
from idaes.models.properties.modular_properties.base.generic_property import (
    GenericParameterBlock,
)
from idaes.models.properties.modular_properties.base.generic_reaction import (
    GenericReactionParameterBlock,
)

from idaes_examples.mod.methanol import methanol_ideal_VLE as thermo_props_VLE
from idaes_examples.mod.methanol import methanol_ideal_vapor as thermo_props_vapor
from idaes_examples.mod.methanol import methanol_reactions as reaction_props

from idaes.models.unit_models import (
    Feed,
    Mixer,
    Heater,
    Compressor,
    Turbine,
    StoichiometricReactor,
    Flash,
    Product,
)
from idaes.models.unit_models.mixer import MomentumMixingType
from idaes.models.unit_models.pressure_changer import ThermodynamicAssumption
from idaes.core import UnitModelCostingBlock
from idaes.models.costing.SSLW import SSLWCosting

# import flowsheet functions
from methanol_flowsheet import (
    build_model,
    set_inputs,
    scale_flowsheet,
    initialize_flowsheet,
    add_costing,
    report,
)

3.2 Build and Solve Flowsheet#

The methanol flowsheet methods are called sequentially below, following the workflow contained in the main() method in methanol_flowsheet.py. First, let’s set the solver options. IDAES contains a default solver get_solver which calls IPOPT using standard settings, and we set an iteration cap of 100 to catch nonconverging solver runs.

# Set solver options
solver = get_solver()  # IPOPT
optarg = {"tol": 1e-6, "max_iter": 100}
solver.options = optarg

Next, we will build and solve the initial flowsheet using imported flowsheet methods - see methanol_flowsheet.py for complete method scripts.

In the code below, we first define a Pyomo model object and build the model by defining each unit block with relevant property packages. As mentioned earlier, only the Flash unit (and the liquid outlet Product block) employ the VLE property package to ensure fast convergence of vapor-only processes.

The process inputs are set for stoichiometric hydrogen and carbon monoxide feeds according to the process diagram in section 2.2. In the output below, the script returns the expected degrees of freedom for the model for each unit (compressor pressure change, heater duty, reactor duty and conversion, turbine pressure change and efficiency, cooler duty and flash duty and pressure change) and the actual model degrees of freedom before input specification, after the feed inputs are specified (flow, enthalpy, pressure, and composition for each feed) and after the unit model inputs are specified.

After setting process inputs, we have a square problem for initialization. Here, we first implement IDAES scaling tools to create a more tractable problem during the solve step, and then sequentially initialize and propagate results from each unit block. As expected, the model only performs dew and bubble point calculations for the Flash and CH3OH product blocks where liquid phases are present and we obtain a square, solved problem:

# Build and solve flowsheet
m = ConcreteModel()
build_model(m)  # build flowsheet by adding unit models and property packages
set_inputs(m)  # unit and stream specifications
scale_flowsheet(m)  # flowsheet and unit model level scaling
initialize_flowsheet(m)  # rigorous initialization scheme

print("DOF before solve: ", degrees_of_freedom(m))
print()
print("Solving initial problem...")

results = solver.solve(m, tee=True)  # initial square problem solve
Unit degrees of freedom
M101 0
C101 1
H101 1
R101 2
T101 2
H102 1
F101 2
Total DOF:  23
DOF after streams specified:  9
DOF after units specified:  0
2024-05-09 18:34:05 [INFO] idaes.init.fs.H2.properties: Starting initialization
---------------------------------------------------------------------------
ApplicationError                          Traceback (most recent call last)
Cell In[5], line 6
      4 set_inputs(m)  # unit and stream specifications
      5 scale_flowsheet(m)  # flowsheet and unit model level scaling
----> 6 initialize_flowsheet(m)  # rigorous initialization scheme
      8 print("DOF before solve: ", degrees_of_freedom(m))
      9 print()

File ~/checkouts/readthedocs.org/user_builds/idaes-examples/checkouts/latest/idaes_examples/notebooks/docs/flowsheets/methanol_flowsheet.py:514, in initialize_flowsheet(m)
    509 def initialize_flowsheet(m):
    510 
    511     # Initialize and solve flowsheet
    513     print('')
--> 514     m.fs.H2.initialize()
    515     propagate_state(arc=m.fs.H2_FEED)
    517     m.fs.CO.initialize()

File ~/checkouts/readthedocs.org/user_builds/idaes-examples/envs/latest/lib/python3.8/site-packages/idaes/core/base/unit_model.py:540, in UnitModelBlockData.initialize(blk, *args, **kwargs)
    537     c.deactivate()
    539 # Remember to collect flags for fixed vars
--> 540 flags = blk.initialize_build(*args, **kwargs)
    542 # If costing block exists, activate and initialize
    543 for c in init_order:

File ~/checkouts/readthedocs.org/user_builds/idaes-examples/envs/latest/lib/python3.8/site-packages/idaes/models/unit_models/feed.py:186, in FeedData.initialize_build(blk, state_args, outlvl, solver, optarg)
    183     state_args = {}
    185 # Initialize state block
--> 186 blk.properties.initialize(
    187     outlvl=outlvl, optarg=optarg, solver=solver, state_args=state_args
    188 )
    190 init_log.info("Initialization Complete.")

File ~/checkouts/readthedocs.org/user_builds/idaes-examples/envs/latest/lib/python3.8/site-packages/idaes/models/properties/modular_properties/base/generic_property.py:2036, in _GenericStateBlock.initialize(blk, state_args, state_vars_fixed, hold_state, outlvl, solver, optarg)
   2031         raise InitializationError(
   2032             f"{blk.name} Unexpected degrees of freedom during "
   2033             f"initialization at property initialization step: {dof}."
   2034         )
   2035     with idaeslog.solver_log(solve_log, idaeslog.DEBUG) as slc:
-> 2036         res = solve_indexed_blocks(opt, [blk], tee=slc.tee)
   2037     init_log.info(
   2038         "Property initialization: {}.".format(idaeslog.condition(res))
   2039     )
   2041 # ---------------------------------------------------------------------
   2042 # Return constraints to initial state

File ~/checkouts/readthedocs.org/user_builds/idaes-examples/envs/latest/lib/python3.8/site-packages/idaes/core/util/initialization.py:285, in solve_indexed_blocks(solver, blocks, **kwds)
    278     tmp._ctypes[Block] = [  # pylint: disable=protected-access
    279         0,
    280         nBlocks - 1,
    281         nBlocks,
    282     ]
    284     # Solve temporary Block
--> 285     results = solver.solve(tmp, **kwds)
    287 finally:
    288     # Clean up temporary Block contents so they are not removed when Block
    289     # is garbage collected.
    290     tmp._decl = {}  # pylint: disable=protected-access

File ~/checkouts/readthedocs.org/user_builds/idaes-examples/envs/latest/lib/python3.8/site-packages/pyomo/opt/base/solvers.py:534, in OptSolver.solve(self, *args, **kwds)
    531 def solve(self, *args, **kwds):
    532     """Solve the problem"""
--> 534     self.available(exception_flag=True)
    535     #
    536     # If the inputs are models, then validate that they have been
    537     # constructed! Collect suffix names to try and import from solution.
    538     #
    539     from pyomo.core.base.block import BlockData

File ~/checkouts/readthedocs.org/user_builds/idaes-examples/envs/latest/lib/python3.8/site-packages/pyomo/opt/solver/shellcmd.py:140, in SystemCallSolver.available(self, exception_flag)
    138     if exception_flag:
    139         msg = "No executable found for solver '%s'"
--> 140         raise ApplicationError(msg % self.name)
    141     return False
    142 return True

ApplicationError: No executable found for solver 'ipopt'

3.3 Flowsheet Costing and Optimization#

Now that we have a well-initialized and solved flowsheet, we can add process economics and optimize the revenue. We utilize IDAES costing tools to calculate reactor and flash vessel capital cost, and implement surrogate models to account for heat exchanger capital costs. Additional, we calculate reactor operating costs as a function of conversion and assume constant rates for electricity, heating and cooling costs. Capital costs are annualized over 15 years, and revenue is determined from total liquid methanol sales, operating costs, annualized capital costs and feed raw material costs. The flowsheet report method returns key process results, including a check on the reaction stoichiometry, relevant duty and state variable values, economic results, and stream tables for feed and product streams:

add_costing(m)  # re-solve with costing equations
print()
print("Solving with costing...")
results2 = solver.solve(m, tee=True)

print("Initial solution process results:")
report(m)  # display initial solution results
Solving with costing...
WARNING: model contains export suffix
'fs.CH3OH.properties[0.0].scaling_factor' that contains 7 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.EXHAUST.properties[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.split.scaling_factor' that
contains 24 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_out[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_in[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.control_volume.scaling_factor'
that contains 1 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.properties_isentropic[0.0].scaling_factor' that contains 8 component
keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_in[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.T101.control_volume.scaling_factor'
that contains 1 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.reactions[0.0].scaling_factor' that contains 1
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_out[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.CO_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.H2_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.CO.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.H2.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH3OH.scaling_factor' that contains 11 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.H2.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CO.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH4.scaling_factor' that contains 8 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH3OH.scaling_factor' that contains 23 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.H2.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.CO.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH4.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
Ipopt 3.13.2: tol=1e-06
max_iter=100


******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt

This version of Ipopt was compiled from source code available at
    https://github.com/IDAES/Ipopt as part of the Institute for the Design of
    Advanced Energy Systems Process Systems Engineering Framework (IDAES PSE
    Framework) Copyright (c) 2018-2019. See https://github.com/IDAES/idaes-pse.

This version of Ipopt was compiled using HSL, a collection of Fortran codes
    for large-scale scientific computation.  All technical papers, sales and
    publicity material resulting from use of the HSL codes within IPOPT must
    contain the following acknowledgement:
        HSL, a collection of Fortran codes for large-scale scientific
        computation. See http://www.hsl.rl.ac.uk.
******************************************************************************

This is Ipopt version 3.13.2, running with linear solver ma27.

Number of nonzeros in equality constraint Jacobian...:      971
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:      611

Total number of variables............................:      319
                     variables with only lower bounds:       43
                variables with lower and upper bounds:      255
                     variables with only upper bounds:        1
Total number of equality constraints.................:      319
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -2.8492051e+07 9.10e+04 1.00e+02  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -2.9068962e+07 5.76e+04 6.45e+01  -1.0 1.20e+05    -  5.03e-02 9.90e-01h  1
   2 -2.9074767e+07 5.71e+02 9.98e+00  -1.0 5.72e+04    -  9.81e-01 9.90e-01h  1
   3 -2.9074825e+07 5.22e-05 1.00e+03  -1.0 5.67e+02    -  9.90e-01 1.00e+00h  1
   4 -2.9074825e+07 1.86e-09 9.90e+04  -1.0 5.22e-05    -  9.90e-01 1.00e+00h  1

Number of Iterations....: 4

                                   (scaled)                 (unscaled)
Objective...............:  -4.4948186430824144e+01   -2.9074824816033211e+07
Dual infeasibility......:   8.3561161967102299e-07    5.4051705720246346e-01
Constraint violation....:   4.5474735088646412e-12    1.8626451492309570e-09
Complementarity.........:   0.0000000000000000e+00    0.0000000000000000e+00
Overall NLP error.......:   4.5474735088646412e-12    5.4051705720246346e-01


Number of objective function evaluations             = 5
Number of objective gradient evaluations             = 5
Number of equality constraint evaluations            = 5
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 5
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 4
Total CPU secs in IPOPT (w/o function evaluations)   =      0.004
Total CPU secs in NLP function evaluations           =      0.000

EXIT: Optimal Solution Found.
Initial solution process results:


Extent of reaction:  237.60047790000002
Stoichiometry of each component normalized by the extent:
CH4 :  0.0
H2 :  -2.0
CH3OH :  1.0
CO :  -1.0
These coefficients should follow 1*CO + 2*H2 => 1*CH3OH

Reaction conversion:  0.75
Reactor duty (MW):  -45.21917830318435
Duty from Reaction (MW)): 21.536107316856
Turbine work (MW):  -0.9593346445867593
Mixer outlet temperature (C)):  20.051714213753257
Compressor outlet temperature (C)):  20.051714213753314
Compressor outlet pressure (Pa)):  5100000.0
Heater outlet temperature (C)):  215.0
Reactor outlet temperature (C)):  234.0
Turbine outlet temperature (C)):  192.87815244243234
Turbine outlet pressure (Pa)):  3100000.0
Cooler outlet temperature (C)):  134.0
Flash outlet temperature (C)):  134.0
Methanol recovery(%):  60.004430129216814
annualized capital cost ($/year) = 219790.50447043404
operating cost ($/year) =  380701687.4964808
sales ($/year) =  64685201172.19813
raw materials cost ($/year) = 35229454878.16397
revenue (1000$/year)=  29074824.816033203


====================================================================================
Unit : fs.H2                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units        Outlet  
    Total Molar Flowrate       mole / second     637.20
    Total Mole Fraction CH4    dimensionless 1.0000e-06
    Total Mole Fraction CO     dimensionless 1.0000e-06
    Total Mole Fraction H2     dimensionless     1.0000
    Total Mole Fraction CH3OH  dimensionless 1.0000e-06
    Molar Enthalpy              joule / mole    -142.40
    Pressure                          pascal 3.0000e+06
====================================================================================

====================================================================================
Unit : fs.CO                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Outlet  
    Total Molar Flowrate       mole / second      316.80
    Total Mole Fraction CH4    dimensionless  1.0000e-06
    Total Mole Fraction CO     dimensionless      1.0000
    Total Mole Fraction H2     dimensionless  1.0000e-06
    Total Mole Fraction CH3OH  dimensionless  1.0000e-06
    Molar Enthalpy              joule / mole -1.1068e+05
    Pressure                          pascal  3.0000e+06
====================================================================================

====================================================================================
Unit : fs.EXHAUST                                                          Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Inlet  
    Total Molar Flowrate       mole / second     336.23
    Total Mole Fraction CH4    dimensionless 2.8373e-06
    Total Mole Fraction CO     dimensionless    0.23555
    Total Mole Fraction H2     dimensionless    0.48181
    Total Mole Fraction CH3OH  dimensionless    0.28263
    Molar Enthalpy              joule / mole    -80218.
    Pressure                          pascal 3.1000e+06
====================================================================================

====================================================================================
Unit : fs.CH3OH                                                            Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units          Inlet  
    Total Molar Flowrate       mole / second      142.57
    Total Mole Fraction CH4    dimensionless  1.0000e-08
    Total Mole Fraction CO     dimensionless  1.0000e-08
    Total Mole Fraction H2     dimensionless  1.0000e-08
    Total Mole Fraction CH3OH  dimensionless      1.0000
    Molar Enthalpy              joule / mole -2.3813e+05
    Pressure                          pascal  3.1000e+06
====================================================================================

Finally, let’s unfix some specifications and determine an optimal revenue. We set bounds on our decision variables to constrain our objective to physical and economically sensible solutions. The pre-reactor section mixes the feeds and brings the reactants to optimal temperature and pressure, and we only unfix downstream unit specifications:

# Set up Optimization Problem (Maximize Revenue)
# keep process pre-reaction fixed and unfix some post-process specs
m.fs.R101.conversion.unfix()
m.fs.R101.conversion_lb = Constraint(expr=m.fs.R101.conversion >= 0.75)
m.fs.R101.conversion_ub = Constraint(expr=m.fs.R101.conversion <= 0.85)
m.fs.R101.outlet_temp.deactivate()
m.fs.R101.outlet_t_lb = Constraint(
    expr=m.fs.R101.control_volume.properties_out[0.0].temperature >= 405 * pyunits.K
)
m.fs.R101.outlet_t_ub = Constraint(
    expr=m.fs.R101.control_volume.properties_out[0.0].temperature <= 505 * pyunits.K
)

# Optimize turbine work (or delta P)
m.fs.T101.deltaP.unfix()  # optimize turbine work recovery/pressure drop
m.fs.T101.outlet_p_lb = Constraint(
    expr=m.fs.T101.outlet.pressure[0] >= 10e5 * pyunits.Pa
)
m.fs.T101.outlet_p_ub = Constraint(
    expr=m.fs.T101.outlet.pressure[0] <= 51e5 * 0.8 * pyunits.Pa
)

# Optimize Cooler outlet temperature - unfix cooler outlet temperature
m.fs.H102.outlet_temp.deactivate()
m.fs.H102.outlet_t_lb = Constraint(
    expr=m.fs.H102.control_volume.properties_out[0.0].temperature
    >= 407.15 * 0.8 * pyunits.K
)
m.fs.H102.outlet_t_ub = Constraint(
    expr=m.fs.H102.control_volume.properties_out[0.0].temperature <= 480 * pyunits.K
)

m.fs.F101.deltaP.unfix()  # allow pressure change in streams

m.fs.F101.isothermal = Constraint(
    expr=m.fs.F101.control_volume.properties_out[0].temperature
    == m.fs.F101.control_volume.properties_in[0].temperature
)

print()
print("Solving optimization problem...")
opt_res = solver.solve(m, tee=True)

print("Optimal solution process results:")
report(m)
Solving optimization problem...
WARNING: model contains export suffix
'fs.CH3OH.properties[0.0].scaling_factor' that contains 7 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.EXHAUST.properties[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.split.scaling_factor' that
contains 24 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_out[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_in[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.properties_isentropic[0.0].scaling_factor' that contains 8 component
keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_in[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.reactions[0.0].scaling_factor' that contains 1
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_out[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.CO_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.H2_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.CO.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.H2.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH3OH.scaling_factor' that contains 11 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.H2.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CO.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH4.scaling_factor' that contains 8 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH3OH.scaling_factor' that contains 23 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.H2.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.CO.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH4.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
Ipopt 3.13.2: tol=1e-06
max_iter=100


******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt

This version of Ipopt was compiled from source code available at
    https://github.com/IDAES/Ipopt as part of the Institute for the Design of
    Advanced Energy Systems Process Systems Engineering Framework (IDAES PSE
    Framework) Copyright (c) 2018-2019. See https://github.com/IDAES/idaes-pse.

This version of Ipopt was compiled using HSL, a collection of Fortran codes
    for large-scale scientific computation.  All technical papers, sales and
    publicity material resulting from use of the HSL codes within IPOPT must
    contain the following acknowledgement:
        HSL, a collection of Fortran codes for large-scale scientific
        computation. See http://www.hsl.rl.ac.uk.
******************************************************************************

This is Ipopt version 3.13.2, running with linear solver ma27.

Number of nonzeros in equality constraint Jacobian...:      975
Number of nonzeros in inequality constraint Jacobian.:        8
Number of nonzeros in Lagrangian Hessian.............:      613

Total number of variables............................:      322
                     variables with only lower bounds:       43
                variables with lower and upper bounds:      256
                     variables with only upper bounds:        1
Total number of equality constraints.................:      318
Total number of inequality constraints...............:        8
        inequality constraints with only lower bounds:        4
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        4

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -2.8492012e+07 2.79e+04 1.00e+02  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -2.8402805e+07 2.72e+04 9.71e+01  -1.0 8.82e+06    -  4.99e-02 2.59e-02h  1
   2 -2.8406590e+07 2.70e+04 9.56e+01  -1.0 8.57e+06    -  7.51e-02 8.58e-03h  1
   3 -2.8493710e+07 2.29e+04 3.69e+02  -1.0 8.41e+06    -  1.67e-01 1.52e-01h  1
   4 -2.8493256e+07 2.28e+04 1.20e+04  -1.0 4.60e+06    -  1.00e-01 2.61e-03h  1
   5 -2.8504482e+07 2.24e+04 1.20e+04  -1.0 4.52e+06    -  2.44e-02 2.38e-02h  1
   6 -2.8536507e+07 2.16e+04 2.28e+04  -1.0 4.39e+06    -  5.48e-02 6.86e-02h  1
   7 -2.8537588e+07 2.16e+04 1.35e+05  -1.0 3.94e+06    -  2.56e-01 2.49e-03h  1
   8 -2.8537637e+07 2.15e+04 6.77e+06  -1.0 1.30e+06    -  4.69e-01 1.17e-04h  1
   9 -2.8910081e+07 8.51e+04 2.07e+06  -1.0 1.31e+06    -  4.38e-01 9.05e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10 -2.8914184e+07 7.59e+04 7.45e+06  -1.0 9.51e+04    -  9.00e-01 1.08e-01h  1
  11 -2.8947637e+07 1.17e+03 1.82e+05  -1.0 8.76e+04    -  9.09e-01 9.90e-01h  1
  12 -2.8897906e+07 2.27e+01 4.44e+06  -1.0 6.65e+03    -  9.89e-01 9.92e-01h  1
  13 -3.9607639e+07 3.82e+04 7.42e+07  -1.0 5.09e+06    -  8.24e-02 1.77e-01f  3
  14 -5.3973065e+07 7.32e+04 5.80e+07  -1.0 1.89e+06    -  6.48e-01 1.00e+00F  1
  15 -5.8002084e+07 1.39e+05 2.82e+06  -1.0 1.54e+06    -  6.75e-01 1.00e+00f  1
  16 -5.8861909e+07 1.30e+05 2.75e+06  -1.0 3.00e+06    -  2.44e-02 7.50e-02f  1
  17 -6.8252381e+07 1.25e+05 2.72e+06  -1.0 6.30e+07    -  8.98e-03 4.63e-02f  2
  18 -6.7691432e+07 5.47e+02 2.17e+06  -1.0 1.32e+04  -4.0 2.04e-01 1.00e+00h  1
  19 -6.7689998e+07 4.76e-01 2.15e+04  -1.0 1.89e+02  -4.5 9.90e-01 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20 -6.7690000e+07 1.68e-08 2.33e+01  -1.0 2.45e-01  -5.0 9.99e-01 1.00e+00h  1
  21 -7.7035618e+07 3.05e+04 5.41e+04  -3.8 4.62e+08    -  6.81e-03 6.33e-03f  1
  22 -7.7132115e+07 3.01e+04 6.44e+06  -3.8 3.55e+06    -  6.66e-01 1.74e-02h  1
  23 -7.7647090e+07 3.09e+04 8.42e+06  -3.8 3.42e+06    -  8.94e-01 1.00e-01h  1
  24 -7.7699683e+07 8.17e+01 3.90e+03  -3.8 2.07e+04    -  9.89e-01 1.00e+00h  1
  25 -7.7699749e+07 7.87e+01 3.80e+03  -3.8 5.54e+07    -  2.54e-02 8.20e-04h  2
  26 -7.7699755e+07 3.08e+00 3.03e-01  -3.8 2.79e+05    -  1.00e+00 1.00e+00H  1
  27 -7.7700174e+07 1.09e+02 5.94e-03  -3.8 3.03e+05    -  1.00e+00 1.00e+00h  1
  28 -7.7700167e+07 3.00e-02 4.25e-06  -3.8 1.14e+04    -  1.00e+00 1.00e+00h  1
  29 -7.7700500e+07 3.89e+00 3.43e+02  -5.7 9.59e+04    -  9.77e-01 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  30 -7.7700531e+07 4.15e-01 1.39e-03  -5.7 2.29e+04    -  1.00e+00 9.07e-01h  1
  31 -7.7700531e+07 4.98e-04 3.89e-08  -5.7 9.80e+02    -  1.00e+00 1.00e+00f  1
  32 -7.7700536e+07 9.48e-04 2.13e-01  -8.6 1.62e+03    -  1.00e+00 9.99e-01h  1
  33 -7.7700536e+07 5.01e-09 1.08e-10  -8.6 1.88e+00    -  1.00e+00 1.00e+00f  1
  34 -7.7700536e+07 8.38e-09 6.97e-11 -10.9 2.16e+00    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 34

                                   (scaled)                 (unscaled)
Objective...............:  -1.2012103932708919e+02   -7.7700535938862875e+07
Dual infeasibility......:   6.9703904435575171e-11    4.5088110809028537e-05
Constraint violation....:   8.7311491370201111e-11    8.3819031715393066e-09
Complementarity.........:   1.4074777602064815e-11    9.1042982064351105e-06
Overall NLP error.......:   8.7311491370201111e-11    4.5088110809028537e-05


Number of objective function evaluations             = 47
Number of objective gradient evaluations             = 35
Number of equality constraint evaluations            = 47
Number of inequality constraint evaluations          = 47
Number of equality constraint Jacobian evaluations   = 35
Number of inequality constraint Jacobian evaluations = 35
Number of Lagrangian Hessian evaluations             = 34
Total CPU secs in IPOPT (w/o function evaluations)   =      0.022
Total CPU secs in NLP function evaluations           =      0.000

EXIT: Optimal Solution Found.
Optimal solution process results:


Extent of reaction:  269.280544787992
Stoichiometry of each component normalized by the extent:
CH4 :  -0.0
H2 :  -2.0
CH3OH :  1.0
CO :  -1.0
These coefficients should follow 1*CO + 2*H2 => 1*CH3OH

Reaction conversion:  0.8500000099999546
Reactor duty (MW):  -51.363573577545786
Duty from Reaction (MW)): 24.407588579583596
Turbine work (MW):  -1.9904899177794766
Mixer outlet temperature (C)):  20.0517142137536
Compressor outlet temperature (C)):  20.051714213753428
Compressor outlet pressure (Pa)):  5100000.0
Heater outlet temperature (C)):  215.0
Reactor outlet temperature (C)):  231.85000468716584
Turbine outlet temperature (C)):  139.85888172675635
Turbine outlet pressure (Pa)):  1427653.3547820912
Cooler outlet temperature (C)):  52.56999709299214
Flash outlet temperature (C)):  134.0
Methanol recovery(%):  92.80355474657543
annualized capital cost ($/year) = 235547.18924473223
operating cost ($/year) =  451663512.6847628
sales ($/year) =  113381889876.90083
raw materials cost ($/year) = 35229454878.16397
revenue (1000$/year)=  77700535.93886286


====================================================================================
Unit : fs.H2                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units        Outlet  
    Total Molar Flowrate       mole / second     637.20
    Total Mole Fraction CH4    dimensionless 1.0000e-06
    Total Mole Fraction CO     dimensionless 1.0000e-06
    Total Mole Fraction H2     dimensionless     1.0000
    Total Mole Fraction CH3OH  dimensionless 1.0000e-06
    Molar Enthalpy              joule / mole    -142.40
    Pressure                          pascal 3.0000e+06
====================================================================================

====================================================================================
Unit : fs.CO                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Outlet  
    Total Molar Flowrate       mole / second      316.80
    Total Mole Fraction CH4    dimensionless  1.0000e-06
    Total Mole Fraction CO     dimensionless      1.0000
    Total Mole Fraction H2     dimensionless  1.0000e-06
    Total Mole Fraction CH3OH  dimensionless  1.0000e-06
    Molar Enthalpy              joule / mole -1.1068e+05
    Pressure                          pascal  3.0000e+06
====================================================================================

====================================================================================
Unit : fs.EXHAUST                                                          Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Inlet  
    Total Molar Flowrate       mole / second     165.54
    Total Mole Fraction CH4    dimensionless 5.7630e-06
    Total Mole Fraction CO     dimensionless    0.28706
    Total Mole Fraction H2     dimensionless    0.59587
    Total Mole Fraction CH3OH  dimensionless    0.11706
    Molar Enthalpy              joule / mole    -52313.
    Pressure                          pascal 7.4845e+06
====================================================================================

====================================================================================
Unit : fs.CH3OH                                                            Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units          Inlet  
    Total Molar Flowrate       mole / second      249.90
    Total Mole Fraction CH4    dimensionless  1.0000e-08
    Total Mole Fraction CO     dimensionless  1.0000e-08
    Total Mole Fraction H2     dimensionless  1.0000e-08
    Total Mole Fraction CH3OH  dimensionless      1.0000
    Molar Enthalpy              joule / mole -2.3792e+05
    Pressure                          pascal  7.4845e+06
====================================================================================

As expected, the process achieves a much greater revenue as a result of increasing conversion and lowering the inlet temperature to the Flash unit to encourage methanol recovery in the liquid phase. The results show a slight increase in equipment and operating costs from these changes, as well as a small loss of methanol in the exhaust.

4. Problem Statement - Analyzing Benefit of Recycling Flash Vapor#

To increase the efficiency of the process as well as overall methanol production and revenue, we can add a recycle stream to send most of the Flash vapor back to the start of the process. This will reduce methanol loss in the exhaust and increase feed utilization, resulting in increased operating costs and increased production (revenue) at the same conversion. Note that for conversions less than 100%, a simulation with no purge will never converge due to accumulation of gases within the system. Therefore, to ensure we close the mass balance we set a lower bound at 10% purge from the Flash vapor to the exhaust. We expect to see a marginal increase in operating costs due to increased flow, and a much larger increase in overall production resulting in a higher total revenue.

By adding a recycle to the flowsheet, we significantly decrease the tractability of the problem and require a better initial guess. The SequentialDecomposition algorithm automatically determines a stream to tear, or use to break the solve loop, and iterates from a set of user-supplied initial guesses until converging on the optimal solution. The code below calls an initialization method to automatically determine the tear stream. See the initialization method of methanol_flowsheet_w_recycle.py for further details Sequential Decomposition scheme.

For given raw material flows and optimal reactor conditions, we will calculate the extent of reaction, relevant process results including reactor duty and turbine duty, methanol recovery, and relevant economic results including annual revenue.

4.1. Main Inputs:#

  • Raw material inlets (F - mol/s, P - Pa, h - j/mol, x - mole fraction)

  • Pre-reactor compressor outlet pressure (Pa)

  • Pre-reactor heater outlet temperature (K)

4.2. Main Outputs:#

  • Extent of reaction (mol/s)

  • Reactor duty (W)

  • Compressor duty (W)

  • Turbine duty (W)

  • Methanol recovery (%)

  • Purge percentage (%)

  • Annual revenue (USD/year)

from IPython.display import Image

Image("methanol_flowsheet_recycle.png")
../../_images/f7d610f0a8ce188c7783b541e46ccf3c8f07a67cc218e642ffbc2e7432519feb.png

5. Import and Solve Recycle Flowsheet#

5.1 Import Pyomo and IDAES Libraries#

As we are rebuilding the model, we need to import require Pyomo and IDAES libraries:

import pytest
import os

# Import Pyomo libraries
from pyomo.environ import (
    Constraint,
    Objective,
    Var,
    Expression,
    Param,
    ConcreteModel,
    TransformationFactory,
    value,
    maximize,
    units as pyunits,
)
from pyomo.environ import TerminationCondition
from pyomo.network import Arc, SequentialDecomposition

# Import IDAES core libraries
from idaes.core import FlowsheetBlock
from idaes.core.solvers import get_solver
from idaes.core.util import scaling as iscale
from idaes.core.util.model_statistics import degrees_of_freedom
from idaes.core.util.initialization import propagate_state

# Import required models

from idaes.models.properties.modular_properties.base.generic_property import (
    GenericParameterBlock,
)
from idaes.models.properties.modular_properties.base.generic_reaction import (
    GenericReactionParameterBlock,
)

from idaes_examples.mod.methanol import methanol_ideal_VLE as thermo_props_VLE
from idaes_examples.mod.methanol import methanol_ideal_vapor as thermo_props_vapor
from idaes_examples.mod.methanol import methanol_reactions as reaction_props

from idaes.models.unit_models import (
    Feed,
    Mixer,
    Heater,
    Compressor,
    Turbine,
    StoichiometricReactor,
    Flash,
    Separator as Splitter,
    Product,
)
from idaes.models.unit_models.mixer import MomentumMixingType
from idaes.models.unit_models.pressure_changer import ThermodynamicAssumption
from idaes.core import UnitModelCostingBlock
from idaes.models.costing.SSLW import SSLWCosting
import idaes.logger as idaeslog

# import flowsheet functions
from methanol_flowsheet_w_recycle import (
    build_model,
    set_inputs,
    scale_flowsheet,
    initialize_flowsheet,
    add_costing,
    report,
)

5.2 Build and Solve Recycle Flowsheet#

As before, we will first build the flowsheet, set required inputs, initialize and solve a square problem. Recycling methanol to pre-reactor blocks complicates VLE calculations, and limiting VLE calculations to the Flash unit and liquid Product block greatly increases tractability during initialization. All initial feed and unit specifications are identical to the non-recycle case; the Sequential Decomposition algorithm automatically selects the compressor feed as the tear stream and uses “no recycle” results as a first guess. In the output below, the solver solves all units and then resolves select blocks with updated inlet results, followed by a full flowsheet solve:

# Build and solve flowsheet
solver = get_solver()  # IPOPT
optarg = {"tol": 1e-6, "max_iter": 100}
solver.options = optarg

m = ConcreteModel()  # create a new model so we may reference 'm' below
build_model(m)  # build flowsheet
set_inputs(m)  # unit and stream specifications
scale_flowsheet(m)  # flowsheet and unit model level scaling

# let the solver determine the tear stream
initialize_flowsheet(m)  # rigorous initialization scheme

print("DOF before solve: ", degrees_of_freedom(m))
print()
print("Solving initial problem...")
results = solver.solve(m, tee=True)
Unit degrees of freedom
M101 0
C101 1
H101 1
R101 2
T101 2
H102 1
F101 2
M102 0
S101 1
Total DOF:  24
DOF after streams specified:  10
DOF after units specified:  0

Tear Stream:
fs.s02 :  fs.M102.outlet  to  fs.C101.inlet

Calculation order:
fs.H2
fs.M101
fs.R101
fs.T101
fs.H102
fs.F101
fs.S101
fs.EXHAUST

Initial DOF =  0
Solving  fs.H2
DOF =  0
Solving  fs.CO
DOF =  0
Solving  fs.C101
DOF =  0
Solving  fs.M101
DOF =  0
Solving  fs.H101
DOF =  0
Solving  fs.R101
DOF =  0
Solving  fs.T101
DOF =  0
Solving  fs.H102
DOF =  0
Solving  fs.F101
DOF =  0
Solving  fs.S101
DOF =  0
Solving  fs.CH3OH
DOF =  0
Solving  fs.EXHAUST
DOF =  0
Solving  fs.M102
DOF =  0
Solving  fs.H2
DOF =  0
Solving  fs.CO
DOF =  0
Solving  fs.M101
DOF =  0
Solving  fs.EXHAUST
DOF =  0
Solving  fs.CH3OH
DOF =  0
Final DOF =  0
DOF before solve:  0

Solving initial problem...
WARNING: model contains export suffix
'fs.CH3OH.properties[0.0].scaling_factor' that contains 7 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.EXHAUST.properties[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.recycle_state[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.purge_state[0.0].scaling_factor' that contains 4 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.mixed_state[0.0].scaling_factor' that contains 4 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.split.scaling_factor' that
contains 24 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_out[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_in[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.control_volume.scaling_factor'
that contains 1 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.properties_isentropic[0.0].scaling_factor' that contains 8 component
keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_in[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.T101.control_volume.scaling_factor'
that contains 1 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.reactions[0.0].scaling_factor' that contains 1
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_out[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M102.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M102.recycle_state[0.0].scaling_factor' that contains 6 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.M102.feed_state[0.0].scaling_factor'
that contains 6 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.M101.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.CO_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.H2_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.CO.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.H2.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH3OH.scaling_factor' that contains 11 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.H2.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CO.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH4.scaling_factor' that contains 8 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH3OH.scaling_factor' that contains 23 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.H2.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.CO.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH4.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
Ipopt 3.13.2: tol=1e-06
max_iter=100


******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt

This version of Ipopt was compiled from source code available at
    https://github.com/IDAES/Ipopt as part of the Institute for the Design of
    Advanced Energy Systems Process Systems Engineering Framework (IDAES PSE
    Framework) Copyright (c) 2018-2019. See https://github.com/IDAES/idaes-pse.

This version of Ipopt was compiled using HSL, a collection of Fortran codes
    for large-scale scientific computation.  All technical papers, sales and
    publicity material resulting from use of the HSL codes within IPOPT must
    contain the following acknowledgement:
        HSL, a collection of Fortran codes for large-scale scientific
        computation. See http://www.hsl.rl.ac.uk.
******************************************************************************

This is Ipopt version 3.13.2, running with linear solver ma27.

Number of nonzeros in equality constraint Jacobian...:     1211
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:      768

Total number of variables............................:      397
                     variables with only lower bounds:       41
                variables with lower and upper bounds:      333
                     variables with only upper bounds:        1
Total number of equality constraints.................:      397
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  0.0000000e+00 2.79e+04 1.00e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  0.0000000e+00 2.79e+02 4.22e+03  -1.0 1.96e+03    -  9.90e-01 9.90e-01h  1
   2  0.0000000e+00 2.77e+00 3.86e+03  -1.0 2.03e+01    -  9.90e-01 9.90e-01h  1
   3  0.0000000e+00 7.44e-06 1.01e+03  -1.0 2.01e-01    -  9.90e-01 1.00e+00h  1
Cannot recompute multipliers for feasibility problem.  Error in eq_mult_calculator

Number of Iterations....: 3

                                   (scaled)                 (unscaled)
Objective...............:   0.0000000000000000e+00    0.0000000000000000e+00
Dual infeasibility......:   1.0099088928127794e+05    1.0099088928127794e+05
Constraint violation....:   2.4013852159823137e-10    7.4442941695451736e-06
Complementarity.........:   0.0000000000000000e+00    0.0000000000000000e+00
Overall NLP error.......:   2.4013852159823137e-10    1.0099088928127794e+05


Number of objective function evaluations             = 4
Number of objective gradient evaluations             = 4
Number of equality constraint evaluations            = 4
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 4
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 3
Total CPU secs in IPOPT (w/o function evaluations)   =      0.003
Total CPU secs in NLP function evaluations           =      0.002

EXIT: Optimal Solution Found.

5.3 Flowsheet Costing and Optimization#

Now that we have a well-initialized and solved flowsheet, we can add process economics and optimize the revenue. We utilize IDAES costing tools to calculate reactor and flash vessel capital cost, and implement surrogate models to account for heat exchanger capital costs, reactor operating costs and utility costs for heating, cooling and electricity. As before, revenue is determined from total liquid methanol sales, operating costs, annualized capital costs and feed raw material costs. The flowsheet report method returns key process results, which are updated for new results with the presence of a recycle stream:

add_costing(m)  # re-solve with costing equations
print()
results2 = solver.solve(m, tee=True)

print("Initial solution process results:")
report(m)  # display initial solution results

WARNING: model contains export suffix
'fs.CH3OH.properties[0.0].scaling_factor' that contains 7 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.EXHAUST.properties[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.recycle_state[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.purge_state[0.0].scaling_factor' that contains 4 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.mixed_state[0.0].scaling_factor' that contains 4 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.split.scaling_factor' that
contains 24 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_out[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_in[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.control_volume.scaling_factor'
that contains 1 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.properties_isentropic[0.0].scaling_factor' that contains 8 component
keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_in[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.T101.control_volume.scaling_factor'
that contains 1 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.reactions[0.0].scaling_factor' that contains 1
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_out[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M102.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M102.recycle_state[0.0].scaling_factor' that contains 6 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.M102.feed_state[0.0].scaling_factor'
that contains 6 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.M101.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.CO_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.H2_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.CO.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.H2.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH3OH.scaling_factor' that contains 11 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.H2.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CO.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH4.scaling_factor' that contains 8 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH3OH.scaling_factor' that contains 23 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.H2.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.CO.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH4.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
Ipopt 3.13.2: tol=1e-06
max_iter=100
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt

This version of Ipopt was compiled from source code available at
    https://github.com/IDAES/Ipopt as part of the Institute for the Design of
    Advanced Energy Systems Process Systems Engineering Framework (IDAES PSE
    Framework) Copyright (c) 2018-2019. See https://github.com/IDAES/idaes-pse.

This version of Ipopt was compiled using HSL, a collection of Fortran codes
    for large-scale scientific computation.  All technical papers, sales and
    publicity material resulting from use of the HSL codes within IPOPT must
    contain the following acknowledgement:
        HSL, a collection of Fortran codes for large-scale scientific
        computation. See http://www.hsl.rl.ac.uk.
******************************************************************************

This is Ipopt version 3.13.2, running with linear solver ma27.

Number of nonzeros in equality constraint Jacobian...:     1227
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:      772

Total number of variables............................:      406
                     variables with only lower bounds:       49
                variables with lower and upper bounds:      333
                     variables with only upper bounds:        1
Total number of equality constraints.................:      406
Total number of inequality constraints...............:        0
        inequality constraints with only lower bounds:        0
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -2.8497869e+07 9.10e+04 1.00e+02  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -2.9074832e+07 5.76e+04 4.22e+03  -1.0 1.20e+05    -  5.03e-02 9.90e-01h  1
   2 -2.9080637e+07 5.71e+02 3.82e+03  -1.0 5.72e+04    -  9.81e-01 9.90e-01h  1
   3 -2.9080695e+07 5.22e-05 1.00e+03  -1.0 5.67e+02    -  9.90e-01 1.00e+00h  1
   4 -2.9080695e+07 6.98e-10 9.90e+04  -1.0 5.22e-05    -  9.90e-01 1.00e+00h  1
Cannot recompute multipliers for feasibility problem.  Error in eq_mult_calculator

Number of Iterations....: 4

                                   (scaled)                 (unscaled)
Objective...............:  -4.4953175283791907e+01   -2.9080695361147862e+07
Dual infeasibility......:   9.9999999999985807e+06    6.4691081725719443e+12
Constraint violation....:   4.5474735088646412e-12    6.9849193096160889e-10
Complementarity.........:   0.0000000000000000e+00    0.0000000000000000e+00
Overall NLP error.......:   4.5474735088646412e-12    6.4691081725719443e+12


Number of objective function evaluations             = 5
Number of objective gradient evaluations             = 5
Number of equality constraint evaluations            = 5
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 5
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 4
Total CPU secs in IPOPT (w/o function evaluations)   =      0.005
Total CPU secs in NLP function evaluations           =      0.000

EXIT: Optimal Solution Found.
Initial solution process results:


Extent of reaction:  237.60641806045152
Stoichiometry of each component normalized by the extent:
CH4 :  0.0
H2 :  -2.0
CH3OH :  1.0
CO :  -1.0
These coefficients should follow 1*CO + 2*H2 => 1*CH3OH

Reaction conversion:  0.75
Reactor duty (MW):  -45.22029794711383
Duty from Reaction (MW)): 21.536645732999325
Compressor work (MW):  4.9022090500807066e-15
Turbine work (MW):  -0.95937850239144
Feed Mixer outlet temperature (C)):  20.051714213753144
Recycle Mixer outlet temperature (C)):  20.056485612776044
Feed Compressor outlet temperature (C)):  20.056485612776157
Feed Compressor outlet pressure (Pa)):  5100000.0
Heater outlet temperature (C)):  215.0
Reactor outlet temperature (C)):  234.0
Turbine outlet temperature (C)):  192.87840947667905
Turbine outlet pressure (Pa)):  3100000.0
Cooler outlet temperature (C)):  134.0
Flash outlet temperature (C)):  134.0
Purge percentage (amount of vapor vented to exhaust): 99.99  %
Methanol recovery(%):  60.00598493491174
annualized capital cost ($/year) = 219794.2325658716
operating cost ($/year) =  380711692.18370014
sales ($/year) =  64691081725.72809
raw materials cost ($/year) = 35229454878.16397
revenue (1000$/year)=  29080695.36114785


====================================================================================
Unit : fs.H2                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units        Outlet  
    Total Molar Flowrate       mole / second     637.20
    Total Mole Fraction CH4    dimensionless 1.0000e-06
    Total Mole Fraction CO     dimensionless 1.0000e-06
    Total Mole Fraction H2     dimensionless     1.0000
    Total Mole Fraction CH3OH  dimensionless 1.0000e-06
    Molar Enthalpy              joule / mole    -142.40
    Pressure                          pascal 3.0000e+06
====================================================================================

====================================================================================
Unit : fs.CO                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Outlet  
    Total Molar Flowrate       mole / second      316.80
    Total Mole Fraction CH4    dimensionless  1.0000e-06
    Total Mole Fraction CO     dimensionless      1.0000
    Total Mole Fraction H2     dimensionless  1.0000e-06
    Total Mole Fraction CH3OH  dimensionless  1.0000e-06
    Molar Enthalpy              joule / mole -1.1068e+05
    Pressure                          pascal  3.0000e+06
====================================================================================

====================================================================================
Unit : fs.EXHAUST                                                          Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Inlet  
    Total Molar Flowrate       mole / second     336.21
    Total Mole Fraction CH4    dimensionless 2.8375e-06
    Total Mole Fraction CO     dimensionless    0.23555
    Total Mole Fraction H2     dimensionless    0.48181
    Total Mole Fraction CH3OH  dimensionless    0.28263
    Molar Enthalpy              joule / mole    -80218.
    Pressure                          pascal 3.1000e+06
====================================================================================

====================================================================================
Unit : fs.CH3OH                                                            Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units          Inlet  
    Total Molar Flowrate       mole / second      142.58
    Total Mole Fraction CH4    dimensionless  1.0000e-08
    Total Mole Fraction CO     dimensionless  1.0000e-08
    Total Mole Fraction H2     dimensionless  1.0000e-08
    Total Mole Fraction CH3OH  dimensionless      1.0000
    Molar Enthalpy              joule / mole -2.3813e+05
    Pressure                          pascal  3.1000e+06
====================================================================================

Finally, let’s unfix some specifications and determine an optimal revenue. We set bounds on our decision variables to constrain our objective to physical and economically sensible solutions, including a purge between 10-50% of flash vapor. The pre-reactor section mixes the feeds and brings the reactants to optimal temperature and pressure, and we only unfix downstream unit specifications:

# Set up Optimization Problem (Maximize Revenue)
# keep process pre-reaction fixed and unfix some post-process specs
m.fs.R101.conversion.unfix()
m.fs.R101.conversion_lb = Constraint(expr=m.fs.R101.conversion >= 0.75)
m.fs.R101.conversion_ub = Constraint(expr=m.fs.R101.conversion <= 0.85)
m.fs.R101.outlet_temp.deactivate()
m.fs.R101.outlet_t_lb = Constraint(
    expr=m.fs.R101.control_volume.properties_out[0.0].temperature >= 405 * pyunits.K
)
m.fs.R101.outlet_t_ub = Constraint(
    expr=m.fs.R101.control_volume.properties_out[0.0].temperature <= 505 * pyunits.K
)

# Optimize turbine work (or delta P)
m.fs.T101.deltaP.unfix()  # optimize turbine work recovery/pressure drop
m.fs.T101.outlet_p_lb = Constraint(
    expr=m.fs.T101.outlet.pressure[0] >= 10e5 * pyunits.Pa
)
m.fs.T101.outlet_p_ub = Constraint(
    expr=m.fs.T101.outlet.pressure[0] <= 51e5 * 0.8 * pyunits.Pa
)

# Optimize Cooler outlet temperature - unfix cooler outlet temperature
m.fs.H102.outlet_temp.deactivate()
m.fs.H102.outlet_t_lb = Constraint(
    expr=m.fs.H102.control_volume.properties_out[0.0].temperature
    >= 407.15 * 0.8 * pyunits.K
)
m.fs.H102.outlet_t_ub = Constraint(
    expr=m.fs.H102.control_volume.properties_out[0.0].temperature <= 480 * pyunits.K
)

m.fs.F101.deltaP.unfix()  # allow pressure change in streams

m.fs.F101.isothermal = Constraint(
    expr=m.fs.F101.control_volume.properties_out[0].temperature
    == m.fs.F101.control_volume.properties_in[0].temperature
)

m.fs.S101.split_fraction[0, "purge"].unfix()  # allow some gas recycle
m.fs.S101.split_fraction_lb = Constraint(
    expr=m.fs.S101.split_fraction[0, "purge"] >= 0.10
)  # min 10% purge
m.fs.S101.split_fraction_ub = Constraint(
    expr=m.fs.S101.split_fraction[0, "purge"] <= 0.50
)  # max 50% purge

print()
print("Solving optimization problem...")
opt_res = solver.solve(m, tee=True)

print("Optimal solution process results:")
report(m)
Solving optimization problem...
WARNING: model contains export suffix
'fs.CH3OH.properties[0.0].scaling_factor' that contains 7 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.EXHAUST.properties[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.recycle_state[0.0].scaling_factor' that contains 4 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.purge_state[0.0].scaling_factor' that contains 4 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.S101.mixed_state[0.0].scaling_factor' that contains 4 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.F101.split.scaling_factor' that
contains 24 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_out[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.F101.control_volume.properties_in[0.0].scaling_factor' that contains 13
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H102.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.properties_isentropic[0.0].scaling_factor' that contains 8 component
keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.T101.control_volume.properties_in[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.reactions[0.0].scaling_factor' that contains 1
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.R101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_out[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.H101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_out[0.0].scaling_factor' that contains 8
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.C101.control_volume.properties_in[0.0].scaling_factor' that contains 7
component keys that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M102.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M102.recycle_state[0.0].scaling_factor' that contains 6 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.M102.feed_state[0.0].scaling_factor'
that contains 6 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.M101.mixed_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.CO_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.M101.H2_WGS_state[0.0].scaling_factor' that contains 6 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.CO.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.H2.properties[0.0].scaling_factor'
that contains 15 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH3OH.scaling_factor' that contains 11 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.H2.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CO.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_vapor.CH4.scaling_factor' that contains 8 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH3OH.scaling_factor' that contains 23 component keys
that are not exported as part of the NL file.  Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.H2.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix 'fs.thermo_params_VLE.CO.scaling_factor'
that contains 8 component keys that are not exported as part of the NL file.
Skipping.
WARNING: model contains export suffix
'fs.thermo_params_VLE.CH4.scaling_factor' that contains 8 component keys that
are not exported as part of the NL file.  Skipping.
Ipopt 3.13.2: tol=1e-06
max_iter=100
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt

This version of Ipopt was compiled from source code available at
    https://github.com/IDAES/Ipopt as part of the Institute for the Design of
    Advanced Energy Systems Process Systems Engineering Framework (IDAES PSE
    Framework) Copyright (c) 2018-2019. See https://github.com/IDAES/idaes-pse.

This version of Ipopt was compiled using HSL, a collection of Fortran codes
    for large-scale scientific computation.  All technical papers, sales and
    publicity material resulting from use of the HSL codes within IPOPT must
    contain the following acknowledgement:
        HSL, a collection of Fortran codes for large-scale scientific
        computation. See http://www.hsl.rl.ac.uk.
******************************************************************************

This is Ipopt version 3.13.2, running with linear solver ma27.

Number of nonzeros in equality constraint Jacobian...:     1236
Number of nonzeros in inequality constraint Jacobian.:       10
Number of nonzeros in Lagrangian Hessian.............:      779

Total number of variables............................:      410
                     variables with only lower bounds:       49
                variables with lower and upper bounds:      334
                     variables with only upper bounds:        1
Total number of equality constraints.................:      405
Total number of inequality constraints...............:       10
        inequality constraints with only lower bounds:        5
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        5

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0 -2.8497829e+07 2.79e+04 1.00e+02  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -2.8431118e+07 2.74e+04 9.77e+01  -1.0 8.82e+06    -  4.99e-02 1.94e-02h  1
   2 -2.8430711e+07 2.74e+04 7.81e+02  -1.0 8.52e+06    -  3.76e-02 1.99e-04h  1
   3 -2.8524881e+07 2.48e+04 1.61e+05  -1.0 6.46e+06    -  2.49e-04 9.25e-02f  1
   4 -2.8526701e+07 2.48e+04 1.61e+05  -1.0 5.76e+06    -  5.84e-02 9.84e-04h  1
   5 -2.8554187e+07 2.48e+04 1.60e+05  -1.0 1.49e+07    -  3.31e-03 8.96e-04h  1
   6 -2.9123963e+07 2.43e+04 1.52e+05  -1.0 1.49e+07    -  1.23e-01 1.84e-02f  1
   7 -2.9208669e+07 2.43e+04 1.51e+05  -1.0 9.71e+06    -  2.32e-02 2.78e-03h  1
   8 -3.0003106e+07 2.36e+04 1.08e+06  -1.0 9.31e+06    -  1.92e-01 2.61e-02h  1
   9 -3.1468193e+07 2.25e+04 1.09e+06  -1.0 8.71e+06    -  6.69e-02 4.91e-02f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10 -3.1583879e+07 2.24e+04 1.14e+07  -1.0 5.51e+06    -  3.91e-01 3.89e-03h  1
  11 -4.3112060e+07 3.08e+04 5.71e+06  -1.0 5.49e+06    -  1.57e-01 3.86e-01f  1
  12 -4.3711568e+07 4.53e+04 5.09e+06  -1.0 3.67e+06    -  8.46e-02 2.88e-02h  1
  13 -4.3718128e+07 4.53e+04 1.94e+06  -1.0 3.57e+06    -  5.80e-01 3.23e-04h  1
  14 -4.3760522e+07 4.51e+04 4.15e+07  -1.0 3.56e+06    -  4.25e-01 5.93e-03h  1
  15 -4.4646098e+07 7.99e+04 5.37e+07  -1.0 3.54e+06    -  6.75e-01 1.23e-01h  4
  16 -6.6609948e+07 4.70e+04 6.17e+06  -1.0 3.14e+06    -  7.83e-01 9.90e-01H  1
  17 -6.5995574e+07 4.70e+04 3.11e+06  -1.0 2.01e+07    -  3.61e-03 3.25e-03h  5
  18 -6.5244336e+07 4.71e+04 3.13e+07  -1.0 1.74e+07    -  4.59e-05 4.34e-03h  5
  19 -6.4062606e+07 2.26e+03 9.67e+06  -1.0 7.97e+04    -  3.33e-04 9.87e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20 -6.4049002e+07 1.77e+03 8.54e+03  -1.0 2.65e+03    -  9.89e-01 1.00e+00h  1
  21 -6.5078492e+07 1.26e+03 4.14e+05  -1.0 1.04e+05    -  9.50e-01 9.92e-01f  1
  22 -7.5331202e+07 1.38e+05 3.86e+06  -1.0 1.20e+06    -  2.40e-01 1.00e+00f  1
  23 -7.4656453e+07 9.99e+04 2.12e+06  -1.0 1.07e+05  -4.0 9.90e-01 2.77e-01h  1
  24 -7.4647249e+07 9.94e+04 2.08e+06  -1.0 7.74e+04  -4.5 5.39e-01 5.21e-03h  1
  25 -7.4611354e+07 9.73e+04 2.02e+06  -1.0 7.24e+04  -5.0 1.00e+00 2.07e-02h  1
  26 -7.4417188e+07 8.61e+04 1.78e+06  -1.0 7.10e+04  -5.4 5.90e-01 1.15e-01h  1
  27 -7.4386526e+07 8.46e+04 1.75e+06  -1.0 7.83e+04  -5.9 1.23e-02 1.80e-02h  1
  28 -7.2736872e+07 3.01e+02 1.72e+06  -1.0 1.09e+05  -6.4 1.06e-04 1.00e+00h  1
  29 -7.2723082e+07 1.43e-01 6.52e+02  -1.0 5.95e+02  -6.9 1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  30 -7.2723222e+07 7.89e-05 2.09e+01  -1.7 1.63e+02  -7.3 1.00e+00 1.00e+00f  1
  31 -8.6816123e+07 8.68e+03 9.78e+05  -2.5 5.17e+06    -  2.86e-02 5.98e-01f  1
  32 -8.6799976e+07 8.39e+03 5.89e+05  -2.5 1.65e+04  -7.8 9.53e-01 3.34e-02h  1
  33 -8.6300379e+07 1.51e+01 7.15e+04  -2.5 2.25e+04  -8.3 8.28e-02 1.00e+00h  1
  34 -8.6315273e+07 4.51e-03 1.67e+00  -2.5 3.37e+03  -8.8 1.00e+00 1.00e+00h  1
  35 -8.6355832e+07 4.54e-02 7.17e-02  -2.5 1.03e+04  -9.2 1.00e+00 1.00e+00f  1
  36 -8.6484786e+07 3.89e-01 3.04e+03  -5.7 3.04e+04  -9.7 9.89e-01 1.00e+00f  1
  37 -8.6863607e+07 3.35e+00 6.38e-01  -5.7 9.16e+04 -10.2 1.00e+00 9.94e-01f  1
  38 -8.7407007e+07 7.89e+00 3.54e-01  -5.7 2.74e+05 -10.7 1.00e+00 4.78e-01f  1
  39 -9.0728057e+07 2.04e+02 2.21e+00  -5.7 8.01e+05 -11.2 1.00e+00 1.00e+00f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  40 -9.9495392e+07 6.13e+02 3.85e+00  -5.7 2.39e+06 -11.6 1.00e+00 9.06e-01f  1
  41 -9.9495416e+07 6.13e+02 3.85e+00  -5.7 5.53e+06 -12.1 1.07e-01 1.10e-06h  1
  42 -1.0301582e+08 3.81e+04 2.43e+01  -5.7 7.11e+06 -12.6 3.99e-01 1.44e-01f  1
  43 -1.0301583e+08 3.81e+04 3.36e+01  -5.7 1.39e+06    -  6.86e-01 1.25e-06h  2
  44 -1.0436645e+08 3.42e+05 1.56e+01  -5.7 2.02e+06    -  1.00e+00 1.00e+00h  1
  45 -1.0441853e+08 3.22e+05 1.44e+01  -5.7 4.91e+06    -  9.43e-01 7.95e-02h  1
  46 -1.0439096e+08 2.72e+05 1.22e+01  -5.7 1.25e+07    -  2.29e-01 1.53e-01h  1
  47 -1.0436186e+08 2.08e+05 9.28e+00  -5.7 6.35e+05    -  1.00e+00 2.38e-01h  1
  48 -1.0427962e+08 1.89e+04 8.38e-01  -5.7 2.21e+05    -  1.00e+00 9.09e-01h  1
  49 -1.0427372e+08 1.22e+01 8.52e-02  -5.7 2.01e+04    -  1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  50 -1.0427510e+08 3.31e+02 1.55e+00  -5.7 5.86e+04 -13.1 1.00e+00 9.55e-01h  1
  51 -1.0427510e+08 2.94e+02 5.87e+01  -5.7 2.24e+04    -  7.65e-02 1.13e-01f  1
  52 -1.0427509e+08 1.51e-03 1.08e-01  -5.7 8.91e+03    -  1.00e+00 1.00e+00f  1
  53 -1.0427919e+08 3.06e+03 5.51e+01  -5.7 1.66e+05 -13.5 1.00e+00 1.00e+00f  1
  54 -1.0427839e+08 2.40e+03 4.05e+01  -5.7 1.34e+05    -  4.18e-01 2.55e-01h  1
  55 -1.0427605e+08 1.01e+03 2.12e+01  -5.7 9.49e+04    -  4.92e-01 1.00e+00h  1
  56 -1.0427605e+08 6.84e-03 5.30e+01  -5.7 1.43e+03    -  2.80e-01 1.00e+00h  1
  57 -1.0427605e+08 6.92e-04 5.08e-03  -5.7 1.97e+02    -  1.00e+00 1.00e+00h  1
  58 -1.0427606e+08 1.10e-02 4.86e+00  -5.7 3.32e+02 -10.4 4.14e-01 1.00e+00h  1
  59 -1.0427605e+08 2.11e-03 5.96e-01  -5.7 2.09e+02    -  2.89e-01 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  60 -1.0427605e+08 7.75e-05 1.67e-01  -5.7 3.44e+02    -  5.92e-01 1.00e+00h  1
  61 -1.0427606e+08 1.07e-03 3.54e-02  -5.7 1.20e+03    -  4.52e-01 1.00e+00h  1
  62 -1.0427606e+08 1.84e-02 6.27e-02  -5.7 5.23e+03    -  3.18e-01 1.00e+00h  1
  63 -1.0427613e+08 2.01e+00 9.36e-03  -5.7 5.45e+04    -  1.26e-01 1.00e+00h  1
  64 -1.0427676e+08 1.61e+02 1.39e-02  -5.7 6.85e+06    -  8.98e-03 7.04e-02h  3
  65 -1.0427678e+08 1.30e-01 1.17e-04  -5.7 7.26e+02 -10.9 1.00e+00 1.00e+00h  1
  66 -1.0427727e+08 9.59e+01 5.94e-03  -5.7 5.11e+06    -  1.07e-01 6.92e-02h  3
  67 -1.0427802e+08 3.15e+02 6.28e-02  -5.7 5.67e+06    -  4.89e-01 9.21e-02h  2
  68 -1.0427841e+08 3.63e+02 7.79e-02  -5.7 6.06e+06    -  2.53e-01 4.21e-02h  2
  69 -1.0427881e+08 4.10e+02 1.51e-01  -5.7 5.10e+06    -  1.00e+00 4.94e-02h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  70 -1.0427883e+08 1.43e-01 9.49e-05  -5.7 1.47e+04    -  1.00e+00 1.00e+00h  1
  71 -1.0427883e+08 7.08e-03 1.45e-08  -5.7 2.57e+03    -  1.00e+00 1.00e+00h  1
  72 -1.0427884e+08 5.67e-04 5.09e-06  -8.6 1.47e+03    -  1.00e+00 1.00e+00h  1
  73 -1.0427884e+08 1.86e-09 3.49e-13  -8.6 6.91e-01    -  1.00e+00 1.00e+00h  1
  74 -1.0427884e+08 9.31e-10 9.31e-12 -10.9 1.99e+00    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 74

                                   (scaled)                 (unscaled)
Objective...............:  -1.6119507851269793e+02   -1.0427883997850099e+08
Dual infeasibility......:   9.3066982868688585e-12    6.0206037947252707e-06
Constraint violation....:   1.0186340659856796e-10    9.3132257461547852e-10
Complementarity.........:   1.4067955349081809e-11    9.1007124920134500e-06
Overall NLP error.......:   1.0186340659856796e-10    9.1007124920134500e-06


Number of objective function evaluations             = 109
Number of objective gradient evaluations             = 75
Number of equality constraint evaluations            = 109
Number of inequality constraint evaluations          = 109
Number of equality constraint Jacobian evaluations   = 75
Number of inequality constraint Jacobian evaluations = 75
Number of Lagrangian Hessian evaluations             = 74
Total CPU secs in IPOPT (w/o function evaluations)   =      0.060
Total CPU secs in NLP function evaluations           =      0.010

EXIT: Optimal Solution Found.
Optimal solution process results:


Extent of reaction:  311.3069854950048
Stoichiometry of each component normalized by the extent:
CH4 :  0.0
H2 :  -2.0
CH3OH :  1.0
CO :  -1.0
These coefficients should follow 1*CO + 2*H2 => 1*CH3OH

Reaction conversion:  0.8500000099996615
Reactor duty (MW):  -59.34022107299144
Duty from Reaction (MW)): 28.216865165267237
Compressor work (MW):  8.44420706806932e-25
Turbine work (MW):  -2.491301208383534
Feed Mixer outlet temperature (C)):  20.051714213753428
Recycle Mixer outlet temperature (C)):  41.54321437801781
Feed Compressor outlet temperature (C)):  41.54321437801781
Feed Compressor outlet pressure (Pa)):  5100000.0
Heater outlet temperature (C)):  215.0
Reactor outlet temperature (C)):  231.85000478420352
Turbine outlet temperature (C)):  141.50037862881612
Turbine outlet pressure (Pa)):  1487177.2483577346
Cooler outlet temperature (C)):  52.56999699056837
Flash outlet temperature (C)):  134.0
Purge percentage (amount of vapor vented to exhaust): 9.999999000026644  %
Methanol recovery(%):  92.05882105498138
annualized capital cost ($/year) = 259559.90821304667
operating cost ($/year) =  525130020.7095513
sales ($/year) =  140033684437.28275
raw materials cost ($/year) = 35229454878.16397
revenue (1000$/year)=  104278839.978501


====================================================================================
Unit : fs.H2                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units        Outlet  
    Total Molar Flowrate       mole / second     637.20
    Total Mole Fraction CH4    dimensionless 1.0000e-06
    Total Mole Fraction CO     dimensionless 1.0000e-06
    Total Mole Fraction H2     dimensionless     1.0000
    Total Mole Fraction CH3OH  dimensionless 1.0000e-06
    Molar Enthalpy              joule / mole    -142.40
    Pressure                          pascal 3.0000e+06
====================================================================================

====================================================================================
Unit : fs.CO                                                               Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Outlet  
    Total Molar Flowrate       mole / second      316.80
    Total Mole Fraction CH4    dimensionless  1.0000e-06
    Total Mole Fraction CO     dimensionless      1.0000
    Total Mole Fraction H2     dimensionless  1.0000e-06
    Total Mole Fraction CH3OH  dimensionless  1.0000e-06
    Molar Enthalpy              joule / mole -1.1068e+05
    Pressure                          pascal  3.0000e+06
====================================================================================

====================================================================================
Unit : fs.EXHAUST                                                          Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units         Inlet  
    Total Molar Flowrate       mole / second     22.743
    Total Mole Fraction CH4    dimensionless 4.1946e-05
    Total Mole Fraction CO     dimensionless    0.24155
    Total Mole Fraction H2     dimensionless    0.64134
    Total Mole Fraction CH3OH  dimensionless    0.11706
    Molar Enthalpy              joule / mole    -47286.
    Pressure                          pascal 7.4845e+06
====================================================================================

====================================================================================
Unit : fs.CH3OH                                                            Time: 0.0
------------------------------------------------------------------------------------
    Stream Table
                                  Units          Inlet  
    Total Molar Flowrate       mole / second      308.65
    Total Mole Fraction CH4    dimensionless  1.0000e-08
    Total Mole Fraction CO     dimensionless  1.0000e-08
    Total Mole Fraction H2     dimensionless  1.0000e-08
    Total Mole Fraction CH3OH  dimensionless      1.0000
    Molar Enthalpy              joule / mole -2.3792e+05
    Pressure                          pascal  7.4845e+06
====================================================================================

As expected, recycling methanol and gases from the flash vapor achieves much greater methanol production, and process cost increases are small compared to the increase in revenue. Note that the reaction conversion and flash inlet temperature did not change, and we obtain the same percentage methanol recovery. We can see in the stream tables that far more of the inlet material exits as methanol than in the non-recycle process (note that we do not have a mole balance due to the reaction stoichiometry). The results show a slight increase in equipment and operating costs from increased throughput on each unit.

6. Summary#

The present example demonstrates building, initializing and optimizing a methanol synthesis problem in IDAES. The imported scripts implement models from the IDAES pre-defined unit model library, the IDAES Property and Reaction Framework, targeted thermophysical properties for specific unit blocks, Pyomo’s Sequential Decomposition methods, the IDAES Costing Framework for capital cost calculations, and integration of custom surrogate expressions for operating cost calculations. The methanol synthesis flowsheet methods may be imported into any external script, and users may build, initialize and optimize the entire model via the main() method in each flowsheet.