Evaluation of an Open-source Chemical Process Simulator Using a Plant-wide Oil and Gas Separation Plant Flowsheet Model as Basis

In this paper, a detailed evaluation of the open source process simulator DWSIM is presented. Using a previously published simulation model of an oil and gas separation plant, the results obtained with DWSIM are compared to a commercial process simulator widely used in the industry. The modelled flow scheme comprises a vast number of unit operations including separators (flash vessels), valves, splitters, mixers, compressors, heat exchangers, pumps and recycles (tear streams). The results obtained with DWSIM both for characterization of the inlet fluid as well as for a single operating state for the entire process, compare very well with the data obtained using a commercial tool. A rigorous comparison is made and generally, compared results are within 1% in deviation with a few exceptions. Further, an elaborate comparison is made for over 90 simulations with different settings where 10 independent variables are randomly varied over a wide range. Again, good agreement is found between the two tools. The results are very encouraging and provide fidelity in the use of the investigated open source process simulation tools in a professional environment.


Introduction
The chemical process simulator is the workhorse for the modern chemical engineer. It is used widely in a variety of activities such as plant design, troubleshooting, bottleneck identification, equipment sizing and specification, process safety analysis, optimization etc. Many commercial process simulation tools exist each with their specific target markets, advantages and selling points. The term chemical process simulator may cover a rather broad suite of different tools, but in the context of the present paper we will define it as a flow-sheeting software with a graphical user interface, implementing a number of property packages comprising different formulations for describing non-ideal multi-component and multiphase VLE/VLLE as well as relevant transport property models. Furthermore, the simulator shall solve the relevant mass and energy balances and shall provide the most common unit operations for modelling a chemical plant including recycles/tear streams. It is outside the scope to list all available tools [1] but especially Aspen Plus, Aspen HYSYS, Honeywell UniSim Design, AVEVA PRO/II are major players with a substantial market share within steady-state and dynamic process simulations. These tools are widely accepted and used throughout the process industry. However, common to all is the fact that they are closed source and come with a substantial license fee. A large license fee may be prohibitive for students and smaller businesses and the closed source nature is prohibitive for studying the model implementations and debugging problematic and spurious simulation cases.
These two major drawbacks have been addressed by Daniel Wagner Oliveira de Medeiros by providing the free open source sequential modular CAPE-OPEN [2,3] compliant process simulator DWSIM [4]. Previous attempts have been made to provide an open source chemical process simulator such as the Sim42 project [5,6] unfortunately without considerable success. A few simulators are also available for free in the public domain without being fully open source; the COCO [7] simulator and the ALSOC/EMSO simulator [8,9] (free for academic/ non-commercial usage). Also, it shall be a acknowledged that a number of relevant open source projects exist, which provide a subset of the building blocks required to define a complete chemical process simulator, such as e.g. CoolProp [10], Reaktoro [11], Cantera [12], The Chemical Engineering Design Library (ChEDL) [13], thermopack [14] and OpenModelica [15], among others.
The chemical process industry is quite conservative when it comes to accepting new methods and simulation tools. For DWSIM and the like to become a trusted and accepted tool, validation and testing of the code is required. A few studies have been published comparing DWSIM to commercial tools. Tangsriwong et al. [16] modelled parts of a gas compression system both with DWSIM and Aspen Plus and compared the results to a reference case. It was found that the results from DWSIM and Aspen Plus compared well.
Omar et al. [17] simulated a PRICO LNG process using DWSIM and compared estimated COP values to previous work using Aspen Plus. It was concluded that the performance of the two tools was similar, although some details were lacking in order to make a thorough assessment. Nayak et al. [18] compared results obtained with DWSIM, Aspen Plus and a property package implementation in OpenModelica. A few examples involving distillation of water/methanol, ethylene glycol production including distillation of water and glycol/ethylene oxide as well as a conversion reactor (ethanol to ethyl acetate) are shown. Generally, the results of DWSIM and Aspen Plus compare well.
The validations and benchmarks of DWSIM against commercial simulators published in the scientific literature are relatively sparse and the simulation cases contain only a fairly limited amount of unit operations and the model complexity is low to moderate. In this study, we will extend these previous works by providing a more rigorous analysis of DWSIM and make a detailed comparison against a commercial process simulator. A complex model of an oil and gas separation plant containing a vast amount of material/energy streams and unit operations such as valves, separators, pumps, heat exchangers and compressors previously published [19] will be used as basis for a plant wide approach [20].

Methods and model description 2.1 Flowsheet and process description
The model implemented is mimicking an oil and gas separation plant and is based on a HYSYS simulation file included in a previous publication [19]. The model has been rebuilt in DWSIM and the simulation flowsheet is visualized in Fig. 1.
The well fluid is separated into oil and gas through three separators: first stage separator, 20-VA-01, the second stage separator, 20-VA-02, and the third stage separator, 20-VA-03. The well fluid is conditioned in the inlet heat exchanger, 20-HA-01 before separation. The temperature in the third stage separator is controlled by the second inter-stage heater, 20-HA-03. The separated oil is routed via a crude cooler, 21-HA-01, to the oil export pump, 21-PA-01.
The flash gas from each separation stage is compressed to a pressure equal to that from the previous separation stage and commingled with the flash gas from this stage. The gas from the third stage separator is routed via the LP (3 rd stage) compressor suction cooler, 23-HA-03, to the LP compressor suction scrubber, 23-VG-03. Liquid condensate is pumped by the condensate recycle pump, 23-PA-01, and discharged upstream of the third stage separator and second inter-stage heater. The gas from the scrubber is compressed in the LP compressor, 23-KA-03, and the compressed gas is mixed with the flash gas from the second stage separator, 20-VA-02. The mixed gas is cooled in the MP compressor suction cooler, 23-HA-02, and routed to the MP (2 nd stage) compressor suction scrubber, 23-VG-02, where condensed liquid is knocked out and commingled with the liquid from the second stage separator as well as condensate from the condensate recycle pump, 23-PA-01. The gas from the MP compressor suction scrubber is compressed in the MP compressor, 23-KA-02, and commingled with the gas from the first stage separator, 20-VA-01. The blended gas is further commingled with condensate from the LT knock-out drum, 25-VG-01 (part of the dew point control unit), before being cooled in the HP (1 st stage) compressor suction cooler, 23-HA-01, and with subsequent condensate knock-out in the HP compressor suction scrubber, 23-VG-01.
The compressed gas is cooled in the dehydration inlet cooler, 24-HA-01, before being routed to the dew point control unit. Gas downstream 24-HA-01 is used as fuel gas. The gas is further processed in the dew point control unit, including heat exchangers 25-HA-01 and 25-HA-02. The former is used for heat recovery with cross exchange with the dew point controlled dry gas, and 25-HA-02 is a simple cooler assumed to be cooled by a refrigerant. The cooled gas is routed to the LT knock-out drum, 25-VG-01, where the condensed liquid is routed to 23-HA-01/23-VG-01. The cold dew point controlled gas is used for cooling of the hydrocarbon wet gas in the heat exchanger 25-HA-01 before being further pressurized in the export compressor 27-KA-01. Before leaving the facilities, the gas is cooled in the export gas cooler, 27-HA-01. The key settings applied in the simulation are summarised in Table 1. All pumps and compressors have been specified with an adiabatic and polytropic efficiency, respectively, of 75%. Equipment pressure drops are only specified for heat exchangers as detailed in [19].

Fluid description and simulation settings
For the comparison, Aspen HYSYS v11 is used and DWSIM v6.7.0.
The composition of the well fluid modelled both in [19] and in the present work is taken from [21]. The well fluid contains CO 2 and simple alkanes from methane and up, and from C7+ the heavy fraction of the well fluid is characterized by 8 pseudo-components/hypotheticals. The Peng-Robinson equation of state is applied [22] with both liquid density and thermodynamic departure functions being calculated using the equation of state. This is a change from the original source [19], where COSTALD liquid density [23] was applied as well as Lee-Kesler for the departure functions. The change of liquid density was made, since DWSIM does not implement COSTALD but uses Rackett for liquid density 1 .
The 8 pseudo-components included have been specified by molecular weight and liquid density and with critical properties and acentric factors estimated by Twu's [24,25] methods. The estimated properties have been used as input for the pseudo-components, instead of using the built-in methods in DWSIM, for consistency between the two simulation models. The pseudo-component properties are listed in Table 2.
1 This has been included in the most recent version of DWSIM. DWSIM does currently not have an implementation of an RVP calculation routine following e.g. ASTM D323-73/79. In order to provide an RVP value of the oil export stream for comparison with the HYSYS, a python unit operation script is added. The python script adjusts the vapor pressure of the export stream at 37.8 °C in order for the gas volume to be exactly 4 times the liquid volume.
The two tools have different ways and granularity for setting calculation tolerances e.g. for recycle operations where details down to component level can be specified in HYSYS, but only for total flow in DWSIM. Generally, for the mass balance the error in recycle blocks are below 1 kg/h in both HYSYS and DWSIM and any significant discrepancies are considered not to be due to mass balance errors.

Parametric study
To further test DWSIM beyond a single converged simulation state, a parametric study is set up, exploring similarities and differences over a wider range of parameter settings. In order to efficiently conduct the parametric study in both DWSIM and HYSYS, a python wrapper is made for both simulation tools in a similar fashion as previous studies [19,26,27]. The parametric study is made by random/Monte Carlo sampling using the lhsmdu [28,29] package over 10 independent variables/factors. The independent variables and their bounds are shown in Table 3. A sampling plan is made using 100 samples and both sampling plans are run using a python wrapper around both HYSYS and DWSIM.

Results
The first comparison made is with respect to the modelling of the fluid phase behavior. Key parameters are compared in Table 4. The results are obtained for the stream "Well fluid" as shown in Fig. 1, with temperature and pressure adjusted to standard conditions. As seen from  the results, DWSIM calculates slightly lower liquid density and slightly higher gas molecular weight, although the modelled properties in the two simulators match very well. The gas-oil-ratio (GOR) is also very well matched.
The largest difference is seen on the critical properties. For comparison, the phase envelope calculated with the two simulators is shown in Fig. 2.
A comparison is made between the gas and oil export between DWSIM and HYSYS. The results are summarized in Table 5. As seen from the results, the two simulators provide almost equal results.
A comparison is made for the power consumption for all the main mechanical drivers in the process: LP compressor, 23-KA-03, MP compressor, 23-KA-02, HP compressor, 23-KA-01, Export compressor 27-KA-01 and the oil export pump 21-PA-01. The results are shown in Fig. 3. Again, the match is very good with the largest deviation slightly above 1% for the MP compressor duty.
For comparison of the implemented models for calculating compressor discharge temperatures according to a polytropic model, the calculated compressor discharge temperatures using both DWSIM and HYSYS are compared in Fig. 4. As seen from Fig. 4, the calculated temperatures compare very well.
The calculated duties for the various heat exchangers are compared in Fig. 5. Generally, the results are very similar. A few results stand out with slightly higher differences   Phase envelope is calculated both in HYSYS and DWSIM  For these two, the deviation is −5.8% and −3.9%, respectively. That being said, in absolute numbers the difference is moderate (30 kW and 24 kW). One reason for the interstage heater to show larger deviation can be explained by the fact that 20-HA-03 has a very small temperature difference (1.9 °C in DWSIM). Even a small difference in the inlet stream will result in a relatively large deviation. The same can be argued for 25-HA-02 which also has a relatively small temperature difference (4.7 °C). All the other heat exchangers have a significantly higher temperature difference and thus a smaller relative deviation. In addition to the rigorous comparison of a single operating point shown in the previous text, a more elaborate comparison is made for 100 randomly selected simulations where 10 independent variables are varied as described in the Methods section.
The dependent variables/responses compared between HYSYS and DWSIM are the export liquid molar flow rate, the main power consumption estimated as the sum of 21-PA-01 23-KA-01, 23-KA-02, 23-KA-03, 27-KA-01, cf. Fig. 3, and the calculated RVP of the liquid export. For analysis of results, the software stack of numpy [30], pandas [31], seaborn [32] and statsmodels [33] is applied. During the calculation of the 100 samples, 9 samples were un-converged in DWSIM (sample indexes 24,47,52,54,55,60,65,93,96 in the generated DACE provided as a part of the supplementary information). A few samples also displayed unexpected deviations between HYSYS and DWSIM, and these samples were manually re-run. The 91 converged samples/simulation cases are analyzed in more detail in Figs. 6-8 and Table 6.
As seen from the results, there is generally good agreement between the two simulation tools. It is noticed that apparently the export liquid flow rate is the response with the poorest correlation as judged from R 2 , but both power and RVP responses have larger RMSE of approx. 0.5%. While the deviation is noted, all responses generally have solid statistics.

Conclusion
The comparison made between the open source chemical process simulator DWSIM and a commercial (closed source) counter-part Aspen HYSYS shows that very little differences are observed. A detailed simulation flowsheet of an oil and gas separation plant has been used as basis for the comparison including a vast amount of different unit operations. Except for a few parameters, the difference observed is typically less than 1%. This result is very encouraging and actually an enormous achievement considering the number of models and equations that needs to be implemented and needs to provide results, which are very similar e.g. equation of state, PT flash algorithm, PH flash algorithm, PS flash algorithm, compressor model, heat exchanger model, pump model -just to mention some.
The availability of a high-quality open source process simulator has many potential applications. One is for academic purposes, for students to learn the inner workings and model implementations and for students and researchers to implement their own models and methods. For usage in the industry, an open source process simulator also adds opportunities currently not present. For instance, massively parallel calculations implemented on a computer cluster (bare metal or virtual) are either not possible with the existing commercial tools, or the license structure may be prohibitive. Using an open source simulator as DWSIM, which is cross platform and can be deployed unlimited on compute nodes, this is now realizable. An open source process simulator can also enable global flowsheet optimization studies from brute-force [34] to evolutionary algorithms, which require a high number of flowsheet evaluations from 1,000-100,000 flowsheet evaluations often taking excessive time to converge [27,35,36]. Such studies may need long running times and would otherwise utilize a substantial amount of an available license pool, limiting other work.
Compared to the commercial counter-part, DWSIM only solved 91% of the simulation cases in the defined parametric study. The remaining cases were un-converged, thus leaving room for some future improvement. As a side note and not presented in more detail, a legacy external FORTRAN dynamic linked library developed by late Prof. Michelsen [37][38][39] implementing a flash algorithm using the Peng-Robinson equation of state was used as an alternative to the built-in flash algorithm in DWSIM, but only for calculating the phase split/compositions.
It is interesting to note that all 100 cases solved using Michelsen's algorithm plugged into DWSIM. While not a direct proof, at least this indicates that the problem does not reside in the general flowsheet solver for converging the mass and energy balances but could be related to a slight instability in the calculated phase splits. This should be investigated in more detail.

Acknowledgement
Language secretary Susanne Tolstrup, Process & Technical Safety Department, Ramboll Energy, Field Development is acknowledged for proof-reading this manuscript.

Supplementary information
The simulation files and scripts, which have formed the basis of the present paper, are publicly available on GitHub [40] as well as the random computer experiment design and the sample simulation output.