function [] = AIChE_Example
%
% Simulis Thermodynamics 
% AIChE 2005 - Cincinnati, OH
% Michel PONS - Alain VACHER
%
% Calculation of dew and bubble temperatures for a water-ethanol mixture
% using a CAPE-OPEN Property Package created with Aspen Properties
%
% 1- Thermodynamic calculator creation
scal = stCALCreate;
% 2- Unit system edition using a standard Simulis dialog
% 2.1- Input unit system edition (atm : calculation pressure)
modified = stCALSystemEdit(scal,1);  
% 2.2- Output unit system edition (°C : dew and bubble temperatures)
modified = stCALSystemEdit(scal,2);
% 3- Thermodynamic calculator edition using another standard Simulis dialog 
%    (CAPE-OPEN Property Package is selected)
modified = stCALEdit(scal);
% 4- Input data
% 4.1- Pressure (atm)
pressure = 1.0;
% 4.2- Composition type (0 = molar, 1 = mass)
typeFrac = 0;
% 4.3- Result type (0 = molar, 1 = mass)
typeRes = 0;
% 4.4- Composition (Range [0,1] on water fraction)
fractions = [0.0 0.0 0.0 0.0];
% 5- Dew and bubble temperatures calculations
for i=1:101,
  ethanolFractions(i) = (i - 1) / 100;  
  fractions(1) = 1 - ethanolFractions(i); 
  fractions(2) = ethanolFractions(i); 
  [dewTemperatures(i)] = stCALDewTemperature(scal,pressure,fractions,typeFrac,typeRes,false);
  [bubbleTemperatures(i)] = stCALBubbleTemperature(scal,pressure,fractions,typeFrac,typeRes,false);
end
% 6- Results plot
hpl = plot(ethanolFractions,dewTemperatures,'-or',...
    ethanolFractions,bubbleTemperatures,'-ob',...
    'LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',5);
title('-  Dew and bubble temperatures (at 1 atm)  -');
xlabel('Ethanol fraction');
ylabel('Temperature (°C)');
grid on;
% 7- Free thermodynamic calculator
stCALFree(scal);