2.2.2. Aspen–MATLAB Linking

The proposed methodology exploits the full potential and relevance of multi-software modeling via linking Aspen Plus ® software (Aspen Plus ® V10, Aspen Technology Inc., Bedford, MA, USA) with MATLAB ® software (MATLAB ® 2020a, The MathWorks Inc., Natick, MA, USA). While the state-of-the-art simulation engine of Aspen Plus ® provides swift and rigorous results due to the sequential modular algorithm, its use in evaluation of large datasets containing numerous di fferent variables is somewhat laborious. On the other hand, the programming language of the MATLAB software is tailored for handling such tasks. Thus, an e ffort to link these two software environments persists. Fontalvo et al. [54] introduced the idea of software linking in the early 2000s, though no details were presented. Several years later, in 2014, Fontalvo described the linking principles [53]; however, these are of limited relevance today. Other authors have continued working on the idea with different aims or providing insufficient details. A MATLAB® sub-software, Simulink, was used by Dos Santos Vidal et al. [60] and Ryu et al. [61] to solve rather complicated automation problems. Muñoz et al. [57] used MATLAB®-to-Aspen linking in a gradient-based multi-objective optimization via ACSII file exchange with Aspen Plus® working in the equation-oriented mode. The published freeware by Abril [76] caused a breakthrough with instructions for component object model (COM) interface linking. Following this publication, several papers [58,59,77,78] were published providing scarce information about the interface build and utilization. Even though the works of Ramirez et al. [56] and Darkwah et al. [55] contain specific programming tips, these are rather unclear to a non-advanced user. Hence, to this day, a simple but complex interface linking methodology remains elusive. Details regarding the program capabilities and the linking procedure are presented in the following text.


**Table 2.** Considered measured data. Legend: BL = battery limit, CHP = combined heat and power plant, HPS = high-pressure steam, MPS = middle-pressure steam.

Aspen Plus® cooperation with external Windows applications is enabled via ActiveX Automation Server. In this way, the applications can interact with Aspen Plus® through a programming interface while the automation server exposes objects through the COM object model [79]. Through this interface it is possible:


As the original user guide for Aspen Plus® is written for the Visual Basic programming language, a simple step-by-step manual for Aspen–MATLAB linking is presented:


**Figure 3.** Example of Aspen Plus®–MATLAB® link utilization (for details see Appendix A).

	- a. Simulation control Syntax: var.command (e.g., var.Run2, var.Reinit, ... )
	- b. User interface control Syntax: var.attribute = value (e.g., var.Visible = 1, ... )
	- c. Input alteration Syntax: var.Tree.Findnode(path).Value = value\_a
	- d. Results gathering Syntax: value\_b = var.Tree.Findnode(path).Value

All commands can be found in Appendix A or in Figure 3. The path to every individual variable of the simulation in Aspen Plus® can be accessed directly in the program via: Customize→ Variable explorer.

• Prior to launching the simulation, it is sensible to also link MATLAB to Excel for more flexible operation via simple and useful inbuilt functions "xlsread" and "xlswrite" enabling reading and writing data from and to the Excel spreadsheet, respectively, without the need for opening the data file manually. An example can be seen in Figure 3.
