Once SolMod.jl is installed, it can be loaded using:

using SolMod

Importing Parameters

We import our parameters from .xlsx files that contain the dataframe necessary to produce a solubility calculation. This format is used to exploit the use of sheets as the parameters for different solvents. The first sheet contains the calorimetric data of the enantiomeric molecule and the racemate:

fusΔHTmfusΔH_racTm_rac
24,500404.6525,600387.75

The data frame is imported as a dictionary to the workspace. When specifying parameters of 3 components, the function will automatically import the calorimetric properties of the racemate as well:

params = NRTL_importParameters(dir, 3)

params["Solute"] = 24500  404.65  25600  387.75

The parameters specify the interaction values determined from either experimental or predicted values. Interaction parameters are model specific, in this case we will use those defined by the NRTL model:

⍺_1⍺_2⍺_3g_1g_2g_3
00.980.400216,63125,269
0.9800.40141,8790
0.400.400-3,235.60-3,235.600

The dataframe is imported as a dictionary with the key entry labelled as the solvent used:

params["Solvent"]["⍺"] = [0         0.979748  0.40104
                          0.979748  0         0.40104
                          0.40104   0.40104   0      ]

params["Solvent"]["g"] = [0       216631  25269
                          141879  0       25269
                          -3235.6 -3235.6 0    ]
Note

Although SolMod.jl imports parameters from .xlsx files, nothing stops you from creating the parameter dataframes directly in Julia. Parameters in SolMod.jl are read as dictionaries. Examples like the one above are shown to demonstrate the output of the import function and how to replicate it yourself.

Binary Curve

With the parameters imported, we can use the model to determine the activity coefficient. We want to predict a solubility curve for the S-enantiomer. The curve will range from $298 K$ to $334 K$ and an initial guess of the composition:

NRTL_solubilityCurve(params, [298, 334], "Solvent", guess = 0.12, components = 3)

We can also obtain an error analysis using SolMod.jl. We will get an output of the residuals from the experimental data and the RMSD (Root Mean Square Deviation). The RMSD of predicted values $\hat{x}$ for times a with variables observed over $A$ times, is computed for $A$ different predictions as the square root of the mean of the squares of the deviations:

\[RMSD = \sqrt{\dfrac{\sum_{a=1}^A{(\hat{x}_a - x_a)^2}}{|A|}}\]

errorAnalysis(model, experimental, 2)

Ternary Phase Diagram

Now we can do what this software was created for and predict ternary phase behaviour. We want to start by defining the method we will use to calculate the activity coefficient for component i (S-enantiomer) and for component j (R-enantiomer). For example calculating the activity coefficient using the NRTL model at $298 K$ :

γi() = NRTL_activityCoefficient(params, "Solvent", 298)
γj() = NRTL_activityCoefficient(params, "Solvent", 298, e = false)

Once the activity coefficient methods are set, we want to check solubility over every possible point at a specific temperature using the ternaryPhase function:

model = ternaryPhase(params, γi, γj, 298)

Similar to before we can obtain the error analysis related to the ternary phase diagram with the same function as before but increasing the number of components to 3:

errorAnalysis(model, experimental, 3)

Next Steps

After this is done, we can either plot the diagrams inside Julia using TernaryPlots.jl or using PyCall to plot with Matplotlib or Plotly.

If Julia is not your software of choice for plotting, then you can make use of SolMod's export features an save the dataframe created as an .xlsx file:

exportTernaryPhase(model, "TPD.xlsx")

This process can then be repeated across multiple temperatures and using different activity coefficient methods. One of the goals of this project was modularity. The many ways to obtain the activity coefficient requires the user to employ various methods to obtain accurate predictions. By separating the method to obtain the activity coefficient with the prediction of solubility we give the user the freedom to experiment with the calculations.

After learning the basic usage of this software you can read a more thorough analysis with results using the jupyter notebooks in the notebook examples section, read more on the various models available, or export an existing method to calculate the activity coefficient.