function IRcurve()
% draws spectral curve for IR spectrum

% define foldername
modelfolder = getmodel;

% read model files
InfTable = zeros(1,9);
filename = strcat(modelfolder,'InfTable.txt');
fid = fopen(filename,'r');
InfTable = fscanf(fid,'%i',9);
fclose(fid);
nFreqs = InfTable(9);

Freqs = zeros(nFreqs,1);
filename = strcat(modelfolder,'Freqs.txt');
fid = fopen(filename,'r');
Freqs = fscanf(fid,'%f',nFreqs);
fclose(fid);
% Freqmin = min(Freqs);
% Freqmax = max(Freqs);
% x = (Freqmin - 100):5:(Freqmax + 100);
x = 200:5:3200; % for ciclohex-benzene only
nx = length(x);
x = x';

filename = strcat(modelfolder,'IRSabsint.txt');
load(filename);
II = IRSabsint(:,1);

filename = strcat(modelfolder,'sigma.txt');
load(filename);
a = 1;
sigma = sigma*a;

Dy=zeros(nx,nFreqs);
for j=1:nFreqs
   Dy(:,j)=(II(j)/(2.5*sigma(j)))* ...
       exp(-(0.5/sigma(j)^2)*(x-Freqs(j)).^2);
end %j
y=(sum(Dy'))';
plot(x,y)
grid
xlabel('frequency, inv. cm')
ylabel('optical density')

% for IRcurve0
filename = strcat(modelfolder,'IRcurve0.txt');
fid = fopen(filename,'w');
fprintf(fid,' %f \n',y);
fclose(fid);
filename = strcat(modelfolder,'x0.txt');
fid = fopen(filename,'w');
fprintf(fid,' %f \n',x);
fclose(fid);

function modelfolder = getmodel()
% gets model name in LevInfinite

filename = 'C:\LevInfinite\Config\Molecules.ini';
fid = fopen(filename,'rt');
molfolder = fgetl(fid);
fclose(fid);

filename = 'C:\LevInfinite\Config\ToCalculate.ini';
fid = fopen(filename,'rt');
modelname = fgetl(fid);
fclose(fid);

modelfolder = strcat(molfolder,modelname);
modelfolder = strcat(modelfolder,'\');
