Project

Project 1 - Parsing NASA thermodynamic data

https://drive.google.com/drive/folders/1o9J4OqiJuLMCiqArGn8p--74GeiyFd-f?usp=sharing

All .m files are uploaded in the above link as well as shared using the insert code option.

Main Program

%file testing clear allclose allclcfor k = 0:52line_no(k+1)=6+4*k; %To Locate the line on which the coefficients startendtemp=linspace(300,1500,50); for j=1:53    b = extract_data(line_no(j)); % For extracting coefficients    sph = spheat1(b,temp)    enth = enthalpy1(b,temp)    ent = entropy1(b,temp)     [mol,count(j)] = molecularwt(line_no(j));    mol     plotting(sph,enth,ent,temp,line_no(j),count(j))end

Extract Data Function :- extract_data

function [a] = extract_data(k)f1=fopen('Nasa_file.txt','r');for i=1:k fgetl(f1);  % To set it to line k+1end a = fscanf(f1,'%f',[6 3]);a = a'end

Specific Heat function : spheat1

function [e] = spheat1(a,t)for i=1:50    e(i)=0;endfor s=1:50    if t(s)>=1000for m=1:5   j=m-1;  e(s)=(e(s)+a(1,m)*(t(s)^j));end   e(s)=e(s)*(8.314);    elsefor k=1:5    if k>3        e(s)=(e(s)+a(3,k-3)*(t(s)^(k-1)));    else        e(s) = e(s) + a(2,k+2)*(t(s)^(k-1));    end  ende(s)=e(s)*(8.314);    endendend

Enthalpy function : enthalpy1

function [e] = enthalpy1(a,t)for i=1:50    e(i)=0;endfor j=1:50    if t(j)>=1000        for m=1:5   e(j)=e(j)+(a(1,m)*(t(j)^m))/m ;         end        e(j) = (e(j)+ a(2,1))*8.314 ;     else       for k=1:5    if k>3        e(j)=(e(j)+(a(3,k-3)*(t(2)^(k)))/k);    else        e(j)=e(j) + (a(2,k+2)*(t(2)^k))/k ;    end       end      e(j) = (e(j)+ a(3,3))*8.314 ;     end    endend   

Entropy function : entropy1

function [e] = entropy1(a,t)for i=1:50    e(i)=0;endfor s=1:50    if t(s)>=1000        e(s)= a(1,1)*log(t(s))+a(2,2);for m=1:4    e(s) = e(s) + (a(1,m+1)*(t(1)^m))/m ;ende(s) = e(s)*8.314 ;     else        e(s)= a(2,3)*log(t(s))+a(3,4);        for m=1:4    if m>2        e(s) = e(s) + (a(3,m-2)*(t(s)^m))/m ;     else       e(s) = e(s) +  (a(2,m+3)*(t(s)^m))/m ;     end        end        e(s) = e(s)*8.314 ;     endend     end     

Molecular weight calculation : molecularwt

function [e,c] = molecularwt(l)f1=fopen('Nasa_file.txt','r');e=0;x=0;c=0;for i=1:l-1    fgetl(f1);    endfor j=1:10       ch = fscanf(f1,'%c',[1 1]);        if ch == 'H'            c=c+1;            e=e+x;            x=1;        end        if ch== 'C'            c=c+1;            e=e+x;            x=12;        end            if ch=='O'                c=c+1;                e=e+x;                x=16;            end                if ch=='N'                    c=c+1;                    e=e+x;                    x=14;                end                if ch=='S'                    c=c+1;                    e=e+x;                    x=32;                end                    if ch=='2'                        c=c+1;                            e=e+2*x;                            x=0;                    end                            if ch=='3'                                c=c+1;                                e=e+3*x;                                x=0;                            end                            if ch=='A'                                c=c+2;                                x=40;                                e=e+x;                                x=0;                            end                            if ch=='('                                c=c+1;                            end                            if ch==')'                                c=c+1;                            end                            if ch==' '                                e=e+x;                                break                            end                                                     endend

Plotting and saving graphs in a folder : plotting

function [e] = plotting(sp,h,s,tem,l,c)f1=fopen('Nasa_file.txt','r');for i=1:l-1    fgetl(f1);    end       ch = fscanf(f1,'%c',[1 c]);       subfolder_name = ch;       projectdir = 'C:\Users\teju\Desktop\eDX engine course';      mkdir( fullfile(projectdir, subfolder_name) );            figure(1);      plot(tem,sp);      xlabel('Temperature in K');      ylabel('Specific heat in kJ/(mol K)')      title('Specific heat vs Temp');      savefig(figure(1),[pwd '/',subfolder_name,'/Sp_heat_',ch,'.fig']);           figure(2);      plot(tem,h);      xlabel('Temperature in K');      ylabel('Enthalpy in kJ/(mol)')      title('Enthalpy vs Temp ');      savefig(figure(2),[pwd '/',subfolder_name,'/Enthalpy_',ch,'.fig']);           figure(3);      plot(tem,s);      xlabel('Temperature in K');      ylabel('Entropy in kJ/(mol K)')      title('Entropy vs Temp ');      savefig(figure(3),[pwd '/',subfolder_name,'/Entropy_',ch,'.fig']);end

Here is the screenshot of the files generated

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.