Project 1 - Parsing NASA thermodynamic data
Title: Program to equate the thermodynamics properties of the polynomial given in the species of NASA's given sheet.
Explanation:
- The program begins with clear all,close all and clc command which clears out all the balance temporary data.
- The thermodynaic file and the written code is to be saved in thee same folder to aviod the miss match.
- f1 is the file which is to be recalled for parsing so the fopen command is used to open the file by recalling its name and format in preading or writing medium.
- fgetl command is used to get the particular row or column of that specific file which is to be read.
- 'a' is the variable in which the starting three lines are to be saved as some header information which is just alphbets.
- tline contains string which consist of the numeric digits which will be used to analyse the thermodynamic properties of the given species.
- 'A' is the variable which gives the string split command to break the string. The command is break from the blank space input, whichmeans wherever there is a blank space the string will automatically will break.
- The splits are given the names as 'low_temp','mid_temp','high_temp' by converting the string into number with the help of 'str2num' command.
- The fgets(f1) command is to recall all the previous code as the thermo file is saved in f1 variable.
- 'l1' is given a command to scan the file via f1 and specifically 10th row is read whichis a numeric row consisting of species.
- tline1 is the command to finds the given row as a string. further the string too is broken into number of species in a meaningful format which make sence.
- Specifically the E alphabet isseen to be appeared in every specie block.line1 command defines to find the string in tline1 with every 'E' alphabet.which gives the spacing of E in every specific position in row string.
- 'la1' is the variable which gives the input of first string of specie . it can be read as the first specie starts from the origin of the string which will be the starting number till the third digit of string from E.
- This will give us our first specie,but the specie is still a string so for that la1 is further coded into the 'str2num' command which converts the string into the polynomial.
- Further the corresponding specie is read and stored in the variable called as 'la2'. which gives the second polynomial specie.
- tline1 is read as the specie starts from the 4th digit from the first line string cut which is E, so the E for first has extended bt three from E so the beginning of 2nd string will be from the forth digit of the complete string.
- Which will be given as the string begins from the $the digit of the line1 E placement and ends to the thirddigit of the 2nd place E in line1.
- This la2 is still a string which is to be converted into the meaningful polynomial, so the la2 is t=given by the str2n command as earlier done for first specie. It will provide us with the 2nd specie polynomial.
- further the entrie row string is read in the same way but just renaming the formant with the recurring value of E for every specie.
- The second row of the O2 specie is read as string and it is saved in the variable names as 'tline2'. This tline2 contains all the species from line 2 of O2.
- The naming of the species is done as same as for the first line.
- line2 is given as the fing string command to find the breakpont of species and which is break by E again.
- The further program is coded in the same way as done for the first all the species and polynomial are saved in the diffrently named variables.
- Same is done for the line3 and coding format remains the same as done for first 2 rows.
- The CO2 specie format is located in the 66th row of the thermo file so the fgetsl command is used to get the f1 variable which is nothing but the complete thermo file which is stored.
- L2 is given the command to call all the numercail format of the 66th row which is the specie row for CO2.
- tline4 is given with the string on the CO2 format,this line is read and saved in tline4 variable.
- Still tline4 is a string so the line is given as to break in varibles by locating E in the strings.This string is saved in tline4.
- lca1 is the variable in which the first polynomial of the CO2 string will be saved.The code will be given as,in tline4 the specie starts from the first digit till the third digit from there the first E string break is located.
- further lca1 is converted to string as done earlier and same is done for all the species of CO2 and all the polynomials are saved in the meaning variables as coded.
- Further coding of N2 species is done in the same way as done for the O2 and CO2 species and all the polynomials are saved in varibles.
- The code for reading species is given below.
-
clear all close all clc % NASA THERMO file Parsing f1 = fopen('THERMO.txt','r') fgetl(f1) a = fscanf(f1,'%d',3) tline = '300.00 1000.00 5000.00' A = strsplit(tline,' ') low_temp = str2num(A{1}) mid_temp = str2num(A{2}) high_temp = str2num(A{3}); % O2 species fgets(f1) for l1 = fscanf(f1,'%n',10); tline1='3.28253784E+00 1.48308754E-03-7.57966669E-07 2.09470555E-10-2.16717794E-14 2' line1 = findstr(tline1,'E') la1 = tline1(1:line1(1)+3); la1 = str2num(la1); la2 = tline1(line1(1)+4:line1(2)+3); la2 = str2num(la2); la3 = tline1(line1(2)+4:line1(3)+3); la3 = str2num(la3); la4 = tline1(line1(3)+4:line1(4)+3); la4 = str2num(la4); la5 = tline1(line1(4)+4:line1(5)+3); la5 = str2num(la5); tline2 = '-1.08845772E+03 5.45323129E+00 3.78245636E+00-2.99673416E-03 9.84730201E-06 ' line2 = findstr(tline,'E') lb1 = tline2(1:line2(1)+3); lb1 = str2num(lb1); lb2 = tline2(line2(1)+4:line2(2)+3); lb2 = str2num(lb2); lb3 = tline2(line2(2)+4:line2(3)+3); lb3 = str2num(lb3); lb4 = tline2(line2(3)+4:line2(4)+3); lb4 = str2num(lb4); lb5 = tline2(line2(4)+4:line2(5)+3); lb5 = str2num(lb5); tline3 = '-9.68129509E-09 3.24372837E-12-1.06394356E+03 3.65767573E+00 4' line3 = findstr(tline,'E') lc1 = tline3(1:line3(1)+3); lc1 = str2num(lc1) lc2 = tline3(line3(1)+4:line3(2)+3) lc2 = str2num(lc2) lc3 = tline3(line3(2)+4:line3(3)+3) lc3 = str2num(lc3) lc4 = tline3(line3(3)+4:line3(4)+3) lc4 = str2num(lc4) % CO2 Species fgets(f1) l2 = fscanf(f1,'%n',66); tline4=' 3.85746029E+00 4.41437026E-03-2.21481404E-06 5.23490188E-10-4.72084164E-14 2' line4 = findstr(tline4,'E') lca1 = tline4(1:line4(1)+3) lca1 = str2num(lca1) lca2 = tline4(line4(1)+4:line4(2)+3) lca2 = str2num(lca2) lca3 = tline4(line4(2)+4:line4(3)+3) lca3 = str2num(lca3) lca4 = tline4(line4(3)+4:line4(4)+3) lca4 = str2num(lca4) lca5 = tline4(line4(4)+4:line4(5)+3) lca5 = str2num(lca5) tline5 = '-4.87591660E+04 2.27163806E+00 2.35677352E+00 8.98459677E-03-7.12356269E-06 3' line5 = findstr(tline,'E') lcb1= tline5(1:line5(1)+3); lcb1 = str2num(lcb1) lcb2 = tline5(line5(1)+4:line5(2)+3) lcb2 = str2num(lcb2) lcb3 = tline5(line5(2)+4:line5(3)+3) lcb3 = str2num(lcb3) lcb4 = tline2(line5(3)+4:line5(4)+3) lcb4 = str2num(lcb4) lcb5 = tline5(line5(4)+4:line5(5)+3) lcb5 = str2num(lcb5) tline6 = ' 2.45919022E-09-1.43699548E-13-4.83719697E+04 9.90105222E+00 4' line6 = findstr(tline,'E') lcc1 = tline6(1:line6(1)+3); lcc1 = str2num(lcc1) lcc2 = tline6(line6(1)+4:line6(2)+3) lcc2 = str2num(lcc2) lcc3 = tline6(line6(2)+4:line6(3)+3) lcc3 = str2num(lcc3) lcc4 = tline6(line6(3)+4:line6(4)+3) lcc4 = str2num(lcc4) % N2 Species fgets(f1) l3 = fscanf(f1,'%n',160); tline7=' 0.48847542E+01 0.21723956E-02-0.82806906E-06 0.15747510E-09-0.10510895E-13 2' line7 = findstr(tline7,'E') lna1 = tline7(1:line7(1)+3); lna1 = str2num(lna1) lna2 = tline4(line7(1)+4:line7(2)+3) lna2 = str2num(lna2) lna3 = tline7(line7(2)+4:line7(3)+3) lna3 = str2num(lna3) lna4 = tline7(line7(3)+4:line7(4)+3) lna4 = str2num(lna4) lna5 = tline7(line7(4)+4:line7(5)+3) lna5 = str2num(lna5) tline8 = ' 0.23164983E+04-0.11741695E+00 0.39440312E+01-0.15854290E-02 0.16657812E-04 3' line8 = findstr(tline,'E') lnb1= tline8(1:line8(1)+3); lnb1 = str2num(lcb1) lnb2 = tline8(line8(1)+4:line8(2)+3) lnb2 = str2num(lnb2) lnb3 = tline8(line8(2)+4:line8(3)+3) lnb3 = str2num(lnb3) lnb4 = tline8(line8(3)+4:line8(4)+3) lnb4 = str2num(lnb4) lnb5 = tline8(line8(4)+4:line8(5)+3) lnb5 = str2num(lnb5) tline9 = ' -0.20475426E-07 0.78350564E-11 0.28966179E+04 0.63119917E+01 4' line9 = findstr(tline,'E') lnc1 = tline9(1:line9(1)+3); lnc1 = str2num(lnc1) lnc2 = tline9(line9(1)+4:line9(2)+3) lnc2 = str2num(lnc2) lnc3 = tline9(line9(2)+4:line9(3)+3) lnc3 = str2num(lnc3) lnc4 = tline9(line9(3)+4:line9(4)+3) lnc4 = str2num(lnc4); end cp/r = la1+la2*200+la3*200^2+la4*3500^3+la5*1000^4; h/rt = lb1 + lb2*T+lb3*T^2+lb4*T^3+lb5*T^4+a6*T^5; s/r = a1*ln*T+a2T+a3*T^2/2+a4*T^3/3+a5*T^4/4+a7; plot(cp/r,h/rt) xlable('TEMPERATURE') ylable('enthalpy')
- Error Faced DUring Coding :
- Many errors were faced during coding which were resolved as the were some minor mistyping errors.
- passed multiple error while coding which is given below

This error was the final error which was observed ans tried multiple attempts but failed to resolve which did not give the desired out put.