Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy)

4
Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy) i n d u s t r IAL g o r i t h m s LLC. (IAL) www.industrialgorithms.com May 2014 Introduction Presented in this document is a short description on how to construct a flowsheet or superstructure using the open-source Dia as the drawing tool (similar to Microsoft Visio) and the open-source Python as the programming language to write out the construction data of the flowsheet into a UPS file. The benefit of using a drawing package such as Dia is that it is a graphical or visual representation of the construction and connectivity data of the industrial optimization problem (IOP) with respect to its flow network, graph or diagram i.e., nodes and directed arcs. The alternative is to configure or populate the structures, shapes or objects in a spreadsheet or data file which can be problematic and difficult to interpret i.e., “a picture is worth a thousand words”. Flowsheet and UOPSS A flowsheet is a common term used in chemical engineering to describe the nodes and directed arcs of a graph, network or superstructure and is widely used in process design simulators. The IMPL flowsheet is similar but in order to more comprehensively model or construct flowsheets suitable for advanced planning and scheduling (APS), advanced production/process control (APC) and advanced production/process monitoring (APM) applications for example, we use the Unit-Operation-Port-State Superstructure (UOPSS) found in Kelly 2004, 2005, Zyngier and Kelly, 2009, 2012 and Kelly and Zyngier 2015. Figure 1. UOPSS Sheet and Shapes in Dia.

description

Presented in this document is a short description on how to construct a flowsheet or superstructure using the open-source Dia as the drawing tool (similar to Microsoft Visio) and the open-source Python as the programming language to write out the construction data of the flowsheet into a UPS file. The benefit of using a drawing package such as Dia is that it is a graphical or visual representation of the construction and connectivity data of the industrial optimization problem (IOP) with respect to its flow network, graph or diagram i.e., nodes and directed arcs. The alternative is to configure or populate the structures, shapes or objects in a spreadsheet or data file which can be problematic and difficult to interpret i.e., “a picture is worth a thousand words”.

Transcript of Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy)

Page 1: Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy)

Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy)

i n d u s t r IAL g o r i t h m s LLC. (IAL)

www.industrialgorithms.com May 2014

Introduction Presented in this document is a short description on how to construct a flowsheet or superstructure using the open-source Dia as the drawing tool (similar to Microsoft Visio) and the open-source Python as the programming language to write out the construction data of the flowsheet into a UPS file. The benefit of using a drawing package such as Dia is that it is a graphical or visual representation of the construction and connectivity data of the industrial optimization problem (IOP) with respect to its flow network, graph or diagram i.e., nodes and directed arcs. The alternative is to configure or populate the structures, shapes or objects in a spreadsheet or data file which can be problematic and difficult to interpret i.e., “a picture is worth a thousand words”. Flowsheet and UOPSS A flowsheet is a common term used in chemical engineering to describe the nodes and directed arcs of a graph, network or superstructure and is widely used in process design simulators. The IMPL flowsheet is similar but in order to more comprehensively model or construct flowsheets suitable for advanced planning and scheduling (APS), advanced production/process control (APC) and advanced production/process monitoring (APM) applications for example, we use the Unit-Operation-Port-State Superstructure (UOPSS) found in Kelly 2004, 2005, Zyngier and Kelly, 2009, 2012 and Kelly and Zyngier 2015.

Figure 1. UOPSS Sheet and Shapes in Dia.

Page 2: Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy)

Figure 1 provides a list of the various UOPSS shapes available in Dia and these can be arranged in any arbitrary topological order where the unit-operation shapes can only be connected to in- and out-port-state shapes and out-port-states (upstream) can only be connected to in-port-states (downstream) as further described below. Dia and UOPSS As shown above in Figure 1, Dia provides the ability to create customized drawing objects or shapes and to collect them into a sheet similar to a stencil in Microsoft Visio. It provides the capability to add or configure custom properties or extra attributes assigned to each object and IMPL uses this to configure the various UOPSS names and types directly within Dia. Figure 2 shows a simple flowsheet with an inbound “Supply” perimeter and an outbound “Demand” perimeter (unit) for a “Feed” and a “Product” (operation) respectively. There are two internal streams from the unit-operations to/from the port-states and one external stream from the out-port-state “out” to the in-port-state “in”. This is a simple supply-demand chain flowsheet given that there is no production or transportation value-add i.e., no pools, processes, pipelines, etc.

Figure 2. Simple Supply-Demand Chain Flowsheet with no Value-Add. There are certain construction rules or protocols that are now described using this simple flowsheet as illustration. Rule #1 - units and ports must have non-blank names. Operation and state names can be left blank but unit and port names must be populated else a red “NULL” will appear as shown in Figure 3 if we do not configure the name “Supply” for the first perimeter unit. Essentially we are ensuring that the “physical” network (unit-ports) is completely configured whereas the “procedural” network (operation-states) can be partially configured. The cross-product or combination of the two networks forms what we call the “projectional” superstructure.

Figure 3. Rule #1 Violated. Rule #2 - port-states must be connected to at least one and only one unit-operation. A port-state must be connected to a unit-operation else a red “NEGLECTED” will appear as shown in Figure 4 if we do not connect it to one (and only one) unit-operation shape. Connecting the same port-state pair shape instance to multiple unit-operation shape instances in the Dia flowsheet is possible i.e., no warning/error assertion will be raised but this should not be done.

Page 3: Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy)

Figure 4. Rule #2 Violated. Rule #3 - out-port-states may only be connected to in-port-states and must be connected at both ends (head/tail, from/to and source/destination). An out-port-state must be connected to an in-port-state at both ends else a red “NEGLECTED” will appear as shown in Figure 5. As mentioned in Rule #2, a port-state must be connected to only one unit-operation but it does not necessarily need to be connected to an upstream or downstream port-state i.e., the unit-operation-port-state tuple has an in- or out-degree of zero (0). This is why only the external stream is highlighted and not also the in-port-state in Figure 5.

Figure 5. Rule #3 Violated. There are two other rules for the construction of the flowsheet as follows however these rules are not strictly enforced in Dia although they will be highlighted by IMPL during the interfacing, interacting, modeling and presolving stages. Rule #4 - port-state pairs must be unique locally on a unit-operation, and Rule #5 - unit-operation pairs must be unique globally in a problem. IALConstructer.py and Python 2.3 The code behind which cycles or loops through all of the Dia objects and extracts the flowsheet details or UOPSS structures with the custom attributes and writes out the UPS file (Appendix A) is called IALConstructer.py where its source code is available as part of the IMPL installation and is provided “as-is” according to the open-source licensing agreements. Unfortunately the Dia scripting language is coded in Python 2.3 only where later versions of Python can fortunately co-exist with the earlier Python 2.3 version. The IALConstructer.py source code also provides three (3) IML aliases: “ALLPARTS” for unit-operation pairs or duples, “ALLINPORTS” and “ALLOUTPORTS” for unit-operation-port-state quadruples (internal streams) and “ALLPATHS” for unit-operation-port-state-unit-operation-port-state octuples (external streams). These aliases are useful to configure the capacity data and other model and cycle data quickly and easily in the IML file. References

Page 4: Constructing the IMPL Flowsheet Using Dia with Python (IMPL-FlowsheetDiaPy)

Kelly, J.D., "Production modeling for multimodal operations", Chemical Engineering Progress, February, 44, (2004). Kelly, J.D., "The unit-operation-stock superstructure (UOSS) and the quantity-logic-quality paradigm (QLQP) for production scheduling in the process industries", In: MISTA 2005 Conference Proceedings, 327, (2005). Zyngier, D., Kelly, J.D., "Multi-product inventory logistics modeling in the process industries", In: W. Chaovalitwonse, K.C. Furman and P.M. Pardalos, Eds., Optimization and Logistics Challenges in the Enterprise", Springer, 61-95, (2009). Zyngier, D., Kelly, J.D., "UOPSS: a new paradigm for modeling production planning and scheduling systems", ESCAPE 22, June, (2012). Kelly, J.D., Zyngier, D., "Unit operation nonlinear modeling for planning and scheduling applications", K.C. Furman et.al. (eds.), Optimization and Analytics in the Oil & Gas Industries, Springer Science, (2015). Industrial Algorithms LLC., “Industrial Modeling & Programming Language (IMPL) Installation Manual”, IAL-IMPL-IMW-1-0.docx. Appendix A – SimpleFlowsheet.UPS File

i M P l (c)

Copyright and Property of i n d u s t r I A L g o r i t h m s LLC.

checksum,10

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Unit-Operation-Port-State-Superstructure (UOPSS) *.UPS File.

! (This file is automatically generated from the Python program IALConstructer.py)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

&sUnit,&sOperation,@sType,@sSubtype,@sUse

Demand,Product,perimeter,,

Supply,Feed,perimeter,,

&sUnit,&sOperation,@sType,@sSubtype,@sUse

! Number of UO shapes = 2

&sAlias,&sUnit,&sOperation

ALLPARTS,Demand,Product

ALLPARTS,Supply,Feed

&sAlias,&sUnit,&sOperation

&sUnit,&sOperation,&sPort,&sState,@sType,@sSubtype

Demand,Product,in,,in,

Supply,Feed,out,,out,

&sUnit,&sOperation,&sPort,&sState,@sType,@sSubtype

! Number of UOPS shapes = 2

&sAlias,&sUnit,&sOperation,&sPort,&sState

ALLINPORTS,Demand,Product,in,

ALLOUTPORTS,Supply,Feed,out,

&sAlias,&sUnit,&sOperation,&sPort,&sState

&sUnit,&sOperation,&sPort,&sState,&sUnit,&sOperation,&sPort,&sState

Supply,Feed,out,,Demand,Product,in,

&sUnit,&sOperation,&sPort,&sState,&sUnit,&sOperation,&sPort,&sState

! Number of UOPSPSUO shapes = 1

!&sUnit,&sOperation,&sPort,&sState,&sUnit,&sOperation,&sPort,&sState

Supply,Feed,out,,Demand,Product,in,

!&sUnit,&sOperation,&sPort,&sState,&sUnit,&sOperation,&sPort,&sState

&sAlias,&sUnit,&sOperation,&sPort,&sState,&sUnit,&sOperation,&sPort,&sState

ALLPATHS,Supply,Feed,out,,Demand,Product,in,

&sAlias,&sUnit,&sOperation,&sPort,&sState,&sUnit,&sOperation,&sPort,&sState