# 7. Connecting CHEMCAD to a Machine Learning Model on the Wolfram Cloud

Published: 20 June 2024| Version 2 | DOI: 10.17632/ch7yy7xbgz.2
Contributors:
,
,
,
,

## Description

We previuosly provided examples of connecting Mathematica to CHEMCAD or Aspen Plus. In References 1-3, we showed how to connect CHEMCAD to Mathematica using Link for Excel, with all software running locally on the desktop computer. References 4 and 5 explain how to deploy Mathematica models to the cloud. Once deployed to the cloud, functions can be accessed over the internet from Excel, which in turn is connected to CHEMCAD through data mapping. Reference 6 extends the procedure to Aspen Plus. This data set further extends the study to supervised machine learning models. As an example problem, we chose a membrane model for an air separation process [7-8]. The membrane unit is well-mixed on the retentate and permeate sides of the membrane. The feed to the membrane unit is fully specified and split by the membrane into retentate and permeate streams. There are many ways to develop a machine-learning model for this problem, and five different methods are provided here, described below. Method 1 (Proof of concept): Supervised learning with single variable linear regression applied separately to each output. The method in Mathematica uses the “Predict” function, which accepts a list of associations between one input and one output. For example, {{a1➝b1}, {a2➝b2}, etc.}. Because of this input-output structure, “Predict” was used five times to generate five output functions, one for each output. Only one input was varied, the others being held constant, as shown here, with only area changing. For example, for output x1 (retentate mole fraction), the input-output structure changes as follows: {{nF1, PR1, PR1, A1} ➝ x1}, {nF2, PR2, PR2, A2} ➝ x2}, etc.} ⇨ {{A1 ➝ x1}, {A2 ➝ x2}, etc.} This creates the input-output structure needed by “Predict.” We used the model in Ref. 5 to generate a table of data that was then entered into Mathematica to train the model. The training data are provided in the Excel data map worksheet. The trained functions were then deployed to the cloud and called from CHEMCAD. The model is not very flexible because the feed flow rate, retentate, and permeate pressures are fixed. However, the results are interesting because a wide range of AI and machine learning tools are available in the Wolfram language that could extend this technique to more general situations. Neural Net Methods: Method 2: More general model than Method 1. Neural net trained with 1000 simulations generated from the model of Reference 3. All input variables simultaneously generated from random number generators, set to the range of values tabulated below. The trained neural net is called locally from CHEMCAD with Link. Input Min Max nF 3,300 3,400 PR 140 160 PP 14 16 A 18,000 22,000 Method 3: Same as Method 2 but trained with 5000 simulations. Method 4: Same as Method 2, trained with 1000 simulations, but with result deployed to cloud.\ Method 5: Same as Method 4, trained with 5000 simulations, with result deployed to cloud.