CCSI-Toolset / FOQUS

FOQUS: Framework for Optimization and Quantification of Uncertainty and Surrogates
https://foqus.readthedocs.io
Other
46 stars 54 forks source link

Process Family Design Project and Costing Plugin #1113

Closed boverhof closed 3 months ago

boverhof commented 1 year ago

Description

Testing the Process Family Design Project and Costing Plugin.

TODOs

Steps

Navigate to your desired installation location for IDAES in your Anaconda shell and follow the installation instructions for idaes-pse.

boverhof commented 1 year ago

Aspen12 VM

IDAES GIT versions

(foqus) C:\Users\Administrator\Desktop\idaes-pse>idaes --version
idaes, version 2.0.0.dev3

(foqus) C:\Users\Administrator\Desktop\idaes-pse>pyomo  --version
Pyomo 6.5.0 (CPython 3.8.13 on Windows 10)

Copy Costing Plugin from Box

(foqus) C:\Users\Administrator\Desktop>cp "C:\Users\Administrator\Downloads\Prepare for AWS\Prepare for AWS\CCS_costing_plugin.py" josh_working_dir\user_plugins\

(foqus) C:\Users\Administrator\Desktop>dir josh_working_dir\user_plugins
 Volume in drive C has no label.
 Volume Serial Number is 0805-9A66

 Directory of C:\Users\Administrator\Desktop\josh_working_dir\user_plugins

02/27/2023  05:49 PM    <DIR>          .
02/27/2023  05:49 PM    <DIR>          ..
02/27/2023  05:49 PM            58,332 CCS_costing_plugin.py
08/04/2022  03:19 PM                 0 __init__.py
               2 File(s)         58,332 bytes
               2 Dir(s)  16,483,315,712 bytes free

(foqus) C:\Users\Administrator\Desktop>

Plugins DEBUG/INFO messages

boverhof commented 1 year ago

Run Flowsheet Error

2023-02-27 18:13:08,078 - DEBUG - foqus.foqus_lib.framework.sim.turbineConfiguration - turbine configuration application url="http://localhost:8000/TurbineLite/application/"
2023-02-27 18:13:08,078 - DEBUG - foqus.foqus_lib.framework.sim.turbineConfiguration - turbine configuration url="http://localhost:8000/TurbineLite"
c:\users\administrator\desktop\idaes-pse\idaes\core\base\property_set.py:73: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if self._idx is not "none":  # pylint: disable=E1101
WARNING: Could not locate the 'ipopt' executable, which is required for solver
    ipopt
Exception in thread Thread-14:
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\graph.py", line 873, in run
    self.solve()
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\graph.py", line 1034, in solve
    self.runGraph(order)
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\graph.py", line 1345, in runGraph
    elif self.runNode(name) != 0:
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\graph.py", line 1357, in runNode
    node.runCalc()
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\node.py", line 1303, in runCalc
    self.runModel()
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\node.py", line 1324, in runModel
    self.runPymodelPlugin()
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\node.py", line 1372, in runPymodelPlugin
    self.pyModel.run()
  File "C:\Users\Administrator\Desktop\josh_working_dir\user_plugins\CCS_costing_plugin.py", line 1285, in run
    results = solver.solve(m, tee=True)
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\pyomo\opt\base\solvers.py", line 513, in solve
    self.available(exception_flag=True)
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\pyomo\opt\solver\shellcmd.py", line 139, in available
    raise ApplicationError(msg % self.name)
pyomo.common.errors.ApplicationError: No executable found for solver 'ipopt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\ProgramData\Anaconda3\envs\foqus\lib\site-packages\foqus_lib\framework\graph\graph.py", line 882, in run
    _log.exception("Exception in graph thread: %s" % (self.ex))
TypeError: not all arguments converted during string formatting
2023-02-27 18:13:10,875 - ERROR - foqus.foqus_lib.gui.main.mainWindow - to results graph thread was likely terminated
boverhof commented 1 year ago

Solver available Test

>>> from idaes.core.solvers import get_solver
>>> solver = get_solver()
>>> solver
<pyomo.solvers.plugins.solvers.IPOPT.IPOPT object at 0x000001A8AEA67640>
>>> solver.available()
False
lbianchi-lbl commented 1 year ago

@boverhof Are the IDAES solvers installed? https://idaes-pse.readthedocs.io/en/2.0.0b2/tutorials/getting_started/windows.html#install-idaes-extensions

bpaul4 commented 1 year ago

@boverhof have you tested directly installing the IDAES extensions, as suggested above? Please let me know if you encounter further obstacles setting up the environment or Python packages.

boverhof commented 1 year ago

IPOPT Solver Available

(foqus) C:\Users\Administrator\Desktop>python Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 05:59:00) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from idaes.core.solvers import get_solver solver = get_solver() solver.available() True solver <pyomo.solvers.plugins.solvers.IPOPT.IPOPT object at 0x0000018581851790>

boverhof commented 1 year ago

PerformanceWarning: DataFrame is highly fragmented

boverhof commented 1 year ago

LowConcentration Flowsheet Runs on OVIRT/VM Aspen12

Screen Shot 2023-03-06 at 8 27 20 AM

Output

Screen Shot 2023-03-06 at 8 32 24 AM
bpaul4 commented 1 year ago

@boverhof great! I'm glad the file is working as expected. When you have a moment, could you please share the file and results with me? Thank you!

boverhof commented 1 year ago

LowConcentration_FullSample

Screen Shot 2023-03-06 at 11 01 15 AM
boverhof commented 1 year ago

HighConcentration Success

Screen Shot 2023-03-06 at 11 34 50 AM
boverhof commented 1 year ago

AWS VM

Successfully built bunch Installing collected packages: webencodings, wcwidth, Send2Trash, ply, pickleshare, mpmath, mistune, ipython-genutils, fastjsonschema, bunch, backports.shutil-get-terminal-size, backcall, xlrd, widgetsnbextension, Werkzeug, webcolors, uri-template, traitlets, tornado, tinydb, tinycss2, sympy, soupsieve, sniffio, rfc3986-validator, rfc3339-validator, pyzmq, pywinpty, python-json-logger, pyrsistent, pyomo, pycparser, prompt-toolkit, prometheus-client, pkgutil-resolve-name, pint, parso, pandocfilters, nest-asyncio, lxml, jupyterlab-widgets, jupyterlab-pygments, jsonpointer, itsdangerous, importlib-resources, fqdn, et-xmlfile, distro, defusedxml, decorator, debugpy, bleach, terminado, rbfopt, qtpy, pandas, openpyxl, omlt, matplotlib-inline, jupyter-core, jsonschema, jedi, flask, comm, cffi, beautifulsoup4, arrow, anyio, nbformat, jupyter-server-terminals, jupyter-client, isoduration, ipython, flask-cors, argon2-cffi-bindings, nbclient, ipykernel, argon2-cffi, qtconsole, nbconvert, jupyter-events, jupyter-console, ipywidgets, jupyter-server, notebook-shim, nbclassic, notebook, jupyter, idaes-pse Attempting uninstall: pandas Found existing installation: pandas 1.5.0 Uninstalling pandas-1.5.0: Successfully uninstalled pandas-1.5.0

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\tools\Anaconda3\envs\foqus\Lib\site-packages\~andas\_libs\algos.cp38-win_amd64.pyd' Consider using the --user option or check the permissions.

boverhof commented 1 year ago

Two TurbineApp nodes Error

boverhof commented 1 year ago

Change Flowsheet CCS_costing_plugin

>>> import json
>>> sd = json.load(open('C:\\Users\\Administrator\\Downloads\\Prepare for AWS\\Prepare for AWS\\LowConcentration.foqus'))
>>> sd['flowsheet']['nodes']['CCS_costing']
{'modelType': 1, 'modelName': 'CCS_costing_plugin', 'x': 0.0, 'y': -100.0, 'z': 0.0, 'scriptMode': 'post', 'pythonCode': '', 'calcError': -1, 'options': {'order': [], 'options': {}}, 'turbApp': ['AspenPlus', 'aspenfile'], 'turbSession': None, 'synced': True}
>>> sd['flowsheet']['nodes']['CCS_costing']['turbApp'] = None
>>> fd = open('C:\\Users\\Administrator\\Downloads\\Prepare for AWS\\Prepare for AWS\\LowConcentration.foqus', 'w')
>>> json.dump(sd, fd)
>>> fd.close()
>>> sd = json.load(open('C:\\Users\\Administrator\\Downloads\\Prepare for AWS\\Prepare for AWS\\LowConcentration.foqus'))
>>> sd['flowsheet']['nodes']['CCS_costing']
{'modelType': 1, 'modelName': 'CCS_costing_plugin', 'x': 0.0, 'y': -100.0, 'z': 0.0, 'scriptMode': 'post', 'pythonCode': '', 'calcError': -1, 'options': {'order': [], 'options': {}}, 'turbApp': None, 'turbSession': None, 'synced': True}
>>> quit()
boverhof commented 1 year ago

Missing Plugin on FOQUS Cloud Worker

2023-03-08 01:48:23,811 - DEBUG - foqus.foqus_lib.framework.graph.graph - Turbine Result Generator Results LEN: 1
2023-03-08 01:48:23,811 - ERROR - foqus.foqus_lib.framework.graph.graph - Job(32792c39-0d2b-41af-acda-461fffbd361b) Error: Flowsheet Error: ['Traceback (most recent call last):\n', '  
File "c:\\users\\administrator\\desktop\\foqus\\foqus_lib\\framework\\graph\\graph.py", line 873, in run\n
    self.solve()\n', '  File "c:\\users\\administrator\\desktop\\foqus\\foqus_lib\\framework\\graph\\graph.py", line 1034, in solve\n
    self.runGraph(order)\n',
 '  File "c:\\users\\administrator\\desktop\\foqus\\foqus_lib\\framework\\graph\\graph.py", line 1345, in runGraph\n
    elif self.runNode(name) != 0:\n', 
'  
File "c:\\users\\administrator\\desktop\\foqus\\foqus_lib\\framework\\graph\\graph.py", line 1357, in runNode\n   
 node.runCalc()\n', '  
File "c:\\users\\administrator\\desktop\\foqus\\foqus_lib\\framework\\graph\\node.py", line 1303, in runCalc\n
    self.runModel()\n', '  File "c:\\users\\administrator\\desktop\\foqus\\foqus_lib\\framework\\graph\\node.py", line 1324, in runModel\n    self.runPymodelPlugin()\n',
 '  File "c:\\users\\administrator\\desktop\\foqus\\foqus_lib\\framework\\graph\\node.py", line 1365, in runPymodelPlugin\n
    self.pyModel = self.gr.pymodels.plugins[self.modelName].pymodel_pg()\n', "KeyError: 'CCS_costing_plugin'\n"]

2023-03-08 01:48:24,249 - DEBUG - foqus.foqus_lib.gui.main.mainWindow - stopSim SingleRun: {
'solTime': 0, 'input': {'graph': {}, 'CCSI_MEAModel': {'ABSDIAM': 1, 'ABSPACKHT': 30, 'STRDIAM': 1, 'STRPACKHT': 25, 'CO2LEANLOADING': 0.2, 'LEANRICHHXAREASPEC': 80, 'LEANSOLVENTTEMP': 40, 'FLUEGASINTEMP': 40, 'STRPRESSURE': 185, 'FLUEGASINFLOW': 2000, 'FLUEGASFRACCO2': 0.05, 'FLUEGASFRACO2': 0.084, 'FLUEGASFRACH2O': 0.086, 'FLUEGASFRACN2': 0.78}, 'CCS_costing': {'Absorber.Volume': 22.5538944, 'Absorber.Packing_Volume': 22.1028165, 'Stripper.Volume': 3.22889153, 'Stripper.Packing_Volume': 3.1643137, 'Condenser.Area': 0.936174117, 'Stripper.Reboiler_Area': 1.35659952, 'LeanRichHX.Area': 52.034442, 'LeanSolventCooler.Area': 1.13815527, 'CO2Product.Flow': 1152.69703, 'FlueGas.Flow': 2002.0657, 'NetPlantPower': 650, 'Utilities.Water': 86.623102, 'Utilities.Steam': 879.971152, 'Utilities.Solvent': 1.75976342, 'Utilities.Electricity': 72.7716987, 'CE_Index.Year': 2018}}, 'output': {'graph': {'error': -1}, 'CCSI_MEAModel': {'ABSVOLUME': 0, 'ABSPACKVOL': 0, 'STRVOLUME': 0, 'STRPACKVOL': 0, 'CONDENSERAREA': 0, 'STRREBAREA': 0, 'LEANRICHHXAREA': 0, 'COOLERAREA': 0, 'CO2PRODFLOW': 0, 'FLUEGASFLOW': 0, 'RATEWATER': 0, 'RATESTEAM': 0, 'RATEMEA': 0, 'RATEELECTRICITY': 0, 'CO2FRACCAP': 0, 'ABSFRACFLOOD': 0, 'STRFRACFLOOD': 0, 'LEANSOLVFLOW': 5796.48792, 'QREB': 347712.253, 'SRD': 3.35810066, 'status': 0}, 'CCS_costing': {'Absorber.Total_Plant_Cost': 1.3886593705269759, 'Absorber.Packing.Total_Plant_Cost': 1.203395894325608, 'Stripper.Total_Plant_Cost': 0.20634864588003515, 'Stripper.Packing.Total_Plant_Cost': 0.15770819055219565, 'Stripper.Condenser.Total_Plant_Cost': 0.00894523073157076, 'Stripper.Reboiler.Total_Plant_Cost': 0.042815990775907316, 'LeanRichHX.Total_Plant_Cost': 0.11411726654844366, 'LeanSolventCooler.Total_Plant_Cost': 0.031603827573924874, 'FlueGasBlower1.Total_Plant_Cost': 0, 'FlueGasBlower2.Total_Plant_Cost': 0.016680830876214244, 'FlueGasDirectContactCooler1.Total_Plant_Cost': 0.05906082360728565, 'FlueGasDirectContactCooler2.Total_Plant_Cost': 0, 'FlueGasDirectContactCooler1.Packing.Total_Plant_Cost': 0.07328818635677407, 'FlueGasDirectContactCooler2.Packing.Total_Plant_Cost': 0.03868227160087614, 'PretreatmentPump1.Total_Plant_Cost': 0.007862035923562593, 'PretreatmentPump2.Total_Plant_Cost': 0, 'PretreatmentCooler1.Total_Plant_Cost': 0, 'PretreatmentCooler2.Total_Plant_Cost': 0.004149664823885809, 'PretreatmentTank1.Total_Plant_Cost': 0.0036196502024322826, 'PretreatmentTank2.Total_Plant_Cost': 0.001910489250600892, 'WashingColumn1.Total_Plant_Cost': 0.11061339650873707, 'WashingColumn2.Total_Plant_Cost': 0.05838290806674986, 'WashingColumn1.Packing.Total_Plant_Cost': 0.080177198032371, 'WashingColumn2 .Packing.Total_Plant_Cost': 0.04231836404556815, 'WashingColumn1.Cooler.Total_Plant_Cost': 0.002685546924385242, 'WashingColumn2 .Cooler.Total_Plant_Cost': 0.0014174597665748557, 'WashingColumn1.SolventPump.Total_Plant_Cost': 0.0006616564886166539, 'WashingColumn2 .SolventPump.Total_Plant_Cost': 0.000349229217851776, 'Condenser1.Pump.Total_Plant_Cost': 0.0013622339471519344, 'Condenser2 .Pump.Total_Plant_Cost': 0.0007190013308713036, 'Stripper1.RefluxDrum.Total_Plant_Cost': 0.0017903646162568281, 'Stripper2.RefluxDrum.Total_Plant_Cost': 0.0032663203316724934, 'LeanSolventPump1.Total_Plant_Cost': 0, 'LeanSolventPump2.Total_Plant_Cost': 0, 'SolventStorageTank1.Total_Plant_Cost': 0.013310971712170331, 'SolventStorageTank2.Total_Plant_Cost': 0.007025670147371023, 'WashingSolventTank1.Total_Plant_Cost': 0.0017903646162568281, 'WashingSolventTank2.Total_Plant_Cost': 0.0009449731777165704, 'SolventStripperReclaimer1.Total_Plant_Cost': 0.007044695555271432, 'SolventStripperReclaimer2.Total_Plant_Cost': 0.0037182640253630274, 'SolventReclaimerCooler1.Total_Plant_Cost': 0.007005774585352805, 'SolventReclaimerCooler2.Total_Plant_Cost': 0.0036977211301952757, 'SolventFiltration1.Total_Plant_Cost': 0.03370555994953072, 'SolventFiltration2.Total_Plant_Cost': 0.017790147215272827, 'TPC': 3.8975757737963006, 'Utilities.Water': 0.08656566413033356, 'Utilities.Steam': 0.05654235740578879, 'Utilities.Solvent': 0.16280820375746133, 'Utilities.Electricity': 0.038248804836724035, 'TotalCost.Capital': 0.1296586669958502, 'TotalCost.Fixed': 3.2882849999999997, 'TotalCost.Variable': 0.3441650301303077, 'TotalCost.PerElectricity': 71.63979975508192, 'TotalCost.PerCapture': 734.4190131575258}}, 'graphError': 19, 'nodeError': {'CCSI_MEAModel': -1, 'CCS_costing': -1}, 'nodeSettings': {'CCSI_MEAModel': {'Visible': False, 'Initialize Model': False, 'Reset': False, 'Reset on Fail': True, 'Retry': False, 'Allow Simulation Warnings': True, 'Max consumer reuse': 90, 'Maximum Wait Time (s)': 1440, 'Maximum Run Time (s)': 840, 'Min Status Check Interval': 4, 'Max Status Check Interval': 5, 'Override Turbine Configuration': 'NULL'}, 'CCS_costing': {}}, 'turbineMessages': {'CCSI_MEAModel': 'NULL', 'CCS_costing': 'NULL'}, 'input_vectorvals': {}, 'output_vectorvals': {'CCSI_MEAModel': {}, 'CCS_costing': {}, 'LowConc': {}},
 'session': 'e899fc3c-f98e-4749-916e-69bc00ed365a', 'Id': '32792c39-0d2b-41af-acda-461fffbd361b', 'resub': 0
}