Regress binary interaction parameters using MATLAB and write to CHEMCAD

Binary interaction parameters and MATLAB

Vapor liquid equilibrium (VLE) thermodynamic models use binary interaction parameters (BIPs) to determine thermodynamic behavior.

CHEMCAD can only use either VLE or LLE to calculate binary interaction parameters.

The prediction can be improved using a combination of different types of experimental data, e.g. vapor liquid equilibrium plus excess enthalpies. MATLAB can do this.

The code snippet shows how to write binary interaction parameters to CHEMCAD. The snippet does not show how to regress BIPs.

%Code snippet to read and write Binary Interaction Parameters
%from CHEMCAD flowsheet through MATLAB. To get
%Binary Interaction parameters from CHEMCAD using CCAPI, the
%thermodynamic model should be selected first in CHEMCAD flowsheet.
 
 
%Path to load the CCAPI DLL
CCAPI = NET.addAssembly('D:\..\CGC.CC-API.dll');
 
%Put your .NET Interface key here

license_key='.......'

%Starting CHEMCAD Server

chemcad = CCAPI.Server(license_key);
 
%Path to the CHEMCAD flowsheet
path='D:\..\Flash.cc7';
 
%Loading the CHEMCAD flowsheet to MATLAB
chemcad.LoadFlowsheet(path);
flowsheet=chemcad.CurrentFlowsheet;
 
 
%Components Collection
compCollection=flowsheet.Components;
 
%First Component in the chemcad flowsheet
firstComponent=compCollection.GetComponentAt(0);
 
%Second Component in the chemcad flowsheet
secondComponent=compCollection.GetComponentAt(1); 
 
%Read the Binary Interaction Parameters of the selected components
bipValues=firstComponent.GetBinaryInteractionParameters(secondComponent);
 
%Writing Binary interaction parameters to the MATLAB
%command window
Bij=bipValues.Get(0)
Bji=bipValues.Get(1)
Alpha=bipValues.Get(2)
Aij=bipValues.Get(4)
Aji=bipValues.Get(5)
Cij=bipValues.Get(6)
Cji=bipValues.Get(7)
 
%Changing first Binary interaction parameter value
bipValues.Set(0,45)
 
 
%Use Put Binary Interaction parameters to pass modified
%parameter to CHEMCAD
firstComponent.PutBinaryInteractionParameters(secondComponent,bipValues)
 
 
%GetBIP after changing one BIP Value
bipValues=firstComponent.GetBinaryInteractionParameters(secondComponent);
 
%Writing the modified parameter to the command window
Bij=bipValues.Get(0)
 
 
%Releasing the COM Objects
chemcad.Release;
chemcad=0;
CCAPI=0;
flowsheet=0;

Files:
Download Flash.cc7