close all;clear all;clc;

%% Examples of experimental data

%Neruchev Y.A., Bolotnikov M.F., Zotov V.V.
%(2005), Investigation of ultrasonic velocity in organic
%liquids on the saturation curve, High temperature, 43,
%266–309.
load expC6H14 %Neruchev1995

%%Zotov V.V., Melikhov Y.F., Mel'nikov G.A.,
%%Neruchev Y.A. (1995), Sound Velocity in Liquid Hy-
%%drocarbons [in Russian], Kursk State Pedagog. Univ.,
%%Kursk.
%load expC6H12 %Zotov1995

Te=data(:,1)+273.15;
ce=data(:,2);

%% Load DIPPR data
% Examples below are created using free sample datasets from https://dippr.aiche.org/

filename='hexane.xls';
%filename='cyclohexane.xls';

%% Import constants for the liquid;
dd=xlsread(filename);

%% Predictive calculations

% Temperature interval for calculations
T=Te;
N=length(T);
% Calculations via different approaches (correlations for the internal pressure: 'S' - modified Srivastava's, 'T' - modified Trouton's rule,
%'L' - based on the heat of vaporization; sosm uses new representation of the isothemal compressibility)
csS=sos(T,'S',dd);
csT=sos(T,'T',dd);
csL=sos(T,'L',dd);
cs=sosm(T,dd);

%% Plots

figure
subplot(1,1,1,'FontSize',22)
% Experimental data
plot(Te,ce,'o')
hold on
% Calculated curves
plot(T,csS,'-','LineWidth',1.5)
plot(T,csT,'-.','color','red','LineWidth',1.5)
plot(T,csL,'--','color','green','LineWidth',1.5)
plot(T,cs,'-','color','black','LineWidth',1.5)
plot((dd(5)+273.15)*[1 1],[min(cs) max(cs)],':','color','black')
xlabel('T, K');ylabel('c, m/s')

%% Saving calculated data to file
out(:,1)=T;
out(:,2)=csS;
out(:,3)=csT;
out(:,4)=csL;
out(:,4)=cs;
csvwrite('out.csv',out);


