%This files reads the data from IntOut.txt and ACDataOut.txt and plots out the Autocorrelation and 
% thermal conductivity.
inData1 = fopen('ACDataOut.txt', 'r');
inData2 = fopen('IntOut.txt', 'r');
data1 = zeros(1,1);
data2 = zeros(1,1);
normalize = 0;
normalizeTime = 0;
% Normalizing the unit time.
unitTime = 2.142*0.002;
t0 = 2.142E-12;
kUnit = 0.030677974;

% First get the number of data sets.
NoSets = fscanf(inData1, '%d', 1);
NoSets = fscanf(inData2, '%d', 1);

AC = zeros(1,NoSets);        % Auto co-relation.
TC = zeros(1,NoSets);        % Thermal conductivity.
t = zeros(1,NoSets);        % Time for all above.

% Read the first line of the data to normalize them.
data = fscanf(inData1, '%d %e', 2);
AC(1,1) = data(2,1)/data(2,1);
t(1,1) = data(1,1)-data(1,1);
normalize = data(2,1);
normalizeTime = data(1,1);
data = fscanf(inData2, '%d %e', 2);
TC(1,1) = data(2,1);

% Now loop to get the rest of the AC & TC data out.
for i = 2:NoSets
  data = fscanf(inData1, '%d %e', 2);
  t(1,i) = data(1,1)-normalizeTime;
  AC(1,i) = data(2,1)/normalize;
  data = fscanf(inData2, '%d %e', 2);
  TC(1,i) = data(2,1);
end;

% Plotting AC vs. #points
subplot(2,1,1); hold on
plot(t*unitTime,AC);
xlabel('Time (ps)');
ylabel('AC');
title('AC vs. Time.');


% Plotting TC vs #points.
subplot(2,1,2); hold on
plot(t*unitTime,TC*kUnit);
xlabel('Time (ps)');
ylabel('K (W/m-K)');
title('Thermal Conductivity K vs. Time.');