<jupyter_start><jupyter_text>Fit $k_{ij}$ and $r_c^{ABij}$ interactions parameter of Ethanol and CPMEThis notebook has te purpose of showing how to optimize the $k_{ij}$ and $r_c^{ABij}$ for a mixture with induced association.First it's needed to import the necessary modules<jupyter_code>import numpy as np

from sgtpy import component, mixture, saftvrmie
from sgtpy.fit import fit_cross<jupyter_output><empty_output><jupyter_text>Now that the functions are available it is necessary to create the mixture.<jupyter_code>ethanol = component('ethanol2C', ms = 1.7728, sigma = 3.5592 , eps = 224.50,
                    lambda_r = 11.319, lambda_a = 6., eAB = 3018.05, rcAB = 0.3547,
                    rdAB = 0.4, sites = [1,0,1], cii= 5.3141080872882285e-20)

cpme = component('cpme', ms =  2.32521144, sigma = 4.13606074, eps = 343.91193798, lambda_r = 14.15484877, 
                 lambda_a = 6.0, npol = 1.91990385,mupol = 1.27, sites =[0,0,1], cii = 3.5213681817448466e-19)

mix = mixture(ethanol, cpme)<jupyter_output><empty_output><jupyter_text>Now the experimental equilibria data is read and a tuple is created. It includes the experimental liquid composition, vapor composition, equilibrium temperature and pressure. This is done with ```datavle = (Xexp, Yexp, Texp, Pexp)```<jupyter_code># Experimental data obtained from <NAME>, J. Chem. Eng. Data, vol. 64, no. 5, pp. 1970–1977, 2019

# Experimental temperature saturation in K
Texp = np.array([355.77, 346.42, 342.82, 340.41, 338.95, 337.78, 336.95, 336.29,
       335.72, 335.3 , 334.92, 334.61, 334.35, 334.09, 333.92, 333.79,
       333.72, 333.72, 333.81, 334.06, 334.58])

# Experimental pressure in Pa
Pexp = np.array([50000., 50000., 50000., 50000., 50000., 50000., 50000., 50000.,
       50000., 50000., 50000., 50000., 50000., 50000., 50000., 50000.,
       50000., 50000., 50000., 50000., 50000.])

# Experimental liquid composition
Xexp = np.array([[0.   , 0.065, 0.11 , 0.161, 0.203, 0.253, 0.301, 0.351, 0.402,
        0.446, 0.497, 0.541, 0.588, 0.643, 0.689, 0.743, 0.785, 0.837,
        0.893, 0.947, 1.   ],
       [1.   , 0.935, 0.89 , 0.839, 0.797, 0.747, 0.699, 0.649, 0.598,
        0.554, 0.503, 0.459, 0.412, 0.357, 0.311, 0.257, 0.215, 0.163,
        0.107, 0.053, 0.   ]])

# Experimental vapor composition
Yexp = np.array([[0.   , 0.302, 0.411, 0.48 , 0.527, 0.567, 0.592, 0.614, 0.642,
        0.657, 0.678, 0.694, 0.71 , 0.737, 0.753, 0.781, 0.801, 0.837,
        0.883, 0.929, 1.   ],
       [1.   , 0.698, 0.589, 0.52 , 0.473, 0.433, 0.408, 0.386, 0.358,
        0.343, 0.322, 0.306, 0.29 , 0.263, 0.247, 0.219, 0.199, 0.163,
        0.117, 0.071, 0.   ]])

datavle = (Xexp, Yexp, Texp, Pexp)<jupyter_output><empty_output><jupyter_text>The function ```fit_cross``` optimize the $k_{ij}$ correction and $r_c^{ABij}$ distance. An initial guess is needed, as well as the mixture object, the index of the self-associating component and the equilibria data.<jupyter_code>#initial guesses for kij and rcij
x0 = [0.01015194, 2.23153033]
fit_cross(x0, mix, assoc=0, datavle=datavle)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15876089060987417, 'fraction_numerical': 0.22039367537915455, 'mean_word_length': 3.161073825503356, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '2273', 'license': 'MIT', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1221, 'n_words': 344, 'path': "examples/SGTPy's paper notebooks/Fit Equilibrium Ethanol + CPME.ipynb", 'repo_name': 'MatKie/SGTPy', 'size': '3106'}