CHAPTER 4: COMPUTATIONAL METHODS
4.2 Development of a Computational Framework
4.2.1. Software selection 88
This section briefly describes the type of knowledge and some of the tools needed to develop a reliable simulation module. Some of the key requirements for the development of a computational tool to assess the overall performance of a solvent include:
1. A database of chemicals associated with the pharmaceutical industry including the various solvents, products, by-products, and impurities for the system under investigation.
89
2. Thermodynamic models that can predict the physical and chemical properties of all the components required in the various computations, including multiphase equilibria calculations.
3. Process models and algorithms that can perform the required solvent evaluations and process synthesis calculations for crystallisation.
4. An automated means to perform multiple calculations.
5. A means to record the results from multiple calculations as structured data sets for analysis.
The first two criteria already exist in many commercial software simulators, such as CHEMCAD, Aspen Plus, Hysys, Pro II, etc. These allow for user defined compounds as well as values of experimentally measured properties, such as binary interaction parameters, to be added into the component database. Chemical process simulators have become reliable tools that are widely used in process engineering. Process simulators contain strict models for most chemical process units, robust numerical algorithms for particular units, and large databases of physicochemical thermodynamic and transport properties. The capability of process simulators can make modelling and optimization of the process easier, while complex calculations can be carried out quickly by a process simulator. Nevertheless, resetting the input parameters to evaluate a range of scenarios can be time consuming, and storage of the multiple simulation results for comparative studies can be challenging.
The developers of commercial process simulation software have created various interfacing options to extend the capabilities and applications of the software. An interface serves as a technical and semantic bridge that allows reading from, and writing to the objects of another software package. But, depending on the purpose of the system, objects can be found on either side of the interface and the objects of a process simulator will differ in meaning to those of adjacent programs. Hence, an important requirement for the design of an interface lies in the standardization of meaning.
A technical bridge from the interface can be implemented by means of a file or data transfer, function calls or shared objects. The key benefit of interfacing is that it allows for the objects in the process simulator to be used beyond its boundaries. For example, CHEMCAD developers have created various interfacing options: between Microsoft Excel and CHEMCAD; between The Design Institute for Physical Properties (DIPPR) databank and CHEMCAD; and between the Dortmund Data Bank (DDBST) and CHEMCAD (Fricke and Schöneberger, 2015). In addition, CHEMCAD also allows a user to develop their own process models that can integrated into any simulation.
90
The CHEMCAD user-defined process models are developed with VBA (Visual Basic for Application) programming language and are hence named VBA Unit Operations. These interfacing facilities now extend computational capabilities by allowing the resetting of input parameters, thus managing the operations of the process simulator. And, as the storage capacity of MS Excel is practically unlimited, it is an ideal, interfacing, complementary tool for the process simulator.
As a result, it was decided to exploit the interfacing capability of CHEMCAD, and to use it to construct a solvent selection tool. This was accomplished by developing an internal, interfacing VBA module embedded within the process simulator. The details of the VBA module is described in the following sections.
4.2.2. Computational Framework
A novel, modular, integrated computational framework is developed to simulate crystallisation process synthesis and optimization. The modular integrated framework integrates CHEMCAD, a VBA Module (with various crystallisation sub-routines) and Excel. The key criterion for the modular integrated framework is the accurate exchange of data between the VBA module algorithms, the CHEMCAD simulation algorithms and Excel. The specified and calculated variables extracted from the CHEMCAD simulation platform are dictated by, and used in the VBA platform, in this study. In the framework, the various calculations for the crystallisation processes are based on the CHEMCAD multiphase flash calculation simulation model. The extraction and processing of necessary data is then implemented by the VBA module. The overall framework, and the interactions of the VBA module with the various components of CHEMCAD and Excel, is shown in Figure 4.1.
This approach, of developing and integrating this VBA module within the commercial simulation programme CHEMCAD, has several advantages. The computations within the VBA modules have access to a full range of thermodynamic models and correlations, a comprehensive database of compounds and their pure and mixture properties, and rigorous, computational algorithms for process calculations and equipment design. In addition, software vendors regularly deliver updates for their programs to fix bugs and to deliver new functionality, including the updating and inclusion of new properties, thermodynamic models and methods. CHEMCAD also provides for user defined components to be added into its database. The VBA modules are integrated into CHEMCAD via a VBA unit operation; and an intuitive and user-friendly dialogue screen, built into a visual basic platform, allows users to send information into the VBA unit operation.
91
Figure 4.1. Components of the integrated computational framework.
The mutual connection between CHEMCAD and MS Excel is created by a VBA unit operation.
A master/slave architecture is adopted, where a series of calculations, as dictated by the VBA module, are carried out systematically with the help of this software connection. The input, feed- stream parameters for every simulation are always set in MS Excel and transferred into CHEMCAD via the VBA Module. When the required computation is completed by the process simulator, the internal variables are further processed and updated within the VBA module sub- routines for the next calculation loop. The next calculation loop may be a change in the operation conditions, or a new component to be evaluated. The desired set of results, either for each calculation loop or at the end of a complete simulation, are transferred back to MS Excel. At the end of the calculations, the initial parameters and the calculation results are displayed in a structured form in the MS Excel file. Thus, the operational database of the crystallisation process is created. The resulting database enables us to define/analyse the optimum and highlight the unfavourable operating range of the system. This typical structure of the various sub-routines is illustrated in Figure 4.2.
92
Figure 4.2. An Example of a Typical Sub-Routine and Its Communication Pathways.
To illustrate this interface and the two way communication between Excel – VBA Module and CHEMCAD, some examples of code statements and their functions in the various sub-routines of the VBA module) are presented in Table E.1. In addition, an example of the many sub- routines that make up the computational framework is presented in Appendix E.
4.4.3. The VBA Module
The heart of the computational solvent selection tool is the VBA module, which not only provides the necessary instructions to CHEMCAD, but has over 30 sub-routines that compute various calculations to fulfil its purpose as a complete conceptual design tool. The VBA module meets the following desired software development requirements: its models are appropriate for purpose, in terms of rigor, level of detail, accuracy, validity and generality; the algorithms are robust, generalizable, and efficient in terms of execution and storage; the software is easy to understand, maintain and modify, and it is transportable; and the user interface readily accepts input, and presents results in a useable form.
93
The Solvent Selection Tool, developed in this work, is capable of computing various outputs associated with crystallisation. Outputs include the prediction of the eutectic temperatures and compositions in the system. It can create various types of phase diagrams and solubility curves that allow the user to examine the overall composition space, to visualize crystallisation regions, to identify separation barriers, and to evaluate the various operations. The operations, such as heating, cooling, solvent addition, solvent removal, anti-solvent addition, and their combinations, can thereby be studied in order to systematically evaluate process alternatives.
The pivotal calculation tool is the multicomponent, multiphase, flash-calculation algorithm, which is presented in chapter 3. The operational protocols of the crystallisation process, to achieve the desired targets, are determined by conditions that lead to the formation of a solid phase, the extent to which a solid phase will continue, under varying temperatures and liquid phase compositions, to crystallise prior to the next solid phase forming. The methodology that is used to establish these protocols is presented in Figure 4. 3.
Figure 4. 3. Algorithm for the analysis of crystallisation to determine operating protocols.
The full computational capabilities of the VBA module are summarised in Figure 4.4. The VBA module consists of 32 sub-routines (150 pages of VBA code). Each of the calculations listed in Figure 4.4 may involve multiple sub-routines with multiple iterative CHEMCAD calculations.
94
Whilst some of the computational outputs present as a single answer after completing several iterations, e.g., run cool down will determine the yield at a specified temperature, others will output a matrix of results for a range of input variables for further analysis. A detailed description of the various menus and calculation capabilities of the developed computational tool is presented in Appendix B.
95 Figure 4.4. Computational Capabilities of the VBA Module developed.
96 | P a g e